本文整理汇总了PHP中core_availability\info::get_modinfo方法的典型用法代码示例。如果您正苦于以下问题:PHP info::get_modinfo方法的具体用法?PHP info::get_modinfo怎么用?PHP info::get_modinfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_availability\info
的用法示例。
在下文中一共展示了info::get_modinfo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_available
public function is_available($not, \core_availability\info $info, $grabthelot, $userid)
{
$context = \context_course::instance($info->get_course()->id);
$allow = true;
if (!has_capability('moodle/site:accessallgroups', $context, $userid)) {
// If the activity has 'group members only' and you don't have accessallgroups...
$groups = $info->get_modinfo()->get_groups($this->get_grouping_id($info));
if (!$groups) {
// ...and you don't belong to a group, then set it so you can't see/access it.
$allow = false;
}
// The NOT condition applies before accessallgroups (i.e. if you
// set something to be available to those NOT in grouping X,
// people with accessallgroups can still access it even if
// they are in grouping X).
if ($not) {
$allow = !$allow;
}
}
return $allow;
}
示例2: is_available
public function is_available($not, \core_availability\info $info, $grabthelot, $userid)
{
$course = $info->get_course();
$context = \context_course::instance($course->id);
$allow = true;
if (!has_capability('moodle/site:accessallgroups', $context, $userid)) {
// Get all groups the user belongs to.
$groups = $info->get_modinfo()->get_groups();
if ($this->groupid) {
$allow = in_array($this->groupid, $groups);
} else {
// No specific group. Allow if they belong to any group at all.
$allow = $groups ? true : false;
}
// The NOT condition applies before accessallgroups (i.e. if you
// set something to be available to those NOT in group X,
// people with accessallgroups can still access it even if
// they are in group X).
if ($not) {
$allow = !$allow;
}
}
return $allow;
}
示例3: get_description
public function get_description($full, $not, \core_availability\info $info)
{
// Get name for module.
$modinfo = $info->get_modinfo();
if (!array_key_exists($this->cmid, $modinfo->cms)) {
$modname = get_string('missing', 'availability_completion');
} else {
$modname = '<AVAILABILITY_CMNAME_' . $modinfo->cms[$this->cmid]->id . '/>';
}
// Work out which lang string to use.
if ($not) {
// Convert NOT strings to use the equivalent where possible.
switch ($this->expectedcompletion) {
case COMPLETION_INCOMPLETE:
$str = 'requires_' . self::get_lang_string_keyword(COMPLETION_COMPLETE);
break;
case COMPLETION_COMPLETE:
$str = 'requires_' . self::get_lang_string_keyword(COMPLETION_INCOMPLETE);
break;
default:
// The other two cases do not have direct opposites.
$str = 'requires_not_' . self::get_lang_string_keyword($this->expectedcompletion);
break;
}
} else {
$str = 'requires_' . self::get_lang_string_keyword($this->expectedcompletion);
}
return get_string($str, 'availability_completion', $modname);
}
示例4: get_description
public function get_description($full, $not, \core_availability\info $info)
{
// Get name for module.
$modinfo = $info->get_modinfo();
if (!isset($this->expectedpublicprivate)) {
$modname = get_string('missing', 'availability_publicprivate');
}
// // Work out which lang string to use.
// if ($not) {
// // Convert NOT strings to use the equivalent where possible.
// switch ($this->expectedpublicprivate) {
// case COMPLETION_INCOMPLETE:
// $str = 'requires_' . self::get_lang_string_keyword(COMPLETION_COMPLETE);
// break;
// case COMPLETION_COMPLETE:
// $str = 'requires_' . self::get_lang_string_keyword(COMPLETION_INCOMPLETE);
// break;
// default:
// // The other two cases do not have direct opposites.
// $str = 'requires_not_' . self::get_lang_string_keyword($this->expectedpublicprivate);
// break;
// }
// } else {
// $str = 'requires_' . self::get_lang_string_keyword($this->expectedpublicprivate);
// }
if ($this->expectedpublicprivate === PUBLICPRIVATE_PRIVATE) {
$str = 'requires_private';
} else {
$str = 'requires_public';
}
return get_string($str, 'availability_publicprivate');
}