コード例 #1
0
ファイル: score.php プロジェクト: ratbird/hope
 /**
  * Displays the global ranking list.
  *
  * @param int $page Page of the ranking list to be displayed.
  */
 public function index_action($page = 1)
 {
     $vis_query = get_vis_query('b');
     // Calculate offsets
     $max_per_page = get_config('ENTRIES_PER_PAGE');
     if ($page < 1) {
         $page = 1;
     }
     $offset = max(0, ($page - 1) * $max_per_page);
     // Liste aller die mutig (oder eitel?) genug sind
     $query = "SELECT SQL_CALC_FOUND_ROWS a.user_id,username,score,geschlecht, {$GLOBALS['_fullname_sql']['full']} AS fullname\n                  FROM user_info AS a\n                  LEFT JOIN auth_user_md5 AS b USING (user_id)\n                  WHERE score > 0 AND locked = 0 AND {$vis_query}\n                  ORDER BY score DESC\n                  LIMIT " . (int) $offset . "," . (int) $max_per_page;
     $result = DBManager::get()->fetchAll($query);
     $count = DBManager::get()->fetchColumn("SELECT FOUND_ROWS()");
     $persons = array();
     foreach ($result as $row) {
         $row['is_king'] = StudipKing::is_king($row['user_id'], true);
         $persons[$row['user_id']] = $row;
     }
     $persons = Score::getScoreContent($persons);
     $this->persons = array_values($persons);
     $this->numberOfPersons = $count;
     $this->page = $page;
     $this->offset = $offset;
     $this->max_per_page = $max_per_page;
     $this->current_user = User::findCurrent();
     $this->current_user_score = Score::getMyScore($this->current_user);
     // Set up sidebar and helpbar
     $sidebar = Sidebar::get();
     $sidebar->setImage('sidebar/medal-sidebar.png');
     $actions = new OptionsWidget();
     $actions->addCheckbox(_('Ihren Wert veröffentlichen'), $this->current_user->score, $this->url_for('score/publish'), $this->url_for('score/unpublish'));
     $sidebar->addWidget($actions);
     $helpbar = Helpbar::get();
 }