当前位置: 首页>>代码示例>>PHP>>正文


PHP badge::set_status方法代码示例

本文整理汇总了PHP中badge::set_status方法的典型用法代码示例。如果您正苦于以下问题:PHP badge::set_status方法的具体用法?PHP badge::set_status怎么用?PHP badge::set_status使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在badge的用法示例。


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

示例1: redirect

        if ($badge->is_locked()) {
            $badge->set_status(BADGE_STATUS_ACTIVE_LOCKED);
            $msg = get_string('activatesuccess', 'badges');
        } else {
            require_sesskey();
            $badge->set_status(BADGE_STATUS_ACTIVE);
            $msg = get_string('activatesuccess', 'badges');
        }
        $returnurl->param('msg', $msg);
        redirect($returnurl);
    }
} else {
    if ($deactivate && has_capability('moodle/badges:configuredetails', $PAGE->context)) {
        $badge = new badge($deactivate);
        if ($badge->is_locked()) {
            $badge->set_status(BADGE_STATUS_INACTIVE_LOCKED);
            $msg = get_string('deactivatesuccess', 'badges');
        } else {
            require_sesskey();
            $badge->set_status(BADGE_STATUS_INACTIVE);
            $msg = get_string('deactivatesuccess', 'badges');
        }
        $returnurl->param('msg', $msg);
        redirect($returnurl);
    }
}
echo $OUTPUT->header();
if ($type == BADGE_TYPE_SITE) {
    echo $OUTPUT->heading_with_help($PAGE->heading, 'sitebadges', 'badges');
} else {
    echo $OUTPUT->heading($PAGE->heading);
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:index.php

示例2: test_badge_enabled

 /**
  * Test the badge enabled event.
  *
  */
 public function test_badge_enabled()
 {
     $badge = new badge($this->badgeid);
     $sink = $this->redirectEvents();
     // Trigger and capture the event.
     $badge->set_status(BADGE_STATUS_ACTIVE);
     $events = $sink->get_events();
     $event = reset($events);
     $this->assertCount(2, $events);
     $event = $events[1];
     // Check that the event data is valid.
     $this->assertInstanceOf('\\core\\event\\badge_enabled', $event);
     $this->assertEquals($badge->id, $event->objectid);
     $this->assertDebuggingNotCalled();
     $sink->close();
 }
开发者ID:evltuma,项目名称:moodle,代码行数:20,代码来源:events_test.php

示例3: redirect

    require_sesskey();
    require_capability('moodle/badges:createbadge', $context);
    $cloneid = $badge->make_clone();
    // If a user can edit badge details, they will be redirected to the edit page.
    if (has_capability('moodle/badges:configuredetails', $context)) {
        redirect(new moodle_url('/badges/edit.php', array('id' => $cloneid, 'action' => 'details')));
    }
    redirect(new moodle_url('/badges/overview.php', array('id' => $cloneid)));
}
if ($activate) {
    require_capability('moodle/badges:configurecriteria', $context);
    $PAGE->url->param('activate', 1);
    $status = $badge->status == BADGE_STATUS_INACTIVE ? BADGE_STATUS_ACTIVE : BADGE_STATUS_ACTIVE_LOCKED;
    if ($confirm == 1) {
        require_sesskey();
        $badge->set_status($status);
        $returnurl->param('msg', 'activatesuccess');
        if ($badge->type == BADGE_TYPE_SITE) {
            // Review on cron if there are more than 1000 users who can earn a site-level badge.
            $sql = 'SELECT COUNT(u.id) as num
                        FROM {user} u
                        LEFT JOIN {badge_issued} bi
                            ON u.id = bi.userid AND bi.badgeid = :badgeid
                        WHERE bi.badgeid IS NULL AND u.id != :guestid AND u.deleted = 0';
            $toearn = $DB->get_record_sql($sql, array('badgeid' => $badge->id, 'guestid' => $CFG->siteguest));
            if ($toearn->num < 1000) {
                $awards = $badge->review_all_criteria();
                $returnurl->param('awards', $awards);
            } else {
                $returnurl->param('awards', 'cron');
            }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:action.php

示例4: test_badge_status

 public function test_badge_status()
 {
     $badge = new badge($this->badgeid);
     $old_status = $badge->status;
     $badge->set_status(BADGE_STATUS_ACTIVE);
     $this->assertAttributeNotEquals($old_status, 'status', $badge);
     $this->assertAttributeEquals(BADGE_STATUS_ACTIVE, 'status', $badge);
 }
开发者ID:nikitskynikita,项目名称:moodle,代码行数:8,代码来源:badgeslib_test.php


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