From 3364c2a2d8ab88703c5566a39df13ef1042f8644 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Mon, 13 Jun 2011 12:52:29 +0200 Subject: [PATCH] Initial admin page --- mod/admin.php | 105 +++++++++++++++++++++++++++++++++++++++++ view/admin_aside.tpl | 20 ++++++++ view/admin_summary.tpl | 33 +++++++++++++ 3 files changed, 158 insertions(+) create mode 100644 mod/admin.php create mode 100644 view/admin_aside.tpl create mode 100644 view/admin_summary.tpl diff --git a/mod/admin.php b/mod/admin.php new file mode 100644 index 0000000000..13131f0135 --- /dev/null +++ b/mod/admin.php @@ -0,0 +1,105 @@ + Array($a->get_baseurl()."/admin/site/", t("Site") , "site"), + 'users' => Array($a->get_baseurl()."/admin/users/", t("Users") , "users"), + 'plugins'=> Array($a->get_baseurl()."/admin/plugins/", t("Plugins") , "plugins") + ); + + /* get plugins admin page */ + + $r = q("SELECT * FROM `hook` WHERE `hook`='plugin_admin'"); + $aside['plugins_admin']=Array(); + foreach ($r as $h){ + $plugin = explode("/",$h['file']); $plugin = $plugin[1]; + $aside['plugins_admin'][] = Array($a->get_baseurl()."/admin/plugins/".$plugin, $plugin, "plugin"); + } + + $aside['logs'] = Array($a->get_baseurl()."/admin/logs/", t("Logs"), "logs"); + + $t = get_markup_template("admin_aside.tpl"); + $a->page['aside'] = replace_macros( $t, array('$admin' => $aside) ); + + + + /** + * Page content + */ + $o = ''; + + // urls + if ($a->argc > 1){ + switch ($a->argv[1]){ + case 'site': { + $o = admin_page_site($a); + break; + } + default: + notice( t("Item not found.") ); + } + } else { + $o = admin_page_summary($a); + } + return $o; +} + + +/** + * Admin Summary Page + */ +function admin_page_summary(&$a) { + $r = q("SELECT `page-flags`, COUNT(uid) as `count` FROM `user` GROUP BY `page-flags`"); + $accounts = Array( + Array( t('Normal Account'), 0), + Array( t('Soapbox Account'), 0), + Array( t('Community/Celebrity Account'), 0), + Array( t('Automatic Friend Account'), 0) + ); + $users=0; + foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+=$u['count']; } + + //echo "
"; var_dump($a->plugins); die("
"); + + + $r = q("SELECT COUNT(id) as `count` FROM `register`"); + $pending = $r[0]['count']; + + + + + + $t = get_markup_template("admin_summary.tpl"); + return replace_macros($t, array( + '$title' => t('Administration'), + '$page' => t('Summary'), + '$users' => Array( t('Registered users'), $users), + '$accounts' => $accounts, + '$pending' => Array( t('Pending registrations'), $pending), + '$version' => Array( t('Version'), FRIENDIKA_VERSION), + '$build' => get_config('system','build'), + '$plugins' => Array( t('Active plugins'), $a->plugins ) + )); +} diff --git a/view/admin_aside.tpl b/view/admin_aside.tpl new file mode 100644 index 0000000000..24aafa7751 --- /dev/null +++ b/view/admin_aside.tpl @@ -0,0 +1,20 @@ +

Admin

+ + + +{{ if $admin.plugins_admin }}

Plugins

{{ endif }} + + + +

Logs

+ diff --git a/view/admin_summary.tpl b/view/admin_summary.tpl new file mode 100644 index 0000000000..cbd659d071 --- /dev/null +++ b/view/admin_summary.tpl @@ -0,0 +1,33 @@ +

$title - $page

+ +
+
$users.0
+
$users.1
+
+{{ for $accounts as $p }} +
+
$p.0
+
$p.1
+
+{{ endfor }} + +
+
$pending.0
+
$pending.1 +
+ +
+
$version.0
+
$version.1 - $build +
+ + + +
+
$plugins.0
+ + {{ for $plugins.1 as $p }} +
$p
+ {{ endfor }} + +