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)' . $joins,
55 class SearchSet
extends UserSet
57 public $advanced = false
;
58 private $score = null
;
59 private $order = null
;
60 private $quick = false
;
62 public function __construct($quick = false
, $no_search = false
, $join = '', $where = '')
64 Platal
::load('search', 'search.inc.php');
69 $this->quick
= $quick;
71 $this->getQuick($join, $where);
73 $this->getAdvanced($join, $where);
77 private function getQuick($join, $where)
79 Platal
::load('search', 'search.inc.php');
82 Env
::kill('with_soundex');
84 $qSearch = new QuickSearch('quick');
85 $fields = new SFieldGroup(true
, array($qSearch));
86 if ($qSearch->isEmpty()) {
87 new ThrowError('Aucun critère de recherche n\'est spécifié.');
89 $this->score
= $qSearch->get_score_statement();
90 $pwhere = $fields->get_where_statement();
97 if (S
::logged() && Env
::has('nonins')) {
101 $where .= 'u.perms="pending" AND u.deces=0';
103 parent
::__construct($join . ' ' . $fields->get_select_statement(), $where);
105 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
106 'u.promo DESC, NomSortKey, prenom')));
109 private function getAdvanced($join, $where)
112 $this->advanced
= true
;
113 $fields = new SFieldGroup(true
, advancedSearchFromInput());
114 if ($fields->too_large()) {
115 new ThrowError('Recherche trop générale.');
117 parent
::__construct(@$join . ' ' . $fields->get_select_statement(),
118 @$where . ' ' . $fields->get_where_statement());
119 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
120 'promo DESC, NomSortKey, prenom')));
123 public function &get($fields, $joins, $where, $groupby, $order, $limitcount = null
, $limitfrom = null
)
126 $fields .= ', ' . $this->score
;
128 return parent
::get($fields, $joins, $where, $groupby, $order, $limitcount, $limitfrom);
132 class ArraySet
extends UserSet
134 public function __construct(array $users)
136 $where = $this->getUids($users);
138 $where = "u.hruid IN ($where)";
142 parent
::__construct('', $where);
145 private function getUids(array $users)
147 $users = User
::getBulkHruid($users, array('User', '_silent_user_callback'));
148 if (is_null($users)) {
151 return '\'' . implode('\', \'', $users) . '\'';
155 class MinificheView
extends MultipageView
157 public function __construct(PlSet
&$set, $data, array $params)
159 require_once 'education.func.inc.php';
161 $this->entriesPerPage
= $globals->search
->per_page
;
162 if (@$params['with_score']) {
163 $this->addSortKey('score', array('-score', '-date', '-promo', 'name_sort'), 'pertinence');
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');
168 parent
::__construct($set, $data, $params);
171 public function fields()
174 return "u.user_id AS id, u.*, d.promo_display,
175 u.perms != 'pending' AS inscrit,
176 u.perms != 'pending' AS wasinscrit,
177 u.deces != 0 AS dcd, u.deces, u.matricule_ax,
178 FIND_IN_SET('femme', u.flags) AS sexe,
179 e.entreprise, e.web AS job_web, es.label AS secteur, ef.fonction_fr AS fonction,
180 IF(n1.nat = '', n1.pays, n1.nat) AS nat1, n1.a2 AS iso3166_1,
181 IF(n2.nat = '', n2.pays, n2.nat) AS nat2, n2.a2 AS iso3166_2,
182 IF(n3.nat = '', n3.pays, n3.nat) AS nat3, n3.a2 AS iso3166_3,
183 IF(ede0.abbreviation = '', ede0.name, ede0.abbreviation) AS eduname0, ede0.url AS eduurl0,
184 IF(edd0.abbreviation = '', edd0.degree, edd0.abbreviation) AS edudegree0,
185 edu0.grad_year AS edugrad_year0, f0.field AS edufield0, edu0.program AS eduprogram0,
186 IF(ede1.abbreviation = '', ede1.name, ede1.abbreviation) AS eduname1, ede1.url AS eduurl1,
187 IF(edd1.abbreviation = '', edd1.degree, edd1.abbreviation) AS edudegree1,
188 edu1.grad_year AS edugrad_year1, f1.field AS edufield1, edu1.program AS eduprogram1,
189 IF(ede2.abbreviation = '', ede2.name, ede2.abbreviation) AS eduname2, ede2.url AS eduurl2,
190 IF(edd2.abbreviation = '', edd2.degree, edd2.abbreviation) AS edudegree2,
191 edu2.grad_year AS edugrad_year2, f2.field AS edufield2, edu2.program AS eduprogram2,
192 IF(ede3.abbreviation = '', ede3.name, ede3.abbreviation) AS eduname3, ede3.url AS eduurl3,
193 IF(edd3.abbreviation = '', edd3.degree, edd3.abbreviation) AS edudegree3,
194 edu3.grad_year AS edugrad_year3, f3.field AS edufield3, edu3.program AS eduprogram3,
195 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region,
196 (COUNT(em.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif,
197 nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort" .
198 (S
::logged() ?
", c.contact AS contact" : '');
201 public function joins()
203 return "LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id".(S
::logged() ?
"" : " AND e.pub = 'public'").")
204 LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id)
205 LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id)
206 LEFT JOIN geoloc_pays AS n1 ON (u.nationalite = n1.a2)
207 LEFT JOIN geoloc_pays AS n2 ON (u.nationalite2 = n2.a2)
208 LEFT JOIN geoloc_pays AS n3 ON (u.nationalite3 = n3.a2)
209 LEFT JOIN profile_education AS edu0 ON (u.user_id = edu0.uid AND edu0.id = 0)
210 LEFT JOIN profile_education_enum AS ede0 ON (ede0.id = edu0.eduid)
211 LEFT JOIN profile_education_degree_enum AS edd0 ON (edd0.id = edu0.degreeid)
212 LEFT JOIN profile_education_field_enum AS f0 ON (f0.id = edu0.fieldid)
213 LEFT JOIN profile_education AS edu1 ON (u.user_id = edu1.uid AND edu1.id = 1)
214 LEFT JOIN profile_education_enum AS ede1 ON (ede1.id = edu1.eduid)
215 LEFT JOIN profile_education_degree_enum AS edd1 ON (edd1.id = edu1.degreeid)
216 LEFT JOIN profile_education_field_enum AS f1 ON (f1.id = edu1.fieldid)
217 LEFT JOIN profile_education AS edu2 ON (u.user_id = edu2.uid AND edu2.id = 2)
218 LEFT JOIN profile_education_enum AS ede2 ON (ede2.id = edu2.eduid)
219 LEFT JOIN profile_education_degree_enum AS edd2 ON (edd2.id = edu2.degreeid)
220 LEFT JOIN profile_education_field_enum AS f2 ON (f2.id = edu2.fieldid)
221 LEFT JOIN profile_education AS edu3 ON (u.user_id = edu3.uid AND edu3.id = 3)
222 LEFT JOIN profile_education_enum AS ede3 ON (ede3.id = edu3.eduid)
223 LEFT JOIN profile_education_degree_enum AS edd3 ON (edd3.id = edu3.degreeid)
224 LEFT JOIN profile_education_field_enum AS f3 ON (f3.id = edu3.fieldid)
225 LEFT JOIN adresses AS adr ON (u.user_id = adr.uid
226 AND FIND_IN_SET('active', adr.statut)".(S
::logged() ?
"" : "
227 AND adr.pub = 'public'").")
228 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
229 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)
230 LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active')
231 INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)
232 INNER JOIN profile_display AS d ON (d.uid = u.user_id)" . (S
::logged() ?
233 "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
237 public function bounds()
239 $order = Env
::v('order', $this->defaultkey
);
241 if (($order == "name") ||
($order == "-name")) {
242 $this->bound_field
= "nom";
244 } elseif (($order == "promo") ||
($order == "-promo")) {
245 $this->bound_field
= "promo";
248 if ($order{0} == '-') {
249 $show_bounds = -$show_bounds;
254 public function templateName()
256 return 'include/plview.minifiche.tpl';
260 class MentorView
extends MultipageView
262 public function __construct(PlSet
&$set, $data, array $params)
264 $this->entriesPerPage
= 10;
265 $this->addSortKey('rand', array('RAND(' . S
::i('uid') . ')'), 'aléatoirement');
266 $this->addSortKey('name', array('name_sort'), 'nom');
267 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
268 $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification');
269 parent
::__construct($set, $data, $params);
272 public function fields()
274 return "m.uid, d.promo_display, u.hruid,
275 m.expertise, mp.pid, ms.secteur, ms.ss_secteur,
276 nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort";
279 public function joins()
281 return "INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)
282 INNER JOIN profile_display AS d ON (d.uid = u.user_id)";
285 public function bounds()
287 $order = Env
::v('order', $this->defaultkey
);
289 if (($order == "name") ||
($order == "-name")) {
290 $this->bound_field
= "nom";
292 } elseif (($order == "promo") ||
($order == "-promo")) {
293 $this->bound_field
= "promo";
296 if ($order{0} == '-') {
297 $show_bounds = -$show_bounds;
302 public function templateName()
304 return 'include/plview.referent.tpl';
308 class TrombiView
extends MultipageView
310 public function __construct(PlSet
&$set, $data, array $params)
312 $this->entriesPerPage
= 24;
313 $this->order
= explode(',', Env
::v('order', 'name_sort'));
314 if (@$params['with_score']) {
315 $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'name_sort'), 'pertinence');
317 $this->addSortKey('name', array('name_sort'), 'nom');
318 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
319 parent
::__construct($set, $data, $params);
322 public function fields()
324 return "u.user_id, nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort, u.promo, d.promo_display, u.hruid ";
327 public function joins()
329 return "INNER JOIN photo AS p ON (p.uid = u.user_id)
330 INNER JOIN profile_display AS d ON (d.uid = u.user_id)
331 INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)";
334 public function bounds()
336 $order = Env
::v('order', $this->defaultkey
);
338 if (($order == "name") ||
($order == "-name")) {
339 $this->bound_field
= "nom";
341 } elseif (($order == "promo") ||
($order == "-promo")) {
342 $this->bound_field
= "promo";
345 if ($order{0} == '-') {
346 $show_bounds = -$show_bounds;
351 public function templateName()
353 return 'include/plview.trombi.tpl';
356 public function apply(PlPage
&$page)
358 if (!empty($GLOBALS['IS_XNET_SITE'])) {
360 $page->assign('mainsiteurl', 'https://' . $globals->core
->secure_domain
. '/');
362 return parent
::apply($page);
366 class GeolocView
implements PlView
372 public function __construct(PlSet
&$set, $data, array $params)
374 $this->params
= $params;
379 private function use_map()
381 return is_file(dirname(__FILE__
) . '/../modules/geoloc/dynamap.swf') &&
382 is_file(dirname(__FILE__
) . '/../modules/geoloc/icon.swf');
385 public function args()
387 $args = $this->set
->args();
388 unset($args['initfile']);
389 unset($args['mapid']);
393 public function apply(PlPage
&$page)
395 require_once 'geoloc.inc.php';
396 require_once '../modules/search/search.inc.php';
398 switch ($this->type
) {
400 header("Content-type: application/x-shockwave-flash");
402 readfile(dirname(__FILE__
).'/../modules/geoloc/icon.swf');
406 header("Content-type: application/x-shockwave-flash");
408 readfile(dirname(__FILE__
).'/../modules/geoloc/dynamap.swf');
412 $page->changeTpl('geoloc/init.tpl', NO_SKIN
);
413 header('Content-Type: text/xml');
415 if (!empty($GLOBALS['IS_XNET_SITE'])) {
416 $page->assign('background', 0xF2E9D0);
421 $page->changeTpl('geoloc/city.tpl', NO_SKIN
);
422 header('Content-Type: text/xml');
424 $only_current = Env
::v('only_current', false
)?
' AND FIND_IN_SET(\'active\', adrf.statut)' : '';
425 $it =& $this->set
->get('u.user_id AS id, u.prenom, u.nom, d.promo_display, al.alias',
426 "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current)
427 INNER JOIN profile_display AS d ON (d.uid = u.user_id)
428 LEFT JOIN aliases AS al ON (u.user_id = al.id
429 AND FIND_IN_SET('bestalias', al.flags))
430 INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")",
431 'adrf.cityid = ' . Env
::i('cityid'), null
, null
, 11);
432 $page->assign('users', $it);
436 if (Env
::has('debug')) {
437 $page->changeTpl('geoloc/country.tpl', SIMPLE
);
439 $page->changeTpl('geoloc/country.tpl', NO_SKIN
);
440 header('Content-Type: text/xml');
443 $mapid = Env
::has('mapid') ? Env
::i('mapid', -2) : false
;
444 list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set
, 10);
445 $page->assign('countries', $countries);
446 $page->assign('cities', $cities);
451 if (!$this->use_map()) {
452 $page->assign('request_geodesix', true
);
454 $page->assign('annu', @$this->params
['with_annu']);
455 $page->assign('protocole', @$_SERVER['HTTPS'] ?
'https' : 'http');
456 $this->set
->get('u.user_id', null
, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null
);
457 return 'include/plview.geoloc.tpl';
462 class GadgetView
implements PlView
464 public function __construct(PlSet
&$set, $data, array $params)
469 public function fields()
471 return "u.user_id AS id, u.*," .
472 "u.perms != 'pending' AS inscrit,
473 u.perms != 'pending' AS wasinscrit,
474 u.deces != 0 AS dcd, u.deces,
475 FIND_IN_SET('femme', u.flags) AS sexe,
476 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region" .
477 (S
::logged() ?
", c.contact AS contact" : '');
480 public function joins()
482 return "LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET('active', adr.statut)".(S
::logged() ?
"" : "
483 AND adr.pub = 'public'").")
484 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
485 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)" .
487 "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
491 public function apply(PlPage
&$page)
493 $page->assign_by_ref('set',
494 $this->set
->get($this->fields(), $this->joins(), null
, null
, null
, 5, 0));
497 public function args()
503 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: