Ejemplo n.º 1
0
 public function save(PropelPDO $con = null)
 {
     $signature = PcUpdatePeer::generateSignature();
     if (!$this->getSignature()) {
         $this->setSignature($signature);
     }
     return parent::save($con);
 }
Ejemplo n.º 2
0
 /**
  * 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());
     }
 }
Ejemplo n.º 3
0
 /**
  * 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(PcUpdatePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(PcUpdatePeer::DATABASE_NAME);
         $criteria->add(PcUpdatePeer::ID, $pks, Criteria::IN);
         $objs = PcUpdatePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Ejemplo n.º 4
0
 /**
  * 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 = PcUpdatePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setSignature($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDescription($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setUrl($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCreatedAt($arr[$keys[4]]);
     }
 }