From 77aca6d5b097eb09533b867e355fbc0233448677 Mon Sep 17 00:00:00 2001 From: Artem Andreev Date: Sat, 21 Jul 2012 14:13:37 +0400 Subject: [PATCH] PHP strict fixes --- add_form.php | 28 ++++++++++++++-------------- duration_form.php | 4 ++-- export_form.php | 4 ++-- locallib.php | 14 ++++---------- renderables.php | 2 -- sessions.php | 4 +++- update_form.php | 4 ++-- 7 files changed, 27 insertions(+), 33 deletions(-) diff --git a/add_form.php b/add_form.php index 849b86d..3ce9fa5 100644 --- a/add_form.php +++ b/add_form.php @@ -47,8 +47,8 @@ class mod_attforblock_add_form extends moodleform { break; case VISIBLEGROUPS: $radio=array(); - $radio[] = &MoodleQuickForm::createElement('radio', 'sessiontype', '', get_string('commonsession','attforblock'), attforblock::SESSION_COMMON); - $radio[] = &MoodleQuickForm::createElement('radio', 'sessiontype', '', get_string('groupsession','attforblock'), attforblock::SESSION_GROUP); + $radio[] = &$mform->createElement('radio', 'sessiontype', '', get_string('commonsession','attforblock'), attforblock::SESSION_COMMON); + $radio[] = &$mform->createElement('radio', 'sessiontype', '', get_string('groupsession','attforblock'), attforblock::SESSION_GROUP); $mform->addGroup($radio, 'sessiontype', get_string('sessiontype','attforblock'), ' ', false); $mform->addHelpButton('sessiontype', 'sessiontype', 'attforblock'); $mform->setDefault('sessiontype', attforblock::SESSION_COMMON); @@ -90,8 +90,8 @@ class mod_attforblock_add_form extends moodleform { $minutes[$i] = sprintf("%02d",$i); } $durtime = array(); - $durtime[] =& MoodleQuickForm::createElement('select', 'hours', get_string('hour', 'form'), $hours, false, true); - $durtime[] =& MoodleQuickForm::createElement('select', 'minutes', get_string('minute', 'form'), $minutes, false, true); + $durtime[] =& $mform->createElement('select', 'hours', get_string('hour', 'form'), $hours, false, true); + $durtime[] =& $mform->createElement('select', 'minutes', get_string('minute', 'form'), $minutes, false, true); $mform->addGroup($durtime, 'durtime', get_string('duration','attforblock'), array(' '), true); $mform->addElement('date_selector', 'sessionenddate', get_string('sessionenddate','attforblock')); @@ -99,24 +99,24 @@ class mod_attforblock_add_form extends moodleform { $sdays = array(); if ($CFG->calendar_startwday === '0') { //week start from sunday - $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Sun', '', get_string('sunday','calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Sun', '', get_string('sunday','calendar')); } - $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Mon', '', get_string('monday','calendar')); - $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Tue', '', get_string('tuesday','calendar')); - $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Wed', '', get_string('wednesday','calendar')); - $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Thu', '', get_string('thursday','calendar')); - $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Fri', '', get_string('friday','calendar')); - $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Sat', '', get_string('saturday','calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Mon', '', get_string('monday','calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Tue', '', get_string('tuesday','calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Wed', '', get_string('wednesday','calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Thu', '', get_string('thursday','calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Fri', '', get_string('friday','calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Sat', '', get_string('saturday','calendar')); if ($CFG->calendar_startwday !== '0') { //week start from sunday - $sdays[] =& MoodleQuickForm::createElement('checkbox', 'Sun', '', get_string('sunday','calendar')); + $sdays[] =& $mform->createElement('checkbox', 'Sun', '', get_string('sunday','calendar')); } $mform->addGroup($sdays, 'sdays', get_string('sessiondays','attforblock'), array(' '), true); $mform->disabledIf('sdays', 'addmultiply', 'notchecked'); $period = array(1=>1,2,3,4,5,6,7,8); $periodgroup = array(); - $periodgroup[] =& MoodleQuickForm::createElement('select', 'period', '', $period, false, true); - $periodgroup[] =& MoodleQuickForm::createElement('static', 'perioddesc', '', get_string('week','attforblock')); + $periodgroup[] =& $mform->createElement('select', 'period', '', $period, false, true); + $periodgroup[] =& $mform->createElement('static', 'perioddesc', '', get_string('week','attforblock')); $mform->addGroup($periodgroup, 'periodgroup', get_string('period','attforblock'), array(' '), false); $mform->disabledIf('periodgroup', 'addmultiply', 'notchecked'); diff --git a/duration_form.php b/duration_form.php index 6b4c810..0403b93 100644 --- a/duration_form.php +++ b/duration_form.php @@ -37,8 +37,8 @@ class mod_attforblock_duration_form extends moodleform { for ($i=0; $i<60; $i+=5) { $minutes[$i] = sprintf("%02d",$i); } - $durselect[] =& MoodleQuickForm::createElement('select', 'hours', '', $hours); - $durselect[] =& MoodleQuickForm::createElement('select', 'minutes', '', $minutes, false, true); + $durselect[] =& $mform->createElement('select', 'hours', '', $hours); + $durselect[] =& $mform->createElement('select', 'minutes', '', $minutes, false, true); $mform->addGroup($durselect, 'durtime', get_string('newduration','attforblock'), array(' '), true); $mform->addElement('hidden', 'ids', $ids); diff --git a/export_form.php b/export_form.php index 1d61008..0a91d81 100644 --- a/export_form.php +++ b/export_form.php @@ -43,8 +43,8 @@ class mod_attforblock_export_form extends moodleform { $mform->addElement('select', 'group', get_string('group'), $grouplist); $ident = array(); - $ident[] =& MoodleQuickForm::createElement('checkbox', 'id', '', get_string('studentid', 'attforblock')); - $ident[] =& MoodleQuickForm::createElement('checkbox', 'uname', '', get_string('username')); + $ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attforblock')); + $ident[] =& $mform->createElement('checkbox', 'uname', '', get_string('username')); $mform->addGroup($ident, 'ident', get_string('identifyby','attforblock'), array('
'), true); $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); diff --git a/locallib.php b/locallib.php index 7782128..26a68ff 100644 --- a/locallib.php +++ b/locallib.php @@ -231,7 +231,7 @@ class att_page_with_filter_controls { } private function calc_sessgroupslist_sesstype() { - global $USER, $SESSION; + global $SESSION; if (!array_key_exists('attsessiontype', $SESSION)) { $SESSION->attsessiontype = array($this->cm->course => self::SESSTYPE_ALL); @@ -277,7 +277,7 @@ class att_page_with_filter_controls { } private function calc_sessgroupslist() { - global $PAGE; + global $USER, $PAGE; $this->sessgroupslist = array(); $groupmode = groups_get_activity_groupmode($this->cm); @@ -533,7 +533,7 @@ class attforblock { $this->cm = $cm; $this->course = $course; if (is_null($context)) { - $this->context = get_context_instance(CONTEXT_MODULE, $this->cm->id); + $this->context = context_module::instance_by_id($this->cm->id); } else { $this->context = $context; } @@ -803,7 +803,7 @@ class attforblock { } } - $rec = new object(); + $rec = new stdClass(); $rec->id = $this->pageparams->sessionid; $rec->lasttaken = $now; $rec->lasttakenby = $USER->id; @@ -886,8 +886,6 @@ class attforblock { } public function get_statuses($onlyvisible = true) { - global $DB; - if (!isset($this->statuses)) { $this->statuses = att_get_statuses($this->id, $onlyvisible); } @@ -937,8 +935,6 @@ class attforblock { } public function get_user_stat($userid) { - global $DB; - $ret = array(); $ret['completed'] = $this->get_user_taken_sessions_count($userid); $ret['statuses'] = $this->get_user_statuses_stat($userid); @@ -947,8 +943,6 @@ class attforblock { } public function get_user_taken_sessions_count($userid) { - global $DB; - if (!array_key_exists($userid, $this->usertakensesscount)) $this->usertakensesscount[$userid] = att_get_user_taken_sessions_count($this->id, $this->course->startdate, $userid); diff --git a/renderables.php b/renderables.php index 99e9b9d..16fe825 100644 --- a/renderables.php +++ b/renderables.php @@ -210,8 +210,6 @@ class attforblock_manage_data implements renderable { * @param attforblock $att instance */ public function __construct(attforblock $att) { - global $DB; - $this->perm = $att->perm; $this->sessions = $att->get_filtered_sessions(); diff --git a/sessions.php b/sessions.php index 679dabb..f2067fa 100644 --- a/sessions.php +++ b/sessions.php @@ -207,7 +207,8 @@ function construct_sessions_data_for_add($formdata) { while ($sdate < $enddate) { if($sdate < $startweek + WEEKSECS) { $dinfo = usergetdate($sdate); - if(key_exists($wdaydesc[$dinfo['wday']], $formdata->sdays)) { + if(array_key_exists($wdaydesc[$dinfo['wday']], $formdata->sdays)) { + $sess = new stdClass(); $sess->sessdate = usergetmidnight($sdate) + $starttime; $sess->duration = $duration; $sess->descriptionitemid = $formdata->sdescription['itemid']; @@ -224,6 +225,7 @@ function construct_sessions_data_for_add($formdata) { } } } else { + $sess = new stdClass(); $sess->sessdate = $formdata->sessiondate; $sess->duration = $duration; $sess->descriptionitemid = $formdata->sdescription['itemid']; diff --git a/update_form.php b/update_form.php index 1ca26d4..4425c41 100644 --- a/update_form.php +++ b/update_form.php @@ -50,8 +50,8 @@ class mod_attforblock_update_form extends moodleform { for ($i=0; $i<60; $i+=5) { $minutes[$i] = sprintf("%02d",$i); } - $durselect[] =& MoodleQuickForm::createElement('select', 'hours', '', $hours); - $durselect[] =& MoodleQuickForm::createElement('select', 'minutes', '', $minutes, false, true); + $durselect[] =& $mform->createElement('select', 'hours', '', $hours); + $durselect[] =& $mform->createElement('select', 'minutes', '', $minutes, false, true); $mform->addGroup($durselect, 'durtime', get_string('duration','attforblock'), array(' '), true); $mform->addElement('editor', 'sdescription', get_string('description', 'attforblock'), null, $defopts);