Source for file class.optiongroups.php
Documentation is available at class.optiongroups.php
* Logique des groupes d'options
* LODEL - Logiciel d'Edition ELectronique.
* Home page: http://www.lodel.org
* E-Mail: lodel@lodel.org
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* @author Ghislain Picard
* @copyright 2001-2002, Ghislain Picard, Marin Dacos
* @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
* @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
* @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
* @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
* @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
* @licence http://www.gnu.org/copyleft/gpl.html
* @since Fichier ajouté depuis la version 0.8
* @version CVS:$Id: class.optiongroups.php 4006 2007-10-05 11:53:41Z malafosse $
* Classe de logique des groupes d'options
* @author Ghislain Picard
* @copyright 2001-2002, Ghislain Picard, Marin Dacos
* @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
* @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
* @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
* @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
* @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
* @licence http://www.gnu.org/copyleft/gpl.html
* @since Classe ajouté depuis la version 0.8
$this->Logic("optiongroups");
* Construction des balises select HTML pour cet objet
* @param array &$context le contexte, tableau passé par référence
* @param string $var le nom de la variable du select
$result= $db->execute(lq("SELECT * FROM #_TP_optiongroups WHERE idparent ". sql_in_array($ids). " ORDER BY rank")) or dberror();
$id= $result->fields['id'];
if ($id!= $context['id']) {
$fullname= $result->fields['title'];
$idparent= $result->fields['idparent'];
if ($idparent) $fullname= $parent[$idparent]. " / ". $fullname;
$d= $rank[$id]= $rank[$idparent]+ ($i* 1.0)/ $l;
$arr["p$d"]= array($id,$fullname);
$arr2= array('0' => '--'); // reorganize the array $arr
$arr2[$row[0]] = $row[1];
* Changement du rang d'un objet
* @param array &$context le contexte passé par référence
* @param array &$error le tableau des erreurs éventuelles passé par référence
* Indique si un objet est protégé en suppression
* Cette méthode indique si un objet, identifié par son identifiant numérique et
* éventuellement son status, ne peut pas être supprimé. Dans le cas où un objet ne serait
* pas supprimable un message est retourné indiquant la cause. Sinon la méthode renvoit le
* @param integer $id identifiant de l'objet
* @param integer $status status de l'objet
* @return false si l'objet n'est pas protégé en suppression, un message sinon
$count = $db->getOne(lq("SELECT count(*) FROM #_TP_options WHERE idgroup='$id' AND status>-64"));
$countgroups = $db->getOne(lq("SELECT count(*) FROM #_TP_optiongroups WHERE idparent='$id' AND status>-64"));
$count = $count + $countgroups;
* Préparation de l'action Edit
* @param object $dao la DAO utilisée
* @param array &$context le context passé par référence
// gather information for the following
if ($context['id']) //it is an edition
$this->oldvo= $dao->getById($context['id']);
die("ERROR: internal error in OptionGroups::_prepareEdit");
if($context['idparent'] != $this->oldvo->idparent) //can't change the parent of an optiongroup !
die("ERROR : Changing the parent of a group is forbidden");
//if it is an add - the optiongroup inherit the exportpolicy
$voparent = $dao->getById($context['idparent'],"id,exportpolicy");
$context['exportpolicy'] = $voparent->exportpolicy;
* Ajout d'un nouvel objet ou Edition d'un objet existant
* Ajout d'un groupe d'option
* @param array &$context le contexte passé par référence
* @param array &$error le tableau des erreurs éventuelles passé par référence
function editAction(&$context, &$error, $clean = false)
* Sauve des données dans des tables liées éventuellement
* Appelé par editAction pour effectuer des opérations supplémentaires de sauvegarde.
* @param object $vo l'objet qui a été créé
* @param array $context le contexte
//if the exportpolicy has been changed update the optiongroups children
$newpolicy = $vo->exportpolicy;
$oldpolicy = $context['exportpolicy'] == 'on' ? 1 : 0;
if($newpolicy != $oldpolicy)
$vos = $dao->findMany("exportpolicy <> '$newpolicy' AND idparent ". sql_in_array($ids),"rank DESC","id,idparent,exportpolicy");
$sqlquery = lq("UPDATE #_TP_optiongroups SET exportpolicy='$newpolicy' WHERE exportpolicy <> '$newpolicy' AND idparent ". sql_in_array($ids));
$ret = $db->execute($sqlquery);
* @param array &$context le contexte passé par référence
* @param array &$error le tableau des erreurs éventuelles passé par référence
// begin{publicfields} automatic generation //
* Retourne la liste des champs publics
return array('idparent' => array('select', '+'),
'name' => array('text', '+'),
'title' => array('text', '+'),
'altertitle' => array('mltext', ''),
'logic' => array('text', ''),
'exportpolicy' => array('boolean', '+'),
'comment' => array('longtext', ''));
// end{publicfields} automatic generation //
// begin{uniquefields} automatic generation //
* Retourne la liste des champs uniques
return array(array('name'), );
// end{uniquefields} automatic generation //
|