diff --git a/locallib.php b/locallib.php index 18f9f0e..5d038ec 100644 --- a/locallib.php +++ b/locallib.php @@ -117,71 +117,50 @@ class att_manage_page_params { /** @var int whether sessions end time will be displayed on manage.php */ public $showendtime; - public $studentssort; - - public $studentid; - private $courseid; - public static function create_default() { - $instance = new att_manage_page_params(); - - $instance->view = self::DEFAULT_VIEW; - $instance->curdate = time(); - $instance->showendtime = self::DEFAULT_SHOWENDTIME; - - return $instance; - } - - public function init(att_manage_page_params $view_params, $courseid) { + public function init($courseid) { $this->courseid = $courseid; - - $this->init_view($view_params->view); - - $this->init_curdate($view_params->curdate); - - $this->init_show_endtime($view_params->showendtime); - - $this->studentssort = $view_params->studentssort; - - $this->studentid = $view_params->studentid; - + $this->init_view(); + $this->init_curdate(); + $this->init_show_endtime(); $this->init_start_end_date(); } - private function init_view($view) { + private function init_view() { global $SESSION; - if (isset($view)) { - $SESSION->attcurrentattview[$this->courseid] = $view; - $this->view = $view; + if (isset($this->view)) { + $SESSION->attcurrentattview[$this->courseid] = $this->view; } elseif (isset($SESSION->attcurrentattview[$this->courseid])) { $this->view = $SESSION->attcurrentattview[$this->courseid]; } + else { + $this->view = self::DEFAULT_VIEW; + } } - private function init_curdate($curdate) { + private function init_curdate() { global $SESSION; - if ($curdate) { - $SESSION->attcurrentattdate[$this->courseid] = $curdate; - $this->curdate = $curdate; + if (isset($this->curdate)) { + $SESSION->attcurrentattdate[$this->courseid] = $this->curdate; } elseif (isset($SESSION->attcurrentattdate[$this->courseid])) { $this->curdate = $SESSION->attcurrentattdate[$this->courseid]; } + else { + $this->curdate = time(); + } } - private function init_show_endtime($show_endtime) { - global $SESSION; - - if (isset($show_endtime)) { - set_user_preference("attforblock_showendtime", $show_endtime); - $this->showendtime = $show_endtime; + private function init_show_endtime() { + if (isset($this->show_endtime)) { + set_user_preference("attforblock_showendtime", $this->show_endtime); } else { - $this->showendtime = get_user_preferences("attforblock_showendtime", $this->showendtime); + $this->showendtime = get_user_preferences("attforblock_showendtime", self::DEFAULT_SHOWENDTIME); } } diff --git a/manage.php b/manage.php index 31706d2..b8089d6 100644 --- a/manage.php +++ b/manage.php @@ -12,13 +12,13 @@ require_once(dirname(__FILE__).'/../../config.php'); require_once(dirname(__FILE__).'/locallib.php'); -$view_params = new att_manage_page_params(); +$pageparams = new att_manage_page_params(); -$id = required_param('id', PARAM_INT); -$from = optional_param('from', NULL, PARAM_ACTION); -$view_params ->view = optional_param('view', NULL, PARAM_INT); // which page to show -$view_params ->curdate = optional_param('curdate', NULL, PARAM_INT); -$view_params ->showendtime = optional_param('showendtime', NULL, PARAM_INT); +$id = required_param('id', PARAM_INT); +$from = optional_param('from', NULL, PARAM_ACTION); +$pageparams ->view = optional_param('view', NULL, PARAM_INT); +$pageparams ->curdate = optional_param('curdate', NULL, PARAM_INT); +$pageparams ->showendtime = optional_param('showendtime', NULL, PARAM_INT); $cm = get_coursemodule_from_id('attforblock', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); @@ -26,12 +26,11 @@ $att = $DB->get_record('attforblock', array('id' => $cm->instance), ' require_login($course, true, $cm); -$att = new attforblock($att, $cm, $course, $PAGE->context, att_manage_page_params::create_default()); +$pageparams->init($course->id); +$att = new attforblock($att, $cm, $course, $PAGE->context, $pageparams); if (!$att->perm->can_manage() && !$att->perm->can_take() && !$att->perm->can_change()) redirect("view.php?id=$cm->id"); -$att->pageparams->init($view_params, $course->id); - // if teacher is coming from block, then check for a session exists for today if ($from === 'block') { $atts = $att->get_today_sessions();