Solution to whom it might interest :
I have created a list/form ("gprh_fabrik_user_training") which enable Training Manager to create training courses and to publish them in front end.
I have replicated this list/form 3 times to enable Training Managers to list / edit their contents :
1. Preparation of Training courses
2. Training courses which are added to the training catalog
3. Training courses which are removed from the training catalog
These forms contain among other a radio button field element called "Status" containing 3 Sub options ("gprh_fabrik_user_training___statut_traitement");
Values
1 | Training course is in preparation / modified -> form shouldn't be published in front end
2 | Training is added to the training catalog -> form can be published in front end
3 | Training is removed from the training catalog -> form shouldn't be published in front end
Training managers can change the status as they wish by editing one of the appropriate form.
I have created a Training enrollment form (gprh_fabrik_user_training) which is accessible in front end via a menu link and enable candidates to enroll to specific training courses. The training related information are displayed in a databasejoin | checkbox | Concat | element.
If there's no Training courses available to enroll for, I need to hide the menu link in front.
So every time a Training course is created or edited by a Training Manager, I need to check if I have got in my "gprh_fabrik_user_training" table at minimum one string which have a Status = 2, if this is the case I will display the menu link, if not I will hide it, since there's no need to publish the enrollment form with no Training courses to enroll for.
So in the following 4 of my 5 forms :
1. Training Creation Form
2. Preparation of Training courses
3. Training courses which are added to the training catalog
4. Training courses which are removed from the training catalog
I have added the PHP Plugin and parameter has followed :
Form 1. Plugin is published in front end, new, after data stored, before calculation (onBeforeCalculations)
Form 2. Plugin is published in front end, edit, after data stored, before calculation (onBeforeCalculations)
Form 3. Plugin is published in front end, edit, after data stored, before calculation (onBeforeCalculations)
Form 4. Plugin is published in front end, edit, after data stored, before calculation (onBeforeCalculations)
PHP code is for these 4 forms :
Code:
$statut = 2;
$menuid = 327;
$unpublished = 0;
$published = 1;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select('COUNT(*)')
->from($db->quoteName('gprh_fabrik_user_training'))
->where($db->quoteName('statut_traitement')." = ".$db->quote($statut));
$db->setQuery($query);
$count = $db->loadResult();
if ($count == 0) {
$query = $db->getQuery(true);
$query = "UPDATE gprh_menu SET published = '$unpublished' WHERE id = '$menuid'";
$db->setQuery($query);
$db->execute();
} else if ($count > 0) {
$query = $db->getQuery(true);
$query = "UPDATE gprh_menu SET published = '$published' WHERE id = '$menuid'";
$db->setQuery($query);
$db->execute();
}
Special thanks to troester and Hugh