1 | <?php |
---|
2 | |
---|
3 | class da_artistes extends data |
---|
4 | { |
---|
5 | |
---|
6 | function artistes_au_hasard($max = null, $get_size = false) |
---|
7 | { $ARTISTES = array(); |
---|
8 | $IMG_WIDTH = 60; |
---|
9 | $IMG_HEIGHT = 60; |
---|
10 | try |
---|
11 | { $query = |
---|
12 | "SELECT id, nom, style, image" |
---|
13 | ." FROM #--artistes" |
---|
14 | ." ORDER BY RAND()" |
---|
15 | .(isset($max) ? " LIMIT ".$max : ""); |
---|
16 | $rst = $this->sql->query($query); |
---|
17 | $artistes = array(); |
---|
18 | $i = 0; |
---|
19 | while($v_rst = $this->sql->fetch_assoc($rst)) |
---|
20 | { $ARTISTES[$i] = Array(); |
---|
21 | $ARTISTES[$i]["id"] = $v_rst["id"]; |
---|
22 | $ARTISTES[$i]["nom"] = $v_rst["nom"]; |
---|
23 | $ARTISTES[$i]["style"] = $v_rst["style"]; |
---|
24 | $width = $IMG_WIDTH; |
---|
25 | $height = $IMG_HEIGHT; |
---|
26 | $EXISTS = true; |
---|
27 | if($get_size) |
---|
28 | { list($width, $height, $type, $attr) = @getimagesize($v_rst["image"]); |
---|
29 | $EXISTS = false; |
---|
30 | if($width) $EXISTS = true; |
---|
31 | if($EXISTS) |
---|
32 | { $div = 1; |
---|
33 | if(($width / $div) > $IMG_WIDTH) $div = $width / $IMG_WIDTH; |
---|
34 | if(($height / $div) > $IMG_HEIGHT) $div = $height / $IMG_HEIGHT; |
---|
35 | $width = floor($width / $div); |
---|
36 | $height = floor($height / $div); |
---|
37 | } |
---|
38 | else |
---|
39 | { $width = $IMG_WIDTH; |
---|
40 | $height = $IMG_HEIGHT; |
---|
41 | } |
---|
42 | } |
---|
43 | $ARTISTES[$i]["image"] = Array(); |
---|
44 | $ARTISTES[$i]["image"]["src"] = $EXISTS ? $v_rst["image"] : ""; |
---|
45 | $ARTISTES[$i]["image"]["width"] = $width; |
---|
46 | $ARTISTES[$i]["image"]["height"] = $height; |
---|
47 | $i++; |
---|
48 | } |
---|
49 | $this->sql->free_result($rst); |
---|
50 | } |
---|
51 | catch(Exception $_e) { $artistes = false; } |
---|
52 | return $ARTISTES; |
---|
53 | } |
---|
54 | |
---|
55 | function artistes($pun_user = null) |
---|
56 | { $artistes = array(); |
---|
57 | try |
---|
58 | { $query = |
---|
59 | "SELECT * FROM #--artistes" |
---|
60 | .(isset($pun_user) ? " WHERE pun_user=".$pun_user : "") |
---|
61 | ." ORDER BY nom"; |
---|
62 | $rst = $this->sql->query($query); |
---|
63 | $artistes = array(); |
---|
64 | while($v_rst = $this->sql->fetch_assoc($rst)) { $artistes[$v_rst["id"]] = $v_rst; } |
---|
65 | $this->sql->free_result($rst); |
---|
66 | } |
---|
67 | catch(Exception $_e) { $artistes = false; } |
---|
68 | return $artistes; |
---|
69 | } |
---|
70 | |
---|
71 | function artiste($id) |
---|
72 | { $artiste = array(); |
---|
73 | try |
---|
74 | { $query = |
---|
75 | "SELECT *" |
---|
76 | ." FROM #--artistes" |
---|
77 | ." WHERE ".$this->env->bdd["prefix"]."artistes.id=".$id; |
---|
78 | $rst = $this->sql->query($query); |
---|
79 | if($v_rst = $this->sql->fetch_assoc($rst)) $artiste = $v_rst; |
---|
80 | $this->sql->free_result($rst); |
---|
81 | } |
---|
82 | catch(Exception $_e) { $artiste = false; } |
---|
83 | return $artiste; |
---|
84 | } |
---|
85 | |
---|
86 | function artiste_presentation($id) |
---|
87 | { $presentation = ""; |
---|
88 | try |
---|
89 | { $query = |
---|
90 | "SELECT presentation" |
---|
91 | ." FROM #--artistes" |
---|
92 | ." WHERE id=".$id; |
---|
93 | $rst = $this->sql->query($query); |
---|
94 | if($v_rst = $this->sql->fetch_assoc($rst)) $presentation = $v_rst["presentation"]; |
---|
95 | $this->sql->free_result($rst); |
---|
96 | } |
---|
97 | catch(Exception $_e) { $presentation = false; } |
---|
98 | return $presentation; |
---|
99 | } |
---|
100 | |
---|
101 | function set_artiste_presentation($id, $presentation) |
---|
102 | { try |
---|
103 | { $query = |
---|
104 | "UPDATE #--artistes" |
---|
105 | ." SET presentation=".$this->eq($presentation) |
---|
106 | ." WHERE id=".$id; |
---|
107 | $this->sql->query($query); |
---|
108 | } |
---|
109 | catch(Exception $_e) { return false; } |
---|
110 | return true; |
---|
111 | } |
---|
112 | |
---|
113 | function add_artiste($pun_user, $nom, $forum = null, $dossier_personnel = null) |
---|
114 | { try |
---|
115 | { $sql = |
---|
116 | "INSERT INTO #--artistes(nom, pun_user, pun_forum, dossier_personnel) VALUES" |
---|
117 | ."( ".$this->eq($nom) |
---|
118 | .", ".$pun_user |
---|
119 | .", ".$this->eq($forum) |
---|
120 | .", ".$this->eq($dossier_personnel) |
---|
121 | .")"; |
---|
122 | $this->sql->query($sql); |
---|
123 | } |
---|
124 | catch(Exception $_e) { return false; } |
---|
125 | return true; |
---|
126 | } |
---|
127 | |
---|
128 | function admin_set_artiste($id, $nom, $forum = null, $dossier_personnel = null) |
---|
129 | { try |
---|
130 | { $query = |
---|
131 | "UPDATE #--artistes SET" |
---|
132 | ." nom=".$this->eq($nom) |
---|
133 | .", pun_forum=".$this->eq($forum) |
---|
134 | .", dossier_personnel=".$this->eq($dossier_personnel) |
---|
135 | ." WHERE id=".$id; |
---|
136 | $this->sql->query($query); |
---|
137 | } |
---|
138 | catch(Exception $_e) { return false; } |
---|
139 | return true; |
---|
140 | } |
---|
141 | |
---|
142 | function set_artiste |
---|
143 | ( $id, |
---|
144 | $nom, |
---|
145 | $image, |
---|
146 | $style, |
---|
147 | $pays, |
---|
148 | $site, |
---|
149 | $email_contact, |
---|
150 | $hide_email, |
---|
151 | $contact_form, |
---|
152 | $identifiant_paypal, |
---|
153 | $lien_boutique, |
---|
154 | $lien_facebook, |
---|
155 | $lien_flickr, |
---|
156 | $lien_twitter, |
---|
157 | $lien_youtube, |
---|
158 | $dossier_personnel = null |
---|
159 | ) |
---|
160 | { try |
---|
161 | { $query = |
---|
162 | "UPDATE #--artistes SET" |
---|
163 | ." nom=".$this->eq($nom) |
---|
164 | .", image=".$this->eq($image) |
---|
165 | .", style=".$this->eq($style) |
---|
166 | .", pays=".$this->eq($pays) |
---|
167 | .", site=".$this->eq($site) |
---|
168 | .", email_contact=".$this->eq($email_contact) |
---|
169 | .", hide_email=".$hide_email |
---|
170 | .", contact_form=".$contact_form |
---|
171 | .", identifiant_paypal=".$this->eq($identifiant_paypal) |
---|
172 | .", lien_boutique=".$this->eq($lien_boutique) |
---|
173 | .", lien_facebook=".$this->eq($lien_facebook) |
---|
174 | .", lien_flickr=".$this->eq($lien_flickr) |
---|
175 | .", lien_twitter=".$this->eq($lien_twitter) |
---|
176 | .", lien_youtube=".$this->eq($lien_youtube) |
---|
177 | .", dossier_personnel=".$this->eq($dossier_personnel) |
---|
178 | ." WHERE id=".$id; |
---|
179 | $this->sql->query($query); |
---|
180 | } |
---|
181 | catch(Exception $_e) { return false; } |
---|
182 | return true; |
---|
183 | } |
---|
184 | |
---|
185 | function del_artiste($id_artiste) |
---|
186 | { try |
---|
187 | { if(($id_artiste_news_categorie = $this->id_categorie(array("root", "artistes", "news", $id_artiste))) !== false) |
---|
188 | { if($id_artiste_news_categorie) |
---|
189 | { $sql = |
---|
190 | "DELETE FROM #--contenus" |
---|
191 | ." WHERE categorie=".$id_artiste_news_categorie; |
---|
192 | $this->sql->query($sql); |
---|
193 | $sql = "DELETE FROM #--categories WHERE id=".$id_artiste_news_categorie; |
---|
194 | $this->sql->query($sql); |
---|
195 | $sql = "DELETE FROM #--categories_tree WHERE child=".$id_artiste_news_categorie; |
---|
196 | $this->sql->query($sql); |
---|
197 | } |
---|
198 | } |
---|
199 | else return false; |
---|
200 | $sql = "DELETE FROM #--albums WHERE id_artiste=".$this->eq($id_artiste); |
---|
201 | $this->sql->query($sql); |
---|
202 | $sql = "DELETE FROM #--concerts WHERE id_artiste=".$this->eq($id_artiste); |
---|
203 | $this->sql->query($sql); |
---|
204 | $sql = "DELETE FROM #--videos WHERE id_artiste=".$this->eq($id_artiste); |
---|
205 | $this->sql->query($sql); |
---|
206 | $downloads = array(); |
---|
207 | $sql = "SELECT id FROM #--downloads WHERE id_artiste=".$this->eq($id_artiste); |
---|
208 | $rst = $this->sql->query($sql); |
---|
209 | while($v_rst = $this->sql->fetch_assoc($rst)) $downloads[] = $v_rst["id"]; |
---|
210 | $this->sql->free_result($rst); |
---|
211 | foreach($downloads as $id_download) |
---|
212 | { $sql = "DELETE FROM #--download_urls WHERE id_download=".$id_download; |
---|
213 | $this->sql->query($sql); |
---|
214 | $sql = "DELETE FROM #--downloads WHERE id=".$id_download; |
---|
215 | $this->sql->query($sql); |
---|
216 | } |
---|
217 | $sql = "DELETE FROM #--artistes WHERE id=".$this->eq($id_artiste); |
---|
218 | $this->sql->query($sql); |
---|
219 | } |
---|
220 | catch(Exception $_e) { return false; } |
---|
221 | return true; |
---|
222 | } |
---|
223 | |
---|
224 | } |
---|
225 | |
---|
226 | ?> |
---|