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.

172 lines
6.0 KiB

12 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. if (!defined("ACCOUNTSETTINGSMODULE.CLASS.PHP")){
  4. define("ACCOUNTSETTINGSMODULE.CLASS.PHP",1);
  5. /**
  6. * Class AccountSettingsModule - provides modifiable display of Account data
  7. * This module contains two panels, one for changing the password and one
  8. * for editing personal information.
  9. *
  10. *@author Erik Winn <erikwinnmail@yahoo.com>
  11. *
  12. *
  13. * $Id: AccountSettingsModule.class.php 237 2008-10-01 19:44:17Z erikwinn $
  14. *@version 0.1
  15. *
  16. *@copyright (C) 2008 by Erik Winn
  17. *@license GPL v.2
  18. This program is free software; you can redistribute it and/or modify
  19. it under the terms of the GNU General Public License as published by
  20. the Free Software Foundation; either version 2 of the License, or
  21. (at your option) any later version.
  22. This program is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. GNU General Public License for more details.
  26. You should have received a copy of the GNU General Public License
  27. along with this program; if not, write to the Free Software
  28. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  29. *
  30. *@package Quasi
  31. * @subpackage Modules
  32. */
  33. class AccountSettingsModule extends QPanel
  34. {
  35. /**
  36. * @var ContentBlockView objControlBlock - usually the AccountManagerModule
  37. */
  38. protected $objControlBlock;
  39. /**
  40. * @var Account objAccount - local reference or instance of the account
  41. */
  42. protected $objAccount;
  43. /**
  44. * @var AccountPasswordEditPanel pnlPasswordEdit - panel for changing password and username
  45. */
  46. public $pnlPasswordEdit;
  47. /**
  48. * @var AccountInfoEditPanel pnlInfoEdit - panel for changing general account information
  49. */
  50. public $pnlInfoEdit;
  51. /**
  52. * @var QLabel lblMessage - let the user know they have saved ..
  53. */
  54. public $lblMessage;
  55. /**
  56. * Module constructor
  57. *
  58. *@param QPanel objControlBlock - parent controller object, usually AccountManagerModule.
  59. *@param array aryParameters - extra parameters, if present should be "Password" to indicate password edit
  60. */
  61. public function __construct( QPanel $objControlBlock, $aryParameters=null)
  62. {
  63. //Parent should always be a ContentBlockView
  64. $this->objControlBlock =& $objControlBlock;
  65. try {
  66. parent::__construct($this->objControlBlock);
  67. } catch (QCallerException $objExc) {
  68. $objExc->IncrementOffset();
  69. throw $objExc;
  70. }
  71. // $this->strTemplate = __QUASI_CORE_TEMPLATES__ . '/AccountSettingsModule.tpl.php';
  72. $this->AutoRenderChildren = true;
  73. $this->lblMessage = new QLabel($this);
  74. $this->lblMessage->HtmlEntities = false;
  75. $this->objAccount =& IndexPage::$objAccount;
  76. if( null != $aryParameters && 'Password' == $aryParameters[0])
  77. {
  78. $this->pnlPasswordEdit = new AccountPasswordEditPanel($this, $this, 'ClosePasswordPanel');
  79. $this->pnlPasswordEdit->Visible = true;
  80. }
  81. else
  82. {
  83. $this->pnlInfoEdit = new AccountInfoEditPanel($this, 'pnlInfoEdit');
  84. $this->pnlInfoEdit->Visible = true;
  85. }
  86. }
  87. /**
  88. * Unused
  89. */
  90. public function Validate()
  91. {
  92. $blnToReturn = true;
  93. // validate input here
  94. return $blnToReturn;
  95. }
  96. /**
  97. * This function closes the password edit panel (by removing all child controls) and shows
  98. * the general info editting panel again. It is called from an action in the password edit panel
  99. */
  100. public function ClosePasswordPanel($blnUpdatesMade)
  101. {
  102. $this->RemoveChildControls(true);
  103. $this->pnlInfoEdit = new AccountInfoEditPanel($this, 'pnlInfoEdit');
  104. $this->pnlInfoEdit->Visible = true;
  105. $this->lblMessage->Text = Quasi::Translate('Password Saved') .'!';
  106. }
  107. /**
  108. * This function closes the general information edit panel (by removing all child controls) and shows
  109. * the password edit panel when the user selects the "Change password" button
  110. */
  111. public function btnChangePassword_Click($strFormId, $strControlId, $strParameter)
  112. {
  113. $this->RemoveChildControls(true);
  114. $this->pnlPasswordEdit = new AccountPasswordEditPanel($this, $this, 'ClosePasswordPanel');
  115. $this->pnlPasswordEdit->Visible = true;
  116. }
  117. ///gettors
  118. public function __get($strName)
  119. {
  120. switch ($strName)
  121. {
  122. case 'Account':
  123. return $this->objAccount ;
  124. default:
  125. try {
  126. return parent::__get($strName);
  127. } catch (QCallerException $objExc) {
  128. $objExc->IncrementOffset();
  129. throw $objExc;
  130. }
  131. }
  132. }
  133. public function __set($strName, $mixValue)
  134. {
  135. switch ($strName)
  136. {
  137. case 'Account':
  138. try {
  139. return ($this->objAccount = QType::Cast($mixValue, 'Account' ));
  140. } catch (QInvalidCastException $objExc) {
  141. $objExc->IncrementOffset();
  142. throw $objExc;
  143. }
  144. default:
  145. try {
  146. return (parent::__set($strName, $mixValue));
  147. } catch (QCallerException $objExc) {
  148. $objExc->IncrementOffset();
  149. throw $objExc;
  150. }
  151. }
  152. }
  153. }//end class
  154. }//end define
  155. ?>