Changed the modules settings page, now it is 'automatic', plus a few bug fixes.
[estigi.git] / core / user / user.admin
blobe46d637b6df4c5028a8ff88cba44cdbeeffbd04d
1 <?php
3 /**
4  * @file user.admin
5  * Admin user module file.
6  * Core Module. Deals with user administrative tasks.
7  *
8  * @ingroup User
9  */
11 /**
12  * User settings form
13  */
14 function user_settings_form(){
16         global $settings;
18         $form['user_admin']['fieldset_register'] = array(
19                 'type'  => 'fieldset',
20                 'legend'  => 'User Registration'
21                 );
23         $form['user_admin']['fieldset_register']['user_register'] = array(
24                 'type'  => 'radio',
25                 'text' =>'',
26                 'options' => array('an' => 'Anyone without administration approval', 'admin' => 'Only administrators can register new users', 'aa' => 'Anyone, but administrative approval is requried'),
27                 'value' => 'an',
28                 'use_keys' => TRUE
29                 );
32         $form['user_admin']['user_emal'] = array(
33                 'type'  => 'checkbox',
34                 'text' =>'Send welcome email',
35                 'inline' => 1,
36                 'checked' => 'checked'
37                 );
39         return $form;
42 /**
43  * User filter form
44  * 
45  * @todo
46  *  Add a group selection
47  */
49 function user_filter_form(){
51         $form['user_list']['fieldset_filter'] = array(
52                 'type' => 'fieldset',
53                 'legend' => 'Filter users'
54         );
56         $form['user_list']['fieldset_filter']['roles'] = array(
57                 'type' => 'select',
58                 'text' => 'View only members of this role',
59                 'options' => user_roles(),
60                 'use_keys' => TRUE
61                 );
63         $form['user_list']['fieldset_filter']['status'] = array(
64                 'type' => 'select',
65                 'text' => 'Status',
66                 'options' => array('Inactive', 'Active'),
67                 'use_keys' => TRUE
68                 );
70         $form['user_list']['fieldset_filter']['submit'] = array(
71                 'type' => 'submit',
72                 'value' => 'Filter'
73                 );
75         return $form;
78 /**
79  * Lists all users
80  */
81 function user_admin_list(){
83         global $skin;
85         $skin['page_title'] = 'User list';
87         if(!user_access('users admin')){
88                 return PATH_NO_ACCESS;
89         }
91         //Filters
92         if(isset($_POST['status']) && $_POST['status'] != '---'){
93                 $where = 'AND status = '.$_POST['status'].'';
94         }
96         $user_list = db_query("SELECT * FROM {PRE_}users WHERE uid > 0 ".$where." ORDER BY uid DESC", TRUE, FALSE, 10);
98         $users = form_form(user_filter_form());
100         $users .= '<table id="users list">
101                                         <thead><tr>
102                                                 <th>Uid</th>
103                                                 <th>Name</th>
104                                                 <th>Registred</th>
105                                                 <th>Status</th>
106                                         </tr>
107                                         </thead>';
109         if($user_list){
111                 foreach($user_list as $user){
113                         $users .= '<tr>
114                                                         <td>'.$user['uid'].'</td>
115                                                         <td>'.path_link('user/edit/'.$user['uid'], $user['name'], 'Click here to edit user\'s account').'</a></td>
116                                                         <td>'.date('Y - M - d', $user['created']).'</td>
117                                                         <td>'.($user['status'] == 1 ? 'Active' : 'Inactive') .'</td>
118                                                 </tr>';
119                 }
120         }
122         $users .= '</table>';
124         return $users;