$this->content->icons = array();
$this->content->footer = '';
- if ($COURSE->id == $this->instance->pageid) {
- $course = $COURSE;
- } else {
- $course = $DB->get_record('course', array('id'=>$this->instance->pageid));
- }
-
- if (empty($course)) {
- return '';
- }
+ $course = $this->page->course;
require_once($CFG->dirroot.'/course/lib.php');
foreach ($modfullnames as $modname => $modfullname) {
if ($modname != 'label') {
- $this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$this->instance->pageid.'">'.$modfullname.'</a>';
+ $this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$course->id.'">'.$modfullname.'</a>';
$this->content->icons[] = '<img src="'.$CFG->modpixpath.'/'.$modname.'/icon.gif" class="icon" alt="" />';
}
}
}
function get_content() {
-
- global $CFG, $USER, $SITE, $COURSE, $DB, $PAGE;
+ global $CFG, $USER, $DB;
if ($this->content !== NULL) {
return $this->content;
$this->content->icons = array();
$this->content->footer = '';
- if (empty($this->instance->pageid)) { // sticky
- if (!empty($COURSE)) {
- $this->instance->pageid = $COURSE->id;
- }
- }
-
- if (empty($this->instance)) {
- return $this->content = '';
- } else if ($this->instance->pageid == SITEID) {
- // return $this->content = '';
- }
-
- if (!empty($this->instance->pageid)) {
- $context = get_context_instance(CONTEXT_COURSE, $this->instance->pageid);
- if ($COURSE->id == $this->instance->pageid) {
- $course = $COURSE;
- } else {
- $course = $DB->get_record('course', array('id'=>$this->instance->pageid));
- }
- } else {
- $context = get_context_instance(CONTEXT_SYSTEM);
- $course = $SITE;
- }
+ $context = $this->page->context;
+ $course = $this->page->course;
if (!has_capability('moodle/course:view', $context)) { // Just return
return $this->content;
}
/// Course editing on/off
-
if ($course->id !== SITEID and has_capability('moodle/course:update', $context)) {
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/edit.gif" class="icon" alt="" />';
- if ($PAGE->user_is_editing()) {
- $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&edit=off&sesskey='.sesskey().'">'.get_string('turneditingoff').'</a>';
+ if ($this->page->user_is_editing()) {
+ $this->content->items[]='<a href="view.php?id='.$course->id.'&edit=off&sesskey='.sesskey().'">'.get_string('turneditingoff').'</a>';
} else {
- $this->content->items[]='<a href="view.php?id='.$this->instance->pageid.'&edit=on&sesskey='.sesskey().'">'.get_string('turneditingon').'</a>';
+ $this->content->items[]='<a href="view.php?id='.$course->id.'&edit=on&sesskey='.sesskey().'">'.get_string('turneditingon').'</a>';
}
- $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/edit.php?id='.$this->instance->pageid.'">'.get_string('settings').'</a>';
+ $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/edit.php?id='.$course->id.'">'.get_string('settings').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/settings.gif" class="icon" alt="" />';
}
/// Assign roles to the course
-
if ($course->id != SITEID) {
if (has_capability('moodle/role:assign', $context)) {
$this->content->items[]='<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id.'">'.get_string('assignroles', 'role').'</a>';
}
if ($reportavailable) {
- $this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/report/index.php?id='.$this->instance->pageid.'">'.get_string('grades').'</a>';
+ $this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/report/index.php?id='.$course->id.'">'.get_string('grades').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" class="icon" alt="" />';
}
}
/// Course outcomes (to help give it more prominence because it's important)
if (!empty($CFG->enableoutcomes)) {
if ($course->id!==SITEID and has_capability('moodle/course:update', $context)) {
- $this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/edit/outcome/course.php?id='.$this->instance->pageid.'">'.get_string('outcomes', 'grades').'</a>';
+ $this->content->items[]='<a href="'.$CFG->wwwroot.'/grade/edit/outcome/course.php?id='.$course->id.'">'.get_string('outcomes', 'grades').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/outcomes.gif" class="icon" alt="" />';
}
}
if ($course->metacourse) {
if (has_capability('moodle/course:managemetacourse', $context)) {
$strchildcourses = get_string('childcourses');
- $this->content->items[]='<a href="importstudents.php?id='.$this->instance->pageid.'">'.$strchildcourses.'</a>';
+ $this->content->items[]='<a href="importstudents.php?id='.$course->id.'">'.$strchildcourses.'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/course.gif" class="icon" alt="" />';
} else if (has_capability('moodle/role:assign', $context)) {
$strchildcourses = get_string('childcourses');
/// Manage groups in this course
-
if (($course->id!==SITEID) && ($course->groupmode || !$course->groupmodeforce) && has_capability('moodle/course:managegroups', $context)) {
$strgroups = get_string('groups');
- $this->content->items[]='<a title="'.$strgroups.'" href="'.$CFG->wwwroot.'/group/index.php?id='.$this->instance->pageid.'">'.$strgroups.'</a>';
+ $this->content->items[]='<a title="'.$strgroups.'" href="'.$CFG->wwwroot.'/group/index.php?id='.$course->id.'">'.$strgroups.'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/group.gif" class="icon" alt="" />';
}
/// Backup this course
-
if ($course->id!==SITEID and has_capability('moodle/site:backup', $context)) {
- $this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.$this->instance->pageid.'">'.get_string('backup').'</a>';
+ $this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.$course->id.'">'.get_string('backup').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" class="icon" alt="" />';
}
/// Restore to this course
if ($course->id !== SITEID and has_capability('moodle/site:restore', $context)) {
- $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'&wdir=/backupdata">'.get_string('restore').'</a>';
+ $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$course->id.'&wdir=/backupdata">'.get_string('restore').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" class="icon" alt="" />';
}
/// Import data from other courses
if ($course->id !== SITEID and has_capability('moodle/site:import', $context)) {
- $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/import.php?id='.$this->instance->pageid.'">'.get_string('import').'</a>';
+ $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/import.php?id='.$course->id.'">'.get_string('import').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" class="icon" alt="" />';
}
/// Reset this course
if ($course->id!==SITEID and has_capability('moodle/course:reset', $context)) {
- $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/reset.php?id='.$this->instance->pageid.'">'.get_string('reset').'</a>';
+ $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/reset.php?id='.$course->id.'">'.get_string('reset').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/return.gif" class="icon" alt="" />';
}
/// View course reports
if ($course->id !== SITEID and has_capability('moodle/site:viewreports', $context)) { // basic capability for listing of reports
- $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/report.php?id='.$this->instance->pageid.'">'.get_string('reports').'</a>';
+ $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/report.php?id='.$course->id.'">'.get_string('reports').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/stats.gif" class="icon" alt="" />';
}
}
if ($questionlink) {
$this->content->items[]='<a href="'.$CFG->wwwroot.'/question/'.$questionlink.
- '?courseid='.$this->instance->pageid.'">'.get_string('questions', 'quiz').'</a>';
+ '?courseid='.$course->id.'">'.get_string('questions', 'quiz').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/questions.gif" class="icon" alt="" />';
}
}
/// Manage files
if ($course->id !== SITEID and has_capability('moodle/course:managefiles', $context)) {
- $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$this->instance->pageid.'">'.get_string('files').'</a>';
+ $this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.$course->id.'">'.get_string('files').'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/files.gif" class="icon" alt=""/>';
}
/// Unenrol link
if (empty($course->metacourse) && ($course->id!==SITEID)) {
if (has_capability('moodle/legacy:guest', $context, NULL, false)) { // Are a guest now
- $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/enrol.php?id='.$this->instance->pageid.'">'.get_string('enrolme', '', format_string($course->shortname)).'</a>';
+ $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/enrol.php?id='.$course->id.'">'.get_string('enrolme', '', format_string($course->shortname)).'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" class="icon" alt="" />';
} else if (has_capability('moodle/role:unassignself', $context, NULL, false) and get_user_roles($context, $USER->id, false)) { // Have some role
- $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/unenrol.php?id='.$this->instance->pageid.'">'.get_string('unenrolme', '', format_string($course->shortname)).'</a>';
+ $this->content->items[]='<a href="'.$CFG->wwwroot.'/course/unenrol.php?id='.$course->id.'">'.get_string('unenrolme', '', format_string($course->shortname)).'</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" class="icon" alt="" />';
}
}
$this->content = new stdClass;
$this->content->footer = '';
- if (empty($this->instance) /*|| empty($CFG->blog_version)*/) {
- // Either we're being asked for content without
- // an associated instance of the Blog module has never been installed.
- $this->content->text = $output;
- return $this->content;
- }
//if ( blog_isLoggedIn() && !isguest() ) {
$courseviewlink = '';
return $this->content;
}
- if (empty($this->instance)) {
- $this->content = '';
- return $this->content;
- }
-
$this->content = new stdClass;
$this->content->text = '';
$this->content->footer = '';
case BLOG_COURSE_LEVEL:
$filtertype = 'course';
- if (isset($COURSE->id)) {
- $filterselect = $COURSE->id;
- } else {
- $filterselect = $this->instance->pageid;
- }
+ $filterselect = $COURSE->id;
break;
default:
$this->content->text = '';
if (empty($this->instance)) { // Overrides: use no course at all
-
$courseshown = false;
$filtercourse = array();
$this->content->footer = '';
}
function specialization() {
- global $COURSE;
- if($this->instance->pagetype == PAGE_COURSE_VIEW && $COURSE->id != SITEID) {
+ if($this->page->pagetype == PAGE_COURSE_VIEW && $PAGE->course->id != SITEID) {
$this->title = get_string('coursesummary', 'block_course_summary');
}
}
return $this->content;
}
- if (!empty($this->instance->pinned) or $this->instance->pagetype === 'course-view') {
+ if ($this->content_is_trusted()) {
// fancy html allowed only on course page and in pinned blocks for security reasons
$filteropt = new stdClass;
$filteropt->noclean = true;
return $this->content;
}
+ function content_is_trusted() {
+ return in_array($this->page->context->contextlevel, array(CONTEXT_COURSE, CONTEXT_COURSECAT, CONTEXT_SYSTEM));
+ }
+
/**
* Will be called before an instance of this block is backed up, so that any links in
* any links in any HTML fields on config can be encoded.
$usehtmleditor = can_use_html_editor();
$text = isset($this->config->text) ? $this->config->text : '';
- if (empty($this->instance->pinned) and $this->instance->pagetype !== 'course-view') {
+ if (!$this->content_is_trusted()) {
$text = clean_text($text, FORMAT_HTML);
}
?>
$this->content = new stdClass;
$this->content->text = '';
$this->content->footer = '';
-
+
if (empty($this->instance) or empty($USER->id) or isguest() or empty($CFG->messaging)) {
return $this->content;
}
*/
var $instance = NULL;
+ /**
+ * The page that this block is appearing on.
+ * @var moodle_page
+ */
+ public $page = NULL;
+
/**
* An object containing the instance configuration information for the current instance of this block.
* @var stdObject $config
*/
function is_empty() {
+ // TODO
if (empty($this->instance->pinned)) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
}
-
+
if ( !has_capability('moodle/block:view', $context) ) {
return true;
}
*/
function _add_edit_controls($options) {
global $CFG, $USER, $PAGE;
-
+
+ // TODO
if (empty($this->instance->pinned)) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
}
-
+
// context for site or course, i.e. participant list etc
// check to see if user can edit site or course blocks.
// blocks can appear on other pages such as mod and blog pages...
- switch ($this->instance->pagetype) {
- case 'course-view':
- if (!has_capability('moodle/site:manageblocks', $context)) {
- return null;
- }
- break;
- default:
-
- break;
+ if (!$this->page->user_can_edit_blocks()) {
+ return null;
}
-
-
+
if (!isset($this->str)) {
$this->str->delete = get_string('delete');
$this->str->moveup = get_string('moveup');
$title = $this->str->show;
}
- if (empty($this->instance->pageid)) {
- $this->instance->pageid = 0;
- }
-
- if (($this->instance->pagetype == $PAGE->pagetype) and $this->instance->pageid == $PAGE->id) {
- $page = $PAGE;
- } else {
- $page = new moodle_page();
- $page->set_pagetype($this->instance->pagetype);
- $page->pageid = $this->instance->pageid;
- }
+ $page = $this->page;
$script = $page->url->out(array('instanceid' => $this->instance->id, 'sesskey' => sesskey()));
- if (empty($this->instance->pinned)) {
- $movebuttons .= '<a class="icon roles" title="'. $this->str->assignroles .'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id.'">' .
- '<img src="'.$CFG->pixpath.'/i/roles.gif" alt="'.$this->str->assignroles.'" /></a>';
- }
-
+ $movebuttons .= '<a class="icon roles" title="'. $this->str->assignroles .'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id.'">' .
+ '<img src="'.$CFG->pixpath.'/i/roles.gif" alt="'.$this->str->assignroles.'" /></a>';
+
if ($this->user_can_edit()) {
$movebuttons .= '<a class="icon hide" title="'. $title .'" href="'.$script.'&blockaction=toggle">' .
'<img src="'. $CFG->pixpath.$icon .'" alt="'.$title.'" /></a>';
* @param block $instance
* @todo add additional documentation to further explain the format of instance and config
*/
- function _load_instance($instance) {
+ function _load_instance($instance, $page) {
if (!empty($instance->configdata)) {
$this->config = unserialize(base64_decode($instance->configdata));
}
// so it won't work correctly. Thus it's commented out.
// unset($instance->configdata);
$this->instance = $instance;
+ $this->page = $page;
$this->specialization();
}
function is_empty() {
+ // TODO
if (empty($this->instance->pinned)) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$context = get_context_instance(CONTEXT_SYSTEM); // pinned blocks do not have own context
}
-
+
if ( !has_capability('moodle/block:view', $context) ) {
return true;
}
// Get context so we can check capabilities.
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
+ // TODO
if (empty($this->instance->pinned)) {
$blockcontext = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
return $this->content;
}
- // the following 3 lines is need to pass _self_test();
- if (empty($this->instance->pageid)) {
- return '';
- }
-
$this->content = new object();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
-
+
/// MDL-13252 Always get the course context or else the context may be incorrect in the user/index.php
- if (!$currentcontext = get_context_instance(CONTEXT_COURSE, $COURSE->id)) {
- $this->content = '';
- return $this->content;
- }
-
+ $currentcontext = $this->page->context;
+
if ($COURSE->id == SITEID) {
if (!has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
$this->content = '';
return $this->content;
}
- if($this->instance->pagetype == 'course-view') {
- // We need to see if we are monitoring a quiz
- $quizid = empty($this->config->quizid) ? 0 : $this->config->quizid;
- $courseid = $this->instance->pageid;
- }
- else {
- // Assuming we are displayed in the quiz view page
- $quizid = $this->instance->pageid;
-
- // A trick to take advantage of instance config and save queries
- if (empty($this->config->courseid)) {
- $modrecord = $DB->get_record('modules', array('name'=>'quiz'));
- $cmrecord = $DB->get_record('course_modules', array('module'=>$modrecord->id, 'instance'=>$quizid));
- $this->config->courseid = intval($cmrecord->course);
- $this->instance_config_commit();
+ if ($this->page->activityname == 'quiz') {
+ $quiz = $this->page->activityrecord;
+ $quizid = $quiz->id;
+ $courseid = $this->page->course->id;
+ $inquiz = true;
+ } else if (!empty($this->config->quizid)) {
+ $quizid = $this->config->quizid;
+ $quiz = $DB->get_record('quiz', array('id' => $quizid));
+ if (empty($quiz)) {
+ $this->content->text = get_string('error_emptyquizrecord', 'block_quiz_results');
+ return $this->content;
}
- $courseid = $this->config->courseid;
+ $courseid = $quiz->course;
+ $inquiz = false;
+ } else {
+ $quizid = 0;
}
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
-
+ $context = $this->page->context;
if (empty($quizid)) {
$this->content->text = get_string('error_emptyquizid', 'block_quiz_results');
return $this->content;
}
- // Get the quiz record
- $quiz = $DB->get_record('quiz', array('id' => $quizid));
- if (empty($quiz)) {
- $this->content->text = get_string('error_emptyquizrecord', 'block_quiz_results');
+ if (empty($this->config->showbest) && empty($this->config->showworst)) {
+ $this->content->text = get_string('configuredtoshownothing', 'block_quiz_results');
return $this->content;
}
return $this->content;
}
- if (empty($this->config->showbest) && empty($this->config->showworst)) {
- $this->content->text = get_string('configuredtoshownothing', 'block_quiz_results');
- return $this->content;
- }
-
$groupmode = NOGROUPS;
$best = array();
$worst = array();
- $nameformat = intval(empty($this->config->nameformat) ? B_QUIZRESULTS_NAME_FORMAT_FULL : $this->config->nameformat);
+ if (!empty($this->config->nameformat)) {
+ $nameformat = $this->config->nameformat;
+ } else {
+ $nameformat = B_QUIZRESULTS_NAME_FORMAT_FULL;
+ }
- if(!empty($this->config->usegroups)) {
- $groupmode = groups_get_activity_groupmode(
- get_coursemodule_from_instance('quiz', $quizid, $courseid), $courseid);
+ if (!empty($this->config->usegroups)) {
+ if ($inquiz) {
+ $cm = $this->page->cm;
+ } else {
+ $cm = get_coursemodule_from_instance('quiz', $quizid, $courseid);
+ }
+ $groupmode = groups_get_activity_groupmode($cm);
}
if (has_capability('moodle/site:accessallgroups', $context) && $groupmode == SEPARATEGROUPS) {
$groupmode = VISIBLEGROUPS;
}
- switch($groupmode) {
+ switch ($groupmode) {
case VISIBLEGROUPS:
// Display group-mode results
$groups = groups_get_all_groups($courseid);
// Find out all the userids which have a submitted grade
$userids = array();
$gradeforuser = array();
- foreach($grades as $grade) {
+ foreach ($grades as $grade) {
$userids[] = $grade->userid;
$gradeforuser[$grade->userid] = (float)$grade->grade;
}
// Collect all the group results we are going to use in $best and $worst
$remaining = $numbest;
$groupgrade = end($groupgrades);
- while($remaining--) {
+ while ($remaining--) {
$best[key($groupgrades)] = $groupgrade['average'];
$groupgrade = prev($groupgrades);
}
$remaining = $numworst;
$groupgrade = reset($groupgrades);
- while($remaining--) {
+ while ($remaining--) {
$worst[key($groupgrades)] = $groupgrade['average'];
$groupgrade = next($groupgrades);
}
// Ready for output!
$gradeformat = intval(empty($this->config->gradeformat) ? B_QUIZRESULTS_GRADE_FORMAT_PCT : $this->config->gradeformat);
- if($this->instance->pagetype != 'mod-quiz-view') {
+ if (!$inquiz) {
// Don't show header and link to the quiz if we ARE at the quiz...
$this->content->text .= '<h1><a href="'.$CFG->wwwroot.'/mod/quiz/view.php?q='.$quizid.'">'.$quiz->name.'</a></h1>';
}
$gradeformat = intval(empty($this->config->gradeformat) ? B_QUIZRESULTS_GRADE_FORMAT_PCT : $this->config->gradeformat);
- if($this->instance->pagetype != 'mod-quiz-view') {
+ if(!$inquiz) {
// Don't show header and link to the quiz if we ARE at the quiz...
$this->content->text .= '<h1><a href="'.$CFG->wwwroot.'/mod/quiz/view.php?q='.$quizid.'">'.$quiz->name.'</a></h1>';
}
<table cellpadding="9" cellspacing="0">
-<?php if($this->instance->pagetype != 'mod-quiz-view') { ?>
+<?php if ($this->page->activityname != 'quiz') { ?>
<tr valign="top">
<td align="right">
<?php print_string('config_select_quiz', 'block_quiz_results') ?>
</td>
<td>
<?php
- $quizzes = $DB->get_records('quiz', array('course'=>$this->instance->pageid), '', 'id, name');
+ $quizzes = $DB->get_records('quiz', array('course' => $this->page->course->id), '', 'id, name');
if(empty($quizzes)) {
echo '<strong>'.get_string('config_no_quizzes_in_course', 'block_quiz_results').'</strong>';
echo '<p><input type="hidden" name="quizid" value="0" /></p>';
?>
</td>
</tr>
-<?php } // end if($this->instance->pagetype != PAGE_QUIZ_VIEW) ?>
+<?php } // end if in quiz ?>
<tr valign="top">
<td align="right">
<?php print_string('config_show_best', 'block_quiz_results') ?>
}
}
+ // TODO
if (empty($this->instance->pinned)) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
}
if (has_capability('block/rss_client:createsharedfeeds', $context)
- || has_capability('block/rss_client:createprivatefeeds', $context)) {
+ || has_capability('block/rss_client:createprivatefeeds', $context)) {
- $page = page_create_object($this->instance->pagetype, $this->instance->pageid);
+ $page = $this->page;
//if ($page->user_allowed_editing()) { // for SUBMITTERS_ALL_ACCOUNT_HOLDERS we're going to run into trouble later if we show it and then they don't have write access to the page.
if (isset($this->config)) {
// This instance is configured - show Add/Edit feeds link.
$id = optional_param('id', SITEID, PARAM_INT);
//create a page object for url_get_full()
-$page = page_create_object($this->instance->pagetype, $this->instance->pageid);
+$page = $this->page;
/// Print tabs at top
print $checkbox . $feedtitle .'<br />'."\n";
}
} else {
+ // TODO
if (empty($this->instance->pinned)) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
} else {
global $act, $url, $rssid, $preferredtitle, $shared;
print '</div></form></div>'; // Closes off page form
+ // TODO
if (empty($this->instance->pinned)) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
global $USER;
$tabs = $row = array();
-
+// TODO
if (empty($this->instance->pinned)) {
$context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
} else {
$this->content->text = '<div class="searchform">';
$this->content->text .= '<form action="'.$CFG->wwwroot.'/mod/forum/search.php" style="display:inline"><fieldset class="invisiblefieldset">';
- $this->content->text .= '<input name="id" type="hidden" value="'.$this->instance->pageid.'" />'; // course
+ $this->content->text .= '<input name="id" type="hidden" value="'.$this->page->course->id.'" />'; // course
$this->content->text .= '<label class="accesshide" for="searchform_search">'.$search.'</label>'.
'<input id="searchform_search" name="search" type="text" size="16" />';
$this->content->text .= '<button id="searchform_button" type="submit" title="'.$search.'">'.$button.'</button><br />';
- $this->content->text .= '<a href="'.$CFG->wwwroot.'/mod/forum/search.php?id='.$this->instance->pageid.'">'.$advancedsearch.'</a>';
+ $this->content->text .= '<a href="'.$CFG->wwwroot.'/mod/forum/search.php?id='.$this->page->course->id.'">'.$advancedsearch.'</a>';
$this->content->text .= helpbutton('search', $advancedsearch, 'moodle', true, false, '', true);
$this->content->text .= '</fieldset></form></div>';
global $DB;
parent::instance_config($instance);
- $course = $DB->get_record('course', array('id'=>$this->instance->pageid));
+ $course = $this->page->course;
if (isset($course->format)) {
if ($course->format == 'topics') {
$this->title = get_string('topics', 'block_section_links');
return $this->content;
}
- if ($this->instance->pageid == $COURSE->id) {
- $course = $COURSE;
- } else {
- $course = $DB->get_record('course', array('id'=>$this->instance->pageid));
- }
+ $course = $this->page->course;
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if ($course->format == 'weeks' or $course->format == 'weekscss') {
}
if (!empty($USER->id)) {
- $display = $DB->get_field('course_display', 'display', array('course'=>$this->instance->pageid, 'userid'=>$USER->id));
+ $display = $DB->get_field('course_display', 'display', array('course'=>$this->page->course->id, 'userid'=>$USER->id));
}
if (!empty($display)) {
- $link = $CFG->wwwroot.'/course/view.php?id='.$this->instance->pageid.'&'.$sectionname.'=';
+ $link = $CFG->wwwroot.'/course/view.php?id='.$this->page->course->id.'&'.$sectionname.'=';
} else {
$link = '#section-';
}
return $this->content;
}
- if ($COURSE->id == $this->instance->pageid) {
- $course = $COURSE;
- } else {
- $course = $DB->get_record('course', array('id'=>$this->instance->pageid));
- }
-
+ $course = $this->page->course;
require_once($CFG->dirroot.'/course/lib.php');
-
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$isediting = $PAGE->user_is_editing() && has_capability('moodle/course:manageactivities', $context);
$modinfo = get_fast_modinfo($course);
return $this->content;
}
-
/// slow & hacky editing mode
- $ismoving = ismoving($this->instance->pageid);
- $section = get_course_section(0, $this->instance->pageid);
+ $ismoving = ismoving($course->id);
+ $section = get_course_section(0, $course->id);
- get_all_mods($this->instance->pageid, $mods, $modnames, $modnamesplural, $modnamesused);
+ get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
$groupbuttons = $course->groupmode;
$groupbuttonslink = (!$course->groupmodeforce);
$this->content->icons[] = '';
}
$instancename = $modinfo->cms[$modnumber]->name;
- $instancename = format_string($instancename, true, $this->instance->pageid);
+ $instancename = format_string($instancename, true, $course->id);
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
if (!empty($modinfo->cms[$modnumber]->extra)) {
$extra = $modinfo->cms[$modnumber]->extra;
return $this->content;
}
- if ($COURSE->id == $this->instance->pageid) {
- $course = $COURSE;
- } else {
- $course = $DB->get_record('course', array('id'=>$this->instance->pageid));
- }
+ $course = $this->page->course;
require_once($CFG->dirroot.'/course/lib.php');
/// slow & hacky editing mode
- $ismoving = ismoving($this->instance->pageid);
- $sections = get_all_sections($this->instance->pageid);
+ $ismoving = ismoving($course->id);
+ $sections = get_all_sections($course->id);
if(!empty($sections) && isset($sections[0])) {
$section = $sections[0];
}
if (!empty($section)) {
- get_all_mods($this->instance->pageid, $mods, $modnames, $modnamesplural, $modnamesused);
+ get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
}
$groupbuttons = $course->groupmode;
$this->content->icons[] = '';
}
$instancename = $modinfo->cms[$modnumber]->name;
- $instancename = format_string($instancename, true, $this->instance->pageid);
+ $instancename = format_string($instancename, true, $course->id);
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
if (!empty($modinfo->cms[$modnumber]->extra)) {
$extra = $modinfo->cms[$modnumber]->extra;
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
BLOCK_R_MAX_WIDTH);
-// Display the blocks and allow blocklib to handle any block action requested
-$pageblocks = blocks_get_by_page($PAGE);
-
-if ($editing) {
- if (!empty($blockaction) && confirm_sesskey()) {
- if (!empty($blockid)) {
- blocks_execute_action($PAGE, $pageblocks, strtolower($blockaction), intval($blockid));
- } else if (!empty($instanceid)) {
- $instance = blocks_find_instance($instanceid, $pageblocks);
- blocks_execute_action($PAGE, $pageblocks, strtolower($blockaction), $instance);
- }
- // This re-query could be eliminated by judicious programming in blocks_execute_action(),
- // but I'm not sure if it's worth the complexity increase...
- $pageblocks = blocks_get_by_page($PAGE);
- }
-}
-
if (!empty($tagid)) {
$taginstance = $DB->get_record('tag', array('id'=>$tagid));
} elseif (!empty($tag)) {