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('xorg.misc.inc.php');
23 require_once('user.func.inc.php');
27 @$globals->search
->result_where_statement
= '
28 LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0)
29 LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid)
30 LEFT JOIN applis_ins AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1)
31 LEFT JOIN applis_def AS ad1 ON (ad1.id = ai1.aid)
32 LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id)
33 LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id)
34 LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id)
35 LEFT JOIN geoloc_pays AS n ON (u.nationalite = n.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)
51 LEFT JOIN aliases AS a ON (a.id = u.user_id AND a.type = \'a_vie\')
58 class SearchSet
extends UserSet
60 public $advanced = false
;
61 private $score = null
;
62 private $order = null
;
63 private $quick = false
;
65 public function __construct($quick = false
, $no_search = false
, $join = '', $where = '')
67 require_once dirname(__FILE__
).'/../modules/search/search.inc.php';
73 $this->quick
= $quick;
75 $this->getQuick($join, $where);
77 $this->getAdvanced($join, $where);
81 private function getQuick($join, $where)
83 require_once dirname(__FILE__
).'/../modules/search/search.inc.php';
86 Env
::kill('with_soundex');
88 $qSearch = new QuickSearch('quick');
89 $fields = new SFieldGroup(true
, array($qSearch));
90 if ($qSearch->isEmpty()) {
91 new ThrowError('Aucun critère de recherche n\'est spécifié.');
93 $this->score
= $qSearch->get_score_statement();
94 $pwhere = $fields->get_where_statement();
101 if (S
::logged() && Env
::has('nonins')) {
105 $where .= 'u.perms="pending" AND u.deces=0';
107 parent
::__construct($join . ' ' . $fields->get_select_statement(), $where);
109 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
110 'u.promo DESC, NomSortKey, prenom')));
113 private function getAdvanced($join, $where)
116 $this->advanced
= true
;
117 $fields = new SFieldGroup(true
, advancedSearchFromInput());
118 if ($fields->too_large()) {
119 new ThrowError('Recherche trop générale.');
121 parent
::__construct(@$join . ' ' . $fields->get_select_statement(),
122 @$where . ' ' . $fields->get_where_statement());
123 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
124 'promo DESC, NomSortKey, prenom')));
127 public function &get($fields, $joins, $where, $groupby, $order, $limitcount = null
, $limitfrom = null
)
130 $fields .= ', ' . $this->score
;
132 return parent
::get($fields, $joins, $where, $groupby, $order, $limitcount, $limitfrom);
136 class ArraySet
extends UserSet
138 public function __construct(array $users)
140 $where = $this->getUids($users);
142 $where = "a.alias IN ($where)";
146 parent
::__construct('', $where);
149 private function getUids(array $users)
151 $users = get_users_forlife_list($users, true
, '_silent_user_callback');
152 if (is_null($users)) {
155 return '\'' . implode('\', \'', $users) . '\'';
159 class MinificheView
extends MultipageView
161 public function __construct(PlSet
&$set, $data, array $params)
163 require_once 'applis.func.inc.php';
165 $this->entriesPerPage
= $globals->search
->per_page
;
166 if (@$params['with_score']) {
167 $this->addSortKey('score', array('-score', '-date', '-promo', 'nom', 'prenom'), 'pertinence');
169 $this->addSortKey('name', array('nom', 'prenom'), 'nom');
170 $this->addSortKey('promo', array('-promo', 'nom', 'prenom'), 'promotion');
171 $this->addSortKey('date_mod', array('-date', '-promo', 'nom', 'prenom'), 'dernière modification');
172 parent
::__construct($set, $data, $params);
175 public function fields()
177 return "u.user_id AS id,
178 u.*, a.alias AS forlife,
179 u.perms != 'pending' AS inscrit,
180 u.perms != 'pending' AS wasinscrit,
181 u.deces != 0 AS dcd, u.deces, u.matricule_ax,
182 FIND_IN_SET('femme', u.flags) AS sexe,
183 e.entreprise, es.label AS secteur, ef.fonction_fr AS fonction,
184 IF(n.nat='',n.pays,n.nat) AS nat, n.a2 AS iso3166,
185 ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
186 ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
187 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region,
188 IF(u.nom_usage<>'',u.nom_usage,u.nom) AS sortkey,
189 (COUNT(em.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif" .
190 (S
::logged() ?
", c.contact AS contact" : '');
193 public function joins()
195 return "LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id".(S
::logged() ?
"" : " AND e.pub = 'public'").")
196 LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id)
197 LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id)
198 LEFT JOIN geoloc_pays AS n ON (u.nationalite = n.a2)
199 LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0)
200 LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid)
201 LEFT JOIN applis_ins AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1)
202 LEFT JOIN applis_def AS ad1 ON (ad1.id = ai1.aid)
203 LEFT JOIN adresses AS adr ON (u.user_id = adr.uid
204 AND FIND_IN_SET('active', adr.statut)".(S
::logged() ?
"" : " AND adr.pub = 'public'").")
205 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
206 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)
207 LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active')" .
209 "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
213 public function bounds()
215 $order = Env
::v('order', $this->defaultkey
);
217 if (($order == "name") ||
($order == "-name")) {
218 $this->bound_field
= "nom";
220 } elseif (($order == "promo") ||
($order == "-promo")) {
221 $this->bound_field
= "promo";
224 if ($order{0} == '-') {
225 $show_bounds = -$show_bounds;
230 public function templateName()
232 return 'include/plview.minifiche.tpl';
236 class MentorView
extends MultipageView
238 public function __construct(PlSet
&$set, $data, array $params)
240 $this->entriesPerPage
= 10;
241 $this->addSortKey('rand', array('RAND(' . S
::i('uid') . ')'), 'aléatoirement');
242 $this->addSortKey('name', array('nom', 'prenom'), 'nom');
243 $this->addSortKey('promo', array('-promo', 'nom', 'prenom'), 'promotion');
244 $this->addSortKey('date_mod', array('-date', '-promo', 'nom', 'prenom'), 'dernière modification');
245 parent
::__construct($set, $data, $params);
248 public function fields()
250 return "m.uid, u.prenom, u.nom, u.promo,
251 a.alias AS forlife, m.expertise, mp.pid,
252 ms.secteur, ms.ss_secteur";
255 public function bounds()
257 $order = Env
::v('order', $this->defaultkey
);
259 if (($order == "name") ||
($order == "-name")) {
260 $this->bound_field
= "nom";
262 } elseif (($order == "promo") ||
($order == "-promo")) {
263 $this->bound_field
= "promo";
266 if ($order{0} == '-') {
267 $show_bounds = -$show_bounds;
272 public function templateName()
274 return 'include/plview.referent.tpl';
278 class TrombiView
extends MultipageView
280 public function __construct(PlSet
&$set, $data, array $params)
282 $this->entriesPerPage
= 24;
283 $this->order
= explode(',', Env
::v('order', 'nom,prenom,promo'));
284 if (@$params['with_score']) {
285 $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'nom', 'prenom'), 'pertinence');
287 $this->addSortKey('name', array('nom', 'prenom'), 'nom');
288 $this->addSortKey('promo', array('-promo', 'nom', 'prenom'), 'promotion');
289 parent
::__construct($set, $data, $params);
292 public function fields()
294 return "u.user_id, IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo, a.alias AS forlife ";
297 public function joins()
299 return "INNER JOIN photo AS p ON (p.uid = u.user_id) ";
302 public function bounds()
304 $order = Env
::v('order', $this->defaultkey
);
306 if (($order == "name") ||
($order == "-name")) {
307 $this->bound_field
= "nom";
309 } elseif (($order == "promo") ||
($order == "-promo")) {
310 $this->bound_field
= "promo";
313 if ($order{0} == '-') {
314 $show_bounds = -$show_bounds;
319 public function templateName()
321 return 'include/plview.trombi.tpl';
324 public function apply(PlatalPage
&$page)
326 if (!empty($GLOBALS['IS_XNET_SITE'])) {
328 $page->assign('mainsiteurl', 'https://' . $globals->core
->secure_domain
. '/');
330 return parent
::apply($page);
334 class GeolocView
implements PlView
340 public function __construct(PlSet
&$set, $data, array $params)
342 $this->params
= $params;
347 private function use_map()
349 return is_file(dirname(__FILE__
) . '/../modules/geoloc/dynamap.swf') &&
350 is_file(dirname(__FILE__
) . '/../modules/geoloc/icon.swf');
353 public function args()
355 $args = $this->set
->args();
356 unset($args['initfile']);
357 unset($args['mapid']);
361 public function apply(PlatalPage
&$page)
363 require_once 'geoloc.inc.php';
364 require_once '../modules/search/search.inc.php';
366 switch ($this->type
) {
368 header("Content-type: application/x-shockwave-flash");
370 readfile(dirname(__FILE__
).'/../modules/geoloc/icon.swf');
374 header("Content-type: application/x-shockwave-flash");
376 readfile(dirname(__FILE__
).'/../modules/geoloc/dynamap.swf');
380 $page->changeTpl('geoloc/init.tpl', NO_SKIN
);
381 header('Content-Type: text/xml');
383 if (!empty($GLOBALS['IS_XNET_SITE'])) {
384 $page->assign('background', 0xF2E9D0);
389 $page->changeTpl('geoloc/city.tpl', NO_SKIN
);
390 header('Content-Type: text/xml');
392 $only_current = Env
::v('only_current', false
)?
' AND FIND_IN_SET(\'active\', adrf.statut)' : '';
393 $it =& $this->set
->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias',
394 "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current)
395 LEFT JOIN aliases AS al ON (u.user_id = al.id
396 AND FIND_IN_SET('bestalias', al.flags))
397 INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")",
398 'adrf.cityid = ' . Env
::i('cityid'), null
, null
, 11);
399 $page->assign('users', $it);
403 if (Env
::has('debug')) {
404 $page->changeTpl('geoloc/country.tpl', SIMPLE
);
406 $page->changeTpl('geoloc/country.tpl', NO_SKIN
);
407 header('Content-Type: text/xml');
410 $mapid = Env
::has('mapid') ? Env
::i('mapid', -2) : false
;
411 list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set
, 10);
412 $page->assign('countries', $countries);
413 $page->assign('cities', $cities);
418 if (!$this->use_map()) {
419 $page->assign('request_geodesix', true
);
421 $page->assign('annu', @$this->params
['with_annu']);
422 $page->assign('protocole', @$_SERVER['HTTPS'] ?
'https' : 'http');
423 $this->set
->get('u.user_id', null
, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null
);
424 return 'include/plview.geoloc.tpl';
429 class GadgetView
implements PlView
431 public function __construct(PlSet
&$set, $data, array $params)
436 public function fields()
438 return "u.user_id AS id,
439 u.*, a.alias AS forlife," .
440 (S
::logged() ?
"q.profile_mobile AS mobile, " : "IF(q.profile_mobile_pub = 'public', q.profile_mobile, NULL) as mobile, ") .
441 "u.perms != 'pending' AS inscrit,
442 u.perms != 'pending' AS wasinscrit,
443 u.deces != 0 AS dcd, u.deces,
444 FIND_IN_SET('femme', u.flags) AS sexe,
445 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region" .
446 (S
::logged() ?
", c.contact AS contact" : '');
449 public function joins()
451 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'").")
452 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
453 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)" .
455 "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
459 public function apply(PlatalPage
&$page)
461 $page->assign_by_ref('set',
462 $this->set
->get($this->fields(), $this->joins(), null
, null
, null
, 5, 0));
465 public function args()
471 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: