From 481853d2cc44a4bf6c540e72c741ff453305a925 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 4 Sep 2011 17:35:06 -0700 Subject: [PATCH] saved searches on network page --- boot.php | 4 +-- database.sql | 8 ++++++ include/group.php | 2 +- include/text.php | 4 ++- mod/network.php | 46 ++++++++++++++++++++++++++++++- update.php | 14 ++++++++-- view/theme/duepuntozero/style.css | 18 ++++++++++++ view/theme/loozah/style.css | 19 +++++++++++++ 8 files changed, 108 insertions(+), 7 deletions(-) diff --git a/boot.php b/boot.php index f3b6af34e..7534046f2 100644 --- a/boot.php +++ b/boot.php @@ -7,9 +7,9 @@ require_once('include/text.php'); require_once("include/pgettext.php"); -define ( 'FRIENDIKA_VERSION', '2.2.1092' ); +define ( 'FRIENDIKA_VERSION', '2.2.1093' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); -define ( 'DB_UPDATE_VERSION', 1085 ); +define ( 'DB_UPDATE_VERSION', 1086 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index 432ce7693..343d4c497 100644 --- a/database.sql +++ b/database.sql @@ -613,3 +613,11 @@ CREATE TABLE IF NOT EXISTS `deliverq` ( `item` INT NOT NULL , `contact` INT NOT NULL ) ENGINE = MyISAM DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `search` ( +`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , +`uid` INT NOT NULL , +`term` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, +INDEX ( `uid` ), +INDEX ( `term` ) +) ENGINE = MyISAM DEFAULT CHARSET=utf8; diff --git a/include/group.php b/include/group.php index cd89739e1..8798adf5a 100644 --- a/include/group.php +++ b/include/group.php @@ -170,7 +170,7 @@ EOT; $selected = (($group_id == $rr['id']) ? ' class="group-selected" ' : ''); $o .= ' \r\n"; diff --git a/include/text.php b/include/text.php index 66447069e..e3d984a1f 100644 --- a/include/text.php +++ b/include/text.php @@ -602,12 +602,14 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) { if(! function_exists('search')) { -function search($s,$id='search-box',$url='/search') { +function search($s,$id='search-box',$url='/search',$save = false) { $a = get_app(); $o = '
'; $o .= '
'; $o .= ''; $o .= ''; + if($save) + $o .= ''; $o .= '
'; return $o; }} diff --git a/mod/network.php b/mod/network.php index 54fb2a0a4..663814ab7 100644 --- a/mod/network.php +++ b/mod/network.php @@ -16,8 +16,26 @@ function network_init(&$a) { $search = ((x($_GET,'search')) ? escape_tags($_GET['search']) : ''); $srchurl = '/network' . ((x($_GET,'cid')) ? '?cid=' . $_GET['cid'] : '') . ((x($_GET,'star')) ? '?star=' . $_GET['star'] : ''); + if(x($_GET,'save')) { + $r = q("select * from `search` where `uid` = %d and `term` = '%s' limit 1", + intval(local_user()), + dbesc($search) + ); + if(! count($r)) { + q("insert into `search` ( `uid`,`term` ) values ( %d, '%s') ", + intval(local_user()), + dbesc($search) + ); + } + } + if(x($_GET,'remove')) { + q("delete from `search` where `uid` = %d and `term` = '%s' limit 1", + intval(local_user()), + dbesc($search) + ); + } - $a->page['aside'] .= search($search,'netsearch-box',$srchurl); + $a->page['aside'] .= search($search,'netsearch-box',$srchurl,true); $a->page['aside'] .= ''; $a->page['aside'] .= group_side('network','network',true,$group_id); + + $a->page['aside'] .= saved_searches(); + } +function saved_searches() { + + $o = ''; + + $r = q("select `term` from `search` WHERE `uid` = %d", + intval(local_user()) + ); + + if(count($r)) { + $o .= '

' . t('Saved Searches') . '

' . "\r\n"; + $o .= '
' . "\r\n"; + } + + return $o; + +} + + + function network_content(&$a, $update = 0) { diff --git a/update.php b/update.php index 80761cce4..3d7b31813 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@