<?php

/**
 * @package MediaWiki
 * @addtopackage maintenance
 */
ini_set("include_path", dirname(__FILE__) . "/..");
require_once "commandLine.inc";
require_once $GLOBALS["IP"] . "/extensions/wikia/TaskManager/Tasks/MultiWikiEditTask.php";
global $wgMaxShellTime, $wgMaxShellFileSize;
$wgMaxShellTime = 0;
$wgMaxShellFileSize = 0;
global $wgExternalSharedDB;
$dbr = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
$aCondition = array("task_id" => $options['TASK_ID']);
$oTask = $dbr->selectRow("wikia_tasks", "*", $aCondition, __METHOD__, array("ORDER BY" => "task_id"));
$task = new \Wikia\Tasks\Tasks\MultiTask();
$task->edit(unserialize($oTask->task_arguments));
 public function deleteUserPages()
 {
     wfProfileIn(__METHOD__);
     if (!$this->checkRequest()) {
         wfProfileOut(__METHOD__);
         return;
     }
     $user = $this->request->getVal('user');
     if (empty($user)) {
         $this->response->setVal('success', false);
         $this->response->setVal('errorMsg', wfMessage('coppatool-invalid-user')->plain());
         wfProfileOut(__METHOD__);
         return;
     }
     $userObj = User::newFromName($user);
     if (!$userObj instanceof User || $userObj->getId() === 0) {
         $this->response->setVal('success', false);
         $this->response->setVal('errorMsg', wfMessage('coppatool-invalid-user')->plain());
         wfProfileOut(__METHOD__);
         return;
     }
     $taskParams = ['mode' => 'you', 'page' => 'User:'******'wikis' => '', 'range' => 'all', 'reason' => wfMessage('coppatool-delete-user-pages-reason')->plain(), 'lang' => '', 'cat' => 0, 'selwikia' => 0, 'edittoken' => $this->wg->User->getEditToken(), 'user' => $this->wg->User->getName(), 'admin' => $this->wg->User->getName(), 'suppress' => true];
     $task = new \Wikia\Tasks\Tasks\MultiTask();
     $task->call('delete', $taskParams);
     $batchDeleteTaskId = $task->queue();
     $this->response->setVal('success', true);
     $this->response->setVal('resultMsg', wfMessage('coppatool-delete-user-pages-success', $batchDeleteTaskId)->plain());
     wfProfileOut(__METHOD__);
 }
<?php

/**
 * @package MediaWiki
 * @addtopackage maintenance
 */
ini_set("include_path", dirname(__FILE__) . "/..");
require_once "commandLine.inc";
require_once $GLOBALS["IP"] . "/extensions/wikia/MultiTasks/Tasks/MultiDeleteTask.php";
global $wgMaxShellTime, $wgMaxShellFileSize;
$wgMaxShellTime = 0;
$wgMaxShellFileSize = 0;
global $wgExternalSharedDB;
$dbr = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
$aCondition = array("task_id" => $options['TASK_ID']);
$oTask = $dbr->selectRow("wikia_tasks", "*", $aCondition, __METHOD__, array("ORDER BY" => "task_id"));
$task = new \Wikia\Tasks\Tasks\MultiTask();
$task->delete(unserialize($oTask->task_arguments));
 /**
  * create task to move comment
  *
  * @access public
  * @static
  *
  * @param Title $oCommentTitle
  * @param Title $oNewTitle
  * @param array $taskParams
  *
  * @return bool
  * @throws MWException
  */
 private static function addMoveTask($oCommentTitle, &$oNewTitle, $taskParams)
 {
     wfProfileIn(__METHOD__);
     if (!is_object($oCommentTitle)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $parts = self::explode($oCommentTitle->getDBkey());
     $commentTitleText = implode('/', $parts['partsOriginal']);
     $newCommentTitle = Title::newFromText(sprintf('%s/%s', $oNewTitle->getText(), $commentTitleText), MWNamespace::getTalk($oNewTitle->getNamespace()));
     $taskParams['page'] = $oCommentTitle->getFullText();
     $taskParams['newpage'] = $newCommentTitle->getFullText();
     $task = new \Wikia\Tasks\Tasks\MultiTask();
     $task->call('move', $taskParams);
     $submit_id = $task->queue();
     Wikia::log(__METHOD__, 'deletecomment', "Added move task ({$submit_id}) for {$taskParams['page']} page");
     wfProfileOut(__METHOD__);
     return true;
 }
Exemple #5
0
 /**
  * acceptSubmit
  *
  * display message after submit action
  *
  * @access private
  *
  * @return display form
  */
 protected function acceptSubmit($mode = MULTIWIKITASK_THIS, $lang = '', $cat = 0)
 {
     global $wgUser, $wgOut, $wgCityId;
     $lines = explode("\n", $this->mPage);
     $pre_wikis = array();
     $wikiaId = 0;
     $modeText = "";
     switch ($mode) {
         case MULTIWIKITASK_SELECTED:
             $pre_wikis = explode(",", $this->mWikiInbox);
             array_walk($pre_wikis, create_function('&$str', '$str=trim($str);'));
             $lang = $cat = "";
             $modeText = wfMsg('multiwikiedit_selected_wikis');
             break;
         case MULTIWIKITASK_ALL:
             $pre_wikis = array();
             $modeText = wfMsg('multiwikiedit_all_wikis');
             break;
         case MULTIWIKITASK_THIS:
             $pre_wikis = array();
             $wikiaId = $wgCityId;
             $modeText = wfMsg('multiwikiedit_this_wiki');
             $lang = $cat = "";
             break;
     }
     #---
     $countWikis = $this->fetchCountWikis($pre_wikis, $lang, $cat, $wikiaId);
     #---
     $this->makeDefaultTaskParams($lang, $cat, $wikiaId);
     $wgOut->addHTML("<p><strong>" . wfMsg('multiwikiedit_tasks_list') . ": </strong></p>");
     $wgOut->addHTML(Xml::openElement('ol', null));
     foreach ($lines as $single_page) {
         #-- lines with articles
         $aTitles = explode("|", trim($single_page));
         if (!empty($aTitles)) {
             $loop = 0;
             foreach ($aTitles as $sTitle) {
                 $loop++;
                 $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
                 $this->mTaskParams['page'] = $sTitle;
                 $task = new \Wikia\Tasks\Tasks\MultiTask();
                 switch ($this->mTaskClass) {
                     case 'MultiDeleteTask':
                         $taskAction = 'delete';
                         break;
                     case 'MultiWikiEditTask':
                         $taskAction = 'edit';
                         break;
                     default:
                         throw new InvalidArgumentException("unsupported modern class: {$this->mTaskClass}");
                 }
                 $task->call($taskAction, $this->mTaskParams);
                 $submit_id = $task->queue();
                 $submitLink = wfMsg("multi_task_added_{$taskAction}", $submit_id);
                 $oTmpl->set_vars(array("modeText" => $modeText, "wgUser" => $wgUser, "sTitle" => $sTitle, "mTaskParams" => $this->mTaskParams, "countWikis" => $countWikis, "lang" => $lang, "cat" => $cat, "obj" => $this, "submit_id" => $submit_id, 'submitLink' => $submitLink, "error" => $submit_id === false));
                 $wgOut->addHTML($oTmpl->render($this->mFinishForm));
             }
         }
     }
     $wgOut->addHTML(Xml::closeElement('ol'));
     $wgOut->addHtml($this->getBackUrl());
 }
<?php

/**
 * @package MediaWiki
 * @addtopackage maintenance
 */
ini_set("include_path", dirname(__FILE__) . "/..");
require_once "commandLine.inc";
require_once $GLOBALS["IP"] . "/extensions/wikia/MultiTasks/SpecialMultiDelete.php";
global $wgMaxShellTime, $wgMaxShellFileSize;
$wgMaxShellTime = 0;
$wgMaxShellFileSize = 0;
$add = isset($options['add']);
$TASK_ID = isset($options['TASK_ID']) ? $options['TASK_ID'] : 0;
if ($add) {
    $params = array('page' => 'Ad_free_wikis_old', 'newpage' => 'Ad_New_free_wikis_old', 'user' => 'Moli.wikia', 'redirect' => 1, 'watch' => 1, 'reason' => 'test moved 2', 'selwikia' => 177);
    $task = new \Wikia\Tasks\Tasks\MultiTask();
    $task->call('move', $params);
    $task->queue();
} elseif ($TASK_ID) {
    global $wgExternalSharedDB;
    $dbr = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
    $aCondition = array("task_id" => $TASK_ID);
    $oTask = $dbr->selectRow("wikia_tasks", "*", $aCondition, __METHOD__, array("ORDER BY" => "task_id"));
    $task = new \Wikia\Tasks\Tasks\MultiTask();
    $task->move(unserialize($oTask->task_arguments));
} else {
    // do nothing
    echo "nothing to do \n";
}
 /**
  * Hook
  *
  * @param WikiPage $wikiPage -- instance of Article class
  * @param User    $user    -- current user
  * @param string  $reason  -- deleting reason
  * @param integer $id      -- article id
  *
  * @static
  * @access public
  *
  * @return boolean -- because it's a hook
  */
 public static function articleDeleteComplete(WikiPage &$wikiPage, &$user, $reason, $id)
 {
     global $wgOut, $wgRC2UDPEnabled, $wgMaxCommentsToDelete, $wgCityId, $wgUser, $wgEnableMultiDeleteExt;
     wfProfileIn(__METHOD__);
     $title = $wikiPage->getTitle();
     if (!MWNamespace::isTalk($title->getNamespace()) || !ArticleComment::isTitleComment($title)) {
         if (empty(self::$mArticlesToDelete)) {
             wfProfileOut(__METHOD__);
             return true;
         }
     }
     if (class_exists('WallHelper') && WallHelper::isWallNamespace($title->getNamespace())) {
         wfProfileOut(__METHOD__);
         return true;
     }
     //watch out for recursion
     if (self::$mDeletionInProgress) {
         wfProfileOut(__METHOD__);
         return true;
     }
     self::$mDeletionInProgress = true;
     //redirect to article/blog after deleting a comment (or whole article/blog)
     $parts = ArticleComment::explode($title->getText());
     $parentTitle = Title::newFromText($parts['title'], MWNamespace::getSubject($title->getNamespace()));
     $wgOut->redirect($parentTitle->getFullUrl());
     //do not use $reason as it contains content of parent article/comment - not current ones that we delete in a loop
     $deleteReason = wfMsgForContent('article-comments-delete-reason');
     //we have comment 1st level - checked in articleDelete() (or 2nd - so do nothing)
     if (is_array(self::$mArticlesToDelete)) {
         $mDelete = 'live';
         if (isset($wgMaxCommentsToDelete) && count(self::$mArticlesToDelete) > $wgMaxCommentsToDelete) {
             if (!empty($wgEnableMultiDeleteExt)) {
                 $mDelete = 'task';
             }
         }
         if ($mDelete == 'live') {
             $irc_backup = $wgRC2UDPEnabled;
             //backup
             $wgRC2UDPEnabled = false;
             //turn off
             foreach (self::$mArticlesToDelete as $page_id => $oComment) {
                 $oCommentTitle = $oComment->getTitle();
                 if ($oCommentTitle instanceof Title) {
                     $oComment = new ArticleComment($oCommentTitle);
                     $oComment->doDeleteComment($deleteReason);
                 }
             }
             $wgRC2UDPEnabled = $irc_backup;
             //restore to whatever it was
             $listing = ArticleCommentList::newFromTitle($parentTitle);
             $listing->purge();
         } else {
             $taskParams = array('mode' => 'you', 'wikis' => '', 'range' => 'one', 'reason' => 'delete page', 'lang' => '', 'cat' => '', 'selwikia' => $wgCityId, 'edittoken' => $wgUser->getEditToken(), 'user' => $wgUser->getName(), 'admin' => $wgUser->getName());
             foreach (self::$mArticlesToDelete as $oComment) {
                 $oCommentTitle = $oComment->getTitle();
                 if ($oCommentTitle instanceof Title) {
                     /* @var $oCommentTitle Title */
                     $data = $taskParams;
                     $data['page'] = $oCommentTitle->getFullText();
                     $task = new \Wikia\Tasks\Tasks\MultiTask();
                     $task->call('delete', $data);
                     $submit_id = $task->queue();
                     Wikia::log(__METHOD__, 'deletecomment', "Added task ({$submit_id}) for {$data['page']} page");
                 }
             }
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }