X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fsearch.php;h=5b188d4f5773e1519cbad52c1438daa6bf118d8d;hb=9ed396c06e661970436bcd81ecc4d758fa647ce0;hp=1fcd390bf1c48f00223ab1c06e4391676341565f;hpb=08cce2ff528b38bde27cdec6d6bc28d6af4a42d4;p=platal.git diff --git a/modules/search.php b/modules/search.php index 1fcd390..5b188d4 100644 --- a/modules/search.php +++ b/modules/search.php @@ -1,6 +1,6 @@ $this->make_hook('quick', AUTH_PUBLIC), 'search/adv' => $this->make_hook('advanced', AUTH_COOKIE), + 'search/ajax/region' => $this->make_hook('region', AUTH_COOKIE, 'user', NO_AUTH), + 'search/ajax/grade' => $this->make_hook('grade', AUTH_COOKIE, 'user', NO_AUTH), + 'advanced_search.php' => $this->make_hook('redir_advanced', AUTH_PUBLIC), ); } + function handler_redir_advanced(&$page, $mode = null) + { + pl_redirect('search/adv'); + exit; + } + + function on_subscribe($forlife, $uid, $promo, $pass) + { + require_once 'user.func.inc.php'; + user_reindex($uid); + } + function get_quick($offset, $limit, $order) { global $globals; @@ -36,7 +51,7 @@ class SearchModule extends PLModule $fields = new SFieldGroup(true, array($qSearch)); if ($qSearch->isempty()) { - new ThrowError('Recherche trop générale.'); + new ThrowError('Recherche trop générale.'); } $sql = 'SELECT SQL_CALC_FOUND_ROWS @@ -49,13 +64,13 @@ class SearchModule extends PLModule '.$fields->get_select_statement().' LEFT JOIN auth_user_quick AS q ON (u.user_id = q.user_id) LEFT JOIN aliases AS a ON (u.user_id = a.id AND a.type="a_vie") - LEFT JOIN contacts AS c ON (c.uid='.Session::getInt('uid').' + LEFT JOIN contacts AS c ON (c.uid='.S::i('uid', -1).' AND c.contact=u.user_id) LEFT JOIN watch_nonins AS w ON (w.ni_id=u.user_id - AND w.uid='.Session::getInt('uid').') + AND w.uid='.S::i('uid', -1).') '.$globals->search->result_where_statement.' WHERE '.$fields->get_where_statement() - .(logged() && Env::has('nonins') ? ' AND u.perms="pending" AND u.deces=0' : '') + .(S::logged() && Env::has('nonins') ? ' AND u.perms="pending" AND u.deces=0' : '') .' GROUP BY u.user_id ORDER BY '.($order?($order.', '):'') @@ -71,7 +86,7 @@ class SearchModule extends PLModule function form_prepare() { - global $page,$globals; + global $page; $page->assign('formulaire',1); $page->assign('choix_nats', @@ -90,21 +105,30 @@ class SearchModule extends PLModule XDB::iterator('SELECT id,text FROM applis_def ORDER BY text')); $page->assign('choix_secteurs', XDB::iterator('SELECT id,label FROM emploi_secteur ORDER BY label')); + $this->get_diplomas(); + } - if (Env::has('school')) { - $sql = 'SELECT type FROM applis_def WHERE id='.Env::getInt('school'); + function get_diplomas($school = null) + { + if (is_null($school) && Env::has('school')) { + $school = Env::i('school'); + } + + if (!is_null($school)) { + $sql = 'SELECT type FROM applis_def WHERE id=' . $school; } else { $sql = 'DESCRIBE applis_def type'; } $res = XDB::query($sql); $row = $res->fetchOneRow(); - if (Env::has('school')) { + if (!is_null($school)) { $types = $row[0]; } else { $types = explode('(',$row[1]); $types = str_replace("'","",substr($types[1],0,-1)); } + global $page; $page->assign('choix_diplomas', explode(',',$types)); } @@ -113,7 +137,7 @@ class SearchModule extends PLModule $fields = new SFieldGroup(true, advancedSearchFromInput()); if ($fields->too_large()) { $this->form_prepare(); - new ThrowError('Recherche trop générale.'); + new ThrowError('Recherche trop générale.'); } global $globals, $page; @@ -133,12 +157,13 @@ class SearchModule extends PLModule '.$fields->get_select_statement().' '.(Env::has('only_referent') ? ' INNER JOIN mentor AS m ON (m.uid = u.user_id)' : '').' LEFT JOIN aliases AS a ON (u.user_id = a.id AND a.type="a_vie") - LEFT JOIN contacts AS c ON (c.uid='.Session::getInt('uid').' + LEFT JOIN contacts AS c ON (c.uid='.S::v('uid').' AND c.contact=u.user_id) LEFT JOIN watch_nonins AS w ON (w.ni_id=u.user_id - AND w.uid='.Session::getInt('uid').') + AND w.uid='.S::v('uid').') '.$globals->search->result_where_statement." $where + GROUP BY u.user_id ORDER BY ".($order?($order.', '):'') .implode(',',array_filter(array($fields->get_order_statement(), 'promo DESC, NomSortKey, prenom'))).' @@ -153,7 +178,7 @@ class SearchModule extends PLModule { global $globals; - require_once 'search.inc.php'; + require_once dirname(__FILE__).'/search/search.inc.php'; $page->changeTpl('search/index.tpl'); @@ -172,12 +197,12 @@ class SearchModule extends PLModule $nb_tot = $search->show(); - if (!logged() && $nb_tot > $globals->search->public_max) { - new ThrowError('Votre recherche a généré trop de résultats pour un affichage public.'); + if (!S::logged() && $nb_tot > $globals->search->public_max) { + new ThrowError('Votre recherche a généré trop de résultats pour un affichage public.'); } elseif ($nb_tot > $globals->search->private_max) { - new ThrowError('Recherche trop générale'); + new ThrowError('Recherche trop générale'); } elseif (empty($nb_tot)) { - new ThrowError('il n\'existe personne correspondant à ces critères dans la base !'); + new ThrowError('il n\'existe personne correspondant à ces critères dans la base !'); } } else { $page->assign('formulaire',1); @@ -190,20 +215,15 @@ class SearchModule extends PLModule { global $globals; - require_once 'search.inc.php' ; + require_once dirname(__FILE__).'/search/search.inc.php'; require_once 'applis.func.inc.php'; require_once 'geoloc.inc.php'; - $page->changeTpl('search/index.tpl'); - - if ($mode == 'mini') { - $page->assign('simple', true); - } + $page->changeTpl('search/index.tpl', $mode == 'mini' ? SIMPLE : SKINNED); $page->assign('advanced',1); $page->assign('public_directory',0); - $page->assign('use_map', $globals->geoloc->use_map()); if (!Env::has('rechercher')) { $this->form_prepare(); @@ -221,13 +241,32 @@ class SearchModule extends PLModule if ($nb_tot > $globals->search->private_max) { $this->form_prepare(); - new ThrowError('Recherche trop générale'); + new ThrowError('Recherche trop générale'); } } + $page->addJsLink('ajax.js'); $page->register_modifier('display_lines', 'display_lines'); } + + function handler_region(&$page, $country = null) + { + header('Content-Type: text/html; charset="UTF-8"'); + require_once("geoloc.inc.php"); + $page->ChangeTpl('search/adv.region.form.tpl', NO_SKIN); + $page->assign('region', ""); + $page->assign('country', $country); + } + + function handler_grade(&$page, $school = null) + { + header('Content-Type: text/html; charset="UTF-8"'); + $page->ChangeTpl('search/adv.grade.form.tpl', NO_SKIN); + $page->assign('grade', ''); + $this->get_diplomas($school); + } } +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>