A Qcodo based CMS/ecommerce framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
6.7 KiB

12 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. if (!defined("ACCOUNTMANAGERMODULE.CLASS.PHP")){
  4. define("ACCOUNTMANAGERMODULE.CLASS.PHP",1);
  5. /**
  6. * Class AccountManagerModule - A managing module for submodules that provide user
  7. * management account functions
  8. *
  9. * This module provides the center or main panel for a Member's home
  10. * page, to which they are directed immediately after login or registration.
  11. * It should be assigned to a content block which is assigned only to
  12. * the Account home page. It performs one basic function: load the requested
  13. * account module according to the Request URL string page parameters.
  14. *
  15. * The Account page has a module that parses the PageParameters to determine which Account module
  16. * to load. Eg. for Addresses/ it will acivate the AccountAddressesModule. This module in turn contains
  17. * an instance of AccountAddressEditPanel and AccountAddressListPanel which it will manage. For a
  18. * parameter like Addresses/2 it will go directly to the edit panel for that address but signalling the sub
  19. * module. By default, the sub modules will show a list page if given no parameters. Each sub-module is
  20. * a Page request, the actions within each of these are ajax calls.
  21. *
  22. * The default Account modules managed by the AccountManagerModule are:
  23. * - AccountAddressModule : addresses viewing and management
  24. * - AccountOrderModule : orders viewing and management
  25. * - AccountSettingsModule: General account settings, includes the following two modules
  26. * - AccountInfoModule : to change email address, avatar or personal name.
  27. * - AccountPasswordModule : change password and username
  28. *
  29. *@todo
  30. * - AccountProfileModule : public profile information
  31. *
  32. *
  33. * NOTE: The Account modules managed by this class do not need to be entered in the
  34. * modules table in the database - instead, they are loaded dynamically using the autoloader
  35. * according to the request page parameters in the URL
  36. *
  37. *@author Erik Winn <erikwinnmail@yahoo.com>
  38. *
  39. *
  40. * $Id: AccountManagerModule.class.php 267 2008-10-07 19:17:26Z erikwinn $
  41. *@version 0.1
  42. *
  43. *@copyright (C) 2008 by Erik Winn
  44. *@license GPL v.2
  45. This program is free software; you can redistribute it and/or modify
  46. it under the terms of the GNU General Public License as published by
  47. the Free Software Foundation; either version 2 of the License, or
  48. (at your option) any later version.
  49. This program is distributed in the hope that it will be useful,
  50. but WITHOUT ANY WARRANTY; without even the implied warranty of
  51. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  52. GNU General Public License for more details.
  53. You should have received a copy of the GNU General Public License
  54. along with this program; if not, write to the Free Software
  55. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  56. *
  57. *@package Quasi
  58. * @subpackage Modules
  59. */
  60. class AccountManagerModule extends QPanel
  61. {
  62. /**
  63. *@var Account objAccount - local reference to the Account object
  64. */
  65. private $objAccount;
  66. /**
  67. * @var Module objModule - local reference or instance of the module ORM object
  68. */
  69. protected $objModule;
  70. /**
  71. * @var ContentBlockView objContentBlock - the content block to which this module is assigned
  72. */
  73. protected $objContentBlock;
  74. /**
  75. * Module constructor
  76. *@param ContentBlockView - objContentBlock parent controller object.
  77. *@param object objModule - the module displayed
  78. */
  79. public function __construct( ContentBlockView $objContentBlock, $objModule)
  80. {
  81. //Parent should always be a ContentBlockView
  82. $this->objContentBlock =& $objContentBlock;
  83. $this->objModule =& $objModule;
  84. try {
  85. parent::__construct($this->objContentBlock);
  86. } catch (QCallerException $objExc) {
  87. $objExc->IncrementOffset();
  88. throw $objExc;
  89. }
  90. $this->AutoRenderChildren = true;
  91. // $this->strTemplate = __QUASI_CORE_TEMPLATES__ . '/AccountManagerModule.tpl.php';
  92. //Make sure we have logged in, otherwise we don't display anything ..
  93. $this->objAccount =& IndexPage::$objAccount;
  94. if($this->objAccount instanceof Account)
  95. $this->loadModule();
  96. else
  97. $this->Text = Quasi::Translate('We are sorry - you must be logged in to access your account settings.');
  98. }
  99. /**
  100. * This is the main action for the manager, it parses the URL string and loads the
  101. * appropriate module. The URL must name the module class.
  102. */
  103. private function loadModule()
  104. {
  105. $aryParameters = explode('/', IndexPage::$strPageParameters);
  106. $strModuleName = array_shift($aryParameters);
  107. if(empty($strModuleName))
  108. $strModuleName = 'Address';
  109. $strClassName = 'Account' . $strModuleName . 'Module';
  110. if(class_exists($strClassName) )
  111. new $strClassName($this, $aryParameters);
  112. else
  113. new AccountAddressModule($this, $aryParameters);
  114. }
  115. /**
  116. * Unused.
  117. */
  118. public function Validate()
  119. {
  120. $blnToReturn = true;
  121. // validate input here
  122. return $blnToReturn;
  123. }
  124. public function __get($strName)
  125. {
  126. switch ($strName)
  127. {
  128. case 'Account':
  129. return $this->objAccount ;
  130. case 'ClassName':
  131. return $this->objModule->ClassName ;
  132. case 'Module':
  133. return $this->objModule ;
  134. default:
  135. try {
  136. return parent::__get($strName);
  137. } catch (QCallerException $objExc) {
  138. $objExc->IncrementOffset();
  139. throw $objExc;
  140. }
  141. }
  142. }
  143. public function __set($strName, $mixValue)
  144. {
  145. switch ($strName)
  146. {
  147. case 'Account':
  148. try {
  149. return ($this->objAccount = QType::Cast($mixValue, 'Account' ));
  150. } catch (QInvalidCastException $objExc) {
  151. $objExc->IncrementOffset();
  152. throw $objExc;
  153. }
  154. default:
  155. try {
  156. return (parent::__set($strName, $mixValue));
  157. } catch (QCallerException $objExc) {
  158. $objExc->IncrementOffset();
  159. throw $objExc;
  160. }
  161. }
  162. }
  163. }//end class
  164. }//end define
  165. ?>