aboutsummaryrefslogtreecommitdiffstats
path: root/mod/admin.php
blob: 13131f0135d8acf33d42b13f003fd0b5bb3eaf17 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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 )
	));
}