From 65542460456a13b8619c1175ed8a5b0d9a1acc83 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 18 Jan 2013 16:01:14 -0800 Subject: add versioning info to basic identity export, create skeleton function for import --- include/identity.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ version.inc | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/include/identity.php b/include/identity.php index 94de192c6..a66929b63 100644 --- a/include/identity.php +++ b/include/identity.php @@ -201,6 +201,9 @@ function identity_basic_export($channel_id) { */ $ret = array(); + + $ret['compatibility'] = array('project' => FRIENDICA_PLATFORM, 'version' => FRIENDICA_VERSION, 'database' => DB_UPDATE_VERSION); + $r = q("select * from channel where channel_id = %d limit 1", intval($channel_id) ); @@ -240,4 +243,49 @@ function identity_basic_export($channel_id) { +function identity_basic_import($arr, $seize_primary = false) { + + $ret = array('result' => false ); + + if($arr['channel']) { + // import channel + + // create a new xchan (if necessary) + + // create a new hubloc and seize control if applicable + + + } + if($arr['profile']) { + // FIXME - change profile assignment to a hash instead of an id we have to fix + + + } + + if($arr['xchan']) { + + // import any xchan and hubloc which are not yet available on this site + // Unset primary for all other hubloc on our own record if $seize_primary + + + } + + if($arr['abook']) { + // import the abook entries + + + } + + + if($seize_primary) { + + // send a refresh message to all our friends, telling them we've moved + + } + + + $ret['result'] = true ; + return $ret; + +} \ No newline at end of file diff --git a/version.inc b/version.inc index f7f909959..290052448 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2013-01-16.202 +2013-01-18.204 -- cgit v1.2.3 From af5666b791c10aaee68c82009c18e4b55a373937 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 18 Jan 2013 18:03:15 -0800 Subject: unescaped apostrophe in single quoted string --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index f4c48dd3d..63c7325ea 100644 --- a/boot.php +++ b/boot.php @@ -1258,7 +1258,7 @@ function profile_load(&$a, $nickname, $profile = 0) { require_once('include/permissions.php'); if(! perm_is_allowed($user[0]['channel_id'],$observer['xchan_hash'],'view_profile')) { // permission denied - notice( t(' Sorry, you don't have the permission to view this profile. ') . EOL); + notice( t(' Sorry, you don\'t have the permission to view this profile. ') . EOL); return; } -- cgit v1.2.3 From a168c628a2d1fd30bb5138fc7d0101963c4c5139 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 18 Jan 2013 19:00:41 -0800 Subject: directory client mode --- mod/directory.php | 205 ++++++++++++++++++++++++++---------------------------- mod/dirsearch.php | 1 - 2 files changed, 98 insertions(+), 108 deletions(-) diff --git a/mod/directory.php b/mod/directory.php index c9332f447..550e60522 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -38,148 +38,139 @@ function directory_content(&$a) { $dirmode = intval(get_config('system','directory_mode')); -// if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) { -// $localdir = true; -// return; -// } - -// FIXME -$localdir = true; - - - if(! $localdir) { + if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) { + $url = z_root() . '/dirsearch'; + } + if(! $url) { $directory = find_upstream_directory($dirmode); if($directory) { $url = $directory['url']; } else { - $url = DIRECTORY_FALLBACK_MASTER . '/post'; + $url = DIRECTORY_FALLBACK_MASTER . '/dirsearch'; } } - - - if($localdir) { + if($url) { + $query = $url . ' ?f=' ; if($search) - $search = dbesc($search); - $sql_extra = ((strlen($search)) ? " AND MATCH ( xchan_name, xchan_addr, xprof_desc, xprof_locale, xprof_region, xprof_country, xprof_gender, xprof_marital ) AGAINST ('$search' IN BOOLEAN MODE) " : ""); + $query .= '$name=' . urlencode($search); - // group_concat(xtag_term separator ', ') as tags - $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash $sql_extra"); - if($r) - $a->set_pager_total($r[0]['total']); + } + if($a->pager['page'] != 1) + $query .= '&p=' . $a->pager['page']; - $order = " ORDER BY `xchan_name` ASC "; + $x = z_fetch_url($query); + if($x['success']) { + $t = 0; + $j = json_decode($x['body'],true); + if($j && $j['results']) { - $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash $sql_extra $order LIMIT %d , %d ", - intval($a->pager['start']), - intval($a->pager['itemspage']) - ); + $entries = array(); + $photo = 'thumb'; - if($r) { + foreach($j['results'] as $rr) { - $entries = array(); - $photo = 'thumb'; - foreach($r as $rr) { - $profile_link = chanlink_hash($rr['xchan_hash']); + $profile_link = chanlink_url($rr['url']); - $pdesc = (($rr['xprof_desc']) ? $rr['xprof_desc'] . '
' : ''); - - $details = ''; - if(strlen($rr['xprof_locale'])) - $details .= $rr['xprof_locale']; - if(strlen($rr['xprof_region'])) { - if(strlen($rr['xprof_locale'])) - $details .= ', '; - $details .= $rr['xprof_region']; - } - if(strlen($rr['xprof_country'])) { - if(strlen($details)) - $details .= ', '; - $details .= $rr['xprof_country']; - } - if(strlen($rr['xprof_dob'])) { - if(($years = age($rr['xprof_dob'],'UTC','')) != 0) - $details .= '
' . t('Age: ') . $years ; - } - if(strlen($rr['xprof_gender'])) - $details .= '
' . t('Gender: ') . $rr['xprof_gender']; - - $page_type = ''; - - $profile = $rr; - - if ((x($profile,'xprof_locale') == 1) - || (x($profile,'xprof_region') == 1) - || (x($profile,'xprof_postcode') == 1) - || (x($profile,'xprof_country') == 1)) - $location = t('Location:'); + $pdesc = (($rr['description']) ? $rr['description'] . '
' : ''); + + $details = ''; + if(strlen($rr['locale'])) + $details .= $rr['locale']; + if(strlen($rr['region'])) { + if(strlen($rr['locale'])) + $details .= ', '; + $details .= $rr['region']; + } + if(strlen($rr['country'])) { + if(strlen($details)) + $details .= ', '; + $details .= $rr['country']; + } + if(strlen($rr['birthday'])) { + if(($years = age($rr['birthday'],'UTC','')) != 0) + $details .= '
' . t('Age: ') . $years ; + } + if(strlen($rr['gender'])) + $details .= '
' . t('Gender: ') . $rr['gender']; + + $page_type = ''; + + $profile = $rr; + + if ((x($profile,'locale') == 1) + || (x($profile,'region') == 1) + || (x($profile,'postcode') == 1) + || (x($profile,'country') == 1)) + $location = t('Location:'); + + $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False); + + $marital = ((x($profile,'marital') == 1) ? t('Status:') : False); + + $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False); - $gender = ((x($profile,'xprof_gender') == 1) ? t('Gender:') : False); + $about = ((x($profile,'about') == 1) ? t('About:') : False); + - $marital = ((x($profile,'marital') == 1) ? t('Status:') : False); + $entry = array( + 'id' => ++$t, + 'profile_link' => $profile_link, + 'photo' => $rr['photo'], + 'alttext' => $rr['name'] . ' ' . $rr['address'], + 'name' => $rr['name'], + 'details' => $pdesc . $details, + 'profile' => $profile, + 'location' => $location, + 'gender' => $gender, + 'pdesc' => $pdesc, + 'marital' => $marital, + 'homepage' => $homepage, + 'about' => $about, - $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False); + ); - $about = ((x($profile,'about') == 1) ? t('About:') : False); - - $t = 0; - - $entry = array( - 'id' => ++$t, - 'profile_link' => $profile_link, - 'photo' => $rr[xchan_photo_m], - 'alttext' => $rr['xchan_name'], - 'name' => $rr['xchan_name'], - 'details' => $pdesc . $details, - 'profile' => $profile, - 'location' => $location, - 'gender' => $gender, - 'pdesc' => $pdesc, - 'marital' => $marital, - 'homepage' => $homepage, - 'about' => $about, - - ); - - $arr = array('contact' => $rr, 'entry' => $entry); - - call_hooks('directory_item', $arr); + $arr = array('contact' => $rr, 'entry' => $entry); + + call_hooks('directory_item', $arr); - unset($profile); - unset($location); + $entries[] = $entry; - $entries[] = $entry; + unset($profile); + unset($location); - } - logger('entries: ' . print_r($entries,true)); + } + + logger('entries: ' . print_r($entries,true)); - $o .= replace_macros($tpl, array( - '$search' => $search, - '$desc' => t('Find'), - '$finddsc' => t('Finding:'), - '$safetxt' => htmlspecialchars($search,ENT_QUOTES,'UTF-8'), - '$entries' => $entries, - '$dirlbl' => t('Directory'), - '$submit' => t('Find') - )); + $o .= replace_macros($tpl, array( + '$search' => $search, + '$desc' => t('Find'), + '$finddsc' => t('Finding:'), + '$safetxt' => htmlspecialchars($search,ENT_QUOTES,'UTF-8'), + '$entries' => $entries, + '$dirlbl' => t('Directory'), + '$submit' => t('Find') + )); - $o .= paginate($a); + $o .= alt_pager($a,$j['records']); - } + } - else - info( t("No entries (some entries may be hidden).") . EOL); + else + info( t("No entries (some entries may be hidden).") . EOL); - } + } return $o; } + diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 30a1fadae..1b1ad0877 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -36,7 +36,6 @@ function dirsearch_content(&$a) { $marital = ((x($_REQUEST,'marital')) ? $_REQUEST['marital'] : ''); $keywords = ((x($_REQUEST,'keywords')) ? $_REQUEST['keywords'] : ''); - $sql_extra = ''; if($name) -- cgit v1.2.3 From 4378cf6fd505a6b5f7c7ab341ac8b5fe79b5776c Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 18 Jan 2013 19:07:32 -0800 Subject: disable magic auth for now since it isn't finished --- mod/chanview.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mod/chanview.php b/mod/chanview.php index 1de4f4e1b..b2a8e12d2 100644 --- a/mod/chanview.php +++ b/mod/chanview.php @@ -40,7 +40,9 @@ function chanview_content(&$a) { } $o = replace_macros(get_markup_template('chanview.tpl'),array( - '$url' => z_root() . '/magic?f=&dest=' . $xchan['xchan_url'] . '&addr=' . $xchan['xchan_addr'] + '$url' => $xchan['xchan_url'] +// FIXME when magic auth is finished replace here and check that against the chanview page when unauthenticated any place +// '$url' => z_root() . '/magic?f=&dest=' . $xchan['xchan_url'] . '&addr=' . $xchan['xchan_addr'] )); return $o; -- cgit v1.2.3 From d22069ad2227597f4a2289ff3ec14d46cd30b0b3 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 18 Jan 2013 19:15:08 -0800 Subject: link people search from navbar --- mod/search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/search.php b/mod/search.php index 6f40ad4b0..64a1318b2 100644 --- a/mod/search.php +++ b/mod/search.php @@ -113,8 +113,8 @@ function search_content(&$a) { $search = substr($search,1); } if(strpos($search,'@') === 0) { - require_once('mod/dirfind.php'); - return dirfind_content($a); + $search = substr($search,1); + goaway(z_root() . '/directory' . '$f=1&search=' . $search); } if(! $search) -- cgit v1.2.3 From 8fd40fc1c033401c7cb1004a55ceb9e086eb6443 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 18 Jan 2013 19:16:27 -0800 Subject: typo --- mod/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/search.php b/mod/search.php index 64a1318b2..0a7c404b6 100644 --- a/mod/search.php +++ b/mod/search.php @@ -114,7 +114,7 @@ function search_content(&$a) { } if(strpos($search,'@') === 0) { $search = substr($search,1); - goaway(z_root() . '/directory' . '$f=1&search=' . $search); + goaway(z_root() . '/directory' . '?f=1&search=' . $search); } if(! $search) -- cgit v1.2.3 From 258ca20ee3dbc587e49694f979bbddb69aaa20a3 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 18 Jan 2013 19:18:36 -0800 Subject: did it again --- mod/directory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/directory.php b/mod/directory.php index 550e60522..27b05704c 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -55,7 +55,7 @@ function directory_content(&$a) { if($url) { $query = $url . ' ?f=' ; if($search) - $query .= '$name=' . urlencode($search); + $query .= '&name=' . urlencode($search); } if($a->pager['page'] != 1) -- cgit v1.2.3 From 27ada18dc5c13591d918cf1bb9132a039f6fb751 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 18 Jan 2013 19:28:16 -0800 Subject: fix people search --- mod/directory.php | 3 ++- mod/dirsearch.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mod/directory.php b/mod/directory.php index 27b05704c..cd0ab4a48 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -53,7 +53,7 @@ function directory_content(&$a) { } if($url) { - $query = $url . ' ?f=' ; + $query = $url . '?f=' ; if($search) $query .= '&name=' . urlencode($search); @@ -61,6 +61,7 @@ function directory_content(&$a) { if($a->pager['page'] != 1) $query .= '&p=' . $a->pager['page']; + logger('mod_directory: query: ' . $query); $x = z_fetch_url($query); if($x['success']) { diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 1b1ad0877..50348bc4a 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -72,11 +72,12 @@ function dirsearch_content(&$a) { } $order = " ORDER BY `xchan_name` ASC "; - +dbg(1); $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where 1 $sql_extra $order LIMIT %d , %d ", intval($startrec), intval($perpage) ); +dbg(0); $ret['page'] = $page + 1; $ret['records'] = count($r); -- cgit v1.2.3 From b274422867a11f14a1a2bfcf57b1de4961361e15 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 18 Jan 2013 19:54:37 -0800 Subject: if chanview is provided a url - always load it even if there's no xchan available on this site. --- mod/chanview.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mod/chanview.php b/mod/chanview.php index b2a8e12d2..a9f3969d1 100644 --- a/mod/chanview.php +++ b/mod/chanview.php @@ -26,7 +26,7 @@ function chanview_content(&$a) { dbesc($_REQUEST['url']) ); if(! $r) - $r = array(array('xchan_url' => $_REQUEST['url'])); + $xchan = array(array('xchan_url' => $_REQUEST['url'])); } if($r) { $xchan = $r[0]; @@ -39,10 +39,15 @@ function chanview_content(&$a) { return; } + $observer = get_observer(); + + $url = (($observer) + ? z_root() . '/magic?f=&dest=' . $xchan['xchan_url'] . '&addr=' . $xchan['xchan_addr'] + : $xchan['xchan_url'] + ); + $o = replace_macros(get_markup_template('chanview.tpl'),array( - '$url' => $xchan['xchan_url'] -// FIXME when magic auth is finished replace here and check that against the chanview page when unauthenticated any place -// '$url' => z_root() . '/magic?f=&dest=' . $xchan['xchan_url'] . '&addr=' . $xchan['xchan_addr'] + '$url' => $url )); return $o; -- cgit v1.2.3 From 33b6d916611f6b9ec214fff38f60df128fbc940a Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 18 Jan 2013 20:00:04 -0800 Subject: allow chanview by address --- mod/chanview.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mod/chanview.php b/mod/chanview.php index a9f3969d1..d3e902f60 100644 --- a/mod/chanview.php +++ b/mod/chanview.php @@ -13,6 +13,11 @@ function chanview_content(&$a) { dbesc($_REQUEST['hash']) ); } + if($_REQUEST['address']) { + $r = q("select * from xchan where xchan_addr = '%s' limit 1", + dbesc($_REQUEST['address']) + ); + } elseif(local_user() && intval($_REQUEST['cid'])) { $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash @@ -26,7 +31,7 @@ function chanview_content(&$a) { dbesc($_REQUEST['url']) ); if(! $r) - $xchan = array(array('xchan_url' => $_REQUEST['url'])); + $r = array(array('xchan_url' => $_REQUEST['url'])); } if($r) { $xchan = $r[0]; -- cgit v1.2.3 From 9725dcf41dce7b03828a29b7f6def11ef120a88f Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 19 Jan 2013 00:43:05 -0800 Subject: distributed directory search from the navbar --- include/text.php | 29 +++++---- library/jquery_ac/friendica.complete.js | 2 + mod/acl.php | 100 ++++++++++++++++++++++++++++---- mod/directory.php | 2 +- mod/dirsearch.php | 42 ++++++++------ view/theme/redbasic/css/style.css | 7 +++ view/tpl/nav.tpl | 1 + view/tpl/smarty3/nav.tpl | 1 + 8 files changed, 142 insertions(+), 42 deletions(-) diff --git a/include/text.php b/include/text.php index 9db22d9ed..1cfc89cae 100644 --- a/include/text.php +++ b/include/text.php @@ -302,26 +302,33 @@ function paginate(&$a) { }} if(! function_exists('alt_pager')) { -function alt_pager(&$a, $i) { - $o = ''; +function alt_pager(&$a, $i, $more = '', $less = '') { + + $o = ''; + + if(! $more) + $more = t('older'); + if(! $less) + $less = t('newer'); + $stripped = preg_replace('/(&page=[0-9]*)/','',$a->query_string); $stripped = str_replace('q=','',$stripped); $stripped = trim($stripped,'/'); $pagenum = $a->pager['page']; - $url = $a->get_baseurl() . '/' . $stripped; + $url = $a->get_baseurl() . '/' . $stripped; - $o .= '
'; + $o .= '
'; - if($a->pager['page']>1) - $o .= "pager['page'] - 1).'">' . t('newer') . ''; - if($i>0) { - if($a->pager['page']>1) - $o .= " - "; - $o .= "pager['page'] + 1).'">' . t('older') . ''; + if($a->pager['page'] > 1) + $o .= "pager['page'] - 1).'">' . $less . ''; + if($i > 0 && $i == $a->pager['itemspage']) { + if($a->pager['page']>1) + $o .= " | "; + $o .= "pager['page'] + 1).'">' . $more . ''; } - $o .= '
'."\r\n"; + $o .= '
'."\r\n"; return $o; }} diff --git a/library/jquery_ac/friendica.complete.js b/library/jquery_ac/friendica.complete.js index 4599c7bc1..c8a28c0a7 100644 --- a/library/jquery_ac/friendica.complete.js +++ b/library/jquery_ac/friendica.complete.js @@ -242,6 +242,7 @@ } else if (!this.isBadQuery(q)) { me = this; me.options.params.query = q; + $('#nav-search-spinner').show(); $.get(this.serviceUrl, me.options.params, function(txt) { me.processResponse(txt); }, 'text'); } }, @@ -304,6 +305,7 @@ this.data = response.data; this.suggest(); } + $('#nav-search-spinner').hide(); }, activate: function(index) { diff --git a/mod/acl.php b/mod/acl.php index 76be01ee6..16945d1a9 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -5,6 +5,7 @@ require_once("include/acl_selectors.php"); function acl_init(&$a){ + logger('mod_acl: ' . print_r($_REQUEST,true)); $start = (x($_REQUEST,'start')?$_REQUEST['start']:0); $count = (x($_REQUEST,'count')?$_REQUEST['count']:100); @@ -21,12 +22,13 @@ function acl_init(&$a){ } - if(! (local_user() || $type == 'x')) - return ""; + if(!(local_user())) + if($type != 'x') + killme(); + logger('continue'); - - if ($search!=""){ + if ($search != "") { $sql_extra = " AND `name` LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " "; $sql_extra2 = "AND ( xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . ") "; @@ -150,18 +152,40 @@ function acl_init(&$a){ ); } elseif($type == 'x') { - $r = q("SELECT xchan_name as id, xchan_name as name, xchan_photo_s as micro, xchan_url as url from xchan - where 1 - $sql_extra3 - ORDER BY `xchan_name` ASC ", - intval(local_user()) - ); + + $r = navbar_complete($a); + $x = array(); + $x['query'] = $search; + $x['photos'] = array(); + $x['links'] = array(); + $x['suggestions'] = array(); + $x['data'] = array(); + if($r) { + foreach($r as $g) { + $x['photos'][] = $g['photo']; + $x['links'][] = $g['url']; + $x['suggestions'][] = '@' . $g['name']; + $x['data'][] = $g['name']; + } + } + echo json_encode($x); + killme(); + + + + +// $r = q("SELECT xchan_name as id, xchan_name as name, xchan_photo_s as micro, xchan_url as url from xchan +// where 1 +// $sql_extra3 +// ORDER BY `xchan_name` ASC ", +// intval(local_user()) +// ); } else $r = array(); - if($type == 'm' || $type == 'a' || $type == 'x') { + if($type == 'm' || $type == 'a') { $x = array(); $x['query'] = $search; $x['photos'] = array(); @@ -209,3 +233,57 @@ function acl_init(&$a){ } +function navbar_complete(&$a) { + + logger('navbar_complete'); + + $dirmode = intval(get_config('system','directory_mode')); + $search = ((x($_REQUEST,'query')) ? htmlentities($_REQUEST['query'],ENT_COMPAT,'UTF-8',false) : ''); + if(! $search || mb_strlen($search) < 2) + return array(); + + $star = false; + $address = false; + + if(substr($search,0,1) === '@') + $search = substr($search,1); + + if(substr($search,0,1) === '*') { + $star = true; + $search = substr($search,1); + } + + if(strpos($search,'@') !== false) { + $address = true; + } + + if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) { + $url = z_root() . '/dirsearch'; + } + + if(! $url) { + $directory = find_upstream_directory($dirmode); + + if($directory) { + $url = $directory['url']; + } + else { + $url = DIRECTORY_FALLBACK_MASTER . '/dirsearch'; + } + } + + if($url) { + $query = $url . '?f=' ; + $query .= '&name=' . urlencode($search) . '&limit=50' . (($address) ? '&address=' . urlencode($search) : ''); + + $x = z_fetch_url($query); + if($x['success']) { + $t = 0; + $j = json_decode($x['body'],true); + if($j && $j['results']) { + return $j['results']; + } + } + } + return array(); +} \ No newline at end of file diff --git a/mod/directory.php b/mod/directory.php index cd0ab4a48..99687a373 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -163,7 +163,7 @@ function directory_content(&$a) { )); - $o .= alt_pager($a,$j['records']); + $o .= alt_pager($a,$j['records'], t('more'), t('back')); } diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 50348bc4a..b3b824b24 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -39,46 +39,50 @@ function dirsearch_content(&$a) { $sql_extra = ''; if($name) - $sql_extra .= " AND xchan_name like '" . protect_sprintf( '%' . dbesc($name) . '%' ) . "' "; - if($addr) - $sql_extra .= " AND xchan_addr like '" . protect_sprintf( '%' . dbesc($addr) . '%' ) . "' "; + $sql_extra .= " OR xchan_name like '" . protect_sprintf( '%' . dbesc($name) . '%' ) . "' "; + if($address) + $sql_extra .= " OR xchan_addr like '" . protect_sprintf( '%' . dbesc($address) . '%' ) . "' "; if($city) - $sql_extra .= " AND xprof_locale like '" . protect_sprintf( '%' . dbesc($city) . '%' ) . "' "; + $sql_extra .= " OR xprof_locale like '" . protect_sprintf( '%' . dbesc($city) . '%' ) . "' "; if($region) - $sql_extra .= " AND xprof_region like '" . protect_sprintf( '%' . dbesc($region) . '%' ) . "' "; + $sql_extra .= " OR xprof_region like '" . protect_sprintf( '%' . dbesc($region) . '%' ) . "' "; if($post) - $sql_extra .= " AND xprof_postcode like '" . protect_sprintf( '%' . dbesc($post) . '%' ) . "' "; + $sql_extra .= " OR xprof_postcode like '" . protect_sprintf( '%' . dbesc($post) . '%' ) . "' "; if($country) - $sql_extra .= " AND xprof_country like '" . protect_sprintf( '%' . dbesc($country) . '%' ) . "' "; + $sql_extra .= " OR xprof_country like '" . protect_sprintf( '%' . dbesc($country) . '%' ) . "' "; if($gender) - $sql_extra .= " AND xprof_gender like '" . protect_sprintf( '%' . dbesc($gender) . '%' ) . "' "; + $sql_extra .= " OR xprof_gender like '" . protect_sprintf( '%' . dbesc($gender) . '%' ) . "' "; if($marital) - $sql_extra .= " AND xprof_marital like '" . protect_sprintf( '%' . dbesc($marital) . '%' ) . "' "; + $sql_extra .= " OR xprof_marital like '" . protect_sprintf( '%' . dbesc($marital) . '%' ) . "' "; if($keywords) - $sql_extra .= " AND xprof_keywords like '" . protect_sprintf( '%' . dbesc($keywords) . '%' ) . "' "; + $sql_extra .= " OR xprof_keywords like '" . protect_sprintf( '%' . dbesc($keywords) . '%' ) . "' "; $perpage = (($_REQUEST['n']) ? $_REQUEST['n'] : 80); $page = (($_REQUEST['p']) ? intval($_REQUEST['p'] - 1) : 0); $startrec = (($page+1) * $perpage) - $perpage; + $limit = (($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 0); // ok a separate tag table won't work. // merge them into xprof $ret['success'] = true; - $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where 1 $sql_extra"); - if($r) { - $ret['total_items'] = $r[0]['total']; + + if($limit) + $qlimit = " LIMIT $limit "; + else { + $qlimit = " LIMIT " . intval($startrec) . " , " . intval($perpage); + $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where 1 $sql_extra"); + if($r) { + $ret['total_items'] = $r[0]['total']; + } } - $order = " ORDER BY `xchan_name` ASC "; + $order = " ORDER BY `xchan_name` ASC "; + $logic = ((strlen($sql_extra)) ? 0 : 1); dbg(1); - $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where 1 $sql_extra $order LIMIT %d , %d ", - intval($startrec), - intval($perpage) - ); + $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra $order $qlimit "); dbg(0); - $ret['page'] = $page + 1; $ret['records'] = count($r); diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 21704e21c..fd989554b 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -2569,6 +2569,13 @@ aside input[type='text'] { margin-top: 4px; } +#nav-search-spinner { + float: right; + margin-top: 8px; + margin-left: 5px; + margin-right: 5px; +} + #nav-search-text:hover { background-color: #FFF; color: #000; diff --git a/view/tpl/nav.tpl b/view/tpl/nav.tpl index b0eb098aa..b0c2393cd 100644 --- a/view/tpl/nav.tpl +++ b/view/tpl/nav.tpl @@ -133,6 +133,7 @@ + diff --git a/view/tpl/smarty3/nav.tpl b/view/tpl/smarty3/nav.tpl index da50bc7bb..0b8344b07 100644 --- a/view/tpl/smarty3/nav.tpl +++ b/view/tpl/smarty3/nav.tpl @@ -133,6 +133,7 @@ + -- cgit v1.2.3 From d8d8dd5ceda475f56a8c6ed2324f2eae94658d3a Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 19 Jan 2013 01:07:35 -0800 Subject: directory services cleanup --- include/nav.php | 5 +++-- mod/acl.php | 17 +++-------------- mod/dirsearch.php | 12 +++++++++--- view/tpl/nav.tpl | 1 + view/tpl/smarty3/nav.tpl | 1 + 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/include/nav.php b/include/nav.php index 644264a92..b65577e0f 100644 --- a/include/nav.php +++ b/include/nav.php @@ -118,9 +118,9 @@ EOT; $nav['search'] = array('search', t('Search'), "", t('Search site content')); - $gdirpath = 'directory'; - $nav['directory'] = array($gdirpath, t('Directory'), "", t('People directory')); + $nav['directory'] = array('directory', t('Channel Directory'), "", t('Channel Locator')); + /** * @@ -199,6 +199,7 @@ EOT; '$localuser' => local_user(), '$sel' => $a->nav_sel, '$apps' => $a->get_apps(), + '$pleasewait' => t('Please wait...') )); call_hooks('page_header', $a->page['nav']); diff --git a/mod/acl.php b/mod/acl.php index 16945d1a9..0290edca8 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -5,7 +5,7 @@ require_once("include/acl_selectors.php"); function acl_init(&$a){ - logger('mod_acl: ' . print_r($_REQUEST,true)); +// logger('mod_acl: ' . print_r($_REQUEST,true)); $start = (x($_REQUEST,'start')?$_REQUEST['start']:0); $count = (x($_REQUEST,'count')?$_REQUEST['count']:100); @@ -26,8 +26,6 @@ function acl_init(&$a){ if($type != 'x') killme(); - logger('continue'); - if ($search != "") { $sql_extra = " AND `name` LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " "; $sql_extra2 = "AND ( xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . ") "; @@ -170,16 +168,7 @@ function acl_init(&$a){ } echo json_encode($x); killme(); - - - -// $r = q("SELECT xchan_name as id, xchan_name as name, xchan_photo_s as micro, xchan_url as url from xchan -// where 1 -// $sql_extra3 -// ORDER BY `xchan_name` ASC ", -// intval(local_user()) -// ); } else $r = array(); @@ -196,7 +185,7 @@ function acl_init(&$a){ foreach($r as $g) { $x['photos'][] = $g['micro']; $x['links'][] = $g['url']; - $x['suggestions'][] = (($type === 'x') ? '@' : '') . $g['name']; + $x['suggestions'][] = $g['name']; $x['data'][] = $g['id']; } } @@ -235,7 +224,7 @@ function acl_init(&$a){ function navbar_complete(&$a) { - logger('navbar_complete'); +// logger('navbar_complete'); $dirmode = intval(get_config('system','directory_mode')); $search = ((x($_REQUEST,'query')) ? htmlentities($_REQUEST['query'],ENT_COMPAT,'UTF-8',false) : ''); diff --git a/mod/dirsearch.php b/mod/dirsearch.php index b3b824b24..07af90ffb 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -4,7 +4,7 @@ require_once('include/dir_fns.php'); function dirsearch_init(&$a) { - $a->set_pager_itemspage(60); + $a->set_pager_itemspage(80); } @@ -36,6 +36,8 @@ function dirsearch_content(&$a) { $marital = ((x($_REQUEST,'marital')) ? $_REQUEST['marital'] : ''); $keywords = ((x($_REQUEST,'keywords')) ? $_REQUEST['keywords'] : ''); +// TODO - a meta search which joins all of these things to one search string + $sql_extra = ''; if($name) @@ -61,12 +63,16 @@ function dirsearch_content(&$a) { $page = (($_REQUEST['p']) ? intval($_REQUEST['p'] - 1) : 0); $startrec = (($page+1) * $perpage) - $perpage; $limit = (($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 0); + $return_total = ((x($_REQUEST,'return_total')) ? intval($_REQUEST['return_total']) : 0); // ok a separate tag table won't work. // merge them into xprof $ret['success'] = true; + // If &limit=n, return at most n entries + // If &return_total=1, we count matching entries and return that as 'total_items' for use in pagination. + // By default we return one page (default 80 items maximum) and do not count total entries if($limit) $qlimit = " LIMIT $limit "; @@ -80,9 +86,9 @@ function dirsearch_content(&$a) { $order = " ORDER BY `xchan_name` ASC "; $logic = ((strlen($sql_extra)) ? 0 : 1); -dbg(1); + $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra $order $qlimit "); -dbg(0); + $ret['page'] = $page + 1; $ret['records'] = count($r); diff --git a/view/tpl/nav.tpl b/view/tpl/nav.tpl index b0c2393cd..3b997e215 100644 --- a/view/tpl/nav.tpl +++ b/view/tpl/nav.tpl @@ -86,6 +86,7 @@