Forums

How to publish/unpublish (approve) form submissions?

Contix71 27 Jan, 2015
I have a submission form (about job ads) connected to his database. It is a public form, but I need to monitor the submissions before they go "live" ...

This is what I want to accomplish.

1. User enters form data and submits it (already done with Chronoforms v4)
2. Data goes into the database and admin is notified via email (already done with Chronoforms v4))
3. Data is set to not display in the table until admin approves it (NOT DONE)
4. Admin logs in and approves the data and published the record (NOT DONE)
5. Record displays in table after admin publishes the record AND two emails starts to notify both the user and the admin (NOT DONE)

Basically I just need to add functionality to the system that Joomla uses for everything else to publish/unpublish records in the database. Although I would take a solution for simple approval of the record. It's this possible with Chronoforms? And how?
thanks in advance.
Max_admin 27 Jan, 2015
Hi Contix,

You can do the last 3 points using ChronoConnectivity v5, you will need to have a listing for ALL records, and another which displays only the approved one, the email feature may be tricky to accomplish but can be done once you understand how CC works, we have many tutorials on the FAQs section!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Contix71 28 Jan, 2015
Please, can you link me a tutorial or a FAQ about that you told me? I didn't found it.
Contix71 02 Feb, 2015
Hi Max, I've tryed to do that you told me ("you will need to have a listing for ALL records, and another which displays only the approved one") and I've created 2 DB tables: one connected to my form, made with CFv5, for ALL records (it can be viewed, using CCv5, only by administrators) and another for the public where they can read only the approved records.....but now I need the last step:

How can I do to approve records for showing them in the other db table using CCv5?

Please answer me (or link me) possibly with a tutorial or an example step by step.
thanks in advance
Max_admin 02 Feb, 2015
You should only have 1 table, this table should have a field named "approved", default value set to 0 (type TINYINT), then you can use the "Binary" feature in CC to toggle the approved field between 0 and 1

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Contix71 02 Feb, 2015

You should only have 1 table, this table should have a field named "approved", default value set to 0 (type TINYINT), then you can use the "Binary" feature in CC to toggle the approved field between 0 and 1



Thanks for suggestions......I understand, but how I create this field? With CF or directly in the DB? For that I need, the ideal solution would be a Radio Box (only for admins) with the question "Approved?" and the options YES and NOT, as I've seen on this tutorial:

http://www.chronoengine.com/faqs/72-ccv5/5208-connectivity-edit-with-chronoforms.html

...but for now I couldn't prevent that the articles were published AFTER being approved, not BEFORE! (In CC I've setted all the fields and permissions to be viewed from both admins and public) 😟
Max_admin 02 Feb, 2015
You can add the field using phpmyadmin because Chronoforms can't edit tables after they were created, and for simplicity you can have it as a "binary" field in the list, so you can toggle it directly from the list by one click!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Contix71 05 Feb, 2015

You can add the field using phpmyadmin because Chronoforms can't edit tables after they were created, and for simplicity you can have it as a "binary" field in the list, so you can toggle it directly from the list by one click!



So, I've done all you've said to me:

1) Created the new field "approved" with PHPmyAdmin, default value set to NULL, typed TINYINT;

2) Added new try-submissions with my form connected to that DB table

3) Gone to CC to view the submissions list (Admin view): the field "approved" works because I can put the check mark that turns green.....so, I can approve ONLY THE RECORD I WANT, right?

4) Gone to CC to view the submissions list (Front view): well, I see ALL THE RECORDS, even those I've not approved!!!😟

So.....where I've wrong?😟
Contix71 05 Feb, 2015
Ah, I forgot to add this: after putting the new submission, in the Admin view, I don't view the field "approved" in the new rows, but only in the olds...how so?
Max_admin 05 Feb, 2015
The "Approved" field default value should be set to 0 (zero)

After you do any changes, you must click the "delete cache" button in CC admin area

If the approved field is in the "Binary" fields box then you should see a grey icon when its set to 0 but a green one when its set to 1
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Contix71 05 Feb, 2015

The "Approved" field default value should be set to 0 (zero)

After you do any changes, you must click the "delete cache" button in CC admin area

If the approved field is in the "Binary" fields box then you should see a grey icon when its set to 0 but a green one when its set to 1



Yes, now it works ALMOST all: the grey icon appears to all records and she become green when I click it......but why I continue to view in the frontend ALL records, even if they are not approved?
Max_admin 06 Feb, 2015
You will need to modify the "Conditions" section in the model's area:

<?php
return array("Model.approved" => 1);
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Contix71 06 Feb, 2015

You will need to modify the "Conditions" section in the model's area:


<?php
return array("Model.approved" => 1);



Many thanks Max, your help is really good and indispensable ... but I think that code php missing something, because if I put it in "Conditions" I can't see the submissions either on Admin view and on front view. While I need to see them ONLY on admin view, approve them and show them on front view.

Sorry for my many requests, Max, but I'm not familiar with php.
Max_admin 07 Feb, 2015
You will need to replace the word "Model" with your real model's name, did you try that ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Contix71 07 Feb, 2015

You will need to replace the word "Model" with your real model's name, did you try that ?



Sure, it's the first thing I've done. My model name is "annunci" and this is the PHP code I've replaced:

<?php
return array("annunci.approved" => 1);

But the result is that I've told you: no ads in both admin and front view.

Maybe I must add some other PHP code in the PHP Functions box of Admin list?
Max_admin 07 Feb, 2015
Did you add this code in the "Conditions" box ?

If yes the please enable the "Debug" feature under the frontend/admin listing areas and post the debug statements here.
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Contix71 07 Feb, 2015

Did you add this code in the "Conditions" box ?

If yes the please enable the "Debug" feature under the frontend/admin listing areas and post the debug statements here.



Yes, I did it under "Conditions" box. Now, there is the result of your suggestion (I've enabled the debug in Admin list):

Array
(
[0] => SELECT `Extension`.`id` AS `Extension.id`, `Extension`.`name` AS `Extension.name` FROM `j25_chronoengine_extensions` AS `Extension` WHERE `Extension`.`enabled` = '1' ORDER BY `Extension`.`ordering` ASC
[1] => SELECT `Connection`.`id` AS `Connection.id`, `Connection`.`title` AS `Connection.title`, `Connection`.`params` AS `Connection.params`, `Connection`.`extras` AS `Connection.extras`, `Connection`.`published` AS `Connection.published` FROM `j25_chronoengine_connections` AS `Connection` WHERE `Connection`.`title` = 'INSERZIONI_CERCO-OFFRO_LAVORO' AND `Connection`.`published` = '1'
[2] => SELECT COUNT(`annunci`.`id`) AS `annunci.count` FROM `j25_cf_v5_INSERZIONI_CERCO-OFFRO_LAVORO` AS `annunci` WHERE `annunci`.`approvato` = '1'
[3] => SELECT `annunci`.`id` AS `annunci.id`, `annunci`.`created` AS `annunci.created`, `annunci`.`titolo_inserzione` AS `annunci.titolo_inserzione`, `annunci`.`tipologia` AS `annunci.tipologia`, `annunci`.`categorie_professionali` AS `annunci.categorie_professionali`, `annunci`.`tipo_di_impiego` AS `annunci.tipo_di_impiego`, `annunci`.`nome_azienda_studio` AS `annunci.nome_azienda_studio`, `annunci`.`email_utente` AS `annunci.email_utente`, `annunci`.`inserzione` AS `annunci.inserzione`, `annunci`.`approvato` AS `annunci.approvato` FROM `j25_cf_v5_INSERZIONI_CERCO-OFFRO_LAVORO` AS `annunci` WHERE `annunci`.`approvato` = '1' ORDER BY `annunci`.`id`, `annunci`.`created`, `annunci`.`titolo_inserzione`, `annunci`.`tipologia`, `annunci`.`categorie_professionali`, `annunci`.`tipo_di_impiego`, `annunci`.`nome_azienda_studio`, `annunci`.`email_utente`, `annunci`.`inserzione`, `annunci`.`approvato` LIMIT 30
)
Max_admin 08 Feb, 2015
And does your table has any approved records ? the statements above show that only approved records will be displayed, so if none are approved then none will be displayed!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Contix71 08 Feb, 2015

And does your table has any approved records ? the statements above show that only approved records will be displayed, so if none are approved then none will be displayed!



Perhaps I didn't explain well and I apologize for that....I try to re-explain what it is exactly that I want to happen:

1) A user fills out the form

2) The ads are saved to the database and appear in ChronoConnectivity, which they are showed ONLY in the Admin View, with the tick "approved" empty. Meanwhile the Front View is also EMPTY (no ads showed).

3) The administrator just click on the ads he want to publish and the checkmarks become green.

4) In Front View are showed only the ads that the administrator has published ...

Essentially, I want the same thing that happens in the beckend of Joomla Articles .
From what you told me, now I'm a bit confused and I want to know: WHERE I must approve the articles stored in the database? In CC or CF? It's absolutely right that only approved records will be displayed, but where I can view and approve them without showing them to the public?
Max_admin 09 Feb, 2015
Yes, that's what I understand!

Please copy the code you have now here, then delete it form your conditions box, does the list display as expected ?

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Contix71 09 Feb, 2015

Yes, that's what I understand!
Please copy the code you have now here, then delete it form your conditions box, does the list display as expected ?



Which code do you mean? This one on condition box? (Please, be patient if I don't understand!😉)

<?php
return array("annunci.approvato" => 1);


If this code is in Condtion box, I can't see anything either in Admin View and Front View, but if I delete it, the list display in Admin View is exactly as expected:



BUT in the Front View I can also see ALL submission (and I don't want it):



If I click "approved" in some ads, I can see both the approved and non approved ads (It's that I want):



BUT in the Front View I still see all submissions and not only that 3 I've approved!!



I think it's because there is no more that code... but at this point What I can do? If that code is there (on Condition box) I can't approve ads because I don't see anything, and if isn't there, I can approve but users can see everything!😟
How do I fix it?
Max_admin 09 Feb, 2015
Answer
1 Likes
Well, since you already have 3 records approved, then only you place this code in the "Conditions" box, you should only get the 3 approved records in both admin and front lists.

Then we can add 1 more line of code to check the area, but the problem is that it doesn't display anything at all!

What's the type of the "approvato" field in your database table ?

This is the line of code to check which area is currently active:

<?php
if(GCORE_SITE == "front"){
return array("annunci.approvato" => 1);
}
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Contix71 09 Feb, 2015

This is the line of code to check which area is currently active:


<?php
if(GCORE_SITE == "front"){
return array("annunci.approvato" => 1);
}



YES! YES! YES!!!!!!!!!! THAT'S THE RIGHT CODE!!! NOW ALL IT WORKS CORRECTLY!!!!! 😀 😀 😀 😀

Thank you very much Max, I couldn't never have done this without you....and I thank you also for youy patience with me! 😉

I suggest you to make a tutorial in CCv5 from this topic, because I think that this is a problem common to many CF and CC users (judging by the number of views....)

Thanks again!🙂
This topic is locked and no more replies can be posted.