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

Documentation generated on Thu, 20 Mar 2014 16:46:52 +0100 by phpDocumentor 1.4.1