/** * dismiss notification * * @author Marooned */ public static function dismiss() { wfProfileIn(__METHOD__); global $wgRequest; $result = false; // this request should be posted if ($wgRequest->wasPosted()) { AutomaticWikiAdoptionHelper::dismissNotification(); $result = true; } wfProfileOut(__METHOD__); return array('result' => $result); }
/** * entry point * * @author Maciej Błaszkowski <marooned at wikia-inc.com> */ function execute($par) { global $wgCityId, $wgOut, $wgExtensionsPath, $wgJsMimeType, $wgRequest, $wgUser, $wgTitle; wfProfileIn(__METHOD__); $this->setHeaders(); $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/AutomaticWikiAdoption/css/AutomaticWikiAdoption.scss')); $canAdopt = AutomaticWikiAdoptionHelper::isAllowedToAdopt($wgCityId, $wgUser); if ($canAdopt == AutomaticWikiAdoptionHelper::USER_ALLOWED) { //allowed to adopt if ($wgRequest->wasPosted()) { //user clicked button to adopt a wiki if (AutomaticWikiAdoptionHelper::adoptWiki($wgCityId, $wgUser)) { $mainPage = wfMsgForContent('mainpage'); $wgOut->redirect($mainPage . '?modal=Adopt'); } else { $wgOut->addHTML(wfMsgExt('wikiadoption-adoption-failed', array('parseinline'))); } } else { //render HTML $template = new EasyTemplate(dirname(__FILE__) . '/templates'); $template->set_vars(array('formAction' => $wgTitle->getFullURL(), 'username' => $wgUser->getName())); $wgOut->addHTML($template->render('main')); } } else { //not allowed to adopt switch ($canAdopt) { case AutomaticWikiAdoptionHelper::REASON_NOT_ENOUGH_EDITS: $msg = wfMsgExt('wikiadoption-not-enough-edits', array('parseinline')); break; case AutomaticWikiAdoptionHelper::REASON_ADOPTED_RECENTLY: $msg = wfMsgExt('wikiadoption-adopted-recently', array('parseinline')); break; default: $msg = wfMsgExt('wikiadoption-not-allowed', array('parseinline')); break; } $wgOut->addHTML($msg); } wfProfileOut(__METHOD__); }