/**
  * Adds inform messages to response for inclusion in pages dynamically. 
  *
  * @since 2.0.18
  * @access public
  */
 public function Inform()
 {
     $this->DeliveryType(DELIVERY_TYPE_BOOL);
     $this->DeliveryMethod(DELIVERY_METHOD_JSON);
     // Retrieve all notifications and inform them.
     NotificationsController::InformNotifications($this);
     $this->Render();
 }
 /**
  * Adds inform messages to response for inclusion in pages dynamically.
  *
  * @since 2.0.18
  * @access public
  */
 public function inform()
 {
     $this->deliveryType(DELIVERY_TYPE_BOOL);
     $this->deliveryMethod(DELIVERY_METHOD_JSON);
     // Retrieve all notifications and inform them.
     NotificationsController::informNotifications($this);
     $this->fireEvent('BeforeInformNotifications');
     $this->render();
 }
Ejemplo n.º 3
0
function efConfirmEmailPrompt(&$msg)
{
    global $wgUser;
    if (!F::app()->checkSkin('oasis')) {
        return true;
    }
    if ($wgUser->isEmailConfirmed()) {
        return true;
    }
    if ($wgUser->getEmail() == '') {
        return true;
    }
    $message = wfMsgExt('confirmemailprompt-error', array('parseinline'), array($wgUser->getEmail(), SpecialPage::getTitleFor('ConfirmEmail')->getPrefixedText(), SpecialPage::getTitleFor('Preferences')->getPrefixedText()));
    NotificationsController::addConfirmation($message, NotificationsController::CONFIRMATION_ERROR);
    return true;
}
Ejemplo n.º 4
0
 /**
  * Notifies the current user when one of his questions have been answered.
  *
  * @param NotificationsController $sender Sending controller instance.
  * @param array $args Event arguments.
  */
 public function notificationsController_beforeInformNotifications_handler($sender, $args)
 {
     $Path = trim($sender->Request->getValue('Path'), '/');
     if (preg_match('`^(vanilla/)?discussion[^s]`i', $Path)) {
         return;
     }
     // Check to see if the user has answered questions.
     $Count = Gdn::SQL()->getCount('Discussion', array('Type' => 'Question', 'InsertUserID' => Gdn::session()->UserID, 'QnA' => 'Answered'));
     if ($Count > 0) {
         $sender->informMessage(formatString(t("You've asked questions that have now been answered", "<a href=\"{/discussions/mine?qna=Answered,url}\">You've asked questions that now have answers</a>. Make sure you accept/reject the answers.")), 'Dismissable');
     }
 }
	/**
	 * Remove all notifications queued for display
	 */
	public static function clearNotifications() {
		self::$notificationsStack = array();
	}
	/**
	 * hook function  - save Facebook profile data
	 *
	 * @param string $article the article
	 * @param string $outputDone the output is done
	 * @param string $userParserCache enable or disable cache
	 * @return bool need to return true
	 *
	 */
	public static function saveFacebookConnectProfile($article, $outputDone, $userParserCache ) { //$fbContent
		global $wgArticle, $wgTitle, $wgOut, $wgRequest;

		if ($wgRequest->getVal( 'fbrequest' ) != 'save') {
			return true;
		}

		$fbContent = F::app()->renderView('UserPagesHeader', 'FacebookConnectArticle');

		if ($fbContent) {
			// getting users page url, not the clean way?
			$userURL = self::getUserURL();

			$articleTitle = Title::newFromText($userURL);
			$wgArticle = new Article($articleTitle);
			$userProfileContent = $wgArticle->getContent(); // reading content

			// remove already existing sync
			$regex = '#<table class="fbconnect-synced-profile[^>]+>[\w\W]*?</table>#i';
			$userProfileContent = preg_replace($regex, '', $userProfileContent);

			$newUserProfileContent = $fbContent .$userProfileContent;

			// save updated profile
			$summary = "Synced profile with Facebook.";
			NotificationsController::addConfirmation(wfMsg('fb-sync-success-message'));

			$wgArticle->doEdit($newUserProfileContent, $summary,
					( 0 ) |
					( 0 ) |
					( 0 ) |
					( 0 ) );

			$wgOut->redirect($wgTitle->getFullUrl());
		}

		return true;
	}
Ejemplo n.º 7
0
 public function execute($subpage)
 {
     wfProfileIn(__METHOD__);
     $this->games = WF::build('ScavengerHuntGames');
     $this->setHeaders();
     $this->mTitle = SpecialPage::getTitleFor('scavengerhunt');
     if ($this->isRestricted() && !$this->userCanExecute($this->user)) {
         $this->displayRestrictionError();
         return;
     }
     @(list($action, $id) = explode('/', $subpage));
     $action = !empty($action) ? $action : 'list';
     $id = (int) $id;
     $game = $this->games->findById($id);
     if (empty($game)) {
         $game = $this->games->newGame();
     }
     // check edit tokens
     if ($this->request->wasPosted() && !$this->user->matchEditToken($this->request->getVal('wpEditToken'))) {
         NotificationsController::addConfirmation(wfMsg('scavengerhunt-edit-token-mismatch'), NotificationsController::CONFIRMATION_ERROR);
         $this->out->redirect($this->mTitle->getFullUrl());
         return;
     }
     $this->out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/ScavengerHunt/css/scavenger-special.scss'));
     $this->out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/ScavengerHunt/css/scavenger-game.scss'));
     $this->out->addScriptFile($this->app->getGlobal('wgExtensionsPath') . '/wikia/ScavengerHunt/js/scavenger-special.js');
     $template = WF::build('EasyTemplate', array(dirname(__FILE__) . '/templates/'));
     $errors = array();
     switch ($action) {
         case 'list':
             $button = '<a class="wikia-button scavengerhunt-add-button" href="' . $this->mTitle->getFullUrl() . '/add">' . XML::element('img', array('class' => 'sprite new', 'src' => $this->app->getGlobal('wgBlankImgUrl'))) . wfMsg('scavengerhunt-button-add') . '</a>';
             $this->out->mPagetitle .= $button;
             $this->out->mPageLinkTitle = true;
             // Games list
             $pager = WF::build('ScavengerHuntGamesPager', array($this->games, $this->mTitle->getFullUrl(), $template));
             $this->out->addHTML($pager->getBody() . $pager->getNavigationBar());
             break;
         case 'toggle':
             $enable = !$game->isEnabled();
             $game->setEnabled($enable);
             $errors = $this->validateGame($game);
             if (empty($errors['errors'])) {
                 $game->save();
                 NotificationsController::addConfirmation($enable ? wfMsg('scavengerhunt-game-has-been-enabled') : wfMsg('scavengerhunt-game-has-been-disabled'));
                 //success! go to the list
                 $this->out->redirect($this->mTitle->getFullUrl());
                 return;
             } else {
                 //failure - display errors
                 $game->setEnabled(false);
             }
             // no "break" on purpose - wasPosted() will return false but we'll display proper template
         // no "break" on purpose - wasPosted() will return false but we'll display proper template
         case 'edit':
             if ($this->request->wasPosted()) {
                 if ($this->request->getVal('enable')) {
                     $enabled = !$this->request->getVal('prevEnabled');
                     $game->setEnabled($enabled);
                     $errors = $this->validateGame($game);
                     if (empty($errors['errors'])) {
                         $game->save();
                         NotificationsController::addConfirmation($enabled ? wfMsg('scavengerhunt-game-has-been-enabled') : wfMsg('scavengerhunt-game-has-been-disabled'));
                         $this->out->redirect($this->mTitle->getFullUrl() . "/edit/{$id}");
                         return;
                     } else {
                         $game->setEnabled(false);
                     }
                 } else {
                     if ($this->request->getVal('delete')) {
                         $game->delete();
                         NotificationsController::addConfirmation(wfMsg('scavengerhunt-game-has-been-deleted'));
                         $this->out->redirect($this->mTitle->getFullUrl());
                         return;
                     }
                 }
             }
             // no "break" on purpose
         // no "break" on purpose
         case 'add':
             if ($this->request->wasPosted()) {
                 if ($this->request->getVal('save')) {
                     $game = $this->updatePostedGame($game);
                     // move the validation process to the moment of enabling the game
                     $errors = $this->validateGame($game);
                     // save changes
                     if (empty($errors['errors']) && $game->save()) {
                         NotificationsController::addConfirmation($action == 'add' ? wfMsg('scavengerhunt-game-has-been-created') : wfMsg('scavengerhunt-game-has-been-saved'));
                         $this->out->redirect($this->mTitle->getFullUrl());
                         return;
                     } else {
                         NotificationsController::addConfirmation(wfMsg('scavengerhunt-game-has-not-been-saved'), NotificationsController::CONFIRMATION_NOTIFY);
                     }
                 }
             }
             $template->set('errors', isset($errors['errors']) ? $errors['errors'] : array());
             $template->set('highlight', isset($errors['highlight']) ? $errors['highlight'] : array());
             $template->set('editToken', $this->user->getEditToken());
             $template->set_vars($this->getTemplateVarsFromGame($game));
             $this->out->addHTML($template->render('form'));
             break;
     }
     wfProfileOut(__METHOD__);
 }
 /**
  * Hook handler
  * Display notification
  *
  * @author Maciej Błaszkowski <marooned at wikia-inc.com>
  */
 static function onSkinTemplateOutputPageBeforeExec(&$skin, &$tpl)
 {
     global $wgUser, $wgCityId, $wgScript, $wgSitename;
     wfProfileIn(__METHOD__);
     if (F::app()->checkSkin('oasis') && self::isAllowedToAdopt($wgCityId, $wgUser) == self::USER_ALLOWED && !self::getDismissNotificationState($wgUser)) {
         NotificationsController::addNotification(wfMsg('wikiadoption-notification', $wgSitename, Wikia::SpecialPageLink('WikiAdoption', 'wikiadoption-adopt-inquiry')), array('name' => 'AutomaticWikiAdoption', 'dismissUrl' => $wgScript . '?action=ajax&rs=AutomaticWikiAdoptionAjax&method=dismiss'), NotificationsController::NOTIFICATION_CUSTOM);
     }
     wfProfileOut(__METHOD__);
     return true;
 }