".$msg['noti_statut_libelle']." "; $i=0; foreach(static::$status as $id => $statut){ if ($i % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } print " ".htmlentities($statut['label'], ENT_QUOTES, $charset)." "; $i++; } print "
"; } public static function get_list(){ global $dbh; if(!static::$status_fetched){ static::$status = array(); $query = "select contribution_area_status_id, contribution_area_status_gestion_libelle,contribution_area_status_class_html, contribution_area_status_available_for from contribution_area_status order by contribution_area_status_gestion_libelle"; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ while($row = pmb_mysql_fetch_object($result)){ static::$status[$row->contribution_area_status_id] = array( 'label' => $row->contribution_area_status_gestion_libelle, 'class_html' => $row->contribution_area_status_class_html, 'available_for' => unserialize($row->contribution_area_status_available_for) ); if(!is_array(static::$status[$row->contribution_area_status_id]['available_for'])){ static::$status[$row->contribution_area_status_id]['available_for'] = array(); } } } static::$status_fetched = true; } } public static function show_form($id){ global $msg,$charset; global $admin_contribution_area_status_form; static::get_list(); $id = intval($id); $form = $admin_contribution_area_status_form; if(isset(static::$status[$id])){ $form_title = $msg['118']; $statut = static::$status[$id]; }else{ $form_title = $msg['115']; $statut = array( 'label' => "", 'class_html' => "statutnot1", 'available_for' => array() ); } $form = str_replace("!!form_title!!", $form_title, $form); $couleur = array(); for ($i=1;$i<=20; $i++) { if ($statut['class_html'] == "statutnot".$i){ $checked = "checked"; } else { $checked = ""; } $couleur[$i]=" "; if ($i==10) $couleur[10].="
"; elseif ($i!=20) $couleur[$i].="|"; } $couleurs=implode("",$couleur); $button = ""; if($id != 1 && isset(static::$status[$id])){ $button = ""; } $form = str_replace( array( "!!class_html!!", "!!gestion_libelle!!", '!!bouton_supprimer!!', ), array( $couleurs, htmlentities($statut['label'],ENT_QUOTES,$charset), $button, ), $form); $entities_list = static::get_pmb_entities(); $pmb_entities = ""; // Si c'est le "Statut par défaut" on désactive tout $default = ""; if ($id == 1) { $default = 'onclick="return false;" readonly="readonly"'; } $i = 0; foreach($entities_list as $value => $name){ if($i!= 0 && $i % 5 == 0){ $pmb_entities.= "
"; } $inputId = "entity_".$value; $isChecked = ""; if (in_array($value,$statut['available_for']) || $id == 1 || $id == 0) { $isChecked = 'checked="checked"'; } $pmb_entities .= ' '; $i++; } $form = str_replace( array( "!!coche_button_type!!", "!!list_entities!!", '!!libelle_suppr!!', "!!id!!" ), array( ($id==1 ? 'hidden' : "button"), $pmb_entities, addslashes($statut['label']), $id ), $form); $form .= confirmation_delete("./modelling.php?categ=contribution_area&sub=status&action=del&id="); print $form; } public static function get_from_from(){ global $id,$form_gestion_libelle,$form_class_html, $form_available_for; if($id == 1) { $form_available_for = array_keys(self::get_pmb_entities()); } return array( 'id' => stripslashes($id), 'label' => stripslashes($form_gestion_libelle), 'class_html' => stripslashes($form_class_html), 'available_for' => $form_available_for ); } public static function save($statut){ global $dbh; $statut['id'] += 0; if($statut['label'] != ""){ if($statut['id'] != 0){ $query = " update contribution_area_status set "; $where = "where contribution_area_status_id = ".$statut['id']; }else{ $query = " insert into contribution_area_status set "; $where = ""; } $query.=" contribution_area_status_gestion_libelle = '".addslashes($statut['label'])."', contribution_area_status_class_html = '".addslashes($statut['class_html'])."', contribution_area_status_available_for = '".addslashes(serialize($statut['available_for']))."' "; $result = pmb_mysql_query($query.$where,$dbh); if($result){ static::$status_fetched = false; }else{ return false; } } return true; } public static function delete($id) { global $dbh; $id+=0; if($id==1) return true; if(!count($used = static::check_used($id))){ $query = "delete from contribution_area_status where contribution_area_status_id = ".$id; pmb_mysql_query($query,$dbh); return true; } return false; } /** * Fonction qui controle si le status de contribution est utilisé * @param integer $id * @return array: */ public static function check_used($id){ global $dbh,$msg; global $base_path; $id+=0; $used = array(); return $used; } private static function get_pmb_entities(){ return contribution_area::get_pmb_entities(); } /** * Fonction permettant de générer le selecteur des statut définis pour un type d'autorité * @param integer $auth_type Constante type d'autorité (ou 1000+id authperso) * @param integer $auth_statut_id Identifiant du statut enregistré pour l'autorité courante * @param boolean $selector_search Sélécteur affiché dans la page de recherche * @return string */ public static function get_form_for($pmb_entity, $contribution_area_id, $search=false){ global $msg; $id+=0; $status_defined = static::get_status_for($pmb_entity); $on_change=''; if($search){ $on_change='onchange="if(this.form) this.form.submit();"'; } $selector = ''; return $selector; } /** * Fonction retournant un tableau des statut défini pour le type d'autorité passé en parametre * @param integer $auth_type Type d'autorité * @return array $status_found Tableau des status disponible pour le type d'autorité passé en parametre */ private static function get_status_for($pmb_entity){ /** * TODO test sur auth_type pour les authorités perso */ static::get_list(); $status_found = array(); foreach(static::$status as $id_statut => $statut){ if(in_array($pmb_entity,$statut['available_for']) || ($id_statut==1)){ $status_found[$id_statut] = $statut; } //TODO: array merge authority perso } return $status_found; } }