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

Source for file class.workshop_com.php

Documentation is available at class.workshop_com.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage workshop
  5.  * @see workshop
  6.  * @author linea21 <info@linea21.com>
  7.  * @version $id SVN
  8.  * @access public
  9.  * @license http://opensource.org/licenses/gpl-3.0.html
  10.  *  Workgroup Forum Management
  11.  */
  12.  
  13. class workshop_com {
  14.   /* @param
  15.    * */
  16.  
  17.   var $TDB_COM = T_WORK_COM// nom de la table.
  18.   var $ID;
  19.   var $SUBJECT;
  20.   var $BODY;
  21.   var $PARENT;
  22.   var $USER_ID;
  23.   var $WORKSHOP_ID;
  24.   var $DATE_CREA;
  25.   var $LAST_MODIFY;
  26.   var $STATUT;
  27.   protected $dispatcher = null;
  28.  
  29.   public function __construct()
  30.   {
  31.     $this->dispatcher = $GLOBALS['dispatcher'];
  32.   }
  33.  
  34.   public function __call($method$arguments)
  35.   {
  36.     $event $this->dispatcher->notifyUntil(new sfEvent($this'workshop_com.extensible_function'array(
  37.       'method'    => $method,
  38.       'arguments' => $arguments
  39.     )));
  40.     if (!$event->isProcessed())
  41.     {
  42.       throw new Exception(sprintf('Call to undefined method %s::%s.'get_class($this)$method));
  43.     }
  44.  
  45.     return $event->getReturnValue();
  46.   }
  47.  
  48.   /**
  49.    * workshop_com::CheckDataIntegrity()
  50.    * Vérification intégrité des données
  51.    *
  52.    * @access public
  53.    * @param array $table contient les composants d'une discussion
  54.    * @return boolean true
  55.    *  si verifié, sinon string 'message d'erreur'
  56.    */
  57.   function CheckDataIntegrity($table$sql_object)
  58.   {
  59.     if (strlen($table[0]3return _t('workshop','com_no_subject');
  60.     if (strlen($table[1]3return _t('workshop','com_no_body');
  61.     return true;
  62.   }
  63.  
  64.   /**
  65.    * workshop_com::AddCom()
  66.    * Ajout d'une nouvelle discussion dans le calendrier
  67.    *
  68.    * @access public
  69.    * @param array $table_com : contient les composants d'une discussion
  70.    * @param object $sql_object 
  71.    * @return integer $last_id
  72.    */
  73.   function AddCom($table_com$sql_object)
  74.   {
  75.     $table_com=$sql_object->DBescape($table_com);
  76.  
  77.     $this->SUBJECT = strip_input(trim($table_com[0]));
  78.     $this->BODY = strip_input(trim($table_com[1]true));
  79.     if ($table_com[2!= ''{
  80.       $this->PARENT_ID $table_com[2];
  81.     else $this->PARENT_ID 0;
  82.     $this->USER_ID = $table_com[3];
  83.     $this->WORKSHOP_ID = $table_com[4];
  84.     $this->STATUT = "P";
  85.  
  86.     if ($this->PARENT_ID == 0{
  87.       $requete "INSERT INTO " $this->TDB_COM . " (workcom_subject, workcom_body, workcom_parent, workcom_user_id, workcom_workshop_id, workcom_statut, workcom_date_crea, workcom_last_modify ) " "VALUES('" $this->SUBJECT . "', '" $this->BODY . "', " $this->PARENT_ID ", " $this->USER_ID . ", " $this->WORKSHOP_ID . ", '" $this->STATUT . "', NOW(), NOW());";
  88.       $last_id $sql_object->DBInsert ($requete1);
  89.     else {
  90.       $requete_root "UPDATE  " $this->TDB_COM . " SET workcom_last_modify=NOW() WHERE workcom_id=" $this->PARENT_ID ";";
  91.       $result_root $sql_object->DBQuery($requete_root);
  92.       $requete "INSERT INTO " $this->TDB_COM . " (workcom_subject, workcom_body, workcom_parent, workcom_user_id, workcom_workshop_id, workcom_statut, workcom_date_crea, workcom_last_modify ) " "VALUES('" $this->SUBJECT . "', '" $this->BODY . "', " $this->PARENT_ID ", " $this->USER_ID . ", " $this->WORKSHOP_ID . ", '" $this->STATUT . "', NOW(), NOW());";
  93.       $last_id $sql_object->DBInsert ($requete1);
  94.     }
  95.     return $last_id;
  96.   }
  97.  
  98.   /**
  99.    * workshop_com::DeleteCom()
  100.    * suppression d'un message
  101.    *
  102.    * @access public
  103.    * @param int $com_id identifiant du message
  104.    * @param int $parent_id identifiant du parent
  105.    * @param object $sql_object 
  106.    * @return bool $result
  107.    */
  108.   function DeleteCom($ID$com_id$parent_id$sql_object)
  109.   {
  110.     if (is_numeric($ID)) {
  111.       $this->ID = $ID;
  112.     else return false;
  113.  
  114.     if ($parent_id == 0{
  115.       $requete_son "SELECT workcom_id FROM " $this->TDB_COM . " WHERE workcom_statut <> 'E' AND workcom_parent=$com_id  AND workcom_workshop_id=$ID";
  116.       echo $requete_son;
  117.       $result_son $sql_object->DBSelect($requete_son);
  118.  
  119.       if ($result_son <> 0{
  120.         $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
  121.         $result $sql_object->DBQuery ($requete);
  122.         for($i 0$i count($result_son)$i++{
  123.           $requete_son_e "UPDATE " $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=" $result_son[$i]['workcom_id'";";
  124.           $result_son_e $sql_object->DBQuery ($requete_son_e);
  125.         }
  126.         return $result;
  127.       else {
  128.         $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
  129.         $result $sql_object->DBQuery ($requete);
  130.         return $result;
  131.       }
  132.     else {
  133.       $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
  134.       $result $sql_object->DBQuery ($requete);
  135.       return $result;
  136.     }
  137.   }
  138.  
  139.   /**
  140.    * workshop_com::LockCom()
  141.    * vérouillage d'un message
  142.    *
  143.    * @access public
  144.    * @param int $ID identifiant du workshop
  145.    * @param int $com_id identifiant du message
  146.    * @param int $parent_id identifiant du message parent
  147.    * @param int $lock 
  148.    * @param object $sql_object 
  149.    * @return bool $result
  150.    */
  151.   function LockCom($ID$com_id$parent_id$lock$sql_object)
  152.   {
  153.     if ($lock == 0$statut 'C';
  154.     else $statut 'P';
  155.  
  156.     if (is_numeric($ID)) {
  157.       $this->ID = $ID;
  158.     else return false;
  159.  
  160.     if ($parent_id == 0{
  161.       $requete_son "SELECT workcom_id FROM " $this->TDB_COM . " WHERE workcom_statut <> 'E' AND workcom_parent=$com_id  AND workcom_workshop_id=$ID";
  162.       $result_son $sql_object->DBSelect($requete_son);
  163.  
  164.       if ($result_son <> 0{
  165.         $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='" $statut "' WHERE workcom_id=$com_id;";
  166.         $result $sql_object->DBQuery ($requete);
  167.         for($i 0$i count($result_son)$i++{
  168.           $requete_son_e "UPDATE " $this->TDB_COM . " SET workcom_statut='" $statut "' WHERE workcom_id=" $result_son[$i]['workcom_id'";";
  169.           $result_son_e $sql_object->DBQuery ($requete_son_e);
  170.         }
  171.         return $result;
  172.       else {
  173.         $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='" $statut "' WHERE workcom_id=$com_id;";
  174.         $result $sql_object->DBQuery ($requete);
  175.         return $result;
  176.       }
  177.     else {
  178.       $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='" $statut "' WHERE workcom_id=$com_id;";
  179.       $result $sql_object->DBQuery ($requete);
  180.       return $result;
  181.     }
  182.   }
  183.  
  184.   /**
  185.    * workshop_com::ModifyCom()
  186.    * modification d'un message
  187.    *
  188.    * @access public
  189.    * @param int $ID identifiant du message
  190.    * @param array $table_com contient les composants d'un message
  191.    * @param object $sql_object 
  192.    * @return bool $result
  193.    */
  194.   function ModifyCom($ID$table_com$sql_object)
  195.   {
  196.     $table_com=$sql_object->DBescape($table_com);
  197.  
  198.     if ($table_com[0!= ''{
  199.       $this->SUBJECT = strip_input(trim($table_com[0]));
  200.     }
  201.     if ($table_com[1!= ''{
  202.       $this->BODY = strip_input(trim($table_com[1]true));
  203.     }
  204.  
  205.     $requete "UPDATE  " $this->TDB_COM . " SET workcom_subject='" $this->SUBJECT . "', workcom_body='" $this->BODY . "' , workcom_last_modify=NOW() WHERE workcom_id=" $ID ";";
  206.     $result $sql_object->DBQuery($requete);
  207.     return $result;
  208.   }
  209.  
  210.   /**
  211.    * workshop_com::ModifyComUser()
  212.    * modification d'un message utilisateur authentifié
  213.    *
  214.    * @access public
  215.    * @param int $ID identifiant du message
  216.    * @param array $table_com contient les composants d'un message
  217.    * @param int $user_id identifiant de l'utilisateur
  218.    * @param object $sql_object 
  219.    * @return bool $result
  220.    */
  221.   function ModifyComUser($ID$table_com$user_id$sql_object)
  222.   {
  223.     $table_com=$sql_object->DBescape($table_com);
  224.  
  225.     if ($table_com[0!= ''{
  226.       $this->SUBJECT = strip_input(trim($table_com[0]));
  227.     }
  228.     if ($table_com[1!= ''{
  229.       $this->BODY = strip_input(trim($table_com[1]true));
  230.     }
  231.     $result_user $this->_CheckUser($sql_object$ID);
  232.     if ($result_user <> $user_id{
  233.       $result _t('workshop','not_author');
  234.     else {
  235.       $requete "UPDATE  " $this->TDB_COM . " SET workcom_subject='" $this->SUBJECT . "', workcom_body='" $this->BODY . "' , workcom_last_modify=NOW() WHERE workcom_id=" $ID ";";
  236.       $result $sql_object->DBQuery($requete);
  237.     }
  238.     return $result;
  239.   }
  240.  
  241.   /**
  242.    * workshop_com::_CheckUser()
  243.    * obtention de l'id d'un auteur de message
  244.    *
  245.    * @param object $sql_object 
  246.    * @param integer $mes_id 
  247.    * @return id_utilisateur $result[0]['workcom_user_id']
  248.    */
  249.   function _CheckUser($sql_object$mes_id = -1)
  250.   {
  251.     if ($mes_id <> -1{
  252.       $requete "SELECT  workcom_user_id FROM " $this->TDB_COM . " WHERE workcom_id=" $mes_id ";";
  253.     }
  254.     $result $sql_object->DBSelect($requete);
  255.     return $result[0]['workcom_user_id'];
  256.   }
  257. }
  258.  
  259. ?>

Documentation generated on Fri, 01 Apr 2011 09:29:42 +0200 by phpDocumentor 1.4.1