linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file class.level.php

Documentation is available at class.level.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage level
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  *  Level Management
  10.  */
  11.  
  12. class level {
  13.   /* @param
  14.    * */
  15.   var $TDB_LEVEL = T_LEVEL// nom de la table.
  16.   var $URI_INPUT = "level/visual/"// dossier racine de stockage des photos
  17.   var $ID;
  18.   var $NAME;
  19.   var $DESCRIPTION;
  20.   var $COMMENT;
  21.   var $VISUAL_URI;
  22.   var $RANGE;
  23.   var $DATE_CREA;
  24.   var $STATUT;
  25.   var $LAST_MODIFY;
  26.  
  27.   var $UPLOAD_MAX_MO = UPLOAD_MAX_MO// taille maximale d'upload des photos en octets
  28.   var $MAX_PHOTO_MAX_WIDTH = 50;
  29.   var $MAX_PHOTO_MIN_WIDTH = 50;
  30.   protected $dispatcher = null;
  31.  
  32.   public function __construct()
  33.   {
  34.     $this->dispatcher = $GLOBALS['dispatcher'];
  35.   }
  36.  
  37.   public function __call($method$arguments)
  38.   {
  39.     $event $this->dispatcher->notifyUntil(new sfEvent($this'level.extensible_function'array(
  40.       'method'    => $method,
  41.       'arguments' => $arguments
  42.     )));
  43.     if (!$event->isProcessed())
  44.     {
  45.       throw new Exception(sprintf('Call to undefined method %s::%s.'get_class($this)$method));
  46.     }
  47.  
  48.     return $event->getReturnValue();
  49.   }
  50.  
  51.  
  52.   /**
  53.    * level::CheckDataIntegrity()
  54.    * vérifie l'integrité des données d'un niveau
  55.    *
  56.    * @access public
  57.    * @param array $table_level : contient les composants d'un niveau
  58.    * @param object $sql_object 
  59.    * @return boolean true
  60.    *  si verifié, sinon string 'message d'erreur'
  61.    */
  62.   function CheckDataIntegrity($table_level)
  63.   {
  64.       // Filter data event + return value
  65.       $r $this->dispatcher->filter(new sfEvent($this'level.before_datacheck'array('data' => $table_level))$table_level);
  66.       $table_level $r->getReturnValue();
  67.       
  68.     if (strlen($table_level[0]2return _t('level','object_notdenomination');
  69.     
  70.     // Notify the beginning of the current method
  71.     $this->dispatcher->notify(new sfEvent($this'level.after_datacheck'array('data' => $table_level)));
  72.  
  73.     return true;
  74.   }
  75.  
  76.   /**
  77.    * level::AddLevel()
  78.    * Ajout d'un niveau
  79.    *
  80.    * @access public
  81.    * @param array $table_level contient les composants d'un niveau
  82.    * @param object $sql_object 
  83.    * @return integer $last_id
  84.    */
  85.   function AddLevel($table_level$sql_object)
  86.   {
  87.       
  88.       // Filter data event + return value
  89.       $r $this->dispatcher->filter(new sfEvent($this'level.before_add'array('data' => $table_level))$table_level);
  90.       $table_level $r->getReturnValue();
  91.       
  92.     $table_level=$sql_object->DBescape($table_level);
  93.     if ($table_level[0!= ''{
  94.       $this->NAME = strip_input($table_level[0]);
  95.     }
  96.     if ($table_level[1!= ''{
  97.       $this->DESCRIPTION = strip_input($table_level[1]true);
  98.     }
  99.     $this->COMMENT = strip_input($table_level[2]true);
  100.  
  101.     $this->VISUAL_URI = strip_input($table_level[3]);
  102.  
  103.     if (is_numeric($table_level[4])) {
  104.       $this->RANGE = $table_level[4];
  105.     }
  106.     if ($table_level[5!= ''{
  107.       strtoupper($table_level[5]);
  108.       switch ($table_level[5]{
  109.         case 'P':
  110.           $this->STATUT = $table_level[5];
  111.           break;
  112.         case 'D':
  113.           $this->STATUT = $table_level[5];
  114.           break;
  115.         default:
  116.           $this->STATUT = 'P';
  117.           break;
  118.       }
  119.     else $this->STATUT = 'P';
  120.  
  121.     $q "INSERT INTO " $this->TDB_LEVEL . " (level_name, level_description, level_comment, level_visual_identity, " "level_range, level_statut, level_date_crea) " "VALUES('" $this->NAME . "', '" $this->DESCRIPTION . "', '" $this->COMMENT . "', '" $this->VISUAL_URI . "', " $this->RANGE . ", '" $this->STATUT . "', NOW());";
  122.     $last_id $sql_object->DBInsert ($q1);
  123.     
  124.     // Notify the end of the current method
  125.     $this->dispatcher->notify(new sfEvent($this'level.after_add'array('data' => $table_level'id' => $last_id)));
  126.     
  127.     return $last_id;
  128.   }
  129.  
  130.   /**
  131.    * level::ModifyLevel()
  132.    * modification d'un niveau
  133.    *
  134.    * @access public
  135.    * @param int $id identifiant niveau a modifier
  136.    * @param array $table_level contient les composants d'un niveau
  137.    * @param object $sql_object 
  138.    * @return bool $result
  139.    */
  140.   function ModifyLevel($ID$table_level$sql_object)
  141.   {
  142.       // Filter data event + return value
  143.       $r $this->dispatcher->filter(new sfEvent($this'level.before_modify'array('data' => $table_level'id' => $ID))$table_level);
  144.       $table_level $r->getReturnValue();
  145.       
  146.     $table_level=$sql_object->DBescape($table_level);
  147.     if (is_numeric($ID)) {
  148.       $this->ID = $ID;
  149.     }
  150.     if ($table_level[0!= ''{
  151.       $this->NAME = strip_input($table_level[0]);
  152.     }
  153.     if ($table_level[1!= ''{
  154.       $this->DESCRIPTION = strip_input($table_level[1]true);
  155.     }
  156.     $this->COMMENT = strip_input($table_level[2]true);
  157.  
  158.     $this->VISUAL_URI = strip_input($table_level[3]);
  159.  
  160.     if (is_numeric($table_level[4])) {
  161.       $this->RANGE = $table_level[4];
  162.     }
  163.     if ($table_level[5!= ''{
  164.       strtoupper($table_level[5]);
  165.       switch ($table_level[5]{
  166.         case 'P':
  167.           $this->STATUT = $table_level[5];
  168.           break;
  169.         case 'D':
  170.           $this->STATUT = $table_level[5];
  171.           break;
  172.         default:
  173.           $this->STATUT = 'P';
  174.           break;
  175.       }
  176.     else $this->STATUT = 'P';
  177.  
  178.     $q "UPDATE  " $this->TDB_LEVEL . " set level_name='" $this->NAME . "', level_description='" $this->DESCRIPTION . "' , level_comment='" $this->COMMENT . "', level_visual_identity='" $this->VISUAL_URI . "',level_range=" $this->RANGE . ", level_statut='" $this->STATUT . "', level_last_modify=NOW() WHERE level_id=" $this->ID . ";";
  179.     $result $sql_object->DBQuery($q);
  180.     
  181.     // Notify the end of the current method
  182.     $this->dispatcher->notify(new sfEvent($this'level.after_modify'array('data' => $table_level'id' => $this->ID)));
  183.     
  184.     return $result;
  185.   }
  186.  
  187.   /**
  188.    * level::StateLevel()
  189.    * modification du statut d'un niveau
  190.    * -- NE PREND PAS EN CHARGE l'EFFACEMENT --
  191.    *
  192.    * @access public
  193.    * @param int $ID identifiant du niveau
  194.    * @param string $state 'P' Public | 'D' Draft/
  195.    * @param object $sql_object 
  196.    * @return bool $result
  197.    */
  198.   function StateLevel($ID$state$sql_object)
  199.   {
  200.       
  201.       // Notify the end of the current method
  202.       $this->dispatcher->notify(new sfEvent($this'level.change_state'array('id' => $ID'state' => $state)));
  203.       
  204.     $this->ID = $ID;
  205.     strtoupper($state);
  206.     switch ($state{
  207.       case 'P':
  208.         $this->STATUT = $state;
  209.         break;
  210.       case 'D':
  211.         $this->STATUT = $state;
  212.         break;
  213.       default:
  214.         $this->STATUT = 'P';
  215.         break;
  216.     }
  217.     $q "UPDATE  " $this->TDB_LEVEL . " set level_statut='" $this->STATUT . "' WHERE level_id=" $this->ID . ";";
  218.     $result $sql_object->DBQuery($q);
  219.     return $result;
  220.   }
  221.  
  222.   /**
  223.    * level::DeleteLevel()
  224.    * suppression d'un niveau
  225.    *  -- NON IMPLEMENTEE/NON TESTEE DANS L'APPLICATION --
  226.    *
  227.    * @access public
  228.    * @param int $ID identifiant du niveau
  229.    * @param object $sql_object 
  230.    * @param string $type type : 'MASS_DELETE' toutes les ressources associées à l'échelle sont rendues inactives
  231.    *  'MASS_MODIFY' remplacement de l'ancienne échelle par $ID_new
  232.    * @param int $ID_new identifiant du nouveau niveau a rattacher
  233.    * @return object $affected
  234.    */
  235.  
  236.   function DeleteLevel($ID$sql_object$type$ID_new = -1)
  237.   {
  238.     $affected 0;
  239.     if (is_numeric($ID)) {
  240.       $this->ID = $ID;
  241.     }
  242.     
  243.     // Notify the end of the current method
  244.     $this->dispatcher->notify(new sfEvent($this'level.delete'array('id' => $ID'type' => $type'new_id' => $ID_new)));
  245.     
  246.     if ($type == 'MASS_MODIFY'{
  247.       if ($ID_new != -&& is_numeric($ID_new)) {
  248.         $q "UPDATE  " $this->TDB_LEVEL . " set level_statut='E', level_last_modify=NOW() WHERE level_id=" $this->ID . ";";
  249.         $result $sql_object->DBQuery($q);
  250.         if ($result == true{
  251.           $q_news "UPDATE  " T_NEWS " set news_level=" $ID_new " WHERE  news_level=" $this->ID . ";";
  252.           $result $sql_object->DBQuery($q_news);
  253.           $affected += $sql_object->DBaffectedRow();
  254.           $q_publication "UPDATE  " T_PUBLI " set publi_level=" $ID_new " WHERE  publi_level=" $this->ID . ";";
  255.           $result $sql_object->DBQuery($q_publication);
  256.           $affected += $sql_object->DBaffectedRow();
  257.         }
  258.       }
  259.     }
  260.     
  261.     if ($type == 'MASS_DELETE'{
  262.       $q "UPDATE  " $this->TDB_LEVEL . " set level_statut='E', level_last_modify=NOW() WHERE level_id=" $this->ID . ";";
  263.       $result $sql_object->DBQuery($q);
  264.       if ($result == true{
  265.         $q_news "UPDATE  " T_NEWS " set news_statut='E' WHERE  news_level=" $this->ID . ";";
  266.         $result $sql_object->DBQuery($q_news);
  267.         $affected += $sql_object->DBaffectedRow();
  268.         $q_publication "UPDATE  " T_PUBLI " set publi_statut='E' WHERE  publi_level=" $this->ID . ";";
  269.         $result $sql_object->DBQuery($q_publication);
  270.         $affected += $sql_object->DBaffectedRow();
  271.       }
  272.     }
  273.     
  274.     return $affected;
  275.   }
  276.  
  277.  
  278. }
  279.  
  280. ?>

Documentation generated on Thu, 20 Mar 2014 16:46:12 +0100 by phpDocumentor 1.4.1