X-Git-Url: http://git.dj3c1t.com/?p=mw_sourceml;a=blobdiff_plain;f=app%2Fdata%2Fmodules%2Fxml%2Fsml_data_authors.php;fp=app%2Fdata%2Fmodules%2Fxml%2Fsml_data_authors.php;h=410227d6522038433ef80851a23b2c7cc46cb14b;hp=953ccfe936a61dd3e1df544c008c5ee7055fa9d4;hb=0b1ecd8b7536944d54d74ffc836982de3654d98b;hpb=3647c6bed06b3a1e3e014ef5a21074e7a6192899 diff --git a/app/data/modules/xml/sml_data_authors.php b/app/data/modules/xml/sml_data_authors.php index 953ccfe..410227d 100644 --- a/app/data/modules/xml/sml_data_authors.php +++ b/app/data/modules/xml/sml_data_authors.php @@ -1,46 +1,45 @@ sgbd(); + public function groupes($id_user = null, $start = null, $alpha = null){ + $sgbd = $this->sgbd(); $env = $this->env(); $groupes = array("list" => array(), "total" => 0); - if(true || isset($id_user)) - { if($rst = $sgbd->open_data("sml_authors")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(!isset($alpha) || (isset($v_rst["nom"]) && substr($v_rst["nom"], 0, 1) == $alpha)) - { if(!isset($id_user) || (isset($v_rst["id_user"]) && $v_rst["id_user"] == $id_user)) - { $groupes["total"]++; + if(true || isset($id_user)){ + if($rst = $sgbd->open_data("sml_authors")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(!isset($alpha) || (isset($v_rst["nom"]) && substr($v_rst["nom"], 0, 1) == $alpha)){ + if(!isset($id_user) || (isset($v_rst["id_user"]) && $v_rst["id_user"] == $id_user)){ + $groupes["total"]++; $groupes["list"][$v_rst["id"]] = $v_rst; } } } - else - { $groupes = false; + else{ + $groupes = false; break; } } $sgbd->close_data($rst); - if($groupes !== false) - { $n = -1; - foreach($groupes["list"] as $id_groupe => $groupe) - { $n++; - if(isset($start) && $env->config("max_list") && ($n < $start || $n >= ($start + $env->config("max_list")))) - { unset($groupes["list"][$id_groupe]); + if($groupes !== false){ + $n = -1; + foreach($groupes["list"] as $id_groupe => $groupe){ + $n++; + if(isset($start) && $env->config("max_list") && ($n < $start || $n >= ($start + $env->config("max_list")))){ + unset($groupes["list"][$id_groupe]); } else{ if(!isset($groupes["list"][$id_groupe]["image"])) $groupes["list"][$id_groupe]["image"] = ""; - $groupes["list"][$id_groupe]["image_uri"] = - ( $groupes["list"][$id_groupe]["image"] ? + $groupes["list"][$id_groupe]["image_uri"] = ( + $groupes["list"][$id_groupe]["image"] ? $env->path("content")."uploads/".$groupes["list"][$id_groupe]["image"] : "" ); @@ -53,15 +52,15 @@ return $groupes; } - function groupe($id){ + public function groupe($id){ if(!isset($this->groupes)) $this->groupes = array(); if(isset($this->groupes[$id])) return $this->groupes[$id]; $sgbd = $this->sgbd(); $env = $this->env(); if(($groupe = $sgbd->get_data("sml_authors", $id)) !== null){ if(!isset($groupe["image"])) $groupe["image"] = ""; - $groupe["image_uri"] = - ( $groupe["image"] ? + $groupe["image_uri"] = ( + $groupe["image"] ? $env->path("content")."uploads/".$groupe["image"] : "" ); @@ -71,21 +70,21 @@ return $groupe; } - function groupe_exists($nom, $other_than_id = null) - { $sgbd = $this->sgbd(); + public function groupe_exists($nom, $other_than_id = null){ + $sgbd = $this->sgbd(); $EXISTS = 0; - if($rst = $sgbd->open_data("sml_authors")) - { while($v_rst = $sgbd->fetch_data($rst)) - { if(isset($v_rst)) - { if(isset($v_rst["nom"]) && $v_rst["nom"] == $nom) - { if(isset($other_than_id)) - { if($v_rst["id"] != $other_than_id) $EXISTS++; + if($rst = $sgbd->open_data("sml_authors")){ + while($v_rst = $sgbd->fetch_data($rst)){ + if(isset($v_rst)){ + if(isset($v_rst["nom"]) && $v_rst["nom"] == $nom){ + if(isset($other_than_id)){ + if($v_rst["id"] != $other_than_id) $EXISTS++; } else $EXISTS++; } } - else - { $EXISTS = false; + else{ + $EXISTS = false; break; } } @@ -94,12 +93,12 @@ return $EXISTS; } - function add_groupe($id_user, $nom, $image, $description, $email, $contact_form, $captcha) - { $sgbd = $this->sgbd(); - return $sgbd->add_data - ( "sml_authors", - array - ( "id_user" => $id_user, + public function add_groupe($id_user, $nom, $image, $description, $email, $contact_form, $captcha){ + $sgbd = $this->sgbd(); + return $sgbd->add_data( + "sml_authors", + array( + "id_user" => $id_user, "nom" => $nom, "image" => $image, "description" => $description, @@ -110,18 +109,18 @@ ); } - function set_groupe($id, $nom, $image, $description, $email, $contact_form, $captcha) - { if(($groupe = $this->groupe($id)) !== false) - { $sgbd = $this->sgbd(); - if($nom != $groupe["nom"]) - { $groupe["nom"] = $nom; + public function set_groupe($id, $nom, $image, $description, $email, $contact_form, $captcha){ + if(($groupe = $this->groupe($id)) !== false){ + $sgbd = $this->sgbd(); + if($nom != $groupe["nom"]){ + $groupe["nom"] = $nom; if(!$this->maj_source_xml_groupe($groupe)) return false; } - return $sgbd->set_data - ( "sml_authors", + return $sgbd->set_data( + "sml_authors", $id, - array - ( "id_user" => $groupe["id_user"], + array( + "id_user" => $groupe["id_user"], "nom" => $nom, "image" => $image, "description" => $description, @@ -134,34 +133,32 @@ return false; } - function del_groupe($id) - { $OK = true; + public function del_groupe($id){ + $OK = true; $USED = false; $sgbd = $this->sgbd(); $env = $this->env(); - if($rst = $sgbd->open_data("sml_sources_authors")) - { while($source_author = $sgbd->fetch_data($rst)) - { if(isset($source_author)) - { if($source_author["id_author"] == $id) - { $USED = true; + if($rst = $sgbd->open_data("sml_sources_authors")){ + while($source_author = $sgbd->fetch_data($rst)){ + if(isset($source_author)){ + if($source_author["id_author"] == $id){ + $USED = true; break; } } - else - { $OK = false; + else{ + $OK = false; break; } } $sgbd->close_data($rst); } else $OK = false; - if($OK) - { if($USED) return 1; + if($OK){ + if($USED) return 1; return $sgbd->del_data("sml_authors", $id) ? true : false; } return false; } } - -?> \ No newline at end of file