Changeset 150
- Timestamp:
- 11/10/08 21:06:08 (1 year ago)
- Files:
-
- trunk/modules/auth/controllers/admin/members.php (modified) (16 diffs)
- trunk/user_guide/general/changelog.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/modules/auth/controllers/admin/members.php
r135 r150 27 27 // Call parent constructor 28 28 parent::Admin_Controller(); 29 29 30 30 // Load userlib language 31 31 $this->lang->load('userlib'); 32 32 33 33 // Set breadcrumb 34 34 $this->page->set_crumb($this->lang->line('backendpro_members'),'auth/admin/members'); 35 35 36 36 // Check for access permission 37 37 check('Members'); 38 38 39 39 // Load the validation library 40 40 $this->load->library('validation'); 41 41 42 42 log_message('debug','Members Class Initialized'); 43 43 } 44 44 45 45 /** 46 46 * View Members … … 53 53 // Get Member Infomation 54 54 $data['members'] = $this->user_model->getUsers(); 55 55 56 56 // Display Page 57 57 $data['header'] = $this->lang->line('backendpro_members'); … … 61 61 return; 62 62 } 63 63 64 64 /** 65 65 * Set Profile Defaults … … 77 77 return; 78 78 } 79 79 80 80 /** 81 81 * Get User Details … … 93 93 $data['group'] = $this->input->post('group'); 94 94 $data['active'] = $this->input->post('active'); 95 95 96 96 // Only if password is set encode it 97 97 if($this->input->post('password') != '') 98 98 $data['password'] = $this->userlib->encode_password($this->input->post('password')); 99 99 100 100 return $data; 101 101 } 102 102 103 103 /** 104 104 * Get Profile Details … … 117 117 return $data; 118 118 } 119 119 120 120 /** 121 121 * Display Member Form … … 135 135 $fields['group'] = $this->lang->line('userlib_group'); 136 136 $fields['active'] = $this->lang->line('userlib_active'); 137 // TODO: Make sure the config file is loaded here 137 138 $fields = array_merge($fields, $this->config->item('userlib_profile_fields')); 138 139 $this->validation->set_fields($fields); 139 140 // VALIDATION RULES 141 if( is_null($id)){ // CREATE USER 140 141 // Setup validation rules 142 if( is_null($id)) 143 { 144 // Use create user rules (make sure no-one has the same email) 142 145 $rules['username'] = "trim|required|spare_username"; 143 146 $rules['email'] = "trim|required|valid_email|spare_email"; 144 147 $rules['password'] = "trim|required|min_length[".$this->preference->item('min_password_length')."]|matches[confirm_password]"; 145 } else { // EDIT USER 148 } else 149 { 150 // Use edit user rules (make sure no-one other than the current user has the same email) 146 151 $rules['username'] = "trim|required|spare_edit_username"; 147 152 $rules['email'] = "trim|required|valid_email|spare_edit_email"; … … 149 154 } 150 155 $rules = array_merge($rules,$this->config->item('userlib_profile_rules')); 151 152 // S ETUP FORM DEFAULT VALUES156 157 // Setup form default values 153 158 if( ! is_null($id) AND ! $this->input->post('submit')) 154 159 { … … 156 161 $user = $this->user_model->getUsers(array('users.id'=>$id)); 157 162 $user = $user->row_array(); 158 163 159 164 $this->validation->set_default_value('group',$user['group_id']); 160 165 unset($user['group']); … … 167 172 $this->validation->set_default_value('group',$this->preference->item('default_user_group')); 168 173 $this->validation->set_default_value('active','1'); 169 174 170 175 // Setup profile defaults 171 176 $this->_set_profile_defaults(); … … 176 181 $this->validation->set_rules($rules); 177 182 } 178 183 179 184 // RUN 180 185 if ($this->validation->run() === FALSE) … … 183 188 $this->page->set_asset('admin','js','generate_password.js'); 184 189 $this->page->set_asset('admin','css','generate_password.css'); 185 190 186 191 // Construct Groups dropdown 187 192 $this->load->model('access_control_model'); 188 193 $data['groups'] = $this->access_control_model->buildAClDropdown('group','id'); 189 194 190 195 // Display form 191 196 $this->validation->output_errors(); … … 206 211 $user['created'] = date('Y-m-d H:i:s'); 207 212 $profile = $this->_get_profile_details(); 208 213 209 214 $this->db->trans_start(); 210 215 $this->user_model->insert('Users',$user); 211 216 $profile['user_id'] = $this->db->insert_id(); 212 217 $this->user_model->insert('UserProfiles',$profile); 213 218 214 219 if($this->db->trans_status() === TRUE) 215 220 { … … 230 235 $user['modified'] = date('Y-m-d H:i:s'); 231 236 $profile = $this->_get_profile_details(); 232 237 233 238 $this->db->trans_start(); 234 239 $this->user_model->update('Users',$user,array('id'=>$user['id'])); 235 if($this->preference->item('allow_user_profiles')) 240 241 // The && count($profile) > 0 has been added here since if no update keys=>values 242 // are passed to the update method it errors saying the set method must be set 243 // See bug #51 244 if($this->preference->item('allow_user_profiles') && count($profile) > 0) 236 245 $this->user_model->update('UserProfiles',$profile,array('user_id'=>$user['id'])); 237 246 238 247 if($this->db->trans_status() === TRUE) 239 248 { … … 250 259 } 251 260 } 252 261 253 262 /** 254 263 * Delete … … 263 272 if(FALSE === ($selected = $this->input->post('select'))) 264 273 redirect('auth/admin/members','location'); 265 274 266 275 foreach($selected as $user) 267 276 { 268 277 $this->user_model->delete('Users',array('id'=>$user)); 269 278 } 270 279 271 280 flashMsg('success',$this->lang->line('userlib_user_deleted')); 272 281 redirect('auth/admin/members','location'); trunk/user_guide/general/changelog.html
r146 r150 68 68 <h3>Bug Fixes</h3> 69 69 <ul> 70 <li>Fixed bug where if no user profile fields are created but the user profiles are turned on, it would error saying "Must you set method" when trying to save a edited user account, See <a href="http://trac2.assembla.com/backendpro/ticket/51">Bug #51</a></li> 70 71 <li>Fixed bug with <strong>unserialize() Spamming logs with errors</strong>, See <a href="http://trac2.assembla.com/backendpro/ticket/37">Bug #37</a></li> 71 72 </ul>