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

Source for file class.sdi.php

Documentation is available at class.sdi.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage sdi
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  *  SDI (Sustainable Development Indicators) Management
  10.  */
  11.  
  12. class sdi {
  13.     /* @param
  14.      * */
  15.     // nom des tables utilisées dans l'objet.
  16.     var $TDB_SDI_INFO = T_SDI_INFO ;
  17.     var $TDB_SDI_EVAL = T_SDI_EVAL ;
  18.     var $TDB_SDI_PROVIDER = T_SDI_PROVIDER ;
  19.     var $TDB_SDI_RULES = T_SDI_RULES ;
  20.     var $TDB_SDI_VALUE = T_SDI_VALUE ;
  21.     var $TDB_SD_THEME = T_SD_THEME ;
  22.     var $TDB_THEME = T_THEME ;
  23.     // variables utilisées pour caractéristiques principales d'un IDD
  24.     var $I_ID;
  25.     var $I_TYPE;
  26.     var $I_DASHBOARD_VIZ;
  27.     var $I_DETAIL_VIZ;
  28.     var $I_NAME;
  29.     var $I_DESCRIPTION;
  30.     var $I_COMMENT;
  31.     var $I_THEME;
  32.     var $I_RANGE;
  33.     var $I_GOAL;
  34.     var $I_CONSULTING;
  35.     var $I_DASHBOARD;
  36.     var $I_UNIT;
  37.     var $I_MAX_VALUE;
  38.     var $I_MIN_VALUE;
  39.     var $I_THRESHOLD;
  40.     var $I_THRESHOLD_RELATIVE;
  41.     var $I_FREQUENCY;
  42.     var $I_PROVIDER;
  43.     var $I_EVALUATION;
  44.     var $I_REGLEMENTATION;
  45.     var $I_DATE_CREA;
  46.     var $I_LAST_MODIFY;
  47.     var $I_STATUT;
  48.     // variables utilisées pour critères d'évaluation d'un ID
  49.     var $E_ID;
  50.     var $E_SCALE;
  51.     var $E_FIABILITY;
  52.     var $E_ACCESSIBILITY;
  53.     var $E_LISIBILITY;
  54.     var $E_RELEVANCE;
  55.     var $E_GLOBAL_PERFORMANCE;
  56.     var $E_DATE_CREA;
  57.     var $E_LAST_MODIFY;
  58.     // variables utilisées pour organisme fournisseur d'un IDD
  59.     var $P_ID;
  60.     var $P_NAME;
  61.     var $P_SERVICE;
  62.     var $P_DESCRIPTION;
  63.     var $P_INCHARGE;
  64.     var $P_ADDRESS;
  65.     var $P_PHONE;
  66.     var $P_FAX;
  67.     var $P_EMAIL;
  68.     var $P_DATE_CREA;
  69.     var $P_LAST_MODIFY;
  70.     // variables utilisées pour réglementation d'un IDD
  71.     var $R_ID;
  72.     var $R_TITLE;
  73.     var $R_BODY;
  74.     var $R_REFERER_URI;
  75.     var $R_MASK_URI;
  76.     var $R_DATE_CREA;
  77.     var $R_LAST_MODIFY;
  78.     // variables utilisées pour valeur d'un IDD
  79.     var $V_ID;
  80.     var $V_VALUE;
  81.     var $V_THRESHOLD;
  82.     var $V_SDI_ID;
  83.     var $V_COMMENT;
  84.     var $V_COMMENT_DISPLAY;
  85.     var $V_SCALE;
  86.     var $V_DATE_PUBLISHED;
  87.     var $V_DATE_CREA;
  88.     var $V_LAST_MODIFY;
  89.     var $V_STATUT;
  90.     protected $dispatcher = null;
  91.  
  92.     public function __construct()
  93.     {
  94.         $this->dispatcher = $GLOBALS['dispatcher'];
  95.     }
  96.  
  97.     public function __call($method$arguments)
  98.     {
  99.         $event $this->dispatcher->notifyUntil(new sfEvent($this'sdi.extensible_function'array(
  100.                 'method'    => $method,
  101.                 'arguments' => $arguments
  102.         )));
  103.         if (!$event->isProcessed())
  104.         {
  105.             throw new Exception(sprintf('Call to undefined method %s::%s.'get_class($this)$method));
  106.         }
  107.  
  108.         return $event->getReturnValue();
  109.     }
  110.  
  111.     /**
  112.      * sdi::CheckDataIntegrity_value()
  113.      * Vérification d'une valeur d'un indicateur
  114.      *
  115.      * @access public
  116.      * @param array $table contient les composants d'un indicateur
  117.      * @return boolean si vrai renvoie true sinon message d'erreurs (string)
  118.      */
  119.     function CheckDataIntegrity_value($table$sql_object)
  120.     {
  121.  
  122.         // Filter data event + return value
  123.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_datacheck_value'array('data' => $table))$table);
  124.         $table $r->getReturnValue();
  125.          
  126.         $notvalue strtolower(_t('dashboard','object_notvalue'));
  127.         $notgoodvalue strtolower(_t('dashboard','object_notgoodvalue'));
  128.  
  129.         if (!is_numeric($table[0])) return $notvalue;
  130.  
  131.         $result $this->_GetInfoSdi($table[1]$sql_object);
  132.         
  133.         // test values only if max and min values are known
  134.         if(!is_null($result[0]['sdii_max_value']&& !is_null($result[0]['sdii_min_value'])) {
  135.  
  136.             if($result[0]['sdii_max_value'$result[0]['sdii_min_value']{
  137.                 if ($table[2$result[0]['sdii_min_value'||  $table[2$result[0]['sdii_max_value']return ucfirst(_t('dashboard','threshold_value')) ' : '$notgoodvalue;
  138.             else {
  139.                 if($table[2$result[0]['sdii_min_value'|| $table[2$result[0]['sdii_max_value']return ucfirst(_t('dashboard','threshold_value')) ' : '.$notgoodvalue;
  140.             }
  141.     
  142.             if($result[0]['sdii_max_value'$result[0]['sdii_min_value']{
  143.                 if ($table[0$result[0]['sdii_min_value'||  $table[0$result[0]['sdii_max_value']return ucfirst(_t('dashboard','value')) ' : '.$notgoodvalue;
  144.             else {
  145.                 if($table[0$result[0]['sdii_min_value'|| $table[0$result[0]['sdii_max_value']return ucfirst(_t('dashboard','value')) ' : '.$notgoodvalue;
  146.             }
  147.         }
  148.  
  149.         if(is_string(checkdate_validity($table[4]))) return checkdate_validity($table[4]);
  150.  
  151.         // Notify the beginning of the current method
  152.         $this->dispatcher->notify(new sfEvent($this'indicator.after_datacheck_value'array('data' => $table)));
  153.  
  154.         return true;
  155.  
  156.     }
  157.  
  158.     /**
  159.      * sdi::CheckDataIntegrity_info()
  160.      * Vérification des données générales d'un indicateur
  161.      *
  162.      * @access public
  163.      * @param array $table contient les composants d'un indicateur
  164.      * @return boolean si vrai renvoie true sinon message d'erreurs (string)
  165.      */
  166.  
  167.     function CheckDataIntegrity_info($table)
  168.     {
  169.  
  170.         // Filter data event + return value
  171.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_datacheck_info'array('data' => $table))$table);
  172.         $table $r->getReturnValue();
  173.          
  174.         $notname _t('sdi','object_notname');
  175.         $notdescription _t('sdi','object_notdescription');
  176.         $nottheme _t('sdi','object_nottheme');
  177.         //$notrange = _t('sdi','object_notrange');
  178.         $notunit _t('sdi','object_notunit');
  179.         $notmax_value _t('sdi','object_notmax_value');
  180.         $notmin_value _t('sdi','object_notmin_value');
  181.         $notthreshold_value _t('sdi','object_notthreshold_value');
  182.         $notfrequency _t('sdi','object_notfrequency');
  183.  
  184.         if (strlen($table[0]2return $notname;
  185.         if (strlen($table[1]2return $notdescription;
  186.         if ($table[3<= || !is_numeric($table[3])) return $nottheme;
  187.  
  188.         $table[7]=trim($table[7]);
  189.         if (empty($table[7])) return $notunit;
  190.          if (!empty($table[8]&& !is_numeric($table[8])) return $notmax_value;
  191.          if (!empty($table[9]&& !is_numeric($table[9])) return $notmin_value;
  192.          if (!empty($table[10]&& !is_numeric($table[10])) return $notthreshold_value;
  193.         if (!is_numeric($table[11])) return $notfrequency;
  194.  
  195.         // Notify the beginning of the current method
  196.         $this->dispatcher->notify(new sfEvent($this'indicator.after_datacheck_info'array('data' => $table)));
  197.  
  198.         return true;
  199.     }
  200.  
  201.     /**
  202.      * sdi::CheckDataIntegrity_eval()
  203.      * Vérification des données d'évaluation d'un indicateur
  204.      *
  205.      * @access public
  206.      * @param array $table contient les composants évaluation d'un indicateur
  207.      * @return boolean si vrai renvoie true sinon message d'erreurs (string)
  208.      */
  209.  
  210.     function CheckDataIntegrity_eval($table)
  211.     {
  212.         // Filter data event + return value
  213.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_datacheck_eval'array('data' => $table))$table);
  214.         $table $r->getReturnValue();
  215.  
  216.         $note_scale_compare _t('sdi','object_note_scale_compare');
  217.         $note_fiability _t('sdi','object_note_fiability');
  218.         $note_accessibility _t('sdi','object_note_accessibility');
  219.         $note_lisibility _t('sdi','object_note_lisibility');
  220.         $note_relevance _t('sdi','object_note_relevance');
  221.         $note_global_performance _t('sdi','object_note_global_performance');
  222.  
  223.         if (!is_numeric($table[13])) return $note_scale_compare;
  224.         if (!is_numeric($table[14])) return $note_fiability;
  225.         if (!is_numeric($table[15])) return $note_accessibility;
  226.         if (!is_numeric($table[16])) return $note_lisibility;
  227.         if (!is_numeric($table[17])) return $note_relevance;
  228.         if (!is_numeric($table[18])) return $note_global_performance;
  229.  
  230.         // Notify the beginning of the current method
  231.         $this->dispatcher->notify(new sfEvent($this'indicator.after_datacheck_eval'array('data' => $table)));
  232.  
  233.         return true;
  234.     }
  235.  
  236.     /**
  237.      * sdi::CheckDataIntegrity_provider()
  238.      * Vérification des données d'un fournisseur d'un indicateur
  239.      *
  240.      * @access public
  241.      * @param array $table contient les composants évaluation d'un indicateur
  242.      * @return boolean si vrai renvoie true sinon message d'erreurs (string)
  243.      */
  244.     function CheckDataIntegrity_provider($table)
  245.     {
  246.  
  247.         // Filter data event + return value
  248.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_datacheck_provider'array('data' => $table))$table);
  249.         $table $r->getReturnValue();
  250.          
  251.         $notp_name _t('sdi','object_notp_name');
  252.         $notp_address _t('sdi','object_notp_address');
  253.         $notp_phone _t('sdi','object_notp_phone');
  254.         $notp_fax _t('sdi','object_notp_fax');
  255.         $notp_mail _t('sdi','object_notp_mail');
  256.  
  257.         if (strlen($table[19]2return $notp_name;
  258.         if (strlen($table[23]2return $notp_address;
  259.  
  260.         if (trim($table[24]!= '' && !is_numeric($table[24])) return $notp_phone;
  261.         if (trim($table[25]!= '' && !is_numeric($table[25])) return $notp_fax;
  262.  
  263.         $testmail $this->_checkEmailValidity($table[26]);
  264.         if ($testmail===falsereturn $notp_mail;
  265.  
  266.         // Notify the beginning of the current method
  267.         $this->dispatcher->notify(new sfEvent($this'indicator.after_datacheck_provider'array('data' => $table)));
  268.  
  269.         return true;
  270.     }
  271.  
  272.  
  273.     /**
  274.      * sdi::CheckDataIntegrity_reglementation()
  275.      * Vérification des données de réglementation d'un indicateur
  276.      *
  277.      * @access public
  278.      * @param array $table contient les composants réglementation d'un indicateur
  279.      * @return boolean si vrai renvoie true sinon message d'erreurs (string)
  280.      */
  281.     function CheckDataIntegrity_reglementation($table)
  282.     {
  283.  
  284.         // Filter data event + return value
  285.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_datacheck_reglementation'array('data' => $table))$table);
  286.         $table $r->getReturnValue();
  287.          
  288.         $notr_title _t('sdi','object_notr_title');
  289.         $notr_body _t('sdi','object_notr_body');
  290.  
  291.         if (strlen($table[27]2return $notr_title;
  292.         if (strlen($table[28]2return $notr_body;
  293.  
  294.         if(CHECK_LINK==true && !empty($table[29])) {
  295.             if (!$this->CheckOnlineFile($table[29])) return _t('sdi','server_noresponse');
  296.         }
  297.  
  298.         // Notify the beginning of the current method
  299.         $this->dispatcher->notify(new sfEvent($this'indicator.after_datacheck_reglementation'array('data' => $table)));
  300.  
  301.         return true;
  302.     }
  303.  
  304.     /**
  305.      * sdi::_checkEmailValidity()
  306.      * Vérification du mail
  307.      *
  308.      * @access private
  309.      * @param string $email contient les composants d'un mail
  310.      * @return boolean si vrai renvoie true sinon message d'erreurs (string)
  311.      */
  312.     function _checkEmailValidity($email)
  313.     {
  314.         // Notify the beginning of the current method
  315.         $this->dispatcher->notify(new sfEvent($this'indicator.check_email_validity'array('data' => $table)));
  316.  
  317.         return validEmail($email);
  318.     }
  319.  
  320.     /**
  321.      * resources::CheckOnlineFile()
  322.      * vérifie l'existence d'un fichier en ligne
  323.      *
  324.      * @access public
  325.      * @param  $path 
  326.      * @return boolean 
  327.      */
  328.     function CheckOnlineFile($path)
  329.     {
  330.         // Notify the beginning of the current method
  331.         $this->dispatcher->notify(new sfEvent($this'indicator.check_online_file'array('path' => $path)));
  332.  
  333.         $file_pt @fopen($path'r');
  334.         if (!$file_ptreturn false;
  335.         else {
  336.             fclose($file_pt);
  337.             return true;
  338.         }
  339.     }
  340.  
  341.     /**
  342.      * sdi::_AddProvider()
  343.      * Ajout d'un nouveau fournisseur d'un IDD
  344.      *
  345.      * @access private
  346.      * @param object $sql_object 
  347.      * @return integer $last_id
  348.      */
  349.     function _AddProvider($sql_object)
  350.     {
  351.         // Notify the beginning of the current method
  352.         $this->dispatcher->notify(new sfEvent($this'indicator.add_provider'));
  353.          
  354.         $q "INSERT INTO " $this->TDB_SDI_PROVIDER . " (sdip_name, sdip_service, sdip_description, sdip_incharge, sdip_address, sdip_phone, sdip_fax, sdip_email, sdip_date_crea) VALUES ('','','', '', '', '', '', '',NOW());";
  355.         $last_id $sql_object->DBInsert ($q1);
  356.         return $last_id;
  357.     }
  358.  
  359.     /**
  360.      * sdi::_AddEvaluation()
  361.      * Ajout de critères d'évaluation d'un IDD
  362.      *
  363.      * @access private
  364.      * @param object $sql_object 
  365.      * @return integer $last_id
  366.      */
  367.     function _AddEvaluation ($sql_object)
  368.     {
  369.         // Notify the beginning of the current method
  370.         $this->dispatcher->notify(new sfEvent($this'indicator.add_evaluation'));
  371.          
  372.         $q "INSERT INTO " $this->TDB_SDI_EVAL . " (sdie_scale_compare, sdie_fiability, sdie_accessibility, sdie_lisibility, sdie_relevance, sdie_global_performance, sdie_date_crea)VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT,NOW());";
  373.         $last_id $sql_object->DBInsert ($q1);
  374.         return $last_id;
  375.     }
  376.  
  377.  
  378.     /**
  379.      * sdi::_AddRules()
  380.      * Ajout d'une réglementation d'un IDD
  381.      *
  382.      * @access private
  383.      * @param object $sql_object 
  384.      * @return integer $last_id
  385.      */
  386.     function _AddRules($sql_object)
  387.     {
  388.         // Notify the beginning of the current method
  389.         $this->dispatcher->notify(new sfEvent($this'indicator.add_rules'));
  390.          
  391.         $q "INSERT INTO " $this->TDB_SDI_RULES . " (sdir_title, sdir_body, sdir_referer_uri, sdir_mask_uri, sdir_date_crea) VALUES ('', '', '', '', NOW());";
  392.         $last_id $sql_object->DBInsert ($q1);
  393.         return $last_id;
  394.     }
  395.  
  396.  
  397.     /**
  398.      * sdi::AddSdi()
  399.      * Ajout d'un IDD
  400.      *
  401.      * @access public
  402.      * @param array $table_sdi_info contient les infos detaillees d'un IDD
  403.      * @param object $sql_object 
  404.      * @return integer $last_id
  405.      */
  406.     function AddSdi($table_sdi_info$sql_object)
  407.     {
  408.         // Filter data event + return value
  409.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_add_indicator'array('data' => $table_sdi_info))$table_sdi_info);
  410.         $table_sdi_info $r->getReturnValue();
  411.          
  412.         $table_sdi_info=$sql_object->DBescape($table_sdi_info);
  413.  
  414.         $this->I_NAME = strip_input($table_sdi_info[0]);
  415.         $this->I_DESCRIPTION = strip_input($table_sdi_info[1]true);
  416.         $this->I_COMMENT = strip_input($table_sdi_info[2]true);
  417.         $this->I_THEME = $table_sdi_info[3];
  418.         $this->I_RANGE = $table_sdi_info[4];
  419.         $this->I_GOAL = strip_input($table_sdi_info[5]true);
  420.         $this->I_CONSULTING = strip_input($table_sdi_info[6]true);
  421.         $this->I_UNIT = strip_input($table_sdi_info[7]);
  422.  
  423.         if($table_sdi_info[8]==''{
  424.             $this->I_MAX_VALUE="NULL";
  425.         else {
  426.             $this->I_MAX_VALUE=$table_sdi_info[8];
  427.         }
  428.         if($table_sdi_info[9]==''{
  429.             $this->I_MIN_VALUE="NULL";
  430.         else {
  431.             $this->I_MIN_VALUE=$table_sdi_info[9];
  432.         }
  433.         if($table_sdi_info[10]==''{
  434.             $this->I_THRESHOLD="NULL";
  435.         else {
  436.             $this->I_THRESHOLD=$table_sdi_info[10];
  437.         }
  438.         $this->I_FREQUENCY = $table_sdi_info[11];
  439.  
  440.         $this->I_PROVIDER = $this->_AddProvider($sql_object);
  441.         $this->I_EVALUATION = $this->_AddEvaluation($sql_object);
  442.         $this->I_REGLEMENTATION = $this->_AddRules($sql_object);
  443.         $this->I_STATUT = $table_sdi_info[12];
  444.         $this->I_THRESHOLD_RELATIVE = $table_sdi_info[13];
  445.         $this->I_DASHBOARD = $table_sdi_info[14];
  446.         $this->I_TYPE = $table_sdi_info[15];
  447.         $this->I_DASHBOARD_VIZ = $table_sdi_info[16];
  448.         $this->I_DETAIL_VIZ = $table_sdi_info[17];
  449.  
  450.  
  451.  
  452.         $q "INSERT INTO " $this->TDB_SDI_INFO . " (sdii_type, sdii_dashboard_viz, sdii_detail_viz, sdii_name, sdii_description, sdii_comment, sdii_theme, sdii_range, sdii_goal,
  453.         sdii_consulting, sdii_to_dashboard, sdii_unit, sdii_max_value, sdii_min_value, sdii_threshold_value, sdii_threshold_relative, sdii_frequency, sdii_provider, sdii_evaluation,
  454.         sdii_reglementation, sdii_statut, sdii_date_crea) VALUES ('".$this->I_TYPE."', '" .$this->I_DASHBOARD_VIZ."', '" .$this->I_DETAIL_VIZ."', '" $this->I_NAME . "', '" $this->I_DESCRIPTION . "', '"
  455.         . $this->I_COMMENT . "', " $this->I_THEME . ", " $this->I_RANGE . ", '" $this->I_GOAL . "', '"
  456.         . $this->I_CONSULTING ."' , '" $this->I_DASHBOARD . "', '" $this->I_UNIT . "' , " $this->I_MAX_VALUE . " , " $this->I_MIN_VALUE . " , "
  457.         . $this->I_THRESHOLD . " , '" $this->I_THRESHOLD_RELATIVE . "' , " $this->I_FREQUENCY . " , " $this->I_PROVIDER . " , " $this->I_EVALUATION . " , "
  458.         . $this->I_REGLEMENTATION . " ,'" $this->I_STATUT . "' , NOW());";
  459.  
  460.         $result $sql_object->DBInsert ($q1);
  461.  
  462.         // Notify the end of the current method
  463.         $this->dispatcher->notify(new sfEvent($this'indicator.after_add_indicator'array('data' => $table_sdi_info'id' => $result)));
  464.  
  465.         return $result;
  466.     }
  467.  
  468.     /**
  469.      * sdi::AddValue()
  470.      * Ajout d'une valeur IDD
  471.      *
  472.      * @access public
  473.      * @param array $table_sdi_value contient les composants d'une valeur d'un IDD
  474.      * @param object $sql_object 
  475.      * @return integer $last_id
  476.      */
  477.     function AddValue($table_sdi_value$sql_object)
  478.     {
  479.         // Filter data event + return value
  480.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_add_value'array('data' => $table_sdi_value))$table_sdi_value);
  481.         $table_sdi_value $r->getReturnValue();
  482.          
  483.         $table_sdi_value=$sql_object->DBescape($table_sdi_value);
  484.  
  485.         $this->V_VALUE = $table_sdi_value[0];
  486.         $this->V_SDI_ID = $table_sdi_value[1];
  487.         if(!empty($table_sdi_value[2])) {
  488.             $this->V_THRESHOLD = $table_sdi_value[2];
  489.         else {
  490.             $this->V_THRESHOLD = "NULL";
  491.         }
  492.         $this->V_SCALE = $table_sdi_value[3];
  493.         $this->V_DATE_PUBLISHED = formatDate($table_sdi_value[4]true);
  494.         $this->V_STATUT = $table_sdi_value[5];
  495.         $this->V_COMMENT = $table_sdi_value[6];
  496.         $this->V_COMMENT_DISPLAY = $table_sdi_value[7];
  497.  
  498.         $q "INSERT INTO " $this->TDB_SDI_VALUE . " (sdiv_value, sdiv_sdi_info, sdiv_threshold, sdiv_comment, sdiv_comment_display, sdiv_scale, sdiv_date_published, sdiv_statut, sdiv_date_crea)
  499.         VALUES (" $this->V_VALUE . ", " $this->V_SDI_ID . ", " $this->V_THRESHOLD . ", '" $this->V_COMMENT . "', '" $this->V_COMMENT_DISPLAY . "', "
  500.         . $this->V_SCALE . ", '" $this->V_DATE_PUBLISHED . "', '" $this->V_STATUT . "', NOW());";
  501.  
  502.         $last_id $sql_object->DBInsert ($q1);
  503.  
  504.         // Notify the end of the current method
  505.         $this->dispatcher->notify(new sfEvent($this'indicator.after_add_value'array('data' => $table_sdi_value'id' => $last_id)));
  506.  
  507.         return $last_id;
  508.     }
  509.  
  510.     /**
  511.      * sdi::ModifySdi()
  512.      * modification d'un IDD
  513.      *
  514.      * @access public
  515.      * @param int $ID identifiant de l'IDD
  516.      * @param object $sql_object 
  517.      * @param array $table_sdi_info contient les composants d'un IDD
  518.      * @return bool $result
  519.      */
  520.     function ModifySdi($ID$table_sdi_info$sql_object)
  521.     {
  522.         // Filter data event + return value
  523.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_modify_indicator'array('data' => $table_sdi_info))$table_sdi_info);
  524.         $table_sdi_info $r->getReturnValue();
  525.          
  526.         $table_sdi_info=$sql_object->DBescape($table_sdi_info);
  527.  
  528.         if (is_numeric($ID)) {
  529.             $this->I_ID = $ID;
  530.         else return false;
  531.  
  532.         $this->I_NAME = strip_input($table_sdi_info[0]);
  533.         $this->I_DESCRIPTION = strip_input($table_sdi_info[1]true);
  534.         $this->I_COMMENT = strip_input($table_sdi_info[2]true);
  535.         $this->I_THEME = $table_sdi_info[3];
  536.         $this->I_RANGE = $table_sdi_info[4];
  537.         $this->I_GOAL = strip_input($table_sdi_info[5]true);
  538.         $this->I_CONSULTING = strip_input($table_sdi_info[6]true);
  539.         $this->I_UNIT = strip_input($table_sdi_info[7]);
  540.         if($table_sdi_info[8]==''{
  541.             $this->I_MAX_VALUE="NULL";
  542.         else {
  543.             $this->I_MAX_VALUE=$table_sdi_info[8];
  544.         }
  545.         if($table_sdi_info[9]==''{
  546.             $this->I_MIN_VALUE="NULL";
  547.         else {
  548.             $this->I_MIN_VALUE=$table_sdi_info[9];
  549.         }
  550.         if($table_sdi_info[10]==''{
  551.             $this->I_THRESHOLD="NULL";
  552.         else {
  553.             $this->I_THRESHOLD=$table_sdi_info[10];
  554.         }
  555.         $this->I_FREQUENCY = $table_sdi_info[11];
  556.         $this->I_STATUT = $table_sdi_info[12];
  557.         $this->I_THRESHOLD_RELATIVE = $table_sdi_info[13];
  558.         $this->I_DASHBOARD = $table_sdi_info[14];
  559.         $this->I_TYPE = $table_sdi_info[15];
  560.         $this->I_DASHBOARD_VIZ = $table_sdi_info[16];
  561.         $this->I_DETAIL_VIZ = $table_sdi_info[17];
  562.  
  563.         $q "UPDATE " $this->TDB_SDI_INFO . " SET sdii_type='"
  564.         . $this->I_TYPE ."', sdii_dashboard_viz='" 
  565.         . $this->I_DASHBOARD_VIZ ."', sdii_detail_viz='" 
  566.         . $this->I_DETAIL_VIZ ."', sdii_name='" 
  567.         . $this->I_NAME . "', sdii_description='"
  568.         . $this->I_DESCRIPTION . "', sdii_comment='" $this->I_COMMENT . "', sdii_theme="
  569.         . $this->I_THEME . ", sdii_range=" $this->I_RANGE . ", sdii_goal='"
  570.         . $this->I_GOAL . "', sdii_consulting='" $this->I_CONSULTING . "', sdii_to_dashboard='"
  571.         . $this->I_DASHBOARD . "', sdii_unit='"
  572.         . $this->I_UNIT . "', sdii_max_value=" $this->I_MAX_VALUE . ", sdii_min_value="
  573.         . $this->I_MIN_VALUE . ", sdii_threshold_value=" $this->I_THRESHOLD . ", sdii_threshold_relative='" $this->I_THRESHOLD_RELATIVE . "', sdii_frequency="
  574.         . $this->I_FREQUENCY . ", sdii_statut='"
  575.         . $this->I_STATUT . "', sdii_last_modify= NOW()
  576.         WHERE sdii_id=" $this->I_ID . ";";
  577.         $result $sql_object->DBQuery ($q);
  578.  
  579.         // Notify the end of the current method
  580.         $this->dispatcher->notify(new sfEvent($this'indicator.after_modify_indicator'array('data' => $table_sdi_info'id' => $ID)));
  581.  
  582.         return $result;
  583.     }
  584.  
  585.     /**
  586.      * sdi::_GetKeysSdi()
  587.      * récupération des clés d'un ID
  588.      *
  589.      * @access private
  590.      * @param int $id_id identifiant de l'IDD
  591.      * @param object $sql_object 
  592.      * @return array $table_key
  593.      */
  594.     function _GetKeysSdi($sdi_id$sql_object)
  595.     {
  596.         // Notify the end of the current method
  597.         $this->dispatcher->notify(new sfEvent($this'indicator.get_indicator_keys'array('id' => $sdi_id)));
  598.          
  599.         if (is_numeric($sdi_id)) {
  600.             $this->I_ID = $sdi_id;
  601.         }
  602.         $q "SELECT sdii_provider, sdii_evaluation, sdii_reglementation
  603.         FROM " $this->TDB_SDI_INFO . "
  604.         WHERE sdii_id=" $this->I_ID . ";";
  605.         $result $sql_object->DBSelect($q);
  606.  
  607.         return $result;
  608.  
  609.     }
  610.  
  611.     /**
  612.      * sdi::ModifyParam()
  613.      * modification des paramètres d'un IDD en fonction de son sdii_id
  614.      *
  615.      * @access public
  616.      * @param int $ID identifiant de l'IDD
  617.      * @param array $tableparam contient les composants d'un IDD
  618.      * @param string $param paramètre passé :
  619.      *  E -> evaluation
  620.      *  P -> provider
  621.      *  R -> reglementation
  622.      * @param object $sql_object 
  623.      * @return bool $result
  624.      */
  625.     function ModifyParam($ID$tableparam$param$sql_object)
  626.     {
  627.         // Filter data event + return value
  628.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_modify_params'array('data' => $tableparam'id' => $ID'element' => $param))$table_sdi_info);
  629.         $table_sdi_info $r->getReturnValue();
  630.          
  631.         $param strtoupper($param);
  632.         switch ($param{
  633.             case 'E':
  634.                 $data $this->_GetKeysSdi($ID$sql_object);
  635.                 $id_e $data[0]['sdii_evaluation'];
  636.                 $result $this->_ModifyEvaluation($id_e$tableparam$sql_object);
  637.                 break;
  638.             case 'P':
  639.                 $data $this->_GetKeysSdi($ID$sql_object);
  640.                 $id_p $data[0]['sdii_provider'];
  641.                 $result $this->_ModifyProvider($id_p$tableparam$sql_object);
  642.                 break;
  643.             case 'R':
  644.                 $data $this->_GetKeysSdi($ID$sql_object);
  645.                 $id_r $data[0]['sdii_reglementation'];
  646.                 $result $this->_ModifyRules($id_r$tableparam$sql_object);
  647.                 break;
  648.         }
  649.  
  650.         // Notify the end of the current method
  651.         $this->dispatcher->notify(new sfEvent($this'indicator.after_modify_params'array('data' => $tableparam'id' => $ID'element' => $param)));
  652.  
  653.         return $result;
  654.     }
  655.     /**
  656.      * sdi::DeleteSdi()
  657.      * suppression d'un IDD
  658.      *
  659.      * @access public
  660.      * @param int $id identifiant de l'IDD a supprimer
  661.      * @param object $sql_object 
  662.      * @return bool $result
  663.      */
  664.     function DeleteSdi($ID$sql_object)
  665.     {
  666.         // Notify the end of the current method
  667.         $this->dispatcher->notify(new sfEvent($this'indicator.delete_indicator'array('id' => $ID)));
  668.          
  669.         $state "E";
  670.         $result $this->StateSdi($ID$state$sql_object);
  671.         $q "UPDATE " $this->TDB_SDI_VALUE . " SET sdiv_statut='" $state "' WHERE sdiv_sdi_info=" $ID ";";
  672.         $result2 $sql_object->DBQuery ($q);
  673.         return $result;
  674.     }
  675.  
  676.     /**
  677.      * sdi::_ModifyEvaluation()
  678.      * modification d'une évaluation IDD
  679.      *
  680.      * @access private
  681.      * @param int $ID identifiant de l'évaluation
  682.      * @param object $sql_object 
  683.      * @param array $table_sdi_eval contient les composants d'un IDD
  684.      * @return bool $result
  685.      */
  686.     function _ModifyEvaluation($ID$table_sdi_eval$sql_object)
  687.     {
  688.         // Filter data event + return value
  689.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_modify_evaluation'array('data' => $table_sdi_eval'id' => $ID))$table_sdi_eval);
  690.         $table_sdi_eval $r->getReturnValue();
  691.          
  692.         $table_sdi_eval=$sql_object->DBescape($table_sdi_eval);
  693.  
  694.         if (is_numeric($ID)) {
  695.             $this->E_ID = $ID;
  696.         else return false;
  697.  
  698.         $this->E_SCALE = empty_numeric($table_sdi_eval[0]);
  699.         $this->E_FIABILITY = empty_numeric($table_sdi_eval[1]);
  700.         $this->E_ACCESSIBILITY = empty_numeric($table_sdi_eval[2]);
  701.         $this->E_LISIBILITY = empty_numeric($table_sdi_eval[3]);
  702.         $this->E_RELEVANCE = empty_numeric($table_sdi_eval[4]);
  703.         $this->E_GLOBAL_PERFORMANCE = empty_numeric($table_sdi_eval[5]);
  704.  
  705.  
  706.         $q "UPDATE " $this->TDB_SDI_EVAL . " SET sdie_scale_compare='" $this->E_SCALE . "', sdie_fiability='"
  707.         . $this->E_FIABILITY . "', sdie_accessibility='" $this->E_ACCESSIBILITY . "', sdie_lisibility='"
  708.         . $this->E_LISIBILITY . "', sdie_relevance='" $this->E_RELEVANCE . "', sdie_global_performance='"
  709.         . $this->E_GLOBAL_PERFORMANCE . "', sdie_last_modify = NOW()
  710.         WHERE sdie_id=" $this->E_ID . ";";
  711.  
  712.         $result $sql_object->DBQuery ($q);
  713.  
  714.         // Notify the end of the current method
  715.         $this->dispatcher->notify(new sfEvent($this'indicator.after_modify_evaluation'array('data' => $table_sdi_eval'id' => $ID)));
  716.  
  717.         return $result;
  718.     }
  719.  
  720.     /**
  721.      * sdi::_ModifyProvider()
  722.      * modification d'un fournisseur IDD
  723.      *
  724.      * @access private
  725.      * @param int $ID identifiant du fournisseur
  726.      * @param object $sql_object 
  727.      * @param array $table_sdi_provider contient les composants d'un fournisseur
  728.      * @return bool $result
  729.      */
  730.     function _ModifyProvider ($ID$table_sdi_provider$sql_object)
  731.     {
  732.         // Filter data event + return value
  733.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_modify_provider'array('data' => $table_sdi_provider'id' => $ID))$table_sdi_provider);
  734.         $table_sdi_provider $r->getReturnValue();
  735.          
  736.         $table_sdi_provider=$sql_object->DBescape($table_sdi_provider);
  737.  
  738.         if (is_numeric($ID)) {
  739.             $this->P_ID = $ID;
  740.         else return false;
  741.  
  742.         $this->P_NAME = strip_input($table_sdi_provider[0]);
  743.         $this->P_SERVICE = strip_input($table_sdi_provider[1]);
  744.         $this->P_DESCRIPTION = strip_input($table_sdi_provider[2]true);
  745.         $this->P_INCHARGE = strip_input($table_sdi_provider[3]);
  746.         $this->P_ADDRESS = strip_input($table_sdi_provider[4]true);
  747.         $this->P_PHONE = strip_input($table_sdi_provider[5]);
  748.         $this->P_FAX = strip_input($table_sdi_provider[6]);
  749.         $this->P_EMAIL = strip_input($table_sdi_provider[7]);
  750.  
  751.         $q "UPDATE " $this->TDB_SDI_PROVIDER . " SET sdip_name= '" $this->P_NAME . "', sdip_service='"
  752.         . $this->P_SERVICE . "', sdip_description='" $this->P_DESCRIPTION . "', sdip_incharge='"
  753.         . $this->P_INCHARGE . "', sdip_address='" $this->P_ADDRESS . "', sdip_phone='"
  754.         . $this->P_PHONE . "', sdip_fax='" $this->P_FAX . "', sdip_email='"
  755.         . $this->P_EMAIL . "', sdip_last_modify = NOW()
  756.         WHERE sdip_id='" $this->P_ID . "';";
  757.  
  758.         $result $sql_object->DBQuery ($q);
  759.  
  760.         // Notify the end of the current method
  761.         $this->dispatcher->notify(new sfEvent($this'indicator.after_modify_provider'array('data' => $table_sdi_provider'id' => $ID)));
  762.  
  763.         return $result;
  764.     }
  765.  
  766.     /**
  767.      * sdi::_ModifyRules()
  768.      * modification d'une réglementation
  769.      *
  770.      * @access private
  771.      * @param int $ID identifiant d'une réglementation
  772.      * @param object $sql_object 
  773.      * @param array $table_sdi_rules contient les composants d'une réglementation
  774.      * @return bool $result
  775.      */
  776.     function _ModifyRules ($ID$table_sdi_rules$sql_object)
  777.     {
  778.         // Filter data event + return value
  779.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_modify_rules'array('data' => $table_sdi_rules'id' => $ID))$table_sdi_rules);
  780.         $table_sdi_rules $r->getReturnValue();
  781.          
  782.         $table_sdi_rules=$sql_object->DBescape($table_sdi_rules);
  783.  
  784.         if (is_numeric($ID)) {
  785.             $this->R_ID = $ID;
  786.         else return false;
  787.  
  788.         $this->R_TITLE = strip_input($table_sdi_rules[0]);
  789.         $this->R_BODY = strip_input($table_sdi_rules[1]true);
  790.         $this->R_REFERER_URI = strip_input($table_sdi_rules[2]);
  791.         $this->R_MASK_URI = strip_input($table_sdi_rules[3]);
  792.  
  793.         $q "UPDATE " $this->TDB_SDI_RULES . " SET sdir_title= '" $this->R_TITLE . "', sdir_body='"
  794.         . $this->R_BODY . "', sdir_referer_uri='" $this->R_REFERER_URI . "', sdir_mask_uri='"
  795.         . $this->R_MASK_URI . "',  sdir_last_modify = NOW()
  796.         WHERE sdir_id='" $this->R_ID . "';";
  797.  
  798.         $result $sql_object->DBQuery ($q);
  799.  
  800.         // Notify the end of the current method
  801.         $this->dispatcher->notify(new sfEvent($this'indicator.after_modify_rules'array('data' => $table_sdi_rules'id' => $ID)));
  802.  
  803.         return $result;
  804.     }
  805.  
  806.     /**
  807.      * sdi::ModifyValue()
  808.      * modification d'une valeur
  809.      *
  810.      * @access public
  811.      * @param int $ID identifiant d'une valeur
  812.      * @param object $sql_object 
  813.      * @param array $table_sdi_value contient les composants d'une valeur
  814.      * @return bool $result
  815.      */
  816.     function ModifyValue ($ID$table_sdi_value$sql_object)
  817.     {
  818.         // Filter data event + return value
  819.         $r $this->dispatcher->filter(new sfEvent($this'indicator.before_modify_value'array('data' => $table_sdi_value'id' => $ID))$table_sdi_value);
  820.         $table_sdi_value $r->getReturnValue();
  821.          
  822.         $table_sdi_value=$sql_object->DBescape($table_sdi_value);
  823.  
  824.         if (is_numeric($ID)) {
  825.             $this->V_ID = $ID;
  826.         else return false;
  827.  
  828.         $this->V_VALUE = $table_sdi_value[0];
  829.         $this->V_SDI_ID = $table_sdi_value[1];
  830.         $this->V_THRESHOLD = $table_sdi_value[2];
  831.         $this->V_SCALE = $table_sdi_value[3];
  832.         $this->V_DATE_PUBLISHED = formatDate($table_sdi_value[4]true);
  833.         $this->V_STATUT = $table_sdi_value[5];
  834.         $this->V_COMMENT = $table_sdi_value[6];
  835.         $this->V_COMMENT_DISPLAY = $table_sdi_value[7];
  836.  
  837.         $q "UPDATE " $this->TDB_SDI_VALUE . " SET sdiv_value=" $this->V_VALUE . ", sdiv_sdi_info="
  838.         . $this->V_SDI_ID . ", sdiv_threshold=".$this->V_THRESHOLD", sdiv_comment='".$this->V_COMMENT."', sdiv_comment_display='".$this->V_COMMENT_DISPLAY."', sdiv_scale=" $this->V_SCALE . ",sdiv_date_published='" $this->V_DATE_PUBLISHED . "',sdiv_statut='" $this->V_STATUT . "', sdiv_last_modify = NOW()
  839.         WHERE sdiv_id=" $this->V_ID . ";";
  840.  
  841.         $result $sql_object->DBQuery ($q);
  842.  
  843.         // Notify the end of the current method
  844.         $this->dispatcher->notify(new sfEvent($this'indicator.after_modify_value'array('data' => $table_sdi_value'id' => $ID)));
  845.  
  846.         return $result;
  847.     }
  848.  
  849.     /**
  850.      * sdi::ModifyRange()
  851.      * modification simple du rang d'un IDD
  852.      *
  853.      * @access public
  854.      * @param int $ID identifiant de l'IDD
  855.      * @param object $sql_object 
  856.      * @param int $range contient la valeur du rang à modifier
  857.      * @return bool $result
  858.      */
  859.     function ModifyRange ($ID$range$sql_object)
  860.     {
  861.         // Notify the end of the current method
  862.         $this->dispatcher->notify(new sfEvent($this'indicator.change_range'array('id' => $ID'range' => $range)));
  863.          
  864.         if (is_numeric($ID)) {
  865.             $this->I_ID = $ID;
  866.         else return false;
  867.  
  868.         if (is_numeric($range)) {
  869.             $this->I_RANGE = $range;
  870.         else return false;
  871.  
  872.         $q "UPDATE " $this->TDB_SDI_INFO . " SET sdii_range=" $this->I_RANGE . ",    sdii_last_modify= NOW() WHERE sdii_id='" $this->I_ID . "';";
  873.  
  874.         $result $sql_object->DBQuery ($q);
  875.  
  876.         return $result;
  877.     }
  878.  
  879.     /**
  880.      * sdi::StateSdi()
  881.      * modification simple du statut d'un IDD
  882.      *
  883.      * @access public
  884.      * @param int $ID identifiant de l'IDD
  885.      * @param object $sql_object 
  886.      * @param string $state contient la valeur du statut à modifier
  887.      * @return bool $result
  888.      */
  889.     function StateSdi ($ID$state$sql_object)
  890.     {
  891.         // Notify the end of the current method
  892.         $this->dispatcher->notify(new sfEvent($this'indicator.change_indicator_state'array('id' => $ID'state' => $state)));
  893.          
  894.         if (is_numeric($ID)) {
  895.             $this->ID $ID;
  896.         else return false;
  897.  
  898.         $q "UPDATE " $this->TDB_SDI_INFO . " SET sdii_statut='" $state "' WHERE sdii_id=" $this->ID ";";
  899.         $result $sql_object->DBQuery ($q);
  900.         return $result;
  901.     }
  902.  
  903.  
  904.  
  905.     /**
  906.      * sdi::StateValue()
  907.      * modification simple du statut d'une valeur d'un IDD
  908.      *
  909.      * @access public
  910.      * @param int $id identifiant de l'IDD
  911.      * @param object $sql_object 
  912.      * @param string $state contient la valeur du statut à modifier
  913.      * @return bool $result
  914.      */
  915.     function StateValue ($ID$state$sql_object)
  916.     {
  917.         // Notify the end of the current method
  918.         $this->dispatcher->notify(new sfEvent($this'indicator.change_value_state'array('id' => $ID'state' => $state)));
  919.          
  920.         if (is_numeric($ID)) {
  921.             $this->ID $ID;
  922.         else return false;
  923.         $q "UPDATE " $this->TDB_SDI_VALUE . " SET sdiv_statut='" $state "' WHERE sdiv_id=" $this->ID ";";
  924.         $result $sql_object->DBQuery ($q);
  925.         return $result;
  926.     }
  927.  
  928.     /**
  929.      * sdi::DeleteValue()
  930.      * suppression  d'une valeur d'un IDD
  931.      *
  932.      * @access public
  933.      * @param int $id identifiant de la valeur a supprimer
  934.      * @param object $sql_object 
  935.      * @return bool $result
  936.      */
  937.     function DeleteValue ($ID$sql_object)
  938.     {
  939.         // Notify the end of the current method
  940.         $this->dispatcher->notify(new sfEvent($this'indicator.delete_value'array('id' => $ID)));
  941.          
  942.         $state "E";
  943.         $result $this->StateValue($ID$state$sql_object);
  944.         return $result;
  945.     }
  946.  
  947.  
  948.     function _GetInfoSdi($id$sql_object)
  949.     {
  950.         // Notify the end of the current method
  951.         $this->dispatcher->notify(new sfEvent($this'indicator.get_info'array('id' => $id)));
  952.          
  953.         if(SQL=='mysql'$datefunction="DATE_FORMAT";
  954.         if(SQL=='pgsql'$datefunction="to_char";
  955.  
  956.         $q "SELECT II.sdii_id, II.sdii_name, II.sdii_description, II.sdii_comment, T.theme_name, II.sdii_theme,
  957.         II.sdii_range, II.sdii_goal, II.sdii_consulting, II.sdii_unit, II.sdii_max_value, II.sdii_min_value,
  958.         II.sdii_threshold_value, II.sdii_threshold_relative, II.sdii_frequency, II.sdii_provider, IP.sdip_name, II.sdii_evaluation, II.sdii_reglementation,
  959.         " $datefunction "(II.sdii_date_crea, '" toStringSqlDate("' ) AS date_c, II.sdii_statut
  960.         FROM " $this->TDB_SDI_INFO . " AS II LEFT OUTER JOIN " $this->TDB_THEME . " as T on II.sdii_theme=T.theme_id
  961.         LEFT OUTER JOIN " $this->TDB_SDI_PROVIDER . " as IP on II.sdii_provider=IP.sdip_id";
  962.         $q .= " WHERE II.sdii_id=" $id ";";
  963.  
  964.         $result $sql_object->DBSelect ($q);
  965.  
  966.         return $result;
  967.     }
  968.     
  969.     /**
  970.      * sdi::getScalesThresholds()
  971.      * return an associative array with  threshold value for
  972.      * each scale (as key)
  973.      *
  974.      * @access public
  975.      * @param int $id Indicator ID
  976.      * @param $default_threshold 
  977.      * @param object $sql_object 
  978.      * @return array $a
  979.      */
  980.     function getScalesThresholds($id$default_threshold$sql_object{
  981.     
  982.         $a array();
  983.         $scales $sql_object -> DBSelect(SQL_getAllScale()'OBJECT');
  984.     
  985.         foreach($scales as $scale{
  986.     
  987.             $r $sql_object -> DBSelect(SQL_getlastInsertByPublicationDate($id$scale->scale_id));
  988.             if(isset($r[0]['sdiv_value']&& !is_null($r[0]['sdiv_threshold'])) {
  989.                 $a[$scale->scale_id$r[0]['sdiv_threshold'];
  990.                 _debug('key : '$scale->scale_id ' - value  : '.$r[0]['sdiv_threshold']);
  991.             else {
  992.                 $a[$scale->scale_id$default_threshold;
  993.                 _debug('key : '$scale->scale_id ' - value  : '.$default_threshold'(default)');
  994.             }
  995.         }
  996.         return $a;
  997.     }
  998.  
  999.  
  1000. }
  1001.  
  1002. ?>

Documentation generated on Mon, 08 Apr 2013 18:13:08 +0200 by phpDocumentor 1.4.1