コード例 #1
0
ファイル: delete.php プロジェクト: rair/yacs
$context['page_title'] = i18n::s('Delete a date');
// not found
if (!isset($item['id'])) {
    include '../error.php';
    // permission denied
} elseif (!$permitted) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // deletion is confirmed
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') {
    // touch the related anchor before actual deletion, since the date has to be accessible at that time
    if (is_object($anchor)) {
        $anchor->touch('date:delete', $item['id']);
    }
    // if no error, back to the anchor or to the index page
    if (Dates::delete($item['id'])) {
        Dates::clear($item);
        if (is_object($anchor)) {
            Safe::redirect($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url());
        } else {
            Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'dates/');
        }
    }
    // deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    Logger::error(i18n::s('The action has not been confirmed.'));
} else {
    // commands
    $menu = array();
    $menu[] = Skin::build_submit_button(i18n::s('Yes, I want to delete this date'), NULL, NULL, 'confirmed');
    if (is_object($anchor)) {