本文整理汇总了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);
示例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();
}
示例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');
}
示例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);
}