コード例 #1
0
 public function __construct(Blueprint $blueprint, $timezone_offset = NULL)
 {
     // Set blueprint
     $this->_blueprint = $blueprint;
     /*
     // Init timezone offsets
     */
     if (!empty($timezone_offset)) {
         $this->_timezone_offset = $timezone_offset;
     } else {
         $this->_timezone_offset = BPTimezone::getOffset();
     }
     // Init query
     $this->init();
 }
コード例 #2
0
 public static function getOffset()
 {
     $tag = "BPTimezone::getOffset()";
     $session_timezone = Session::user("_TIMEZONE");
     // Overrides Session::user("_TIMEZONE_OFFSET")
     $session_timezone_offset = Session::user("_TIMEZONE_OFFSET");
     $config_timezone = isset(BPConfig::$timezone) ? BPConfig::$timezone : "";
     // Overrides $timezone_offset
     $config_timezone_offset = isset(BPConfig::$timezone_offset) ? BPConfig::$timezone_offset : 0;
     $default_timezone = date_default_timezone_get();
     if (!empty($session_timezone)) {
         $offset = BPTimezone::getOffsetForTimezone($session_timezone);
         Log::debug("{$tag}: Returning offset from Session::user(_TIMEZONE): {$offset}");
         return $offset;
     } else {
         if (!empty($session_timezone_offset)) {
             Log::debug("{$tag}: Returning offset from Session::user(_TIMEZONE_OFFSET) {$session_timezone_offset}");
             return $session_timezone_offset;
         } else {
             if (!empty($config_timezone)) {
                 $offset = BPTimezone::getOffsetForTimezone($config_timezone);
                 Log::debug("{$tag}: Returning offset from BPConfig::timezone: {$offset}");
                 return $offset;
             } else {
                 if (!empty($config_timezone_offset)) {
                     Log::debug("{$tag}: Returning offset from BPConfig::timezone_offset {$config_timezone_offset}");
                     return $config_timezone_offset;
                 } else {
                     if (!empty($default_timezone)) {
                         $offset = BPTimezone::getOffsetForTimezone($default_timezone);
                         Log::debug("{$tag}: Returning offset from default timezone: {$offset}");
                         return $offset;
                     } else {
                         Log::debug("{$tag}: Returning offset for UTC:" . BPTimezone::UTC);
                         return BPTimezone::UTC;
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
 public static function get($blueprintSignature, $id, $field, $timezone_offset = NULL)
 {
     $tag = "EntityDAO: get()";
     Log::debug("{$tag}: <blueprintSignature={$blueprintSignature}, id={$id}, field={$field}, timezone_offset={$timezone_offset}>");
     // Init timezone offsets
     if (empty($timezone_offset)) {
         $timezone_offset = BPTimezone::getOffset();
     }
     try {
         $blueprint = BlueprintReader::read($blueprintSignature);
         $dao = new EntityDAO($blueprint, $timezone_offset);
         if ($entity = $dao->load($id)) {
             $value = $entity->get($field);
             Log::debug("{$tag}: {$field} = {$value}");
             return $value;
         } else {
             // entity with "id" not found
             Log::warning("{$tag}: {$blueprintSignature} with id {$id} not found.");
             return false;
         }
     } catch (Exception $e) {
         Log::error("{$tag}: Caught: " . $e->getMessage());
         throw $e;
     }
 }