* Constructor
* @param object $context the context this table relates to.
* @param object $user the user we are generating the results for.
- * @param string $contextname print_context_name($context) - to save recomputing.
+ * @param string $contextname $context->get_context_name() - to save recomputing.
*/
public function __construct($context, $user, $contextname) {
parent::__construct($context, 'explaincaps');
/**
* Constructor.
* @param context $context the context this table relates to.
- * @param string $contextname print_context_name($context) - to save recomputing.
+ * @param string $contextname $context->get_context_name() - to save recomputing.
* @param array $allowoverrides
* @param array $allowsafeoverrides
* @param array $overridableroles
$mform->addElement('hidden', 'bui_parentcontextid', $parentcontext->id);
$mform->setType('bui_parentcontextid', PARAM_INT);
- $mform->addElement('static', 'bui_homecontext', get_string('createdat', 'block'), print_context_name($parentcontext));
+ $mform->addElement('static', 'bui_homecontext', get_string('createdat', 'block'), $parentcontext->get_context_name());
$mform->addHelpButton('bui_homecontext', 'createdat', 'block');
// For pre-calculated (fixed) pagetype lists
// module context doesn't have child contexts, so display in current context only
$mform->addElement('hidden', 'bui_contexts', BUI_CONTEXTS_CURRENT);
} else {
- $parentcontextname = print_context_name($parentcontext);
+ $parentcontextname = $parentcontext->get_context_name();
$contextoptions[BUI_CONTEXTS_CURRENT] = get_string('showoncontextonly', 'block', $parentcontextname);
$contextoptions[BUI_CONTEXTS_CURRENT_SUBS] = get_string('showoncontextandsubs', 'block', $parentcontextname);
$mform->addElement('select', 'bui_contexts', get_string('contexts', 'block'), $contextoptions);
$isfrontpage = ($context->contextlevel == CONTEXT_COURSE && $context->instanceid == SITEID);
-$contextname = print_context_name($context);
+$contextname = $context->get_context_name();
if ($context->contextlevel == CONTEXT_COURSECAT) {
$heading = "$SITE->fullname: ".get_string("categories");
return true;
}
-/**
- * Prints human readable context identifier.
- *
- * @deprecated since 2.2
- * @param context $context the context.
- * @param boolean $withprefix whether to prefix the name of the context with the
- * type of context, e.g. User, Course, Forum, etc.
- * @param boolean $short whether to user the short name of the thing. Only applies
- * to course contexts
- * @return string the human readable context name.
- */
-function print_context_name(context $context, $withprefix = true, $short = false) {
- return $context->get_context_name($withprefix, $short);
-}
-
/**
* Get a URL for a context, if there is a natural one. For example, for
* CONTEXT_COURSE, this is the course page. For CONTEXT_USER it is the
break;
case CONTEXT_MODULE:
$filterparam = 'modid';
- $strlevel = print_context_name($context);
+ $strlevel = $context->get_context_name();
break;
case CONTEXT_USER:
$filterparam = 'userid';
debugging('get_contextlevel_name() is deprecated, please use context_helper::get_level_name() instead.', DEBUG_DEVELOPER);
return context_helper::get_level_name($contextlevel);
}
+
+/**
+ * Prints human readable context identifier.
+ *
+ * @deprecated since 2.2
+ * @see context::get_context_name()
+ * @param context $context the context.
+ * @param boolean $withprefix whether to prefix the name of the context with the
+ * type of context, e.g. User, Course, Forum, etc.
+ * @param boolean $short whether to user the short name of the thing. Only applies
+ * to course contexts
+ * @return string the human readable context name.
+ */
+function print_context_name(context $context, $withprefix = true, $short = false) {
+ debugging('print_context_name() is deprecated, please use $context->get_context_name() instead.', DEBUG_DEVELOPER);
+ return $context->get_context_name($withprefix, $short);
+}
protected function load_block_settings() {
global $CFG;
- $blocknode = $this->add(print_context_name($this->context));
+ $blocknode = $this->add($this->context->get_context_name());
$blocknode->force_open();
// Assign local roles
protected function load_category_settings() {
global $CFG;
- $categorynode = $this->add(print_context_name($this->context), null, null, null, 'categorysettings');
+ $categorynode = $this->add($this->context->get_context_name(), null, null, null, 'categorysettings');
$categorynode->force_open();
$onmanagepage = $this->page->url->compare(new moodle_url('/course/manage.php'), URL_MATCH_BASE);
$summary = '';
$summary .= 'General type: ' . $this->pagelayout . '. ';
if (!during_initial_install()) {
- $summary .= 'Context ' . print_context_name($this->_context) . ' (context id ' . $this->_context->id . '). ';
+ $summary .= 'Context ' . $this->context->get_context_name() . ' (context id ' . $this->_context->id . '). ';
}
$summary .= 'Page type ' . $this->pagetype . '. ';
if ($this->subpage) {
}
if (!$rescueqcategory = question_save_from_deletion(
array_keys($questionids), $parentcontextid,
- print_context_name($context), $rescueqcategory)) {
+ $context->get_context_name(), $rescueqcategory)) {
return false;
}
$feedbackdata[] = array($category->name,
array('contextid'=>$context->id));
if ($feedback) {
$a = new stdClass();
- $a->oldplace = print_context_name($context);
- $a->newplace = print_context_name($newcontext);
+ $a->oldplace = $context->get_context_name();
+ $a->newplace = $newcontext->get_context_name();
echo $OUTPUT->notification(
get_string('movedquestionsandcategories', 'question', $a), 'notifysuccess');
}
array('contextid' => $context->id))) {
// Otherwise, we need to make one
$category = new stdClass();
- $contextname = print_context_name($context, false, true);
+ $contextname = $context->get_context_name(false, true);
$category->name = get_string('defaultfor', 'question', $contextname);
$category->info = get_string('defaultinfofor', 'question', $contextname);
$category->contextid = $context->id;
$context = context_course::instance($testcourses[2]);
$name = print_context_name($context);
+ $this->assertDebuggingCalled('print_context_name() is deprecated, please use $context->get_context_name() instead.', DEBUG_DEVELOPER);
$this->assertFalse(empty($name));
$url = get_context_url($coursecontext);
* context_moved() is deprecated, please use context::update_moved().
* context_instance_preload() is deprecated, please use context_helper::preload_from_record().
* get_contextlevel_name() is deprecated, please use context_helper::get_level_name().
+* print_context_name() is deprecated, please use $context->get_context_name().
=== 2.5.1 ===
} else if ($this->exporter->get('formatclass') == PORTFOLIO_FORMAT_LEAP2A) {
$leapwriter = $this->exporter->get('format')->leap2a_writer();
$entry = new portfolio_format_leap2a_entry($this->area . $this->cmid,
- print_context_name($context),
+ $context->get_context_name(),
'resource',
$html);
// If we have multiple files, they should be grouped together into a folder.
$entry = new portfolio_format_leap2a_entry($baseid . 'group',
- print_context_name($context),
+ $context->get_context_name(),
'selection');
$leapwriter->add_entry($entry);
$leapwriter->make_selection($entry, $entryids, 'Folder');
if (($this->parentlist->nextlist !== null) && $last && $toplevel && (count($this->parentlist->items)>1)){
$url = new moodle_url($this->parentlist->pageurl, array('movedowncontext'=>$this->id, 'tocontext'=>$this->parentlist->nextlist->context->id, 'sesskey'=>sesskey()));
$this->icons['down'] = $this->image_icon(
- get_string('shareincontext', 'question', print_context_name($this->parentlist->nextlist->context)), $url, 'down');
+ get_string('shareincontext', 'question', $this->parentlist->nextlist->context->get_context_name()), $url, 'down');
}
if (($this->parentlist->lastlist !== null) && $first && $toplevel && (count($this->parentlist->items)>1)){
$url = new moodle_url($this->parentlist->pageurl, array('moveupcontext'=>$this->id, 'tocontext'=>$this->parentlist->lastlist->context->id, 'sesskey'=>sesskey()));
$this->icons['up'] = $this->image_icon(
- get_string('shareincontext', 'question', print_context_name($this->parentlist->lastlist->context)), $url, 'up');
+ get_string('shareincontext', 'question', $this->parentlist->lastlist->context->get_context_name()), $url, 'up');
}
}
$listhtml = $list->to_html(0, array('str'=>$this->str));
if ($listhtml){
echo $OUTPUT->box_start('boxwidthwide boxaligncenter generalbox questioncategories contextlevel' . $list->context->contextlevel);
- echo $OUTPUT->heading(get_string('questioncatsfor', 'question', print_context_name(context::instance_by_id($context))), 3);
+ $fullcontext = context::instance_by_id($context);
+ echo $OUTPUT->heading(get_string('questioncatsfor', 'question', $fullcontext->get_context_name()), 3);
echo $listhtml;
echo $OUTPUT->box_end();
}
$role->name = $role->localname;
$context = context::instance_by_id($role->contextid);
$role->name = role_get_name($role, $context, ROLENAME_BOTH);
- $role->contextname = print_context_name($context);
+ $role->contextname = $context->get_context_name();
$role->url = "$CFG->wwwroot/$CFG->admin/roles/override.php?contextid=$role->contextid&roleid=$role->id";
$links[] = '<li>'.get_string('check_riskbackup_editoverride', 'report_security', $role).'</li>';
}
$context = context::instance_by_id($user->contextid);
$url = "$CFG->wwwroot/$CFG->admin/roles/assign.php?contextid=$user->contextid&roleid=$user->roleid";
$a = (object)array('fullname'=>fullname($user), 'url'=>$url, 'email'=>$user->email,
- 'contextname'=>print_context_name($context));
+ 'contextname'=>$context->get_context_name());
$users[] = '<li>'.get_string('check_riskbackup_unassign', 'report_security', $a).'</li>';
}
if (!empty($users)) {