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

Source for file class.publication.php

Documentation is available at class.publication.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage publication
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  *  Publication Management
  10.  */
  11.  
  12. class publication {
  13.   /* @param
  14.    * */
  15.   var $TDB_PUBLI = T_PUBLI// nom de la table.
  16.   var $ID;
  17.   var $TITLE;
  18.   var $RESUME;
  19.   var $THEME;
  20.   var $SCALE;
  21.   var $LEVEL;
  22.   var $POSTED_BY;
  23.   var $PUBLISHED_DATE;
  24.   var $COMMENT;
  25.   var $DATE_CREA;
  26.   var $LAST_MODIFY;
  27.   var $STATUT;
  28.  
  29.   /**
  30.    * publication::CheckDataIntegrity()
  31.    * Vérification intégrité des données
  32.    *
  33.    * @access public
  34.    * @param array $table : contient les composants d'une publication
  35.    * @return boolean true
  36.    *  si verifié, sinon string 'message d'erreur'
  37.    */
  38.   function CheckDataIntegrity($table$sql_object)
  39.   {
  40.     if (strlen($table[0]3return _t('publication','no_title');
  41.     if (strlen($table[1]3return _t('publication','no_resume');
  42.     if ($table[2== -1return _t('publication','no_theme');
  43.     if ($table[3== -1return _t('publication','no_scale');
  44.     if (strlen(trim($table[5])) 2return _t('publication','no_author');
  45.     $result $this->_CheckUserValidity($table[5]$sql_object);
  46.     if (!is_numeric($result['user_id'])) return _t('publication','author_not_valid');
  47.     if ($result['publi_right'== 'U'return _t('publication','author_not_rights');
  48.     else return $result;
  49.   }
  50.  
  51.   /**
  52.    * publication::_CheckUserValidity()
  53.    * Vérification validité de l'utilisateur
  54.    *
  55.    * @access private
  56.    * @param string $login 
  57.    * @param object $sql_object 
  58.    * @return array contenant $user_id et droit si login associé au workshop
  59.    *  sinon renvoie false
  60.    */
  61.   function _CheckUserValidity($login$sql_object)
  62.   {
  63.     $user array('user_id' => '''publi_right' => '');
  64.  
  65.     $requete "SELECT user_id, rights_publication FROM " T_USER " LEFT OUTER JOIN " T_RIGHT " ON user_rights=rights_id WHERE user_login= '" $login "' AND user_validity='Y';";
  66.     $result $sql_object->DBSelect($requete);
  67.  
  68.     if ($result == 0return false;
  69.     if (count($result1exit();
  70.     else {
  71.       $user['user_id'$result[0]['user_id'];
  72.       $user['publi_right'$result[0]['rights_publication'];
  73.     }
  74.     return $user;
  75.   }
  76.  
  77.   /**
  78.    * publication::AddPublication()
  79.    * Ajout d'une nouvelle publication/dossier
  80.    *
  81.    * @access public
  82.    * @param array $table_publi contient les composants d'une publication
  83.    * @param object $sql_object 
  84.    * @return integer $last_id
  85.    */
  86.   function AddPublication($table_publi$sql_object)
  87.   {
  88.     $table_publi=$sql_object->DBescape($table_publi);
  89.     
  90.     if($table_publi[4== -1$table_publi[4]=0;
  91.     
  92.     $this->TITLE = strip_input(trim($table_publi[0])true);
  93.     $this->RESUME = strip_input(trim($table_publi[1])true);
  94.     $this->THEME = $table_publi[2];
  95.     $this->SCALE = $table_publi[3];
  96.     $this->LEVEL = $table_publi[4];
  97.     $this->POSTED_BY = $table_publi[5];
  98.     $this->COMMENT = strip_input(trim($table_publi[6]true));
  99.  
  100.     if ($table_publi[7!= ''{
  101.       $this->STATUT = strtoupper($table_publi[7]);
  102.     }
  103.     if ($this->STATUT == 'P'{
  104.       $this->PUBLISHED_DATE = "NOW()";
  105.     else {
  106.       $this->PUBLISHED_DATE = "'0001-01-01'";
  107.     }
  108.     $requete "INSERT INTO " $this->TDB_PUBLI . " (publi_title, publi_resume, publi_theme, publi_scale, publi_level, publi_posted_by, publi_published_date, publi_comment, publi_statut, publi_date_crea) VALUES('" $this->TITLE . "', '" $this->RESUME . "', " $this->THEME . ", " $this->SCALE . ", " $this->LEVEL . ", " $this->POSTED_BY . ", " $this->PUBLISHED_DATE . ", '" $this->COMMENT . "', '" $this->STATUT . "', NOW());";
  109.     $last_id $sql_object->DBInsert ($requete1);
  110.     return $last_id;
  111.   }
  112.  
  113.   /**
  114.    * publication::ModifyPublication()
  115.    * modification d'une publication
  116.    *
  117.    * @access public
  118.    * @param int $ID identifiant de la publication
  119.    * @param array $table_publi contient les composants d'une publication
  120.    * @param object $sql_object 
  121.    * @return bool $result
  122.    */
  123.   function ModifyPublication($ID$table_publi$sql_object)
  124.   {
  125.  
  126.     $table_publi=$sql_object->DBescape($table_publi);
  127.     
  128.     if($table_publi[4== -1$table_publi[4]=0;
  129.      
  130.     if (is_numeric($ID)) {
  131.       $this->ID = $ID;
  132.     else exit;
  133.     $this->TITLE = strip_input(trim($table_publi[0])true);
  134.     $this->RESUME = strip_input(trim($table_publi[1])true);
  135.     $this->THEME = $table_publi[2];
  136.     $this->SCALE = $table_publi[3];
  137.     $this->LEVEL = $table_publi[4];
  138.     $this->POSTED_BY = $table_publi[5];
  139.     $this->COMMENT = strip_input(trim($table_publi[6]true));
  140.     $this->STATUT = $table_publi[7];
  141.  
  142.     $mask $this->_HavePublishedDate($table_publi[8]);
  143.  
  144.     $requete "UPDATE  " $this->TDB_PUBLI . " set publi_title='" $this->TITLE . "', publi_resume='" $this->RESUME . "' , publi_theme='" $this->THEME . "', publi_scale='" $this->SCALE . "', publi_level='" $this->LEVEL . "', publi_comment='" $this->COMMENT . "', publi_posted_by='" $this->POSTED_BY . "', publi_last_modify=NOW(), publi_statut='" $this->STATUT . "'" $mask " WHERE publi_id='" $this->ID . "';";
  145.     $result $sql_object->DBQuery($requete);
  146.     return $result;
  147.   }
  148.  
  149.   /**
  150.    * publication::_HavePublishedDate()
  151.    * Détermine la date de publication a inserer dans la bdd
  152.    *
  153.    * @access private
  154.    * @param string $current_status : statut actuel de la publication
  155.    * @return string $sql_mask
  156.    */
  157.   function _HavePublishedDate($current_status)
  158.   {
  159.     switch ($this->STATUT{
  160.       case 'P':
  161.         if ($current_status == 'D'$sql_mask ", publi_published_date= NOW()";
  162.         else $sql_mask '';
  163.         break;
  164.       case 'D':
  165.         $sql_mask ", publi_published_date= '0001-01-01'";
  166.         break;
  167.       default:
  168.         $sql_mask '';
  169.     }
  170.     return $sql_mask;
  171.   }
  172.  
  173.   /**
  174.    * publication::DeletePublication()
  175.    * suppression d'une publication
  176.    *
  177.    * @access public
  178.    * @param int $ID identifiant de la publication a supprimer
  179.    * @param object $sql_object 
  180.    * @return bool $result
  181.    */
  182.   function DeletePublication($ID$sql_object)
  183.   {
  184.     $this->ID = $ID;
  185.     $requete "UPDATE  " $this->TDB_PUBLI . " set publi_statut='E', publi_last_modify=NOW() WHERE publi_id=" $this->ID . ";";
  186.     $result $sql_object->DBQuery($requete);
  187.  
  188.     return $result;
  189.   }
  190. }
  191.  
  192. ?>

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