Commit | Line | Data |
---|---|---|
8c4a0c30 | 1 | <?php |
2 | /*************************************************************************** | |
179afa7f | 3 | * Copyright (C) 2003-2008 Polytechnique.org * |
8c4a0c30 | 4 | * http://opensource.polytechnique.org/ * |
5 | * * | |
6 | * This program is free software; you can redistribute it and/or modify * | |
7 | * it under the terms of the GNU General Public License as published by * | |
8 | * the Free Software Foundation; either version 2 of the License, or * | |
9 | * (at your option) any later version. * | |
10 | * * | |
11 | * This program is distributed in the hope that it will be useful, * | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 | * GNU General Public License for more details. * | |
15 | * * | |
16 | * You should have received a copy of the GNU General Public License * | |
17 | * along with this program; if not, write to the Free Software * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
8c4a0c30 | 22 | require_once('user.func.inc.php'); |
23 | ||
24 | global $globals; | |
25 | ||
35fa92e8 | 26 | @$globals->search->result_where_statement = ' |
043bbacf SJ |
27 | LEFT JOIN profile_education AS edu ON (u.user_id = edu.uid) |
28 | LEFT JOIN profile_education_enum AS ede ON (ede.id = edu.eduid) | |
2398e553 SJ |
29 | LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id) |
30 | LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id) | |
31 | LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id) | |
32 | LEFT JOIN geoloc_pays AS n1 ON (u.nationalite = n1.a2) | |
33 | LEFT JOIN geoloc_pays AS n2 ON (u.nationalite2 = n2.a2) | |
34 | LEFT JOIN geoloc_pays AS n3 ON (u.nationalite2 = n3.a2) | |
35 | LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut)) | |
36 | LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2) | |
37 | LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region) | |
38 | LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = \'active\')'; | |
8c4a0c30 | 39 | |
40 | class UserSet extends PlSet | |
41 | { | |
42 | public function __construct($joins = '', $where = '') | |
43 | { | |
44 | global $globals; | |
45 | parent::__construct('auth_user_md5 AS u', | |
eaf30d86 PH |
46 | (!empty($GLOBALS['IS_XNET_SITE']) ? |
47 | 'INNER JOIN groupex.membres AS gxm ON (u.user_id = gxm.uid | |
8c4a0c30 | 48 | AND gxm.asso_id = ' . $globals->asso('id') . ') ' : '') |
eaf30d86 | 49 | . 'LEFT JOIN auth_user_quick AS q USING (user_id) |
9d66aa4a | 50 | LEFT JOIN aliases AS a ON (a.id = u.user_id AND a.type = \'a_vie\') |
8c4a0c30 | 51 | ' . $joins, |
52 | $where, | |
53 | 'u.user_id'); | |
54 | } | |
55 | } | |
56 | ||
57 | class SearchSet extends UserSet | |
58 | { | |
86b5c8f0 | 59 | public $advanced = false; |
35fa92e8 | 60 | private $score = null; |
8c4a0c30 | 61 | private $order = null; |
62 | private $quick = false; | |
63 | ||
a2aa8436 | 64 | public function __construct($quick = false, $no_search = false, $join = '', $where = '') |
8c4a0c30 | 65 | { |
66 | require_once dirname(__FILE__).'/../modules/search/search.inc.php'; | |
67 | ||
68 | if ($no_search) { | |
69 | return; | |
70 | } | |
71 | ||
72 | $this->quick = $quick; | |
73 | if ($quick) { | |
a2aa8436 | 74 | $this->getQuick($join, $where); |
8c4a0c30 | 75 | } else { |
a2aa8436 | 76 | $this->getAdvanced($join, $where); |
8c4a0c30 | 77 | } |
78 | } | |
79 | ||
a2aa8436 | 80 | private function getQuick($join, $where) |
8c4a0c30 | 81 | { |
82 | require_once dirname(__FILE__).'/../modules/search/search.inc.php'; | |
83 | global $globals; | |
84 | if (!S::logged()) { | |
85 | Env::kill('with_soundex'); | |
86 | } | |
87 | $qSearch = new QuickSearch('quick'); | |
88 | $fields = new SFieldGroup(true, array($qSearch)); | |
89 | if ($qSearch->isEmpty()) { | |
8d118e58 | 90 | new ThrowError('Aucun critère de recherche n\'est spécifié.'); |
8c4a0c30 | 91 | } |
35fa92e8 | 92 | $this->score = $qSearch->get_score_statement(); |
3b2f9d11 | 93 | $pwhere = $fields->get_where_statement(); |
94 | if (trim($pwhere)) { | |
95 | if (trim($where)) { | |
96 | $where .= ' AND '; | |
97 | } | |
98 | $where .= $pwhere; | |
99 | } | |
100 | if (S::logged() && Env::has('nonins')) { | |
101 | if (trim($where)) { | |
102 | $where .= ' AND '; | |
103 | } | |
104 | $where .= 'u.perms="pending" AND u.deces=0'; | |
105 | } | |
106 | parent::__construct($join . ' ' . $fields->get_select_statement(), $where); | |
8c4a0c30 | 107 | |
108 | $this->order = implode(',',array_filter(array($fields->get_order_statement(), | |
109 | 'u.promo DESC, NomSortKey, prenom'))); | |
110 | } | |
111 | ||
63fac48e | 112 | private function getAdvanced($join, $where) |
8c4a0c30 | 113 | { |
114 | global $globals; | |
86b5c8f0 | 115 | $this->advanced = true; |
8c4a0c30 | 116 | $fields = new SFieldGroup(true, advancedSearchFromInput()); |
117 | if ($fields->too_large()) { | |
118 | new ThrowError('Recherche trop générale.'); | |
119 | } | |
137e819f FB |
120 | parent::__construct(@$join . ' ' . $fields->get_select_statement(), |
121 | @$where . ' ' . $fields->get_where_statement()); | |
8c4a0c30 | 122 | $this->order = implode(',',array_filter(array($fields->get_order_statement(), |
123 | 'promo DESC, NomSortKey, prenom'))); | |
124 | } | |
35fa92e8 | 125 | |
126 | public function &get($fields, $joins, $where, $groupby, $order, $limitcount = null, $limitfrom = null) | |
127 | { | |
128 | if ($this->score) { | |
129 | $fields .= ', ' . $this->score; | |
130 | } | |
131 | return parent::get($fields, $joins, $where, $groupby, $order, $limitcount, $limitfrom); | |
132 | } | |
8c4a0c30 | 133 | } |
134 | ||
1cc0afe7 | 135 | class ArraySet extends UserSet |
136 | { | |
137 | public function __construct(array $users) | |
138 | { | |
139 | $where = $this->getUids($users); | |
140 | if ($where) { | |
141 | $where = "a.alias IN ($where)"; | |
142 | } else { | |
143 | $where = " 0 "; | |
144 | } | |
145 | parent::__construct('', $where); | |
146 | } | |
147 | ||
148 | private function getUids(array $users) | |
149 | { | |
150 | $users = get_users_forlife_list($users, true, '_silent_user_callback'); | |
151 | if (is_null($users)) { | |
152 | return ''; | |
153 | } | |
154 | return '\'' . implode('\', \'', $users) . '\''; | |
155 | } | |
156 | } | |
157 | ||
8c4a0c30 | 158 | class MinificheView extends MultipageView |
159 | { | |
160 | public function __construct(PlSet &$set, $data, array $params) | |
161 | { | |
162 | require_once 'applis.func.inc.php'; | |
163 | global $globals; | |
164 | $this->entriesPerPage = $globals->search->per_page; | |
35fa92e8 | 165 | if (@$params['with_score']) { |
cd5bd7dc | 166 | $this->addSortKey('score', array('-score', '-date', '-promo', 'name_sort'), 'pertinence'); |
35fa92e8 | 167 | } |
cd5bd7dc PC |
168 | $this->addSortKey('name', array('name_sort'), 'nom'); |
169 | $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion'); | |
170 | $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification'); | |
8c4a0c30 | 171 | parent::__construct($set, $data, $params); |
172 | } | |
173 | ||
174 | public function fields() | |
175 | { | |
176 | return "u.user_id AS id, | |
177 | u.*, a.alias AS forlife, | |
178 | u.perms != 'pending' AS inscrit, | |
179 | u.perms != 'pending' AS wasinscrit, | |
180 | u.deces != 0 AS dcd, u.deces, u.matricule_ax, | |
181 | FIND_IN_SET('femme', u.flags) AS sexe, | |
182 | e.entreprise, es.label AS secteur, ef.fonction_fr AS fonction, | |
eeb2ec0f SJ |
183 | IF(n1.nat='',n1.pays,n1.nat) AS nat1, n1.a2 AS iso3166_1, |
184 | IF(n2.nat='',n2.pays,n2.nat) AS nat2, n2.a2 AS iso3166_2, | |
185 | IF(n3.nat='',n3.pays,n3.nat) AS nat3, n3.a2 AS iso3166_3, | |
043bbacf SJ |
186 | ede0.name AS eduname0, ede0.url AS eduurl0, edd0.degree AS edudegree0, edu0.grad_year AS edugrad_year0, f0.field AS edufield0, |
187 | ede1.name AS eduname1, ede1.url AS eduurl1, edd1.degree AS edudegree1, edu1.grad_year AS edugrad_year1, f1.field AS edufield1, | |
188 | ede2.name AS eduname2, ede2.url AS eduurl2, edd2.degree AS edudegree2, edu2.grad_year AS edugrad_year2, f2.field AS edufield2, | |
189 | ede3.name AS eduname3, ede3.url AS eduurl3, edd3.degree AS edudegree3, edu3.grad_year AS edugrad_year3, f3.field AS edufield3, | |
8c4a0c30 | 190 | adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region, |
cd5bd7dc PC |
191 | (COUNT(em.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif, |
192 | nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort" . | |
0e5ec860 | 193 | (S::logged() ? ", c.contact AS contact" : ''); |
8c4a0c30 | 194 | } |
195 | ||
196 | public function joins() | |
197 | { | |
2398e553 SJ |
198 | return "LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id".(S::logged() ? "" : " AND e.pub = 'public'").") |
199 | LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id) | |
200 | LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id) | |
201 | LEFT JOIN geoloc_pays AS n1 ON (u.nationalite = n1.a2) | |
202 | LEFT JOIN geoloc_pays AS n2 ON (u.nationalite2 = n2.a2) | |
203 | LEFT JOIN geoloc_pays AS n3 ON (u.nationalite3 = n3.a2) | |
043bbacf SJ |
204 | LEFT JOIN profile_education AS edu0 ON (u.user_id = edu0.uid AND edu0.id = 0) |
205 | LEFT JOIN profile_education_enum AS ede0 ON (ede0.id = edu0.eduid) | |
206 | LEFT JOIN profile_education_degree_enum AS edd0 ON (edd0.id = edu0.degreeid) | |
207 | LEFT JOIN profile_education_field_enum AS f0 ON (f0.id = edu0.fieldid) | |
208 | LEFT JOIN profile_education AS edu1 ON (u.user_id = edu1.uid AND edu1.id = 1) | |
209 | LEFT JOIN profile_education_enum AS ede1 ON (ede1.id = edu1.eduid) | |
210 | LEFT JOIN profile_education_degree_enum AS edd1 ON (edd1.id = edu1.degreeid) | |
211 | LEFT JOIN profile_education_field_enum AS f1 ON (f1.id = edu1.fieldid) | |
212 | LEFT JOIN profile_education AS edu2 ON (u.user_id = edu2.uid AND edu2.id = 2) | |
213 | LEFT JOIN profile_education_enum AS ede2 ON (ede2.id = edu2.eduid) | |
214 | LEFT JOIN profile_education_degree_enum AS edd2 ON (edd2.id = edu2.degreeid) | |
215 | LEFT JOIN profile_education_field_enum AS f2 ON (f2.id = edu2.fieldid) | |
216 | LEFT JOIN profile_education AS edu3 ON (u.user_id = edu3.uid AND edu3.id = 3) | |
217 | LEFT JOIN profile_education_enum AS ede3 ON (ede3.id = edu3.eduid) | |
218 | LEFT JOIN profile_education_degree_enum AS edd3 ON (edd3.id = edu3.degreeid) | |
219 | LEFT JOIN profile_education_field_enum AS f3 ON (f3.id = edu3.fieldid) | |
2398e553 SJ |
220 | LEFT JOIN adresses AS adr ON (u.user_id = adr.uid |
221 | AND FIND_IN_SET('active', adr.statut)".(S::logged() ? "" : " | |
222 | AND adr.pub = 'public'").") | |
223 | LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2) | |
224 | LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region) | |
225 | LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active') | |
226 | INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)" . | |
eaf30d86 | 227 | (S::logged() ? |
2398e553 | 228 | "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")" |
86b5c8f0 | 229 | : ""); |
8c4a0c30 | 230 | } |
231 | ||
b71b2a36 SJ |
232 | public function bounds() |
233 | { | |
234 | $order = Env::v('order', $this->defaultkey); | |
235 | $show_bounds = 0; | |
236 | if (($order == "name") || ($order == "-name")) { | |
237 | $this->bound_field = "nom"; | |
238 | $show_bounds = 1; | |
239 | } elseif (($order == "promo") || ($order == "-promo")) { | |
240 | $this->bound_field = "promo"; | |
241 | $show_bounds = -1; | |
242 | } | |
243 | if ($order{0} == '-') { | |
244 | $show_bounds = -$show_bounds; | |
245 | } | |
246 | return $show_bounds; | |
247 | } | |
248 | ||
8c4a0c30 | 249 | public function templateName() |
250 | { | |
251 | return 'include/plview.minifiche.tpl'; | |
252 | } | |
253 | } | |
254 | ||
ff3eb9b7 | 255 | class MentorView extends MultipageView |
256 | { | |
257 | public function __construct(PlSet &$set, $data, array $params) | |
258 | { | |
eaf30d86 | 259 | $this->entriesPerPage = 10; |
ff3eb9b7 | 260 | $this->addSortKey('rand', array('RAND(' . S::i('uid') . ')'), 'aléatoirement'); |
cd5bd7dc PC |
261 | $this->addSortKey('name', array('name_sort'), 'nom'); |
262 | $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion'); | |
263 | $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification'); | |
eaf30d86 | 264 | parent::__construct($set, $data, $params); |
ff3eb9b7 | 265 | } |
266 | ||
267 | public function fields() | |
268 | { | |
cd5bd7dc | 269 | return "m.uid, u.promo, |
ff3eb9b7 | 270 | a.alias AS bestalias, m.expertise, mp.pid, |
cd5bd7dc PC |
271 | ms.secteur, ms.ss_secteur, |
272 | nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort"; | |
273 | } | |
274 | ||
275 | public function joins() | |
276 | { | |
277 | return "INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)"; | |
ff3eb9b7 | 278 | } |
279 | ||
b71b2a36 SJ |
280 | public function bounds() |
281 | { | |
282 | $order = Env::v('order', $this->defaultkey); | |
283 | $show_bounds = 0; | |
284 | if (($order == "name") || ($order == "-name")) { | |
285 | $this->bound_field = "nom"; | |
286 | $show_bounds = 1; | |
287 | } elseif (($order == "promo") || ($order == "-promo")) { | |
288 | $this->bound_field = "promo"; | |
289 | $show_bounds = -1; | |
290 | } | |
291 | if ($order{0} == '-') { | |
292 | $show_bounds = -$show_bounds; | |
293 | } | |
294 | return $show_bounds; | |
295 | } | |
296 | ||
ff3eb9b7 | 297 | public function templateName() |
298 | { | |
299 | return 'include/plview.referent.tpl'; | |
300 | } | |
301 | } | |
302 | ||
8c4a0c30 | 303 | class TrombiView extends MultipageView |
304 | { | |
305 | public function __construct(PlSet &$set, $data, array $params) | |
306 | { | |
307 | $this->entriesPerPage = 24; | |
cd5bd7dc | 308 | $this->order = explode(',', Env::v('order', 'name_sort')); |
35fa92e8 | 309 | if (@$params['with_score']) { |
cd5bd7dc | 310 | $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'name_sort'), 'pertinence'); |
35fa92e8 | 311 | } |
cd5bd7dc PC |
312 | $this->addSortKey('name', array('name_sort'), 'nom'); |
313 | $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion'); | |
8c4a0c30 | 314 | parent::__construct($set, $data, $params); |
315 | } | |
316 | ||
317 | public function fields() | |
318 | { | |
cd5bd7dc | 319 | return "u.user_id, nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort, u.promo, a.alias AS forlife "; |
8c4a0c30 | 320 | } |
321 | ||
322 | public function joins() | |
323 | { | |
cd5bd7dc PC |
324 | return "INNER JOIN photo AS p ON (p.uid = u.user_id) |
325 | INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)"; | |
8c4a0c30 | 326 | } |
327 | ||
b71b2a36 SJ |
328 | public function bounds() |
329 | { | |
330 | $order = Env::v('order', $this->defaultkey); | |
331 | $show_bounds = 0; | |
332 | if (($order == "name") || ($order == "-name")) { | |
333 | $this->bound_field = "nom"; | |
334 | $show_bounds = 1; | |
335 | } elseif (($order == "promo") || ($order == "-promo")) { | |
336 | $this->bound_field = "promo"; | |
337 | $show_bounds = -1; | |
338 | } | |
339 | if ($order{0} == '-') { | |
340 | $show_bounds = -$show_bounds; | |
341 | } | |
342 | return $show_bounds; | |
343 | } | |
344 | ||
8c4a0c30 | 345 | public function templateName() |
346 | { | |
347 | return 'include/plview.trombi.tpl'; | |
348 | } | |
349 | ||
04334c61 | 350 | public function apply(PlPage &$page) |
8c4a0c30 | 351 | { |
352 | if (!empty($GLOBALS['IS_XNET_SITE'])) { | |
353 | global $globals; | |
354 | $page->assign('mainsiteurl', 'https://' . $globals->core->secure_domain . '/'); | |
355 | } | |
356 | return parent::apply($page); | |
357 | } | |
358 | } | |
359 | ||
360 | class GeolocView implements PlView | |
361 | { | |
362 | private $set; | |
363 | private $type; | |
364 | private $params; | |
365 | ||
366 | public function __construct(PlSet &$set, $data, array $params) | |
367 | { | |
368 | $this->params = $params; | |
369 | $this->set =& $set; | |
370 | $this->type = $data; | |
371 | } | |
372 | ||
373 | private function use_map() | |
374 | { | |
375 | return is_file(dirname(__FILE__) . '/../modules/geoloc/dynamap.swf') && | |
376 | is_file(dirname(__FILE__) . '/../modules/geoloc/icon.swf'); | |
377 | } | |
378 | ||
35fa92e8 | 379 | public function args() |
8c4a0c30 | 380 | { |
35fa92e8 | 381 | $args = $this->set->args(); |
382 | unset($args['initfile']); | |
383 | unset($args['mapid']); | |
384 | return $args; | |
8c4a0c30 | 385 | } |
386 | ||
04334c61 | 387 | public function apply(PlPage &$page) |
8c4a0c30 | 388 | { |
389 | require_once 'geoloc.inc.php'; | |
390 | require_once '../modules/search/search.inc.php'; | |
391 | ||
392 | switch ($this->type) { | |
393 | case 'icon.swf': | |
394 | header("Content-type: application/x-shockwave-flash"); | |
395 | header("Pragma:"); | |
396 | readfile(dirname(__FILE__).'/../modules/geoloc/icon.swf'); | |
397 | exit; | |
398 | ||
399 | case 'dynamap.swf': | |
400 | header("Content-type: application/x-shockwave-flash"); | |
401 | header("Pragma:"); | |
402 | readfile(dirname(__FILE__).'/../modules/geoloc/dynamap.swf'); | |
403 | exit; | |
404 | ||
405 | case 'init': | |
406 | $page->changeTpl('geoloc/init.tpl', NO_SKIN); | |
407 | header('Content-Type: text/xml'); | |
408 | header('Pragma:'); | |
409 | if (!empty($GLOBALS['IS_XNET_SITE'])) { | |
410 | $page->assign('background', 0xF2E9D0); | |
411 | } | |
8c4a0c30 | 412 | break; |
413 | ||
414 | case 'city': | |
415 | $page->changeTpl('geoloc/city.tpl', NO_SKIN); | |
416 | header('Content-Type: text/xml'); | |
417 | header('Pragma:'); | |
a2aa8436 | 418 | $only_current = Env::v('only_current', false)? ' AND FIND_IN_SET(\'active\', adrf.statut)' : ''; |
8c4a0c30 | 419 | $it =& $this->set->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias', |
a2aa8436 | 420 | "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current) |
8c4a0c30 | 421 | LEFT JOIN aliases AS al ON (u.user_id = al.id |
010268b2 | 422 | AND FIND_IN_SET('bestalias', al.flags)) |
97eff0ff | 423 | INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")", |
8c4a0c30 | 424 | 'adrf.cityid = ' . Env::i('cityid'), null, null, 11); |
425 | $page->assign('users', $it); | |
426 | break; | |
427 | ||
428 | case 'country': | |
429 | if (Env::has('debug')) { | |
430 | $page->changeTpl('geoloc/country.tpl', SIMPLE); | |
431 | } else { | |
432 | $page->changeTpl('geoloc/country.tpl', NO_SKIN); | |
433 | header('Content-Type: text/xml'); | |
434 | header('Pragma:'); | |
435 | } | |
8c4a0c30 | 436 | $mapid = Env::has('mapid') ? Env::i('mapid', -2) : false; |
437 | list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set, 10); | |
438 | $page->assign('countries', $countries); | |
439 | $page->assign('cities', $cities); | |
440 | break; | |
441 | ||
442 | default: | |
443 | global $globals; | |
444 | if (!$this->use_map()) { | |
445 | $page->assign('request_geodesix', true); | |
446 | } | |
a2aa8436 | 447 | $page->assign('annu', @$this->params['with_annu']); |
8c4a0c30 | 448 | $page->assign('protocole', @$_SERVER['HTTPS'] ? 'https' : 'http'); |
449 | $this->set->get('u.user_id', null, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null); | |
8c4a0c30 | 450 | return 'include/plview.geoloc.tpl'; |
451 | } | |
452 | } | |
453 | } | |
454 | ||
92e80560 VZ |
455 | class GadgetView implements PlView |
456 | { | |
457 | public function __construct(PlSet &$set, $data, array $params) | |
458 | { | |
459 | $this->set =& $set; | |
460 | } | |
461 | ||
462 | public function fields() | |
463 | { | |
464 | return "u.user_id AS id, | |
465 | u.*, a.alias AS forlife," . | |
92e80560 VZ |
466 | "u.perms != 'pending' AS inscrit, |
467 | u.perms != 'pending' AS wasinscrit, | |
468 | u.deces != 0 AS dcd, u.deces, | |
469 | FIND_IN_SET('femme', u.flags) AS sexe, | |
470 | adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region" . | |
471 | (S::logged() ? ", c.contact AS contact" : ''); | |
472 | } | |
473 | ||
474 | public function joins() | |
475 | { | |
2398e553 SJ |
476 | return "LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET('active', adr.statut)".(S::logged() ? "" : " |
477 | AND adr.pub = 'public'").") | |
478 | LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2) | |
479 | LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)" . | |
92e80560 | 480 | (S::logged() ? |
2398e553 | 481 | "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")" |
92e80560 VZ |
482 | : ""); |
483 | } | |
484 | ||
04334c61 | 485 | public function apply(PlPage &$page) |
92e80560 VZ |
486 | { |
487 | $page->assign_by_ref('set', | |
488 | $this->set->get($this->fields(), $this->joins(), null, null, null, 5, 0)); | |
489 | } | |
490 | ||
491 | public function args() | |
492 | { | |
493 | return null; | |
494 | } | |
495 | } | |
496 | ||
8c4a0c30 | 497 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
498 | ?> |