/**
  * Sets the timezone
  *
  * @param PcUser $user
  */
 private static function setTimezone(PcUser $user)
 {
     $forumTablesPrefix = sfConfig::get('app_forum_tablePrefix');
     $connection = Propel::getConnection();
     $userId = $user->getForumId();
     $timezone = PcTimezonePeer::retrieveByPk($user->getTimezoneId());
     $timezone = $timezone->getOffset() / 60;
     // in the forum the timezone is in hours, not in minutes
     $query = sprintf("UPDATE " . $forumTablesPrefix . "users SET timezone=:timezone WHERE id=%d", (int) $userId);
     $statement = $connection->prepare($query);
     $statement->execute(array('timezone' => $timezone));
 }
Exemple #2
0
 /**
  * Returns the real offset in seconds between and GMT and user settings, 
  * considering both the timezone and dst of the user
  *
  * @return integer
  */
 public function getRealOffsetFromGMT()
 {
     $timezone = PcTimezonePeer::retrieveByPk($this->getTimezoneId());
     $ret = 0;
     if ($timezone) {
         $timezoneOffsetFromGMT = $timezone->getOffset();
         // in minutes
         $dstOffsetFromGMT = $this->getDstActive() * 60;
         // in minutes // if dst is active, the clock is 1 hour forward
         $ret = $timezoneOffsetFromGMT * 60 + $dstOffsetFromGMT * 60;
     }
     return $ret;
 }
 /**
  * Get the associated PcTimezone object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     PcTimezone The associated PcTimezone object.
  * @throws     PropelException
  */
 public function getPcTimezone(PropelPDO $con = null)
 {
     if ($this->aPcTimezone === null && $this->timezone_id !== null) {
         $this->aPcTimezone = PcTimezonePeer::retrieveByPk($this->timezone_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aPcTimezone->addPcUsers($this);
         		 */
     }
     return $this->aPcTimezone;
 }