Beispiel #1
0
 function cleanup_and_notify(&$request, $args, &$moderation)
 {
     $pagename = $moderation['args']['pagename'];
     $page = $request->_dbi->getPage($pagename);
     $pass = $args['pass'];
     // accept or reject
     $reason = $args['reason'];
     // summary why
     $user = $moderation['args']['user'];
     $action = $moderation['args']['action'];
     $id = $args['id'];
     unset($moderation['data'][$id]);
     unset($moderation['id']);
     $page->set('moderation', $moderation);
     // TODO: Notify the user, only if the user has an email:
     if ($email = $user->getPref('email')) {
         $action_page = $request->getPage(_("ModeratedPage"));
         $status = $this->getSiteStatus($request, $action_page);
         require_once "lib/MailNotify.php";
         $mailer = new MailNotify($pagename);
         $subject = "[" . WIKI_NAME . "] {$pass} {$action} " . _("ModeratedPage") . ': ' . $pagename;
         $mailer->from = $request->_user->UserFrom();
         $content = sprintf(_("%s approved your wiki action from %s"), $mailer->from, CTime($moderation['timestamp'])) . "\n\n" . "Decision: " . $pass . "Reason: " . $reason . "\n<" . WikiURL($pagename) . ">\n";
         $mailer->emails = $mailer->userids = $email;
         $mailer->sendMail($subject, $content, "Approval notice");
     }
 }
Beispiel #2
0
 /** A higher-level interface to createRevision.
  *
  * This takes care of computing the links, and storing
  * a cached version of the transformed wiki-text.
  *
  * @param string $wikitext  The page content.
  *
  * @param int $version Version number for new revision.  
  * To ensure proper serialization of edits, $version must be
  * exactly one higher than the current latest version.
  * (You can defeat this check by setting $version to
  * {@link WIKIDB_FORCE_CREATE} --- not usually recommended.)
  *
  * @param hash $meta  Meta-data for new revision.
  */
 function save($wikitext, $version, $meta, $formatted = null)
 {
     if ($this->_wikidb->readonly) {
         trigger_error("readonly database", E_USER_WARNING);
         return;
     }
     if (is_null($formatted)) {
         $formatted = new TransformedText($this, $wikitext, $meta);
     }
     $type = $formatted->getType();
     $meta['pagetype'] = $type->getName();
     $links = $formatted->getWikiPageLinks();
     // linkto => relation
     $attributes = array();
     foreach ($links as $link) {
         if ($link['linkto'] === "" and !empty($link['relation'])) {
             $attributes[$link['relation']] = $this->getAttribute($link['relation']);
         }
     }
     $meta['attribute'] = $attributes;
     $backend =& $this->_wikidb->_backend;
     $newrevision = $this->createRevision($version, $wikitext, $meta, $links);
     if ($newrevision and !WIKIDB_NOCACHE_MARKUP) {
         $this->set('_cached_html', $formatted->pack());
     }
     // FIXME: probably should have some global state information
     // in the backend to control when to optimize.
     //
     // We're doing this here rather than in createRevision because
     // postgresql can't optimize while locked.
     if ((int) DEBUG & _DEBUG_SQL or DATABASE_OPTIMISE_FREQUENCY > 0 and time() % DATABASE_OPTIMISE_FREQUENCY == 0) {
         if ($backend->optimize()) {
             if ((int) DEBUG) {
                 trigger_error(_("Optimizing database"), E_USER_NOTICE);
             }
         }
     }
     /* Generate notification emails? */
     if (ENABLE_MAILNOTIFY and isa($newrevision, 'WikiDB_PageRevision')) {
         // Save didn't fail because of concurrent updates.
         $notify = $this->_wikidb->get('notify');
         if (!empty($notify) and is_array($notify) and !isa($GLOBALS['request'], 'MockRequest')) {
             include_once "lib/MailNotify.php";
             $MailNotify = new MailNotify($newrevision->getName());
             $MailNotify->onChangePage($this->_wikidb, $wikitext, $version, $meta);
         }
         $newrevision->_transformedContent = $formatted;
     }
     // more pagechange callbacks: (in a hackish manner for now)
     if (ENABLE_RECENTCHANGESBOX and empty($meta['is_minor_edit']) and !in_array($GLOBALS['request']->getArg('action'), array('loadfile', 'upgrade'))) {
         require_once "lib/WikiPlugin.php";
         $w = new WikiPluginLoader();
         $p = $w->getPlugin("RecentChangesCached", false);
         $p->box_update(false, $GLOBALS['request'], $this->_pagename);
     }
     return $newrevision;
 }