コード例 #1
0
ファイル: delete.php プロジェクト: rair/yacs
}
// not found
if (!isset($item['id'])) {
    include '../error.php';
    // access 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 image has to be accessible at that time
    if (is_object($anchor)) {
        $anchor->touch('section:delete', $item['id']);
    }
    // attempt to delete
    if (Sections::delete($item['id'])) {
        // log item deletion
        $label = sprintf(i18n::c('Deletion: %s'), strip_tags($item['title']));
        $description = Sections::get_permalink($item);
        Logger::remember('sections/delete.php: ' . $label, $description);
        // this can appear anywhere
        Cache::clear();
        // back to the anchor page or to the index page
        if (is_object($overlay) && ($back_url = $overlay->get_url_after_deleting())) {
            Safe::redirect($back_url);
        } elseif (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'] . 'sections/');
        }
    }
コード例 #2
0
ファイル: sections.php プロジェクト: rair/yacs
 /**
  * delete all sections for a given anchor
  *
  * @param string the anchor to check (e.g., 'section:123')
  * @return void
  *
  * @see shared/anchors.php
  */
 public static function delete_for_anchor($anchor)
 {
     global $context;
     // seek all records attached to this anchor
     $query = "SELECT id FROM " . SQL::table_name('sections') . " AS sections " . " WHERE sections.anchor LIKE '" . SQL::escape($anchor) . "'";
     if (!($result = SQL::query($query))) {
         return;
     }
     // empty list
     if (!SQL::count($result)) {
         return;
     }
     // delete silently all matching items
     while ($row = SQL::fetch($result)) {
         Sections::delete($row['id']);
     }
 }
コード例 #3
0
ファイル: manage.php プロジェクト: rair/yacs
     // clear the cache for this section
     Sections::clear($item);
     // report on results
     $context['text'] .= '<p>' . sprintf(i18n::ns('%d page has been deleted.', '%d pages have been deleted.', $count), $count) . '</p>';
     // follow-up commands
     $follow_up = i18n::s('What do you want to do now?');
     $menu = array();
     $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the section'), 'span');
     $menu[] = Skin::build_link(Sections::get_url($item['id'], 'manage'), i18n::s('Manage it'), 'span');
     $follow_up .= Skin::finalize_list($menu, 'menu_bar');
     $context['text'] .= Skin::build_block($follow_up, 'bottom');
     // sections
 } elseif (isset($_REQUEST['selected_sections'])) {
     $count = 0;
     foreach ($_REQUEST['selected_sections'] as $dummy => $id) {
         if (Sections::delete($id)) {
             $count++;
         }
     }
     // clear the cache for this section
     Sections::clear($item);
     // report on results
     $context['text'] .= '<p>' . sprintf(i18n::ns('%d section has been deleted.', '%d sections have been deleted.', $count), $count) . '</p>';
     // follow-up commands
     $follow_up = i18n::s('What do you want to do now?');
     $menu = array();
     $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the section'), 'span');
     $menu[] = Skin::build_link(Sections::get_url($item['id'], 'manage'), i18n::s('Manage it'), 'span');
     $follow_up .= Skin::finalize_list($menu, 'menu_bar');
     $context['text'] .= Skin::build_block($follow_up, 'bottom');
     // nothing to do