Example #1
0
 function on_settings()
 {
     $table_columns = array('cb' => '<input type="checkbox" />', 'user_login' => __('User Login', WP_CLANWARS_TEXTDOMAIN), 'user_permissions' => __('Permissions', WP_CLANWARS_TEXTDOMAIN));
     $categories_dropdown = wp_dropdown_categories(array('name' => 'category', 'hierarchical' => true, 'show_option_none' => __('None'), 'hide_empty' => 0, 'hide_if_empty' => 0, 'selected' => get_option(WP_CLANWARS_CATEGORY, -1), 'echo' => false));
     $enable_default_styles = get_option(WP_CLANWARS_DEFAULTCSS);
     // hide default styles checkbox on jumpstarter
     $hide_default_styles = $this->is_jumpstarter();
     $games = \WP_Clanwars\Games::get_game('id=all');
     $acl = \WP_Clanwars\ACL::get();
     $acl_keys = \WP_Clanwars\ACL::all_caps();
     $obj = new stdClass();
     $obj->id = 0;
     $obj->title = __('All', WP_CLANWARS_TEXTDOMAIN);
     $obj->abbr = __('All');
     $obj->icon = 0;
     array_unshift($games, $obj);
     $user_acl_info = array();
     foreach ($acl as $user_id => $user_acl) {
         $user = get_userdata($user_id);
         $allowed_games = \WP_Clanwars\ACL::user_can('which_games', false, $user_id);
         $user_games = \WP_Clanwars\Games::get_game(array('id' => $allowed_games, 'orderby' => 'title', 'order' => 'asc'));
         // populate games with urls for icons
         foreach ($user_games as $game) {
             $game->icon_url = wp_get_attachment_url($game->icon);
         }
         $item = new stdClass();
         $item->user = $user;
         $item->user_acl = $user_acl;
         $item->user_games = $user_games;
         $item->allowed_games = $allowed_games;
         array_push($user_acl_info, $item);
     }
     $view = new View('settings');
     $view->add_helper('print_table_header', array($this, 'print_table_header'));
     $context = compact('table_columns', 'games', 'acl_keys', 'user_acl_info', 'categories_dropdown', 'enable_default_styles', 'hide_default_styles');
     $view->render($context);
 }