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 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)
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\')';
41 class UserSet
extends PlSet
43 public function __construct($joins = '', $where = '')
46 parent
::__construct('auth_user_md5 AS u',
47 (!empty($GLOBALS['IS_XNET_SITE']) ?
48 'INNER JOIN groupex.membres AS gxm ON (u.user_id = gxm.uid
49 AND gxm.asso_id = ' . $globals->asso('id') . ') ' : '')
50 . 'LEFT JOIN auth_user_quick AS q USING (user_id)' . $joins,
56 class SearchSet
extends UserSet
58 public $advanced = false
;
59 private $score = null
;
60 private $order = null
;
61 private $quick = false
;
63 public function __construct($quick = false
, $no_search = false
, $join = '', $where = '')
65 Platal
::load('search', 'search.inc.php');
70 $this->quick
= $quick;
72 $this->getQuick($join, $where);
74 $this->getAdvanced($join, $where);
78 private function getQuick($join, $where)
80 Platal
::load('search', 'search.inc.php');
83 Env
::kill('with_soundex');
85 $qSearch = new QuickSearch('quick');
86 $fields = new SFieldGroup(true
, array($qSearch));
87 if ($qSearch->isEmpty()) {
88 new ThrowError('Aucun critère de recherche n\'est spécifié.');
90 $this->score
= $qSearch->get_score_statement();
91 $pwhere = $fields->get_where_statement();
98 if (S
::logged() && Env
::has('nonins')) {
102 $where .= 'u.perms="pending" AND u.deces=0';
104 parent
::__construct($join . ' ' . $fields->get_select_statement(), $where);
106 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
107 'u.promo DESC, NomSortKey, prenom')));
110 private function getAdvanced($join, $where)
113 $this->advanced
= true
;
114 $fields = new SFieldGroup(true
, advancedSearchFromInput());
115 if ($fields->too_large()) {
116 new ThrowError('Recherche trop générale.');
118 parent
::__construct(@$join . ' ' . $fields->get_select_statement(),
119 @$where . ' ' . $fields->get_where_statement());
120 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
121 'promo DESC, NomSortKey, prenom')));
124 public function &get($fields, $joins, $where, $groupby, $order, $limitcount = null
, $limitfrom = null
)
127 $fields .= ', ' . $this->score
;
129 return parent
::get($fields, $joins, $where, $groupby, $order, $limitcount, $limitfrom);
133 class ArraySet
extends UserSet
135 public function __construct(array $users)
137 $where = $this->getUids($users);
139 $where = "u.hruid IN ($where)";
143 parent
::__construct('', $where);
146 private function getUids(array $users)
148 $users = User
::getBulkHruid($users, array('User', '_silent_user_callback'));
149 if (is_null($users)) {
152 return '\'' . implode('\', \'', $users) . '\'';
156 class MinificheView
extends MultipageView
158 public function __construct(PlSet
&$set, $data, array $params)
160 require_once 'education.func.inc.php';
162 $this->entriesPerPage
= $globals->search
->per_page
;
163 if (@$params['with_score']) {
164 $this->addSortKey('score', array('-score', '-date', '-promo', 'name_sort'), 'pertinence');
166 $this->addSortKey('name', array('name_sort'), 'nom');
167 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
168 $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification');
169 parent
::__construct($set, $data, $params);
172 public function fields()
175 return "u.user_id AS id, u.*, d.promo_display,
176 CONCAT(a.alias, '@{$globals->mail->domain}') AS bestemail,
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,
181 je.name AS entreprise, je.url AS job_web, es.name AS secteur, ef.fonction_fr AS fonction,
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,
187 edu0.grad_year AS edugrad_year0, f0.field AS edufield0, edu0.program AS eduprogram0,
188 IF(ede1.abbreviation = '', ede1.name, ede1.abbreviation) AS eduname1, ede1.url AS eduurl1,
189 IF(edd1.abbreviation = '', edd1.degree, edd1.abbreviation) AS edudegree1,
190 edu1.grad_year AS edugrad_year1, f1.field AS edufield1, edu1.program AS eduprogram1,
191 IF(ede2.abbreviation = '', ede2.name, ede2.abbreviation) AS eduname2, ede2.url AS eduurl2,
192 IF(edd2.abbreviation = '', edd2.degree, edd2.abbreviation) AS edudegree2,
193 edu2.grad_year AS edugrad_year2, f2.field AS edufield2, edu2.program AS eduprogram2,
194 IF(ede3.abbreviation = '', ede3.name, ede3.abbreviation) AS eduname3, ede3.url AS eduurl3,
195 IF(edd3.abbreviation = '', edd3.degree, edd3.abbreviation) AS edudegree3,
196 edu3.grad_year AS edugrad_year3, f3.field AS edufield3, edu3.program AS eduprogram3,
197 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region,
198 (COUNT(em.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif,
199 nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort" .
200 (S
::logged() ?
", c.contact AS contact" : '');
203 public function joins()
205 return "LEFT JOIN aliases AS a ON (u.user_id = a.id AND FIND_IN_SET('bestalias', a.flags))
206 LEFT JOIN profile_job AS j ON (j.uid = u.user_id".(S
::logged() ?
"" : " AND j.pub = 'public'").")
207 LEFT JOIN profile_job_enum AS je ON (je.id = j.jobid)
208 LEFT JOIN profile_job_sector_enum AS es ON (j.sectorid = es.id)
209 LEFT JOIN fonctions_def AS ef ON (j.functionid = ef.id)
210 LEFT JOIN geoloc_pays AS n1 ON (u.nationalite = n1.a2)
211 LEFT JOIN geoloc_pays AS n2 ON (u.nationalite2 = n2.a2)
212 LEFT JOIN geoloc_pays AS n3 ON (u.nationalite3 = n3.a2)
213 LEFT JOIN profile_education AS edu0 ON (u.user_id = edu0.uid AND edu0.id = 0)
214 LEFT JOIN profile_education_enum AS ede0 ON (ede0.id = edu0.eduid)
215 LEFT JOIN profile_education_degree_enum AS edd0 ON (edd0.id = edu0.degreeid)
216 LEFT JOIN profile_education_field_enum AS f0 ON (f0.id = edu0.fieldid)
217 LEFT JOIN profile_education AS edu1 ON (u.user_id = edu1.uid AND edu1.id = 1)
218 LEFT JOIN profile_education_enum AS ede1 ON (ede1.id = edu1.eduid)
219 LEFT JOIN profile_education_degree_enum AS edd1 ON (edd1.id = edu1.degreeid)
220 LEFT JOIN profile_education_field_enum AS f1 ON (f1.id = edu1.fieldid)
221 LEFT JOIN profile_education AS edu2 ON (u.user_id = edu2.uid AND edu2.id = 2)
222 LEFT JOIN profile_education_enum AS ede2 ON (ede2.id = edu2.eduid)
223 LEFT JOIN profile_education_degree_enum AS edd2 ON (edd2.id = edu2.degreeid)
224 LEFT JOIN profile_education_field_enum AS f2 ON (f2.id = edu2.fieldid)
225 LEFT JOIN profile_education AS edu3 ON (u.user_id = edu3.uid AND edu3.id = 3)
226 LEFT JOIN profile_education_enum AS ede3 ON (ede3.id = edu3.eduid)
227 LEFT JOIN profile_education_degree_enum AS edd3 ON (edd3.id = edu3.degreeid)
228 LEFT JOIN profile_education_field_enum AS f3 ON (f3.id = edu3.fieldid)
229 LEFT JOIN adresses AS adr ON (u.user_id = adr.uid
230 AND FIND_IN_SET('active', adr.statut)".(S
::logged() ?
"" : "
231 AND adr.pub = 'public'").")
232 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
233 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)
234 LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active')
235 INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)
236 INNER JOIN profile_display AS d ON (d.uid = u.user_id)" . (S
::logged() ?
237 "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
241 public function bounds()
243 $order = Env
::v('order', $this->defaultkey
);
245 if (($order == "name") ||
($order == "-name")) {
246 $this->bound_field
= "nom";
248 } elseif (($order == "promo") ||
($order == "-promo")) {
249 $this->bound_field
= "promo";
252 if ($order{0} == '-') {
253 $show_bounds = -$show_bounds;
258 public function templateName()
260 return 'include/plview.minifiche.tpl';
264 class MentorView
extends MultipageView
266 public function __construct(PlSet
&$set, $data, array $params)
268 $this->entriesPerPage
= 10;
269 $this->addSortKey('rand', array('RAND(' . S
::i('uid') . ')'), 'aléatoirement');
270 $this->addSortKey('name', array('name_sort'), 'nom');
271 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
272 $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification');
273 parent
::__construct($set, $data, $params);
276 public function fields()
278 return "m.uid, d.promo_display, u.hruid,
279 m.expertise, mp.country, ms.sectorid, ms.subsectorid,
280 nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort";
283 public function joins()
285 return "INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)
286 INNER JOIN profile_display AS d ON (d.uid = u.user_id)";
289 public function bounds()
291 $order = Env
::v('order', $this->defaultkey
);
293 if (($order == "name") ||
($order == "-name")) {
294 $this->bound_field
= "nom";
296 } elseif (($order == "promo") ||
($order == "-promo")) {
297 $this->bound_field
= "promo";
300 if ($order{0} == '-') {
301 $show_bounds = -$show_bounds;
306 public function templateName()
308 return 'include/plview.referent.tpl';
312 class TrombiView
extends MultipageView
314 public function __construct(PlSet
&$set, $data, array $params)
316 $this->entriesPerPage
= 24;
317 $this->order
= explode(',', Env
::v('order', 'name_sort'));
318 if (@$params['with_score']) {
319 $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'name_sort'), 'pertinence');
321 $this->addSortKey('name', array('name_sort'), 'nom');
322 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
323 parent
::__construct($set, $data, $params);
326 public function fields()
328 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 ";
331 public function joins()
333 return "INNER JOIN photo AS p ON (p.uid = u.user_id)
334 INNER JOIN profile_display AS d ON (d.uid = u.user_id)
335 INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)";
338 public function bounds()
340 $order = Env
::v('order', $this->defaultkey
);
342 if (($order == "name") ||
($order == "-name")) {
343 $this->bound_field
= "nom";
345 } elseif (($order == "promo") ||
($order == "-promo")) {
346 $this->bound_field
= "promo";
349 if ($order{0} == '-') {
350 $show_bounds = -$show_bounds;
355 public function templateName()
357 return 'include/plview.trombi.tpl';
360 public function apply(PlPage
&$page)
362 if (!empty($GLOBALS['IS_XNET_SITE'])) {
364 $page->assign('mainsiteurl', 'https://' . $globals->core
->secure_domain
. '/');
366 return parent
::apply($page);
370 class GeolocView
implements PlView
376 public function __construct(PlSet
&$set, $data, array $params)
378 $this->params
= $params;
383 private function use_map()
385 return is_file(dirname(__FILE__
) . '/../modules/geoloc/dynamap.swf') &&
386 is_file(dirname(__FILE__
) . '/../modules/geoloc/icon.swf');
389 public function args()
391 $args = $this->set
->args();
392 unset($args['initfile']);
393 unset($args['mapid']);
397 public function apply(PlPage
&$page)
399 require_once 'geoloc.inc.php';
400 require_once '../modules/search/search.inc.php';
402 switch ($this->type
) {
404 header("Content-type: application/x-shockwave-flash");
406 readfile(dirname(__FILE__
).'/../modules/geoloc/icon.swf');
410 header("Content-type: application/x-shockwave-flash");
412 readfile(dirname(__FILE__
).'/../modules/geoloc/dynamap.swf');
416 $page->changeTpl('geoloc/init.tpl', NO_SKIN
);
417 header('Content-Type: text/xml');
419 if (!empty($GLOBALS['IS_XNET_SITE'])) {
420 $page->assign('background', 0xF2E9D0);
425 $page->changeTpl('geoloc/city.tpl', NO_SKIN
);
426 header('Content-Type: text/xml');
428 $only_current = Env
::v('only_current', false
)?
' AND FIND_IN_SET(\'active\', adrf.statut)' : '';
429 $it =& $this->set
->get('u.user_id AS id, u.prenom, u.nom, d.promo_display, al.alias',
430 "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current)
431 INNER JOIN profile_display AS d ON (d.uid = u.user_id)
432 LEFT JOIN aliases AS al ON (u.user_id = al.id
433 AND FIND_IN_SET('bestalias', al.flags))
434 INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")",
435 'adrf.cityid = ' . Env
::i('cityid'), null
, null
, 11);
436 $page->assign('users', $it);
440 if (Env
::has('debug')) {
441 $page->changeTpl('geoloc/country.tpl', SIMPLE
);
443 $page->changeTpl('geoloc/country.tpl', NO_SKIN
);
444 header('Content-Type: text/xml');
447 $mapid = Env
::has('mapid') ? Env
::i('mapid', -2) : false
;
448 list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set
, 10);
449 $page->assign('countries', $countries);
450 $page->assign('cities', $cities);
455 if (!$this->use_map()) {
456 $page->assign('request_geodesix', true
);
458 $page->assign('annu', @$this->params
['with_annu']);
459 $page->assign('protocole', @$_SERVER['HTTPS'] ?
'https' : 'http');
460 $this->set
->get('u.user_id', null
, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null
);
461 return 'include/plview.geoloc.tpl';
466 class GadgetView
implements PlView
468 public function __construct(PlSet
&$set, $data, array $params)
473 public function fields()
475 return "u.user_id AS id, u.*," .
476 "u.perms != 'pending' AS inscrit,
477 u.perms != 'pending' AS wasinscrit,
478 u.deces != 0 AS dcd, u.deces,
479 FIND_IN_SET('femme', u.flags) AS sexe,
480 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region" .
481 (S
::logged() ?
", c.contact AS contact" : '');
484 public function joins()
486 return "LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET('active', adr.statut)".(S
::logged() ?
"" : "
487 AND adr.pub = 'public'").")
488 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
489 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)" .
491 "LEFT JOIN contacts AS c ON (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
495 public function apply(PlPage
&$page)
497 $page->assign_by_ref('set',
498 $this->set
->get($this->fields(), $this->joins(), null
, null
, null
, 5, 0));
501 public function args()
507 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: