/**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $user = PcUserPeer::getLoggedInUser();
     $this->getUser()->setCulture($user->getPreferredLanguage());
     // {{{ START: is this the first login?
     // We need to do this before calling refreshLastLogin()
     if ($user->getLastLogin('U') < mktime(0, 0, 0)) {
         $this->getUser()->setAttribute('user_first_login_of_the_day', 1);
     } else {
         $this->getUser()->setAttribute('user_first_login_of_the_day', 0);
     }
     // }}} END: is this the first login?
     $user->refreshLastLogin()->save();
     if (!$user->getHasDesktopAppBeenLoaded()) {
         $this->getUser()->setAttribute('user_still_to_load_desktop_app', 1);
     }
     // the action we are in is not called by the mobile app, but must by the desktop app
     $user->setHasDesktopAppBeenLoaded(true)->save();
     $this->updateAvailable = false;
     // check whether one day has passed from the last check
     $lastCheckForUpdates = PcUtils::getValue('last_check_for_updates', time());
     if (time() - $lastCheckForUpdates > 86400) {
         // time to do a new check
         //
         // we access the version file directly (and not the config value) to avoid cache
         $urlFriendlySiteVersion = str_replace('.', '-', file_get_contents(sfConfig::get('sf_root_dir') . '/version'));
         $updatesUrl = sfConfig::get('app_site_urlForUpdates') . '/' . $urlFriendlySiteVersion;
         // $updatesUrl may be something like this: http://updates.plancake.com/updates/1.8.6
         $updates = PcUtils::getFileContentOverInternet($updatesUrl, true);
         // $updates may be something like this:
         // 1--|--ffb524e371203966974750bf5c3a9a77--|--Reminder: Plancake will be down for maintenance in a few hours--|--http://tinyurl.com/34vwsq5
         $updatesParts = explode(sfConfig::get('app_site_updatesStringDivider'), $updates);
         $newReleaseAvailable = isset($updatesParts[0]) ? $updatesParts[0] : '';
         $lastUpdateSignature = isset($updatesParts[1]) ? $updatesParts[1] : '';
         $lastUpdateDescription = isset($updatesParts[2]) ? $updatesParts[2] : '';
         $lastUpdateLink = isset($updatesParts[3]) ? $updatesParts[3] : '';
         // we use this also in the hosted version (even if it is meant for installations)
         // to spot problems easily
         $this->updateAvailable = (bool) $newReleaseAvailable;
         if (defined('PLANCAKE_PUBLIC_RELEASE')) {
             // check whether the update is already in the system
             if (!is_object(PcUpdatePeer::retrieveBySignature($lastUpdateSignature))) {
                 $update = new PcUpdate();
                 $update->setUrl($lastUpdateLink)->setDescription($lastUpdateDescription)->setSignature($lastUpdateSignature)->setCreatedAt(time())->save();
                 PcUtils::broadcastUpdate($lastUpdateDescription, $lastUpdateLink);
             }
         }
         PcUtils::setValue('last_check_for_updates', time());
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      PcUpdate $value A PcUpdate object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(PcUpdate $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }