本文整理汇总了PHP中get_capability_string函数的典型用法代码示例。如果您正苦于以下问题:PHP get_capability_string函数的具体用法?PHP get_capability_string怎么用?PHP get_capability_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_capability_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor.
* @throws Command_Exception.
*/
public function __construct()
{
global $DB;
// Getting command description.
$cmd_name = vmoodle_get_string('cmdsynccapabilityname', 'vmoodleadminset_roles');
$cmd_desc = vmoodle_get_string('cmdsynccapabilitydesc', 'vmoodleadminset_roles');
// Creating platform parameter.
$platform_param = new Command_Parameter('platform', 'enum', vmoodle_get_string('platformparamsyncdesc', 'vmoodleadminset_roles'), null, get_available_platforms());
// Getting role parameter.
$roles = role_fix_names(get_all_roles(), \context_system::instance(), ROLENAME_ORIGINAL);
$rolemenu = array();
foreach ($roles as $r) {
$rolemenu[$r->shortname] = $r->name;
}
$role_param = new Command_Parameter('role', 'enum', vmoodle_get_string('roleparamsyncdesc', 'vmoodleadminset_roles'), null, $rolemenu);
// Creating capability parameter.
$records = $DB->get_records('capabilities', null, 'name', 'name');
$capabilities = array();
foreach ($records as $record) {
$capabilities[$record->name] = get_capability_string($record->name);
}
asort($capabilities);
$capability_param = new Command_Parameter('capability', 'enum', vmoodle_get_string('capabilityparamsyncdesc', 'vmoodleadminset_roles'), null, $capabilities);
// Creating command.
parent::__construct($cmd_name, $cmd_desc, array($platform_param, $role_param, $capability_param));
}
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:30,代码来源:Command_Role_Capability_Sync.php
示例2: get_capabitity_optgroups
protected function get_capabitity_optgroups()
{
if (!empty($this->_optGroups)) {
// I have absolutely no idea why this is necessary, but it does seem to be.
// Bloody formslib. Somehow it is calling the constructor twice.
return array();
}
$optgroups = array();
$capabilities = context_system::instance()->get_capabilities();
$contextlevel = 0;
$component = '';
$currentgroup = array();
$currentgroupname = '';
foreach ($capabilities as $capability) {
// Start a new optgroup if the componentname or context level has changed.
if (component_level_changed($capability, $component, $contextlevel)) {
if ($currentgroup) {
$optgroups[$currentgroupname] = $currentgroup;
}
$currentgroup = array();
$currentgroupname = context_helper::get_level_name($capability->contextlevel) . ': ' . get_component_string($capability->component, $capability->contextlevel);
}
$contextlevel = $capability->contextlevel;
$component = $capability->component;
$a = new stdClass();
$a->name = get_capability_string($capability->name);
$a->capabilityname = $capability->name;
$currentgroup[$capability->name] = get_string('capabilityandname', 'tool_editrolesbycap', $a);
}
// Remeber to add the currently open optgroup.
if ($currentgroup) {
$optgroups[$currentgroupname] = $currentgroup;
}
return $optgroups;
}
开发者ID:Keneth1212,项目名称:moodle,代码行数:35,代码来源:capabilityformfield.php
示例3: definition
function definition()
{
$mform = $this->_form;
$service = isset($this->_customdata) ? $this->_customdata : new stdClass();
$mform->addElement('header', 'extservice', get_string('externalservice', 'webservice'));
$mform->addElement('text', 'name', get_string('name'));
$mform->addRule('name', get_string('required'), 'required', null, 'client');
$mform->setType('name', PARAM_TEXT);
$mform->addElement('advcheckbox', 'enabled', get_string('enabled', 'webservice'));
$mform->setType('enabled', PARAM_BOOL);
$mform->addElement('advcheckbox', 'restrictedusers', get_string('restrictedusers', 'webservice'));
$mform->addHelpButton('restrictedusers', 'restrictedusers', 'webservice');
$mform->setType('restrictedusers', PARAM_BOOL);
// Can users download files?
$mform->addElement('advcheckbox', 'downloadfiles', get_string('downloadfiles', 'webservice'));
$mform->setAdvanced('downloadfiles');
$mform->addHelpButton('downloadfiles', 'downloadfiles', 'webservice');
$mform->setType('downloadfiles', PARAM_BOOL);
// Can users upload files?
$mform->addElement('advcheckbox', 'uploadfiles', get_string('uploadfiles', 'webservice'));
$mform->setAdvanced('uploadfiles');
$mform->addHelpButton('uploadfiles', 'uploadfiles', 'webservice');
/// needed to select automatically the 'No required capability" option
$currentcapabilityexist = false;
if (empty($service->requiredcapability)) {
$service->requiredcapability = "norequiredcapability";
$currentcapabilityexist = true;
}
// Prepare the list of capabilities to choose from
$systemcontext = context_system::instance();
$allcapabilities = $systemcontext->get_capabilities();
$capabilitychoices = array();
$capabilitychoices['norequiredcapability'] = get_string('norequiredcapability', 'webservice');
foreach ($allcapabilities as $cap) {
$capabilitychoices[$cap->name] = $cap->name . ': ' . get_capability_string($cap->name);
if (!empty($service->requiredcapability) && $service->requiredcapability == $cap->name) {
$currentcapabilityexist = true;
}
}
$mform->addElement('searchableselector', 'requiredcapability', get_string('requiredcapability', 'webservice'), $capabilitychoices);
$mform->addHelpButton('requiredcapability', 'requiredcapability', 'webservice');
$mform->setAdvanced('requiredcapability');
$mform->setType('requiredcapability', PARAM_RAW);
/// display notification error if the current requiredcapability doesn't exist anymore
if (empty($currentcapabilityexist)) {
global $OUTPUT;
$mform->addElement('static', 'capabilityerror', '', $OUTPUT->notification(get_string('selectedcapabilitydoesntexit', 'webservice', $service->requiredcapability)));
$service->requiredcapability = "norequiredcapability";
}
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
if (!empty($service->id)) {
$buttonlabel = get_string('savechanges');
} else {
$buttonlabel = get_string('addaservice', 'webservice');
}
$this->add_action_buttons(true, $buttonlabel);
$this->set_data($service);
}
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:59,代码来源:forms.php
示例4: capability_comparison_table
/**
* Produces a table to visually compare roles and capabilities.
*
* @param array $capabilities An array of capabilities to show comparison for.
* @param int $contextid The context we are displaying for.
* @param array $roles An array of roles to show comparison for.
* @return string
*/
public function capability_comparison_table(array $capabilities, $contextid, array $roles)
{
$strpermissions = $this->get_permission_strings();
$permissionclasses = $this->get_permission_classes();
if ($contextid === context_system::instance()->id) {
$strpermissions[CAP_INHERIT] = new lang_string('notset', 'role');
}
$table = new html_table();
$table->attributes['class'] = 'comparisontable';
$table->head = array(' ');
foreach ($roles as $role) {
$url = new moodle_url('/admin/roles/define.php', array('action' => 'view', 'roleid' => $role->id));
$table->head[] = html_writer::div(html_writer::link($url, $role->localname));
}
$table->data = array();
foreach ($capabilities as $capability) {
$contexts = tool_capability_calculate_role_data($capability, $roles);
$captitle = new html_table_cell(get_capability_string($capability) . html_writer::span($capability));
$captitle->header = true;
$row = new html_table_row(array($captitle));
foreach ($roles as $role) {
if (isset($contexts[$contextid]->rolecapabilities[$role->id])) {
$permission = $contexts[$contextid]->rolecapabilities[$role->id];
} else {
$permission = CAP_INHERIT;
}
$cell = new html_table_cell($strpermissions[$permission]);
$cell->attributes['class'] = $permissionclasses[$permission];
$row->cells[] = $cell;
}
$table->data[] = $row;
}
// Start the list item, and print the context name as a link to the place to make changes.
if ($contextid == context_system::instance()->id) {
$url = new moodle_url('/admin/roles/manage.php');
$title = get_string('changeroles', 'tool_capability');
} else {
$url = new moodle_url('/admin/roles/override.php', array('contextid' => $contextid));
$title = get_string('changeoverrides', 'tool_capability');
}
$context = context::instance_by_id($contextid);
$html = $this->output->heading(html_writer::link($url, $context->get_context_name(), array('title' => $title)), 3);
$html .= html_writer::table($table);
// If there are any child contexts, print them recursively.
if (!empty($contexts[$contextid]->children)) {
foreach ($contexts[$contextid]->children as $childcontextid) {
$html .= $this->capability_comparison_table($capabilities, $childcontextid, $roles, true);
}
}
return $html;
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:59,代码来源:renderer.php
示例5: capability_matrix
/**
* Outputs a matrix of roles and capabilities.
*
* @param int $contextid The context we are displaying for.
* @param array $capabilities An array of capabilities to show.
* @param array $roles An array of roles to show.
*/
function capability_matrix($contextid, array $capabilities, array $roles)
{
$strpermissions = get_permission_strings();
if ($contextid === context_system::instance()->id) {
$strpermissions[CAP_INHERIT] = new lang_string('notset', 'role');
}
// Start the list item.
$context = context::instance_by_id($contextid);
echo "\n" . $context->get_context_name() . "\t";
// Display the role names as headings.
foreach ($roles as $role) {
echo $role->localname . "\t";
}
echo "\n\n";
$matrix = array();
foreach ($capabilities as $capability) {
$contexts = tool_capability_calculate_role_data($capability, $roles);
echo get_capability_string($capability) . "\t";
foreach ($roles as $role) {
if (isset($contexts[$contextid]->rolecapabilities[$role->id])) {
$permission = $contexts[$contextid]->rolecapabilities[$role->id];
} else {
$permission = CAP_INHERIT;
}
echo $strpermissions[$permission] . "\t";
$matrix[$role][$capability] = $permission;
// for comparison matrix !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
echo "\n";
}
// If there are any child contexts, print them recursively.
if (!empty($contexts[$contextid]->children)) {
foreach ($contexts[$contextid]->children as $childcontextid) {
capability_comparison_table($capabilities, $childcontextid, $roles, true);
}
}
return;
}
开发者ID:OBU-OBIS,项目名称:moodle-local_roles,代码行数:45,代码来源:capabilities.php
示例6: capabilities
/**
* Display capabilities for role
*/
public function capabilities($capabilities, $roleid, $companyid)
{
global $DB;
// get heading
$company = $DB->get_record('company', array('id' => $companyid), '*', MUST_EXIST);
$role = $DB->get_record('role', array('id' => $roleid), '*', MUST_EXIST);
$out = '<h3>' . get_string('restrictcapabilitiesfor', 'block_iomad_company_admin', $company->name) . '</h3>';
$out .= '<p><b>' . get_string('rolename', 'block_iomad_company_admin', $role->name) . '</b></p>';
$out .= '<p>' . get_string('iomadcapabilities_boiler', 'block_iomad_company_admin') . '</p>';
$table = new html_table();
foreach ($capabilities as $capability) {
$checked = '';
if (!$capability->iomad_restriction) {
$checked = 'checked="checked"';
}
$value = "{$companyid}.{$roleid}.{$capability->capability}";
$caplink = '<a href="' . iomad::documentation_link() . $capability->capability . '">' . get_capability_string($capability->capability) . '</a>';
$row = array($caplink . '<br /><small>' . $capability->capability . '</small>', '<input class="checkbox" type="checkbox" ' . $checked . ' value="' . $value . '" />' . get_string('allow'));
$table->data[] = $row;
}
$out .= html_writer::table($table);
return $out;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:26,代码来源:renderer.php
示例7: load_choices
/**
* Load all of the uses who have the capability into choice array
*
* @return bool Always returns true
*/
function load_choices()
{
if (is_array($this->choices)) {
return true;
}
$users = get_users_by_capability(get_context_instance(CONTEXT_SYSTEM), $this->capability, 'u.id,u.username,u.firstname,u.lastname', 'u.lastname,u.firstname');
$this->choices = array('$@NONE@$' => get_string('nobody'), '$@ALL@$' => get_string('everyonewhocan', 'admin', get_capability_string($this->capability)));
if ($this->includeadmins) {
$admins = get_admins();
foreach ($admins as $user) {
$this->choices[$user->id] = fullname($user);
}
}
if (is_array($users)) {
foreach ($users as $user) {
$this->choices[$user->id] = fullname($user);
}
}
return true;
}
开发者ID:raymondAntonio,项目名称:moodle,代码行数:25,代码来源:adminlib.php
示例8: load_choices
/**
* Load all of the uses who have the capability into choice array
*
* @return bool Always returns true
*/
function load_choices()
{
if (is_array($this->choices)) {
return true;
}
list($sort, $sortparams) = users_order_by_sql('u');
if (!empty($sortparams)) {
throw new coding_exception('users_order_by_sql returned some query parameters. ' . 'This is unexpected, and a problem because there is no way to pass these ' . 'parameters to get_users_by_capability. See MDL-34657.');
}
$userfields = 'u.id, u.username, ' . get_all_user_name_fields(true, 'u');
$users = get_users_by_capability(context_system::instance(), $this->capability, $userfields, $sort);
$this->choices = array('$@NONE@$' => get_string('nobody'), '$@ALL@$' => get_string('everyonewhocan', 'admin', get_capability_string($this->capability)));
if ($this->includeadmins) {
$admins = get_admins();
foreach ($admins as $user) {
$this->choices[$user->id] = fullname($user);
}
}
if (is_array($users)) {
foreach ($users as $user) {
$this->choices[$user->id] = fullname($user);
}
}
return true;
}
开发者ID:Alexbado,项目名称:moodle2,代码行数:30,代码来源:adminlib.php
示例9: foreach
$view = 'viewowncontent';
} else {
if (empty($userid) && !empty($shared)) {
$sharedfiles = false;
if (!empty($USER->access['rdef'])) {
foreach ($USER->access['rdef'] as $ucontext) {
if ($sharedfiles) {
continue;
}
if (isset($ucontext['block/repository:viewsharedcontent']) && $ucontext['block/repository:viewsharedcontent']) {
$sharedfiles = true;
}
}
}
if (!$sharedfiles) {
$capabilityname = get_capability_string('block/repository:viewsharedcontent');
print_error('nopermissions', '', '', $capabilityname);
exit;
}
if (empty($uuid)) {
$uuid = $repo->suuid;
}
$view = 'viewsharedcontent';
} else {
if (!empty($id) && empty($oid) && empty($shared) && $id != SITEID) {
require_capability('block/repository:viewcoursecontent', $context, $USER->id);
$view = 'viewcoursecontent';
if (empty($uuid)) {
$uuid = $repo->get_course_store($id);
}
} else {
开发者ID:remotelearner,项目名称:elis.alfresco,代码行数:31,代码来源:link.php
示例10: require_capability
/**
* This is an easy to use function, combining has_capability() with require_course_login().
* And will call those where needed.
*
* It checks for a capability assertion being true. If it isn't
* then the page is terminated neatly with a standard error message.
*
* If the user is not logged in, or is using 'guest' access or other special "users,
* it provides a logon prompt.
*
* @param string $capability - name of the capability
* @param object $context - a context object (record from context table)
* @param integer $userid - a userid number
* @param bool $doanything - if false, ignore do anything
* @param string $errorstring - an errorstring
* @param string $stringfile - which stringfile to get it from
*/
function require_capability($capability, $context, $userid = NULL, $doanything = true, $errormessage = 'nopermissions', $stringfile = '')
{
global $USER, $CFG;
/* Empty $userid means current user, if the current user is not logged in,
* then make sure they are (if needed).
* Originally there was a check for loaded permissions - it is not needed here.
* Context is now required parameter, the cached $CONTEXT was only hiding errors.
*/
$errorlink = '';
if (empty($userid)) {
if ($context->contextlevel == CONTEXT_COURSE) {
require_login($context->instanceid);
} else {
if ($context->contextlevel == CONTEXT_MODULE) {
if (!($cm = get_record('course_modules', 'id', $context->instanceid))) {
error('Incorrect module');
}
if (!($course = get_record('course', 'id', $cm->course))) {
error('Incorrect course.');
}
require_course_login($course, true, $cm);
$errorlink = $CFG->wwwroot . '/course/view.php?id=' . $cm->course;
} else {
if ($context->contextlevel == CONTEXT_SYSTEM) {
if (!empty($CFG->forcelogin)) {
require_login();
}
} else {
require_login();
}
}
}
}
/// OK, if they still don't have the capability then print a nice error message
if (!has_capability($capability, $context, $userid, $doanything)) {
$capabilityname = get_capability_string($capability);
print_error($errormessage, $stringfile, $errorlink, $capabilityname);
}
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:56,代码来源:accesslib.php
示例11: dirname
require_once dirname(__FILE__) . '/../../../config.php';
require_once $CFG->dirroot . '/' . $CFG->admin . '/tool/capability/locallib.php';
require_once $CFG->libdir . '/adminlib.php';
// Get URL parameters.
$systemcontext = context_system::instance();
$contextid = optional_param('context', $systemcontext->id, PARAM_INT);
// Check permissions.
list($context, $course, $cm) = get_context_info_array($contextid);
require_login($course, false, $cm);
require_capability('moodle/role:manage', $context);
// Print the header.
admin_externalpage_setup('toolcapability');
// Prepare the list of capabilities to choose from.
$capabilitychoices = array();
foreach ($context->get_capabilities() as $cap) {
$capabilitychoices[$cap->name] = $cap->name . ': ' . get_capability_string($cap->name);
}
$allroles = role_fix_names(get_all_roles($context));
// Prepare the list of roles to choose from.
$rolechoices = array('0' => get_string('all'));
foreach ($allroles as $role) {
$rolechoices[$role->id] = $role->localname;
}
$form = new tool_capability_settings_form(null, array('capabilities' => $capabilitychoices, 'roles' => $rolechoices));
$PAGE->requires->yui_module('moodle-tool_capability-search', 'M.tool_capability.init_capability_search', array(array('strsearch' => get_string('search'))));
// Log.
$capabilities = array();
$rolestoshow = array();
$roleids = array('0');
$cleanedroleids = array();
if ($data = $form->get_data()) {
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:31,代码来源:index.php
示例12: foreach
}
}
// Put the role capabilites into the context tree.
if (!empty($rolecaps)) {
foreach ($rolecaps as $rolecap) {
$contexts[$rolecap->contextid]->rolecapabilites[$rolecap->roleid] = $rolecap->permission;
}
}
// Fill in any missing rolecaps for the system context.
foreach ($cleanedroleids as $roleid) {
if (!isset($contexts[$systemcontext->id]->rolecapabilites[$roleid])) {
$contexts[$systemcontext->id]->rolecapabilites[$roleid] = CAP_INHERIT;
}
}
// Print the report heading.
print_heading(get_string('reportforcapability', 'report_capability', get_capability_string($capability)), '', 2, 'main', false, 'report');
if (count($cleanedroleids) != count($allroles)) {
$rolenames = array();
foreach ($cleanedroleids as $roleid) {
$rolenames[] = $allroles[$roleid]->name;
}
echo '<p>', get_string('forroles', 'report_capability', implode(', ', $rolenames)), '</p>';
}
// Now, recursively print the contexts, and the role information.
print_report_tree($systemcontext->id, $contexts, $allroles);
}
// Footer.
admin_externalpage_print_footer();
function print_report_tree($contextid, $contexts, $allroles)
{
global $CFG;
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:index.php
示例13: foreach
if ($parentcontextid) {
$contexts[$parentcontextid]->children[] = $conid;
}
}
// Put the role capabilities into the context tree.
foreach ($rolecaps as $rolecap) {
$contexts[$rolecap->contextid]->rolecapabilities[$rolecap->roleid] = $rolecap->permission;
}
// Fill in any missing rolecaps for the system context.
foreach ($cleanedroleids as $roleid) {
if (!isset($contexts[$systemcontext->id]->rolecapabilities[$roleid])) {
$contexts[$systemcontext->id]->rolecapabilities[$roleid] = CAP_INHERIT;
}
}
// Print the report heading.
echo $OUTPUT->heading(get_string('reportforcapability', 'report_capability', get_capability_string($capability)), 2, 'main', 'report');
if (count($cleanedroleids) != count($allroles)) {
$rolenames = array();
foreach ($cleanedroleids as $roleid) {
$rolenames[] = $allroles[$roleid]->name;
}
echo '<p>', get_string('forroles', 'report_capability', implode(', ', $rolenames)), '</p>';
}
// Now, recursively print the contexts, and the role information.
print_report_tree($systemcontext->id, $contexts, $allroles);
}
// Footer.
echo $OUTPUT->footer();
function print_report_tree($contextid, $contexts, $allroles)
{
global $CFG;
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:index.php
示例14: array
$declines = array();
// If a user can take attendance, they can approve staff's booking requests.
if ($cantakeattendance) {
$requests = facetoface_get_requests($session->id);
}
// If requests found (but not in the middle of taking attendance), show requests table.
if ($requests && !$takeattendance) {
$canapproverequests = true;
}
// Check the user is allowed to view this page.
if (!$canviewattendees && !$cantakeattendance && !$canapproverequests && !$canviewcancellations) {
print_error('nopermissions', '', "{$CFG->wwwroot}/mod/facetoface/view.php?id={$cm->id}", get_string('view'));
}
// Check user has permissions to take attendance.
if ($takeattendance && !$cantakeattendance) {
print_error('nopermissions', '', '', get_capability_string('mod/facetoface:takeattendance'));
}
/*
* Handle submitted data
*/
if ($form = data_submitted()) {
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', 'error');
}
$return = "{$CFG->wwwroot}/mod/facetoface/attendees.php?s={$s}&backtoallsessions={$backtoallsessions}";
if ($cancelform) {
redirect($return);
} else {
if (!empty($form->requests)) {
// Approve requests.
if ($canapproverequests && facetoface_approve_requests($form)) {
开发者ID:Mihailoff,项目名称:facetoface-2.0,代码行数:31,代码来源:attendees.php
示例15: list
// $Id: exportgood.php,v 1.4 2008/12/02 09:49:53 jamiesensei Exp $
/**
* Export questions in the given category and which have been assigned a grade
* above a certain level.
*
* @author Martin Dougiamas, Howard Miller, Jamie Pratt and many others.
* {@link http://moodle.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
require_once "../../config.php";
require_once $CFG->dirroot . "/question/editlib.php";
require_once "export_good_questions_form.php";
list($thispageurl, $contexts, $cmid, $cm, $qcreate, $pagevars) = question_edit_setup('export', true);
if (!has_capability('moodle/question:viewmine', $contexts->lowest()) && !has_capability('moodle/question:viewall', $contexts->lowest())) {
$capabilityname = get_capability_string('moodle/question:viewmine');
print_error('nopermissions', '', '', $capabilityname);
}
// get display strings
$txt = new object();
$txt->category = get_string('category', 'quiz');
$txt->download = get_string('download', 'quiz');
$txt->downloadextra = get_string('downloadextra', 'quiz');
$txt->exporterror = get_string('exporterror', 'quiz');
$txt->exportname = get_string('exportname', 'quiz');
$txt->exportquestions = get_string('exportquestions', 'quiz');
$txt->fileformat = get_string('fileformat', 'quiz');
$txt->exportcategory = get_string('exportcategory', 'quiz');
$txt->modulename = get_string('modulename', 'quiz');
$txt->modulenameplural = get_string('modulenameplural', 'quiz');
$txt->tofile = get_string('tofile', 'quiz');
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:30,代码来源:exportgood.php
示例16: get_cap_string
function get_cap_string($capability)
{
global $CFG;
$doc_ref = 'http://docs.moodle.org/' . $CFG->lang . '/Capabilities/' . $capability['name'];
return "<td class=\"action\">\n <span class=\"cap_friendly_name\"><a href=\"{$doc_ref}\">" . get_capability_string($capability['name']) . "</a></span>\n <span class=\"cap_name\">{$capability['name']}</span>" . get_risks_images($capability) . '</td>';
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:6,代码来源:index.php
示例17: get_row_attributes
/**
* Add additional attributes to row
*
* @param stdClass $capability capability that this table row relates to.
* @return array key value pairs of attribute names and values.
*/
protected function get_row_attributes($capability)
{
return array('data-id' => $capability->id, 'data-name' => $capability->name, 'data-humanname' => get_capability_string($capability->name));
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:10,代码来源:permissions_table.php
示例18: require_capability
/**
* This is an easy to use function, combining has_capability() with require_course_login().
* And will call those where needed.
*
* It checks for a capability assertion being true. If it isn't
* then the page is terminated neatly with a standard error message.
*
* If the user is not logged in, or is using 'guest' access or other special "users,
* it provides a logon prompt.
*
* @param string $capability - name of the capability
* @param object $context - a context object (record from context table)
* @param integer $userid - a userid number
* @param bool $doanything - if false, ignore do anything
* @param string $errorstring - an errorstring
* @param string $stringfile - which stringfile to get it from
*/
function require_capability($capability, $context = NULL, $userid = NULL, $doanything = true, $errormessage = 'nopermissions', $stringfile = '')
{
global $USER, $CFG;
/// If the current user is not logged in, then make sure they are (if needed)
if (is_null($userid) && !isset($USER->access)) {
if ($context && $context->contextlevel == CONTEXT_COURSE) {
require_login($context->instanceid);
} else {
if ($context && $context->contextlevel == CONTEXT_MODULE) {
if ($cm = get_record('course_modules', 'id', $context->instanceid)) {
if (!($course = get_record('course', 'id', $cm->course))) {
error('Incorrect course.');
}
require_course_login($course, true, $cm);
} else {
require_login();
}
} else {
if ($context && $context->contextlevel == CONTEXT_SYSTEM) {
if (!empty($CFG->forcelogin)) {
require_login();
}
} else {
require_login();
}
}
}
}
/// OK, if they still don't have the capability then print a nice error message
if (!has_capability($capability, $context, $userid, $doanything)) {
$capabilityname = get_capability_string($capability);
print_error($errormessage, $stringfile, '', $capabilityname);
}
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:51,代码来源:accesslib.php
示例19: __construct
/**
* Constructor
* @param context $context The context used for the capability check
* @param string $capability The required capability
* @param string $errormessage The error message to show the user
* @param string $stringfile
*/
function __construct($context, $capability, $errormessage, $stringfile)
{
$capabilityname = get_capability_string($capability);
if ($context->contextlevel == CONTEXT_MODULE and preg_match('/:view$/', $capability)) {
// we can not go to mod/xx/view.php because we most probably do not have cap to view it, let's go to course instead
$paranetcontext = context::instance_by_id(get_parent_contextid($context));
$link = get_context_url($paranetcontext);
} else {
$link = get_context_url($context);
}
parent::__construct($errormessage, $stringfile, $link, $capabilityname);
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:19,代码来源:setuplib.php
示例20: html_header
function html_header($course, $wdir, $formfield = "")
{
global $CFG, $ME, $USER, $id, $shared, $userid, $oid, $uuid, $repo, $canedit;
/// Get the appropriate context for the site, course or organization.
if (!empty($oid)) {
$cluster_context = get_context_instance(context_level_base::get_custom_context_level('cluster', 'block_curr_admin'), $oid);
}
if ($id == SITEID) {
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
} else {
$context = get_context_instance(CONTEXT_COURSE, $id);
}
/// Make sure that we have the correct 'base' UUID for a course or user storage area as well
/// as checking for correct permissions.
if (!empty($userid) && !empty($id)) {
$personalfiles = false;
if (!empty($USER->access['rdef'])) {
foreach ($USER->access['rdef'] as $ucontext) {
if ($personalfiles) {
continue;
}
if (isset($ucontext['block/repository:viewowncontent']) && $ucontext['block/repository:viewowncontent'] == CAP_ALLOW) {
$personalfiles = true;
}
}
}
if (!$personalfiles) {
$capabilityname = get_capability_string('block/repository:viewowncontent');
print_error('nopermissions', '', '', $capabilityname);
exit;
}
if (empty($uuid)) {
$uuid = $repo->get_user_store($userid);
}
} else {
if (empty($userid) && !empty($shared)) {
$sharedfiles = false;
if (!empty($USER->access['rdef'])) {
foreach ($USER->access['rdef'] as $ucontext) {
if ($sharedfiles) {
continue;
}
if (isset($ucontext['block/repository:viewsharedcontent']) && $ucontext['block/repository:viewsharedcontent'] == CAP_ALLOW) {
$sharedfiles = true;
}
}
}
if (!$sharedfiles) {
$capabilityname = get_capability_string('block/repository:viewsharedcontent');
print_error('nopermissions', '', '', $capabilityname);
exit;
}
if (empty($uuid)) {
$uuid = $repo->suuid;
}
} else {
if (!empty($id) && empty($oid) && $id != SITEID) {
require_capability('block/repository:viewcoursecontent', $context, $USER->id);
if (empty($uuid)) {
$uuid = $repo->get_course_store($id);
}
} else {
if (!empty($oid)) {
require_capability('block/repository:vieworganizationcontent', $cluster_context, $USER->id);
if (empty($uuid)) {
$uuid = $repo->get_organization_store($oid);
}
} else {
require_capability('block/repository:viewsitecontent', $context, $USER->id);
if (empty($uuid)) {
if ($root = $repo->get_root()) {
$uuid = $root->uuid;
}
}
}
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>coursefiles</title>
<script type="text/javascript">
//<![CDATA[
function set_value(params) {
/// function's argument is an object containing necessary values
/// to export parent window (url,isize,itype,iwidth,iheight, imodified)
/// set values when user click's an image name.
var upper = window.parent;
var insimg = upper.document.getElementById('f_url');
try {
if(insimg != null) {
if(params.itype.indexOf("image/gif") == -1 && params.itype.indexOf("image/jpeg") == -1 && params.itype.indexOf("image/png") == -1) {
alert("<?php
//.........这里部分代码省略.........
开发者ID:remotelearner,项目名称:elis.alfresco,代码行数:101,代码来源:coursefiles.php
注:本文中的get_capability_string函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论