From: <al...@us...> - 2008-09-02 20:56:52
|
Revision: 665 http://sciret.svn.sourceforge.net/sciret/?rev=665&view=rev Author: alpeb Date: 2008-09-02 20:56:40 +0000 (Tue, 02 Sep 2008) Log Message: ----------- some workarounds to be able to instantiate an anonoymous user obj without having a connection to the db (bypassing the Users gateway class). Used during install Modified Paths: -------------- trunk/index.php trunk/models/User.php trunk/models/Users.php Modified: trunk/index.php =================================================================== --- trunk/index.php 2008-09-02 20:55:01 UTC (rev 664) +++ trunk/index.php 2008-09-02 20:56:40 UTC (rev 665) @@ -95,8 +95,8 @@ Zend_Session::start(); $auth = Zend_Auth::getInstance(); -$users = new Users(); if ($auth->hasIdentity()) { + $users = new Users(); $user = $auth->getStorage()->read(); $user->init(); if ($user->app == 'monkeys') { @@ -110,7 +110,7 @@ $user->setTable($users); } else { // guest user - $user = $users->createRow(); + $user = new User(); } Zend_Registry::set('user', $user); Modified: trunk/models/User.php =================================================================== --- trunk/models/User.php 2008-09-02 20:55:01 UTC (rev 664) +++ trunk/models/User.php 2008-09-02 20:56:40 UTC (rev 665) @@ -21,6 +21,30 @@ public $app = 'sciret'; public $publicId; + /** + * These are here to be able to have default values when instantiating + * an anonymous User object without having a connection to the DB + * (during install) + */ + public $id = 0; + public $admin = 0; + public $password_changed = '0000-00-00'; + public $startBrowsing = 'all'; + public $articlesPerPage = 10; + public $dateFormat = 'Month Day, Year'; + public $language = ''; + public $navigationType = 'catAndSubCats'; + public $hiddenCategories = ''; + public $preferences; + private $_defaultPreferences = array( + 'startBrowsing' => 'all', + 'articlesPerPage' => 10, + 'dateFormat' => 'Month Day, Year', + 'language' => '', // set in the constructor + 'navigationType' => 'catAndSubCats', + 'hiddenCategories' => '', + ); + var $langArr; var $skipTranslations = false; var $rtlLanguages = array('Hebrew'); @@ -29,6 +53,12 @@ private $_preferencesArr; + public function __construct($config = array()) + { + $this->preferences = serialize($this->_defaultPreferences); + parent::__construct($config); + } + public function init() { if ($this->id) { Modified: trunk/models/Users.php =================================================================== --- trunk/models/Users.php 2008-09-02 20:55:01 UTC (rev 664) +++ trunk/models/Users.php 2008-09-02 20:56:40 UTC (rev 665) @@ -8,19 +8,14 @@ public function createRow() { - $preferences = array( - 'startBrowsing' => 'all', - 'articlesPerPage' => 10, - 'dateFormat' => 'Month Day, Year', - 'language' => '', // set in the constructor - 'navigationType' => 'catAndSubCats', - 'hiddenCategories' => '', - ); - + /** + * we instantiate an anonymous user obj just to get the default field values + */ + $user = new User(); return parent::createRow(array( - 'password_changed' => '0000-00-00', - 'admin' => 0, - 'preferences' => serialize($preferences), + 'password_changed' => $user->password_changed, + 'admin' => $user->admin, + 'preferences' => $user->preferences, )); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |