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.

137 lines
4.1 KiB

  1. <?php
  2. if(!defined('QUINTACMS') ) die("No quinta.");
  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 <sidewalksoftware@gmail.com>
  11. *
  12. *@version 0.3
  13. *
  14. *@package Quinta
  15. * @subpackage Modules
  16. */
  17. class AccountSettingsModule extends QPanel{
  18. /**
  19. * @var ContentBlockController objControlBlock - usually the AccountManagerModule
  20. */
  21. protected $objControlBlock;
  22. /**
  23. * @var Account objAccount - local reference or instance of the account
  24. */
  25. protected $objAccount;
  26. /**
  27. * @var AccountPasswordEditPanel pnlPasswordEdit - panel for changing password and username
  28. */
  29. public $pnlPasswordEdit;
  30. /**
  31. * @var AccountInfoEditPanel pnlInfoEdit - panel for changing general account information
  32. */
  33. public $pnlInfoEdit;
  34. /**
  35. * @var QLabel lblMessage - let the user know they have saved ..
  36. */
  37. public $lblMessage;
  38. /**
  39. * Module constructor
  40. *
  41. *@param QPanel objControlBlock - parent controller object, usually AccountManagerModule.
  42. *@param array aryParameters - extra parameters, if present should be "Password" to indicate password edit
  43. */
  44. public function __construct( QPanel $objControlBlock, $aryParameters=null){
  45. //Parent should always be a ContentBlockController
  46. $this->objControlBlock =& $objControlBlock;
  47. try {
  48. parent::__construct($this->objControlBlock);
  49. } catch (QCallerException $objExc) {
  50. $objExc->IncrementOffset();
  51. throw $objExc;
  52. }
  53. // $this->strTemplate = __QUINTA_CORE_VIEWS__ . '/AccountSettingsModule.tpl.php';
  54. $this->AutoRenderChildren = true;
  55. $this->lblMessage = new QLabel($this);
  56. $this->lblMessage->HtmlEntities = false;
  57. $this->objAccount =& IndexPage::$objAccount;
  58. if( null != $aryParameters && 'Password' == $aryParameters[0]){
  59. $this->pnlPasswordEdit = new AccountPasswordEditPanel($this, $this, 'ClosePasswordPanel');
  60. $this->pnlPasswordEdit->Visible = true;
  61. }else{
  62. $this->pnlInfoEdit = new AccountInfoEditPanel($this, 'pnlInfoEdit');
  63. $this->pnlInfoEdit->Visible = true;
  64. }
  65. }
  66. /**
  67. * Unused
  68. */
  69. public function Validate(){
  70. $blnToReturn = true;
  71. // validate input here
  72. return $blnToReturn;
  73. }
  74. /**
  75. * This function closes the password edit panel (by removing all child controls) and shows
  76. * the general info editting panel again. It is called from an action in the password edit panel
  77. */
  78. public function ClosePasswordPanel($blnUpdatesMade){
  79. $this->RemoveChildControls(true);
  80. $this->pnlInfoEdit = new AccountInfoEditPanel($this, 'pnlInfoEdit');
  81. $this->pnlInfoEdit->Visible = true;
  82. $this->lblMessage->Text = Quinta::Translate('Password Saved') .'!';
  83. }
  84. /**
  85. * This function closes the general information edit panel (by removing all child controls) and shows
  86. * the password edit panel when the user selects the "Change password" button
  87. */
  88. public function btnChangePassword_Click($strFormId, $strControlId, $strParameter){
  89. $this->RemoveChildControls(true);
  90. $this->pnlPasswordEdit = new AccountPasswordEditPanel($this, $this, 'ClosePasswordPanel');
  91. $this->pnlPasswordEdit->Visible = true;
  92. }
  93. ///gettors
  94. public function __get($strName){
  95. switch ($strName){
  96. case 'Account':
  97. return $this->objAccount ;
  98. default:
  99. try {
  100. return parent::__get($strName);
  101. } catch (QCallerException $objExc) {
  102. $objExc->IncrementOffset();
  103. throw $objExc;
  104. }
  105. }
  106. }
  107. public function __set($strName, $mixValue){
  108. switch ($strName){
  109. case 'Account':
  110. try {
  111. return ($this->objAccount = QType::Cast($mixValue, 'Account' ));
  112. } catch (QInvalidCastException $objExc) {
  113. $objExc->IncrementOffset();
  114. throw $objExc;
  115. }
  116. default:
  117. try {
  118. return (parent::__set($strName, $mixValue));
  119. } catch (QCallerException $objExc) {
  120. $objExc->IncrementOffset();
  121. throw $objExc;
  122. }
  123. }
  124. }
  125. }//end class
  126. }//end define
  127. ?>