- Timestamp:
- Nov 30, 2020 2:27:06 AM (3 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r739 r740 1879 1879 } 1880 1880 1881 // Create a DateTime object and conver the timezone from server to user. 1882 $dt = $this->convertTZ($datetime, $this->getParam('php_timezone'), $this->getParam('user_timezone')); 1881 try { 1882 // Create a DateTime object and conver the timezone from server to user. 1883 $dt = $this->convertTZ($datetime, $this->getParam('php_timezone'), $this->getParam('user_timezone')); 1884 } catch (Exception $e) { 1885 $this->logMsg(sprintf('DateTime failed to parse string in %s: %s', __METHOD__, $datetime), LOG_NOTICE, __FILE__, __LINE__); 1886 return ''; 1887 } 1883 1888 1884 1889 // By default, we try to use a localized date format. Set lc_date_format to null to use regular date_format instead. … … 1906 1911 function dateToServerTZ($datetime, $format='Y-m-d H:i:s') 1907 1912 { 1908 return $this->convertTZ($datetime, $this->getParam('user_timezone'), $this->getParam('php_timezone'))->format($format); 1913 try { 1914 // Create a DateTime object and conver the timezone from server to user. 1915 $dt = $this->convertTZ($datetime, $this->getParam('user_timezone'), $this->getParam('php_timezone')); 1916 } catch (Exception $e) { 1917 $this->logMsg(sprintf('DateTime failed to parse string in %s: %s', __METHOD__, $datetime), LOG_NOTICE, __FILE__, __LINE__); 1918 return ''; 1919 } 1920 1921 return $dt->format($format); 1909 1922 } 1910 1923 -
trunk/lib/Prefs.inc.php
r719 r740 332 332 if (!(isset($_SESSION['_prefs'][$this->_ns]['defaults']) && array_key_exists($key, $_SESSION['_prefs'][$this->_ns]['defaults'])) 333 333 || $_SESSION['_prefs'][$this->_ns]['defaults'][$key] != $val 334 || (isset($_SESSION['_prefs'][$this->_ns]['saved']) && array_key_exists($key, $_SESSION['_prefs'][$this->_ns]['saved']))) {334 || $this->exists($key)) { 335 335 $_SESSION['_prefs'][$this->_ns]['saved'][$key] = $val; 336 336 $app->logMsg(sprintf('Setting session/database preference %s => %s', $key, getDump($val, true)), LOG_DEBUG, __FILE__, __LINE__); … … 355 355 * a default value is returned, or if not that, null. 356 356 * 357 * @param string $key The name of the preference to retrieve. 358 * 357 * @param string $key The name of the preference to retrieve (or null to retrieve all keys). 359 358 * @return string The value of the preference. 360 359 */ 361 public function get($key )360 public function get($key=null) 362 361 { 363 362 $app =& App::getInstance(); … … 368 367 case 'session': 369 368 case 'database': 370 if (isset($_SESSION['_prefs'][$this->_ns]['saved']) && array_key_exists($key, $_SESSION['_prefs'][$this->_ns]['saved'])) { 369 if (is_null($key) && isset($_SESSION['_prefs'][$this->_ns]['saved'])) { 370 return $_SESSION['_prefs'][$this->_ns]['saved']; 371 } 372 if ($this->exists($key)) { 371 373 $app->logMsg(sprintf('Found %s in saved', $key), LOG_DEBUG, __FILE__, __LINE__); 372 374 return $_SESSION['_prefs'][$this->_ns]['saved'][$key]; 373 } else if (isset($_SESSION['_prefs'][$this->_ns]['defaults']) && array_key_exists($key, $_SESSION['_prefs'][$this->_ns]['defaults'])) { 375 } 376 if (isset($_SESSION['_prefs'][$this->_ns]['defaults']) && array_key_exists($key, $_SESSION['_prefs'][$this->_ns]['defaults'])) { 374 377 $app->logMsg(sprintf('Found %s in defaults', $key), LOG_DEBUG, __FILE__, __LINE__); 375 378 return $_SESSION['_prefs'][$this->_ns]['defaults'][$key]; 376 } else { 377 $app->logMsg(sprintf('Key not found in prefs cache: %s', $key), LOG_DEBUG, __FILE__, __LINE__); 378 } 379 } 380 $app->logMsg(sprintf('Key not found in prefs cache: %s', $key), LOG_DEBUG, __FILE__, __LINE__); 379 381 return null; 380 382 381 383 case 'cookie': 384 if (is_null($key)) { 385 $app->logMsg(sprintf('Unable to get(null) when using cookie storagetype.', null), LOG_WARNING, __FILE__, __LINE__); 386 return null; 387 } 382 388 $name = $this->_getCookieName($key); 383 389 if ($this->exists($key) && '' != $_COOKIE[$name]) { … … 385 391 $app->logMsg(sprintf('Found %s in cookie: %s', $key, getDump($val)), LOG_DEBUG, __FILE__, __LINE__); 386 392 return $val; 387 } else { 388 $app->logMsg(sprintf('Did not find %s in cookie', $key), LOG_DEBUG, __FILE__, __LINE__); 389 } 393 } 394 $app->logMsg(sprintf('Did not find %s in cookie', $key), LOG_DEBUG, __FILE__, __LINE__); 390 395 return null; 391 396 } … … 405 410 case 'session': 406 411 case 'database': 412 // isset() does not return TRUE for array keys that correspond to a NULL value, while array_key_exists() does. 407 413 return (isset($_SESSION['_prefs'][$this->_ns]['saved']) && array_key_exists($key, $_SESSION['_prefs'][$this->_ns]['saved'])); 408 414
Note: See TracChangeset
for help on using the changeset viewer.