コード例 #1
0
ファイル: users.php プロジェクト: mewsop/Ushahidi_Web
 function index()
 {
     $this->template->content = new View('admin/users');
     $this->template->js = new View('admin/users_js');
     // Check, has the form been submitted, if so, setup validation
     if ($_POST) {
         $post = Validation::factory(array_merge($_POST, $_FILES));
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // As far as I know, the only time we submit a form here is to delete a user
         if ($post->action == 'd') {
             // We don't want to delete the first user
             if ($post->user_id_action != 1) {
                 // Delete the user
                 $user = ORM::factory('user', $post->user_id_action)->delete();
                 // Remove the roles assigned to the now deleted user to clean up
                 $roles_user_model = new Roles_User_Model();
                 $roles_user_model->delete_role($post->user_id_action);
             }
             $form_saved = TRUE;
             $form_action = strtoupper(Kohana::lang('ui_admin.deleted'));
         }
     }
     // Pagination
     $pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => (int) Kohana::config('settings.items_per_page_admin'), 'total_items' => ORM::factory('user')->count_all()));
     $users = ORM::factory('user')->orderby('name', 'asc')->find_all((int) Kohana::config('settings.items_per_page_admin'), $pagination->sql_offset);
     // Set the flag for displaying the roles link
     $this->template->content->display_roles = $this->display_roles;
     $this->template->content->pagination = $pagination;
     $this->template->content->total_items = $pagination->total_items;
     $this->template->content->users = $users;
 }
コード例 #2
0
ファイル: admin.php プロジェクト: kjgarza/ushahidi
 /**
  * Generate User Sub Tab Menus
  * @param object $user
  * @return bool TRUE if has any permission to access anything. FALSE if not (essentially login only level)
  */
 public static function admin_access($user = FALSE)
 {
     if ($user !== FALSE) {
         foreach ($user->roles as $user_role) {
             // If any of the users roles allows them to access anything, put them on the admin page,
             //	 otherwise send them to the front end.
             if (Roles_User_Model::role_allow_admin($user_role->id) == TRUE) {
                 return TRUE;
             }
         }
     }
     return FALSE;
 }