_GetInfoSdi($table[1], $sql_object); if ($table[0] > $result[0]['sdii_max_value'])return $notgoodvalue; if ($table[0] < $result[0]['sdii_min_value'])return $notgoodvalue; return true; } /** * sdi::CheckDataIntegrity_info() * Vérification des données générales d'un indicateur * * @access public * @param array $table contient les composants d'un indicateur * @return boolean si vrai renvoie true sinon message d'erreurs (string) */ function CheckDataIntegrity_info($table) { //include('../languages/' . LANGUAGE . '/lang_sdi.php'); $notname = $GLOBALS['lang']['sdi']['object_notname']; $notdescription = $GLOBALS['lang']['sdi']['object_notdescription']; $nottheme = $GLOBALS['lang']['sdi']['object_nottheme']; //$notrange = $GLOBALS['lang']['sdi']['object_notrange']; $notunit = $GLOBALS['lang']['sdi']['object_notunit']; $notmax_value = $GLOBALS['lang']['sdi']['object_notmax_value']; $notmin_value = $GLOBALS['lang']['sdi']['object_notmin_value']; $notthreshold_value = $GLOBALS['lang']['sdi']['object_notthreshold_value']; $notfrequency = $GLOBALS['lang']['sdi']['object_notfrequency']; if (strlen($table[0]) < 2) return $notname; if (strlen($table[1]) < 2) return $notdescription; if ($table[3] == 0) return $nottheme; // if ($table[4] == "") return $notrange; if (!is_numeric($table[8])) return $notmax_value; if (!is_numeric($table[9])) return $notmin_value; if (!is_numeric($table[10])) return $notthreshold_value; if (!is_numeric($table[11])) return $notfrequency; return true; } /** * sdi::CheckDataIntegrity_eval() * Vérification des données d'évaluation d'un indicateur * * @access public * @param array $table contient les composants évaluation d'un indicateur * @return boolean si vrai renvoie true sinon message d'erreurs (string) */ function CheckDataIntegrity_eval($table) { //include('../languages/' . LANGUAGE . '/lang_sdi.php'); $note_scale_compare = $GLOBALS['lang']['sdi']['object_note_scale_compare']; $note_fiability = $GLOBALS['lang']['sdi']['object_note_fiability']; $note_accessibility = $GLOBALS['lang']['sdi']['object_note_accessibility']; $note_lisibility = $GLOBALS['lang']['sdi']['object_note_lisibility']; $note_relevance = $GLOBALS['lang']['sdi']['object_note_relevance']; $note_global_performance = $GLOBALS['lang']['sdi']['object_note_global_performance']; if (!is_numeric($table[13])) return $note_scale_compare; if (!is_numeric($table[14])) return $note_fiability; if (!is_numeric($table[15])) return $note_accessibility; if (!is_numeric($table[16])) return $note_lisibility; if (!is_numeric($table[17])) return $note_relevance; if (!is_numeric($table[18])) return $note_global_performance; return true; } /** * sdi::CheckDataIntegrity_provider() * Vérification des données d'un fournisseur d'un indicateur * * @access public * @param array $table contient les composants évaluation d'un indicateur * @return boolean si vrai renvoie true sinon message d'erreurs (string) */ function CheckDataIntegrity_provider($table) { //include('../languages/' . LANGUAGE . '/lang_sdi.php'); $notp_name = $GLOBALS['lang']['sdi']['object_notp_name']; $notp_address = $GLOBALS['lang']['sdi']['object_notp_address']; $notp_phone = $GLOBALS['lang']['sdi']['object_notp_phone']; $notp_fax = $GLOBALS['lang']['sdi']['object_notp_fax']; $notp_mail = $GLOBALS['lang']['sdi']['object_notp_mail']; if (strlen($table[19]) < 2) return $notp_name; if (strlen($table[23]) < 2) return $notp_address; if (trim($table[24]) != '' && !is_numeric($table[24])) return $notp_phone; if (trim($table[25]) != '' && !is_numeric($table[25])) return $notp_fax; $testmail = $this->_checkEmailValidity($table[26]); if ($testmail != 1) return $notp_mail; return true; } /** * sdi::_checkEmailValidity() * Vérification du mail * * @access private * @param string $email contient les composants d'un mail * @return boolean si vrai renvoie true sinon message d'erreurs (string) */ function _checkEmailValidity($email) { $email = strtolower($email); if (strlen($email) < 6 || !ereg("@", $email) || preg_match_all("/([^a-zA-Z0-9_\@\.\-])/i", $email, $trouve) || !preg_match("/^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}\$/i", $email)) { return 0; } return 1; } /** * sdi::CheckDataIntegrity_reglementation() * Vérification des données de réglementation d'un indicateur * * @access public * @param array $table contient les composants réglementation d'un indicateur * @return boolean si vrai renvoie true sinon message d'erreurs (string) */ function CheckDataIntegrity_reglementation($table) { //include('../languages/' . LANGUAGE . '/lang_sdi.php'); $notr_title = $GLOBALS['lang']['sdi']['object_notr_title']; $notr_body = $GLOBALS['lang']['sdi']['object_notr_body']; if (strlen($table[27]) < 2) return $notr_title; if (strlen($table[28]) < 2) return $notr_body; return true; } /** * sdi::_AddProvider() * Ajout d'un nouveau fournisseur d'un IDD * * @access private * @param object $sql_object * @return integer $last_id */ function _AddProvider($sql_object) { $requete = "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());"; $last_id = $sql_object->DBInsert ($requete, 1); return $last_id; } /** * sdi::_AddEvaluation() * Ajout de critères d'évaluation d'un IDD * * @access private * @param object $sql_object * @return integer $last_id */ function _AddEvaluation ($sql_object) { $requete = "INSERT INTO " . $this->TDB_SDI_EVAL . "(sdie_scale_compare, sdie_fiability, sdie_accessibility, sdie_lisibility, sdie_relevance, sdie_global_performance, sdie_date_crea)VALUES ('', '', '', '', '', '',NOW());"; $last_id = $sql_object->DBInsert ($requete, 1); return $last_id; } /** * sdi::_AddRules() * Ajout d'une réglementation d'un IDD * * @access private * @param object $sql_object * @return integer $last_id */ function _AddRules($sql_object) { $requete = "INSERT INTO " . $this->TDB_SDI_RULES . " (sdir_title, sdir_body, sdir_referer_uri, sdir_mask_uri, sdir_date_crea) VALUES ('', '', '', '', NOW());"; $last_id = $sql_object->DBInsert ($requete, 1); return $last_id; } /** * sdi::AddSdi() * Ajout d'un IDD * * @access public * @param array $table_sdi_info contient les infos detaillees d'un IDD * @param object $sql_object * @return integer $last_id */ function AddSdi($table_sdi_info, $sql_object) { $this->I_NAME = strip_tags($table_sdi_info[0]); $this->I_DESCRIPTION = strip_tags($table_sdi_info[1]); $this->I_COMMENT = strip_tags($table_sdi_info[2]); $this->I_THEME = $table_sdi_info[3]; $this->I_RANGE = $table_sdi_info[4]; $this->I_GOAL = strip_tags($table_sdi_info[5]); $this->I_CONSULTING = strip_tags($table_sdi_info[6]); $this->I_UNIT = strip_tags($table_sdi_info[7]); $this->I_MAX_VALUE = $table_sdi_info[8]; $this->I_MIN_VALUE = $table_sdi_info[9]; $this->I_THRESHOLD = $table_sdi_info[10]; $this->I_FREQUENCY = $table_sdi_info[11]; $this->I_PROVIDER = $this->_AddProvider($sql_object); $this->I_EVALUATION = $this->_AddEvaluation($sql_object); $this->I_REGLEMENTATION = $this->_AddRules($sql_object); $this->I_STATUT = $table_sdi_info[12]; $this->I_THRESHOLD_RELATIVE = $table_sdi_info[14]; $requete = "INSERT INTO " . $this->TDB_SDI_INFO . " (sdii_name, sdii_description, sdii_comment, sdii_theme, sdii_range, sdii_goal, sdii_consulting, sdii_unit, sdii_max_value, sdii_min_value, sdii_threshold_value, sdii_threshold_relative, sdii_frequency, sdii_provider, sdii_evaluation, sdii_reglementation, sdii_statut, sdii_date_crea) VALUES ('" . $this->I_NAME . "', '" . $this->I_DESCRIPTION . "', '" . $this->I_COMMENT . "', " . $this->I_THEME . ", " . $this->I_RANGE . ", '" . $this->I_GOAL . "', '" . $this->I_CONSULTING . "' , '" . $this->I_UNIT . "' , " . $this->I_MAX_VALUE . " , " . $this->I_MIN_VALUE . " , " . $this->I_THRESHOLD . " , '" . $this->I_THRESHOLD_RELATIVE . "' , " . $this->I_FREQUENCY . " , " . $this->I_PROVIDER . " , " . $this->I_EVALUATION . " , " . $this->I_REGLEMENTATION . " ,'" . $this->I_STATUT . "' , CURRENT_TIMESTAMP());"; $result = $sql_object->DBInsert ($requete, 1); return $result; } /** * sdi::AddValue() * Ajout d'une valeur IDD * * @access public * @param array $table_sdi_value contient les composants d'une valeur d'un IDD * @param object $sql_object * @return integer $last_id */ function AddValue($table_sdi_value, $sql_object) { $this->V_VALUE = $table_sdi_value[0]; $this->V_SDI_ID = $table_sdi_value[1]; $this->V_SCALE = $table_sdi_value[2]; $this->V_DATE_PUBLISHED = $table_sdi_value[3]; $this->V_STATUT = $table_sdi_value[4]; $requete = "INSERT INTO " . $this->TDB_SDI_VALUE . " (sdiv_value, sdiv_sdi_info, sdiv_scale, sdiv_date_published, sdiv_statut, sdiv_date_crea) VALUES (" . $this->V_VALUE . ", " . $this->V_SDI_ID . ", " . $this->V_SCALE . ", '" . $this->V_DATE_PUBLISHED . "', '" . $this->V_STATUT . "', CURRENT_TIMESTAMP());"; $last_id = $sql_object->DBInsert ($requete, 1); return $last_id; } /** * sdi::ModifySdi() * modification d'un IDD * * @access public * @param int $ID identifiant de l'IDD * @param object $sql_object * @param array $table_sdi_info contient les composants d'un IDD * @return bool $result */ function ModifySdi($ID, $table_sdi_info, $sql_object) { if (is_numeric($ID)) { $this->I_ID = $ID; } else return false; $this->I_NAME = strip_tags($table_sdi_info[0]); $this->I_DESCRIPTION = strip_tags($table_sdi_info[1]); $this->I_COMMENT = strip_tags($table_sdi_info[2]); $this->I_THEME = $table_sdi_info[3]; $this->I_RANGE = $table_sdi_info[4]; $this->I_GOAL = strip_tags($table_sdi_info[5]); $this->I_CONSULTING = strip_tags($table_sdi_info[6]); $this->I_UNIT = strip_tags($table_sdi_info[7]); $this->I_MAX_VALUE = $table_sdi_info[8]; $this->I_MIN_VALUE = $table_sdi_info[9]; $this->I_THRESHOLD = $table_sdi_info[10]; $this->I_FREQUENCY = $table_sdi_info[11]; $this->I_STATUT = $table_sdi_info[12]; $this->I_THRESHOLD_RELATIVE = $table_sdi_info[13]; $requete = "UPDATE " . $this->TDB_SDI_INFO . " SET sdii_name='" . $this->I_NAME . "', sdii_description='" . $this->I_DESCRIPTION . "', sdii_comment='" . $this->I_COMMENT . "', sdii_theme=" . $this->I_THEME . ", sdii_range=" . $this->I_RANGE . ", sdii_goal='" . $this->I_GOAL . "', sdii_consulting='" . $this->I_CONSULTING . "', sdii_unit='" . $this->I_UNIT . "', sdii_max_value=" . $this->I_MAX_VALUE . ", sdii_min_value=" . $this->I_MIN_VALUE . ", sdii_threshold_value=" . $this->I_THRESHOLD . ", sdii_threshold_relative='" . $this->I_THRESHOLD_RELATIVE . "', sdii_frequency=" . $this->I_FREQUENCY . ", sdii_statut='" . $this->I_STATUT . "', sdii_last_modify= CURRENT_TIMESTAMP() WHERE sdii_id=" . $this->I_ID . ";"; $result = $sql_object->DBQuery ($requete); return $result; } /** * sdi::_GetKeysSdi() * récupération des clés d'un IDD * * @access private * @param int $id_id identifiant de l'IDD * @param object $sql_object * @return array $table_key */ function _GetKeysSdi($sdi_id, $sql_object) { if (is_numeric($sdi_id)) { $this->I_ID = $sdi_id; } $requete = "SELECT sdii_provider, sdii_evaluation, sdii_reglementation FROM " . $this->TDB_SDI_INFO . " WHERE sdii_id=" . $this->I_ID . ";"; $result = $sql_object->DBQuery ($requete); $i = 0; while ($data = mysql_fetch_assoc($result)) { $table_key[$i] = $data; $i++; } return $table_key; } /** * sdi::ModifyParam() * modification des paramètres d'un IDD en fonction de son sdii_id * * @access public * @param int $ID identifiant de l'IDD * @param array $tableparam contient les composants d'un IDD * @param string $param paramètre passé : * E -> evaluation * P -> provider * R -> reglementation * @param object $sql_object * @return bool $result */ function ModifyParam($ID, $tableparam, $param, $sql_object) { $param = strtoupper($param); switch ($param) { case 'E': $data = $this->_GetKeysSdi($ID, $sql_object); $id_e = $data[0]['sdii_evaluation']; $result = $this->_ModifyEvaluation($id_e, $tableparam, $sql_object); break; case 'P': $data = $this->_GetKeysSdi($ID, $sql_object); $id_p = $data[0]['sdii_provider']; $result = $this->_ModifyProvider($id_p, $tableparam, $sql_object); break; case 'R': $data = $this->_GetKeysSdi($ID, $sql_object); $id_r = $data[0]['sdii_reglementation']; $result = $this->_ModifyRules($id_r, $tableparam, $sql_object); break; } return $result; } /** * sdi::DeleteSdi() * suppression d'un IDD * * @access public * @param int $id identifiant de l'IDD a supprimer * @param object $sql_object * @return bool $result */ function DeleteSdi($ID, $sql_object) { $state = "E"; $result = $this->StateSdi($ID, $state, $sql_object); $requete = "UPDATE " . $this->TDB_SDI_VALUE . " SET sdiv_statut='" . $state . "' WHERE sdiv_sdi_info=" . $ID . ";"; $result2 = $sql_object->DBQuery ($requete); return $result; } /** * sdi::_ModifyEvaluation() * modification d'une évaluation IDD * * @access private * @param int $ID identifiant de l'évaluation * @param object $sql_object * @param array $table_sdi_eval contient les composants d'un IDD * @return bool $result */ function _ModifyEvaluation($ID, $table_sdi_eval, $sql_object) { if (is_numeric($ID)) { $this->E_ID = $ID; } else return false; $this->E_SCALE = $table_sdi_eval[0]; $this->E_FIABILITY = $table_sdi_eval[1]; $this->E_ACCESSIBILITY = $table_sdi_eval[2]; $this->E_LISIBILITY = $table_sdi_eval[3]; $this->E_RELEVANCE = $table_sdi_eval[4]; $this->E_GLOBAL_PERFORMANCE = $table_sdi_eval[5]; $requete = "UPDATE " . $this->TDB_SDI_EVAL . " SET sdie_scale_compare='" . $this->E_SCALE . "', sdie_fiability='" . $this->E_FIABILITY . "', sdie_accessibility='" . $this->E_ACCESSIBILITY . "', sdie_lisibility='" . $this->E_LISIBILITY . "', sdie_relevance='" . $this->E_RELEVANCE . "', sdie_global_performance='" . $this->E_GLOBAL_PERFORMANCE . "', sdie_last_modify = CURRENT_TIMESTAMP() WHERE sdie_id=" . $this->E_ID . ";"; $result = $sql_object->DBQuery ($requete); return $result; } /** * sdi::_ModifyProvider() * modification d'un fournisseur IDD * * @access private * @param int $ID identifiant du fournisseur * @param object $sql_object * @param array $table_sdi_provider contient les composants d'un fournisseur * @return bool $result */ function _ModifyProvider ($ID, $table_sdi_provider, $sql_object) { if (is_numeric($ID)) { $this->P_ID = $ID; } else return false; $this->P_NAME = strip_tags($table_sdi_provider[0]); $this->P_SERVICE = strip_tags($table_sdi_provider[1]); $this->P_DESCRIPTION = strip_tags($table_sdi_provider[2]); $this->P_INCHARGE = strip_tags($table_sdi_provider[3]); $this->P_ADDRESS = strip_tags($table_sdi_provider[4]); $this->P_PHONE = strip_tags($table_sdi_provider[5]); $this->P_FAX = strip_tags($table_sdi_provider[6]); $this->P_EMAIL = strip_tags($table_sdi_provider[7]); $requete = "UPDATE " . $this->TDB_SDI_PROVIDER . " SET sdip_name= '" . $this->P_NAME . "', sdip_service='" . $this->P_SERVICE . "', sdip_description='" . $this->P_DESCRIPTION . "', sdip_incharge='" . $this->P_INCHARGE . "', sdip_address='" . $this->P_ADDRESS . "', sdip_phone='" . $this->P_PHONE . "', sdip_fax='" . $this->P_FAX . "', sdip_email='" . $this->P_EMAIL . "', sdip_last_modify = CURRENT_TIMESTAMP() WHERE sdip_id='" . $this->P_ID . "';"; $result = $sql_object->DBQuery ($requete); return $result; } /** * sdi::_ModifyRules() * modification d'une réglementation * * @access private * @param int $ID identifiant d'une réglementation * @param object $sql_object * @param array $table_sdi_rules contient les composants d'une réglementation * @return bool $result */ function _ModifyRules ($ID, $table_sdi_rules, $sql_object) { if (is_numeric($ID)) { $this->R_ID = $ID; } else return false; $this->R_TITLE = strip_tags($table_sdi_rules[0]); $this->R_BODY = strip_tags($table_sdi_rules[1]); $this->R_REFERER_URI = strip_tags($table_sdi_rules[2]); $this->R_MASK_URI = strip_tags($table_sdi_rules[3]); $requete = "UPDATE " . $this->TDB_SDI_RULES . " SET sdir_title= '" . $this->R_TITLE . "', sdir_body='" . $this->R_BODY . "', sdir_referer_uri='" . $this->R_REFERER_URI . "', sdir_mask_uri='" . $this->R_MASK_URI . "', sdir_last_modify = CURRENT_TIMESTAMP() WHERE sdir_id='" . $this->R_ID . "';"; $result = $sql_object->DBQuery ($requete); return $result; } /** * sdi::ModifyValue() * modification d'une valeur * * @access public * @param int $ID identifiant d'une valeur * @param object $sql_object * @param array $table_sdi_value contient les composants d'une valeur * @return bool $result */ function ModifyValue ($ID, $table_sdi_value, $sql_object) { if (is_numeric($ID)) { $this->V_ID = $ID; } else return false; $this->V_VALUE = $table_sdi_value[0]; $this->V_SDI_ID = $table_sdi_value[1]; $this->V_SCALE = $table_sdi_value[2]; $this->V_DATE_PUBLISHED = $table_sdi_value[3]; $this->V_STATUT = $table_sdi_value[4]; $requete = "UPDATE " . $this->TDB_SDI_VALUE . " SET sdiv_value=" . $this->V_VALUE . ", sdiv_sdi_info=" . $this->V_SDI_ID . ", sdiv_scale=" . $this->V_SCALE . ",sdiv_date_published='" . $this->V_DATE_PUBLISHED . "',sdiv_statut='" . $this->V_STATUT . "', sdiv_last_modify = CURRENT_TIMESTAMP() WHERE sdiv_id=" . $this->V_ID . ";"; $result = $sql_object->DBQuery ($requete); return $result; } /** * sdi::ModifyRange() * modification simple du rang d'un IDD * * @access public * @param int $ID identifiant de l'IDD * @param object $sql_object * @param int $range contient la valeur du rang à modifier * @return bool $result */ function ModifyRange ($ID, $range, $sql_object) { if (is_numeric($ID)) { $this->I_ID = $ID; } else return false; if (is_numeric($range)) { $this->I_RANGE = $range; } else return false; $requete = "UPDATE " . $this->TDB_SDI_INFO . " SET sdii_range=" . $this->I_RANGE . ", sdii_last_modify= CURRENT_TIMESTAMP() WHERE sdii_id='" . $this->I_ID . "';"; $result = $sql_object->DBQuery ($requete); return $result; } /** * sdi::StateSdi() * modification simple du statut d'un IDD * * @access public * @param int $ID identifiant de l'IDD * @param object $sql_object * @param string $state contient la valeur du statut à modifier * @return bool $result */ function StateSdi ($ID, $state, $sql_object) { if (is_numeric($ID)) { $this->ID = $ID; } else return false; $requete = "UPDATE " . $this->TDB_SDI_INFO . " SET sdii_statut='" . $state . "' WHERE sdii_id=" . $this->ID . ";"; $result = $sql_object->DBQuery ($requete); return $result; } /** * sdi::StateValue() * modification simple du statut d'une valeur d'un IDD * * @access public * @param int $id identifiant de l'IDD * @param object $sql_object * @param string $state contient la valeur du statut à modifier * @return bool $result */ function StateValue ($ID, $state, $sql_object) { if (is_numeric($ID)) { $this->ID = $ID; } else return false; $requete = "UPDATE " . $this->TDB_SDI_VALUE . " SET sdiv_statut='" . $state . "' WHERE sdiv_id=" . $this->ID . ";"; $result = $sql_object->DBQuery ($requete); return $result; } /** * sdi::DeleteValue() * suppression d'une valeur d'un IDD * * @access public * @param int $id identifiant de la valeur a supprimer * @param object $sql_object * @return bool $result */ function DeleteValue ($ID, $sql_object) { $state = "E"; $result = $this->StateValue($ID, $state, $sql_object); return $result; } function _GetInfoSdi($id, $sql_object) { $requete = "SELECT II.sdii_id, II.sdii_name, II.sdii_description, II.sdii_comment, T.theme_name, II.sdii_theme, II.sdii_range, II.sdii_goal, II.sdii_consulting, II.sdii_unit, II.sdii_max_value, II.sdii_min_value, II.sdii_threshold_value, II.sdii_threshold_relative, II.sdii_frequency, II.sdii_provider, IP.sdip_name, II.sdii_evaluation, II.sdii_reglementation, DATE_FORMAT(II.sdii_date_crea, '" . $this->DATE_FORMAT . "' ) AS date_c, II.sdii_statut FROM " . $this->TDB_SDI_INFO . " AS II LEFT OUTER JOIN theme as T on II.sdii_theme=T.theme_id LEFT OUTER JOIN sdi_provider as IP on II.sdii_provider=IP.sdip_id"; $requete .= " WHERE II.sdii_id=" . $id . ";"; // echo $requete; $result = $sql_object->DBQuery ($requete); $i = 0; while ($data = mysql_fetch_assoc($result)) { $table[$i] = $data; $i++; } return $table; } } ?>