• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP badges_bake函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中badges_bake函数的典型用法代码示例。如果您正苦于以下问题:PHP badges_bake函数的具体用法?PHP badges_bake怎么用?PHP badges_bake使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了badges_bake函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: dirname

 * @subpackage badges
 * @copyright  2012 onwards Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @author     Yuliya Bozhko <[email protected]>
 */
require_once dirname(dirname(__FILE__)) . '/config.php';
require_once $CFG->libdir . '/badgeslib.php';
$id = required_param('hash', PARAM_ALPHANUM);
$bake = optional_param('bake', 0, PARAM_BOOL);
$PAGE->set_context(context_system::instance());
$output = $PAGE->get_renderer('core', 'badges');
$badge = new issued_badge($id);
if ($bake && $badge->recipient->id == $USER->id) {
    $name = str_replace(' ', '_', $badge->badgeclass['name']) . '.png';
    ob_start();
    $file = badges_bake($id, $badge->badgeid);
    header('Content-Type: image/png');
    header('Content-Disposition: attachment; filename="' . $name . '"');
    readfile($file);
    ob_flush();
}
$PAGE->set_url('/badges/badge.php', array('hash' => $id));
$PAGE->set_pagelayout('base');
$PAGE->set_title(get_string('issuedbadge', 'badges'));
if (isloggedin()) {
    $PAGE->set_heading($badge->badgeclass['name']);
    $PAGE->navbar->add($badge->badgeclass['name']);
    if ($badge->recipient->id == $USER->id) {
        $url = new moodle_url('/badges/mybadges.php');
    } else {
        $url = new moodle_url($CFG->wwwroot);
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:31,代码来源:badge.php


示例2: require_sesskey

if ($clearsearch) {
    $search = '';
}
if ($hide) {
    require_sesskey();
    $DB->set_field('badge_issued', 'visible', 0, array('id' => $hide, 'userid' => $USER->id));
} else {
    if ($show) {
        require_sesskey();
        $DB->set_field('badge_issued', 'visible', 1, array('id' => $show, 'userid' => $USER->id));
    } else {
        if ($download && $hash) {
            require_sesskey();
            $badge = new badge($download);
            $name = str_replace(' ', '_', $badge->name) . '.png';
            $filehash = badges_bake($hash, $download, $USER->id, true);
            $fs = get_file_storage();
            $file = $fs->get_file_by_hash($filehash);
            send_stored_file($file, 0, 0, true, array('filename' => $name));
        } else {
            if ($downloadall) {
                require_sesskey();
                badges_download($USER->id);
            }
        }
    }
}
$context = context_user::instance($USER->id);
require_capability('moodle/badges:manageownbadges', $context);
$PAGE->set_context($context);
$title = get_string('mybadges', 'badges');
开发者ID:grug,项目名称:moodle,代码行数:31,代码来源:mybadges.php


示例3: required_param

 * @subpackage badges
 * @copyright  2012 onwards Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @author     Yuliya Bozhko <[email protected]>
 */
require_once __DIR__ . '/../config.php';
require_once $CFG->libdir . '/badgeslib.php';
require_once $CFG->libdir . '/filelib.php';
$id = required_param('hash', PARAM_ALPHANUM);
$bake = optional_param('bake', 0, PARAM_BOOL);
$PAGE->set_context(context_system::instance());
$output = $PAGE->get_renderer('core', 'badges');
$badge = new issued_badge($id);
if ($bake && $badge->recipient->id == $USER->id) {
    $name = str_replace(' ', '_', $badge->badgeclass['name']) . '.png';
    $filehash = badges_bake($id, $badge->badgeid, $USER->id, true);
    $fs = get_file_storage();
    $file = $fs->get_file_by_hash($filehash);
    send_stored_file($file, 0, 0, true, array('filename' => $name));
}
$PAGE->set_url('/badges/badge.php', array('hash' => $id));
$PAGE->set_pagelayout('base');
$PAGE->set_title(get_string('issuedbadge', 'badges'));
if (isloggedin()) {
    $PAGE->set_heading($badge->badgeclass['name']);
    $PAGE->navbar->add($badge->badgeclass['name']);
    if ($badge->recipient->id == $USER->id) {
        $url = new moodle_url('/badges/mybadges.php');
    } else {
        $url = new moodle_url($CFG->wwwroot);
    }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:31,代码来源:badge.php


示例4: require_sesskey

    $search = '';
}
if ($hide) {
    require_sesskey();
    $DB->set_field('badge_issued', 'visible', 0, array('id' => $hide));
} else {
    if ($show) {
        require_sesskey();
        $DB->set_field('badge_issued', 'visible', 1, array('id' => $show));
    } else {
        if ($download && $hash) {
            require_sesskey();
            $badge = new badge($download);
            $name = str_replace(' ', '_', $badge->name) . '.png';
            ob_start();
            $file = badges_bake($hash, $download);
            header('Content-Type: image/png');
            header('Content-Disposition: attachment; filename="' . $name . '"');
            readfile($file);
            ob_flush();
        } else {
            if ($downloadall) {
                require_sesskey();
                ob_start();
                badges_download($USER->id);
                ob_flush();
            }
        }
    }
}
$context = context_user::instance($USER->id);
开发者ID:helenagarcia90,项目名称:moodle,代码行数:31,代码来源:mybadges.php


示例5: issue

 /**
  * Issue a badge to user.
  *
  * @param int $userid User who earned the badge
  * @param bool $nobake Not baking actual badges (for testing purposes)
  */
 public function issue($userid, $nobake = false)
 {
     global $DB, $CFG;
     $now = time();
     $issued = new stdClass();
     $issued->badgeid = $this->id;
     $issued->userid = $userid;
     $issued->uniquehash = sha1(rand() . $userid . $this->id . $now);
     $issued->dateissued = $now;
     if ($this->can_expire()) {
         $issued->dateexpire = $this->calculate_expiry($now);
     } else {
         $issued->dateexpire = null;
     }
     // Take into account user badges privacy settings.
     // If none set, badges default visibility is set to public.
     $issued->visible = get_user_preferences('badgeprivacysetting', 1, $userid);
     $result = $DB->insert_record('badge_issued', $issued, true);
     if ($result) {
         // Trigger badge awarded event.
         $eventdata = array('context' => $this->get_context(), 'objectid' => $this->id, 'relateduserid' => $userid, 'other' => array('dateexpire' => $issued->dateexpire, 'badgeissuedid' => $result));
         \core\event\badge_awarded::create($eventdata)->trigger();
         // Lock the badge, so that its criteria could not be changed any more.
         if ($this->status == BADGE_STATUS_ACTIVE) {
             $this->set_status(BADGE_STATUS_ACTIVE_LOCKED);
         }
         // Update details in criteria_met table.
         $compl = $this->get_criteria_completions($userid);
         foreach ($compl as $c) {
             $obj = new stdClass();
             $obj->id = $c->id;
             $obj->issuedid = $result;
             $DB->update_record('badge_criteria_met', $obj, true);
         }
         if (!$nobake) {
             // Bake a badge image.
             $pathhash = badges_bake($issued->uniquehash, $this->id, $userid, true);
             // Notify recipients and badge creators.
             badges_notify_badge_award($this, $userid, $issued->uniquehash, $pathhash);
         }
     }
 }
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:48,代码来源:badgeslib.php


示例6: get_badges_by_username

 /**
  * Get user information
  *
  * @param string $username EBS username, could be 8-digit int or string.
  * @return array An array describing targets (and metadata) for that user for all leapcore_* courses.
  */
 public static function get_badges_by_username($username)
 {
     global $CFG, $DB;
     $params = self::validate_parameters(self::get_badges_by_username_parameters(), array('username' => $username));
     if ($params['username'] == '') {
         header($_SERVER["SERVER_PROTOCOL"] . ' 422 Unprocessable Entity ($params[\'username\'] empty.)', true, 422);
         exit(1);
     }
     // Could do with knowing what this user's {user}.id is.
     $sql = "SELECT id from {user} WHERE username LIKE ?;";
     if (!($user = $DB->get_record_sql($sql, array($params['username'] . '%')))) {
         header($_SERVER["SERVER_PROTOCOL"] . ' 422 Unprocessable Entity ($params[\'username\'] could not be matched against a valid user.)', true, 422);
         exit(1);
     }
     require_once $CFG->libdir . '/badgeslib.php';
     // Get the user's badges.
     $userbadges = badges_get_user_badges($user->id);
     $output = array();
     if (!$userbadges) {
         return $output;
     } else {
         $output = array();
         $count = 0;
         foreach ($userbadges as $hash => $ubadge) {
             $count++;
             $output[$count]['course_id'] = $ubadge->courseid;
             $output[$count]['date_issued'] = $ubadge->dateissued;
             $output[$count]['description'] = $ubadge->description;
             $output[$count]['details_link'] = (string) new moodle_url('/badges/badge.php', array('hash' => $hash));
             $output[$count]['image_url'] = (string) badges_bake($hash, $ubadge->id);
             $output[$count]['name'] = $ubadge->name;
         }
     }
     return $output;
 }
开发者ID:kevtufc,项目名称:leap,代码行数:41,代码来源:externallib.php



注:本文中的badges_bake函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP badges_get_user_badges函数代码示例发布时间:2022-05-24
下一篇:
PHP badges_add_course_navigation函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap