/**
  * Ajax method for un/deleting a map from IntMaps API
  */
 public function updateMapDeletionStatus()
 {
     $mapId = $this->request->getInt('mapId');
     $deleted = $this->request->getInt('deleted');
     if (!in_array($deleted, [WikiaMaps::MAP_DELETED, WikiaMaps::MAP_NOT_DELETED])) {
         $deleted = WikiaMaps::MAP_DELETED;
     }
     $result = false;
     if (!$this->isUserAllowed() || !$this->canUserDelete() && !$this->isUserMapCreator($mapId)) {
         throw new WikiaMapsPermissionException();
     }
     if ($mapId) {
         $result = $this->getModel()->updateMapDeletionStatus($mapId, $deleted)['success'];
     }
     if ($result) {
         $action = $deleted === WikiaMaps::MAP_DELETED ? WikiaMapsLogger::ACTION_DELETE_MAP : WikiaMapsLogger::ACTION_UNDELETE_MAP;
         WikiaMapsLogger::addLogEntry($action, $this->wg->User, $mapId, $mapId);
         BannerNotificationsController::addConfirmation($deleted ? wfMessage('wikia-interactive-maps-delete-map-success')->text() : wfMessage('wikia-interactive-maps-undelete-map-success')->text());
         $redirectUrl = WikiaMapsSpecialController::getSpecialUrl();
         if ($deleted === WikiaMaps::MAP_NOT_DELETED) {
             $redirectUrl .= '/' . $mapId;
         }
         $this->response->setVal('redirectUrl', $redirectUrl);
     }
 }
 /**
  * @param PHPUnit_Framework_MockObject_MockObject|WikiaMapsSpecialController $wikiaMapsSpecialControllerMock
  * @param mixed $val Value to be returned by getRequest()->getVal() method
  */
 private function setValToBeReturned($wikiaMapsSpecialControllerMock, $val)
 {
     $requestMock = $this->getMock('WikiaRequest', ['getVal'], [], '', false);
     $requestMock->expects($this->any())->method('getVal')->will($this->returnValue($val));
     $wikiaMapsSpecialControllerMock->expects($this->any())->method('getRequest')->will($this->returnValue($requestMock));
 }
 /**
  * @desc Renders Wikia Maps placeholder
  *
  * @return null|string
  */
 public function mapThumbnail()
 {
     $params = $this->getMapPlaceholderParams();
     $userName = $params->map->created_by;
     $isMobile = $this->app->checkskin('wikiamobile');
     if ($isMobile) {
         //proper image is lazy loaded from the thumbnailer
         $params->map->imagePlaceholder = $this->wg->BlankImgUrl;
         $params->map->mobile = true;
         $params->map->href = WikiaMapsSpecialController::getSpecialUrl() . '/' . $params->map->id;
     } else {
         $params->map->image = $this->mapsModel->createCroppedThumb($params->map->image, self::DEFAULT_WIDTH, self::DEFAULT_HEIGHT);
     }
     $renderParams = $this->mapsModel->getMapRenderParams($params->map->city_id);
     $params->map->url = $this->mapsModel->getMapRenderUrl([$params->map->id, $params->zoom, $params->lat, $params->lon], $renderParams);
     $this->setVal('map', (object) $params->map);
     $this->setVal('params', $params);
     $this->setVal('created_by', wfMessage('wikia-interactive-maps-parser-tag-created-by', $userName)->text());
     $this->setVal('avatarUrl', AvatarService::getAvatarUrl($userName, AvatarService::AVATAR_SIZE_SMALL));
     $this->setVal('view', wfMessage('wikia-interactive-maps-parser-tag-view')->plain());
     $this->response->setTemplateEngine(WikiaResponse::TEMPLATE_ENGINE_MUSTACHE);
     if ($isMobile) {
         $this->overrideTemplate('mapThumbnail_mobile');
     }
 }