Initial admin page
This commit is contained in:
parent
afd0f8e4d8
commit
3364c2a2d8
105
mod/admin.php
Normal file
105
mod/admin.php
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
/**
|
||||
* Friendika admin
|
||||
*/
|
||||
|
||||
|
||||
function admin_init(&$a) {
|
||||
if(!is_site_admin()) {
|
||||
notice( t('Permission denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function admin_content(&$a) {
|
||||
|
||||
if(!is_site_admin()) {
|
||||
return login(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Side bar links
|
||||
*/
|
||||
|
||||
// array( url, name, extra css classes )
|
||||
$aside = Array(
|
||||
'site' => 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 "<pre>"; var_dump($a->plugins); die("</pre>");
|
||||
|
||||
|
||||
$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 )
|
||||
));
|
||||
}
|
20
view/admin_aside.tpl
Normal file
20
view/admin_aside.tpl
Normal file
|
@ -0,0 +1,20 @@
|
|||
<h4>Admin</h4>
|
||||
<ul>
|
||||
<li class='admin link $admin.site.2'><a href='$admin.site.0'>$admin.site.1</a></li>
|
||||
<li class='admin link $admin.users.2'><a href='$admin.users.0'>$admin.users.1</a></li>
|
||||
<li class='admin link $admin.plugins.2'><a href='$admin.plugins.0'>$admin.plugins.1</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
{{ if $admin.plugins_admin }}<h4>Plugins</h4>{{ endif }}
|
||||
<ul>
|
||||
{{ for $admin.plugins_admin as $l }}
|
||||
<li class='admin link $l.2'><a href='$l.0'>$l.1</a></li>
|
||||
{{ endfor }}
|
||||
</ul>
|
||||
|
||||
|
||||
<h4>Logs</h4>
|
||||
<ul>
|
||||
<li class='admin link $admin.logs.2'><a href='$admin.logs.0'>$admin.logs.1</a></li>
|
||||
</ul>
|
33
view/admin_summary.tpl
Normal file
33
view/admin_summary.tpl
Normal file
|
@ -0,0 +1,33 @@
|
|||
<h1>$title - $page</h1>
|
||||
|
||||
<dl>
|
||||
<dt>$users.0</dt>
|
||||
<dd>$users.1</dd>
|
||||
</dl>
|
||||
{{ for $accounts as $p }}
|
||||
<dl>
|
||||
<dt>$p.0</dt>
|
||||
<dd>$p.1</dd>
|
||||
</dl>
|
||||
{{ endfor }}
|
||||
|
||||
<dl>
|
||||
<dt>$pending.0</dt>
|
||||
<dd>$pending.1</dt>
|
||||
</dl>
|
||||
|
||||
<dl>
|
||||
<dt>$version.0</dt>
|
||||
<dd>$version.1 - $build</dt>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<dl>
|
||||
<dt>$plugins.0</dt>
|
||||
|
||||
{{ for $plugins.1 as $p }}
|
||||
<dd>$p</dd>
|
||||
{{ endfor }}
|
||||
|
||||
</dl>
|
Loading…
Reference in a new issue