Example #1
0
 /**
  * @static
  * @param string $action
  * @param Article $article
  * @return bool
  * @throws UserBlockedError
  * @throws PermissionsError
  */
 static function onPowerDelete($action, $article)
 {
     global $wgOut, $wgUser, $wgRequest;
     if ($action !== 'powerdelete') {
         return true;
     }
     if (!$wgUser->isAllowed('delete') || !$wgUser->isAllowed('powerdelete')) {
         throw new PermissionsError('powerdelete');
     }
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($wgUser->mBlock);
     }
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return false;
     }
     $reason = $wgRequest->getText('reason');
     $title = $article->getTitle();
     $file = $title->getNamespace() == NS_IMAGE ? wfLocalFile($title) : false;
     if ($file) {
         $oldimage = null;
         FileDeleteForm::doDelete($title, $file, $oldimage, $reason, false);
     } else {
         $article->doDelete($reason);
     }
     // this is stupid, but otherwise, WikiPage::doUpdateRestrictions complains about passing by reference
     $false = false;
     $article->doUpdateRestrictions(array('create' => 'sysop'), array('create' => 'infinity'), $false, $reason, $wgUser);
     return false;
 }
/**
 *
 * @param $article - object with the following fields (page_id and page_title)
 * @param $reason - reason for the deletion 
 */
function deleteTalkPage($article, $reason)
{
    $title = Title::newFromID($article->page_id);
    if ($title) {
        $article = new Article($title);
        if ($article) {
            echo $title->getFullURL() . "\n";
            $article->doDelete($reason);
        }
    }
}
 function doDelete($pages, $reason)
 {
     foreach ($pages as $page) {
         if ($title = Title::newFromText($page)) {
             $article = new Article($title);
             $article->doDelete($reason);
         } else {
             die("Bad title: \"{$page}\"");
         }
     }
 }
 /**
  * Have an existing Topic "inherit" a new version by applying a category 
  * version tag to it.
  *
  * @param $topicTitle string The internal mediawiki title of the article.
  * @param $version PonyDocsVersion The target Version
  * @param $tocSection The TOC section this title resides in.
  * @param $tocTitle The toc title that references this topic.
  * @param $deleteExisting boolean Should we purge any existing conflicts?
  * @returns boolean
  */
 static function inheritTopic($topicTitle, $version, $tocSection, $tocTitle, $deleteExisting)
 {
     global $wgTitle;
     // Clear any hooks so no weirdness gets called after we save the inherit
     $wgHooks['ArticleSave'] = array();
     if (!preg_match('/^' . PONYDOCS_DOCUMENTATION_NAMESPACE_NAME . ':([^:]*):([^:]*):(.*):([^:]*)$/', $topicTitle, $match)) {
         throw new Exception("Invalid Title to Inherit From: " . $topicTitle);
     }
     $productName = $match[1];
     $manual = $match[2];
     $title = $match[3];
     // Get PonyDocsProduct
     $product = PonyDocsProduct::GetProductByShortName($productName);
     // Get conflicts.
     $conflicts = self::getConflicts($product, $topicTitle, $version);
     if (!empty($conflicts)) {
         if (!$deleteExisting) {
             throw new Exception("When calling inheritTitle, there were conflicts and deleteExisting was false.");
         }
         // We want to purge each conflicting title completely.
         foreach ($conflicts as $conflict) {
             $article = new Article(Title::newFromText($conflict));
             if (!$article->exists()) {
                 // No big deal. A conflict no longer exists? Continue.
                 continue;
             }
             if ($conflict == $topicTitle) {
                 // Conflict was same as source material. Do nothing with it.
                 continue;
             } else {
                 $article->doDelete("Requested purge of conficting article when inheriting topic " . $topicTitle . " with version: " . $version->getVersionName(), false);
             }
         }
     }
     $title = Title::newFromText($topicTitle);
     $wgTitle = $title;
     $existingArticle = new Article($title);
     if (!$existingArticle->exists()) {
         // No such title exists in the system
         throw new Exception("Invalid Title to Inherit From: " . $topicTitle);
     }
     // Okay, source article exists.
     // Add the appropriate version cateogry.
     // Check for existing category.
     $content = $existingArticle->getContent();
     if (!preg_match("/\\[\\[Category:V:" . preg_quote($productName . ":" . $version->getVersionName()) . "\\]\\]/", $content)) {
         $content .= "[[Category:V:" . $productName . ":" . $version->getVersionName() . "]]";
         // Save the article as an edit
         $existingArticle->doEdit($content, "Inherited topic " . $topicTitle . " with version: " . $productName . ":" . $version->getVersionName(), EDIT_UPDATE);
     }
     return $title;
 }
Example #5
0
}
$dbw =& wfGetDB(DB_MASTER);
for ($linenum = 1; !feof($file); $linenum++) {
    $line = trim(fgets($file));
    if ($line === false) {
        break;
    }
    $page = Title::newFromText($line);
    if (is_null($page)) {
        print "Invalid title '{$line}' on line {$linenum}\n";
        continue;
    }
    if (!$page->exists()) {
        print "Skipping nonexistent page '{$line}'\n";
        continue;
    }
    print $page->getPrefixedText();
    $dbw->begin();
    if ($page->getNamespace() == NS_IMAGE) {
        $art = new ImagePage($page);
    } else {
        $art = new Article($page);
    }
    $art->doDelete($reason);
    $dbw->immediateCommit();
    print "\n";
    if ($interval) {
        sleep($interval);
    }
    wfWaitForSlaves(5);
}
Example #6
0
 function doSubmit()
 {
     global $wgOut, $wgUser, $wgMaximumMovedPages, $wgLang;
     global $wgFixDoubleRedirects;
     if ($wgUser->pingLimiter('move')) {
         $wgOut->rateLimited();
         return;
     }
     $ot = $this->oldTitle;
     $nt = $this->newTitle;
     # Delete to make way if requested
     if ($wgUser->isAllowed('delete') && $this->deleteAndMove) {
         $article = new Article($nt);
         # Disallow deletions of big articles
         $bigHistory = $article->isBigDeletion();
         if ($bigHistory && !$nt->userCan('bigdelete')) {
             global $wgDeleteRevisionsLimit;
             $this->showForm(array('delete-toobig', $wgLang->formatNum($wgDeleteRevisionsLimit)));
             return;
         }
         // Delete an associated image if there is
         $file = wfLocalFile($nt);
         if ($file->exists()) {
             $file->delete(wfMsgForContent('delete_and_move_reason'), false);
         }
         // This may output an error message and exit
         $article->doDelete(wfMsgForContent('delete_and_move_reason'));
     }
     # don't allow moving to pages with # in
     if (!$nt || $nt->getFragment() != '') {
         $this->showForm('badtitletext');
         return;
     }
     # Show a warning if the target file exists on a shared repo
     if ($nt->getNamespace() == NS_FILE && !($this->moveOverShared && $wgUser->isAllowed('reupload-shared')) && !RepoGroup::singleton()->getLocalRepo()->findFile($nt) && wfFindFile($nt)) {
         $this->showForm(array('file-exists-sharedrepo'));
         return;
     }
     if ($wgUser->isAllowed('suppressredirect')) {
         $createRedirect = $this->leaveRedirect;
     } else {
         $createRedirect = true;
     }
     # Do the actual move.
     $error = $ot->moveTo($nt, true, $this->reason, $createRedirect);
     if ($error !== true) {
         # @todo FIXME: Show all the errors in a list, not just the first one
         $this->showForm(reset($error));
         return;
     }
     if ($wgFixDoubleRedirects && $this->fixRedirects) {
         DoubleRedirectJob::fixRedirects('move', $ot, $nt);
     }
     wfRunHooks('SpecialMovepageAfterMove', array(&$this, &$ot, &$nt));
     $wgOut->setPagetitle(wfMsg('pagemovedsub'));
     $oldUrl = $ot->getFullUrl('redirect=no');
     $newUrl = $nt->getFullUrl();
     $oldText = $ot->getPrefixedText();
     $newText = $nt->getPrefixedText();
     $oldLink = "<span class='plainlinks'>[{$oldUrl} {$oldText}]</span>";
     $newLink = "<span class='plainlinks'>[{$newUrl} {$newText}]</span>";
     $msgName = $createRedirect ? 'movepage-moved-redirect' : 'movepage-moved-noredirect';
     $wgOut->addWikiMsg('movepage-moved', $oldLink, $newLink, $oldText, $newText);
     $wgOut->addWikiMsg($msgName);
     # Now we move extra pages we've been asked to move: subpages and talk
     # pages.  First, if the old page or the new page is a talk page, we
     # can't move any talk pages: cancel that.
     if ($ot->isTalkPage() || $nt->isTalkPage()) {
         $this->moveTalk = false;
     }
     if (!$ot->userCan('move-subpages')) {
         $this->moveSubpages = false;
     }
     # Next make a list of id's.  This might be marginally less efficient
     # than a more direct method, but this is not a highly performance-cri-
     # tical code path and readable code is more important here.
     #
     # Note: this query works nicely on MySQL 5, but the optimizer in MySQL
     # 4 might get confused.  If so, consider rewriting as a UNION.
     #
     # If the target namespace doesn't allow subpages, moving with subpages
     # would mean that you couldn't move them back in one operation, which
     # is bad.
     # @todo FIXME: A specific error message should be given in this case.
     // @todo FIXME: Use Title::moveSubpages() here
     $dbr = wfGetDB(DB_MASTER);
     if ($this->moveSubpages && (MWNamespace::hasSubpages($nt->getNamespace()) || $this->moveTalk && MWNamespace::hasSubpages($nt->getTalkPage()->getNamespace()))) {
         $conds = array('page_title' . $dbr->buildLike($ot->getDBkey() . '/', $dbr->anyString()) . ' OR page_title = ' . $dbr->addQuotes($ot->getDBkey()));
         $conds['page_namespace'] = array();
         if (MWNamespace::hasSubpages($nt->getNamespace())) {
             $conds['page_namespace'][] = $ot->getNamespace();
         }
         if ($this->moveTalk && MWNamespace::hasSubpages($nt->getTalkPage()->getNamespace())) {
             $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
         }
     } elseif ($this->moveTalk) {
         $conds = array('page_namespace' => $ot->getTalkPage()->getNamespace(), 'page_title' => $ot->getDBkey());
     } else {
         # Skip the query
         $conds = null;
     }
     $extraPages = array();
     if (!is_null($conds)) {
         $extraPages = TitleArray::newFromResult($dbr->select('page', array('page_id', 'page_namespace', 'page_title'), $conds, __METHOD__));
     }
     $extraOutput = array();
     $skin = $this->getSkin();
     $count = 1;
     foreach ($extraPages as $oldSubpage) {
         if ($ot->equals($oldSubpage)) {
             # Already did this one.
             continue;
         }
         $newPageName = preg_replace('#^' . preg_quote($ot->getDBkey(), '#') . '#', StringUtils::escapeRegexReplacement($nt->getDBkey()), $oldSubpage->getDBkey());
         if ($oldSubpage->isTalkPage()) {
             $newNs = $nt->getTalkPage()->getNamespace();
         } else {
             $newNs = $nt->getSubjectPage()->getNamespace();
         }
         # Bug 14385: we need makeTitleSafe because the new page names may
         # be longer than 255 characters.
         $newSubpage = Title::makeTitleSafe($newNs, $newPageName);
         if (!$newSubpage) {
             $oldLink = $skin->linkKnown($oldSubpage);
             $extraOutput[] = wfMsgHtml('movepage-page-unmoved', $oldLink, htmlspecialchars(Title::makeName($newNs, $newPageName)));
             continue;
         }
         # This was copy-pasted from Renameuser, bleh.
         if ($newSubpage->exists() && !$oldSubpage->isValidMoveTarget($newSubpage)) {
             $link = $skin->linkKnown($newSubpage);
             $extraOutput[] = wfMsgHtml('movepage-page-exists', $link);
         } else {
             $success = $oldSubpage->moveTo($newSubpage, true, $this->reason, $createRedirect);
             if ($success === true) {
                 if ($this->fixRedirects) {
                     DoubleRedirectJob::fixRedirects('move', $oldSubpage, $newSubpage);
                 }
                 $oldLink = $skin->linkKnown($oldSubpage, null, array(), array('redirect' => 'no'));
                 $newLink = $skin->linkKnown($newSubpage);
                 $extraOutput[] = wfMsgHtml('movepage-page-moved', $oldLink, $newLink);
                 ++$count;
                 if ($count >= $wgMaximumMovedPages) {
                     $extraOutput[] = wfMsgExt('movepage-max-pages', array('parsemag', 'escape'), $wgLang->formatNum($wgMaximumMovedPages));
                     break;
                 }
             } else {
                 $oldLink = $skin->linkKnown($oldSubpage);
                 $newLink = $skin->link($newSubpage);
                 $extraOutput[] = wfMsgHtml('movepage-page-unmoved', $oldLink, $newLink);
             }
         }
     }
     if ($extraOutput !== array()) {
         $wgOut->addHTML("<ul>\n<li>" . implode("</li>\n<li>", $extraOutput) . "</li>\n</ul>");
     }
     # Deal with watches (we don't watch subpages)
     if ($this->watch && $wgUser->isLoggedIn()) {
         $wgUser->addWatch($ot);
         $wgUser->addWatch($nt);
     } else {
         $wgUser->removeWatch($ot);
         $wgUser->removeWatch($nt);
     }
     # Re-clear the file redirect cache, which may have been polluted by
     # parsing in messages above. See CR r56745.
     # @todo FIXME: Needs a more robust solution inside FileRepo.
     if ($ot->getNamespace() == NS_FILE) {
         RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect($ot);
     }
 }
Example #7
0
 function deleteArticleByRule($title, $text, $rulesText)
 {
     global $wgUser, $wgOut;
     // return "deletion of articles by DPL is disabled.";
     // we use ; as command delimiter; \; stands for a semicolon
     // \n is translated to a real linefeed
     $rulesText = str_replace(";", '°', $rulesText);
     $rulesText = str_replace('\\°', ';', $rulesText);
     $rulesText = str_replace("\\n", "\n", $rulesText);
     $rules = split('°', $rulesText);
     $exec = false;
     $message = '';
     $reason = '';
     foreach ($rules as $rule) {
         if (preg_match('/^\\s*#/', $rule) > 0) {
             continue;
             // # is comment symbol
         }
         $rule = preg_replace('/^[\\s]*/', '', $rule);
         // strip leading white space
         $cmd = preg_split("/ +/", $rule, 2);
         if (count($cmd) > 1) {
             $arg = $cmd[1];
         } else {
             $arg = '';
         }
         $cmd[0] = trim($cmd[0]);
         if ($cmd[0] == 'reason') {
             $reason = $arg;
         }
         // we execute only if "exec" is given, otherwise we merely show what would be done
         if ($cmd[0] == 'exec') {
             $exec = true;
         }
     }
     $reason .= "\nbulk delete by DPL query";
     $titleX = Title::newFromText($title);
     if ($exec) {
         # Check permissions
         $permission_errors = $titleX->getUserPermissionsErrors('delete', $wgUser);
         if (count($permission_errors) > 0) {
             $wgOut->showPermissionsErrorPage($permission_errors);
             return 'permission error';
         } elseif (wfReadOnly()) {
             $wgOut->readOnlyPage();
             return 'DPL: read only mode';
         } else {
             $articleX = new Article($titleX);
             $articleX->doDelete($reason);
         }
     } else {
         $message .= "set 'exec yes' to delete &#160; &#160; <big>'''{$title}'''</big>\n";
     }
     $message .= '<pre><nowiki>' . "\n" . $text . '</nowiki></pre>';
     // <pre><nowiki>\n"; // .$text."\n</nowiki></pre>\n";
     return $message;
 }
Example #8
0
 function generate($take_duration)
 {
     global $mvgIP;
     require_once $mvgIP . '/includes/MV_Index.php';
     $s = MV_Stream::newStreamByName($this->name);
     if (!$s->db_load_stream()) {
         return "An error occured while loading stream info please notify Administrator";
     }
     $stream_duration = $s->getDuration();
     if ($stream_duration === NULL) {
         return "Error: Stream Duration not set";
     }
     $sitting_id = $s->getSittingId();
     $editors = $this->getAssignedEditors($sitting_id);
     $readers = $this->getAssignedReaders($sitting_id);
     $reporters = $this->getAssignedReporters($sitting_id);
     $editors_count = count($editors);
     $readers_count = count($readers);
     $reporters_count = count($reporters);
     $html = '';
     if ($editors_count == 0) {
         $html .= "No Editors Assigned";
         return $html;
     }
     if ($readers_count == 0) {
         $html .= "No Readers Assigned";
         return $html;
     }
     if ($reporters_count == 0) {
         $html .= "No Reporters Assigned";
         return $html;
     }
     //delete all existing take transcripts
     $dbr =& wfGetDB(DB_SLAVE);
     $result =& MV_Index::getMVDInRange($s->getStreamId(), 0, $s->getDuration(), $this->mvd_tracks);
     while ($row = $dbr->fetchObject($result)) {
         $title = Title::newFromText($row->wiki_title, MV_NS_MVD);
         $art = new Article($title);
         if ($art->exists()) {
             $art->doDelete("new takes generated", true);
         }
     }
     $num_editor = 0;
     $num_reader = 0;
     $num_reporter = 0;
     for ($i = 0; $i < $stream_duration; $i = $i + $take_duration) {
         $start_time = $i;
         $end_time = $i + $take_duration;
         $title_text = 'Take_en:' . $this->name . '/' . seconds2ntp($start_time) . '/' . seconds2ntp($end_time);
         $title = Title::newFromText($title_text, MV_NS_MVD);
         $editor = User::newFromId($editors[$num_editor]);
         $editor_name = $editor->getRealName();
         $reader = User::newFromId($readers[$num_editor]);
         $reader_name = $reader->getRealName();
         $reporter = User::newFromId($reporters[$num_editor]);
         $reporter_name = $reporter->getRealName();
         $article = new Article($title);
         $text = '[[Edited By::' . $editor_name . ']], ' . '[[Read By::' . $reader_name . ']], ' . '[[Reported By::' . $reporter_name . ']], ' . '[[Status::Incomplete]]';
         $article->doEdit($text, 'Automatically Generated', EDIT_NEW);
         if ($num_editor < $editors_count - 1) {
             $num_editor++;
         } else {
             $num_editor = 0;
         }
         if ($num_reader < $readers_count - 1) {
             $num_reader++;
         } else {
             $num_reader = 0;
         }
         if ($num_reporter < $reporters_count - 1) {
             $num_reporter++;
         } else {
             $num_reporter = 0;
         }
     }
     $html .= 'Takes Successfully Generated';
     return $html;
 }
 function deletePage($line, $reason, &$db, $multi = false, $linenum = 0, $user = null)
 {
     global $wgOut, $wgUser;
     $page = Title::newFromText($line);
     if (is_null($page)) {
         /* invalid title? */
         $wgOut->addWikiMsg('deletebatch_omitting_invalid', $line);
         if (!$multi) {
             if (!is_null($user)) {
                 $wgUser = $user;
             }
         }
         return false;
     }
     if (!$page->exists()) {
         /* no such page? */
         $wgOut->addWikiMsg('deletebatch_omitting_nonexistant', $line);
         if (!$multi) {
             if (!is_null($user)) {
                 $wgUser = $user;
             }
         }
         return false;
     }
     $db->begin();
     if (NS_MEDIA == $page->getNamespace()) {
         $page = Title::makeTitle(NS_IMAGE, $page->getDBkey());
     }
     /* this stuff goes like Article::newFromTitle() */
     if ($page->getNamespace() == NS_IMAGE) {
         $art = new ImagePage($page);
     } else {
         $art = new Article($page);
     }
     /* 	what is the generic reason for page deletion?
     			something about the content, I guess...
     		*/
     $art->doDelete($reason);
     $db->immediateCommit();
     return true;
 }
 function do_remove_mvd($titleKey, $mvd_id)
 {
     global $wgOut;
     $title = Title::newFromText($titleKey, MV_NS_MVD);
     $article = new Article($title);
     // purge parent article:
     MV_MVD::onEdit($this->mvd_pages, $mvd_id);
     // run the delete function:
     $article->doDelete($_REQUEST['wpReason']);
     // check if delete
     if ($article->exists()) {
         return php2jsObj(array('status' => 'error', 'error_txt' => $wgOut->getHTML()));
     } else {
         return php2jsObj(array('status' => 'ok'));
     }
 }
Example #11
0
 function testDuplicateCreate()
 {
     $this->markTestSkipped('Randomly failing due to master/slave lag');
     // FIXME
     /**  @var $poll WikiaPollAjax */
     $poll = WF::build('WikiaPollAjax');
     $wgRequest = $this->getMock('WebRequest', array('getVal', 'getArray'));
     $wgRequest->expects($this->at(0))->method('getVal')->with($this->equalTo('question'))->will($this->returnValue("Unit Testing"));
     $wgRequest->expects($this->any())->method('getArray')->with($this->equalTo('answer'))->will($this->returnValue(array("One", "Two", "Three")));
     $wgRequest->expects($this->any())->method('getIP')->will($this->returnValue('127.0.0.1'));
     $this->mockGlobalVariable('wgRequest', $wgRequest);
     $this->mockApp();
     // Create the same poll twice
     $result = $poll->create();
     $this->assertType("array", $result, "Create duplicate result is array");
     $this->assertEquals(false, $result["success"], "Create duplicate Poll success flag is false");
     $this->assertType("string", $result["error"], "Create duplicate Poll results in an error");
     // clean up
     $title = Title::newFromText("Unit Testing", NS_WIKIA_POLL);
     $article = new Article($title, NS_WIKIA_POLL);
     /* @var $article WikiPage */
     if ($article->exists()) {
         $article->doDelete("Unit Testing", true);
     }
 }
Example #12
0
 static function deletePage($title, $sp = null)
 {
     $ret = null;
     $file = $title->getNamespace() == NS_IMAGE ? wfLocalFile($title) : false;
     if ($file) {
         $reason = wfMsg("blockandnuke-delete-file");
         $oldimage = null;
         // Must be passed by reference
         $ret = FileDeleteForm::doDelete($title, $file, $oldimage, $reason, false);
     } else {
         $reason = wfMsg("blockandnuke-delete-article");
         if ($title->isKnown()) {
             $article = new Article($title);
             $ret = $article->doDelete($reason);
             if ($ret && $sp) {
                 $sp->getOutput()->addHTML(wfMessage("blockandnuke-deleted-page", $title));
             }
         }
     }
     return $ret;
 }
$res = $dbr->select("page_ban", array("pb_namespace", "pb_page"));
$deleted = array();
$wgUser = User::newFromName("EmilyPostBot");
$n = 0;
print "Start :" . wfTimestampNow(TS_MW) . "\n";
$pages = array();
foreach ($res as $row) {
    $pages[] = array('name' => $row->pb_page, 'ns' => $row->pb_namespace);
}
foreach ($pages as $page) {
    $title = Title::newFromText($page['name'], $page['ns']);
    $deletion = false;
    if ($title && $title->exists() && $title->getNamespace() != NS_MAIN) {
        print 'Deleting article ' . $wgContLang->getNSText($row->pb_namespace) . ':' . $title->getText() . "\n";
        $article = new Article($title);
        $article->doDelete('Bad page');
        $deletion = true;
    }
    if ($page['ns'] == NS_USER) {
        $user = User::newFromName($page['name']);
        if ($user && $user->getID() > 0) {
            if (ProfileBox::removeUserData($user)) {
                print "Removed profilebox for " . $user->getName() . "\n";
                $deletion = true;
            }
            $ra = Avatar::getAvatarRaw($user->getName());
            if ($ra['url'] != '') {
                if (preg_match("@SUCCESS@", Avatar::removePicture($user->getID()))) {
                    print "Remove avatar picture for " . $user->getName() . "\n";
                    $deletion = true;
                }
Example #14
0
 function removeStream($removeMVDs = true)
 {
     global $mvIndexTableName;
     $dbw =& wfGetDB(DB_WRITE);
     $dbr =& wfGetDB(DB_SLAVE);
     if ($removeMVDs) {
         //delete metadata pages:
         //@@todo figure out a way to do this quickly/group sql queries.
         $res = MV_Index::getMVDInRange($this->getStreamId());
         if ($dbr->numRows($res) != 0) {
             while ($row = $dbr->fetchObject($res)) {
                 $title = Title::newFromText($row->wiki_title, MV_NS_MVD);
                 $article = new Article($title);
                 $article->doDelete('parent stream removed');
             }
         }
     }
     return true;
 }
<?php

require_once 'commandLine.inc';
$dbr = wfGetDB(DB_SLAVE);
$bad = array();
$wgUser = User::newFromName('Tderouin');
$res = $dbr->select('page', array('page_title', 'page_namespace'), array('page_namespace' => NS_IMAGE));
$count = 0;
while ($row = $dbr->fetchObject($res)) {
    $t = Title::makeTitle($row->page_namespace, $row->page_title);
    if (preg_match("/[^" . Title::legalChars() . "]|\\?/", $t->getText())) {
        #echo "find /var/www/images_en -name '{$t->getText()}' \n";
        $img = wfFindFile($t, false);
        $oldpath = $img->getPath();
        $newtitle = Title::makeTitle(NS_IMAGE, trim(preg_replace("@\\?@", "", $t->getText())));
        if (!$newtitle) {
            echo "oops! {$row->page_title}\n";
            exit;
        }
        $a = new Article($t);
        $a->doDelete("Bad image name");
        #echo "{$oldpath}\t{$newpath}\n";
        echo "{$t->getText()}\n";
        #echo "cp " . wfEscapeShellArg($img->getPath()) . " /tmp/bad \n";
    }
    $count++;
}
 /**
  * Deletes an user form the database
  * @global User $wgUser
  * @param Integer $iUserId user id
  * @return string json encoded response
  */
 public static function deleteUser($iUserId)
 {
     $aAnswer = array('success' => true, 'errors' => array(), 'message' => array());
     if (wfReadOnly()) {
         global $wgReadOnly;
         $aAnswer['success'] = false;
         $aAnswer['message'][] = wfMessage('bs-readonly', $wgReadOnly)->plain();
     }
     if (BsCore::checkAccessAdmission('wikiadmin') === false) {
         $aAnswer['success'] = false;
         $aAnswer['message'][] = wfMessage('bs-wikiadmin-notallowed')->plain();
     }
     $oUser = User::newFromId($iUserId);
     if ($oUser->getId() == 0) {
         $aAnswer['success'] = false;
         $aAnswer['message'][] = wfMessage('bs-usermanager-idnotexist')->plain();
     }
     if ($oUser->getId() == 1) {
         $aAnswer['success'] = false;
         $aAnswer['message'][] = wfMessage('bs-usermanager-admin-nodelete')->plain();
     }
     global $wgUser;
     if ($oUser->getId() == $wgUser->getId()) {
         $aAnswer['success'] = false;
         $aAnswer['message'][] = wfMessage('bs-usermanager-self-nodelete')->plain();
     }
     if (!$aAnswer['success']) {
         return FormatJson::encode($aAnswer);
     }
     $dbw = wfGetDB(DB_MASTER);
     $res = $dbw->delete('user', array('user_id' => $oUser->getId()));
     $res1 = $dbw->delete('user_groups', array('ug_user' => $oUser->getId()));
     $res2 = $dbw->delete('user_newtalk', array('user_id' => $oUser->getId()));
     $iUsers = $dbw->selectField('user', 'COUNT(*)', array());
     $res3 = $dbw->update('site_stats', array('ss_users' => $iUsers), array('ss_row_id' => 1));
     if ($oUser->getUserPage()->exists()) {
         $oUserPageArticle = new Article($oUser->getUserPage());
         $oUserPageArticle->doDelete(wfMessage('bs-usermanager-db-error')->plain());
     }
     if ($res === false || $res1 === false || $res2 === false || $res3 === false) {
         $aAnswer['success'] = false;
         $aAnswer['message'][] = wfMessage('bs-usermanager-db-error')->plain();
         return FormatJson::encode($aAnswer);
     }
     $aAnswer['message'][] = wfMessage('bs-usermanager-user-deleted')->plain();
     return FormatJson::encode($aAnswer);
 }
function do_process_text($stream, $force)
{
    $dbr = wfGetDB(DB_SLAVE);
    if ($force) {
        global $botUserName;
        // get wiki stream id:
        $wikiStream = new MV_Stream(array('name' => $stream->name));
        // first remove all bot edited pages:
        $mvd_res = MV_Index::getMVDInRange($wikiStream->getStreamId(), null, null, 'Ht_en');
        while ($row = $dbr->fetchObject($mvd_res)) {
            $title = Title::newFromText($row->wiki_title, MV_NS_MVD);
            $current = Revision::newFromTitle($title);
            if ($current->getUserText() == $botUserName) {
                $article = new Article($title);
                $article->doDelete('mvbot removal');
                print "removed {$row->wiki_title} \n";
            } else {
                print "skiped {$roe->wiki_title} (last edit by: " . $current->getUserText() . ")\n";
            }
        }
    }
    /* for now use the stream search table (in the future should put in our orphaned person data)
     * should be able to do quick checks against the index. */
    $sql = "SELECT (`time`+" . CC_OFFSET . ") as time, `value` " . "FROM `metavid`.`stream_attr_time_text`\n\t\t\t\t\t\tWHERE `stream_fk`=" . $stream->id . "\n\t\t\t\t\t\tAND `time` >= " . $stream->adj_start_time . "\n\t\t\t\t\t\tAND `time` <= " . $stream->adj_end_time . "\n\t\t\t\tORDER BY `time` ASC ";
    // $sql = "SELECT * FROM `metavid`.`stream_search` WHERE `stream_fk`={$stream->id}";
    $page_res = $dbr->query($sql);
    if ($dbr->numRows($page_res) == 0) {
        echo 'No pages for stream' . $stream->name . "\n";
    }
    $pages = array();
    while ($page = $dbr->fetchObject($page_res)) {
        $pages[] = $page;
    }
    print "Checking " . count($pages) . " text pages\n";
    $i = $j = 0;
    foreach ($pages as $inx => $page) {
        // status updates:
        if ($i == 50) {
            print "on {$j} of " . count($pages) . "\n";
            $i = 0;
        }
        $i++;
        $j++;
        $start_time = $page->time - $stream->adj_start_time;
        if (seconds2npt($start_time) < 0) {
            $start_time = '0:00:00';
        }
        if ($inx + 1 == count($pages)) {
            $end_time = $stream->adj_end_time - $stream->adj_start_time;
        } else {
            $end_time = $pages[$inx + 1]->time - $stream->adj_start_time;
        }
        if ($end_time - $start_time > 40) {
            $end_time = $start_time + 40;
        }
        // skip if end_time <1
        if ($end_time < 0) {
            continue;
        }
        // now pull up the person for the given stream time:`metavid`.`people`.`name_clean`
        $sql = "SELECT * , abs( `metavid`.`people_attr_stream_time`.`time` -{$page->time} ) AS `distance` " . "FROM `metavid`.`people_attr_stream_time` " . "LEFT JOIN `metavid`.`people` ON `metavid`.`people_attr_stream_time`.`people_fk` = `metavid`.`people`.`id` " . "WHERE `metavid`.`people_attr_stream_time`.`stream_fk` ={$stream->id} " . "AND  (`metavid`.`people_attr_stream_time`.`time`-{$page->time})>-4 " . "AND abs( `metavid`.`people_attr_stream_time`.`time` -{$page->time} )< 90 " . "ORDER BY `distance` ASC " . "LIMIT 1 ";
        $person_res = $dbr->query($sql);
        $page_title = $stream->name . '/' . seconds2npt($start_time) . '/' . seconds2npt($end_time);
        // print $page_title . "\n";
        $page_body = '';
        if ($dbr->numRows($person_res) != 0) {
            $person = $dbr->fetchObject($person_res);
            $person_name = utf8_encode($person->name_clean);
            $page_body .= "\n[[Spoken By::{$person_name}]] ";
        }
        $page_body .= trim(str_replace("\n", ' ', strtolower($page->value)));
        // print $page_title . "\n";
        // die;
        // print $page_body . "\n\n";
        do_update_wiki_page('Ht_en:' . $page_title, $page_body, MV_NS_MVD);
    }
}
Example #18
0
 public function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     // Scan all talk pages for AjaxComments data structures
     $this->output("\nScanning talk pages for comments needing migration...\n");
     $res = $dbw->select('page', array('page_id'), array('page_namespace & 1'));
     $data = array();
     $pages = 0;
     $cpages = 0;
     foreach ($res as $row) {
         $id = $row->page_id;
         $title = Title::newFromId($id);
         if ($title->exists()) {
             $pages++;
             $article = new Article($title);
             $content = $article->getPage()->getContent()->getNativeData();
             // This page ID of the associated content page
             $page = Title::newFromText($title->getText(), $title->getNamespace() - 1);
             if ($page) {
                 $page = $page->getArticleID();
                 $this->output("   Processing talk page with ID {$id} (associated content page has ID {$page})\n");
                 // If this page has AjaxComments data in it's current revision, extract the data,
                 if ($ac = $this->textToData($content)) {
                     $cpages++;
                     foreach ($ac as $k => $v) {
                         $data[$k] = $v;
                         $data[$k]['talk'] = $id;
                         $data[$k]['page'] = $page;
                         $data[$k]['id'] = count($data);
                     }
                     // and revert it to it's state prior to AjaxComments, or delete it
                     $rev = Revision::newFromId($title->getLatestRevID());
                     do {
                         $rev = $rev->getPrevious();
                     } while ($rev && strpos($comment = $rev->getRawComment(), 'AjaxComments') !== false);
                     if ($rev) {
                         $this->output("      Reverting (talkpage {$id}) to comment " . $rev->getId() . " (Edit comment: '{$comment}').\n");
                         $article->doEdit($rev->getText(), 'Reverted talkpage to state prior to AJAXCOMMENTS additions', EDIT_UPDATE);
                     } else {
                         $this->output("      Deleting (talkpage {$id}) as it has only AjaxComments revisions.\n");
                         $article->doDelete('Deleting talkpage, comments data has been moved into the "ajaxcomments" database table.');
                     }
                 }
             }
         }
     }
     $this->output("   Done (" . count($data) . " comments migrated from {$cpages} talkpages out of {$pages} in total)\n");
     // Update the data to the new format
     $this->output("\nUpgrading comment data...\n");
     foreach ($data as $k => $v) {
         $id = $data[$k]['id'];
         $name = $data[$k][AJAXCOMMENTS_USER];
         $uid = User::newFromName($name)->getId();
         if ($uid < 1) {
             $uid = 0;
             $this->output('   WARNING: Invalid user in comment $k in page ' . $data[$k]['page'] . " ID set to zero\n");
         }
         $data[$k][AJAXCOMMENTS_USER] = $uid;
         $this->output("   New id for {$k} is {$id}, user '{$name}' has ID {$uid}\n");
         if ($parent = $data[$k][AJAXCOMMENTS_PARENT]) {
             $data[$k][AJAXCOMMENTS_PARENT] = $data[$parent]['id'];
             $this->output("      'parent' field changed from {$parent} to " . $data[$parent]['id'] . "\n");
         }
         if ($n = count($data[$k][AJAXCOMMENTS_LIKE])) {
             $likes = array();
             foreach ($data[$k][AJAXCOMMENTS_LIKE] as $name => $val) {
                 $uid = User::newFromName($name)->getId();
                 if ($uid) {
                     $likes[$uid] = $val;
                 } else {
                     $this->output("      WARNING: Invalid user in 'like' field, item dropped\n");
                 }
             }
             $data[$k][AJAXCOMMENTS_LIKE] = $likes;
             $this->output("      {$n} usernames changed to IDs in the 'like' field\n");
         }
     }
     $this->output("   Done\n");
     // Add the new table
     $tbl = $dbw->tableName(AJAXCOMMENTS_TABLE);
     $this->output("\nAdding table {$tbl} if it doesn't already exist, clearing data if it does exist...\n");
     $dbw->query("DROP TABLE IF EXISTS {$tbl}");
     $dbw->query("CREATE TABLE IF NOT EXISTS {$tbl} (\n\t\t\tac_id     INT UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\tac_type   INT UNSIGNED NOT NULL,\n\t\t\tac_parent INT UNSIGNED,\n\t\t\tac_user   INT UNSIGNED,\n\t\t\tac_page   INT UNSIGNED,\n\t\t\tac_time   INT UNSIGNED,\n\t\t\tac_data   TEXT,\n\t\t\tPRIMARY KEY (ac_id)\n\t\t)");
     $this->output("   Done\n");
     // Insert the upgraded data into the table
     $this->output("\nInserting the upgraded data into the table...\n");
     foreach ($data as $k => $v) {
         $id = $data[$k]['id'];
         $page = $data[$k]['page'];
         $this->output("   Inserting comment {$id} (was {$k})\n");
         $dbw->insert(AJAXCOMMENTS_TABLE, array('ac_type' => AJAXCOMMENTS_DATATYPE_COMMENT, 'ac_parent' => $data[$k][AJAXCOMMENTS_PARENT], 'ac_user' => $data[$k][AJAXCOMMENTS_USER], 'ac_page' => $page, 'ac_time' => $data[$k][AJAXCOMMENTS_DATE], 'ac_data' => $data[$k][AJAXCOMMENTS_TEXT]));
         // Insert a row for each 'like' in this comment
         if ($n = count($data[$k][AJAXCOMMENTS_LIKE])) {
             foreach ($data[$k][AJAXCOMMENTS_LIKE] as $uid => $val) {
                 $dbw->insert(AJAXCOMMENTS_TABLE, array('ac_type' => AJAXCOMMENTS_DATATYPE_LIKE, 'ac_parent' => $id, 'ac_user' => $uid, 'ac_page' => $page, 'ac_data' => $val));
             }
             $this->output("      {$n} 'like' rows added for this comment\n");
         }
     }
 }
 function removeStream($removeMVDs = true)
 {
     $dbw = wfGetDB(DB_WRITE);
     $dbr = wfGetDB(DB_SLAVE);
     if ($removeMVDs) {
         // delete metadata pages:
         // @@todo figure out a way to do this quickly/group sql queries.
         $mvd_rows = MV_Index::getMVDInRange($this->getStreamId());
         foreach ($mvd_rows as $row) {
             $title = Title::newFromText($row->wiki_title, MV_NS_MVD);
             $article = new Article($title);
             $article->doDelete('parent stream removed');
         }
     }
     //remove the stream db entries and images:
     $this->deleteDB();
     return true;
 }
Example #20
0
 function doDelete($pages, $reason)
 {
     foreach ($pages as $page) {
         $title = Title::newFromURL($page);
         $file = $title->getNamespace() == NS_IMAGE ? wfLocalFile($title) : false;
         if ($file) {
             $oldimage = null;
             // Must be passed by reference
             FileDeleteForm::doDelete($title, $file, $oldimage, $reason, false);
         } else {
             $article = new Article($title);
             $article->doDelete($reason);
         }
     }
 }
 /**
  * If a user is nabbing an article, there are Skip/Cancel and Mark as
  * Patrolled buttons at the buttom of the list of NAB actions.  When
  * either of these buttons are pushed, this function processes the
  * submitted form.
  */
 private function doNABAction(&$dbw)
 {
     global $wgRequest, $wgOut, $wgUser;
     $err = false;
     $aid = $wgRequest->getVal('page', 0);
     $aid = intval($aid);
     if ($wgRequest->getVal('nap_submit', null) != null) {
         $title = Title::newFromID($aid);
         // MARK ARTICLE AS PATROLLED
         self::markNabbed($dbw, $aid, $wgUser->getId());
         if (!$title) {
             $wgOut->addHTML('Error: target page for NAB was not found');
             return;
         }
         // LOG ENTRY
         $params = array($aid);
         $log = new LogPage('nap', false);
         $log->addEntry('nap', $title, wfMsg('nap_logsummary', $title->getFullText()), $params);
         // ADD ANY TEMPLATES
         self::addTemplates($title);
         // Rising star actions FS RS
         $this->flagRisingStar($title);
         // DELETE ARTICLE IF PATROLLER WANTED THIS
         if ($wgRequest->getVal('delete', null) != null && $wgUser->isAllowed('delete')) {
             $article = new Article($title);
             $article->doDelete($wgRequest->getVal("delete_reason"));
         }
         // MOVE/RE-TITLE ARTICLE IF PATROLLER WANTED THIS
         if ($wgRequest->getVal('move', null) != null && $wgUser->isAllowed('move')) {
             if ($wgRequest->getVal('move_newtitle', null) == null) {
                 $wgOut->addHTML('Error: no target page title specified.');
                 return;
             }
             $newTarget = $wgRequest->getVal('move_newtitle');
             $newTitle = Title::newFromText($newTarget);
             if (!$newTitle) {
                 $wgOut->addHTML("Bad new title: {$newTarget}");
                 return;
             }
             $ret = $title->moveTo($newTitle);
             if (is_string($ret)) {
                 $wgOut->addHTML("Renaming of the article failed: " . wfMsg($ret));
                 $err = true;
             }
             // move the talk page if it exists
             $oldTitleTalkPage = $title->getTalkPage();
             if ($oldTitleTalkPage->exists()) {
                 $newTitleTalkPage = $newTitle->getTalkPage();
                 $err = $oldTitleTalkPage->moveTo($newTitleTalkPage) === true;
             }
             $title = $newTitle;
         }
         // MARK ALL PREVIOUS EDITS AS PATROLLED IN RC
         $maxrcid = $wgRequest->getVal('maxrcid');
         if ($maxrcid) {
             $res = $dbw->select('recentchanges', 'rc_id', array('rc_id<=' . $maxrcid, 'rc_cur_id=' . $aid, 'rc_patrolled=0'), __METHOD__);
             while ($row = $dbw->fetchObject($res)) {
                 RecentChange::markPatrolled($row->rc_id);
                 PatrolLog::record($row->rc_id, false);
             }
             $dbw->freeResult($res);
         }
         wfRunHooks("NABArticleFinished", array($aid));
     }
     // GET NEXT UNPATROLLED ARTICLE
     if ($wgRequest->getVal('nap_skip') && $wgRequest->getVal('page')) {
         // if article was skipped, clear the checkout of the
         // article, so others can NAB it
         $dbw->update('newarticlepatrol', array('nap_user_co=0'), array("nap_page", $aid), __METHOD__);
     }
     $title = $this->getNextUnpatrolledArticle($dbw, $aid);
     if (!$title) {
         $wgOut->addHTML("Unable to get next id to patrol.");
         return;
     }
     $nap = SpecialPage::getTitleFor('Newarticleboost', $title->getPrefixedText());
     $url = $nap->getFullURL() . ($this->do_newbie ? '?newbie=1' : '');
     if (!$err) {
         $wgOut->redirect($url);
     } else {
         $wgOut->addHTML("<br/><br/>Click <a href='{$nap->getFullURL()}'>here</a> to continue.");
     }
 }
Example #22
0
 function doSubmit()
 {
     global $wgOut, $wgUser, $wgRequest;
     $fname = "MovePageForm::doSubmit";
     if ($wgUser->pingLimiter('move')) {
         $wgOut->rateLimited();
         return;
     }
     # Variables beginning with 'o' for old article 'n' for new article
     // WERELATE - default ns on new title to ns on old title
     $ot = Title::newFromText($this->oldTitle);
     $nt = Title::newFromText($this->newTitle, $ot->getNamespace());
     // WERELATE - added: PERSON and FAMILY pages must have a unique id
     if ($nt && ($nt->getNamespace() == NS_PERSON || $nt->getNamespace() == NS_FAMILY) && !StructuredData::titleStringHasId($nt->getText())) {
         $nt = StructuredData::appendUniqueId($nt);
     }
     # Delete to make way if requested
     // WERELATE: added title parm and $nt condition
     if ($nt && $wgUser->isAllowed('delete', $nt) && $this->deleteAndMove) {
         $article = new Article($nt);
         // This may output an error message and exit
         $article->doDelete(wfMsgForContent('delete_and_move_reason'));
     }
     # don't allow moving to pages with # in
     if (!$nt || $nt->getFragment() != '') {
         $this->showForm('badtitletext');
         return;
     }
     $error = $ot->moveTo($nt, true, $this->reason);
     if ($error !== true) {
         $this->showForm($error);
         return;
     }
     wfRunHooks('SpecialMovepageAfterMove', array(&$this, &$ot, &$nt));
     # Move the talk page if relevant, if it exists, and if we've been told to
     $ott = $ot->getTalkPage();
     if ($ott->exists()) {
         if ($wgRequest->getVal('wpMovetalk') == 1 && !$ot->isTalkPage() && !$nt->isTalkPage()) {
             $ntt = $nt->getTalkPage();
             # Attempt the move
             $error = $ott->moveTo($ntt, true, $this->reason);
             if ($error === true) {
                 $talkmoved = 1;
                 wfRunHooks('SpecialMovepageAfterMove', array(&$this, &$ott, &$ntt));
             } else {
                 $talkmoved = $error;
             }
         } else {
             # Stay silent on the subject of talk.
             $talkmoved = '';
         }
     } else {
         $talkmoved = 'notalkpage';
     }
     # Give back result to user.
     $titleObj = Title::makeTitle(NS_SPECIAL, 'Movepage');
     $success = $titleObj->getFullURL('action=success&oldtitle=' . wfUrlencode($ot->getPrefixedText()) . '&newtitle=' . wfUrlencode($nt->getPrefixedText()) . '&talkmoved=' . $talkmoved);
     $wgOut->redirect($success);
 }
 function doSubmit()
 {
     global $wgOut, $wgUser, $wgLang;
     global $wgDeferredUpdateList, $wgMessageCache;
     global $wgUseSquid, $wgRequest;
     $fname = "MovePageForm::doSubmit";
     if ($wgUser->pingLimiter('move')) {
         $wgOut->rateLimited();
         return;
     }
     # Variables beginning with 'o' for old article 'n' for new article
     $ot = Title::newFromText($this->oldTitle);
     $nt = Title::newFromText($this->newTitle);
     # Delete to make way if requested
     if ($wgUser->isAllowed('delete') && $this->deleteAndMove) {
         $article = new Article($nt);
         // This may output an error message and exit
         $article->doDelete(wfMsgForContent('delete_and_move_reason'));
     }
     # don't allow moving to pages with # in
     if (!$nt || $nt->getFragment() != '') {
         $this->showForm('badtitletext');
         return;
     }
     $error = $ot->moveTo($nt, true, $this->reason);
     if ($error !== true) {
         $this->showForm($error);
         return;
     }
     # Move talk page if
     # (1) the checkbox says to,
     # (2) the namespaces are not themselves talk namespaces, and of course
     # (3) it exists.
     if ($wgRequest->getVal('wpMovetalk') == 1 && !$ot->isTalkPage() && !$nt->isTalkPage()) {
         $ott = $ot->getTalkPage();
         $ntt = $nt->getTalkPage();
         # Attempt the move
         $error = $ott->moveTo($ntt, true, $this->reason);
         if ($error === true) {
             $talkmoved = 1;
         } else {
             $talkmoved = $error;
         }
     } else {
         # Stay silent on the subject of talk.
         $talkmoved = '';
     }
     # Give back result to user.
     $titleObj = Title::makeTitle(NS_SPECIAL, 'Movepage');
     $success = $titleObj->getFullURL('action=success&oldtitle=' . wfUrlencode($ot->getPrefixedText()) . '&newtitle=' . wfUrlencode($nt->getPrefixedText()) . '&talkmoved=' . $talkmoved);
     $wgOut->redirect($success);
 }
 function doDelete($pages, $reason)
 {
     foreach ($pages as $page) {
         $title = Title::newFromUrl($page);
         $article = new Article($title);
         $article->doDelete($reason);
     }
 }
 function doSubmit()
 {
     global $wgOut, $wgUser, $wgRequest;
     if ($wgUser->pingLimiter('move')) {
         $wgOut->rateLimited();
         return;
     }
     # Variables beginning with 'o' for old article 'n' for new article
     $ot = Title::newFromText($this->oldTitle);
     $nt = Title::newFromText($this->newTitle);
     # Delete to make way if requested
     if ($wgUser->isAllowed('delete') && $this->deleteAndMove) {
         $article = new Article($nt);
         // This may output an error message and exit
         $article->doDelete(wfMsgForContent('delete_and_move_reason'));
     }
     # don't allow moving to pages with # in
     if (!$nt || $nt->getFragment() != '') {
         $this->showForm('badtitletext');
         return;
     }
     $hookErr = null;
     if (!wfRunHooks('AbortMove', array($ot, $nt, $wgUser, &$hookErr))) {
         $this->showForm('hookaborted', $hookErr);
         return;
     }
     $error = $ot->moveTo($nt, true, $this->reason);
     if ($error !== true) {
         $this->showForm($error);
         return;
     }
     wfRunHooks('SpecialMovepageAfterMove', array(&$this, &$ot, &$nt));
     # Move the talk page if relevant, if it exists, and if we've been told to
     $ott = $ot->getTalkPage();
     if ($ott->exists()) {
         if ($this->moveTalk && !$ot->isTalkPage() && !$nt->isTalkPage()) {
             $ntt = $nt->getTalkPage();
             # Attempt the move
             $error = $ott->moveTo($ntt, true, $this->reason);
             if ($error === true) {
                 $talkmoved = 1;
                 wfRunHooks('SpecialMovepageAfterMove', array(&$this, &$ott, &$ntt));
             } else {
                 $talkmoved = $error;
             }
         } else {
             # Stay silent on the subject of talk.
             $talkmoved = '';
         }
     } else {
         $talkmoved = 'notalkpage';
     }
     # Deal with watches
     if ($this->watch) {
         $wgUser->addWatch($ot);
         $wgUser->addWatch($nt);
     } else {
         $wgUser->removeWatch($ot);
         $wgUser->removeWatch($nt);
     }
     # Give back result to user.
     $titleObj = SpecialPage::getTitleFor('Movepage');
     $success = $titleObj->getFullURL('action=success&oldtitle=' . wfUrlencode($ot->getPrefixedText()) . '&newtitle=' . wfUrlencode($nt->getPrefixedText()) . '&talkmoved=' . $talkmoved);
     $wgOut->redirect($success);
 }
Example #26
0
function mvMoveHook(&$old_title, &$new_title, &$user, $pageid, $redirid)
{
    global $mvgIP, $wgOut;
    // die;
    // confirm we are in the mvd Namespace & update the wiki_title
    if ($old_title->getNamespace() == MV_NS_MVD) {
        MV_Index::update_index_title($old_title->getDBkey(), $new_title->getDBkey());
        //remove the old MVD having lots of redirects around is not fun
        $oldArticle = new Article($old_title);
        $oldArticle->doDelete(wfMsg('mv_move_delete_msg', $new_title->getText()), false);
        //clear output  @@todo (should really check for errors and integrate info into move)
        $wgOut->clearHTML();
    } else {
        //make sure we call smwfMoveHook after and only if we don't delete
        if (function_exists('smwfMoveHook')) {
            smwfMoveHook($old_title, $new_title, $user, $pageid, $redirid);
        }
    }
    return true;
    // always return true, in order not to stop MW's hook processing!
}
Example #27
0
/**
 * Part of SemanticImageAnnotator
 * Provides Functions that are called from Javascript.
 * The functions are called from the editing view as well as from query results with format=imageannotation
 * @author Felix Obenauer
 */
function removeAnnotation($annotationID)
{
    $article = new Article(Title::newFromText($annotationID));
    $article->doDelete('ImageAnnotation removed');
    return $annotationID;
}
/**
 * Deletes an article. This function is invoked by an ajax call.
 * 
 * @param string $pagename The name of the article.
 * @param string $reason A reason why it was deleted.
 * @param string $user The name of the user who wants to delete the article
 */
function smwf_om_DeleteArticle($pagename, $user, $reason)
{
    if (smwf_om_userCan($pagename, 'delete') === "false") {
        return "false,denied,{$pagename}";
    }
    $titleObj = Title::newFromText($pagename);
    $article = new Article($titleObj);
    if ($article->exists()) {
        $article->doDelete($reason);
    }
    return "true";
}