Ejemplo n.º 1
0
 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);
     }
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = PcQuoteOfTheDayPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setQuote($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setQuoteInItalian($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setQuoteAuthor($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setQuoteAuthorInItalian($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setIsTip($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setShownOn($arr[$keys[6]]);
     }
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(PcQuoteOfTheDayPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(PcQuoteOfTheDayPeer::DATABASE_NAME);
         $criteria->add(PcQuoteOfTheDayPeer::ID, $pks, Criteria::IN);
         $objs = PcQuoteOfTheDayPeer::doSelect($criteria, $con);
     }
     return $objs;
 }