本文整理汇总了PHP中badge::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP badge::delete方法的具体用法?PHP badge::delete怎么用?PHP badge::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类badge
的用法示例。
在下文中一共展示了badge::delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirect
redirect($CFG->wwwroot);
}
$PAGE->set_title($hdr);
$PAGE->requires->js('/badges/backpack.js');
$PAGE->requires->js_init_call('check_site_access', null, false);
$output = $PAGE->get_renderer('core', 'badges');
if ($delete && has_capability('moodle/badges:deletebadge', $PAGE->context)) {
$badge = new badge($delete);
if (!$confirm) {
echo $output->header();
echo $output->confirm(get_string('delconfirm', 'badges', $badge->name), new moodle_url($PAGE->url, array('delete' => $badge->id, 'confirm' => 1)), $returnurl);
echo $output->footer();
die;
} else {
require_sesskey();
$badge->delete();
redirect($returnurl);
}
}
if ($activate && has_capability('moodle/badges:configuredetails', $PAGE->context)) {
$badge = new badge($activate);
if (!$badge->has_criteria()) {
$err = get_string('error:cannotact', 'badges') . get_string('nocriteria', 'badges');
} else {
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');
示例2: test_delete_badge
public function test_delete_badge()
{
$badge = new badge($this->badgeid);
$badge->delete();
// We don't actually delete badges. We archive them.
$this->assertAttributeEquals(BADGE_STATUS_ARCHIVED, 'status', $badge);
}
示例3: test_badge_deleted
/**
* Test the badge deleted event.
*/
public function test_badge_deleted()
{
$badge = new badge($this->badgeid);
$sink = $this->redirectEvents();
// Trigger and capture the event.
$badge->delete(false);
$events = $sink->get_events();
$event = reset($events);
$this->assertCount(1, $events);
// Check that the event data is valid.
$this->assertInstanceOf('\\core\\event\\badge_deleted', $event);
$this->assertEquals($badge->id, $event->objectid);
$this->assertDebuggingNotCalled();
$sink->close();
}
示例4: array
// Archive this badge?
echo $output->heading(get_string('archivebadge', 'badges', $badge->name));
$archivebutton = $output->single_button(new moodle_url($PAGE->url, array('archive' => $badge->id, 'confirm' => 1)), get_string('archiveconfirm', 'badges'));
echo $output->box(get_string('archivehelp', 'badges') . $archivebutton, 'generalbox');
// Delete this badge?
echo $output->heading(get_string('delbadge', 'badges', $badge->name));
$deletebutton = $output->single_button(new moodle_url($PAGE->url, array('delete' => $badge->id, 'confirm' => 1)), get_string('delconfirm', 'badges'));
echo $output->box(get_string('deletehelp', 'badges') . $deletebutton, 'generalbox');
// Go back.
echo $output->action_link($returnurl, get_string('cancel'));
echo $output->footer();
die;
} else {
require_sesskey();
$archiveonly = $archive != 0 ? true : false;
$badge->delete($archiveonly);
redirect($returnurl);
}
}
if ($deactivate && has_capability('moodle/badges:configuredetails', $PAGE->context)) {
require_sesskey();
$badge = new badge($deactivate);
if ($badge->is_locked()) {
$badge->set_status(BADGE_STATUS_INACTIVE_LOCKED);
} else {
$badge->set_status(BADGE_STATUS_INACTIVE);
}
$msg = 'deactivatesuccess';
$returnurl->param('msg', $msg);
redirect($returnurl);
}