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

Source for file class.sites.php

Documentation is available at class.sites.php

  1. <?php
  2. /**    
  3.  * Logique des sites
  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.sites.php 4006 2007-10-05 11:53:41Z malafosse $
  40.  */
  41.  
  42.  
  43.  
  44. /**
  45.  * Classe de logique des sites
  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 SitesLogic extends Logic 
  61. {
  62.  
  63.     /**
  64.      * Constructeur
  65.      */
  66.     function SitesLogic()
  67.     {
  68.         $this->Logic('sites');
  69.     }
  70.  
  71.     /**
  72.      * Construction des balises select HTML pour cet objet
  73.      *
  74.      * @param array &$context le contexte, tableau passé par référence
  75.      * @param string $var le nom de la variable du select
  76.      */
  77.     function makeSelect(&$context$var)
  78.     {
  79.         switch($var{
  80.         }
  81.     }
  82.  
  83.     /**
  84.      * Bloque un site
  85.      *
  86.      * Met le status d'un site à 32
  87.      *
  88.      * @param array &$context le contexte passé par référence
  89.      * @param array &$error le tableau des erreurs éventuelles passé par référence
  90.      */
  91.     function lockAction(&$context&$error)
  92.     {
  93.         $ret $this->_lockOrUnlock($context['id']'lock');
  94.         return $ret;
  95.     }
  96.  
  97.     /**
  98.      * Débloque un site
  99.      *
  100.      * Met le status d'un site à 1
  101.      *
  102.      * @param array &$context le contexte passé par référence
  103.      * @param array &$error le tableau des erreurs éventuelles passé par référence
  104.      */
  105.     function unlockAction(&$context&$error)
  106.     {
  107.         $ret $this->_lockOrUnlock($context['id'],'unlock');
  108.         return $ret;
  109.     }
  110.  
  111.  
  112.     /**
  113.      * Bloque ou débloque
  114.      *
  115.      * @access private
  116.      * @param integer $id identifiant du site
  117.      * @param string $action lock ou unlock
  118.      */
  119.     function _lockOrUnlock($id$action 'lock')
  120.     {
  121.         global $db;
  122.         if(!$id{
  123.             return '_error';
  124.         }
  125.         $critere " id = '$idAND status > 0";
  126.         usemaindb();
  127.  
  128.         if($action == 'lock'// Verouillage du site
  129.         {
  130.             //bloque les tables
  131.             lock_write ('session''sites');
  132.             // cherche le nom du site
  133.             $dao &getDAO('sites');
  134.             $vo $dao->find($critere'path');
  135.             if (!$vo->path{
  136.                 $context['error'getlodeltextcontent('error_during_lock_site_the_site_may_have_been_deleted''lodeladmin');
  137.                 return '_error';
  138.             }
  139.             // delogue tout le monde sauf l'utilisateur courant
  140.             $db->execute(lq("DELETE FROM #_MTP_session WHERE site='$siteAND iduser!='$iduser'")) or dberror();
  141.             // change le statut du site
  142.             $db->execute(lq("UPDATE #_MTP_sites SET status = 32 WHERE $critere")) or dberror();
  143.             unlock();
  144.  
  145.         else if ($action == 'unlock'// Déverouillage du site
  146.  
  147.             $db->execute(lq("UPDATE #_MTP_sites SET status = 1 WHERE $critere")) or dberror();
  148.             //deverouille les tables
  149.             unlock();
  150.  
  151.         else {
  152.             die();
  153.         }
  154.  
  155.         usecurrentdb();
  156.         require_once 'cachefunc.php';
  157.         clearcache();
  158.         return '_back';
  159.     }
  160.  
  161.     // begin{publicfields} automatic generation  //
  162.  
  163.     /**
  164.      * Retourne la liste des champs publics
  165.      * @access private
  166.      */
  167.     function _publicfields(
  168.     {
  169.         return array('title' => array('text''+'),
  170.                                     'subtitle' => array('text''+'),
  171.                                     'path' => array('text''+'),
  172.                                     'url' => array('text''+'),
  173.                                     'langdef' => array('select'''));
  174.     }
  175.     // end{publicfields} automatic generation  //
  176.  
  177.     // begin{uniquefields} automatic generation  //
  178.  
  179.     // end{uniquefields} automatic generation  //
  180.  
  181. // class 
  182. ?>

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