Exemple #1
0
 /**
  * Deletes a user
  *
  * @access	public
  * @param	none
  * @return	void
  **/
 public function delete()
 {
     //	Get the user's details
     $_uid = $this->uri->segment(4);
     $_user = $this->user_model->get_by_id($_uid);
     // --------------------------------------------------------------------------
     //	Non-superusers editing superusers is not cool
     if (!$this->user_model->is_superuser() && user_has_permission('superuser', $_user)) {
         $this->session->set_flashdata('error', lang('accounts_edit_error_noteditable'));
         redirect($this->input->get('return_to'));
         return;
     }
     // --------------------------------------------------------------------------
     //	Delete user
     $_user = $this->user_model->get_by_id($_uid);
     if (!$_user) {
         $this->session->set_flashdata('error', lang('accounts_edit_error_unknown_id'));
         redirect($this->input->get('return_to'));
         return;
     }
     // --------------------------------------------------------------------------
     //	Define messages
     if ($this->user_model->destroy($_uid)) {
         $this->session->set_flashdata('success', lang('accounts_delete_success', title_case($_user->first_name . ' ' . $_user->last_name)));
         //	Update admin changelog
         _ADMIN_CHANGE_ADD('deleted', 'a', 'user', $_uid, '#' . number_format($_uid) . ' ' . $_user->first_name . ' ' . $_user->last_name);
     } else {
         $this->session->set_flashdata('error', lang('accounts_delete_error', title_case($_user->first_name . ' ' . $_user->last_name)));
     }
     // --------------------------------------------------------------------------
     redirect($this->input->get('return_to'));
 }
Exemple #2
0
 public function restore()
 {
     //	Fetch and check post
     $_post_id = $this->uri->segment(4);
     // --------------------------------------------------------------------------
     if ($this->blog_post_model->restore($_post_id)) {
         $_post = $this->blog_post_model->get_by_id($_post_id);
         $this->session->set_flashdata('success', '<strong>Success!</strong> Post was restored successfully. ');
         //	Update admin changelog
         _ADMIN_CHANGE_ADD('restored', 'a', 'blog post', $_post_id, $_post->title, 'admin/blog/edit/' . $_post_id);
     } else {
         $this->session->set_flashdata('error', '<strong>Sorry,</strong> I failed to restore that post.');
     }
     redirect('admin/blog');
     return;
 }