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 $THEME_ID;
  21.   var $WORKSHOP_ID;
  22.   var $NAME;
  23.   var $DESCRIPTION;
  24.   var $BODY;
  25.   var $BEGIN_DATE;
  26.   var $ESTIMATED_DATE;
  27.   var $END_DATE;
  28.   var $SDI;
  29.   var $PUBLISHED_DATE;
  30.   var $POSTED_BY;
  31.   var $DATE_CREA;
  32.   var $STATUT;
  33.   var $LAST_MODIFY;
  34.   protected $dispatcher = null;
  35.  
  36.   public function __construct()
  37.   {
  38.     $this->dispatcher = $GLOBALS['dispatcher'];
  39.   }
  40.  
  41.   public function __call($method$arguments)
  42.   {
  43.     $event $this->dispatcher->notifyUntil(new sfEvent($this'project.extensible_function'array(
  44.       'method'    => $method,
  45.       'arguments' => $arguments
  46.     )));
  47.     if (!$event->isProcessed())
  48.     {
  49.       throw new Exception(sprintf('Call to undefined method %s::%s.'get_class($this)$method));
  50.     }
  51.  
  52.     return $event->getReturnValue();
  53.   }
  54.  
  55.   /**
  56.    * project::_getDate()
  57.    * date courante et ajout
  58.    *
  59.    * @access private
  60.    * @param int $m chiffre des mois
  61.    * @param int $d chiffre des jours
  62.    * @param int $y chiffre des années
  63.    * @return string $format_date
  64.    * @return 
  65.    */
  66.   function _getDate($m 0$d 0$y 0)
  67.   {
  68.     $format_date mktime(date("H")date("i")date("s")date("m"$mdate("d"date("Y")-1);
  69.     $format_date strftime('%Y-%m-%d %H:%M:%S'$format_date);
  70.  
  71.     return $format_date;
  72.   }
  73.  
  74.   /**
  75.    * project::CheckDataIntegrity()
  76.    * Vérification intégrité des données
  77.    *
  78.    * @access public
  79.    * @param array $table : contient les composants Nécessaires d'un projet
  80.    * @return boolean true
  81.    *  si verifié, sinon string 'message d'erreur'
  82.    */
  83.  
  84.   function CheckDataIntegrity($table)
  85.   {
  86.     if (strlen($table[0]3return _t('project','no_name');
  87.     if (strlen($table[1]3return _t('project','no_description');
  88.     if (strlen($table[2]3return _t('project','no_body');
  89.     if ($table[5<= || !is_numeric($table[5])) return _t('project','no_priority');
  90.     if ($table[4<= || !is_numeric($table[4])) return _t('project','no_scale');
  91.     if(!empty($table[6])) return checkdate_validity($table[6]_t('project','begin_date_err'));
  92.     if(!empty($table[7])) return checkdate_validity($table[7]_t('project','estimated_date_err'));
  93.     if(!empty($table[8])) return checkdate_validity($table[8]_t('project','end_date_err'));
  94.  
  95.     return true;
  96.   }
  97.  
  98.   /**
  99.    * project::AddProject()
  100.    * Ajout d'un projet
  101.    *
  102.    * @access public
  103.    * @param array $table_project : contient les composants d'un projet
  104.    * @param object $sql_object 
  105.    * @return integer $last_id
  106.    */
  107.   function AddProject($table_project$sql_object)
  108.   {
  109.     $table_project=$sql_object->DBescape($table_project);
  110.  
  111.     if ($table_project[0!= ''{
  112.       $this->NAME = strip_input(trim($table_project[0])true);
  113.     }
  114.     if ($table_project[1!= ''{
  115.       $this->DESCRIPTION = strip_input(trim($table_project[1])true);
  116.     }
  117.     if ($table_project[2!= ''{
  118.       $this->BODY = strip_input(trim($table_project[2])true);
  119.     }
  120.     if (is_numeric($table_project[3]&& $table_project[3!= -1{
  121.       $this->PARENT_ID = $table_project[3];
  122.     else {
  123.       $this->PARENT_ID = 0;
  124.     }
  125.     if (is_numeric($table_project[4])) {
  126.       $this->SCALE_ID = $table_project[4];
  127.     }
  128.     if (is_numeric($table_project[5])) {
  129.       $this->PRIORITY_ID = $table_project[5];
  130.     }
  131.     if ($table_project[6!= ''{
  132.       $this->BEGIN_DATE = formatDate($table_project[6]true);
  133.     else {
  134.       $this->BEGIN_DATE = '0001-01-01';
  135.     }
  136.     if ($table_project[7!= ''{
  137.       $this->ESTIMATED_DATE = formatDate($table_project[7]true);
  138.     else {
  139.       $this->ESTIMATED_DATE = '0001-01-01';
  140.     }
  141.     if ($table_project[8!= ''{
  142.       $this->END_DATE = formatDate($table_project[8]true);
  143.     else {
  144.       $this->END_DATE = '0001-01-01';
  145.     }
  146.     if (is_numeric($table_project[9])) {
  147.       $this->POSTED_BY = $table_project[9];
  148.     }
  149.     if ($table_project[10!= ''{
  150.       $this->STATUT = strtoupper($table_project[10]);
  151.     }
  152.     if (is_numeric($table_project[11]&& $table_project[11!= -1{
  153.       $this->THEME_ID = $table_project[11];
  154.     else {
  155.       $this->THEME_ID = 0;
  156.     }
  157.     if (is_numeric($table_project[12]&& $table_project[12!= -1{
  158.       $this->WORKSHOP_ID = $table_project[12];
  159.     else {
  160.       $this->WORKSHOP_ID = 0;
  161.     }
  162.     $this->SDI = $table_project[13];
  163.     if ($this->STATUT == 'P'{
  164.       $this->PUBLISHED_DATE = $this->_getDate();
  165.     else {
  166.       $this->PUBLISHED_DATE = '0001-01-01';
  167.     }
  168.  
  169.     $query "INSERT INTO " $this->TDB_PROJECT . " (project_name, project_description, project_body, ".
  170.     "project_parent_id, project_priority_id, project_scale_id, " .
  171.     "project_begin_date, project_estimated_date, project_end_date, ".
  172.     "project_theme_id, project_workshop_id, ".
  173.     "project_posted_by, project_published_date, " .
  174.     "project_statut, project_date_crea) " .
  175.     "VALUES('" $this->NAME . "', '" $this->DESCRIPTION . "', '" $this->BODY .
  176.     "', " $this->PARENT_ID . ", " $this->PRIORITY_ID . ", " $this->SCALE_ID .
  177.     ", '" $this->BEGIN_DATE . "', '" $this->ESTIMATED_DATE . "', '" $this->END_DATE .
  178.     "', " $this->THEME_ID . ", " $this->WORKSHOP_ID .
  179.     ", " $this->POSTED_BY . ", '" $this->PUBLISHED_DATE . "' , '" $this->STATUT .
  180.     "', now());";
  181.      
  182.     $this->ID = $sql_object->DBInsert ($query1);
  183.     $this->_addSDI($sql_object);
  184.  
  185.     return $this->ID;
  186.   }
  187.  
  188.   /**
  189.    * project::DeleteProject()
  190.    * suppression d'un projet
  191.    *
  192.    * @access public
  193.    * @param int $ID : identifiant du projet
  194.    * @param object $sql_object 
  195.    * @return bool $result
  196.    */
  197.  
  198.   function DeleteProject($ID$sql_object)
  199.   {
  200.     $this->ID = $ID;
  201.  
  202.  
  203.     $query "UPDATE " $this->TDB_PROJECT . " set project_statut='E', project_last_modify=NOW() WHERE project_id='" $this->ID . "';";
  204.     $result $sql_object->DBQuery($query);
  205.     if($result{
  206.       $query "DELETE FROM " J_PROJECT_SDI " WHERE jps_project_id='".$this->ID."';";
  207.       $res $sql_object->DBQuery($query);
  208.     }
  209.     if($result{
  210.       $query "UPDATE " $this->TDB_PROJECT . " set project_parent_id=0 WHERE project_parent_id='" $this->ID . "';";
  211.       $result $sql_object->DBQuery($query);
  212.     }
  213.     return $result;
  214.   }
  215.  
  216.   /**
  217.    * project::ModifyProject()
  218.    * modification d'un projet
  219.    *
  220.    * @access public
  221.    * @param integer $ID : identifiant du projet
  222.    * @param object $sql_object 
  223.    * @param array $table_project : contient les composants d'un projet
  224.    * @return boolean $result
  225.    */
  226.   function ModifyProject($ID$table_project$sql_object)
  227.   {
  228.  
  229.     $table_project=$sql_object->DBescape($table_project);
  230.  
  231.     if (is_numeric($ID)) {
  232.       $this->ID = $ID;
  233.     }
  234.  
  235.     if ($table_project[0!= ''{
  236.       $this->NAME = strip_input(trim($table_project[0])true);
  237.     }
  238.     if ($table_project[1!= ''{
  239.       $this->DESCRIPTION = strip_input(trim($table_project[1])true);
  240.     }
  241.     if ($table_project[2!= ''{
  242.       $this->BODY = strip_input(trim($table_project[2])true);
  243.     }
  244.     if (is_numeric($table_project[3]&& $table_project[3!= -1{
  245.       $this->PARENT_ID = $table_project[3];
  246.     else {
  247.       $this->PARENT_ID = 0;
  248.     }
  249.     if (is_numeric($table_project[4])) {
  250.       $this->SCALE_ID = $table_project[4];
  251.     }
  252.     if (is_numeric($table_project[5])) {
  253.       $this->PRIORITY_ID = $table_project[5];
  254.     }
  255.     if ($table_project[6!= ''{
  256.       $this->BEGIN_DATE = formatDate($table_project[6]true);
  257.     else {
  258.       $this->BEGIN_DATE = '0001-01-01';
  259.     }
  260.     if ($table_project[7!= ''{
  261.       $this->ESTIMATED_DATE = formatDate($table_project[7]true);
  262.     else {
  263.       $this->ESTIMATED_DATE = '0001-01-01';
  264.     }
  265.     if ($table_project[8!= ''{
  266.       $this->END_DATE = formatDate($table_project[8]true);
  267.     else {
  268.       $this->END_DATE = '0001-01-01';
  269.     }
  270.     if ($table_project[9!= ''{
  271.       $this->STATUT = strtoupper($table_project[9]);
  272.     }
  273.     if (is_numeric($table_project[11]&& $table_project[11!= -1{
  274.       $this->THEME_ID = $table_project[11];
  275.     else {
  276.       $this->THEME_ID = 0;
  277.     }
  278.     if (is_numeric($table_project[12]&& $table_project[12!= -1{
  279.       $this->WORKSHOP_ID = $table_project[12];
  280.     else {
  281.       $this->WORKSHOP_ID = 0;
  282.     }
  283.     $this->SDI = $table_project[13];
  284.     if ($this->STATUT == 'P'{
  285.       $this->PUBLISHED_DATE = $this->_getDate();
  286.     else {
  287.       $this->PUBLISHED_DATE = '0001-01-01';
  288.     }
  289.  
  290.     $mask $this->_HavePublishedDate($table_project[10]);
  291.  
  292.     $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_theme_id='" $this->THEME_ID ."', project_workshop_id='" $this->WORKSHOP_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 . "';";
  293.     $result $sql_object->DBQuery($query);
  294.     $result $this->_modifySDI($sql_object);
  295.  
  296.     return $result;
  297.   }
  298.  
  299.   /**
  300.    * project::_addSDI()
  301.    * associate indicators to project
  302.    *
  303.    * @access private
  304.    */
  305.   function _addSDI($sql_object{
  306.     foreach ($this->SDI as &$value{
  307.       $query "INSERT INTO "J_PROJECT_SDI " VALUES(".$this->ID.", ".$value.");";
  308.       $result $sql_object->DBQuery($query);
  309.     }
  310.     return $result;
  311.   }
  312.  
  313.   /**
  314.    * project::_modifySDI()
  315.    * associate indicators to project
  316.    *
  317.    * @access private
  318.    */
  319.   function _modifySDI($sql_object{
  320.     $query "DELETE FROM " J_PROJECT_SDI " WHERE jps_project_id='".$this->ID."';";
  321.     $result $sql_object->DBQuery($query);
  322.     if(count($this->SDI)>0{
  323.       $result $this->_addSDI($sql_object);
  324.     }
  325.  
  326.     return $result;
  327.   }
  328.  
  329.   /**
  330.    * project::_HavePublishedDate()
  331.    * Détermine la date de publication a inserer dans la bdd
  332.    *
  333.    * @access private
  334.    * @param string $current_status : statut actuel de l'actualité
  335.    * @return string $sql_mask
  336.    */
  337.   function _HavePublishedDate($current_status)
  338.   {
  339.     switch ($this->STATUT{
  340.       case 'P':
  341.         if ($current_status == 'D'$sql_mask ", project_published_date= NOW()";
  342.         else $sql_mask '';
  343.         break;
  344.       case 'D':
  345.         $sql_mask ", project_published_date= '0001-01-01'";
  346.         break;
  347.       default:
  348.         $sql_mask '';
  349.     }
  350.     return $sql_mask;
  351.   }
  352. }
  353.  
  354. ?>

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