Ejemplo n.º 1
0
 /**
  * Delete page from the WikiDB. 
  *
  * Deletes the page from the WikiDB with the possibility to revert and diff.
  * //Also resets all page meta-data to the default values.
  *
  * Note: purgePage() effectively destroys all revisions of the page from the WikiDB. 
  *
  * @access public
  *
  * @param string $pagename Name of page to delete.
  */
 function deletePage($pagename)
 {
     // don't create empty revisions of already purged pages.
     if ($this->_backend->get_latest_version($pagename)) {
         $result = $this->_cache->delete_page($pagename);
     } else {
         $result = -1;
     }
     /* Generate notification emails? */
     if (!$this->isWikiPage($pagename) and !isa($GLOBALS['request'], 'MockRequest')) {
         $notify = $this->get('notify');
         if (!empty($notify) and is_array($notify)) {
             global $request;
             //TODO: deferr it (quite a massive load if you remove some pages).
             //TODO: notification class which catches all changes,
             //  and decides at the end of the request what to mail.
             //  (type, page, who, what, users, emails)
             // could be used for PageModeration and RSS2 Cloud xml-rpc also.
             $page = new WikiDB_Page($this, $pagename);
             list($emails, $userids) = $page->getPageChangeEmails($notify);
             if (!empty($emails)) {
                 // Codendi specific
                 $subject = sprintf(_("Page removed %s"), $pagename);
                 $from = user_getemail(user_getid());
                 $body = $subject . "\n" . sprintf(_("Removed by: %s"), $from) . "\n\n";
                 $m = new Mail();
                 $m->setFrom($from);
                 $m->setSubject("[" . WIKI_NAME . "] " . $subject);
                 $m->setBcc(join(',', $emails));
                 $m->setBody($body);
                 if ($m->send()) {
                     trigger_error(sprintf(_("PageChange Notification of %s sent to %s"), $pagename, join(',', $userids)), E_USER_NOTICE);
                 } else {
                     trigger_error(sprintf(_("PageChange Notification Error: Couldn't send %s to %s"), $pagename, join(',', $userids)), E_USER_WARNING);
                 }
             }
         }
     }
     //How to create a RecentChanges entry with explaining summary? Dynamically
     /*
     $page = $this->getPage($pagename);
     $current = $page->getCurrentRevision();
     $meta = $current->_data;
     $version = $current->getVersion();
     $meta['summary'] = _("removed");
     $page->save($current->getPackedContent(), $version + 1, $meta);
     */
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Delete page from the WikiDB. 
  *
  * Deletes the page from the WikiDB with the possibility to revert and diff.
  * //Also resets all page meta-data to the default values.
  *
  * Note: purgePage() effectively destroys all revisions of the page from the WikiDB. 
  *
  * @access public
  *
  * @param string $pagename Name of page to delete.
  */
 function deletePage($pagename)
 {
     // don't create empty revisions of already purged pages.
     if ($this->_backend->get_latest_version($pagename)) {
         $result = $this->_cache->delete_page($pagename);
     } else {
         $result = -1;
     }
     /* Generate notification emails? */
     if (!$this->isWikiPage($pagename) and !isa($GLOBALS['request'], 'MockRequest')) {
         $notify = $this->get('notify');
         if (!empty($notify) and is_array($notify)) {
             global $request;
             //TODO: deferr it (quite a massive load if you remove some pages).
             //TODO: notification class which catches all changes,
             //  and decides at the end of the request what to mail.
             //  (type, page, who, what, users, emails)
             // could be used for PageModeration and RSS2 Cloud xml-rpc also.
             $page = new WikiDB_Page($this, $pagename);
             list($emails, $userids) = $page->getPageChangeEmails($notify);
             if (!empty($emails)) {
                 $from = $request->_user->getId();
                 $editedby = sprintf(_("Removed by: %s"), $from);
                 $emails = join(',', $emails);
                 $headers = "From: {$from} <nobody>\r\n" . "Bcc: {$emails}\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/plain; charset=" . CHARSET . "; format=flowed\r\n" . "Content-Transfer-Encoding: 8bit";
                 $subject = sprintf(_("Page removed %s"), urlencode($pagename));
                 if (mail("<undisclosed-recipients>", "[" . WIKI_NAME . "] " . $subject, $subject . "\n" . $editedby . "\n\n" . "Deleted {$pagename}", $headers)) {
                     trigger_error(sprintf(_("PageChange Notification of %s sent to %s"), $pagename, join(',', $userids)), E_USER_NOTICE);
                 } else {
                     trigger_error(sprintf(_("PageChange Notification Error: Couldn't send %s to %s"), $pagename, join(',', $userids)), E_USER_WARNING);
                 }
             }
         }
     }
     //How to create a RecentChanges entry with explaining summary? Dynamically
     /*
     $page = $this->getPage($pagename);
     $current = $page->getCurrentRevision();
     $meta = $current->_data;
     $version = $current->getVersion();
     $meta['summary'] = _("removed");
     $page->save($current->getPackedContent(), $version + 1, $meta);
     */
     return $result;
 }