3 class sml_data_authors extends mw_data{
7 # ----------------------------------------------------------------------------------------
11 public function groupes($id_user = null, $start = null, $alpha = null){
12 $sgbd = $this->sgbd();
14 $groupes = array("list" => array(), "total" => 0);
15 if(true || isset($id_user)){
16 if($rst = $sgbd->open_data("sml_authors")){
17 while($v_rst = $sgbd->fetch_data($rst)){
19 if(!isset($alpha) || (isset($v_rst["nom"]) && substr($v_rst["nom"], 0, 1) == $alpha)){
20 if(!isset($id_user) || (isset($v_rst["id_user"]) && $v_rst["id_user"] == $id_user)){
22 $groupes["list"][$v_rst["id"]] = $v_rst;
31 $sgbd->close_data($rst);
32 if($groupes !== false){
34 foreach($groupes["list"] as $id_groupe => $groupe){
36 if(isset($start) && $env->config("max_list") && ($n < $start || $n >= ($start + $env->config("max_list")))){
37 unset($groupes["list"][$id_groupe]);
40 if(!isset($groupes["list"][$id_groupe]["image"])) $groupes["list"][$id_groupe]["image"] = "";
41 $groupes["list"][$id_groupe]["image_uri"] = (
42 $groupes["list"][$id_groupe]["image"] ?
43 $env->path("content")."uploads/".$groupes["list"][$id_groupe]["image"]
50 else $groupes = false;
55 public function groupe($id){
56 if(!isset($this->groupes)) $this->groupes = array();
57 if(isset($this->groupes[$id])) return $this->groupes[$id];
58 $sgbd = $this->sgbd();
60 if(($groupe = $sgbd->get_data("sml_authors", $id)) !== null){
61 if(!isset($groupe["image"])) $groupe["image"] = "";
62 $groupe["image_uri"] = (
64 $env->path("content")."uploads/".$groupe["image"]
69 if($groupe != false) $this->groupes[$id] = $groupe;
73 public function groupe_exists($nom, $other_than_id = null){
74 $sgbd = $this->sgbd();
76 if($rst = $sgbd->open_data("sml_authors")){
77 while($v_rst = $sgbd->fetch_data($rst)){
79 if(isset($v_rst["nom"]) && $v_rst["nom"] == $nom){
80 if(isset($other_than_id)){
81 if($v_rst["id"] != $other_than_id) $EXISTS++;
91 $sgbd->close_data($rst);
96 public function add_groupe($id_user, $nom, $image, $description, $email, $contact_form, $captcha){
97 $sgbd = $this->sgbd();
98 return $sgbd->add_data(
101 "id_user" => $id_user,
104 "description" => $description,
106 "contact_form" => $contact_form,
107 "captcha" => $captcha
112 public function set_groupe($id, $nom, $image, $description, $email, $contact_form, $captcha){
113 if(($groupe = $this->groupe($id)) !== false){
114 $sgbd = $this->sgbd();
115 if($nom != $groupe["nom"]){
116 $groupe["nom"] = $nom;
117 if(!$this->maj_source_xml_groupe($groupe)) return false;
119 return $sgbd->set_data(
123 "id_user" => $groupe["id_user"],
126 "description" => $description,
128 "contact_form" => $contact_form,
129 "captcha" => $captcha
136 public function del_groupe($id){
139 $sgbd = $this->sgbd();
141 if($rst = $sgbd->open_data("sml_sources_authors")){
142 while($source_author = $sgbd->fetch_data($rst)){
143 if(isset($source_author)){
144 if($source_author["id_author"] == $id){
154 $sgbd->close_data($rst);
159 return $sgbd->del_data("sml_authors", $id) ? true : false;