From a2aa843639f292ed0197ffb06edf7e19174b27e8 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Sat, 28 Jul 2007 20:05:22 +0000 Subject: [PATCH] Some uncommitted work I made before being away. -> many fixes on the geoloc behaviour -> initial work on search into contacts ChangeLog | 1 + classes/plset.php | 5 ++++- include/userset.inc.php | 23 +++++++++++------------ modules/carnet.php | 23 ++++++++++++++++++----- modules/search.php | 4 ++-- modules/search/classes.inc.php | 15 +++++++++++++-- modules/search/search.inc.php | 5 +++-- templates/include/plview.geoloc.tpl | 31 ++++++++++++++----------------- 8 files changed, 66 insertions(+), 41 deletions(-) git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1890 839d8a87-29fc-0310-9880-83ba4fa771e5 --- ChangeLog | 1 + classes/plset.php | 5 ++++- include/userset.inc.php | 23 +++++++++++------------ modules/carnet.php | 23 ++++++++++++++++++----- modules/search.php | 4 ++-- modules/search/classes.inc.php | 15 +++++++++++++-- modules/search/search.inc.php | 5 +++-- templates/include/plview.geoloc.tpl | 31 ++++++++++++++----------------- 8 files changed, 66 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b18abb..fb34772 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,7 @@ Bug/Wish: - Fix GoogleMaps links -FRU - #663: Link to Xnet's map from the "My groups" page -FRU - #689: Edit my profile from Xnet -FRU + - #692: Layout of the profile -FRU * Xnet: - #694: Color of 'Promotion' groups -ALK diff --git a/classes/plset.php b/classes/plset.php index 83322a6..576e864 100644 --- a/classes/plset.php +++ b/classes/plset.php @@ -96,7 +96,7 @@ class PlSet protected function encodeArgs(array $args, $encode = false) { $qs = '?'; - $sep = $encode ? '&' : '&'; + $sep = '&'; foreach ($args as $k=>$v) { if (!$encode) { $k = urlencode($k); @@ -161,6 +161,9 @@ class PlSet return false; } $args = $view->args(); + if (!isset($args['rechercher'])) { + $args['rechercher'] = 'Chercher'; + } $page->changeTpl('core/plset.tpl'); $page->assign('plset_base', $baseurl); $page->assign('plset_mods', $this->mods); diff --git a/include/userset.inc.php b/include/userset.inc.php index 895f489..a4e6dc7 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -62,7 +62,7 @@ class SearchSet extends UserSet private $order = null; private $quick = false; - public function __construct($quick = false, $no_search = false) + public function __construct($quick = false, $no_search = false, $join = '', $where = '') { require_once dirname(__FILE__).'/../modules/search/search.inc.php'; @@ -72,13 +72,13 @@ class SearchSet extends UserSet $this->quick = $quick; if ($quick) { - $this->getQuick(); + $this->getQuick($join, $where); } else { - $this->getAdvanced(); + $this->getAdvanced($join, $where); } } - private function getQuick() + private function getQuick($join, $where) { require_once dirname(__FILE__).'/../modules/search/search.inc.php'; global $globals; @@ -91,8 +91,8 @@ class SearchSet extends UserSet new ThrowError('Recherche trop générale.'); } $this->score = $qSearch->get_score_statement(); - parent::__construct("{$fields->get_select_statement()}", - $fields->get_where_statement() . + parent::__construct($join . ' ' . $fields->get_select_statement(), + $where . ' ' . $fields->get_where_statement() . (S::logged() && Env::has('nonins') ? ' AND u.perms="pending" AND u.deces=0' : '')); $this->order = implode(',',array_filter(array($fields->get_order_statement(), @@ -107,8 +107,8 @@ class SearchSet extends UserSet if ($fields->too_large()) { new ThrowError('Recherche trop générale.'); } - parent::__construct($fields->get_select_statement(), - $fields->get_where_statement()); + parent::__construct($join . ' ' . $fields->get_select_statement(), + $where . ' ' . $fields->get_where_statement()); $this->order = implode(',',array_filter(array($fields->get_order_statement(), 'promo DESC, NomSortKey, prenom'))); } @@ -326,8 +326,9 @@ class GeolocView implements PlView $page->changeTpl('geoloc/city.tpl', NO_SKIN); header('Content-Type: text/xml'); header('Pragma:'); + $only_current = Env::v('only_current', false)? ' AND FIND_IN_SET(\'active\', adrf.statut)' : ''; $it =& $this->set->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias', - "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id) + "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id $only_current) LEFT JOIN aliases AS al ON (u.user_id = al.id AND FIND_IN_SET('bestalias', al.flags)) INNER JOIN adresses AS avg ON (" . getadr_join('avg') . ")", @@ -354,9 +355,7 @@ class GeolocView implements PlView if (!$this->use_map()) { $page->assign('request_geodesix', true); } - if (!empty($GLOBALS['IS_XNET_SITE'])) { - $page->assign('no_annu', true); - } + $page->assign('annu', @$this->params['with_annu']); $page->assign('protocole', @$_SERVER['HTTPS'] ? 'https' : 'http'); $this->set->get('u.user_id', null, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null); return 'include/plview.geoloc.tpl'; diff --git a/modules/carnet.php b/modules/carnet.php index 24bdaaa..108ebdb 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -183,7 +183,7 @@ class CarnetModule extends PLModule return Array($total, $list); } - function handler_contacts(&$page, $action = null, $subaction = null) + function handler_contacts(&$page, $action = null, $subaction = null, $ssaction = null) { $page->assign('xorg_title','Polytechnique.org - Mes contacts'); $this->_add_rss_link($page); @@ -228,12 +228,25 @@ class CarnetModule extends PLModule } } - $view = new UserSet("INNER JOIN contacts AS c2 ON (u.user_id = c2.contact)", " c2.uid = $uid "); + $search = false; + if ($action == 'search') { + $action = $subaction; + $subaction = $ssaction; + $search = true; + } + if ($search && trim(Env::v('quick'))) { + require_once 'userset.inc.php'; + $base = 'carnet/contacts/search'; + $view = new SearchSet(true, false, "INNER JOIN contacts AS c2 ON (u.user_id = c2.contact)", " c2.uid = $uid AND "); + } else { + $base = 'carnet/contacts'; + $view = new UserSet("INNER JOIN contacts AS c2 ON (u.user_id = c2.contact)", " c2.uid = $uid "); + } $view->addMod('minifiche', 'Mini-Fiches', true); $view->addMod('trombi', 'Trombinoscope', false, array('with_admin' => false, 'with_promo' => true)); - $view->addMod('geoloc', 'Planisphère'); - $view->apply('carnet/contacts', $page, $action, $subaction); - if ($action != 'geoloc' || !$subaction) { + $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'carnet/contacts/search')); + $view->apply($base, $page, $action, $subaction); + if ($action != 'geoloc' || ($search && !$ssaction) || (!$search && !$subaction)) { $page->changeTpl('carnet/mescontacts.tpl'); } } diff --git a/modules/search.php b/modules/search.php index 9f26a73..b4c4cca 100644 --- a/modules/search.php +++ b/modules/search.php @@ -124,7 +124,7 @@ class SearchModule extends PLModule $view->addMod('minifiche', 'Minifiches', true, array('with_score' => true)); if (S::logged() && !Env::i('nonins')) { $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true, 'with_score' => true)); - $view->addMod('geoloc', 'Planisphère'); + $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'search/adv')); } $view->apply('search', $page, $action, $subaction); @@ -163,7 +163,7 @@ class SearchModule extends PLModule $view = new SearchSet(false, $action == 'geoloc' && substr($subaction, -3) == 'swf'); $view->addMod('minifiche', 'Minifiches', true); $view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true)); - $view->addMod('geoloc', 'Planisphère'); + $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'search/adv')); $view->apply('search/adv', $page, $action, $subaction); if ($subaction) { diff --git a/modules/search/classes.inc.php b/modules/search/classes.inc.php index 63da70a..7664bb0 100644 --- a/modules/search/classes.inc.php +++ b/modules/search/classes.inc.php @@ -78,11 +78,20 @@ else */ class ThrowError { + public static $throwHook = array('ThrowError', 'defaultHandler'); + /** constuctor * @param $explain string the error (in natural language) */ public function __construct($explain) { + call_user_func(ThrowError::$throwHook, $explain); + } + + /** defaut error handler + */ + private static function defaultHandler($explain) + { global $page, $globals; $page->changeTpl('search/index.tpl'); $page->assign('xorg_title','Polytechnique.org - Annuaire'); @@ -477,8 +486,10 @@ class MapSField extends RefSField $this->mapId = Env::v($_fieldFormName, ''); else $this->mapId = $_mapId; + $this->value = $this->mapId; $this->RefSField($_fieldFormName, $_fieldDbName, $_refTable, $_refAlias, $_refCondition, true, false); } + function get_select_statement() { if ($this->mapId === '') return false; @@ -737,8 +748,8 @@ class SFieldGroup function too_large() { $b = true; - for ($i=0; $b && $ifields); $i++) { - $b &= $this->fields[$i]->too_large(); + for ($i=0 ; $b && $ifields) ; $i++) { + $b = $b && $this->fields[$i]->too_large(); } return $b; } diff --git a/modules/search/search.inc.php b/modules/search/search.inc.php index 39e0f8b..8334c36 100644 --- a/modules/search/search.inc.php +++ b/modules/search/search.inc.php @@ -46,7 +46,8 @@ function advancedSearchFromInput() $cityIdField = new RefSField('cityid',array('av.cityid'),'adresses','av',getadr_join('av')); $countryField = new RefSField('country',array('ap.country'),'adresses','ap',getadr_join('ap')); $regionField = new RefSField('region',array('ar.region'),'adresses','ar',getadr_join('ar')); - + $mapField = new MapSField('mapid', array('sgcim.map_id'), array('adresses','geoloc_city_in_maps'), array('amp','sgcim'), array(getadr_join('amp'), 'amp.cityid = sgcim.city_id')); + $entrepriseField = new RefSField('entreprise',array('ee.entreprise'),'entreprises','ee','u.user_id=ee.uid',false); $posteField = new RefSField('poste',array('ep.poste'),'entreprises','ep','u.user_id=ep.uid', false); $fonctionField = new RefSField('fonction',array('en.fonction'),'entreprises','en','u.user_id=en.uid'); @@ -65,7 +66,7 @@ function advancedSearchFromInput() return array( $nameField, $firstnameField, $nicknameField, $promo1Field, $promo2Field, $womanField, $subscriberField, $aliveField, - $townField, $countryField, $regionField, $entrepriseField, + $townField, $countryField, $regionField, $mapField, $entrepriseField, $posteField, $secteurField, $cvField, $natField, $binetField, $groupexField, $sectionField, $schoolField, $diplomaField, $freeField, $fonctionField, $cityIdField); diff --git a/templates/include/plview.geoloc.tpl b/templates/include/plview.geoloc.tpl index 593598c..27b11f1 100644 --- a/templates/include/plview.geoloc.tpl +++ b/templates/include/plview.geoloc.tpl @@ -20,41 +20,33 @@ {* *} {**************************************************************************} - +//]]> {if !$request_geodesix} @@ -93,6 +85,11 @@ function searchMapId(f) pluginspage="{$protocole}://www.macromedia.com/go/getflashplayer"/>

+ {if $annu} +

+ Lister les X présents sur cette carte +

+ {/if}

Carte fournie gracieusement par Geodesix.

{else}

Le moteur de carte n'a pas été installé sur cette version de plat/al. Veuillez contacter Geodesix.

-- 2.1.4