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 if(!isset($groupes["list"][$id_groupe]["image"])) $groupes["list"][$id_groupe]["image"] = "";
42 $groupes["list"][$id_groupe]["image_uri"] =
43 ( $groupes["list"][$id_groupe]["image"] ?
44 $env->path("content")."uploads/".$groupes["list"][$id_groupe]["image"]
51 else $groupes = false;
57 if(!isset($this->groupes)) $this->groupes = array();
58 if(isset($this->groupes[$id])) return $this->groupes[$id];
59 $sgbd = $this->sgbd();
61 if(($groupe = $sgbd->get_data("sml_authors", $id)) !== null){
62 if(!isset($groupe["image"])) $groupe["image"] = "";
63 $groupe["image_uri"] =
65 $env->path("content")."uploads/".$groupe["image"]
70 if($groupe != false) $this->groupes[$id] = $groupe;
74 function groupe_exists($nom, $other_than_id = null)
75 { $sgbd = $this->sgbd();
77 if($rst = $sgbd->open_data("sml_authors"))
78 { while($v_rst = $sgbd->fetch_data($rst))
80 { if(isset($v_rst["nom"]) && $v_rst["nom"] == $nom)
81 { if(isset($other_than_id))
82 { if($v_rst["id"] != $other_than_id) $EXISTS++;
92 $sgbd->close_data($rst);
97 function add_groupe($id_user, $nom, $image, $description, $email, $contact_form, $captcha)
98 { $sgbd = $this->sgbd();
99 return $sgbd->add_data
102 ( "id_user" => $id_user,
105 "description" => $description,
107 "contact_form" => $contact_form,
108 "captcha" => $captcha
113 function set_groupe($id, $nom, $image, $description, $email, $contact_form, $captcha)
114 { if(($groupe = $this->groupe($id)) !== false)
115 { $sgbd = $this->sgbd();
116 if($nom != $groupe["nom"])
117 { $groupe["nom"] = $nom;
118 if(!$this->maj_source_xml_groupe($groupe)) return false;
120 return $sgbd->set_data
124 ( "id_user" => $groupe["id_user"],
127 "description" => $description,
129 "contact_form" => $contact_form,
130 "captcha" => $captcha
137 function del_groupe($id)
140 $sgbd = $this->sgbd();
142 if($rst = $sgbd->open_data("sml_sources_authors"))
143 { while($source_author = $sgbd->fetch_data($rst))
144 { if(isset($source_author))
145 { if($source_author["id_author"] == $id)
155 $sgbd->close_data($rst);
159 { if($USED) return 1;
160 return $sgbd->del_data("sml_authors", $id) ? true : false;