* * * $Id: AccountManagerModule.class.php 267 2008-10-07 19:17:26Z erikwinn $ *@version 0.1 * *@copyright (C) 2008 by Erik Winn *@license GPL v.2 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA * *@package Quasi * @subpackage Modules */ class AccountManagerModule extends QPanel { /** *@var Account objAccount - local reference to the Account object */ private $objAccount; /** * @var Module objModule - local reference or instance of the module ORM object */ protected $objModule; /** * @var ContentBlockView objContentBlock - the content block to which this module is assigned */ protected $objContentBlock; /** * Module constructor *@param ContentBlockView - objContentBlock parent controller object. *@param object objModule - the module displayed */ public function __construct( ContentBlockView $objContentBlock, $objModule) { //Parent should always be a ContentBlockView $this->objContentBlock =& $objContentBlock; $this->objModule =& $objModule; try { parent::__construct($this->objContentBlock); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->AutoRenderChildren = true; // $this->strTemplate = __QUASI_CORE_TEMPLATES__ . '/AccountManagerModule.tpl.php'; //Make sure we have logged in, otherwise we don't display anything .. $this->objAccount =& IndexPage::$objAccount; if($this->objAccount instanceof Account) $this->loadModule(); else $this->Text = Quasi::Translate('We are sorry - you must be logged in to access your account settings.'); } /** * This is the main action for the manager, it parses the URL string and loads the * appropriate module. The URL must name the module class. */ private function loadModule() { $aryParameters = explode('/', IndexPage::$strPageParameters); $strModuleName = array_shift($aryParameters); if(empty($strModuleName)) $strModuleName = 'Address'; $strClassName = 'Account' . $strModuleName . 'Module'; if(class_exists($strClassName) ) new $strClassName($this, $aryParameters); else new AccountAddressModule($this, $aryParameters); } /** * Unused. */ public function Validate() { $blnToReturn = true; // validate input here return $blnToReturn; } public function __get($strName) { switch ($strName) { case 'Account': return $this->objAccount ; case 'ClassName': return $this->objModule->ClassName ; case 'Module': return $this->objModule ; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } } public function __set($strName, $mixValue) { switch ($strName) { case 'Account': try { return ($this->objAccount = QType::Cast($mixValue, 'Account' )); } catch (QInvalidCastException $objExc) { $objExc->IncrementOffset(); throw $objExc; } default: try { return (parent::__set($strName, $mixValue)); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } } }//end class }//end define ?>