本文整理汇总了PHP中get_context_instance函数的典型用法代码示例。如果您正苦于以下问题:PHP get_context_instance函数的具体用法?PHP get_context_instance怎么用?PHP get_context_instance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_context_instance函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setup_page
/**
* Sets up the edit page
*
* @param string $baseurl the base url of the
*
* @return array Array of variables that the page is set up with
*/
public function setup_page($baseurl)
{
global $PAGE, $CFG, $DB;
$this->pagevars = array();
$pageurl = new \moodle_url($baseurl);
$pageurl->remove_all_params();
$id = optional_param('cmid', false, PARAM_INT);
$quizid = optional_param('quizid', false, PARAM_INT);
// get necessary records from the DB
if ($id) {
$cm = get_coursemodule_from_id('activequiz', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$quiz = $DB->get_record('activequiz', array('id' => $cm->instance), '*', MUST_EXIST);
} else {
$quiz = $DB->get_record('activequiz', array('id' => $quizid), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('activequiz', $quiz->id, $course->id, false, MUST_EXIST);
}
$this->get_parameters();
// get the rest of the parameters and set them in the class
if ($CFG->version < 2011120100) {
$this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
} else {
$this->context = \context_module::instance($cm->id);
}
// set up question lib
list($this->pageurl, $this->contexts, $cmid, $cm, $quiz, $this->pagevars) = question_edit_setup('editq', '/mod/activequiz/edit.php', true);
$PAGE->set_url($this->pageurl);
$this->pagevars['pageurl'] = $this->pageurl;
$PAGE->set_title(strip_tags($course->shortname . ': ' . get_string("modulename", "activequiz") . ': ' . format_string($quiz->name, true)));
$PAGE->set_heading($course->fullname);
// setup classes needed for the edit page
$this->RTQ = new \mod_activequiz\activequiz($cm, $course, $quiz, $this->pagevars);
$this->RTQ->get_renderer()->init($this->RTQ, $this->pageurl, $this->pagevars);
}
开发者ID:agarnav,项目名称:moodle-mod_activequiz,代码行数:42,代码来源:edit.php
示例2: definition
function definition()
{
global $CFG;
$mform =& $this->_form;
$syscontext = get_context_instance(CONTEXT_SYSTEM);
$actions = array(0 => get_string('choose') . '...');
if (has_capability('moodle/user:update', $syscontext)) {
$actions[1] = get_string('confirm');
}
if (has_capability('moodle/site:readallmessages', $syscontext) && !empty($CFG->messaging)) {
$actions[2] = get_string('messageselectadd');
}
if (has_capability('moodle/user:delete', $syscontext)) {
$actions[3] = get_string('delete');
}
$actions[4] = get_string('displayonpage');
if (has_capability('moodle/user:update', $syscontext)) {
$actions[5] = get_string('download', 'admin');
}
if (has_capability('moodle/role:assign', $syscontext)) {
$actions[6] = get_string('enrolmultipleusers', 'admin');
}
$objs = array();
$objs[] =& $mform->createElement('select', 'action', null, $actions);
$objs[] =& $mform->createElement('submit', 'doaction', get_string('go'));
$mform->addElement('group', 'actionsgrp', get_string('withselectedusers'), $objs, ' ', false);
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:27,代码来源:user_bulk_forms.php
示例3: callback_weeks_get_section_name
/**
* Gets the name for the provided section.
*
* @param stdClass $course
* @param stdClass $section
* @return string
*/
function callback_weeks_get_section_name($course, $section)
{
// We can't add a node without text
if (!empty($section->name)) {
// Return the name the user set
return format_string($section->name, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
} else {
if ($section->section == 0) {
// Return the section0name
return get_string('section0name', 'format_weeks');
} else {
// Got to work out the date of the week so that we can show it
$sections = get_all_sections($course->id);
$weekdate = $course->startdate + 7200;
foreach ($sections as $sec) {
if ($sec->id == $section->id) {
break;
} else {
if ($sec->section != 0) {
$weekdate += 604800;
}
}
}
$strftimedateshort = ' ' . get_string('strftimedateshort');
$weekday = userdate($weekdate, $strftimedateshort);
$endweekday = userdate($weekdate + 518400, $strftimedateshort);
return $weekday . ' - ' . $endweekday;
}
}
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:37,代码来源:lib.php
示例4: definition_after_data
function definition_after_data()
{
global $CFG;
$mform =& $this->_form;
$courseid = $mform->getElementValue('courseid');
if ($id = $mform->getElementValue('id')) {
$scale = grade_scale::fetch(array('id' => $id));
$used = $scale->is_used();
if ($used) {
$mform->hardFreeze('scale');
}
if (empty($courseid)) {
$mform->hardFreeze('standard');
} else {
if (empty($scale->courseid) and !has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
$mform->hardFreeze('standard');
} else {
if ($used and !empty($scale->courseid)) {
$mform->hardFreeze('standard');
}
}
}
$usedstr = $scale->is_used() ? get_string('yes') : get_string('no');
$used_el =& $mform->getElement('used');
$used_el->setValue($usedstr);
} else {
$mform->removeElement('used');
if (empty($courseid) or !has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
$mform->hardFreeze('standard');
}
}
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:32,代码来源:edit_form.php
示例5: resource_base
/**
* Constructor for the base resource class
*
* Constructor for the base resource class.
* If cmid is set create the cm, course, resource objects.
* and do some checks to make sure people can be here, and so on.
*
* @param cmid integer, the current course module id - not set for new resources
*/
function resource_base($cmid = 0)
{
global $CFG, $COURSE;
$this->navlinks = array();
if ($cmid) {
if (!($this->cm = get_coursemodule_from_id('resource', $cmid))) {
error("Course Module ID was incorrect");
}
if (!($this->course = get_record("course", "id", $this->cm->course))) {
error("Course is misconfigured");
}
if (!($this->resource = get_record("resource", "id", $this->cm->instance))) {
error("Resource ID was incorrect");
}
$this->strresource = get_string("modulename", "resource");
$this->strresources = get_string("modulenameplural", "resource");
if (!$this->cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $this->cm->id))) {
$pagetitle = strip_tags($this->course->shortname . ': ' . $this->strresource);
$navigation = build_navigation($this->navlinks, $this->cm);
print_header($pagetitle, $this->course->fullname, $navigation, "", "", true, '', navmenu($this->course, $this->cm));
notice(get_string("activityiscurrentlyhidden"), "{$CFG->wwwroot}/course/view.php?id={$this->course->id}");
}
} else {
$this->course = $COURSE;
}
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:35,代码来源:lib.php
示例6: useredit_update_picture
/**
* Updates the provided users profile picture based upon the expected fields
* returned from the edit or edit_advanced forms.
*
* @global moodle_database $DB
* @param stdClass $usernew An object that contains some information about the user being updated
* @param moodleform $userform The form that was submitted to edit the form
* @return bool True if the user was updated, false if it stayed the same.
*/
function useredit_update_picture(stdClass $usernew, moodleform $userform)
{
global $CFG, $DB;
require_once "{$CFG->libdir}/gdlib.php";
$context = get_context_instance(CONTEXT_USER, $usernew->id, MUST_EXIST);
$user = $DB->get_record('user', array('id' => $usernew->id), 'id, picture', MUST_EXIST);
$newpicture = $user->picture;
if (!empty($usernew->deletepicture)) {
// The user has chosen to delete the selected users picture
$fs = get_file_storage();
$fs->delete_area_files($context->id, 'user', 'icon');
// drop all images in area
$newpicture = 0;
} else {
if ($iconfile = $userform->save_temp_file('imagefile')) {
// There is a new image that has been uploaded
// Process the new image and set the user to make use of it.
// NOTE: Uploaded images always take over Gravatar
$newpicture = (int) process_new_icon($context, 'user', 'icon', 0, $iconfile);
// Delete the file that has now been processed
@unlink($iconfile);
}
}
if ($newpicture != $user->picture) {
$DB->set_field('user', 'picture', $newpicture, array('id' => $user->id));
return true;
} else {
return false;
}
}
开发者ID:nmicha,项目名称:moodle,代码行数:39,代码来源:editlib.php
示例7: available_courses
/**
* Returns list of courses that we offer to the caller for remote enrolment of their users
*
* Since Moodle 2.0, courses are made available for MNet peers by creating an instance
* of enrol_mnet plugin for the course. Hidden courses are not returned. If there are two
* instances - one specific for the host and one for 'All hosts', the setting of the specific
* one is used. The id of the peer is kept in customint1, no other custom fields are used.
*
* @uses mnet_remote_client Callable via XML-RPC only
* @return array
*/
public function available_courses()
{
global $CFG, $DB;
require_once $CFG->libdir . '/filelib.php';
if (!($client = get_mnet_remote_client())) {
die('Callable via XML-RPC only');
}
// we call our id as 'remoteid' because it will be sent to the peer
// the column aliases are required by MNet protocol API for clients 1.x and 2.0
$sql = "SELECT c.id AS remoteid, c.fullname, c.shortname, c.idnumber, c.summary, c.summaryformat,\n c.sortorder, c.startdate, cat.id AS cat_id, cat.name AS cat_name,\n cat.description AS cat_description, cat.descriptionformat AS cat_descriptionformat,\n e.cost, e.currency, e.roleid AS defaultroleid, r.name AS defaultrolename,\n e.customint1\n FROM {enrol} e\n INNER JOIN {course} c ON c.id = e.courseid\n INNER JOIN {course_categories} cat ON cat.id = c.category\n INNER JOIN {role} r ON r.id = e.roleid\n WHERE e.enrol = 'mnet'\n AND (e.customint1 = 0 OR e.customint1 = ?)\n AND c.visible = 1\n ORDER BY cat.sortorder, c.sortorder, c.shortname";
$rs = $DB->get_recordset_sql($sql, array($client->id));
$courses = array();
foreach ($rs as $course) {
// use the record if it does not exist yet or is host-specific
if (empty($courses[$course->remoteid]) or $course->customint1 > 0) {
unset($course->customint1);
// the client does not need to know this
$context = get_context_instance(CONTEXT_COURSE, $course->remoteid);
// Rewrite file URLs so that they are correct
$course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', false);
$courses[$course->remoteid] = $course;
}
}
$rs->close();
return array_values($courses);
// can not use keys for backward compatibility
}
开发者ID:vuchannguyen,项目名称:web,代码行数:38,代码来源:enrol.php
示例8: __construct
/**
* Constructor - instantiates one object of this class
*/
public function __construct($name, $blockid, $moduleid = null, $plan = null)
{
global $DB;
// Check blockid exists
if (!($block = $DB->get_record('block_instances', array('id' => $blockid)))) {
throw new backup_task_exception('block_task_block_instance_not_found', $blockid);
}
$this->blockid = $blockid;
$this->blockname = $block->blockname;
$this->contextid = get_context_instance(CONTEXT_BLOCK, $this->blockid)->id;
$this->moduleid = $moduleid;
$this->modulename = null;
$this->parentcontextid = null;
// If moduleid passed, check exists, supports moodle2 format and save info
// Check moduleid exists
if (!empty($moduleid)) {
if (!($coursemodule = get_coursemodule_from_id(false, $moduleid))) {
throw new backup_task_exception('block_task_coursemodule_not_found', $moduleid);
}
// Check activity supports this moodle2 backup format
if (!plugin_supports('mod', $coursemodule->modname, FEATURE_BACKUP_MOODLE2)) {
throw new backup_task_exception('block_task_activity_lacks_moodle2_backup_support', $coursemodule->modname);
}
$this->moduleid = $moduleid;
$this->modulename = $coursemodule->modname;
$this->parentcontextid = get_context_instance(CONTEXT_MODULE, $this->moduleid)->id;
}
parent::__construct($name, $plan);
}
开发者ID:vuchannguyen,项目名称:web,代码行数:32,代码来源:backup_block_task.class.php
示例9: get_content
/**
* Content generation method of block; list of page links
**/
function get_content()
{
if ($this->content !== NULL) {
return $this->content;
}
global $CFG, $USER;
$this->content = new stdClass();
$user = CoursePrefsUser::findByUnique($USER->username);
$this->content->icons = array();
$this->content->footer = '';
$this->content->items = array();
$context = get_context_instance(CONTEXT_SYSTEM);
if (has_capability('block/courseprefs:viewdata', $context)) {
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/content_viewer.php">' . get_string('content_viewer', 'block_courseprefs') . '</a>';
}
if (!$user || !$user->isTeacher()) {
$this->content->items[] = get_string('block_request_link', 'block_courseprefs') . " <a href=\"{$CFG->wwwroot}/blocks/courseprefs/request.php\">here</a> to" . ' request a course';
return $this->content;
}
// Removing Links that might break current courses
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/creation_enrol.php">' . get_string('creation_link', 'block_courseprefs') . '</a>';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/split.php">' . get_string('split_link', 'block_courseprefs') . '</a>';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/crosslist.php">' . get_string('crosslist_link', 'block_courseprefs') . '</a>';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/teamteach.php">' . get_string('teamteach_link', 'block_courseprefs') . '</a>';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/materials.php">' . get_string('materials_link', 'block_courseprefs') . '</a>';
$this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/unwanted.php">' . get_string('unwanted_link', 'block_courseprefs') . '</a>';
return $this->content;
}
开发者ID:rrusso,项目名称:EARS,代码行数:31,代码来源:block_courseprefs.php
示例10: get_content
function get_content()
{
global $THEME, $CFG, $USER;
// only for logged in users!
if (!isloggedin() || isguest()) {
return false;
}
// check for outgoing roaming permission first
if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
return '';
}
if ($this->content !== NULL) {
return $this->content;
}
// TODO: Test this query - it's appropriate? It works?
// get the hosts and whether we are doing SSO with them
$sql = "\n SELECT DISTINCT \n h.id, \n h.name,\n h.wwwroot,\n a.name as application,\n a.display_name\n FROM \n {$CFG->prefix}mnet_host h,\n {$CFG->prefix}mnet_application a,\n {$CFG->prefix}mnet_host2service h2s_IDP,\n {$CFG->prefix}mnet_service s_IDP,\n {$CFG->prefix}mnet_host2service h2s_SP,\n {$CFG->prefix}mnet_service s_SP\n WHERE\n h.id != '{$CFG->mnet_localhost_id}' AND\n h.id = h2s_IDP.hostid AND\n h.applicationid = a.id AND\n h2s_IDP.serviceid = s_IDP.id AND\n s_IDP.name = 'sso_idp' AND\n h2s_IDP.publish = '1' AND\n h.id = h2s_SP.hostid AND\n h2s_SP.serviceid = s_SP.id AND\n s_SP.name = 'sso_idp' AND\n h2s_SP.publish = '1'\n ORDER BY\n a.display_name,\n h.name";
$hosts = get_records_sql($sql);
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if ($hosts) {
foreach ($hosts as $host) {
$icon = '<img src="' . $CFG->pixpath . '/i/' . $host->application . '_host.gif"' . ' class="icon" alt="' . get_string('server', 'block_mnet_hosts') . '" />';
$this->content->icons[] = $icon;
if ($host->id == $USER->mnethostid) {
$this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$host->wwwroot}\">" . s($host->name) . "</a>";
} else {
$this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) . "</a>";
}
}
}
return $this->content;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:35,代码来源:block_mnet_hosts.php
示例11: get_init_params
protected function get_init_params($elementid, array $options = null)
{
global $CFG, $PAGE, $OUTPUT;
//TODO: we need to implement user preferences that affect the editor setup too
$directionality = get_string('thisdirection', 'langconfig');
$strtime = get_string('strftimetime');
$strdate = get_string('strftimedaydate');
$lang = current_language();
$contentcss = $PAGE->theme->editor_css_url()->out(false);
$context = empty($options['context']) ? get_context_instance(CONTEXT_SYSTEM) : $options['context'];
$xmedia = 'moodlemedia,';
// HQ thinks it should be always on, so it is no matter if it will actually work or not
/*
if (!empty($options['legacy'])) {
$xmedia = 'moodlemedia,';
} else {
if (!empty($options['noclean']) or !empty($options['trusted'])) {
}
}*/
$filters = filter_get_active_in_context($context);
if (array_key_exists('filter/tex', $filters)) {
$xdragmath = 'dragmath,';
} else {
$xdragmath = '';
}
if (array_key_exists('filter/emoticon', $filters)) {
$xemoticon = 'moodleemoticon,';
} else {
$xemoticon = '';
}
$params = array('mode' => "exact", 'elements' => $elementid, 'relative_urls' => false, 'document_base_url' => $CFG->httpswwwroot, 'content_css' => $contentcss, 'language' => $lang, 'directionality' => $directionality, 'plugin_insertdate_dateFormat ' => $strdate, 'plugin_insertdate_timeFormat ' => $strtime, 'theme' => "advanced", 'skin' => "o2k7", 'skin_variant' => "silver", 'apply_source_formatting' => true, 'remove_script_host' => false, 'entity_encoding' => "raw", 'plugins' => "{$xmedia}advimage,safari,table,style,layer,advhr,advlink,emotions,inlinepopups,searchreplace,paste,directionality,fullscreen,moodlenolink,{$xemoticon}{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak,spellchecker", 'theme_advanced_font_sizes' => "1,2,3,4,5,6,7", 'theme_advanced_layout_manager' => "SimpleLayout", 'theme_advanced_toolbar_align' => "left", 'theme_advanced_buttons1' => "fontselect,fontsizeselect,formatselect", 'theme_advanced_buttons1_add' => "|,undo,redo,|,search,replace,|,fullscreen", 'theme_advanced_buttons2' => "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright", 'theme_advanced_buttons2_add' => "|,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl", 'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,|,image,{$xemoticon}{$xmedia}{$xdragmath}nonbreaking,charmap", 'theme_advanced_buttons3_add' => "table,|,code,spellchecker", 'theme_advanced_fonts' => "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings", 'theme_advanced_resize_horizontal' => true, 'theme_advanced_resizing' => true, 'theme_advanced_toolbar_location' => "top", 'theme_advanced_statusbar_location' => "bottom", 'spellchecker_rpc_url' => $CFG->wwwroot . "/lib/editor/tinymce/tiny_mce/{$this->version}/plugins/spellchecker/rpc.php");
if ($xemoticon) {
$manager = get_emoticon_manager();
$emoticons = $manager->get_emoticons();
$imgs = array();
// see the TinyMCE plugin moodleemoticon for how the emoticon index is (ab)used :-S
$index = 0;
foreach ($emoticons as $emoticon) {
$imgs[$emoticon->text] = $OUTPUT->render($manager->prepare_renderable_emoticon($emoticon, array('class' => 'emoticon emoticon-index-' . $index++)));
}
$params['moodleemoticon_emoticons'] = json_encode($imgs);
}
if (empty($CFG->xmlstrictheaders) and (!empty($options['legacy']) or !empty($options['noclean']) or !empty($options['trusted']))) {
// now deal somehow with non-standard tags, people scream when we do not make moodle code xtml strict,
// but they scream even more when we strip all tags that are not strict :-(
$params['valid_elements'] = 'script[src|type],*[*]';
// for some reason the *[*] does not inlcude javascript src attribute MDL-25836
$params['invalid_elements'] = '';
}
if (empty($options['legacy'])) {
if (isset($options['maxfiles']) and $options['maxfiles'] != 0) {
$params['file_browser_callback'] = "M.editor_tinymce.filepicker";
}
}
//Add onblur event for client side text validation
if (!empty($options['required'])) {
$params['init_instance_callback'] = 'M.editor_tinymce.onblur_event';
}
return $params;
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:60,代码来源:lib.php
示例12: get_content
function get_content()
{
global $CFG, $USER;
if ($this->content !== NULL) {
return $this->content;
}
$content = '';
$footer = '';
$nologin_auths = block_repository_nopasswd_auths();
if (!empty($USER->auth) && in_array($USER->auth, $nologin_auths)) {
return '';
}
if (isloggedin() && file_exists($CFG->dirroot . '/file/repository/alfresco/repository.php')) {
require_once $CFG->dirroot . '/file/repository/repository.class.php';
if (isset($CFG->repository_plugins_enabled) && strstr($CFG->repository_plugins_enabled, 'alfresco')) {
if ($repo = repository_factory::factory('alfresco')) {
if ($repo->alfresco_userdir($USER->username) !== false) {
// Fix username
$username = repository_plugin_alfresco::fix_username($USER->username);
// So that we don't conflict with the default Alfresco admin account.
$username = $username == 'admin' ? $CFG->repository_alfresco_admin_username : $username;
$hastenant = false;
// We must include the tenant portion of the username here.
if (($tenantname = strpos($CFG->repository_alfresco_server_username, '@')) > 0) {
$username .= substr($CFG->repository_alfresco_server_username, $tenantname);
$hastenant = true;
}
// Display a link to access the Alfresco repository directly.
$content .= get_string('webappaccess', 'block_repository', $repo->get_webapp_url()) . '<br /><br />';
// Display a link to the configured embedded WebDAV client (if defined).
if (!empty($CFG->block_course_repository_webdav_client)) {
$content .= get_string('embeddedwebdavlink', 'block_repository', $CFG->block_course_repository_webdav_client) . '<br /><br />';
}
if ($hastenant || $username != $USER->username) {
$content .= get_string('usernametenantinfo', 'block_repository', $username);
} else {
$content .= get_string('usernameinfo', 'block_repository', $username);
}
// Display a link to defined help files
if (!empty($CFG->block_course_repository_help_link)) {
$footer = get_string('helpfileslink', 'block_repository', $CFG->block_course_repository_help_link);
}
}
}
}
}
// If there is no content and the current user can actually modify the site settings, display some text
// in the block explaining what is happening.
if (empty($content) && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
if (file_exists($CFG->dirroot . '/admin/file/repositories.php')) {
$content = get_string('alfresconotconfigured', 'block_repository', $CFG->wwwroot . '/admin/file/' . 'repositories.php');
} else {
$content = get_string('norepositorypluginsystem', 'block_repository');
}
}
$this->content = new stdClass();
$this->content->text = $content;
$this->content->footer = $footer;
return $this->content;
}
开发者ID:remotelearner,项目名称:elis.alfresco,代码行数:60,代码来源:block_repository.php
示例13: __construct
public function __construct(stdClass $options)
{
global $CFG, $USER, $PAGE;
require_once $CFG->dirroot . '/repository/lib.php';
$defaults = array('accepted_types' => '*', 'return_types' => FILE_INTERNAL, 'env' => 'filepicker', 'client_id' => uniqid(), 'itemid' => 0, 'maxbytes' => -1, 'maxfiles' => 1, 'buttonname' => false);
foreach ($defaults as $key => $value) {
if (empty($options->{$key})) {
$options->{$key} = $value;
}
}
$options->currentfile = '';
if (!empty($options->itemid)) {
$fs = get_file_storage();
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
if (empty($options->filename)) {
if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $options->itemid, 'id DESC', false)) {
$file = reset($files);
}
} else {
$file = $fs->get_file($usercontext->id, 'user', 'draft', $options->itemid, $options->filepath, $options->filename);
}
if (!empty($file)) {
$options->currentfile = html_writer::link(moodle_url::make_draftfile_url($file->get_itemid(), $file->get_filepath(), $file->get_filename()), $file->get_filename());
}
}
// initilise options, getting files in root path
$this->options = initialise_filepicker($options);
// copying other options
foreach ($options as $name => $value) {
if (!isset($this->options->{$name})) {
$this->options->{$name} = $value;
}
}
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:34,代码来源:outputcomponents.php
示例14: xmldb_block_roomscheduler_upgrade
/**
*
* @since 2.0
* @package blocks
* @copyright 2011 Dustin Durand
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_block_roomscheduler_upgrade($oldversion)
{
global $DB;
$dbman = $DB->get_manager();
if ($oldversion < 2011150301) {
$timenow = time();
$sysctx = get_context_instance(CONTEXT_SYSTEM);
/// Fully setup the Elluminate Moderator role.
if (!($mrole = $DB->get_record('role', array('shortname' => 'roomschedulermanager')))) {
if ($rid = create_role(get_string('roomschedulermanager', 'block_roomscheduler'), 'roomschedulemanager', get_string('roomschedulermanagerdescription', 'block_roomscheduler'))) {
$mrole = $DB->get_record('role', array('id' => $rid));
assign_capability('block/roomscheduler:manage', CAP_ALLOW, $mrole->id, $sysctx->id);
set_role_contextlevels($mrole->id, array(CONTEXT_SYSTEM));
} else {
$mrole = $DB->get_record('role', array('shortname' => 'roomschedulermanager'));
set_role_contextlevels($mrole->id, array(CONTEXT_SYSTEM));
}
}
upgrade_block_savepoint(true, 2011150301, 'roomscheduler');
}
if ($oldversion < 2011140315) {
// Define field reservable to be added to roomscheduler_rooms
$table = new xmldb_table('roomscheduler_rooms');
$field = new xmldb_field('reservable', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '1', 'active');
// Conditionally launch add field reservable
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
upgrade_block_savepoint(true, 2011140315, 'roomscheduler');
}
return true;
}
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:39,代码来源:upgrade.php
示例15: get_content
function get_content()
{
global $CFG, $OUTPUT;
if ($this->content !== NULL) {
return $this->content;
}
if (empty($this->instance)) {
return '';
}
$this->content = new stdClass();
$options = new stdClass();
$options->noclean = true;
// Don't clean Javascripts etc
$options->overflowdiv = true;
$context = get_context_instance(CONTEXT_COURSE, $this->page->course->id);
$this->page->course->summary = file_rewrite_pluginfile_urls($this->page->course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
$this->content->text = format_text($this->page->course->summary, $this->page->course->summaryformat, $options);
if ($this->page->user_is_editing()) {
if ($this->page->course->id == SITEID) {
$editpage = $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=frontpagesettings';
} else {
$editpage = $CFG->wwwroot . '/course/edit.php?id=' . $this->page->course->id;
}
$this->content->text .= "<div class=\"editbutton\"><a href=\"{$editpage}\"><img src=\"" . $OUTPUT->pix_url('t/edit') . "\" alt=\"" . get_string('edit') . "\" /></a></div>";
}
$this->content->footer = '';
return $this->content;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:28,代码来源:block_course_summary.php
示例16: save_category
/**
* Save the course category
*
* @author Andrew Zoltay
* date 2011-05-30
* @global type $DB
* @param string $categoryname
* @param int $parent
* @return boolean - success or failure
*/
function save_category($categoryname, $parent = 0)
{
global $DB;
// First off - don't save any categories that are null.
if (empty($categoryname) or is_null($categoryname)) {
return false;
}
// Next check to see if category already exists.
$categoryid = $DB->get_field_select('course_categories', 'id', 'name = ? AND parent = ?', array($categoryname, $parent));
// Finally save the category if it hasnt been found.
if ($categoryid) {
echo 'Found existing cat: ' . $categoryname . ' with id=' . $categoryid . '</br>';
return $categoryid;
} else {
// Save the new category.
$newcategory->name = $categoryname;
$newcategory->description = '';
// Don't define a description.
$newcategory->descriptionformat = 1;
// Default to HTML format.
$newcategory->parent = $parent;
$newcategory->sortorder = 999;
$newcategory->id = $DB->insert_record('course_categories', $newcategory);
$newcategory->context = get_context_instance(CONTEXT_COURSECAT, $newcategory->id);
$categorycontext = $newcategory->context;
mark_context_dirty($newcategory->context->path);
// Now that we have the context, we need to update the category's path info.
$DB->update_record('course_categories', $newcategory);
fix_course_sortorder();
echo 'Added new cat: ' . $categoryname . ' with id=' . $newcategory->id . '</br>';
return $newcategory->id;
}
}
开发者ID:royalroads,项目名称:cace,代码行数:43,代码来源:caceloadcategories.php
示例17: get_content
function get_content()
{
global $CFG, $OUTPUT;
if (empty($this->instance)) {
$this->content = '';
return $this->content;
}
$this->content = new stdClass();
$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
$currentcontext = $this->page->context;
if ($this->page->course->id == SITEID) {
if (!has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
$this->content = '';
return $this->content;
}
} else {
if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
$this->content = '';
return $this->content;
}
}
$icon = '<img src="' . $OUTPUT->pix_url('i/users') . '" class="icon" alt="" /> ';
$this->content->items[] = '<a title="' . get_string('listofallpeople') . '" href="' . $CFG->wwwroot . '/user/index.php?contextid=' . $currentcontext->id . '">' . $icon . get_string('participants') . '</a>';
return $this->content;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:28,代码来源:block_participants.php
示例18: validation
function validation($data, $files)
{
$errors = parent::validation($data, $files);
$tocoursefilesid = $this->_customdata['tocoursefilesid'];
$fromcoursefilesid = $this->_customdata['fromcoursefilesid'];
if (isset($data['urls']) && count($data['urls'])) {
foreach ($data['urls'] as $key => $urlaction) {
switch ($urlaction) {
case QUESTION_FILEMOVE:
if (!has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $fromcoursefilesid))) {
$errors["urls[{$key}]"] = get_string('filecantmovefrom', 'question');
}
//no break; COPY check is also applied to MOVE action
//no break; COPY check is also applied to MOVE action
case QUESTION_FILECOPY:
if (!has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $tocoursefilesid))) {
$errors["urls[{$key}]"] = get_string('filecantmoveto', 'question');
}
break;
case QUESTION_FILEMOVELINKSONLY:
case QUESTION_FILEDONOTHING:
break;
}
}
}
//check that there hasn't been any changes in files between time form was displayed
//and now when it has been submitted.
if (isset($data['urls']) && count($data['urls']) != count($this->_customdata['urls'])) {
$errors['urls[0]'] = get_string('errorfileschanged', 'question');
}
return $errors;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:32,代码来源:contextmove_form.php
示例19: print_tabs
/**
* Prints the tabs for the learning path type
*
* @param string $currenttab Tab to highlight
* @return void
**/
function print_tabs($currenttab = 'layout')
{
global $COURSE;
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
$tabs = $row = $inactive = $active = array();
$row[] = new tabobject('view', $this->url_get_full(), get_string('editpage', 'format_page'));
if (has_capability('format/page:addpa
|
请发表评论