aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-05-16 18:52:27 -0700
committerFriendika <info@friendika.com>2011-05-16 18:52:27 -0700
commitf9444c8be50f91282a81eebc84825813d118bfe4 (patch)
tree2b157c31fd32ab93837680f8e065ef05eb033d59
parent85c6457e6e6c9be6200f76bb12c449f010d4117b (diff)
downloadvolse-hubzilla-f9444c8be50f91282a81eebc84825813d118bfe4.tar.gz
volse-hubzilla-f9444c8be50f91282a81eebc84825813d118bfe4.tar.bz2
volse-hubzilla-f9444c8be50f91282a81eebc84825813d118bfe4.zip
admin directory view
-rw-r--r--boot.php8
-rw-r--r--mod/directory.php19
-rw-r--r--view/directory_header.tpl1
3 files changed, 26 insertions, 2 deletions
diff --git a/boot.php b/boot.php
index a44d8298f..b0c7a6197 100644
--- a/boot.php
+++ b/boot.php
@@ -2736,3 +2736,11 @@ function parse_xml_string($s) {
libxml_clear_errors();
return $x;
}}
+
+if(! function_exists('is_site_admin')) {
+function is_site_admin() {
+ $a = get_app();
+ if(local_user() && x($a->user,'email') && x($a->config,'admin_email') && ($a->user['email'] === $a->config['admin_email']))
+ return true;
+ return false;
+}} \ No newline at end of file
diff --git a/mod/directory.php b/mod/directory.php
index 77fdb30a4..dfe8ec0d9 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -14,6 +14,8 @@ function directory_post(&$a) {
function directory_content(&$a) {
+ $everything = (($a->argc > 1 && $a->argv[1] === 'all' && is_site_admin()) ? true : false);
+
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
return;
@@ -38,9 +40,18 @@ function directory_content(&$a) {
. $gdirpath . '">' . t('Global Directory') . '</a></div></li></ul>';
}
+ $admin = '';
+ if(is_site_admin()) {
+ if($everything)
+ $admin = '<ul><li><div id="directory-admin-link"><a href="' . $a->get_baseurl() . '/directory' . '">' . t('Normal site view') . '</a></div></li></ul>';
+ else
+ $admin = '<ul><li><div id="directory-admin-link"><a href="' . $a->get_baseurl() . '/directory/all' . '">' . t('View all site entries') . '</a></div></li></ul>';
+ }
+
$o .= replace_macros($tpl, array(
'$search' => $search,
'$globaldir' => $globaldir,
+ '$admin' => $admin,
'$finding' => (strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : ""),
'$sitedir' => t('Site Directory'),
'$submit' => t('Find')
@@ -50,16 +61,20 @@ function directory_content(&$a) {
$search = dbesc($search);
$sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : "");
- $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
+ $publish = ((get_config('system','publish_all') || $everything) ? '' : " AND `publish` = 1 " );
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ");
if(count($r))
$a->set_pager_total($r[0]['total']);
+ if($everything)
+ $order = " ORDER BY `register_date` DESC ";
+ else
+ $order = " ORDER BY `name` ASC ";
- $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra ORDER BY `name` ASC LIMIT %d , %d ",
+ $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $sql_extra $order LIMIT %d , %d ",
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
diff --git a/view/directory_header.tpl b/view/directory_header.tpl
index 490868cc9..c5463778b 100644
--- a/view/directory_header.tpl
+++ b/view/directory_header.tpl
@@ -1,6 +1,7 @@
<h1>$sitedir</h1>
$globaldir
+$admin
$finding