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 profile_education AS edu ON (u.user_id = edu.uid)
28 LEFT JOIN profile_education_enum AS ede ON (ede.id = edu.eduid)
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\')';
40 class UserSet
extends PlSet
42 public function __construct($joins = '', $where = '')
45 parent
::__construct('auth_user_md5 AS u',
46 (!empty($GLOBALS['IS_XNET_SITE']) ?
47 'INNER JOIN groupex.membres AS gxm ON (u.user_id = gxm.uid
48 AND gxm.asso_id = ' . $globals->asso('id') . ') ' : '')
49 . 'LEFT JOIN auth_user_quick AS q USING (user_id)
50 LEFT JOIN aliases AS a ON (a.id = u.user_id AND a.type = \'a_vie\')
57 class SearchSet
extends UserSet
59 public $advanced = false
;
60 private $score = null
;
61 private $order = null
;
62 private $quick = false
;
64 public function __construct($quick = false
, $no_search = false
, $join = '', $where = '')
66 require_once dirname(__FILE__
).'/../modules/search/search.inc.php';
72 $this->quick
= $quick;
74 $this->getQuick($join, $where);
76 $this->getAdvanced($join, $where);
80 private function getQuick($join, $where)
82 require_once dirname(__FILE__
).'/../modules/search/search.inc.php';
85 Env
::kill('with_soundex');
87 $qSearch = new QuickSearch('quick');
88 $fields = new SFieldGroup(true
, array($qSearch));
89 if ($qSearch->isEmpty()) {
90 new ThrowError('Aucun critère de recherche n\'est spécifié.');
92 $this->score
= $qSearch->get_score_statement();
93 $pwhere = $fields->get_where_statement();
100 if (S
::logged() && Env
::has('nonins')) {
104 $where .= 'u.perms="pending" AND u.deces=0';
106 parent
::__construct($join . ' ' . $fields->get_select_statement(), $where);
108 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
109 'u.promo DESC, NomSortKey, prenom')));
112 private function getAdvanced($join, $where)
115 $this->advanced
= true
;
116 $fields = new SFieldGroup(true
, advancedSearchFromInput());
117 if ($fields->too_large()) {
118 new ThrowError('Recherche trop générale.');
120 parent
::__construct(@$join . ' ' . $fields->get_select_statement(),
121 @$where . ' ' . $fields->get_where_statement());
122 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
123 'promo DESC, NomSortKey, prenom')));
126 public function &get($fields, $joins, $where, $groupby, $order, $limitcount = null
, $limitfrom = null
)
129 $fields .= ', ' . $this->score
;
131 return parent
::get($fields, $joins, $where, $groupby, $order, $limitcount, $limitfrom);
135 class ArraySet
extends UserSet
137 public function __construct(array $users)
139 $where = $this->getUids($users);
141 $where = "a.alias IN ($where)";
145 parent
::__construct('', $where);
148 private function getUids(array $users)
150 $users = get_users_forlife_list($users, true
, '_silent_user_callback');
151 if (is_null($users)) {
154 return '\'' . implode('\', \'', $users) . '\'';
158 class MinificheView
extends MultipageView
160 public function __construct(PlSet
&$set, $data, array $params)
162 require_once 'applis.func.inc.php';
164 $this->entriesPerPage
= $globals->search
->per_page
;
165 if (@$params['with_score']) {
166 $this->addSortKey('score', array('-score', '-date', '-promo', 'name_sort'), 'pertinence');
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');
171 parent
::__construct($set, $data, $params);
174 public function fields()
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,
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,
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,
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 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)
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)" .
228 "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
232 public function bounds()
234 $order = Env
::v('order', $this->defaultkey
);
236 if (($order == "name") ||
($order == "-name")) {
237 $this->bound_field
= "nom";
239 } elseif (($order == "promo") ||
($order == "-promo")) {
240 $this->bound_field
= "promo";
243 if ($order{0} == '-') {
244 $show_bounds = -$show_bounds;
249 public function templateName()
251 return 'include/plview.minifiche.tpl';
255 class MentorView
extends MultipageView
257 public function __construct(PlSet
&$set, $data, array $params)
259 $this->entriesPerPage
= 10;
260 $this->addSortKey('rand', array('RAND(' . S
::i('uid') . ')'), 'aléatoirement');
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');
264 parent
::__construct($set, $data, $params);
267 public function fields()
269 return "m.uid, u.promo,
270 a.alias AS bestalias, m.expertise, mp.pid,
271 ms.secteur, ms.ss_secteur,
272 nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort";
275 public function joins()
277 return "INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)";
280 public function bounds()
282 $order = Env
::v('order', $this->defaultkey
);
284 if (($order == "name") ||
($order == "-name")) {
285 $this->bound_field
= "nom";
287 } elseif (($order == "promo") ||
($order == "-promo")) {
288 $this->bound_field
= "promo";
291 if ($order{0} == '-') {
292 $show_bounds = -$show_bounds;
297 public function templateName()
299 return 'include/plview.referent.tpl';
303 class TrombiView
extends MultipageView
305 public function __construct(PlSet
&$set, $data, array $params)
307 $this->entriesPerPage
= 24;
308 $this->order
= explode(',', Env
::v('order', 'name_sort'));
309 if (@$params['with_score']) {
310 $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'name_sort'), 'pertinence');
312 $this->addSortKey('name', array('name_sort'), 'nom');
313 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
314 parent
::__construct($set, $data, $params);
317 public function fields()
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 ";
322 public function joins()
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)";
328 public function bounds()
330 $order = Env
::v('order', $this->defaultkey
);
332 if (($order == "name") ||
($order == "-name")) {
333 $this->bound_field
= "nom";
335 } elseif (($order == "promo") ||
($order == "-promo")) {
336 $this->bound_field
= "promo";
339 if ($order{0} == '-') {
340 $show_bounds = -$show_bounds;
345 public function templateName()
347 return 'include/plview.trombi.tpl';
350 public function apply(PlPage
&$page)
352 if (!empty($GLOBALS['IS_XNET_SITE'])) {
354 $page->assign('mainsiteurl', 'https://' . $globals->core
->secure_domain
. '/');
356 return parent
::apply($page);
360 class GeolocView
implements PlView
366 public function __construct(PlSet
&$set, $data, array $params)
368 $this->params
= $params;
373 private function use_map()
375 return is_file(dirname(__FILE__
) . '/../modules/geoloc/dynamap.swf') &&
376 is_file(dirname(__FILE__
) . '/../modules/geoloc/icon.swf');
379 public function args()
381 $args = $this->set
->args();
382 unset($args['initfile']);
383 unset($args['mapid']);
387 public function apply(PlPage
&$page)
389 require_once 'geoloc.inc.php';
390 require_once '../modules/search/search.inc.php';
392 switch ($this->type
) {
394 header("Content-type: application/x-shockwave-flash");
396 readfile(dirname(__FILE__
).'/../modules/geoloc/icon.swf');
400 header("Content-type: application/x-shockwave-flash");
402 readfile(dirname(__FILE__
).'/../modules/geoloc/dynamap.swf');
406 $page->changeTpl('geoloc/init.tpl', NO_SKIN
);
407 header('Content-Type: text/xml');
409 if (!empty($GLOBALS['IS_XNET_SITE'])) {
410 $page->assign('background', 0xF2E9D0);
415 $page->changeTpl('geoloc/city.tpl', NO_SKIN
);
416 header('Content-Type: text/xml');
418 $only_current = Env
::v('only_current', false
)?
' AND FIND_IN_SET(\'active\', adrf.statut)' : '';
419 $it =& $this->set
->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias',
420 "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current)
421 LEFT JOIN aliases AS al ON (u.user_id = al.id
422 AND FIND_IN_SET('bestalias', al.flags))
423 INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")",
424 'adrf.cityid = ' . Env
::i('cityid'), null
, null
, 11);
425 $page->assign('users', $it);
429 if (Env
::has('debug')) {
430 $page->changeTpl('geoloc/country.tpl', SIMPLE
);
432 $page->changeTpl('geoloc/country.tpl', NO_SKIN
);
433 header('Content-Type: text/xml');
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);
444 if (!$this->use_map()) {
445 $page->assign('request_geodesix', true
);
447 $page->assign('annu', @$this->params
['with_annu']);
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
);
450 return 'include/plview.geoloc.tpl';
455 class GadgetView
implements PlView
457 public function __construct(PlSet
&$set, $data, array $params)
462 public function fields()
464 return "u.user_id AS id,
465 u.*, a.alias AS forlife," .
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" : '');
474 public function joins()
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)" .
481 "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
485 public function apply(PlPage
&$page)
487 $page->assign_by_ref('set',
488 $this->set
->get($this->fields(), $this->joins(), null
, null
, null
, 5, 0));
491 public function args()
497 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: