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 | { | |
f711b03f | 162 | require_once 'education.func.inc.php'; |
8c4a0c30 | 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, | |
1504ac45 SJ |
186 | ede0.name AS eduname0, ede0.url AS eduurl0, edd0.degree AS edudegree0, |
187 | edu0.grad_year AS edugrad_year0, f0.field AS edufield0, edu0.program AS eduprogram0, | |
188 | ede1.name AS eduname1, ede1.url AS eduurl1, edd1.degree AS edudegree1, | |
189 | edu1.grad_year AS edugrad_year1, f1.field AS edufield1, edu1.program AS eduprogram1, | |
190 | ede2.name AS eduname2, ede2.url AS eduurl2, edd2.degree AS edudegree2, | |
191 | edu2.grad_year AS edugrad_year2, f2.field AS edufield2, edu2gram AS eduprogram2, | |
192 | ede3.name AS eduname3, ede3.url AS eduurl3, edd3.degree AS edudegree3, | |
193 | edu3.grad_year AS edugrad_year3, f3.field AS edufield3, edu3gram AS eduprogram3, | |
8c4a0c30 | 194 | adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region, |
cd5bd7dc PC |
195 | (COUNT(em.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif, |
196 | nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort" . | |
0e5ec860 | 197 | (S::logged() ? ", c.contact AS contact" : ''); |
8c4a0c30 | 198 | } |
199 | ||
200 | public function joins() | |
201 | { | |
2398e553 SJ |
202 | return "LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id".(S::logged() ? "" : " AND e.pub = 'public'").") |
203 | LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id) | |
204 | LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id) | |
205 | LEFT JOIN geoloc_pays AS n1 ON (u.nationalite = n1.a2) | |
206 | LEFT JOIN geoloc_pays AS n2 ON (u.nationalite2 = n2.a2) | |
207 | LEFT JOIN geoloc_pays AS n3 ON (u.nationalite3 = n3.a2) | |
043bbacf SJ |
208 | LEFT JOIN profile_education AS edu0 ON (u.user_id = edu0.uid AND edu0.id = 0) |
209 | LEFT JOIN profile_education_enum AS ede0 ON (ede0.id = edu0.eduid) | |
210 | LEFT JOIN profile_education_degree_enum AS edd0 ON (edd0.id = edu0.degreeid) | |
211 | LEFT JOIN profile_education_field_enum AS f0 ON (f0.id = edu0.fieldid) | |
212 | LEFT JOIN profile_education AS edu1 ON (u.user_id = edu1.uid AND edu1.id = 1) | |
213 | LEFT JOIN profile_education_enum AS ede1 ON (ede1.id = edu1.eduid) | |
214 | LEFT JOIN profile_education_degree_enum AS edd1 ON (edd1.id = edu1.degreeid) | |
215 | LEFT JOIN profile_education_field_enum AS f1 ON (f1.id = edu1.fieldid) | |
216 | LEFT JOIN profile_education AS edu2 ON (u.user_id = edu2.uid AND edu2.id = 2) | |
217 | LEFT JOIN profile_education_enum AS ede2 ON (ede2.id = edu2.eduid) | |
218 | LEFT JOIN profile_education_degree_enum AS edd2 ON (edd2.id = edu2.degreeid) | |
219 | LEFT JOIN profile_education_field_enum AS f2 ON (f2.id = edu2.fieldid) | |
220 | LEFT JOIN profile_education AS edu3 ON (u.user_id = edu3.uid AND edu3.id = 3) | |
221 | LEFT JOIN profile_education_enum AS ede3 ON (ede3.id = edu3.eduid) | |
222 | LEFT JOIN profile_education_degree_enum AS edd3 ON (edd3.id = edu3.degreeid) | |
223 | LEFT JOIN profile_education_field_enum AS f3 ON (f3.id = edu3.fieldid) | |
2398e553 SJ |
224 | LEFT JOIN adresses AS adr ON (u.user_id = adr.uid |
225 | AND FIND_IN_SET('active', adr.statut)".(S::logged() ? "" : " | |
226 | AND adr.pub = 'public'").") | |
227 | LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2) | |
228 | LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region) | |
229 | LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active') | |
230 | INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)" . | |
eaf30d86 | 231 | (S::logged() ? |
2398e553 | 232 | "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")" |
86b5c8f0 | 233 | : ""); |
8c4a0c30 | 234 | } |
235 | ||
b71b2a36 SJ |
236 | public function bounds() |
237 | { | |
238 | $order = Env::v('order', $this->defaultkey); | |
239 | $show_bounds = 0; | |
240 | if (($order == "name") || ($order == "-name")) { | |
241 | $this->bound_field = "nom"; | |
242 | $show_bounds = 1; | |
243 | } elseif (($order == "promo") || ($order == "-promo")) { | |
244 | $this->bound_field = "promo"; | |
245 | $show_bounds = -1; | |
246 | } | |
247 | if ($order{0} == '-') { | |
248 | $show_bounds = -$show_bounds; | |
249 | } | |
250 | return $show_bounds; | |
251 | } | |
252 | ||
8c4a0c30 | 253 | public function templateName() |
254 | { | |
255 | return 'include/plview.minifiche.tpl'; | |
256 | } | |
257 | } | |
258 | ||
ff3eb9b7 | 259 | class MentorView extends MultipageView |
260 | { | |
261 | public function __construct(PlSet &$set, $data, array $params) | |
262 | { | |
eaf30d86 | 263 | $this->entriesPerPage = 10; |
ff3eb9b7 | 264 | $this->addSortKey('rand', array('RAND(' . S::i('uid') . ')'), 'aléatoirement'); |
cd5bd7dc PC |
265 | $this->addSortKey('name', array('name_sort'), 'nom'); |
266 | $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion'); | |
267 | $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification'); | |
eaf30d86 | 268 | parent::__construct($set, $data, $params); |
ff3eb9b7 | 269 | } |
270 | ||
271 | public function fields() | |
272 | { | |
cd5bd7dc | 273 | return "m.uid, u.promo, |
ff3eb9b7 | 274 | a.alias AS bestalias, m.expertise, mp.pid, |
cd5bd7dc PC |
275 | ms.secteur, ms.ss_secteur, |
276 | nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort"; | |
277 | } | |
278 | ||
279 | public function joins() | |
280 | { | |
281 | return "INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)"; | |
ff3eb9b7 | 282 | } |
283 | ||
b71b2a36 SJ |
284 | public function bounds() |
285 | { | |
286 | $order = Env::v('order', $this->defaultkey); | |
287 | $show_bounds = 0; | |
288 | if (($order == "name") || ($order == "-name")) { | |
289 | $this->bound_field = "nom"; | |
290 | $show_bounds = 1; | |
291 | } elseif (($order == "promo") || ($order == "-promo")) { | |
292 | $this->bound_field = "promo"; | |
293 | $show_bounds = -1; | |
294 | } | |
295 | if ($order{0} == '-') { | |
296 | $show_bounds = -$show_bounds; | |
297 | } | |
298 | return $show_bounds; | |
299 | } | |
300 | ||
ff3eb9b7 | 301 | public function templateName() |
302 | { | |
303 | return 'include/plview.referent.tpl'; | |
304 | } | |
305 | } | |
306 | ||
8c4a0c30 | 307 | class TrombiView extends MultipageView |
308 | { | |
309 | public function __construct(PlSet &$set, $data, array $params) | |
310 | { | |
311 | $this->entriesPerPage = 24; | |
cd5bd7dc | 312 | $this->order = explode(',', Env::v('order', 'name_sort')); |
35fa92e8 | 313 | if (@$params['with_score']) { |
cd5bd7dc | 314 | $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'name_sort'), 'pertinence'); |
35fa92e8 | 315 | } |
cd5bd7dc PC |
316 | $this->addSortKey('name', array('name_sort'), 'nom'); |
317 | $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion'); | |
8c4a0c30 | 318 | parent::__construct($set, $data, $params); |
319 | } | |
320 | ||
321 | public function fields() | |
322 | { | |
cd5bd7dc | 323 | 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 | 324 | } |
325 | ||
326 | public function joins() | |
327 | { | |
cd5bd7dc PC |
328 | return "INNER JOIN photo AS p ON (p.uid = u.user_id) |
329 | INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)"; | |
8c4a0c30 | 330 | } |
331 | ||
b71b2a36 SJ |
332 | public function bounds() |
333 | { | |
334 | $order = Env::v('order', $this->defaultkey); | |
335 | $show_bounds = 0; | |
336 | if (($order == "name") || ($order == "-name")) { | |
337 | $this->bound_field = "nom"; | |
338 | $show_bounds = 1; | |
339 | } elseif (($order == "promo") || ($order == "-promo")) { | |
340 | $this->bound_field = "promo"; | |
341 | $show_bounds = -1; | |
342 | } | |
343 | if ($order{0} == '-') { | |
344 | $show_bounds = -$show_bounds; | |
345 | } | |
346 | return $show_bounds; | |
347 | } | |
348 | ||
8c4a0c30 | 349 | public function templateName() |
350 | { | |
351 | return 'include/plview.trombi.tpl'; | |
352 | } | |
353 | ||
04334c61 | 354 | public function apply(PlPage &$page) |
8c4a0c30 | 355 | { |
356 | if (!empty($GLOBALS['IS_XNET_SITE'])) { | |
357 | global $globals; | |
358 | $page->assign('mainsiteurl', 'https://' . $globals->core->secure_domain . '/'); | |
359 | } | |
360 | return parent::apply($page); | |
361 | } | |
362 | } | |
363 | ||
364 | class GeolocView implements PlView | |
365 | { | |
366 | private $set; | |
367 | private $type; | |
368 | private $params; | |
369 | ||
370 | public function __construct(PlSet &$set, $data, array $params) | |
371 | { | |
372 | $this->params = $params; | |
373 | $this->set =& $set; | |
374 | $this->type = $data; | |
375 | } | |
376 | ||
377 | private function use_map() | |
378 | { | |
379 | return is_file(dirname(__FILE__) . '/../modules/geoloc/dynamap.swf') && | |
380 | is_file(dirname(__FILE__) . '/../modules/geoloc/icon.swf'); | |
381 | } | |
382 | ||
35fa92e8 | 383 | public function args() |
8c4a0c30 | 384 | { |
35fa92e8 | 385 | $args = $this->set->args(); |
386 | unset($args['initfile']); | |
387 | unset($args['mapid']); | |
388 | return $args; | |
8c4a0c30 | 389 | } |
390 | ||
04334c61 | 391 | public function apply(PlPage &$page) |
8c4a0c30 | 392 | { |
393 | require_once 'geoloc.inc.php'; | |
394 | require_once '../modules/search/search.inc.php'; | |
395 | ||
396 | switch ($this->type) { | |
397 | case 'icon.swf': | |
398 | header("Content-type: application/x-shockwave-flash"); | |
399 | header("Pragma:"); | |
400 | readfile(dirname(__FILE__).'/../modules/geoloc/icon.swf'); | |
401 | exit; | |
402 | ||
403 | case 'dynamap.swf': | |
404 | header("Content-type: application/x-shockwave-flash"); | |
405 | header("Pragma:"); | |
406 | readfile(dirname(__FILE__).'/../modules/geoloc/dynamap.swf'); | |
407 | exit; | |
408 | ||
409 | case 'init': | |
410 | $page->changeTpl('geoloc/init.tpl', NO_SKIN); | |
411 | header('Content-Type: text/xml'); | |
412 | header('Pragma:'); | |
413 | if (!empty($GLOBALS['IS_XNET_SITE'])) { | |
414 | $page->assign('background', 0xF2E9D0); | |
415 | } | |
8c4a0c30 | 416 | break; |
417 | ||
418 | case 'city': | |
419 | $page->changeTpl('geoloc/city.tpl', NO_SKIN); | |
420 | header('Content-Type: text/xml'); | |
421 | header('Pragma:'); | |
a2aa8436 | 422 | $only_current = Env::v('only_current', false)? ' AND FIND_IN_SET(\'active\', adrf.statut)' : ''; |
8c4a0c30 | 423 | $it =& $this->set->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias', |
a2aa8436 | 424 | "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current) |
8c4a0c30 | 425 | LEFT JOIN aliases AS al ON (u.user_id = al.id |
010268b2 | 426 | AND FIND_IN_SET('bestalias', al.flags)) |
97eff0ff | 427 | INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")", |
8c4a0c30 | 428 | 'adrf.cityid = ' . Env::i('cityid'), null, null, 11); |
429 | $page->assign('users', $it); | |
430 | break; | |
431 | ||
432 | case 'country': | |
433 | if (Env::has('debug')) { | |
434 | $page->changeTpl('geoloc/country.tpl', SIMPLE); | |
435 | } else { | |
436 | $page->changeTpl('geoloc/country.tpl', NO_SKIN); | |
437 | header('Content-Type: text/xml'); | |
438 | header('Pragma:'); | |
439 | } | |
8c4a0c30 | 440 | $mapid = Env::has('mapid') ? Env::i('mapid', -2) : false; |
441 | list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set, 10); | |
442 | $page->assign('countries', $countries); | |
443 | $page->assign('cities', $cities); | |
444 | break; | |
445 | ||
446 | default: | |
447 | global $globals; | |
448 | if (!$this->use_map()) { | |
449 | $page->assign('request_geodesix', true); | |
450 | } | |
a2aa8436 | 451 | $page->assign('annu', @$this->params['with_annu']); |
8c4a0c30 | 452 | $page->assign('protocole', @$_SERVER['HTTPS'] ? 'https' : 'http'); |
453 | $this->set->get('u.user_id', null, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null); | |
8c4a0c30 | 454 | return 'include/plview.geoloc.tpl'; |
455 | } | |
456 | } | |
457 | } | |
458 | ||
92e80560 VZ |
459 | class GadgetView implements PlView |
460 | { | |
461 | public function __construct(PlSet &$set, $data, array $params) | |
462 | { | |
463 | $this->set =& $set; | |
464 | } | |
465 | ||
466 | public function fields() | |
467 | { | |
468 | return "u.user_id AS id, | |
469 | u.*, a.alias AS forlife," . | |
92e80560 VZ |
470 | "u.perms != 'pending' AS inscrit, |
471 | u.perms != 'pending' AS wasinscrit, | |
472 | u.deces != 0 AS dcd, u.deces, | |
473 | FIND_IN_SET('femme', u.flags) AS sexe, | |
474 | adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region" . | |
475 | (S::logged() ? ", c.contact AS contact" : ''); | |
476 | } | |
477 | ||
478 | public function joins() | |
479 | { | |
2398e553 SJ |
480 | return "LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET('active', adr.statut)".(S::logged() ? "" : " |
481 | AND adr.pub = 'public'").") | |
482 | LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2) | |
483 | LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)" . | |
92e80560 | 484 | (S::logged() ? |
2398e553 | 485 | "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")" |
92e80560 VZ |
486 | : ""); |
487 | } | |
488 | ||
04334c61 | 489 | public function apply(PlPage &$page) |
92e80560 VZ |
490 | { |
491 | $page->assign_by_ref('set', | |
492 | $this->set->get($this->fields(), $this->joins(), null, null, null, 5, 0)); | |
493 | } | |
494 | ||
495 | public function args() | |
496 | { | |
497 | return null; | |
498 | } | |
499 | } | |
500 | ||
8c4a0c30 | 501 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
502 | ?> |