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

Source for file class.useroptiongroups.php

Documentation is available at class.useroptiongroups.php

  1. <?php
  2. /**    
  3.  * Logique des groupes d'options utilisateur
  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.useroptiongroups.php 4006 2007-10-05 11:53:41Z malafosse $
  40.  */
  41.  
  42.  
  43.  
  44. function humanfieldtype($text)
  45.  
  46. {
  47.   return $GLOBALS['fieldtypes'][$text];
  48. }
  49.  
  50. /***/
  51.  
  52.  
  53.  
  54. /**
  55.  * Classe de logique des groupes d'options utilisateurs
  56.  * 
  57.  * @package lodel/logic
  58.  * @author Ghislain Picard
  59.  * @author Jean Lamy
  60.  * @copyright 2001-2002, Ghislain Picard, Marin Dacos
  61.  * @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
  62.  * @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
  63.  * @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
  64.  * @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
  65.  * @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
  66.  * @licence http://www.gnu.org/copyleft/gpl.html
  67.  * @since Classe ajouté depuis la version 0.8
  68.  * @see logic.php
  69.  */
  70. class UserOptionGroupsLogic extends Logic {
  71.  
  72.     /** Constructor
  73.     */
  74.     function UserOptionGroupsLogic({
  75.         $this->Logic("optiongroups")// UserOptionGroups use the same table as OptionGroups but restrein permitted operations to change the option values.
  76.     }
  77.  
  78.     /**
  79.      * Affichage d'un objet
  80.      *
  81.      * @param array &$context le contexte passé par référence
  82.      * @param array &$error le tableau des erreurs éventuelles passé par référence
  83.      */
  84.     function viewAction(&$context,$error
  85.  
  86.     {
  87.         function loop_useroptions($context,$funcname)
  88.         {
  89.             global $db;
  90.             $result=$db->execute(lq("SELECT * FROM #_TP_options WHERE status > 0 AND idgroup='".$context['id']."' ORDER BY rank,name ")) or dberror();
  91.             while (!$result->EOF{
  92.                 $localcontext=array_merge($context,$result->fields);
  93.                 $name=$result->fields['name'];
  94.                 if ($context[$name]$localcontext['value']=$context[$name];
  95.                     call_user_func("code_do_$funcname",$localcontext);
  96.                 $result->MoveNext();
  97.             }
  98.         }
  99.         return Logic::viewAction($context,$funcname);
  100.     }
  101.  
  102.  
  103.     function editAction(&$context,&$error)
  104.  
  105.     {
  106.         global $lodeluser,$home;
  107.         // get the dao for working with the object
  108.         
  109.         $dao=&getDAO("options");
  110.         $options=$dao->findMany("idgroup='".$context['id']."'","","id,name,type,defaultvalue,userrights");     
  111.         require_once("validfunc.php");
  112.         foreach ($options as $option{
  113.             if ($option->type=="passwd" && !trim($context['data'][$option->name])) continue// empty password means we keep the previous one.
  114.             $valid=validfield($context['data'][$option->name],$option->type,"",$option->name);
  115.             if ($valid===falsedie("ERROR: \"".$option->type."\" can not be validated in UserOptionGroups::editAction.php");
  116.             if ( ($option->type=="file" || $option->type=="image"&& preg_match("/\/tmpdir-\d+\/[^\/]+$/",$context['data'][$option->name]) ) {
  117.                 $dir=dirname($context['data'][$option->name]);
  118.                 rename(SITEROOT.$dir,SITEROOT.preg_replace("/\/tmpdir-\d+$/","/option-".$option->id,$dir));
  119.             }
  120.             if (is_string($valid)) $error[$option->name]=$valid;
  121.         }
  122.  
  123.         if ($errorreturn "_error";
  124.  
  125.         foreach ($options as $option{
  126.             if ($lodeluser['rights'$option->userrightscontinue// the user has not the right to do that.
  127.             if ($option->type=="passwd" && !trim($context['data'][$option->name])) continue// empty password means we keep the previous one.
  128.             if ($option->type!="boolean" && trim($context['data'][$option->name])===""$context['data'][$option->name]=$option->defaultvalue// default value
  129.             $option->value=$context['data'][$option->name];
  130.             if (!$dao->save($option)) die("You don't have the rights to modify this option");
  131.         }
  132.         touch(SITEROOT."CACHE/maj");
  133.         @unlink(SITEROOT."CACHE/options_cache.php");
  134.         return "_back";
  135.     }
  136.  
  137.  
  138.     /**
  139.         * Change rank action
  140.         */
  141.     function copyAction(&$context,&$error)
  142.     {
  143.         die("ERROR: forbidden");
  144.     }
  145.  
  146.     /**
  147.      * Changement du rang d'un objet
  148.      *
  149.      * @param array &$context le contexte passé par référence
  150.      * @param array &$error le tableau des erreurs éventuelles passé par référence
  151.      */
  152.     function changeRankAction(&$context&$error)
  153.     {
  154.         die('ERROR: forbidden');
  155.     }
  156.  
  157.     /**
  158.         * Delete
  159.         */
  160.  
  161.     function deleteAction(&$context,&$error)
  162.     {     
  163.         die("ERROR: forbidden");
  164.     }
  165.  
  166.     /**
  167.      * Construction des balises select HTML pour cet objet
  168.      *
  169.      * @param array &$context le contexte, tableau passé par référence
  170.      * @param string $var le nom de la variable du select
  171.      */
  172.     function makeSelect(&$context$var)
  173.     {
  174.             require_once 'lang.php';
  175.             makeselectlangs($context[$var]);
  176.     }
  177.  
  178.     /*---------------------------------------------------------------*/
  179.     //! Private or protected from this point
  180.     /**
  181.         * @private
  182.         */
  183.  
  184. // class 
  185.  
  186.  
  187. /*-----------------------------------*/
  188. /* loops                             */
  189.  
  190.  
  191.  
  192.  
  193.  
  194. ?>

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