2 /***************************************************************************
3 * Copyright (C) 2003-2008 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
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. *
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. *
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 *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once('user.func.inc.php');
26 @$globals->search
->result_where_statement
= '
27 LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0)
28 LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid)
29 LEFT JOIN applis_ins AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1)
30 LEFT JOIN applis_def AS ad1 ON (ad1.id = ai1.aid)
31 LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id)
32 LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id)
33 LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id)
34 LEFT JOIN geoloc_pays AS n1 ON (u.nationalite = n1.a2)
35 LEFT JOIN geoloc_pays AS n2 ON (u.nationalite2 = n2.a2)
36 LEFT JOIN geoloc_pays AS n3 ON (u.nationalite2 = n3.a2)
37 LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut))
38 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
39 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)
40 LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = \'active\')';
42 class UserSet
extends PlSet
44 public function __construct($joins = '', $where = '')
47 parent
::__construct('auth_user_md5 AS u',
48 (!empty($GLOBALS['IS_XNET_SITE']) ?
49 'INNER JOIN groupex.membres AS gxm ON (u.user_id = gxm.uid
50 AND gxm.asso_id = ' . $globals->asso('id') . ') ' : '')
51 . 'LEFT JOIN auth_user_quick AS q USING (user_id)
52 LEFT JOIN aliases AS a ON (a.id = u.user_id AND a.type = \'a_vie\')
59 class SearchSet
extends UserSet
61 public $advanced = false
;
62 private $score = null
;
63 private $order = null
;
64 private $quick = false
;
66 public function __construct($quick = false
, $no_search = false
, $join = '', $where = '')
68 require_once dirname(__FILE__
).'/../modules/search/search.inc.php';
74 $this->quick
= $quick;
76 $this->getQuick($join, $where);
78 $this->getAdvanced($join, $where);
82 private function getQuick($join, $where)
84 require_once dirname(__FILE__
).'/../modules/search/search.inc.php';
87 Env
::kill('with_soundex');
89 $qSearch = new QuickSearch('quick');
90 $fields = new SFieldGroup(true
, array($qSearch));
91 if ($qSearch->isEmpty()) {
92 new ThrowError('Aucun critère de recherche n\'est spécifié.');
94 $this->score
= $qSearch->get_score_statement();
95 $pwhere = $fields->get_where_statement();
102 if (S
::logged() && Env
::has('nonins')) {
106 $where .= 'u.perms="pending" AND u.deces=0';
108 parent
::__construct($join . ' ' . $fields->get_select_statement(), $where);
110 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
111 'u.promo DESC, NomSortKey, prenom')));
114 private function getAdvanced($join, $where)
117 $this->advanced
= true
;
118 $fields = new SFieldGroup(true
, advancedSearchFromInput());
119 if ($fields->too_large()) {
120 new ThrowError('Recherche trop générale.');
122 parent
::__construct(@$join . ' ' . $fields->get_select_statement(),
123 @$where . ' ' . $fields->get_where_statement());
124 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
125 'promo DESC, NomSortKey, prenom')));
128 public function &get($fields, $joins, $where, $groupby, $order, $limitcount = null
, $limitfrom = null
)
131 $fields .= ', ' . $this->score
;
133 return parent
::get($fields, $joins, $where, $groupby, $order, $limitcount, $limitfrom);
137 class ArraySet
extends UserSet
139 public function __construct(array $users)
141 $where = $this->getUids($users);
143 $where = "a.alias IN ($where)";
147 parent
::__construct('', $where);
150 private function getUids(array $users)
152 $users = get_users_forlife_list($users, true
, '_silent_user_callback');
153 if (is_null($users)) {
156 return '\'' . implode('\', \'', $users) . '\'';
160 class MinificheView
extends MultipageView
162 public function __construct(PlSet
&$set, $data, array $params)
164 require_once 'applis.func.inc.php';
166 $this->entriesPerPage
= $globals->search
->per_page
;
167 if (@$params['with_score']) {
168 $this->addSortKey('score', array('-score', '-date', '-promo', 'name_sort'), 'pertinence');
170 $this->addSortKey('name', array('name_sort'), 'nom');
171 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
172 $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification');
173 parent
::__construct($set, $data, $params);
176 public function fields()
178 return "u.user_id AS id,
179 u.*, a.alias AS forlife,
180 u.perms != 'pending' AS inscrit,
181 u.perms != 'pending' AS wasinscrit,
182 u.deces != 0 AS dcd, u.deces, u.matricule_ax,
183 FIND_IN_SET('femme', u.flags) AS sexe,
184 e.entreprise, es.label AS secteur, ef.fonction_fr AS fonction,
185 IF(n1.nat='',n1.pays,n1.nat) AS nat1, n1.a2 AS iso3166_1,
186 IF(n2.nat='',n2.pays,n2.nat) AS nat2, n2.a2 AS iso3166_2,
187 IF(n3.nat='',n3.pays,n3.nat) AS nat3, n3.a2 AS iso3166_3,
188 ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
189 ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
190 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region,
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" .
193 (S
::logged() ?
", c.contact AS contact" : '');
196 public function joins()
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)
204 LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0)
205 LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid)
206 LEFT JOIN applis_ins AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1)
207 LEFT JOIN applis_def AS ad1 ON (ad1.id = ai1.aid)
208 LEFT JOIN adresses AS adr ON (u.user_id = adr.uid
209 AND FIND_IN_SET('active', adr.statut)".(S
::logged() ?
"" : " AND adr.pub = 'public'").")
210 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
211 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)
212 LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active')
213 INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)" .
215 "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
219 public function bounds()
221 $order = Env
::v('order', $this->defaultkey
);
223 if (($order == "name") ||
($order == "-name")) {
224 $this->bound_field
= "nom";
226 } elseif (($order == "promo") ||
($order == "-promo")) {
227 $this->bound_field
= "promo";
230 if ($order{0} == '-') {
231 $show_bounds = -$show_bounds;
236 public function templateName()
238 return 'include/plview.minifiche.tpl';
242 class MentorView
extends MultipageView
244 public function __construct(PlSet
&$set, $data, array $params)
246 $this->entriesPerPage
= 10;
247 $this->addSortKey('rand', array('RAND(' . S
::i('uid') . ')'), 'aléatoirement');
248 $this->addSortKey('name', array('name_sort'), 'nom');
249 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
250 $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification');
251 parent
::__construct($set, $data, $params);
254 public function fields()
256 return "m.uid, u.promo,
257 a.alias AS bestalias, m.expertise, mp.pid,
258 ms.secteur, ms.ss_secteur,
259 nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort";
262 public function joins()
264 return "INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)";
267 public function bounds()
269 $order = Env
::v('order', $this->defaultkey
);
271 if (($order == "name") ||
($order == "-name")) {
272 $this->bound_field
= "nom";
274 } elseif (($order == "promo") ||
($order == "-promo")) {
275 $this->bound_field
= "promo";
278 if ($order{0} == '-') {
279 $show_bounds = -$show_bounds;
284 public function templateName()
286 return 'include/plview.referent.tpl';
290 class TrombiView
extends MultipageView
292 public function __construct(PlSet
&$set, $data, array $params)
294 $this->entriesPerPage
= 24;
295 $this->order
= explode(',', Env
::v('order', 'name_sort'));
296 if (@$params['with_score']) {
297 $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'name_sort'), 'pertinence');
299 $this->addSortKey('name', array('name_sort'), 'nom');
300 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
301 parent
::__construct($set, $data, $params);
304 public function fields()
306 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 ";
309 public function joins()
311 return "INNER JOIN photo AS p ON (p.uid = u.user_id)
312 INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)";
315 public function bounds()
317 $order = Env
::v('order', $this->defaultkey
);
319 if (($order == "name") ||
($order == "-name")) {
320 $this->bound_field
= "nom";
322 } elseif (($order == "promo") ||
($order == "-promo")) {
323 $this->bound_field
= "promo";
326 if ($order{0} == '-') {
327 $show_bounds = -$show_bounds;
332 public function templateName()
334 return 'include/plview.trombi.tpl';
337 public function apply(PlPage
&$page)
339 if (!empty($GLOBALS['IS_XNET_SITE'])) {
341 $page->assign('mainsiteurl', 'https://' . $globals->core
->secure_domain
. '/');
343 return parent
::apply($page);
347 class GeolocView
implements PlView
353 public function __construct(PlSet
&$set, $data, array $params)
355 $this->params
= $params;
360 private function use_map()
362 return is_file(dirname(__FILE__
) . '/../modules/geoloc/dynamap.swf') &&
363 is_file(dirname(__FILE__
) . '/../modules/geoloc/icon.swf');
366 public function args()
368 $args = $this->set
->args();
369 unset($args['initfile']);
370 unset($args['mapid']);
374 public function apply(PlPage
&$page)
376 require_once 'geoloc.inc.php';
377 require_once '../modules/search/search.inc.php';
379 switch ($this->type
) {
381 header("Content-type: application/x-shockwave-flash");
383 readfile(dirname(__FILE__
).'/../modules/geoloc/icon.swf');
387 header("Content-type: application/x-shockwave-flash");
389 readfile(dirname(__FILE__
).'/../modules/geoloc/dynamap.swf');
393 $page->changeTpl('geoloc/init.tpl', NO_SKIN
);
394 header('Content-Type: text/xml');
396 if (!empty($GLOBALS['IS_XNET_SITE'])) {
397 $page->assign('background', 0xF2E9D0);
402 $page->changeTpl('geoloc/city.tpl', NO_SKIN
);
403 header('Content-Type: text/xml');
405 $only_current = Env
::v('only_current', false
)?
' AND FIND_IN_SET(\'active\', adrf.statut)' : '';
406 $it =& $this->set
->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias',
407 "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current)
408 LEFT JOIN aliases AS al ON (u.user_id = al.id
409 AND FIND_IN_SET('bestalias', al.flags))
410 INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")",
411 'adrf.cityid = ' . Env
::i('cityid'), null
, null
, 11);
412 $page->assign('users', $it);
416 if (Env
::has('debug')) {
417 $page->changeTpl('geoloc/country.tpl', SIMPLE
);
419 $page->changeTpl('geoloc/country.tpl', NO_SKIN
);
420 header('Content-Type: text/xml');
423 $mapid = Env
::has('mapid') ? Env
::i('mapid', -2) : false
;
424 list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set
, 10);
425 $page->assign('countries', $countries);
426 $page->assign('cities', $cities);
431 if (!$this->use_map()) {
432 $page->assign('request_geodesix', true
);
434 $page->assign('annu', @$this->params
['with_annu']);
435 $page->assign('protocole', @$_SERVER['HTTPS'] ?
'https' : 'http');
436 $this->set
->get('u.user_id', null
, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null
);
437 return 'include/plview.geoloc.tpl';
442 class GadgetView
implements PlView
444 public function __construct(PlSet
&$set, $data, array $params)
449 public function fields()
451 return "u.user_id AS id,
452 u.*, a.alias AS forlife," .
453 "u.perms != 'pending' AS inscrit,
454 u.perms != 'pending' AS wasinscrit,
455 u.deces != 0 AS dcd, u.deces,
456 FIND_IN_SET('femme', u.flags) AS sexe,
457 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region" .
458 (S
::logged() ?
", c.contact AS contact" : '');
461 public function joins()
463 return "LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET('active', adr.statut)".(S
::logged() ?
"" : " AND adr.pub = 'public'").")
464 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
465 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)" .
467 "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
471 public function apply(PlPage
&$page)
473 $page->assign_by_ref('set',
474 $this->set
->get($this->fields(), $this->joins(), null
, null
, null
, 5, 0));
477 public function args()
483 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: