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() ?
"" : " AND adr.pub = 'public'").")
222 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
223 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)
224 LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active')
225 INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)" .
227 "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
231 public function bounds()
233 $order = Env
::v('order', $this->defaultkey
);
235 if (($order == "name") ||
($order == "-name")) {
236 $this->bound_field
= "nom";
238 } elseif (($order == "promo") ||
($order == "-promo")) {
239 $this->bound_field
= "promo";
242 if ($order{0} == '-') {
243 $show_bounds = -$show_bounds;
248 public function templateName()
250 return 'include/plview.minifiche.tpl';
254 class MentorView
extends MultipageView
256 public function __construct(PlSet
&$set, $data, array $params)
258 $this->entriesPerPage
= 10;
259 $this->addSortKey('rand', array('RAND(' . S
::i('uid') . ')'), 'aléatoirement');
260 $this->addSortKey('name', array('name_sort'), 'nom');
261 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
262 $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification');
263 parent
::__construct($set, $data, $params);
266 public function fields()
268 return "m.uid, u.promo,
269 a.alias AS bestalias, m.expertise, mp.pid,
270 ms.secteur, ms.ss_secteur,
271 nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort";
274 public function joins()
276 return "INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)";
279 public function bounds()
281 $order = Env
::v('order', $this->defaultkey
);
283 if (($order == "name") ||
($order == "-name")) {
284 $this->bound_field
= "nom";
286 } elseif (($order == "promo") ||
($order == "-promo")) {
287 $this->bound_field
= "promo";
290 if ($order{0} == '-') {
291 $show_bounds = -$show_bounds;
296 public function templateName()
298 return 'include/plview.referent.tpl';
302 class TrombiView
extends MultipageView
304 public function __construct(PlSet
&$set, $data, array $params)
306 $this->entriesPerPage
= 24;
307 $this->order
= explode(',', Env
::v('order', 'name_sort'));
308 if (@$params['with_score']) {
309 $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'name_sort'), 'pertinence');
311 $this->addSortKey('name', array('name_sort'), 'nom');
312 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
313 parent
::__construct($set, $data, $params);
316 public function fields()
318 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 ";
321 public function joins()
323 return "INNER JOIN photo AS p ON (p.uid = u.user_id)
324 INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)";
327 public function bounds()
329 $order = Env
::v('order', $this->defaultkey
);
331 if (($order == "name") ||
($order == "-name")) {
332 $this->bound_field
= "nom";
334 } elseif (($order == "promo") ||
($order == "-promo")) {
335 $this->bound_field
= "promo";
338 if ($order{0} == '-') {
339 $show_bounds = -$show_bounds;
344 public function templateName()
346 return 'include/plview.trombi.tpl';
349 public function apply(PlPage
&$page)
351 if (!empty($GLOBALS['IS_XNET_SITE'])) {
353 $page->assign('mainsiteurl', 'https://' . $globals->core
->secure_domain
. '/');
355 return parent
::apply($page);
359 class GeolocView
implements PlView
365 public function __construct(PlSet
&$set, $data, array $params)
367 $this->params
= $params;
372 private function use_map()
374 return is_file(dirname(__FILE__
) . '/../modules/geoloc/dynamap.swf') &&
375 is_file(dirname(__FILE__
) . '/../modules/geoloc/icon.swf');
378 public function args()
380 $args = $this->set
->args();
381 unset($args['initfile']);
382 unset($args['mapid']);
386 public function apply(PlPage
&$page)
388 require_once 'geoloc.inc.php';
389 require_once '../modules/search/search.inc.php';
391 switch ($this->type
) {
393 header("Content-type: application/x-shockwave-flash");
395 readfile(dirname(__FILE__
).'/../modules/geoloc/icon.swf');
399 header("Content-type: application/x-shockwave-flash");
401 readfile(dirname(__FILE__
).'/../modules/geoloc/dynamap.swf');
405 $page->changeTpl('geoloc/init.tpl', NO_SKIN
);
406 header('Content-Type: text/xml');
408 if (!empty($GLOBALS['IS_XNET_SITE'])) {
409 $page->assign('background', 0xF2E9D0);
414 $page->changeTpl('geoloc/city.tpl', NO_SKIN
);
415 header('Content-Type: text/xml');
417 $only_current = Env
::v('only_current', false
)?
' AND FIND_IN_SET(\'active\', adrf.statut)' : '';
418 $it =& $this->set
->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias',
419 "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current)
420 LEFT JOIN aliases AS al ON (u.user_id = al.id
421 AND FIND_IN_SET('bestalias', al.flags))
422 INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")",
423 'adrf.cityid = ' . Env
::i('cityid'), null
, null
, 11);
424 $page->assign('users', $it);
428 if (Env
::has('debug')) {
429 $page->changeTpl('geoloc/country.tpl', SIMPLE
);
431 $page->changeTpl('geoloc/country.tpl', NO_SKIN
);
432 header('Content-Type: text/xml');
435 $mapid = Env
::has('mapid') ? Env
::i('mapid', -2) : false
;
436 list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set
, 10);
437 $page->assign('countries', $countries);
438 $page->assign('cities', $cities);
443 if (!$this->use_map()) {
444 $page->assign('request_geodesix', true
);
446 $page->assign('annu', @$this->params
['with_annu']);
447 $page->assign('protocole', @$_SERVER['HTTPS'] ?
'https' : 'http');
448 $this->set
->get('u.user_id', null
, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null
);
449 return 'include/plview.geoloc.tpl';
454 class GadgetView
implements PlView
456 public function __construct(PlSet
&$set, $data, array $params)
461 public function fields()
463 return "u.user_id AS id,
464 u.*, a.alias AS forlife," .
465 "u.perms != 'pending' AS inscrit,
466 u.perms != 'pending' AS wasinscrit,
467 u.deces != 0 AS dcd, u.deces,
468 FIND_IN_SET('femme', u.flags) AS sexe,
469 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region" .
470 (S
::logged() ?
", c.contact AS contact" : '');
473 public function joins()
475 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'").")
476 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
477 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)" .
479 "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
483 public function apply(PlPage
&$page)
485 $page->assign_by_ref('set',
486 $this->set
->get($this->fields(), $this->joins(), null
, null
, null
, 5, 0));
489 public function args()
495 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: