public function executeStartupData(sfWebRequest $request) { include_once sfConfig::get('sf_root_dir') . '/apps/api/lib/PlancakeApiServer.class.php'; $loggedInUser = PcUserPeer::getLoggedInUser(); $this->getUser()->setCulture($loggedInUser->getPreferredLanguage()); $userTodayQuote = null; if ($this->getUser()->getAttribute('user_first_login_of_the_day') === 1) { $userTodayQuote = PcQuoteOfTheDayPeer::getUserTodayQuote(); if ($userTodayQuote === null) { sfErrorNotifier::alert("THERE ARE NOT QUOTES LEFT!!!!!!"); } } $quoteContent = ''; $quoteAuthor = ''; if ($userTodayQuote) { $quoteContent = $userTodayQuote->getQuote(); $quoteContentInItalian = $userTodayQuote->getQuoteInItalian(); $quoteAuthor = $userTodayQuote->getQuoteAuthor(); $quoteAuthorInItalian = $userTodayQuote->getQuoteAuthorInItalian(); if ($loggedInUser->isItalian() && $quoteContentInItalian) { $quoteContent = $quoteContentInItalian; } if ($loggedInUser->isItalian() && $quoteAuthorInItalian) { $quoteAuthor = $quoteAuthorInItalian; } } $apiVersion = sfConfig::get('app_api_version'); $lists = PlancakeApiServer::getLists(array('api_ver' => $apiVersion, 'camel_case_keys' => 1)); $tags = PlancakeApiServer::getTags(array('api_ver' => $apiVersion, 'camel_case_keys' => 1)); $repetitionOptions = PlancakeApiServer::getRepetitionOptions(array('api_ver' => $apiVersion)); $userSettings = PlancakeApiServer::getUserSettings(array('api_ver' => $apiVersion, 'camel_case_keys' => 1)); $breakingNewsId = ''; $breakingNewsHeadline = ''; $breakingNewsLink = ''; if ($breakingNews = $loggedInUser->getBreakingNews()) { $breakingNewsId = $breakingNews->getId(); $breakingNewsHeadline = $breakingNews->getHeadline(); $breakingNewsLink = $breakingNews->getLink(); } $data = array('isPublicRelease' => (int) defined('PLANCAKE_PUBLIC_RELEASE'), 'isFirstDesktopLogin' => (int) $this->getUser()->getAttribute('user_still_to_load_desktop_app'), 'quoteAuthor' => $quoteAuthor, 'quoteContent' => $quoteContent, 'breakingNewsId' => $breakingNewsId, 'breakingNewsHeadline' => $breakingNewsHeadline, 'breakingNewsLink' => $breakingNewsLink, 'showExpiringSubscriptionAlert' => (int) $loggedInUser->isExpiringSubscriptionAlertToShow(), 'isSubscriptionExpired' => (int) $loggedInUser->isSubscriptionExpired()); $config = array('maxListsForFreeAccount' => sfConfig::get('app_site_maxListsForNonSupporter'), 'maxTagsForFreeAccount' => sfConfig::get('app_site_maxTagsForNonSupporter'), 'supportEmailAddress' => sfConfig::get('app_emailAddress_support'), 'custom' => $loggedInUser->getId() == 4 ? 1 : 0); // this 'custom' key is a temporal thing if (stripos($request->getUri(), '/mobile') === FALSE) { // the request doesn't come from the mobile app $this->getUser()->setAttribute('user_still_to_load_desktop_app', 0); } $lang = null; $strings = PcStringPeer::getWebAppStrings(); $i = 0; foreach ($strings as $string) { $lang[$string->getId()] = __($string->getId()); } $startupData = array('hideableHintsSetting' => $loggedInUser->getHideableHintsSetting(), 'lists' => $lists, 'tags' => $tags, 'repetitionOptions' => $repetitionOptions, 'userSettings' => $userSettings, 'data' => $data, 'config' => $config, 'lang' => $lang); if ($request->isXmlHttpRequest()) { return $this->renderJson($startupData); } }