本文整理汇总了PHP中get_backpack_settings函数的典型用法代码示例。如果您正苦于以下问题:PHP get_backpack_settings函数的具体用法?PHP get_backpack_settings怎么用?PHP get_backpack_settings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_backpack_settings函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: core_badges_myprofile_navigation
/**
* Add nodes to myprofile page.
*
* @param \core_user\output\myprofile\tree $tree Tree object
* @param stdClass $user user object
* @param bool $iscurrentuser
* @param stdClass $course Course object
*
* @return bool
*/
function core_badges_myprofile_navigation(\core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course)
{
global $CFG, $PAGE, $USER, $SITE;
require_once $CFG->dirroot . '/badges/renderer.php';
if (empty($CFG->enablebadges) || !empty($course) && empty($CFG->badges_allowcoursebadges)) {
// Y U NO LIKE BADGES ?
return true;
}
// Add category. This node should appear after 'contact' so that administration block appears towards the end. Refer MDL-49928.
$category = new core_user\output\myprofile\category('badges', get_string('badges', 'badges'), 'contact');
$tree->add_category($category);
$context = context_user::instance($user->id);
$courseid = empty($course) ? 0 : $course->id;
if ($USER->id == $user->id || has_capability('moodle/badges:viewotherbadges', $context)) {
$records = badges_get_user_badges($user->id, $courseid, null, null, null, true);
$renderer = new core_badges_renderer($PAGE, '');
// Local badges.
if ($records) {
$title = get_string('localbadgesp', 'badges', format_string($SITE->fullname));
$content = $renderer->print_badges_list($records, $user->id, true);
$localnode = $mybadges = new core_user\output\myprofile\node('badges', 'localbadges', $title, null, null, $content);
$tree->add_node($localnode);
}
// External badges.
if ($courseid == 0 && !empty($CFG->badges_allowexternalbackpack)) {
$backpack = get_backpack_settings($user->id);
if (isset($backpack->totalbadges) && $backpack->totalbadges !== 0) {
$title = get_string('externalbadgesp', 'badges');
$content = $renderer->print_badges_list($backpack->badges, $user->id, true, true);
$externalnode = $mybadges = new core_user\output\myprofile\node('badges', 'externalbadges', $title, null, null, $content);
$tree->add_node($externalnode);
}
}
}
}
开发者ID:evltuma,项目名称:moodle,代码行数:45,代码来源:lib.php
示例2: __construct
/**
* Initializes user badge collection.
*
* @param array $badges Badges to render
* @param int $userid Badges owner
*/
public function __construct($badges, $userid)
{
global $CFG;
parent::__construct($badges);
if (!empty($CFG->badges_allowexternalbackpack)) {
$this->backpack = get_backpack_settings($userid);
}
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:14,代码来源:renderer.php
示例3: profile_display_badges
/**
* Print badges on user profile page.
*
* @deprecated since Moodle 2.9 MDL-45898 - please do not use this function any more.
* @param int $userid User ID.
* @param int $courseid Course if we need to filter badges (optional).
*/
function profile_display_badges($userid, $courseid = 0)
{
global $CFG, $PAGE, $USER, $SITE;
require_once $CFG->dirroot . '/badges/renderer.php';
debugging('profile_display_badges() is deprecated.', DEBUG_DEVELOPER);
// Determine context.
if (isloggedin()) {
$context = context_user::instance($USER->id);
} else {
$context = context_system::instance();
}
if ($USER->id == $userid || has_capability('moodle/badges:viewotherbadges', $context)) {
$records = badges_get_user_badges($userid, $courseid, null, null, null, true);
$renderer = new core_badges_renderer($PAGE, '');
// Print local badges.
if ($records) {
$left = get_string('localbadgesp', 'badges', format_string($SITE->fullname));
$right = $renderer->print_badges_list($records, $userid, true);
echo html_writer::tag('dt', $left);
echo html_writer::tag('dd', $right);
}
// Print external badges.
if ($courseid == 0 && !empty($CFG->badges_allowexternalbackpack)) {
$backpack = get_backpack_settings($userid);
if (isset($backpack->totalbadges) && $backpack->totalbadges !== 0) {
$left = get_string('externalbadgesp', 'badges');
$right = $renderer->print_badges_list($backpack->badges, $userid, true, true);
echo html_writer::tag('dt', $left);
echo html_writer::tag('dd', $right);
}
}
}
}
开发者ID:speciwoman,项目名称:moodle,代码行数:40,代码来源:deprecatedlib.php
示例4: required_param
$userid = required_param('user', PARAM_INT);
$PAGE->set_url(new moodle_url('/badges/external.php', array('hash' => $hash, 'user' => $userid)));
// Using the same setting as user profile page.
if (!empty($CFG->forceloginforprofiles)) {
require_login();
if (isguestuser()) {
$SESSION->wantsurl = $PAGE->url->out(false);
redirect(get_login_url());
}
} else {
if (!empty($CFG->forcelogin)) {
require_login();
}
}
// Get all external badges of a user.
$out = get_backpack_settings($userid);
// If we didn't find any badges then print an error.
if (is_null($out)) {
print_error('error:externalbadgedoesntexist', 'badges');
}
$badges = $out->badges;
// The variable to store the badge we want.
$badge = '';
// Loop through the badges and check if supplied badge hash exists in user external badges.
foreach ($badges as $b) {
if ($hash == hash("md5", $b->hostedUrl)) {
$badge = $b;
break;
}
}
// If we didn't find the badge a user might be trying to replace the userid parameter.
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:external.php
注:本文中的get_backpack_settings函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论