Menu

RemovePage doesn't work (phpwiki1.3.3)

Help
2002-07-11
2012-10-11
  • Jean-Francois Declercq

    When I try to remove a page, the following message appears:

    Remove page
    Someone has edited the page!

    (I'm the only user...)
    and I can't remove the page.

    ???

    JF

     
    • Wade Johnson

      Wade Johnson - 2002-07-20

      Hello all,

      the problem with the removepage is again that the action url of the target page has the pagename arg being overwritten.  I have resolved this by changing the removepage.php source to add a hidden pagename argument to the deletion confirmation page.  This allows the page to be deleted.  Please see the code below.  My hacks are designated as follows:

      //wtj beg of hack....

      //wtj end of hack...

      Note:  there are a couple of places in the code.

      Regards,

      Wade Johnson
      wade@wadejohnson.de

      <?php
      rcs_id('$Id: removepage.php,v 1.12 2002/02/14 03:40:00 carstenklapp Exp $');
      require_once('lib/Template.php');

      function RemovePage (&$request) {
          global $Theme;

          $page = $request->getPage();
          $pagelink = WikiLink($page);

          if ($request->getArg('cancel')) {
              $request->redirect(WikiURL($page));
              // The user probably doesn't see the rest of this.
              $html = HTML(HTML::h2(_("Request Cancelled!")),
                           HTML::p(fmt("Return to %s.", $pagelink)));
          }

          $current = $page->getCurrentRevision();
          $version = $current->getVersion();

          if (!$request->isPost() || !$request->getArg('verify')) {

              // FIXME: button should be class wikiadmin
              $removeB = Button('submit:verify', _("Remove the page now"), 'wikiadmin');
              $cancelB = Button('submit:cancel', _("Cancel"), 'button'); // use generic wiki button look

      //wtj beg hack for delete fix
              $lar_url = parse_url(WikiURL($page));
              list ($ls_pagename, $ls_value) = split ('[=]', $lar_url['query']);
      //wtj end hack for delete fix

              $html = HTML(HTML::h2(fmt("You are about to remove '%s' permanently!", $pagelink)),
                           HTML::form(array('method' => 'post',
                                            'action' => WikiURL($page)),
      //wtj beg hack for delete fix                                     
                                      HTML::input(array('type' => 'hidden',
                                                        'name' => 'pagename',
                                                        'value' => $ls_value)),
      //wtj end hack for delete fix                               
                                      HTML::input(array('type' => 'hidden',
                                                        'name' => 'currentversion',
                                                        'value' => $version)),
                                      HTML::input(array('type' => 'hidden',
                                                        'name' => 'action',
                                                        'value' => 'remove')),
                                      HTML::div(array('class' => 'toolbar'),
                                                $removeB,
                                                $Theme->getButtonSeparator(),
                                                $cancelB)));
          }
          elseif ($request->getArg('currentversion') != $version) {
              $html = HTML(HTML::h2(_("Someone has edited the page!")),
                           HTML::p(fmt("Since you started the deletion process, someone has saved a new version of %s.  Please check to make sure you still want to permanently remove the page from the database.", $pagelink)));
          }
          else {
              // Real delete.
              $pagename = $page->getName();
              $dbi = $request->getDbh();
              $dbi->deletePage($pagename);
              $html = HTML(HTML::h2(fmt("Removed page '%s' succesfully.", $pagename)));
          }

          GeneratePage($html, _("Remove page"));
      }

      // For emacs users
      // Local Variables:
      // mode: php
      // tab-width: 8
      // c-basic-offset: 4
      // c-hanging-comment-ender-p: nil
      // indent-tabs-mode: nil
      // End:
      ?>

       
    • Jean-Francois Declercq

      It worked !

      Thanks a lot

      JF

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.