From: x2003bruneau
Date: Wed, 15 Aug 2007 14:55:29 +0000 (+0000)
Subject: Closes #682: Add search in contact list
X-Git-Tag: xorg/0.9.15~211
X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=3b2f9d11e87daee8b59a2e0ab661a448160a4e51;p=platal.git
Closes #682: Add search in contact list
Fix issues with string encoding in backtrace
ChangeLog | 3 +++
classes/plbacktrace.php | 13 +++++++++----
classes/plset.php | 1 -
htdocs/css/default.css | 2 +-
htdocs/css/keynote.css | 2 +-
include/userset.inc.php | 17 ++++++++++++++---
modules/carnet.php | 11 ++++++++++-
modules/search/classes.inc.php | 1 +
templates/carnet/mescontacts.tpl | 15 ++++++++++++++-
templates/core/plset.tpl | 2 +-
templates/skin/common.title.header.tpl | 2 +-
11 files changed, 55 insertions(+), 14 deletions(-)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1913 839d8a87-29fc-0310-9880-83ba4fa771e5
---
diff --git a/ChangeLog b/ChangeLog
index 3f33f58..a0a1856 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,9 @@ New:
Bug/Wish:
+ * Carnet:
+ - #682: Can quick search in contact list -FRU
+
* Core:
- #674: MiniWiki xhtml validation -FRU
- #678: PlUpload filename detection -FRU
diff --git a/classes/plbacktrace.php b/classes/plbacktrace.php
index 2f18f7a..e15a304 100644
--- a/classes/plbacktrace.php
+++ b/classes/plbacktrace.php
@@ -39,7 +39,11 @@ class PlBacktrace
private function fixCharset($action)
{
- return is_utf8($action) ? $action : utf8_encode($action);
+ if (!is_string($action)) {
+ return $action;
+ } else {
+ return is_utf8($action) ? $action : utf8_encode($action);
+ }
}
private function add(array &$entry, $sizef = 'rows', $timef = 'exectime', $errorf = 'error')
@@ -52,12 +56,12 @@ class PlBacktrace
unset($entry[$timef]);
$trace['rows'] = @$entry[$sizef];
unset($entry[$sizef]);
- $trace['error'] = @$entry[$errorf];
+ $trace['error'] = $this->fixCharset(@$entry[$errorf]);
unset($entry[$errorf]);
if ($trace['error']) {
$this->error = true;
}
- $trace['data'] = array($entry);
+ $trace['data'] = array($this->fixCharset($entry));
$this->traces[] =& $trace;
}
@@ -90,7 +94,8 @@ class PlBacktrace
{
$trace =& $this->traces[count($this->traces) - 1];
$trace['rows'] = $rows;
- $trace['error'] = $error;
+ $trace['error'] = $this->fixCharset($error);
+ array_walk_recursive($userdata, array($this, 'fixCharset'));
$trace['data'] = $userdata;
if ($trace['error']) {
$this->error = true;
diff --git a/classes/plset.php b/classes/plset.php
index 576e864..8cf1ba2 100644
--- a/classes/plset.php
+++ b/classes/plset.php
@@ -116,7 +116,6 @@ class PlSet
$limitcount = "LIMIT $limitcount";
}
$joins = $this->joins . ' ' . $joins;
- $where = $where;
if (trim($this->where)) {
if (trim($where)) {
$where .= ' AND ';
diff --git a/htdocs/css/default.css b/htdocs/css/default.css
index 19d5ab2..2957cc6 100644
--- a/htdocs/css/default.css
+++ b/htdocs/css/default.css
@@ -609,7 +609,7 @@ div.adresse strong {
vertical-align: top;
}
-#quick_search {
+.quick_search {
color: gray;
text-align: right;
}
diff --git a/htdocs/css/keynote.css b/htdocs/css/keynote.css
index ce1af92..415af9a 100644
--- a/htdocs/css/keynote.css
+++ b/htdocs/css/keynote.css
@@ -625,7 +625,7 @@ div.adresse {
font-size: 95%;
}
-#quick_search {
+.quick_search {
color: gray;
background: #fff;
text-align: right;
diff --git a/include/userset.inc.php b/include/userset.inc.php
index a4e6dc7..7595292 100644
--- a/include/userset.inc.php
+++ b/include/userset.inc.php
@@ -91,9 +91,20 @@ class SearchSet extends UserSet
new ThrowError('Recherche trop générale.');
}
$this->score = $qSearch->get_score_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' : ''));
+ $pwhere = $fields->get_where_statement();
+ if (trim($pwhere)) {
+ if (trim($where)) {
+ $where .= ' AND ';
+ }
+ $where .= $pwhere;
+ }
+ if (S::logged() && Env::has('nonins')) {
+ if (trim($where)) {
+ $where .= ' AND ';
+ }
+ $where .= 'u.perms="pending" AND u.deces=0';
+ }
+ parent::__construct($join . ' ' . $fields->get_select_statement(), $where);
$this->order = implode(',',array_filter(array($fields->get_order_statement(),
'u.promo DESC, NomSortKey, prenom')));
diff --git a/modules/carnet.php b/modules/carnet.php
index 108ebdb..9c9172b 100644
--- a/modules/carnet.php
+++ b/modules/carnet.php
@@ -183,6 +183,12 @@ class CarnetModule extends PLModule
return Array($total, $list);
}
+ function searchErrorHandler($explain) {
+ global $page;
+ $page->trig($explain);
+ $this->handler_contacts($page);
+ }
+
function handler_contacts(&$page, $action = null, $subaction = null, $ssaction = null)
{
$page->assign('xorg_title','Polytechnique.org - Mes contacts');
@@ -237,7 +243,10 @@ class CarnetModule extends PLModule
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 ");
+
+ require_once(dirname(__FILE__) . '/search/classes.inc.php');
+ ThrowError::$throwHook = array($this, 'searchErrorHandler');
+ $view = new SearchSet(true, false, "INNER JOIN contacts AS c2 ON (u.user_id = c2.contact)", "c2.uid = $uid");
} else {
$base = 'carnet/contacts';
$view = new UserSet("INNER JOIN contacts AS c2 ON (u.user_id = c2.contact)", " c2.uid = $uid ");
diff --git a/modules/search/classes.inc.php b/modules/search/classes.inc.php
index 7664bb0..29d7163 100644
--- a/modules/search/classes.inc.php
+++ b/modules/search/classes.inc.php
@@ -305,6 +305,7 @@ class QuickSearch extends SField
$ip = XDB::escape($this->ip);
$where[] = "( ls.ip = $ip OR ls.forward_ip = $ip )";
}
+
return join(" AND ", $where);
}
diff --git a/templates/carnet/mescontacts.tpl b/templates/carnet/mescontacts.tpl
index 870fe42..241e7b9 100644
--- a/templates/carnet/mescontacts.tpl
+++ b/templates/carnet/mescontacts.tpl
@@ -39,7 +39,7 @@
il te suffit de cliquer sur l'icône {icon name=add} en face de son nom dans les résultats !
-{if $plset_count}
+{if $plset_count || $smarty.request.quick}
Pour récupérer ta liste de contacts dans un PDF imprimable :
(attention, les photos font beaucoup grossir les fichiers !)
@@ -72,6 +72,19 @@ Pour récupérer ta liste de contacts dans un PDF imprimable :
+
+
+ Tu peux faire une recherche sur tes contacts :
+
+
{include file="core/plset.tpl"}
{/if}
diff --git a/templates/core/plset.tpl b/templates/core/plset.tpl
index 009aa23..511fbca 100644
--- a/templates/core/plset.tpl
+++ b/templates/core/plset.tpl
@@ -20,7 +20,7 @@
{* *}
{**************************************************************************}
-
+
{if !$plset_count}
Aucune entrée
diff --git a/templates/skin/common.title.header.tpl b/templates/skin/common.title.header.tpl
index a4c73c4..fd4585d 100644
--- a/templates/skin/common.title.header.tpl
+++ b/templates/skin/common.title.header.tpl
@@ -32,7 +32,7 @@
{insert name="getNbIns"} polytechniciens sur le web
{insert name="getNbNotifs"}