Select Git revision
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
-
Closes #853 Merge request studip/studip!1191
Closes #853 Merge request studip/studip!1191
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
overview.php 4.06 KiB
<?php
require_once __DIR__ . '/consultation_controller.php';
/**
* Overview/Student controller for the consultation app.
*
* @author Jan-Hendrik Willms <tleilax+studip@gmail.com>
* @license GPL2 or any later version
* @since Stud.IP 4.3
*/
class Consultation_OverviewController extends ConsultationController
{
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
if (!$this->range) {
return;
}
if ($this->range->isEditableByUser()) {
$this->redirect('consultation/admin');
return;
}
PageLayout::setTitle(sprintf(
'%s: %s',
$this->getConsultationTitle(),
$this->range->getFullName()
));
}
public function index_action($page = 0)
{
$this->activateNavigation('overview');
$this->setupSidebar();
$this->count = ConsultationBlock::countByRange($this->range);
$this->limit = Config::get()->ENTRIES_PER_PAGE;
if ($page >= ceil($this->count / $this->limit)) {
$page = 0;
}
$this->page = max($page, 0);
$this->blocks = ConsultationBlock::findbyRange(
$this->range,
"ORDER BY start ASC LIMIT " . ($this->page * $this->limit) . ", {$this->limit}"
);
$action = $GLOBALS['user']->cfg->CONSULTATION_SHOW_GROUPED ? 'index' : 'ungrouped';
$this->render_action($action);
}
public function booked_action($page = 0)
{
$this->activateNavigation('booked');
$this->slots = ConsultationSlot::findOccupiedSlotsByUserAndRange(
$GLOBALS['user']->id,
$this->range
);
}
public function book_action($block_id, $slot_id)
{
$this->slot = $this->loadSlot($block_id, $slot_id);
if (Request::isPost()) {
CSRFProtection::verifyUnsafeRequest();