Beispiel #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)) {
                 $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;
 }
Beispiel #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)) {
                 // 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;
 }
Beispiel #3
0
 /**
  * Get next WikiDB_Page in sequence.
  *
  * @access public
  *
  * @return WikiDB_Page The next WikiDB_Page in the sequence.
  */
 function next()
 {
     if (!($next = $this->_iter->next())) {
         return false;
     }
     $pagename =& $next['pagename'];
     if (!is_string($pagename)) {
         // Bug #1327912 fixed by Joachim Lous
         /*if (is_array($pagename) && isset($pagename['linkto'])) {
         		$pagename = $pagename['linkto'];
         	    }
                     $pagename = strval($pagename);*/
         trigger_error("WikiDB_PageIterator->next pagename", E_USER_WARNING);
     }
     if (!$pagename) {
         if (isset($next['linkrelation']) or isset($next['pagedata']['linkrelation'])) {
             return false;
         }
         trigger_error('empty pagename in WikiDB_PageIterator::next()', E_USER_WARNING);
         var_dump($next);
         return false;
     }
     // There's always hits, but we cache only if more
     // (well not with file, cvs and dba)
     if (isset($next['pagedata']) and count($next['pagedata']) > 1) {
         $this->_wikidb->_cache->cache_data($next);
         // cache existing page id's since we iterate over all links in GleanDescription
         // and need them later for LinkExistingWord
     } elseif ($this->_options and array_key_exists('include_empty', $this->_options) and !$this->_options['include_empty'] and isset($next['id'])) {
         $this->_wikidb->_cache->_id_cache[$next['pagename']] = $next['id'];
     }
     $page = new WikiDB_Page($this->_wikidb, $pagename);
     if (isset($next['linkrelation'])) {
         $page->set('linkrelation', $next['linkrelation']);
     }
     if (isset($next['score'])) {
         $page->score = $next['score'];
     }
     return $page;
 }