本文整理汇总了PHP中has_capability函数的典型用法代码示例。如果您正苦于以下问题:PHP has_capability函数的具体用法?PHP has_capability怎么用?PHP has_capability使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has_capability函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: assignfeedback_editpdf_pluginfile
/**
* Serves assignment feedback and other files.
*
* @param mixed $course course or id of the course
* @param mixed $cm course module or id of the course module
* @param context $context
* @param string $filearea
* @param array $args
* @param bool $forcedownload
* @return bool false if file not found, does not return if found - just send the file
*/
function assignfeedback_editpdf_pluginfile($course, $cm, context $context, $filearea, $args, $forcedownload)
{
global $USER, $DB, $CFG;
if ($context->contextlevel == CONTEXT_MODULE) {
require_login($course, false, $cm);
$itemid = (int) array_shift($args);
if (!($assign = $DB->get_record('assign', array('id' => $cm->instance)))) {
return false;
}
$record = $DB->get_record('assign_grades', array('id' => $itemid), 'userid,assignment', MUST_EXIST);
$userid = $record->userid;
if ($assign->id != $record->assignment) {
return false;
}
// Check is users feedback or has grading permission.
if ($USER->id != $userid and !has_capability('mod/assign:grade', $context)) {
return false;
}
$relativepath = implode('/', $args);
$fullpath = "/{$context->id}/assignfeedback_editpdf/{$filearea}/{$itemid}/{$relativepath}";
$fs = get_file_storage();
if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
return false;
}
// Download MUST be forced - security!
send_stored_file($file, 0, 0, true);
// Check if we want to retrieve the stamps.
}
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:40,代码来源:lib.php
示例2: get_submission_status
/**
* Search a list of modules.
*
* @param $modulecode
* @return array [string]
* @throws \invalid_parameter_exception
*/
public static function get_submission_status($submissionid)
{
global $DB, $USER;
$params = self::validate_parameters(self::get_submission_status_parameters(), array('submissionid' => $submissionid));
$submissionid = $params['submissionid'];
$submission = $DB->get_record('turnitintooltwo_submissions', array('id' => $submissionid));
if (!$submission) {
return array('status' => 'error');
}
// Grab more data.
$turnitintooltwo = $DB->get_record('turnitintooltwo', array('id' => $submission->turnitintooltwoid));
list($course, $cm) = get_course_and_cm_from_instance($turnitintooltwo, 'turnitintooltwo');
// Check this is our submission.
if ($USER->id !== $submission->userid && !has_capability('mod/turnitintooltwo:grade', \context_module::instance($cm->id))) {
return array('status' => 'nopermission');
}
// What is the status?
$status = $DB->get_record('turnitintooltwo_sub_status', array('submissionid' => $submissionid));
if (!$status) {
return array('status' => 'queued');
}
// Decode the receipt.
$digitalreceipt = (array) json_decode($status->receipt);
// Woo!
if ($status->status == \mod_turnitintooltwo\task\submit_assignment::STATUS_SUCCESS) {
$turnitintooltwoview = new \turnitintooltwo_view();
$digitalreceipt = $turnitintooltwoview->show_digital_receipt($digitalreceipt);
$digitalreceipt = \html_writer::tag("div", $digitalreceipt, array("id" => "box_receipt"));
return array('status' => 'success', 'message' => $digitalreceipt);
}
return array('status' => 'failed', 'message' => \html_writer::tag("div", $digitalreceipt["message"], array("class" => "alert alert-danger")));
}
开发者ID:SkylarKelty,项目名称:moodle-mod_turnitintooltwo,代码行数:39,代码来源:external.php
示例3: definition
function definition()
{
global $CFG, $USER;
$mform =& $this->_form;
$course = $this->_customdata['course'];
$cm = $this->_customdata['cm'];
$modcontext = $this->_customdata['modcontext'];
$mform->addElement('header', 'general', get_string('export', 'quiz'));
$mform->setHelpButton('general', array('export', get_string('export', 'quiz'), 'attforblock'));
$groupmode = groups_get_activity_groupmode($cm);
$groups = groups_get_activity_allowed_groups($cm, $USER->id);
if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $modcontext)) {
$grouplist[0] = get_string('allparticipants');
}
if ($groups) {
foreach ($groups as $group) {
$grouplist[$group->id] = $group->name;
}
}
$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'));
$mform->addGroup($ident, 'ident', get_string('identifyby', 'attforblock'), array('<br />'), true);
$mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true));
$mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attforblock'), get_string('yes'));
$mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod', 'attforblock'));
$mform->disabledIf('sessionenddate', 'includenottaken', 'notchecked');
$mform->addElement('select', 'format', get_string('format'), array('excel' => get_string('downloadexcel', 'attforblock'), 'ooo' => get_string('downloadooo', 'attforblock'), 'text' => get_string('downloadtext', 'attforblock')));
// buttons
$submit_string = get_string('ok');
$this->add_action_buttons(false, $submit_string);
$mform->addElement('hidden', 'id', $cm->id);
// $mform->addElement('hidden', 'action', 'add');
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:35,代码来源:export_form.php
示例4: booktool_wordimport_extend_settings_navigation
/**
* Adds module specific settings to the settings block
*
* @param settings_navigation $settings The settings navigation object
* @param navigation_node $node The node to add module settings to
*/
function booktool_wordimport_extend_settings_navigation(settings_navigation $settings, navigation_node $node)
{
global $PAGE;
if ($PAGE->cm->modname !== 'book') {
return;
}
$params = $PAGE->url->params();
if (empty($params['id']) and empty($params['cmid'])) {
return;
}
if (empty($PAGE->cm->context)) {
$PAGE->cm->context = get_context_module::instance($PAGE->cm->instance);
}
if (!(has_capability('booktool/wordimport:import', $PAGE->cm->context) and has_capability('mod/book:edit', $PAGE->cm->context))) {
return;
}
// Configure Import link, and pass in the current chapter in case the insert should happen here rather than at the end.
$url1 = new moodle_url('/mod/book/tool/wordimport/index.php', array('id' => $PAGE->cm->id, 'chapterid' => $params['chapterid']));
$node->add(get_string('importchapters', 'booktool_wordimport'), $url1, navigation_node::TYPE_SETTING, null, null, new pix_icon('f/document', '', 'moodle', array('class' => 'iconsmall', 'title' => '')));
// Configure Export links for book and current chapter.
$url2 = new moodle_url('/mod/book/tool/wordimport/index.php', array('id' => $PAGE->cm->id, 'action' => 'export'));
$node->add(get_string('exportbook', 'booktool_wordimport'), $url2, navigation_node::TYPE_SETTING, null, null, new pix_icon('f/document', '', 'moodle', array('class' => 'iconsmall', 'title' => '')));
$url3 = new moodle_url('/mod/book/tool/wordimport/index.php', array('id' => $PAGE->cm->id, 'chapterid' => $params['chapterid'], 'action' => 'export'));
$node->add(get_string('exportchapter', 'booktool_wordimport'), $url3, navigation_node::TYPE_SETTING, null, null, new pix_icon('f/document', '', 'moodle', array('class' => 'iconsmall', 'title' => '')));
}
开发者ID:ecampbell,项目名称:moodle-booktool_wordimport,代码行数:31,代码来源:lib.php
示例5: 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
示例6: 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
示例7: __construct
/**
* Constructor.
*
* @param stdClass $cohort
*/
public function __construct($cohort)
{
$cohortcontext = \context::instance_by_id($cohort->contextid);
$editable = has_capability('moodle/cohort:manage', $cohortcontext);
$displayvalue = format_string($cohort->name, true, array('context' => $cohortcontext));
parent::__construct('core_cohort', 'cohortname', $cohort->id, $editable, $displayvalue, $cohort->name, new lang_string('editcohortname', 'cohort'), new lang_string('newnamefor', 'cohort', $displayvalue));
}
开发者ID:rushi963,项目名称:moodle,代码行数:12,代码来源:cohortname.php
示例8: 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
示例9: 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:addpages', $context)) {
$row[] = new tabobject('addpage', $this->url_build('action', 'editpage'), get_string('addpage', 'format_page'));
}
if (has_capability('format/page:managepages', $context)) {
$row[] = new tabobject('manage', $this->url_build('action', 'manage'), get_string('manage', 'format_page'));
}
if (has_capability('moodle/local:managepageactivities', $context)) {
$row[] = new tabobject('activities', $this->url_build('action', 'activities'), get_string('managemods', 'format_page'));
}
if (has_capability('moodle/local:classifylearningpath', $context)) {
$row[] = new tabobject('classify', $this->url_build('action', 'classify'), get_string('classification', 'local'));
}
if (has_capability('moodle/local:savelearningpathtemplate', $context)) {
$row[] = new tabobject('backup', $this->url_build('action', 'backup'), get_string('makebackup', 'local'));
}
$tabs[] = $row;
if (in_array($currenttab, array('layout', 'settings', 'view'))) {
$active[] = 'view';
$row = array();
$row[] = new tabobject('layout', $this->url_get_full(), get_string('layout', 'format_page'));
$row[] = new tabobject('settings', $this->url_get_full(array('action' => 'editpage')), get_string('settings', 'format_page'));
$tabs[] = $row;
}
print_tabs($tabs, $currenttab, $inactive, $active);
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:37,代码来源:pagelib.php
示例10: get_content
/**
* block contents
*
* @return object
*/
public function get_content()
{
global $CFG, $COURSE, $USER, $PAGE;
if ($this->content !== NULL) {
return $this->content;
}
if ($COURSE->id == SITEID) {
$context = context_system::instance();
} else {
$context = context_course::instance($COURSE->id);
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
$mymoodle = 0;
if (strcmp('my-index', $PAGE->pagetype) == 0) {
$mymoodle = 1;
}
if (has_capability('block/enrolsurvey:edit', $context)) {
$editpage = get_string('editpage', 'block_enrolsurvey');
$this->content->text .= "<a\nhref=\"{$CFG->wwwroot}/blocks/enrolsurvey/edit_survey.php?id={$this->instance->id}&courseid={$COURSE->id}&mymoodle={$mymoodle}\">{$editpage}</a><br\n/>";
}
if (has_capability('block/enrolsurvey:take', $context) && cm_get_crlmuserid($USER->id) !== false) {
// MUST have ELIS user record to take survey!
if (!empty($this->config->force_user) && !is_survey_taken($USER->id, $this->instance->id)) {
redirect("{$CFG->wwwroot}/blocks/enrolsurvey/survey.php?id={$this->instance->id}");
}
$takepage = get_string('takepage', 'block_enrolsurvey');
$this->content->text .= "<a\nhref=\"{$CFG->wwwroot}/blocks/enrolsurvey/survey.php?id={$this->instance->id}&courseid={$COURSE->id}&mymoodle={$mymoodle}\">{$takepage}</a><br\n/>";
}
// $this->content->text .= "<br/> crontime = {$this->config->cron_time}";
return $this->content;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:38,代码来源:block_enrolsurvey.php
示例11: module_specific_controls
/**
* Callback function called from question_list() function (which is called from showbank())
*/
function module_specific_controls($totalnumber, $recurse, $category, $cmid)
{
global $QTYPES;
$out = '';
$catcontext = get_context_instance_by_id($category->contextid);
if (has_capability('moodle/question:useall', $catcontext)) {
$randomusablequestions = $QTYPES['random']->get_usable_questions_from_category($category->id, $recurse, '0');
$maxrand = count($randomusablequestions);
if ($maxrand > 0) {
for ($i = 1; $i <= min(10, $maxrand); $i++) {
$randomcount[$i] = $i;
}
for ($i = 20; $i <= min(100, $maxrand); $i += 10) {
$randomcount[$i] = $i;
}
$out .= '<br />';
$out .= get_string('addrandom', 'quiz', choose_from_menu($randomcount, 'randomcount', '1', '', '', '', true));
$out .= '<input type="hidden" name="recurse" value="' . $recurse . '" />';
$out .= '<input type="hidden" name="categoryid" value="' . $category->id . '" />';
$out .= ' <input type="submit" name="addrandom" value="' . get_string('add') . '" />';
$out .= helpbutton('random', get_string('random', 'quiz'), 'quiz', true, false, '', true);
}
}
return $out;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:28,代码来源:edit.php
示例12: 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
示例13: definition
/**
* Form definition
*/
function definition()
{
global $USER, $CFG, $COURSE;
$coursecontext = context_course::instance($COURSE->id);
$mform =& $this->_form;
$editoroptions = $this->_customdata['editoroptions'];
$mform->addElement('header', 'general', get_string('general', 'form'));
$mform->addElement('text', 'name', get_string('groupingname', 'group'), 'maxlength="254" size="50"');
$mform->addRule('name', get_string('required'), 'required', null, 'server');
$mform->setType('name', PARAM_MULTILANG);
$mform->addElement('text', 'idnumber', get_string('idnumbergrouping'), 'maxlength="100" size="10"');
$mform->addHelpButton('idnumber', 'idnumbergrouping');
$mform->setType('idnumber', PARAM_RAW);
$mform->setAdvanced('idnumber');
if (!has_capability('moodle/course:changeidnumber', $coursecontext)) {
$mform->hardFreeze('idnumber');
}
$mform->addElement('editor', 'description_editor', get_string('groupingdescription', 'group'), null, $editoroptions);
$mform->setType('description_editor', PARAM_RAW);
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'courseid');
$mform->setType('courseid', PARAM_INT);
$this->add_action_buttons();
}
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:28,代码来源:grouping_form.php
示例14: other_attempt_fields
protected function other_attempt_fields(MoodleQuickForm $mform) {
if (has_capability('mod/quiz:regrade', $this->_customdata['context'])) {
$mform->addElement('advcheckbox', 'onlyregraded', '',
get_string('optonlyregradedattempts', 'quiz_overview'));
$mform->disabledIf('onlyregraded', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
}
}
开发者ID:JP-Git,项目名称:moodle,代码行数:7,代码来源:overview_form.php
示例15: get_instance_info
/**
* Return guest enrolment instance information.
*
* @param int $instanceid instance id of guest enrolment plugin.
* @return array warnings and instance information.
* @since Moodle 3.1
*/
public static function get_instance_info($instanceid)
{
global $DB;
$params = self::validate_parameters(self::get_instance_info_parameters(), array('instanceid' => $instanceid));
$warnings = array();
// Retrieve guest enrolment plugin.
$enrolplugin = enrol_get_plugin('guest');
if (empty($enrolplugin)) {
throw new moodle_exception('invaliddata', 'error');
}
require_login(null, false, null, false, true);
$enrolinstance = $DB->get_record('enrol', array('id' => $params['instanceid']), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $enrolinstance->courseid), '*', MUST_EXIST);
$context = context_course::instance($course->id);
if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) {
throw new moodle_exception('coursehidden');
}
$instanceinfo = $enrolplugin->get_enrol_info($enrolinstance);
// Specific instance information.
$instanceinfo->passwordrequired = $instanceinfo->requiredparam->passwordrequired;
unset($instanceinfo->requiredparam);
$result = array();
$result['instanceinfo'] = $instanceinfo;
$result['warnings'] = $warnings;
return $result;
}
开发者ID:rushi963,项目名称:moodle,代码行数:33,代码来源:external.php
示例16: display_folder
/**
* Returns html to display the content of mod_folder
* (Description, folder files and optionally Edit button)
*
* @param stdClass $folder record from 'folder' table (please note
* it may not contain fields 'revision' and 'timemodified')
* @return string
*/
public function display_folder(stdClass $folder) {
$output = '';
$folderinstances = get_fast_modinfo($folder->course)->get_instances_of('folder');
if (!isset($folderinstances[$folder->id]) ||
!($cm = $folderinstances[$folder->id]) ||
!$cm->uservisible ||
!($context = context_module::instance($cm->id)) ||
!has_capability('mod/folder:view', $context)) {
// some error in parameters or module is not visible to the user
// don't throw any errors in renderer, just return empty string
return $output;
}
if (trim($folder->intro)) {
if ($folder->display != FOLDER_DISPLAY_INLINE) {
$output .= $this->output->box(format_module_intro('folder', $folder, $cm->id),
'generalbox', 'intro');
} else if ($cm->showdescription) {
// for "display inline" do not filter, filters run at display time.
$output .= format_module_intro('folder', $folder, $cm->id, false);
}
}
$output .= $this->output->box($this->render(new folder_tree($folder, $cm)),
'generalbox foldertree');
// Do not append the edit button on the course page.
if ($folder->display != FOLDER_DISPLAY_INLINE && has_capability('mod/folder:managefiles', $context)) {
$output .= $this->output->container(
$this->output->single_button(new moodle_url('/mod/folder/edit.php',
array('id' => $cm->id)), get_string('edit')),
'mdl-align folder-edit-button');
}
return $output;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:43,代码来源:renderer.php
示例17: report_comments_can_access_user_report
/**
* Is current user allowed to access this report
*
* @private defined in lib.php for performance reasons
*
* @param stdClass $user
* @param stdClass $course
* @return bool
*/
function report_comments_can_access_user_report($user, $course)
{
global $USER, $CFG;
if (empty($CFG->enablecomments)) {
return false;
}
if ($course->id != SITEID and !$course->enablecomments) {
return false;
}
$coursecontext = context_course::instance($course->id);
if (has_capability('report/comments:view', $coursecontext)) {
return true;
}
$personalcontext = context_user::instance($user->id);
if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
if ($course->showreports and (is_viewing($coursecontext, $user) or is_enrolled($coursecontext, $user))) {
return true;
}
} else {
if ($user->id == $USER->id) {
if ($course->showreports and (is_viewing($coursecontext, $USER) or is_enrolled($coursecontext, $USER))) {
return true;
}
}
}
return false;
}
开发者ID:ewallah,项目名称:moodle-report_comments,代码行数:36,代码来源:lib.php
示例18: rcontent_get_count_users
/**
* Check the grades available for the request activity
* @param int $rcontentid -> ID of the rcontent
* @param int $groupingid -> ID of the group
* @return int -> count of grades
*/
function rcontent_get_count_users($rcontentid, $groupingid = null, $context, $filter = '')
{
global $CFG, $USER, $DB;
// Test when the user role is studen and just count his grades
if (has_capability('mod/rcontent:viewreport', $context)) {
if (!has_capability('mod/rcontent:viewresult', $context)) {
$sql = "SELECT count(st.id) FROM {rcontent_grades} st\r\n WHERE st.rcontentid = {$rcontentid} AND st.userid={$USER->id}";
// Filter by status
if ($filter != '') {
$sql .= " AND st.status = '{$filter}'";
}
if ($DB->count_records_sql($sql) > 0) {
return 1;
}
} else {
if (!empty($CFG->enablegroupings) && !empty($groupingid)) {
$sql = "SELECT COUNT(DISTINCT st.userid)\r\n FROM {rcontent_grades} st\r\n INNER JOIN {groups_members} gm ON st.userid = gm.userid\r\n INNER JOIN {groupings_groups} gg ON gm.groupid = gg.groupid\r\n WHERE st.rcontentid = {$rcontentid} AND gg.groupingid = {$groupingid}";
// Filter by status
if ($filter != '') {
$sql .= " AND st.status = '{$filter}'";
}
} else {
$sql = "SELECT COUNT(DISTINCT st.userid)\r\n FROM {rcontent_grades} st\r\n WHERE st.rcontentid = {$rcontentid}";
// Filter by status
if ($filter != '') {
$sql .= " AND st.status = '{$filter}'";
}
}
return $DB->count_records_sql($sql);
}
}
return 0;
}
开发者ID:kevin-bruton,项目名称:marsupial,代码行数:39,代码来源:locallib.php
示例19: init
private function init()
{
if (!$this->isInit) {
$this->isInit = true;
// Discover location of editor plugin.
$editor_plugin = WIRISpluginWrapper::get_wiris_plugin();
$this->installed = !empty($editor_plugin);
// Return if editor plugin is not installed.
if (!$this->installed) {
global $COURSE, $PAGE;
$coursecontext = context_course::instance($COURSE->id);
if (has_capability('moodle/site:config', $coursecontext)) {
// Display missing WIRIS editor plugin dependency error
$PAGE->requires->js('/filter/wiris/js/message.js', false);
}
return null;
}
// Init haxe environment.
if (!class_exists('com_wiris_system_CallWrapper')) {
require_once $editor_plugin->path . '/integration/lib/com/wiris/system/CallWrapper.class.php';
}
com_wiris_system_CallWrapper::getInstance()->init($editor_plugin->path . '/integration');
// Start haxe environment.
$this->begin();
// Create PluginBuilder with Moodle specific configuration.
require_once 'MoodleConfigurationUpdater.php';
$this->moodleConfig = new com_wiris_plugin_configuration_MoodleConfigurationUpdater($editor_plugin);
$this->instance = com_wiris_plugin_api_PluginBuilder::getInstance();
$this->instance->addConfigurationUpdater($this->moodleConfig);
$this->instance->addConfigurationUpdater(new com_wiris_plugin_web_PhpConfigurationUpdater());
// Stop haxe environment.
$this->end();
}
}
开发者ID:mads233,项目名称:moodle-filter_wiris,代码行数:34,代码来源:wirispluginwrapper.php
示例20: view
function view()
{
global $USER;
$context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
require_capability('mod/assignment:view', $context);
add_to_log($this->course->id, "assignment-embedded", "view", "view-embedded.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
// $this->view_header();
echo "<center>";
$this->view_intro();
echo "Hands-on exams will be graded within 10 business days. Results will be provided via email. If you do not receive your results within 10 business days of submitting your answer file, please open a ticket with Kaseya University at helpdesk.kaseya.com.";
echo "</center>";
$this->view_dates();
$filecount = $this->count_user_files($USER->id);
if ($submission = $this->get_submission()) {
if ($submission->timemarked) {
$this->view_feedback();
}
if ($filecount) {
print_simple_box($this->print_user_files($USER->id, true), 'center');
}
}
if (has_capability('mod/assignment:submit', $context) && $this->isopen() && (!$filecount || $this->assignment->resubmit || !$submission->timemarked)) {
$this->view_upload_form();
}
// $this->view_footer();
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:26,代码来源:assignment_embedded.class.php
注:本文中的has_capability函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论