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 n1 ON (u.nationalite = n1.a2)
36 LEFT JOIN geoloc_pays AS n2 ON (u.nationalite2 = n2.a2)
37 LEFT JOIN geoloc_pays AS n3 ON (u.nationalite2 = n3.a2)
38 LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut))
39 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
40 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)
41 LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = \'active\')';
43 class UserSet
extends PlSet
45 public function __construct($joins = '', $where = '')
48 parent
::__construct('auth_user_md5 AS u',
49 (!empty($GLOBALS['IS_XNET_SITE']) ?
50 'INNER JOIN groupex.membres AS gxm ON (u.user_id = gxm.uid
51 AND gxm.asso_id = ' . $globals->asso('id') . ') ' : '')
52 . 'LEFT JOIN auth_user_quick AS q USING (user_id)
53 LEFT JOIN aliases AS a ON (a.id = u.user_id AND a.type = \'a_vie\')
60 class SearchSet
extends UserSet
62 public $advanced = false
;
63 private $score = null
;
64 private $order = null
;
65 private $quick = false
;
67 public function __construct($quick = false
, $no_search = false
, $join = '', $where = '')
69 require_once dirname(__FILE__
).'/../modules/search/search.inc.php';
75 $this->quick
= $quick;
77 $this->getQuick($join, $where);
79 $this->getAdvanced($join, $where);
83 private function getQuick($join, $where)
85 require_once dirname(__FILE__
).'/../modules/search/search.inc.php';
88 Env
::kill('with_soundex');
90 $qSearch = new QuickSearch('quick');
91 $fields = new SFieldGroup(true
, array($qSearch));
92 if ($qSearch->isEmpty()) {
93 new ThrowError('Aucun critère de recherche n\'est spécifié.');
95 $this->score
= $qSearch->get_score_statement();
96 $pwhere = $fields->get_where_statement();
103 if (S
::logged() && Env
::has('nonins')) {
107 $where .= 'u.perms="pending" AND u.deces=0';
109 parent
::__construct($join . ' ' . $fields->get_select_statement(), $where);
111 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
112 'u.promo DESC, NomSortKey, prenom')));
115 private function getAdvanced($join, $where)
118 $this->advanced
= true
;
119 $fields = new SFieldGroup(true
, advancedSearchFromInput());
120 if ($fields->too_large()) {
121 new ThrowError('Recherche trop générale.');
123 parent
::__construct(@$join . ' ' . $fields->get_select_statement(),
124 @$where . ' ' . $fields->get_where_statement());
125 $this->order
= implode(',',array_filter(array($fields->get_order_statement(),
126 'promo DESC, NomSortKey, prenom')));
129 public function &get($fields, $joins, $where, $groupby, $order, $limitcount = null
, $limitfrom = null
)
132 $fields .= ', ' . $this->score
;
134 return parent
::get($fields, $joins, $where, $groupby, $order, $limitcount, $limitfrom);
138 class ArraySet
extends UserSet
140 public function __construct(array $users)
142 $where = $this->getUids($users);
144 $where = "a.alias IN ($where)";
148 parent
::__construct('', $where);
151 private function getUids(array $users)
153 $users = get_users_forlife_list($users, true
, '_silent_user_callback');
154 if (is_null($users)) {
157 return '\'' . implode('\', \'', $users) . '\'';
161 class MinificheView
extends MultipageView
163 public function __construct(PlSet
&$set, $data, array $params)
165 require_once 'applis.func.inc.php';
167 $this->entriesPerPage
= $globals->search
->per_page
;
168 if (@$params['with_score']) {
169 $this->addSortKey('score', array('-score', '-date', '-promo', 'name_sort'), 'pertinence');
171 $this->addSortKey('name', array('name_sort'), 'nom');
172 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
173 $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification');
174 parent
::__construct($set, $data, $params);
177 public function fields()
179 return "u.user_id AS id,
180 u.*, a.alias AS forlife,
181 u.perms != 'pending' AS inscrit,
182 u.perms != 'pending' AS wasinscrit,
183 u.deces != 0 AS dcd, u.deces, u.matricule_ax,
184 FIND_IN_SET('femme', u.flags) AS sexe,
185 e.entreprise, es.label AS secteur, ef.fonction_fr AS fonction,
186 IF(n1.nat='',n1.pays,n1.nat) AS nat1, n1.a2 AS iso3166_1,
187 IF(n2.nat='',n2.pays,n2.nat) AS nat2, n2.a2 AS iso3166_2,
188 IF(n3.nat='',n3.pays,n3.nat) AS nat3, n3.a2 AS iso3166_3,
189 ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
190 ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
191 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region,
192 (COUNT(em.email) > 0 OR FIND_IN_SET('googleapps', u.mail_storage) > 0) AS actif,
193 nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort" .
194 (S
::logged() ?
", c.contact AS contact" : '');
197 public function joins()
199 return "LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id".(S
::logged() ?
"" : " AND e.pub = 'public'").")
200 LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id)
201 LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id)
202 LEFT JOIN geoloc_pays AS n1 ON (u.nationalite = n1.a2)
203 LEFT JOIN geoloc_pays AS n2 ON (u.nationalite2 = n2.a2)
204 LEFT JOIN geoloc_pays AS n3 ON (u.nationalite3 = n3.a2)
205 LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0)
206 LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid)
207 LEFT JOIN applis_ins AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1)
208 LEFT JOIN applis_def AS ad1 ON (ad1.id = ai1.aid)
209 LEFT JOIN adresses AS adr ON (u.user_id = adr.uid
210 AND FIND_IN_SET('active', adr.statut)".(S
::logged() ?
"" : " AND adr.pub = 'public'").")
211 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
212 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)
213 LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active')
214 INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)" .
216 "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
220 public function templateName()
222 return 'include/plview.minifiche.tpl';
226 class MentorView
extends MultipageView
228 public function __construct(PlSet
&$set, $data, array $params)
230 $this->entriesPerPage
= 10;
231 $this->addSortKey('rand', array('RAND(' . S
::i('uid') . ')'), 'aléatoirement');
232 $this->addSortKey('name', array('name_sort'), 'nom');
233 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
234 $this->addSortKey('date_mod', array('-date', '-promo', 'name_sort'), 'dernière modification');
235 parent
::__construct($set, $data, $params);
238 public function fields()
240 return "m.uid, u.promo,
241 a.alias AS bestalias, m.expertise, mp.pid,
242 ms.secteur, ms.ss_secteur,
243 nd.display AS name_display, nd.tooltip AS name_tooltip, nd.sort AS name_sort";
246 public function joins()
248 return "INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)";
251 public function templateName()
253 return 'include/plview.referent.tpl';
257 class TrombiView
extends MultipageView
259 public function __construct(PlSet
&$set, $data, array $params)
261 $this->entriesPerPage
= 24;
262 $this->order
= explode(',', Env
::v('order', 'name_sort'));
263 if (@$params['with_score']) {
264 $this->addSortKey('score', array('-score', '-watch_last', '-promo', 'name_sort'), 'pertinence');
266 $this->addSortKey('name', array('name_sort'), 'nom');
267 $this->addSortKey('promo', array('-promo', 'name_sort'), 'promotion');
268 parent
::__construct($set, $data, $params);
271 public function fields()
273 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 ";
276 public function joins()
278 return "INNER JOIN photo AS p ON (p.uid = u.user_id)
279 INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id)";
282 public function templateName()
284 return 'include/plview.trombi.tpl';
287 public function apply(PlatalPage
&$page)
289 if (!empty($GLOBALS['IS_XNET_SITE'])) {
291 $page->assign('mainsiteurl', 'https://' . $globals->core
->secure_domain
. '/');
293 return parent
::apply($page);
297 class GeolocView
implements PlView
303 public function __construct(PlSet
&$set, $data, array $params)
305 $this->params
= $params;
310 private function use_map()
312 return is_file(dirname(__FILE__
) . '/../modules/geoloc/dynamap.swf') &&
313 is_file(dirname(__FILE__
) . '/../modules/geoloc/icon.swf');
316 public function args()
318 $args = $this->set
->args();
319 unset($args['initfile']);
320 unset($args['mapid']);
324 public function apply(PlatalPage
&$page)
326 require_once 'geoloc.inc.php';
327 require_once '../modules/search/search.inc.php';
329 switch ($this->type
) {
331 header("Content-type: application/x-shockwave-flash");
333 readfile(dirname(__FILE__
).'/../modules/geoloc/icon.swf');
337 header("Content-type: application/x-shockwave-flash");
339 readfile(dirname(__FILE__
).'/../modules/geoloc/dynamap.swf');
343 $page->changeTpl('geoloc/init.tpl', NO_SKIN
);
344 header('Content-Type: text/xml');
346 if (!empty($GLOBALS['IS_XNET_SITE'])) {
347 $page->assign('background', 0xF2E9D0);
352 $page->changeTpl('geoloc/city.tpl', NO_SKIN
);
353 header('Content-Type: text/xml');
355 $only_current = Env
::v('only_current', false
)?
' AND FIND_IN_SET(\'active\', adrf.statut)' : '';
356 $it =& $this->set
->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias',
357 "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current)
358 LEFT JOIN aliases AS al ON (u.user_id = al.id
359 AND FIND_IN_SET('bestalias', al.flags))
360 INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")",
361 'adrf.cityid = ' . Env
::i('cityid'), null
, null
, 11);
362 $page->assign('users', $it);
366 if (Env
::has('debug')) {
367 $page->changeTpl('geoloc/country.tpl', SIMPLE
);
369 $page->changeTpl('geoloc/country.tpl', NO_SKIN
);
370 header('Content-Type: text/xml');
373 $mapid = Env
::has('mapid') ? Env
::i('mapid', -2) : false
;
374 list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set
, 10);
375 $page->assign('countries', $countries);
376 $page->assign('cities', $cities);
381 if (!$this->use_map()) {
382 $page->assign('request_geodesix', true
);
384 $page->assign('annu', @$this->params
['with_annu']);
385 $page->assign('protocole', @$_SERVER['HTTPS'] ?
'https' : 'http');
386 $this->set
->get('u.user_id', null
, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null
);
387 return 'include/plview.geoloc.tpl';
392 class GadgetView
implements PlView
394 public function __construct(PlSet
&$set, $data, array $params)
399 public function fields()
401 return "u.user_id AS id,
402 u.*, a.alias AS forlife," .
403 "u.perms != 'pending' AS inscrit,
404 u.perms != 'pending' AS wasinscrit,
405 u.deces != 0 AS dcd, u.deces,
406 FIND_IN_SET('femme', u.flags) AS sexe,
407 adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region" .
408 (S
::logged() ?
", c.contact AS contact" : '');
411 public function joins()
413 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'").")
414 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
415 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)" .
417 "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S
::v('uid') . ")"
421 public function apply(PlatalPage
&$page)
423 $page->assign_by_ref('set',
424 $this->set
->get($this->fields(), $this->joins(), null
, null
, null
, 5, 0));
427 public function args()
433 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: