phpDocumentor lodel-logic
[ class tree: lodel-logic ] [ index: lodel-logic ] [ all elements ]

Source for file class.persontypes.php

Documentation is available at class.persontypes.php

  1. <?php
  2. /**    
  3.  * Logique des types de personnes
  4.  *
  5.  * PHP versions 4 et 5
  6.  *
  7.  * LODEL - Logiciel d'Edition ELectronique.
  8.  *
  9.  * Home page: http://www.lodel.org
  10.  * E-Mail: lodel@lodel.org
  11.  *
  12.  * All Rights Reserved
  13.  *
  14.  * This program is free software; you can redistribute it and/or modify
  15.  * it under the terms of the GNU General Public License as published by
  16.  * the Free Software Foundation; either version 2 of the License, or
  17.  * (at your option) any later version.
  18.  *
  19.  * This program is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.  * GNU General Public License for more details.
  23.  *
  24.  * You should have received a copy of the GNU General Public License
  25.  * along with this program; if not, write to the Free Software
  26.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27.  *
  28.  * @package lodel/logic
  29.  * @author Ghislain Picard
  30.  * @author Jean Lamy
  31.  * @copyright 2001-2002, Ghislain Picard, Marin Dacos
  32.  * @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
  33.  * @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
  34.  * @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
  35.  * @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
  36.  * @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
  37.  * @licence http://www.gnu.org/copyleft/gpl.html
  38.  * @since Fichier ajouté depuis la version 0.8
  39.  * @version CVS:$Id: class.persontypes.php 4006 2007-10-05 11:53:41Z malafosse $
  40.  */
  41.  
  42.  
  43.  
  44. /**
  45.  * Classe de logique des types de personnes
  46.  * 
  47.  * @package lodel/logic
  48.  * @author Ghislain Picard
  49.  * @author Jean Lamy
  50.  * @copyright 2001-2002, Ghislain Picard, Marin Dacos
  51.  * @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
  52.  * @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
  53.  * @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
  54.  * @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
  55.  * @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
  56.  * @licence http://www.gnu.org/copyleft/gpl.html
  57.  * @since Classe ajouté depuis la version 0.8
  58.  * @see logic.php
  59.  */
  60. class PersonTypesLogic extends Logic
  61. {
  62.  
  63.     /**
  64.      * Constructeur
  65.      */
  66.     function PersonTypesLogic(
  67.     {
  68.         $this->Logic("persontypes");
  69.     }
  70.  
  71.     /**
  72.     *  Indique si un objet est protégé en suppression
  73.     *
  74.     * Cette méthode indique si un objet, identifié par son identifiant numérique et
  75.     * éventuellement son status, ne peut pas être supprimé. Dans le cas où un objet ne serait
  76.     * pas supprimable un message est retourné indiquant la cause. Sinon la méthode renvoit le
  77.     * booleen false.
  78.     *
  79.     * @param integer $id identifiant de l'objet
  80.     * @param integer $status status de l'objet
  81.     * @return false si l'objet n'est pas protégé en suppression, un message sinon
  82.     */
  83.     function isdeletelocked($id,$status=0
  84.  
  85.     {
  86.         global $db;
  87.         $count=$db->getOne(lq("SELECT count(*) FROM #_TP_persons WHERE idtype='$idAND status>-64"));
  88.         if ($db->errorno())  dberror();
  89.         if ($count==0{
  90.             return false;
  91.         else {
  92.             return sprintf(getlodeltextcontents("cannot_delete_hasperson","admin"),$count);
  93.         }
  94.     }
  95.  
  96.     /**
  97.      * Construction des balises select HTML pour cet objet
  98.      *
  99.      * @param array &$context le contexte, tableau passé par référence
  100.      * @param string $var le nom de la variable du select
  101.      */
  102.     function makeSelect(&$context$var)
  103.  
  104.     {
  105.         switch($var{
  106.         case 'gui_user_complexity' :
  107.             require_once 'commonselect.php';
  108.             makeSelectGuiUserComplexity($context['gui_user_complexity']);
  109.             break;
  110.         case 'g_type' :
  111.             require_once 'fieldfunc.php';
  112.             $g_typefields $GLOBALS['g_persontypes_fields'];
  113.             $dao=$this->_getMainTableDAO();
  114.             $types $dao->findMany('status > 0''''g_type, title');
  115.             foreach($types as $type){
  116.                 $arr[$type->g_type$type->title;
  117.             }
  118.  
  119.             $arr2 array('' => '--');
  120.             foreach($g_typefields as $g_type{
  121.                 $lg_type=strtolower($g_type);
  122.                 if ($arr[$lg_type]{
  123.                     $arr2[$lg_type]=$g_type." &rarr; ".$arr[$lg_type];
  124.                 else {
  125.                     $arr2[$lg_type]=$g_type;
  126.                 }
  127.             }
  128.             renderOptions($arr2,$context['g_type']);
  129.             break;
  130.         }
  131.     }
  132.  
  133.     /**
  134.     * Préparation de l'action Edit
  135.     *
  136.     * @access private
  137.     * @param object $dao la DAO utilisée
  138.     * @param array &$context le context passé par référence
  139.     */
  140.     function _prepareEdit($dao,&$context)
  141.  
  142.     {
  143.         // gather information for the following
  144.         if ($context['id']{
  145.             $this->oldvo=$dao->getById($context['id']);
  146.             if (!$this->oldvodie("ERROR: internal error in PersonTypesLogic::_prepareEdit");
  147.         }
  148.     }
  149.  
  150.  
  151.     /**
  152.     * Sauve des données dans des tables liées éventuellement
  153.     *
  154.     * Appelé par editAction pour effectuer des opérations supplémentaires de sauvegarde.
  155.     *
  156.     * @param object $vo l'objet qui a été créé
  157.     * @param array $context le contexte
  158.     */
  159.         function _saveRelatedTables($vo,$context
  160.  
  161.     {
  162.         #print_r($vo);
  163.         #print_r($this->oldvo);
  164.  
  165.         if ($vo->type!=$this->oldvo->type{
  166.             // name has changed
  167.             $GLOBALS['db']->execute(lq("UPDATE #_TP_tablefields SET name='".$vo->type."' WHERE name='".$this->oldvo->type."' AND type='persons'")) or dberror();
  168.         }
  169.     }
  170.     /**
  171.     * Appelé avant l'action delete
  172.     *
  173.     * Cette méthode est appelée avant l'action delete pour effectuer des vérifications
  174.     * préliminaires à une suppression.
  175.     *
  176.     * @param object $dao la DAO utilisée
  177.     * @param array &$context le contexte passé par référénce
  178.     */
  179.     function _prepareDelete($dao,&$context)
  180.  
  181.     {     
  182.         // gather information for the following
  183.         $this->vo=$dao->getById($context['id']);
  184.         if (!$this->vodie("ERROR: internal error in PersonTypesLogic::_prepareDelete");
  185.     }
  186.  
  187.     function _deleteRelatedTables($id{
  188.         global $home;
  189.  
  190.         //require_once("typetypefunc.php"); 
  191.         //typetype_delete("persontype","idpersontype='".$id."'");
  192.             
  193.         $dao=&getDAO("tablefields");
  194.         $dao->delete("type='persons' AND name='".$this->vo->type."'");
  195.     }
  196.  
  197.  
  198.     // begin{publicfields} automatic generation  //
  199.  
  200.     /**
  201.      * Retourne la liste des champs publics
  202.      * @access private
  203.      */
  204.     function _publicfields(
  205.     {
  206.         return array('type' => array('type''+'),
  207.                                     'class' => array('class''+'),
  208.                                     'title' => array('text''+'),
  209.                                     'altertitle' => array('mltext'''),
  210.                                     'icon' => array('image'''),
  211.                                     'gui_user_complexity' => array('select''+'),
  212.                                     'g_type' => array('select'''),
  213.                                     'style' => array('style'''),
  214.                                     'tpl' => array('tplfile'''),
  215.                                     'tplindex' => array('tplfile'''));
  216.     }
  217.     // end{publicfields} automatic generation  //
  218.  
  219.     // begin{uniquefields} automatic generation  //
  220.  
  221.     /**
  222.      * Retourne la liste des champs uniques
  223.      * @access private
  224.      */
  225.     function _uniqueFields(
  226.     
  227.         return array(array('type'));
  228.     }
  229.     // end{uniquefields} automatic generation  //
  230.  
  231.  
  232. // class 
  233.  
  234.  
  235. /*-----------------------------------*/
  236. /* loops                             */
  237.  
  238. function loop_entitytypes($context,$funcname)
  239. require_once("typetypefunc.php")
  240.     loop_typetable ("entitytype","persontype",$context,$funcname,$_POST['edit'$context['entitytype': -1);}
  241.  
  242.  
  243.  
  244.  
  245. ?>

Documentation generated on Thu, 24 Jul 2008 05:08:03 +0200 by phpDocumentor 1.4.0a2