<?php


  $TABLE_HEADLINE = lang("tab_adminboard");
  $FORUMS_HEADLINE = lang("tab_adminforums");
  $USERS_HEADLINE = lang("tab_adminusers");
  $USERRANKS_HEADLINE = lang("tab_adminuserranks");
  
  $LINK_BOARD = ($board_config->seo ? "$main_path/sbb-admin.html" : "$main_script?todo=admin");
  $LINK_FORUMS = ($board_config->seo ? "$main_path/sbb-admin-forums.html" : "$main_script?todo=adminforums");
  $LINK_USERS = ($board_config->seo ? "$main_path/sbb-admin-users.html" : "$main_script?todo=adminusers");
  $LINK_USERRANKS = ($board_config->seo ? "$main_path/sbb-admin-userranks.html" : "$main_script?todo=adminuserranks");

  $sbb_add2title .= " - " . he(lang("tab_adminuserranks"));
  
  $BACK = lang("back");
  $DESCR_RANK = lang("descr_rank");
  $DESCR_IMG = lang("descr_rank_img");
  $DESCR_USERS = lang("descr_users");
  $IMG_DELTITLE = lang("del_rank");
  $IMG_EDITTITLE = lang("edit_rank");

  /**********
   * List all ranks [+]
   **********/
    if (!$section) {
      $TEMPLATE_FLAGS["SHOWRANKS"] = true;
      
      $ADDRANK = lang("addrank");
    
      $ranks = $SBBUserranks->RankList();
       
      $DEFINED_USERRANKS_HEADLINE = lang("savedranks");
      
      $CONFIRM_DELRANK = lang("confirm_delrank");
       
      if ($SBBUserranks->count) {
        for ($i=0;$i<$SBBUserranks->count;$i++) {
          $rank = $ranks[$i];
          $RANKS[] = array("RANK_ID" => $rank->id,
                           "RANK_DESCR" => $rank->descr,
                           "RANK_IMG" => "$rel_path/images/ranks/" . $rank->img,
                           "RANK_USERS" => intval($rank->users)
                           );
        }
      } else {
        $NO_RANKS_DEFINED = lang("no_ranks_defined");
      }
    }
  /**********
   * List all ranks [-]
   **********/     
  
  
  
  
  
  /**********
   * Edit single rank [+]
   **********/     
    if ($section == "edit") {
      $TEMPLATE_FLAGS["EDITRANK"] = true;
      $rank_id = intval($_REQUEST["rank_id"]);
      $this_rank = $SBBUserranks->GetRank($rank_id);
      
      $EDIT_RANK_HEADLINE = lang($rank_id ? "hl_edit_rank" : "hl_create_rank");
      $DESCR_SAVE = lang("save_settings");
      
      if (!$action && $this_rank) {
        $descr = $this_rank->descr;
        $img = $this_rank->img;
      }
      $FORM_VAL_RANK_ID = $rank_id;
      $FORM_VAL_RANK_DESCR = he($descr);
      $FORM_VAL_RANK_IMG = ($img ? "$rel_path/images/ranks/$img" : "");        
      $IMG_RANK_SRC = ($img ? "$rel_path/images/ranks/$img" : "$rel_path/images/spacer.png");  
      
      $DESCR_SELECT_RANK_IMG = lang("select_rank_img");
      
    }
  /**********
   * Edit single rank [-]
   **********/     
  

  /************
   * initiate template and assign variables
   ************/    

  $adminuserranksVARS = array('TABLE_HEADLINE' => $TABLE_HEADLINE,
                              'FORUMS_HEADLINE' => $FORUMS_HEADLINE,
                              'LINK_BOARD' => $LINK_BOARD,
                              'USERS_HEADLINE' => $USERS_HEADLINE,
                              'LINK_USERS' => $LINK_USERS,
                              'REGISTERED_USERS_HEADLINE' => $REGISTERED_USERS_HEADLINE,
                              'LINK_FORUMS' => $LINK_FORUMS,
                              'BACK' => $BACK,
                              'LINK_PAGE_PREFIX' => $LINK_PAGE_PREFIX,
                              'LINK_USERRANKS' => $LINK_USERRANKS,
                              'USERRANKS_HEADLINE' => $USERRANKS_HEADLINE,

                              //listing
                              'ADDRANK' => $ADDRANK,
                              'NO_RANKS_DEFINED' => $NO_RANKS_DEFINED,
                              'DEFINED_USERRANKS_HEADLINE' => $DEFINED_USERRANKS_HEADLINE,
                              'CONFIRM_DELRANK' => $CONFIRM_DELRANK,

                              //modification
                              'DESCR_RANK' => $DESCR_RANK,
                              'DESCR_IMG' => $DESCR_IMG,
                              'EDIT_RANK_HEADLINE' => $EDIT_RANK_HEADLINE,
                              'FORM_VAL_RANK_ID' => $FORM_VAL_RANK_ID,
                              'FORM_VAL_RANK_DESCR' => $FORM_VAL_RANK_DESCR,
                              'FORM_VAL_RANK_IMG' => $FORM_VAL_RANK_IMG,
                              'DESCR_SAVE' => $DESCR_SAVE,
                              'DESCR_SELECT_RANK_IMG' => $DESCR_SELECT_RANK_IMG,
                              'IMG_RANK_SRC' => $IMG_RANK_SRC,
                              'DESCR_USERS' => $DESCR_USERS,
                              'IMG_EDITTITLE' => $IMG_EDITTITLE,
                              'IMG_DELTITLE' => $IMG_DELTITLE,

                              //arrays
                              'CONF' => $GLOBAL_TEMPLATE_VARS,
                              'FLAGS' => $TEMPLATE_FLAGS,
                              'RANKS' => $RANKS,
                              );

  $QuickSkin = new QuickSkin("admin-userranks.html");
  $QuickSkin->assign($adminuserranksVARS);
  $content .= $QuickSkin->result();
  unset($QuickSkin);
      

?>