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