root/devel/mod/admin/lib.php

Revision 1539, 5.7 kB (checked in by renato, 10 months ago)

Setting prop svn:eol-style in LOTS of files.

  • Property svn:mime-type set to text/plain
  • Property svn:eol-style set to native
Line 
1 <?php
2 /*
3  * Created on Sep 20, 2007
4  *
5  * @author Diego Andrés Ramírez Aragón <diego@somosmas.org>
6  * @copyright Corporación Somos más - 2007
7  */
8 function admin_pagesetup() {
9         global $PAGE,$CFG;
10
11 /*
12     if (isadmin()) {
13         $PAGE->menu_top [] = array( 'name' => 'admin',
14                                     //'html' => a_href("{$CFG->wwwroot}_admin/",
15                                     //                "Administration"));
16                                     'html' => "<li><a href=\"" . $CFG->wwwroot . "mod/admin/\">" . __gettext("Administration") . "</a></li>");
17     }
18 */     
19         if (defined("context") && context == "account") {
20                 $PAGE->menu_sub[] = array (
21                         'name' => 'user:edit',
22                         'html' => a_href("{$CFG->wwwroot}_userdetails/",__gettext("Edit user details")));
23                 $PAGE->menu_sub[] = array (
24                         'name' => 'user:icon',
25                         'html' => a_href("{$CFG->wwwroot}_icons/",__gettext("Your site picture")));
26         }
27
28         if (defined("context") && context == "admin" && isloggedin() && user_flag_get("admin", $_SESSION['userid'])) {
29                 $PAGE->menu_sub[] = array (
30                         'name' => 'admin',
31                         'html' => a_href(get_url(-1, 'admin::main'),__gettext("Main")));
32
33                 $PAGE->menu_sub[] = array (
34                         'name' => 'admin:users:add',
35                         'html' => a_href(get_url(-1, 'admin::users::add'),__gettext("Add users")));
36
37                 $PAGE->menu_sub[] = array (
38                         'name' => 'admin:users',
39                         'html' => a_href(get_url(-1, 'admin::users'),__gettext("Manage users")));
40
41                 $PAGE->menu_sub[] = array (
42                         'name' => 'admin:users:banned',
43                         'html' => a_href(get_url(-1, 'admin::users::banned'),__gettext("Banned users")));
44
45                 $PAGE->menu_sub[] = array (
46                         'name' => 'admin:users:admin',
47                         'html' => a_href(get_url(-1, 'admin::users::admin'),__gettext("Admin users")));
48
49                 $PAGE->menu_sub[] = array (
50                         'name' => 'admin:flags',
51                         'html' => a_href(get_url(-1, 'admin::flags'),__gettext("Manage flagged content")));
52
53                 $PAGE->menu_sub[] = array (
54                         'name' => 'admin:spam',
55                         'html' => a_href(get_url(-1, 'admin::spam'),__gettext("Spam control")));
56         }
57
58 }
59 function admin_init() {
60         global $CFG, $function;
61
62         // Elgg administration utilities
63         // Ben Werdmuller, September 2005
64
65         // These utilities allow users tagged with the 'administration' flag
66         // to perform tasks on other users' accounts, including editing posts,
67         // banning or deleting accounts, adding accounts in bulk and so on.
68
69         // Permissions check
70         // Establishes permissions; if the question is 'does this admin user
71         // have permissions', the answer is 'yes'
72         $function['permissions:check'][] = $CFG->dirroot . "mod/admin/lib/permissions_check.php";
73
74         // Main admin panel screen
75         $function['admin:main'][] = $CFG->dirroot . "mod/admin/lib/admin_main.php";
76
77         // Content flagging system
78         $function['profile:view'][] = $CFG->dirroot . "mod/admin/lib/display_content_flag_form.php";
79         $function['weblogs:posts:view:individual'][] = $CFG->dirroot . "mod/admin/lib/display_content_flag_form.php";
80         $function['files:folder:view'][] = $CFG->dirroot . "mod/admin/lib/display_content_flag_form.php";
81
82         // Content flag administration
83         $function['admin:contentflags'][] = $CFG->dirroot . "mod/admin/lib/admin_contentflags.php";
84
85         // Extra administration of user details
86         $function['userdetails:edit:details'][] = $CFG->dirroot . "mod/admin/lib/admin_userdetails.php";
87         // Menu to view all users
88         $function['admin:users'][] = $CFG->dirroot . "mod/admin/lib/admin_users.php";
89         $function['admin:users:admin'][] = $CFG->dirroot . "mod/admin/lib/admin_admin_users.php";
90         $function['admin:users:banned'][] = $CFG->dirroot . "mod/admin/lib/admin_banned_users.php";
91
92         // Bulk user addition screen
93         $function['admin:users:add'][] = $CFG->dirroot . "mod/admin/lib/admin_users_add.php";
94
95         // Display a user control panel when given a database row from elgg.users
96         $function['admin:users:panel'][] = $CFG->dirroot . "mod/admin/lib/admin_users_panel.php";
97
98         // Anti-spam
99         $function['admin:spam'][] = $CFG->dirroot . "mod/admin/lib/admin_spam.php";
100         $function['spam:check'][] = $CFG->dirroot . "mod/admin/lib/spam_check.php";
101
102         // Admin-related actions
103     // also allows users to flag content
104         $function['init'][] = $CFG->dirroot . "mod/admin/lib/admin_actions.php";
105
106 }
107
108 function admin_url($oid, $type) {
109     global $CFG;
110     $url = null;
111
112     if (strpos($type, 'admin::') == 0) {
113         $url = $CFG->wwwroot . 'mod/admin/';
114         switch ($type) {
115             case 'admin::spam':
116                 $url .= '?do=spam';
117                 break;
118             case 'admin::flags':
119                 $url .= '?do=flags';
120                 break;
121             case 'admin::users::add':
122                 $url .= '?do=users&amp;view=add';
123                 break;
124             case 'admin::users::admin':
125                 $url .= '?do=users&amp;view=admin';
126                 break;
127             case 'admin::users::banned':
128                 $url .= '?do=users&amp;view=banned';
129                 break;
130             case 'admin::users':
131                 $url .= '?do=users';
132                 break;
133             case 'admin::userdetails':
134                 $url = $CFG->wwwroot . 'mod/users/?context=admin&profile_id='.$oid;
135                 break;
136             case 'admin::main':
137             default:
138                 break;
139         }
140     }
141
142     return $url;
143 }
144
145 function get_url_query($object_id, $object_type, $query) {
146     $url = get_url($object_id, $object_type);
147
148     if (strpos($url, '?') === false) {
149         $sep = '?';
150     } else {
151         $sep = '&amp;';
152     }
153
154     return $url . $sep . $query;
155 }
156
157 /**
158  * Register user types
159  */
160 function register_user_type($type) {
161     global $CFG;
162     if (!isset($CFG->user_types)) {
163         $CFG->user_types = array();
164     }
165
166     $CFG->user_types[] = $type;
167     return true;
168 }
169
170 function get_user_types() {
171     global $CFG;
172     if (!isset($CFG->user_types)) {
173         $CFG->user_types = array();
174     }
175
176     return $CFG->user_types;
177 }
178
179 ?>
Note: See TracBrowser for help on using the browser.