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