Exemplo n.º 1
0
 /**
  * Reinforces an Athena training page
  *
  * @param $id integer
  * @param $spam boolean - whether its been marked for spam or not
  */
 public function reinforceAthenaPage($id, $spam)
 {
     global $wgAthenaTraining;
     $output = $this->getOutput();
     $this->setHeaders();
     $output->setPageTitle(wfMessage('athena-title') . ' - ' . wfMessage('athena-reinforce-title', $id));
     if ($wgAthenaTraining) {
         $dbw = wfGetDB(DB_SLAVE);
         $res = $dbw->selectRow(array('athena_log', 'athena_page_details'), array('athena_log.al_id', 'al_value', 'apd_content', 'apd_comment', 'apd_namespace', 'apd_title', 'al_success', 'al_overridden', 'apd_user'), array('athena_log.al_id' => $id, 'athena_page_details.al_id' => $id), __METHOD__, array());
         // Check the Athena id exists
         if ($res) {
             // Check it is training data
             if ($res->al_success >= 2) {
                 // Check it hasn't been overridden already
                 if ($res->al_overridden == 0) {
                     if ($spam) {
                         AthenaHelper::reinforceDeleteTraining($id);
                     } else {
                         AthenaHelper::reinforceCreateTraining($id);
                     }
                     // Reinforce the system
                     $output->addWikiMsg('athena-reinforce-reinforced');
                     if ($spam) {
                         $al_success = 3;
                     } else {
                         $al_success = 4;
                     }
                     $dbw->update('athena_log', array('al_overridden' => 1, 'al_success' => $al_success), array('al_id' => $id), __METHOD__, null);
                 } else {
                     $output->addWikiMsgArray('athena-reinforce-error-overridden', $id);
                 }
             } else {
                 $output->addWikiMsgArray('athena-reinforce-error-not-blocked', $id);
             }
         } else {
             $output->addWikiMsgArray('athena-reinforce-error-not-exists', $id);
         }
     } else {
         $output->addWikiMsg('athena-training-off');
     }
 }