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

Source for file class.project.php

Documentation is available at class.project.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage project
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  *  Project Management
  10.  */
  11.  
  12. class project {
  13.   /* @param
  14.    * */
  15.   var $TDB_PROJECT = T_PROJECT// nom de la table.
  16.   var $ID;
  17.   var $PARENT_ID;
  18.   var $SCALE_ID;
  19.   var $PRIORITY_ID;
  20.   var $NAME;
  21.   var $DESCRIPTION;
  22.   var $BODY;
  23.   var $BEGIN_DATE;
  24.   var $ESTIMATED_DATE;
  25.   var $END_DATE;
  26.   var $PUBLISHED_DATE;
  27.   var $POSTED_BY;
  28.   var $DATE_CREA;
  29.   var $STATUT;
  30.   var $LAST_MODIFY;
  31.  
  32.  
  33.   /**
  34.    * project::_getDate()
  35.    * date courante et ajout
  36.    *
  37.    * @access private
  38.    * @param int $m chiffre des mois
  39.    * @param int $d chiffre des jours
  40.    * @param int $y chiffre des années
  41.    * @return string $format_date
  42.    * @return 
  43.    */
  44.   function _getDate($m 0$d 0$y 0)
  45.   {
  46.     $format_date mktime(date("H")date("i")date("s")date("m"$mdate("d"date("Y")-1);
  47.     $format_date strftime('%Y-%m-%d %H:%M:%S'$format_date);
  48.  
  49.     return $format_date;
  50.   }
  51.  
  52.   /**
  53.    * project::CheckDataIntegrity()
  54.    * Vérification intégrité des données
  55.    *
  56.    * @access public
  57.    * @param array $table : contient les composants Nécessaires d'un projet
  58.    * @return boolean true
  59.    *  si verifié, sinon string 'message d'erreur'
  60.    */
  61.  
  62.   function CheckDataIntegrity($table)
  63.   {
  64.     if (strlen($table[0]3return $GLOBALS['lang']['project']['no_name'];
  65.     if (strlen($table[1]3return $GLOBALS['lang']['project']['no_description'];
  66.     if (strlen($table[2]3return $GLOBALS['lang']['project']['no_body'];
  67.     if ($table[5<= || !is_numeric($table[5])) return $GLOBALS['lang']['project']['no_priority'];
  68.     if ($table[4<= || !is_numeric($table[4])) return $GLOBALS['lang']['project']['no_scale'];
  69.     if(!empty($table[6])) return checkdate_validity($table[6]$GLOBALS['lang']['project']['begin_date_err']);
  70.     if(!empty($table[7])) return checkdate_validity($table[7]$GLOBALS['lang']['project']['estimated_date_err']);
  71.     if(!empty($table[8])) return checkdate_validity($table[8]$GLOBALS['lang']['project']['end_date_err']);
  72.  
  73.     return true;
  74.   }
  75.  
  76.   /**
  77.    * project::AddProject()
  78.    * Ajout d'un projet
  79.    *
  80.    * @access public
  81.    * @param array $table_project : contient les composants d'un projet
  82.    * @param object $sql_object 
  83.    * @return integer $last_id
  84.    */
  85.   function AddProject($table_project$sql_object)
  86.   {
  87.     $table_project=$sql_object->DBescape($table_project);
  88.  
  89.     if ($table_project[0!= ''{
  90.       $this->NAME = strip_input(trim($table_project[0])true);
  91.     }
  92.     if ($table_project[1!= ''{
  93.       $this->DESCRIPTION = strip_input(trim($table_project[1])true);
  94.     }
  95.     if ($table_project[2!= ''{
  96.       $this->BODY = strip_input(trim($table_project[2])true);
  97.     }
  98.     if (is_numeric($table_project[3]&& $table_project[3!= -1{
  99.       $this->PARENT_ID = $table_project[3];
  100.     else {
  101.       $this->PARENT_ID = 0;
  102.     }
  103.     if (is_numeric($table_project[4])) {
  104.       $this->SCALE_ID = $table_project[4];
  105.     }
  106.     if (is_numeric($table_project[5])) {
  107.       $this->PRIORITY_ID = $table_project[5];
  108.     }
  109.     if ($table_project[6!= ''{
  110.       $this->BEGIN_DATE = formatDate($table_project[6]true);
  111.     else {
  112.       $this->BEGIN_DATE = '0001-01-01';
  113.     }
  114.     if ($table_project[7!= ''{
  115.       $this->ESTIMATED_DATE = formatDate($table_project[7]true);
  116.     else {
  117.       $this->ESTIMATED_DATE = '0001-01-01';
  118.     }
  119.     if ($table_project[8!= ''{
  120.       $this->END_DATE = formatDate($table_project[8]true);
  121.     else {
  122.       $this->END_DATE = '0001-01-01';
  123.     }
  124.     if (is_numeric($table_project[9])) {
  125.       $this->POSTED_BY = $table_project[9];
  126.     }
  127.     if ($table_project[10!= ''{
  128.       $this->STATUT = strtoupper($table_project[10]);
  129.     }
  130.     if ($this->STATUT == 'P'{
  131.       $this->PUBLISHED_DATE = $this->_getDate();
  132.     else {
  133.       $this->PUBLISHED_DATE = '0001-01-01';
  134.     }
  135.  
  136.     $query "INSERT INTO " $this->TDB_PROJECT . " (project_name, project_description, project_body, ".
  137.     "project_parent_id, project_priority_id, project_scale_id, " .
  138.     "project_begin_date, project_estimated_date, project_end_date, ".
  139.     "project_posted_by, project_published_date, " 
  140.     "project_statut, project_date_crea) " 
  141.     "VALUES('" $this->NAME . "', '" $this->DESCRIPTION . "', '" $this->BODY . 
  142.     "', " $this->PARENT_ID . ", " $this->PRIORITY_ID . ", " $this->SCALE_ID . 
  143.     ", '" $this->BEGIN_DATE . "', '" $this->ESTIMATED_DATE . "', '" $this->END_DATE . 
  144.     "', " $this->POSTED_BY . ", '" $this->PUBLISHED_DATE . "' , '" $this->STATUT . 
  145.     "', now());";
  146.      
  147.     echo $query;
  148.     //exit;
  149.     $last_id $sql_object->DBInsert ($query1);
  150.     return $last_id;
  151.   }
  152.  
  153.   /**
  154.    * project::DeleteProject()
  155.    * suppression d'un projet
  156.    *
  157.    * @access public
  158.    * @param int $ID : identifiant du projet
  159.    * @param object $sql_object 
  160.    * @return bool $result
  161.    */
  162.  
  163.   function DeleteProject($ID$sql_object)
  164.   {
  165.     $this->ID = $ID;
  166.  
  167.  
  168.     $query "UPDATE  " $this->TDB_PROJECT . " set project_statut='E', project_last_modify=NOW() WHERE project_id='" $this->ID . "';";
  169.     $result $sql_object->DBQuery($query);
  170.     if($result{
  171.       $requete "SELECT project_parent_id FROM " $this->TDB_PROJECT . " WHERE project_id=" $this->ID . ";";
  172.       $result $sql_object->DBSelect($requete);
  173.       $parent_id $result[0]['project_parent_id'];
  174.  
  175.       $query "UPDATE  " $this->TDB_PROJECT . " set project_parent_id=null WHERE project_parent_id='" $parent_id "';";
  176.       $result $sql_object->DBQuery($query);
  177.     }
  178.     return $result;
  179.   }
  180.  
  181.   /**
  182.    * project::ModifyProject()
  183.    * modification d'un projet
  184.    *
  185.    * @access public
  186.    * @param integer $ID : identifiant du projet
  187.    * @param object $sql_object 
  188.    * @param array $table_project : contient les composants d'un projet
  189.    * @return boolean $result
  190.    */
  191.   function ModifyProject($ID$table_project$sql_object)
  192.   {
  193.  
  194.     $table_project=$sql_object->DBescape($table_project);
  195.  
  196.     if (is_numeric($ID)) {
  197.       $this->ID = $ID;
  198.     }
  199.  
  200.     if ($table_project[0!= ''{
  201.       $this->NAME = strip_input(trim($table_project[0])true);
  202.     }
  203.     if ($table_project[1!= ''{
  204.       $this->DESCRIPTION = strip_input(trim($table_project[1])true);
  205.     }
  206.     if ($table_project[2!= ''{
  207.       $this->BODY = strip_input(trim($table_project[2])true);
  208.     }
  209.     if (is_numeric($table_project[3]&& $table_project[3!= -1{
  210.       $this->PARENT_ID = $table_project[3];
  211.     else {
  212.       $this->PARENT_ID = 0;
  213.     }
  214.     if (is_numeric($table_project[4])) {
  215.       $this->SCALE_ID = $table_project[4];
  216.     }
  217.     if (is_numeric($table_project[5])) {
  218.       $this->PRIORITY_ID = $table_project[5];
  219.     }
  220.     if ($table_project[6!= ''{
  221.       $this->BEGIN_DATE = formatDate($table_project[6]true);
  222.     else {
  223.       $this->BEGIN_DATE = '0001-01-01';
  224.     }
  225.     if ($table_project[7!= ''{
  226.       $this->ESTIMATED_DATE = formatDate($table_project[7]true);
  227.     else {
  228.       $this->ESTIMATED_DATE = '0001-01-01';
  229.     }
  230.     if ($table_project[8!= ''{
  231.       $this->END_DATE = formatDate($table_project[8]true);
  232.     else {
  233.       $this->END_DATE = '0001-01-01';
  234.     }
  235.     if ($table_project[9!= ''{
  236.       $this->STATUT = strtoupper($table_project[9]);
  237.     }
  238.     if ($this->STATUT == 'P'{
  239.       $this->PUBLISHED_DATE = $this->_getDate();
  240.     else {
  241.       $this->PUBLISHED_DATE = '0001-01-01';
  242.     }
  243.  
  244.     $mask $this->_HavePublishedDate($table_project[10]);
  245.  
  246.     $query "UPDATE  " $this->TDB_PROJECT . " SET project_name='" $this->NAME . "', project_description='" $this->DESCRIPTION"', project_body='" $this->BODY . "' , project_parent_id='" $this->PARENT_ID . "', project_scale_id='" $this->SCALE_ID . "', project_priority_id='" $this->PRIORITY_ID . "', project_begin_date='" $this->BEGIN_DATE . "', project_estimated_date='" $this->ESTIMATED_DATE . "', project_end_date='".$this->END_DATE."', project_statut='" $this->STATUT . "', project_last_modify=NOW() " $mask " WHERE project_id='" $this->ID . "';";
  247.     $result $sql_object->DBQuery($query);
  248.  
  249.     return $result;
  250.   }
  251.  
  252.   /**
  253.    * project::_HavePublishedDate()
  254.    * Détermine la date de publication a inserer dans la bdd
  255.    *
  256.    * @access private
  257.    * @param string $current_status : statut actuel de l'actualité
  258.    * @return string $sql_mask
  259.    */
  260.   function _HavePublishedDate($current_status)
  261.   {
  262.     switch ($this->STATUT{
  263.       case 'P':
  264.         if ($current_status == 'D'$sql_mask ", project_published_date= NOW()";
  265.         else $sql_mask '';
  266.         break;
  267.       case 'D':
  268.         $sql_mask ", project_published_date= '0001-01-01'";
  269.         break;
  270.       default:
  271.         $sql_mask '';
  272.     }
  273.     return $sql_mask;
  274.   }
  275. }
  276.  
  277. ?>

Documentation generated on Sat, 08 Nov 2008 14:51:21 +0100 by phpDocumentor 1.4.1