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.  
  28.   /**
  29.    * workshop_com::CheckDataIntegrity()
  30.    * Vérification intégrité des données
  31.    *
  32.    * @access public
  33.    * @param array $table contient les composants d'une discussion
  34.    * @return boolean true
  35.    *  si verifié, sinon string 'message d'erreur'
  36.    */
  37.   function CheckDataIntegrity($table$sql_object)
  38.   {
  39.     if (strlen($table[0]3return _t('workshop','com_no_subject');
  40.     if (strlen($table[1]3return _t('workshop','com_no_body');
  41.     return true;
  42.   }
  43.  
  44.   /**
  45.    * workshop_com::AddCom()
  46.    * Ajout d'une nouvelle discussion dans le calendrier
  47.    *
  48.    * @access public
  49.    * @param array $table_com : contient les composants d'une discussion
  50.    * @param object $sql_object 
  51.    * @return integer $last_id
  52.    */
  53.   function AddCom($table_com$sql_object)
  54.   {
  55.     $table_com=$sql_object->DBescape($table_com);
  56.  
  57.     $this->SUBJECT = strip_input(trim($table_com[0]));
  58.     $this->BODY = strip_input(trim($table_com[1]true));
  59.     if ($table_com[2!= ''{
  60.       $this->PARENT_ID $table_com[2];
  61.     else $this->PARENT_ID 0;
  62.     $this->USER_ID = $table_com[3];
  63.     $this->WORKSHOP_ID = $table_com[4];
  64.     $this->STATUT = "P";
  65.  
  66.     if ($this->PARENT_ID == 0{
  67.       $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());";
  68.       $last_id $sql_object->DBInsert ($requete1);
  69.     else {
  70.       $requete_root "UPDATE  " $this->TDB_COM . " SET workcom_last_modify=NOW() WHERE workcom_id=" $this->PARENT_ID ";";
  71.       $result_root $sql_object->DBQuery($requete_root);
  72.       $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());";
  73.       $last_id $sql_object->DBInsert ($requete1);
  74.     }
  75.     return $last_id;
  76.   }
  77.  
  78.   /**
  79.    * workshop_com::DeleteCom()
  80.    * suppression d'un message
  81.    *
  82.    * @access public
  83.    * @param int $com_id identifiant du message
  84.    * @param int $parent_id identifiant du parent
  85.    * @param object $sql_object 
  86.    * @return bool $result
  87.    */
  88.   function DeleteCom($ID$com_id$parent_id$sql_object)
  89.   {
  90.     if (is_numeric($ID)) {
  91.       $this->ID = $ID;
  92.     else return false;
  93.  
  94.     if ($parent_id == 0{
  95.       $requete_son "SELECT workcom_id FROM " $this->TDB_COM . " WHERE workcom_statut <> 'E' AND workcom_parent=$com_id  AND workcom_workshop_id=$ID";
  96.       echo $requete_son;
  97.       $result_son $sql_object->DBSelect($requete_son);
  98.  
  99.       if ($result_son <> 0{
  100.         $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
  101.         $result $sql_object->DBQuery ($requete);
  102.         for($i 0$i count($result_son)$i++{
  103.           $requete_son_e "UPDATE " $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=" $result_son[$i]['workcom_id'";";
  104.           $result_son_e $sql_object->DBQuery ($requete_son_e);
  105.         }
  106.         return $result;
  107.       else {
  108.         $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
  109.         $result $sql_object->DBQuery ($requete);
  110.         return $result;
  111.       }
  112.     else {
  113.       $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='E' WHERE workcom_id=$com_id;";
  114.       $result $sql_object->DBQuery ($requete);
  115.       return $result;
  116.     }
  117.   }
  118.  
  119.   /**
  120.    * workshop_com::LockCom()
  121.    * vérouillage d'un message
  122.    *
  123.    * @access public
  124.    * @param int $ID identifiant du workshop
  125.    * @param int $com_id identifiant du message
  126.    * @param int $parent_id identifiant du message parent
  127.    * @param int $lock 
  128.    * @param object $sql_object 
  129.    * @return bool $result
  130.    */
  131.   function LockCom($ID$com_id$parent_id$lock$sql_object)
  132.   {
  133.     if ($lock == 0$statut 'C';
  134.     else $statut 'P';
  135.  
  136.     if (is_numeric($ID)) {
  137.       $this->ID = $ID;
  138.     else return false;
  139.  
  140.     if ($parent_id == 0{
  141.       $requete_son "SELECT workcom_id FROM " $this->TDB_COM . " WHERE workcom_statut <> 'E' AND workcom_parent=$com_id  AND workcom_workshop_id=$ID";
  142.       $result_son $sql_object->DBSelect($requete_son);
  143.  
  144.       if ($result_son <> 0{
  145.         $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='" $statut "' WHERE workcom_id=$com_id;";
  146.         $result $sql_object->DBQuery ($requete);
  147.         for($i 0$i count($result_son)$i++{
  148.           $requete_son_e "UPDATE " $this->TDB_COM . " SET workcom_statut='" $statut "' WHERE workcom_id=" $result_son[$i]['workcom_id'";";
  149.           $result_son_e $sql_object->DBQuery ($requete_son_e);
  150.         }
  151.         return $result;
  152.       else {
  153.         $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='" $statut "' WHERE workcom_id=$com_id;";
  154.         $result $sql_object->DBQuery ($requete);
  155.         return $result;
  156.       }
  157.     else {
  158.       $requete "UPDATE " $this->TDB_COM . " SET workcom_statut='" $statut "' WHERE workcom_id=$com_id;";
  159.       $result $sql_object->DBQuery ($requete);
  160.       return $result;
  161.     }
  162.   }
  163.  
  164.   /**
  165.    * workshop_com::ModifyCom()
  166.    * modification d'un message
  167.    *
  168.    * @access public
  169.    * @param int $ID identifiant du message
  170.    * @param array $table_com contient les composants d'un message
  171.    * @param object $sql_object 
  172.    * @return bool $result
  173.    */
  174.   function ModifyCom($ID$table_com$sql_object)
  175.   {
  176.     $table_com=$sql_object->DBescape($table_com);
  177.  
  178.     if ($table_com[0!= ''{
  179.       $this->SUBJECT = strip_input(trim($table_com[0]));
  180.     }
  181.     if ($table_com[1!= ''{
  182.       $this->BODY = strip_input(trim($table_com[1]true));
  183.     }
  184.  
  185.     $requete "UPDATE  " $this->TDB_COM . " SET workcom_subject='" $this->SUBJECT . "', workcom_body='" $this->BODY . "' , workcom_last_modify=NOW() WHERE workcom_id=" $ID ";";
  186.     $result $sql_object->DBQuery($requete);
  187.     return $result;
  188.   }
  189.  
  190.   /**
  191.    * workshop_com::ModifyComUser()
  192.    * modification d'un message utilisateur authentifié
  193.    *
  194.    * @access public
  195.    * @param int $ID identifiant du message
  196.    * @param array $table_com contient les composants d'un message
  197.    * @param int $user_id identifiant de l'utilisateur
  198.    * @param object $sql_object 
  199.    * @return bool $result
  200.    */
  201.   function ModifyComUser($ID$table_com$user_id$sql_object)
  202.   {
  203.     $table_com=$sql_object->DBescape($table_com);
  204.  
  205.     if ($table_com[0!= ''{
  206.       $this->SUBJECT = strip_input(trim($table_com[0]));
  207.     }
  208.     if ($table_com[1!= ''{
  209.       $this->BODY = strip_input(trim($table_com[1]true));
  210.     }
  211.     $result_user $this->_CheckUser($sql_object$ID);
  212.     if ($result_user <> $user_id{
  213.       $result _t('workshop','not_author');
  214.     else {
  215.       $requete "UPDATE  " $this->TDB_COM . " SET workcom_subject='" $this->SUBJECT . "', workcom_body='" $this->BODY . "' , workcom_last_modify=NOW() WHERE workcom_id=" $ID ";";
  216.       $result $sql_object->DBQuery($requete);
  217.     }
  218.     return $result;
  219.   }
  220.  
  221.   /**
  222.    * workshop_com::_CheckUser()
  223.    * obtention de l'id d'un auteur de message
  224.    *
  225.    * @param object $sql_object 
  226.    * @param integer $mes_id 
  227.    * @return id_utilisateur $result[0]['workcom_user_id']
  228.    */
  229.   function _CheckUser($sql_object$mes_id = -1)
  230.   {
  231.     if ($mes_id <> -1{
  232.       $requete "SELECT  workcom_user_id FROM " $this->TDB_COM . " WHERE workcom_id=" $mes_id ";";
  233.     }
  234.     $result $sql_object->DBSelect($requete);
  235.     return $result[0]['workcom_user_id'];
  236.   }
  237. }
  238.  
  239. ?>

Documentation generated on Fri, 16 Oct 2009 09:30:42 +0200 by phpDocumentor 1.4.1