A QCodo powered CMS
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.

149 lines
4.9 KiB

  1. <?php
  2. if(!defined('QUINTACMS') ) die("No quinta.");
  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 <sidewalksoftware@gmail.com>
  38. *
  39. *@version 0.3
  40. *
  41. *@package Quinta
  42. * @subpackage Modules
  43. */
  44. class AccountManagerModule extends QPanel{
  45. /**
  46. *@var Account objAccount - local reference to the Account object
  47. */
  48. private $objAccount;
  49. /**
  50. * @var Module objModule - local reference or instance of the module ORM object
  51. */
  52. protected $objModule;
  53. /**
  54. * @var ContentBlockController objContentBlock - the content block to which this module is assigned
  55. */
  56. protected $objContentBlock;
  57. /**
  58. * Module constructor
  59. *@param ContentBlockController - objContentBlock parent controller object.
  60. *@param object objModule - the module displayed
  61. */
  62. public function __construct( ContentBlockController $objContentBlock, $objModule){
  63. //Parent should always be a ContentBlockController
  64. $this->objContentBlock =& $objContentBlock;
  65. $this->objModule =& $objModule;
  66. try {
  67. parent::__construct($this->objContentBlock);
  68. } catch (QCallerException $objExc) {
  69. $objExc->IncrementOffset();
  70. throw $objExc;
  71. }
  72. $this->AutoRenderChildren = true;
  73. // $this->strTemplate = __QUINTA_CORE_VIEWS__ . '/AccountManagerModule.tpl.php';
  74. //Make sure we have logged in, otherwise we don't display anything ..
  75. $this->objAccount =& IndexPage::$objAccount;
  76. if($this->objAccount instanceof Account)
  77. $this->loadModule();
  78. else
  79. $this->Text = Quinta::Translate('We are sorry - you must be logged in to access your account settings.');
  80. }
  81. /**
  82. * This is the main action for the manager, it parses the URL string and loads the
  83. * appropriate module. The URL must name the module class.
  84. */
  85. private function loadModule(){
  86. $aryParameters = explode('/', IndexPage::$strPageParameters);
  87. $strModuleName = array_shift($aryParameters);
  88. if(empty($strModuleName))
  89. $strModuleName = 'Address';
  90. $strClassName = 'Account' . $strModuleName . 'Module';
  91. if(class_exists($strClassName) )
  92. new $strClassName($this, $aryParameters);
  93. else
  94. new AccountAddressModule($this, $aryParameters);
  95. }
  96. /**
  97. * Unused.
  98. */
  99. public function Validate(){
  100. $blnToReturn = true;
  101. // validate input here
  102. return $blnToReturn;
  103. }
  104. public function __get($strName){
  105. switch ($strName){
  106. case 'Account':
  107. return $this->objAccount ;
  108. case 'ClassName':
  109. return $this->objModule->ClassName ;
  110. case 'Module':
  111. return $this->objModule ;
  112. default:
  113. try {
  114. return parent::__get($strName);
  115. } catch (QCallerException $objExc) {
  116. $objExc->IncrementOffset();
  117. throw $objExc;
  118. }
  119. }
  120. }
  121. public function __set($strName, $mixValue){
  122. switch ($strName){
  123. case 'Account':
  124. try {
  125. return ($this->objAccount = QType::Cast($mixValue, 'Account' ));
  126. } catch (QInvalidCastException $objExc) {
  127. $objExc->IncrementOffset();
  128. throw $objExc;
  129. }
  130. default:
  131. try {
  132. return (parent::__set($strName, $mixValue));
  133. } catch (QCallerException $objExc) {
  134. $objExc->IncrementOffset();
  135. throw $objExc;
  136. }
  137. }
  138. }
  139. }//end class
  140. }//end define
  141. ?>