3 class sml_data_authors extends mw_data
8 # ----------------------------------------------------------------------------------------
12 function groupes($id_user = null, $start = null, $alpha = null)
13 { $sgbd = $this->sgbd();
15 $groupes = array("list" => array(), "total" => 0);
16 if(true || isset($id_user))
17 { if($rst = $sgbd->open_data("sml_authors"))
18 { while($v_rst = $sgbd->fetch_data($rst))
20 { if(!isset($alpha) || (isset($v_rst["nom"]) && substr($v_rst["nom"], 0, 1) == $alpha))
21 { if(!isset($id_user) || (isset($v_rst["id_user"]) && $v_rst["id_user"] == $id_user))
22 { $groupes["total"]++;
23 $groupes["list"][$v_rst["id"]] = $v_rst;
32 $sgbd->close_data($rst);
33 if($groupes !== false)
35 foreach($groupes["list"] as $id_groupe => $groupe)
37 if(isset($start) && $env->config("max_list") && ($n < $start || $n >= ($start + $env->config("max_list"))))
38 { unset($groupes["list"][$id_groupe]);
41 { $groupes["list"][$id_groupe]["image_uri"] =
43 $env->path("content")."uploads/".$groupe["image"]
50 else $groupes = false;
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 { $groupe["image_uri"] =
63 $env->path("content")."uploads/".$groupe["image"]
68 if($groupe != false) $this->groupes[$id] = $groupe;
72 function groupe_exists($nom, $other_than_id = null)
73 { $sgbd = $this->sgbd();
75 if($rst = $sgbd->open_data("sml_authors"))
76 { while($v_rst = $sgbd->fetch_data($rst))
78 { if(isset($v_rst["nom"]) && $v_rst["nom"] == $nom)
79 { if(isset($other_than_id))
80 { if($v_rst["id"] != $other_than_id) $EXISTS++;
90 $sgbd->close_data($rst);
95 function add_groupe($id_user, $nom, $image, $description, $email, $contact_form, $captcha)
96 { $sgbd = $this->sgbd();
97 return $sgbd->add_data
100 ( "id_user" => $id_user,
103 "description" => $description,
105 "contact_form" => $contact_form,
106 "captcha" => $captcha
111 function set_groupe($id, $nom, $image, $description, $email, $contact_form, $captcha)
112 { if(($groupe = $this->groupe($id)) !== false)
113 { $sgbd = $this->sgbd();
114 if($nom != $groupe["nom"])
115 { $groupe["nom"] = $nom;
116 if(!$this->maj_source_xml_groupe($groupe)) return false;
118 return $sgbd->set_data
122 ( "id_user" => $groupe["id_user"],
125 "description" => $description,
127 "contact_form" => $contact_form,
128 "captcha" => $captcha
135 function del_groupe($id)
138 $sgbd = $this->sgbd();
140 if($rst = $sgbd->open_data("sml_sources_authors"))
141 { while($source_author = $sgbd->fetch_data($rst))
142 { if(isset($source_author))
143 { if($source_author["id_author"] == $id)
153 $sgbd->close_data($rst);
157 { if($USED) return 1;
158 return $sgbd->del_data("sml_authors", $id) ? true : false;