本文整理汇总了PHP中get_contexts_by_capability_for_user函数的典型用法代码示例。如果您正苦于以下问题:PHP get_contexts_by_capability_for_user函数的具体用法?PHP get_contexts_by_capability_for_user怎么用?PHP get_contexts_by_capability_for_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_contexts_by_capability_for_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: block_courserequest_can_do_request
/**
* Determines whether the current user is allowed to make course / class
* requests: they must have the necessary capability at the site level,
* in some course, or some curriculum involved in a course-curriculum association
*
* @uses $CFG
* @uses $DB
* @uses $USER
* @return boolean True if allowed, otherwise false
*/
function block_courserequest_can_do_request()
{
global $CFG, $DB, $USER;
require_once $CFG->dirroot . '/local/elisprogram/lib/data/course.class.php';
$context = context_system::instance();
//handle system context in case no courses are set up
if (has_capability('block/courserequest:request', $context)) {
return true;
}
if ($course_contexts = get_contexts_by_capability_for_user('course', 'block/courserequest:request', $USER->id)) {
$course_filter = $course_contexts->get_filter('id', 'course');
$filter_sql = $course_filter->get_sql(false, 'course');
// *TBV*
$params = array();
$where = '';
if (isset($filter_sql['where'])) {
$where = 'WHERE ' . $filter_sql['where'];
$params = $filter_sql['where_parameters'];
}
//this will handle both the course and curriculum cases
$course_sql = 'SELECT * FROM {' . course::TABLE . "} course {$where}";
if ($DB->record_exists_sql($course_sql, $params)) {
return true;
}
}
//access denied
return false;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:38,代码来源:lib.php
示例2: setupForm
/**
* Adds controls specific to this filter in the form.
* @param object $mform a MoodleForm object to setup
*/
function setupForm(&$mform)
{
global $USER;
$choices_array = array();
//figure out which capability to check
if ($this->execution_mode == php_report::EXECUTION_MODE_SCHEDULED) {
$capability = 'block/php_report:schedule';
} else {
$capability = 'block/php_report:view';
}
//obtain all course contexts where this user can view reports
$contexts = get_contexts_by_capability_for_user('user', $capability, $USER->id);
$context_array = array('contexts' => $contexts);
if ($records = cluster_get_listing('name', 'ASC', 0, 0, '', '', $context_array)) {
foreach ($records as $record) {
if ($record->parent == 0) {
$choices_array[$record->id] = $record->name;
$child_array = $this->find_child_clusters($records, $record->id);
$choices_array = $this->merge_array_keep_keys($choices_array, $child_array);
}
}
}
//explicitly set the list of available options
$this->_options = $choices_array;
parent::setupForm($mform);
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:30,代码来源:clusterselect.php
示例3: get_main_options
/**
* Override this method to return the main pulldown option
* @return array List of options keyed on id
*/
function get_main_options()
{
global $USER;
$courses_array = array('0' => get_string('selectacourse', 'block_curr_admin'));
// Fetch array of allowed classes
$contexts = get_contexts_by_capability_for_user('class', 'block/php_report:view', $USER->id);
if ($records = cmclass_get_listing('crsname', 'ASC', 0, 0, '', '', 0, false, $contexts)) {
$allowed_courses = array();
foreach ($records as $record) {
if (!in_array($record->courseid, $allowed_courses)) {
$allowed_courses[] = $record->courseid;
}
}
sort($allowed_courses);
// Fetch array of all courses
$course_list = course_get_listing('name', 'ASC', 0, 0, '', '');
foreach ($course_list as $course_obj) {
// Only show courses that are associated with an allowed class
if (in_array($course_obj->id, $allowed_courses)) {
$courses_array[$course_obj->id] = strlen($course_obj->name) > 80 ? substr($course_obj->name, 0, 80) . '...' : $course_obj->name;
}
}
}
return $courses_array;
}
开发者ID:remotelearner,项目名称:elis.cm,代码行数:29,代码来源:courseclassselect.php
示例4: get_contexts
public static function get_contexts($capability)
{
if (!isset(coursepage::$contexts[$capability])) {
global $USER;
coursepage::$contexts[$capability] = get_contexts_by_capability_for_user('course', $capability, $USER->id);
}
return coursepage::$contexts[$capability];
}
开发者ID:jamesmcq,项目名称:elis,代码行数:8,代码来源:coursepage.class.php
示例5: get_contexts
static function get_contexts($capability)
{
if (!isset(bulkuserpage::$contexts[$capability])) {
global $USER;
bulkuserpage::$contexts[$capability] = get_contexts_by_capability_for_user('user', $capability, $USER->id);
}
return bulkuserpage::$contexts[$capability];
}
开发者ID:jamesmcq,项目名称:elis,代码行数:8,代码来源:bulkuserpage.class.php
示例6: get_contexts
static function get_contexts($capability)
{
if (!isset(curriculumpage::$contexts[$capability])) {
global $USER;
curriculumpage::$contexts[$capability] = get_contexts_by_capability_for_user('curriculum', $capability, $USER->id);
}
return curriculumpage::$contexts[$capability];
}
开发者ID:jamesmcq,项目名称:elis,代码行数:8,代码来源:curriculumpage.class.php
示例7: add_course_info
/**
* Adds fields to this form which are relevant to the course, either
* new or old, that a class is being requested for, including any associated
* validation rules
*/
protected function add_course_info()
{
global $PAGE, $USER;
$PAGE->requires->js('/blocks/courserequest/forms.js');
$mform =& $this->_form;
$mform->addElement('header', 'courseheader', get_string('createcourseheader', 'block_courserequest'));
$courses = array(0 => get_string('newcourse', 'block_courserequest'));
/*
* Get all courses the current user has access to:
* Access is allowed if you have the correct capability at the system, curriculum, or course level
*/
$course_contexts = get_contexts_by_capability_for_user('course', 'block/courserequest:request', $USER->id);
// this will actually handle all cases because it handles curricula explicitly
$eliscourses = course_get_listing('crs.name', 'ASC', 0, 0, '', '', $course_contexts);
$eliscourses = $eliscourses ? $eliscourses : array();
foreach ($eliscourses as $course) {
$courses[$course->id] = '(' . $course->idnumber . ') ' . $course->name;
}
$mform->addElement('select', 'courseid', get_string('course', 'block_courserequest'), $courses, array('onchange' => 'handle_course_change()'));
// If this user has approval permission then let's give them the class id field so we can skip the approval page
$syscontext = context_system::instance();
if (has_capability('block/courserequest:approve', $syscontext)) {
// indicate that course idnumber is required
$label = '<span class="required">' . get_string('courseidnumber', 'block_courserequest') . '*</span>';
$mform->addElement('text', 'crsidnumber', $label);
$mform->addRule('crsidnumber', null, 'maxlength', 100);
$mform->setType('crsidnumber', PARAM_TEXT);
$mform->disabledIf('crsidnumber', 'courseid', 'gt', '0');
}
// indicate that course name is required
$label = '<span class="required">' . get_string('title', 'block_courserequest') . '*</span>';
$mform->addElement('text', 'title', $label);
$mform->setType('title', PARAM_RAW);
// only needed for new courses
$mform->disabledIf('title', 'courseid', 'gt', '0');
$usecoursefields = get_config('block_courserequest', 'use_course_fields');
if (!empty($usecoursefields)) {
// add course-level custom fields to the interface
$this->add_custom_fields('course', true);
}
}
开发者ID:jamesmcq,项目名称:elis,代码行数:46,代码来源:request_form.php
示例8: generalized_filter_clusterselect
/**
* Constructor
* @param string $name the name of the filter instance
* @param string $label the label of the filter instance
* @param boolean $advanced advanced form element flag
* @param string $field user table filed name
* @param array $options select options
*/
function generalized_filter_clusterselect($uniqueid, $alias, $name, $label, $advanced, $field, $options = array())
{
global $USER;
//figure out which capability to check
if ($this->execution_mode == php_report::EXECUTION_MODE_SCHEDULED) {
$capability = 'local/elisreports:schedule';
} else {
$capability = 'local/elisreports:view';
}
//obtain all cluster contexts where this user can view reports
$contexts = get_contexts_by_capability_for_user('cluster', $capability, $USER->id);
//set up cluster listing
$choices_array = array();
if ($records = $this->cluster_dropdown_get_listing($contexts)) {
foreach ($records as $record) {
if (empty($choices_array[$record->id])) {
//if (count($choices_array) > 1) {
// $choices_array[-$record->id] = $cluster_group_separator;
//}
$ancestors = $record->depth - 1;
// shorten really long cluster names
$clstname = strlen($record->name) > 100 ? substr($record->name, 0, 100) . '...' : $record->name;
$choices_array[$record->id] = $ancestors ? str_repeat('- ', $ancestors) . $clstname : $clstname;
//merge in child clusters
$child_array = $this->find_child_clusters($records, $record->id, $ancestors);
$choices_array = $this->merge_array_keep_keys($choices_array, $child_array);
}
}
}
//explicitly set the list of available options
$this->_options = $choices_array;
//expected by the parent class
$options['choices'] = $choices_array;
$options['numeric'] = true;
parent::generalized_filter_equalityselect($uniqueid, $alias, $name, $label, $advanced, $field, $options);
}
开发者ID:jamesmcq,项目名称:elis,代码行数:44,代码来源:clusterselect.php
示例9: definition
function definition()
{
global $USER, $CFG, $COURSE, $CURMAN;
parent::definition();
if (!empty($this->_customdata['obj'])) {
$obj = $this->_customdata['obj'];
if (empty($obj->startdate) || $obj->startdate == 0) {
$this->set_data(array('disablestart' => '1'));
}
if (empty($obj->enddate) || $obj->enddate == 0) {
$this->set_data(array('disableend' => '1'));
}
if (isset($obj->starttimeminute) && isset($obj->starttimehour)) {
$this->set_data(array('starttime' => array('minute' => $obj->starttimeminute, 'hour' => $obj->starttimehour)));
}
if (isset($obj->endtimeminute) && isset($obj->endtimehour)) {
$this->set_data(array('endtime' => array('minute' => $obj->endtimeminute, 'hour' => $obj->endtimehour)));
}
}
$mform =& $this->_form;
$mform->addElement('hidden', 'id');
// If there is no custom data for the course, create some
if (empty($this->_customdata['obj']->course->name) || empty($this->_customdata['obj']->id)) {
$courses = array();
if (!empty($USER->id)) {
$contexts = get_contexts_by_capability_for_user('course', 'block/curr_admin:class:create', $USER->id);
// get listing of available ELIS courses
$courses = course_get_listing('name', 'ASC', 0, 0, '', '', $contexts);
}
// Add course select
$attributes = array('onchange' => 'update_trk_multiselect(); ');
$selections = array();
if (!empty($courses)) {
foreach ($courses as $course) {
$selections[$course->id] = '(' . $course->idnumber . ')' . $course->name;
}
}
$mform->addElement('select', 'courseid', get_string('course', 'block_curr_admin') . ':', $selections, $attributes);
$mform->setHelpButton('courseid', array('cmclassform/course', get_string('course', 'block_curr_admin'), 'block_curr_admin'));
$firstcourse = reset($courses);
$this->firstcourse = $firstcourse;
if (false !== $firstcourse && empty($this->_customdata['obj']->id)) {
$this->add_track_multi_select($firstcourse->id);
} elseif (!empty($courses)) {
$this->add_track_multi_select($this->_customdata['obj']->courseid);
}
} else {
$extra_params = array();
$mform->addElement('static', 'courseid', get_string('course', 'block_curr_admin') . ':');
// Get current action and set param accordingly
$current_action = optional_param('action', 'view', PARAM_ALPHA);
$extra_params['action'] = $current_action;
$extra_params['s'] = 'crs';
// Want to set the url for the course
$extra_params['id'] = $this->_customdata['obj']->courseid;
// Course id
$course_url = $this->get_moodle_url($extra_params);
$course_name = '(' . $this->_customdata['obj']->course->idnumber . ')' . '<a href="' . $course_url . '" >' . $this->_customdata['obj']->course->name . '</a>';
$this->set_data(array('courseid' => $course_name));
$mform->setHelpButton('courseid', array('cmclassform/course', get_string('course', 'block_curr_admin'), 'block_curr_admin'));
$this->add_track_multi_select($this->_customdata['obj']->courseid);
}
if (!empty($this->_customdata['obj']->courseid)) {
$mform->freeze('courseid');
} else {
$mform->addRule('courseid', get_string('required'), 'required', NULL, 'client');
}
// Done adding course select
//get_string('general');
$mform->addElement('text', 'idnumber', get_string('class_idnumber', 'block_curr_admin') . ':');
$mform->addRule('idnumber', get_string('required'), 'required', NULL, 'client');
$mform->setType('idnumber', PARAM_TEXT);
$mform->setHelpButton('idnumber', array('cmclassform/idnumber', get_string('class_idnumber', 'block_curr_admin'), 'block_curr_admin'));
$mform->addElement('date_selector', 'startdate', get_string('class_startdate', 'block_curr_admin') . ':', array('optional' => true, 'disabled' => 'disabled'));
$mform->setHelpButton('startdate', array('cmclassform/startdate', get_string('class_startdate', 'block_curr_admin'), 'block_curr_admin'));
$mform->addElement('date_selector', 'enddate', get_string('class_enddate', 'block_curr_admin') . ':', array('optional' => true));
// They may very likely be a much better way of checking for this...
if (empty($obj->starttimehour) and empty($obj->starttimeminute)) {
$mform->addElement('time_selector', 'starttime', get_string('class_starttime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'checked', 'display_12h' => $CURMAN->config->time_format_12h));
} else {
$mform->addElement('time_selector', 'starttime', get_string('class_starttime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'unchecked', 'display_12h' => $CURMAN->config->time_format_12h));
}
$mform->setHelpButton('starttime', array('cmclassform/starttime', get_string('class_starttime', 'block_curr_admin'), 'block_curr_admin'));
// Do the same thing for the endtime
if (empty($obj->endtimehour) and empty($obj->endtimeminute)) {
$mform->addElement('time_selector', 'endtime', get_string('class_endtime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'checked', 'display_12h' => $CURMAN->config->time_format_12h));
} else {
$mform->addElement('time_selector', 'endtime', get_string('class_endtime', 'block_curr_admin') . ':', array('optional' => true, 'checked' => 'unchecked', 'display_12h' => $CURMAN->config->time_format_12h));
}
$mform->addElement('text', 'maxstudents', get_string('class_maxstudents', 'block_curr_admin') . ':');
$mform->setType('maxstudents', PARAM_INT);
$mform->setHelpButton('maxstudents', array('cmclassform/maxstudents', get_string('class_maxstudents', 'block_curr_admin'), 'block_curr_admin'));
// Environment selector
$envs = environment_get_listing();
$envs = $envs ? $envs : array();
$o_envs = array(get_string('none', 'block_curr_admin'));
foreach ($envs as $env) {
$o_envs[$env->id] = $env->name;
}
$mform->addElement('select', 'environmentid', get_string('environment', 'block_curr_admin') . ':', $o_envs);
//.........这里部分代码省略.........
开发者ID:remotelearner,项目名称:elis.cm,代码行数:101,代码来源:cmclassform.class.php
示例10: mtrace
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
require_once $CFG->dirroot . '/local/elisprogram/lib/contexts.php';
require_once $CFG->dirroot . '/local/elisprogram/lib/data/pmclass.class.php';
if (!isloggedin() || isguestuser()) {
mtrace("ERROR: must be logged in!");
exit;
}
$ids = array();
if (array_key_exists('id', $_REQUEST)) {
$dirtyids = $_REQUEST['id'];
if (is_array($dirtyids)) {
foreach ($dirtyids as $dirty) {
$ids[] = clean_param($dirty, PARAM_INT);
}
} else {
$ids[] = clean_param($dirtyids, PARAM_INT);
}
} else {
$ids[] = 0;
}
// Must have blank value as the default here (instead of zero) or it breaks the gas guage report
$choices_array = array(array('', get_string('anyvalue', 'filters')));
if (!empty($ids)) {
$contexts = get_contexts_by_capability_for_user('class', 'local/elisreports:view', $USER->id);
$records = pmclass_get_listing('idnumber', 'ASC', 0, 0, '', '', $ids, false, $contexts);
foreach ($records as $record) {
$choices_array[] = array($record->id, $record->idnumber);
}
unset($records);
}
echo json_encode($choices_array);
开发者ID:jamesmcq,项目名称:elis,代码行数:31,代码来源:childoptions.php
示例11: can_view_report
/**
* Determines whether the current user can view this report, based on being logged in
* and php_report:view capability
*
* @return boolean True if permitted, otherwise false
*/
function can_view_report()
{
//make sure context libraries are loaded
$this->require_dependencies();
//make sure the current user can view reports in at least one curriculum context
$contexts = get_contexts_by_capability_for_user('curriculum', $this->access_capability, $this->userid);
return !$contexts->is_empty();
}
开发者ID:remotelearner,项目名称:elis.reporting,代码行数:14,代码来源:course_usage_summary_report.class.php
示例12: can_do_add
function can_do_add()
{
global $USER;
if (!empty($USER->id)) {
$contexts = get_contexts_by_capability_for_user('course', 'local/elisprogram:class_create', $USER->id);
return !$contexts->is_empty();
}
return false;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:9,代码来源:pmclasspage.class.php
示例13: test_usersetcontexts
/**
* Tests contexts in userset data object.
*
* Covers:
* local/elisprogram/lib/data/userset.class.php:334
* local/elisprogram/lib/data/userset.class.php:453
* local/elisprogram/lib/data/userset.class.php:561
* local/elisprogram/lib/data/userset.class.php:595
* local/elisprogram/lib/data/userset.class.php:616
* local/elisprogram/lib/data/userset.class.php:721
* local/elisprogram/lib/data/userset.class.php:755
* local/elisprogram/lib/data/userset.class.php:847
* local/elisprogram/lib/data/userset.class.php:901
*/
public function test_usersetcontexts()
{
global $USER, $DB;
require_once elispm::file('plugins/usetclassify/usersetclassification.class.php');
require_once elispm::file('plugins/usetclassify/lib.php');
$this->setup_users();
$this->setup_usersets();
// TEST local/elisprogram/lib/data/userset.class.php:334.
$res = userset::get_allowed_clusters(1);
// TEST local/elisprogram/lib/data/userset.class.php:453.
$ussfilter = new usersubset_filter('id', new field_filter('id', 1));
$res = $ussfilter->get_sql();
// TEST
// local/elisprogram/lib/data/userset.class.php:561
// local/elisprogram/lib/data/userset.class.php:595
// local/elisprogram/lib/data/userset.class.php:616
// local/elisprogram/lib/data/userset.class.php:721
// local/elisprogram/lib/data/userset.class.php:755.
$field = new field(array('shortname' => USERSET_CLASSIFICATION_FIELD));
$field->load();
$userset = $this->create_userset($field);
// Get a role to assign.
$rolesctx = $DB->get_records('role_context_levels', array('contextlevel' => CONTEXT_ELIS_USERSET));
foreach ($rolesctx as $i => $rolectx) {
$roleid = $rolectx->roleid;
}
// Add userset_view capability to our role.
$usersetcontext = \local_elisprogram\context\userset::instance($userset->id);
$rc = new stdClass();
$rc->contextid = $usersetcontext->id;
$rc->roleid = $roleid;
$rc->capability = 'local/elisprogram:userset_view';
$rc->permission = 1;
$rc->timemodified = time();
$rc->modifierid = 0;
$DB->insert_record('role_capabilities', $rc);
$rc = new stdClass();
$rc->contextid = $usersetcontext->id;
$rc->roleid = $roleid;
$rc->capability = 'local/elisprogram:userset_enrol_userset_user';
$rc->permission = 1;
$rc->timemodified = time();
$rc->modifierid = 0;
$DB->insert_record('role_capabilities', $rc);
// Assign role.
$user = new user(103);
$muser = $user->get_moodleuser();
$raid = role_assign($roleid, $muser->id, $usersetcontext->id);
$this->setUser(100);
// Assign other user to userset.
$clst = new clusterassignment();
$clst->clusterid = $userset->id;
$clst->userid = 104;
$clst->plugin = 'manual';
$clst->save();
// Get cluster listing.
$capability = 'local/elisprogram:userset_view';
$contexts = get_contexts_by_capability_for_user('cluster', $capability, 100);
$extrafilters = array('contexts' => $contexts, 'classification' => 'test field data');
$res = cluster_get_listing('name', 'ASC', 0, 0, '', '', $extrafilters, 104);
$res = cluster_count_records('', '', $extrafilters);
// TEST local/elisprogram/lib/data/userset.class.php:847.
cluster_get_non_child_clusters(1);
// TEST local/elisprogram/lib/data/userset.class.php:901.
cluster_get_possible_sub_clusters(1);
$this->setUser(null);
}
开发者ID:jamesmcq,项目名称:elis,代码行数:81,代码来源:miscellaneouscontexts_test.php
示例14: transform_grouping_header_label
function transform_grouping_header_label($grouping_current, $grouping, $datum, $export_format)
{
global $DB;
$params = array();
$labels = array();
//obtain an sql clause that filters out users you shouldn't see
$contexts = get_contexts_by_capability_for_user('user', $this->access_capability, $this->userid);
//$permissions_filter = $contexts->sql_filter_for_context_level('u.id', 'user');
$filter_obj = $contexts->get_filter('id', 'user');
$filter_sql = $filter_obj->get_sql(false, 'u', SQL_PARAMS_NAMED);
$permissions_filter1 = 'TRUE';
if (isset($filter_sql['where'])) {
$permissions_filter1 = $filter_sql['where'];
$params = array_merge($params, $filter_sql['where_parameters']);
}
$filter_sql = $filter_obj->get_sql(false, 'u', SQL_PARAMS_NAMED);
$permissions_filter2 = 'TRUE';
if (isset($filter_sql['where'])) {
$permissions_filter2 = $filter_sql['where'];
$params = array_merge($params, $filter_sql['where_parameters']);
}
$filter_sql = $filter_obj->get_sql(false, 'u', SQL_PARAMS_NAMED);
$permissions_filter3 = 'TRUE';
if (isset($filter_sql['where'])) {
$permissions_filter3 = $filter_sql['where'];
$params = array_merge($params, $filter_sql['where_parameters']);
}
$filter_sql = $filter_obj->get_sql(false, 'u', SQL_PARAMS_NAMED);
$permissions_filter4 = 'TRUE';
if (isset($filter_sql['where'])) {
$permissions_filter4 = $filter_sql['where'];
$params = array_merge($params, $filter_sql['where_parameters']);
}
$filter_sql = $filter_obj->get_sql(false, 'u', SQL_PARAMS_NAMED);
$permissions_filter5 = 'TRUE';
if (isset($filter_sql['where'])) {
// TBD
$permissions_filter5 = $filter_sql['where'];
$params = array_merge($params, $filter_sql['where_parameters']);
}
$class_join = $this->get_class_join_sql();
//dynamically hande the class start / end date condition
$startdate_condition = $this->get_class_startdate_condition();
$status_clause = '';
$status_sql = '';
$status_join = '';
$status_where = '';
// Check if we need to check status
if ($value = php_report_filtering_get_active_filter_values($this->get_report_shortname(), 'filter-completionstatus', $this->filter)) {
$status = $value[0]['value'];
}
if (isset($status)) {
$status_clause = $this->get_class_status_sql($status);
$status_sql = ' AND EXISTS (SELECT stu.userid
FROM {' . student::TABLE . '} stu
' . $this->get_class_join_sql('WHERE', false) . " AND stu.userid = u.id\n {$status_clause})";
$status_join = ' JOIN {' . student::TABLE . '} stu
ON stu.userid = u.id ';
if (!empty($class_join)) {
$status_join .= 'AND stu.classid = cls.id ';
}
$status_where = $this->get_class_status_sql($status);
} else {
$status = STUSTATUS_PASSED;
}
$ccc_sql = $this->get_course_class_condition_sql();
// Determine if we are filtering by one or more custom field values
$filtering_cur_customfield = false;
/**
* This section handles updating all curriculum custom fields with an additional condition,
* attaching the filter condition to the outer curriculum in the case where we are displaying
* some curriculum field, such as name or a custom field datum
*/
//find a curriculum customfield filters
foreach ($this->filter->_fields as $key => $value) {
if (strpos($key, 'filter-ccc-curriculum-customfield-') === 0) {
//determine if a session value is set for this field
if ($test_customfield = php_report_filtering_get_active_filter_values($this->get_report_shortname(), $key, $this->filter)) {
//signal that we are filtering by curriculum customfields
$filtering_cur_customfield = true;
break;
}
}
}
/**
* Calculate the total number of distinct users in the report
*/
if ($this->_show_curricula) {
//we are showing curricula, so we need to figure out which users have
//appropriate credits
//subquery to retreive the number of credits
$subquery = '(SELECT SUM(stu.credits)
FROM {' . student::TABLE . '} stu
JOIN {' . pmclass::TABLE . "} cls ON stu.classid = cls.id {$ccc_sql}\n LEFT JOIN ({" . curriculumcourse::TABLE . '} curcrs
JOIN {' . curriculumstudent::TABLE . '} curstu ON curcrs.curriculumid = curstu.curriculumid) ON cls.courseid = curcrs.courseid AND stu.userid = curstu.userid
WHERE curstu.id IS NULL
AND stu.completestatusid = ' . STUSTATUS_PASSED . "\n AND {$startdate_condition}\n AND stu.userid = u.id)";
//subquery to determine if one or more credit has been awarded
$exists_query = 'SELECT * FROM {' . student::TABLE . '} stu
JOIN {' . pmclass::TABLE . "} cls\n ON stu.classid = cls.id {$ccc_sql}\n LEFT JOIN ({" . curriculumcourse::TABLE . '} curcrs
//.........这里部分代码省略.........
开发者ID:jamesmcq,项目名称:elis,代码行数:101,代码来源:user_class_completion_report.class.php
示例15: block_php_report_field_accessible
/**
* Specifies whether a course-level custom field is accessible to the
* current user in at least once course context
*
* @param array $owners shortname-indexed collection of all field owners
*
* @return boolean true if accessible, otherwise false
*/
function block_php_report_field_accessible($owners)
{
global $USER, $CFG;
require_once $CFG->dirroot . '/curriculum/lib/contexts.php';
if ($view_capability = block_php_report_field_capability($owners)) {
//make sure the user has the view capability in some course
$contexts = get_contexts_by_capability_for_user('course', $view_capability, $USER->id);
return !$contexts->is_empty();
} else {
//data error
return false;
}
}
开发者ID:remotelearner,项目名称:elis.reporting,代码行数:21,代码来源:sharedlib.php
示例16: can_view_report
/**
* Determines whether the current user can view this report,
* based on being logged in and php_report:view capability
*
* @param none
* @return boolean - true if permitted, otherwise false
*/
function can_view_report()
{
//Check for report view capability
if (!isloggedin() || isguestuser()) {
return false;
}
//make sure context libraries are loaded
$this->require_dependencies();
//make sure the current user can view reports in at least one context
$contexts = get_contexts_by_capability_for_user('user', $this->access_capability, $this->userid);
return !$contexts->is_empty();
}
开发者ID:remotelearner,项目名称:elis.reporting,代码行数:19,代码来源:sitewide_time_summary_report.class.php
示例17: can_view_report
/**
* Determines whether the current user can view this report, based on being logged in
* and php_report:view capability
* @return boolean True if permitted, otherwise false
*/
function can_view_report()
{
//Check for report view capability
if (!isloggedin() || isguestuser()) {
return false;
}
$this->require_dependencies();
// make sure the current user has the capability for SOME user
$contexts = get_contexts_by_capability_for_user('user', $this->access_capability, $this->userid);
if (!$contexts->is_empty()) {
return true;
}
// Since user is logged-in AND HAVE VALID PM/CM userid, then they should
// always be able to see their own courses/classes, but NOT schedule
if ($this->execution_mode != php_report::EXECUTION_MODE_SCHEDULED && cm_get_crlmuserid($this->userid)) {
return true;
}
return false;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:24,代码来源:individual_course_progress_report.class.php
示例18: get_total_credits
/**
* Calculate the total credits for the current user
* @param string array $grouping_current Mapping of field names to current values in the grouping
* @param table_report_grouping $grouping Object containing all info about the current
* level of grouping being handled
* @param stdClass $datum The most recent record encountered
* @param string $export_format The format being used to render the report
* @uses $DB
* @return string The format total of credits
*/
function get_total_credits($grouping_current, $grouping, $datum, $export_format)
{
global $DB;
$params = array();
//obtain an sql clause that filters out users you shouldn't see
$contexts = get_contexts_by_capability_for_user('user', $this->access_capability, $this->userid);
//$permissions_filter = $contexts->sql_filter_for_context_level('u.id', 'user');
$filter_obj = $contexts->get_filter('id', 'user');
$filter_sql = $filter_obj->get_sql(false, 'u', SQL_PARAMS_NAMED);
$permissions_filter = 'TRUE';
if (isset($filter_sql['where'])) {
$permissions_filter = $filter_sql['where'];
$params = array_merge($params, $filter_sql['where_parameters']);
}
//dynamically hande the class start / end date condition
$startdate_condition = $this->get_class_startdate_condition();
$ccc_sql = $this->get_course_class_condition_sql();
$status_clause = '';
$status_sql = '';
// Check if we need to check status
if ($value = php_report_filtering_get_active_filter_values($this->parentname, 'filter-completionstatus', $this->filter)) {
$status = $value[0]['value'];
}
if (isset($status)) {
$status_clause = $this->get_class_status_sql($status);
$status_sql = ' AND EXISTS
(SELECT stu.userid
FROM {' . student::TABLE . '} stu' . $this->get_class_join_sql('WHERE') . ' AND stu.userid = u.id' . $status_clause . ')';
} else {
$status = STUSTATUS_PASSED;
}
// Determine if we are filtering by one or more custom field values
$filtering_cur_customfield = false;
/**
* This section handles updating all curriculum custom fields with an additional condition,
* attaching the filter condition to the outer curriculum in the case where we are displaying
* some curriculum field, such as name or a custom field datum
*/
//find a curriculum customfield filters
foreach ($this->filter->_fields as $key => $value) {
if (strpos($key, 'filter-ccc-curriculum-customfield-') === 0) {
//determine if a session value is set for this field
if ($test_customfield = php_report_filtering_get_active_filter_values($this->get_report_shortname(), $key, $this->filter)) {
//signal that we are filtering by curriculum customfields
$filtering_cur_customfield = true;
break;
}
}
}
//calculate the appropriate filter clause - moved up from within next if block
list($filter_clause, $filter_params) = $this->get_filter_condition('');
if (empty($filter_clause)) {
$filter_clause = 'TRUE';
} else {
$params = array_merge($params, $filter_params);
}
//error_log("UCCDR::get_total_credits() - filter_clause = {$filter_clause}");
/**
* Calculate the total number of distinct credits in the report
*/
if ($this->_show_curricula || $filtering_cur_customfield) {
//we are showing curricula, so we need to account for curriculum and
//non-curriculum cases
if (!$this->_show_curricula && $filtering_cur_customfield) {
//special case: filtering by customfields when showing no curriculum info
$filter_clause = str_replace('u.id = cca.userid', 'u.id = cca.userid AND curcrs.curriculumid = cca.curriculumid', $filter_clause);
}
$curriculum_sql = 'SELECT SUM(credits) FROM (
SELECT DISTINCT u.id AS userid, cls.id AS classid, stu.credits
FROM {' . user::TABLE . '} u
JOIN {' . student::TABLE . '} stu
ON u.id = stu.userid {$status_clause}
JOIN {' . pmclass::TABLE . '} cls
ON stu.classid = cls.id
JOIN {' . curriculumcourse::TABLE . '} curcrs
ON cls.courseid = curcrs.courseid
JOIN {' . curriculumstudent::TABLE . '} curstu
ON u.id = curstu.userid
JOIN {' . curriculum::TABLE . '} cur
ON curstu.curriculumid = cur.id
AND curcrs.curriculumid = curstu.curriculumid
WHERE stu.completestatusid = ' . STUSTATUS_PASSED . "\n AND {$filter_clause}\n {$ccc_sql}\n AND {$permissions_filter}\n AND {$startdate_condition}) c";
//obtain the actual number
$curriculum_num = $DB->get_field_sql($curriculum_sql, $params);
if ($filtering_cur_customfield) {
//if we are filtering by curriculum customfields, there will never be any non-curriculum results
$noncurriculum_num = 0;
} else {
$noncurriculum_sql = 'SELECT SUM(stu.credits)
FROM {' . user::TABLE . '} u
//.........这里部分代码省略.........
开发者ID:jamesmcq,项目名称:elis,代码行数:101,代码来源:user_class_completion_details_report.class.php
示例19: definition
/**
* items in the form
*
* @uses $USER
*/
public function definition()
{
global $USER;
$fields = field::get_for_context_level('track');
foreach ($fields as $rec) {
$field = new field($rec);
if (strcmp($field->datatype, "num") == 0) {
$fieldname = "field_{$field->shortname}";
if (isset($this->_customdata['obj']->{$fieldname})) {
$formatnum = $field->format_number($this->_customdata['obj']->{$fieldname});
$this->_customdata['obj']->{$fieldname} = $formatnum;
}
}
}
$this->set_data($this->_customdata['obj']);
$mform =& $this->_form;
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$curs = array();
if (!empty($USER->id)) {
// TBD: and/or capability 'local/elisprogram:track_edit|view' ?
// This is necessary for creating a new track but will prevent a parent programs from appearing
// when the user has track edit permissions but not track creation permission -- ELIS-5954
$contexts = get_contexts_by_capability_for_user('curriculum', 'local/elisprogram:track_create', $USER->id);
$curs = curriculum_get_listing('name', 'ASC', 0, 0, '', '', $contexts);
}
if (empty($this->_customdata['obj']->id)) {
$curid_options = array();
if (!empty($curs)) {
foreach ($curs as $cur) {
$curid_options[$cur->id] = '(' .
|
请发表评论