2 /***************************************************************************
3 * Copyright (C) 2003-2009 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 n ON (u.nationalite = n.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 'applis.func.inc.php';
161 $this->entriesPerPage
= $globals->search
->per_page
;
162 if (@$params['with_score']) {
163 $this->addSortKey('score', array('-score', '-date', '-promo', 'nom', 'prenom'), 'pertinence');
165 $this->addSortKey('name', array('nom', 'prenom'), 'nom');
166 $this->addSortKey('promo', array('-promo', 'nom', 'prenom'), 'promotion');
167 $this->addSortKey('date_mod', array('-date', '-promo', 'nom', 'prenom'), 'dernière modification');
168 parent
::__construct($set, $data, $params);
171 public function fields()
174 return "u.user_id AS id, u.*,
175 CONCAT(a.alias, '@{$globals->mail->domain}') AS bestemail,
176 u.perms != 'pending' AS inscrit,
177 u.perms != 'pending' AS wasinscrit,
178 u.deces != 0 AS dcd, u.deces, u.matricule_ax,
179 FIND_IN_SET('femme', u.flags) AS sexe,
180 e.entreprise, e.web AS job_web, es.label AS secteur, ef.fonction_fr AS fonction,
181 IF(n.nat='',n.pays,n.nat) AS nat, n.a2 AS iso3166,
182 ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
183 ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
184 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region,
185 IF(u.nom_usage<>'',u.nom_usage,u.nom) AS sortkey,
186 (COUNT(em.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif" .
187 (S
::logged() ?
", c.contact AS contact" : '');
190 public function joins()
192 return "LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id".(S
::logged() ?
"" : " AND e.pub = 'public'").")
193 LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id)
194 LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id)
195 LEFT JOIN geoloc_pays AS n ON (u.nationalite = n.a2)
196 LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0)
197 LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid)
198 LEFT JOIN applis_ins AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1)
199 LEFT JOIN applis_def AS ad1 ON (ad1.id = ai1.aid)
200 LEFT JOIN adresses AS adr ON (u.user_id = adr.uid
201 AND FIND_IN_SET('active', adr.statut)".(S
::logged() ?
"" : " AND adr.pub = 'public'").")
202 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
203 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)
204 LEFT JOIN aliases AS a ON (a.id = u.user_id AND FIND_IN_SET('bestalias', a.flags))
205 LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active')" .
207 "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
211 public function bounds()
213 $order = Env
::v('order', $this->defaultkey
);
215 if (($order == "name") ||
($order == "-name")) {
216 $this->bound_field
= "nom";
218 } elseif (($order == "promo") ||
($order == "-promo")) {
219 $this->bound_field
= "promo";
222 if ($order{0} == '-') {
223 $show_bounds = -$show_bounds;
228 public function templateName()
230 return 'include/plview.minifiche.tpl';
234 class MentorView
extends MultipageView
236 public function __construct(PlSet
&$set, $data, array $params)
238 $this->entriesPerPage
= 10;
239 $this->addSortKey('rand', array('RAND(' . S
::i('uid') . ')'), 'aléatoirement');
240 $this->addSortKey('name', array('nom', 'prenom'), 'nom');
241 $this->addSortKey('promo', array('-promo', 'nom', 'prenom'), 'promotion');
242 $this->addSortKey('date_mod', array('-date', '-promo', 'nom', 'prenom'), 'dernière modification');
243 parent
::__construct($set, $data, $params);
246 public function fields()
248 return "m.uid, u.prenom, u.nom, u.promo, u.hruid,
249 m.expertise, mp.pid, ms.secteur, ms.ss_secteur";
252 public function bounds()
254 $order = Env
::v('order', $this->defaultkey
);
256 if (($order == "name") ||
($order == "-name")) {
257 $this->bound_field
= "nom";
259 } elseif (($order == "promo") ||
($order == "-promo")) {
260 $this->bound_field
= "promo";
263 if ($order{0} == '-') {
264 $show_bounds = -$show_bounds;
269 public function templateName()
271 return 'include/plview.referent.tpl';
275 class TrombiView
extends MultipageView
277 public function __construct(PlSet
&$set, $data, array $params)
279 $this->entriesPerPage
= 24;
280 $this->order
= explode(',', Env
::v('order', 'nom,prenom,promo'));
281 if (@$params['with_score']) {
282 $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'nom', 'prenom'), 'pertinence');
284 $this->addSortKey('name', array('nom', 'prenom'), 'nom');
285 $this->addSortKey('promo', array('-promo', 'nom', 'prenom'), 'promotion');
286 parent
::__construct($set, $data, $params);
289 public function fields()
291 return "u.user_id, IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo, u.hruid ";
294 public function joins()
296 return "INNER JOIN photo AS p ON (p.uid = u.user_id) ";
299 public function bounds()
301 $order = Env
::v('order', $this->defaultkey
);
303 if (($order == "name") ||
($order == "-name")) {
304 $this->bound_field
= "nom";
306 } elseif (($order == "promo") ||
($order == "-promo")) {
307 $this->bound_field
= "promo";
310 if ($order{0} == '-') {
311 $show_bounds = -$show_bounds;
316 public function templateName()
318 return 'include/plview.trombi.tpl';
321 public function apply(PlPage
&$page)
323 if (!empty($GLOBALS['IS_XNET_SITE'])) {
325 $page->assign('mainsiteurl', 'https://' . $globals->core
->secure_domain
. '/');
327 return parent
::apply($page);
331 class GeolocView
implements PlView
337 public function __construct(PlSet
&$set, $data, array $params)
339 $this->params
= $params;
344 private function use_map()
346 return is_file(dirname(__FILE__
) . '/../modules/geoloc/dynamap.swf') &&
347 is_file(dirname(__FILE__
) . '/../modules/geoloc/icon.swf');
350 public function args()
352 $args = $this->set
->args();
353 unset($args['initfile']);
354 unset($args['mapid']);
358 public function apply(PlPage
&$page)
360 require_once 'geoloc.inc.php';
361 require_once '../modules/search/search.inc.php';
363 switch ($this->type
) {
365 pl_cached_content_headers("application/x-shockwave-flash");
366 readfile(dirname(__FILE__
).'/../modules/geoloc/icon.swf');
370 pl_cached_content_headers("application/x-shockwave-flash");
371 readfile(dirname(__FILE__
).'/../modules/geoloc/dynamap.swf');
375 $page->changeTpl('geoloc/init.tpl', NO_SKIN
);
376 pl_cached_content_headers("text/xml", "utf-8");
377 if (!empty($GLOBALS['IS_XNET_SITE'])) {
378 $page->assign('background', 0xF2E9D0);
383 $page->changeTpl('geoloc/city.tpl', NO_SKIN
);
384 pl_cached_content_headers("text/xml", "utf-8");
385 $only_current = Env
::v('only_current', false
)?
' AND FIND_IN_SET(\'active\', adrf.statut)' : '';
386 $it =& $this->set
->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias',
387 "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current)
388 LEFT JOIN aliases AS al ON (u.user_id = al.id
389 AND FIND_IN_SET('bestalias', al.flags))
390 INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")",
391 'adrf.cityid = ' . Env
::i('cityid'), null
, null
, 11);
392 $page->assign('users', $it);
396 if (Env
::has('debug')) {
397 $page->changeTpl('geoloc/country.tpl', SIMPLE
);
399 $page->changeTpl('geoloc/country.tpl', NO_SKIN
);
400 pl_cached_content_headers("text/xml", "utf-8");
402 $mapid = Env
::has('mapid') ? Env
::i('mapid', -2) : false
;
403 list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set
, 10);
404 $page->assign('countries', $countries);
405 $page->assign('cities', $cities);
410 if (!$this->use_map()) {
411 $page->assign('request_geodesix', true
);
413 $page->assign('annu', @$this->params
['with_annu']);
414 $page->assign('protocole', @$_SERVER['HTTPS'] ?
'https' : 'http');
415 $this->set
->get('u.user_id', null
, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null
);
416 return 'include/plview.geoloc.tpl';
421 class GadgetView
implements PlView
423 public function __construct(PlSet
&$set, $data, array $params)
428 public function fields()
430 return "u.user_id AS id, u.*," .
431 (S
::logged() ?
"q.profile_mobile AS mobile, " : "IF(q.profile_mobile_pub = 'public', q.profile_mobile, NULL) as mobile, ") .
432 "u.perms != 'pending' AS inscrit,
433 u.perms != 'pending' AS wasinscrit,
434 u.deces != 0 AS dcd, u.deces,
435 FIND_IN_SET('femme', u.flags) AS sexe,
436 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region" .
437 (S
::logged() ?
", c.contact AS contact" : '');
440 public function joins()
442 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'").")
443 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
444 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)" .
446 "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
450 public function apply(PlPage
&$page)
452 $page->assign_by_ref('set',
453 $this->set
->get($this->fields(), $this->joins(), null
, null
, null
, 5, 0));
456 public function args()
462 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: