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.

174 lines
6.6 KiB

13 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. if (!defined("ACCOUNTINFOEDITPANEL.CLASS.PHP")){
  4. define("ACCOUNTINFOEDITPANEL.CLASS.PHP",1);
  5. /**
  6. * Class AccountInfoEditPanel - provides modifiable display of Account data
  7. *
  8. *@author Erik Winn <erikwinnmail@yahoo.com>
  9. *
  10. *
  11. * $Id: AccountInfoEditPanel.class.php 286 2008-10-10 23:33:36Z erikwinn $
  12. *@version 0.1
  13. *
  14. *@copyright (C) 2008 by Erik Winn
  15. *@license GPL v.2
  16. This program is free software; you can redistribute it and/or modify
  17. it under the terms of the GNU General Public License as published by
  18. the Free Software Foundation; either version 2 of the License, or
  19. (at your option) any later version.
  20. This program is distributed in the hope that it will be useful,
  21. but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. GNU General Public License for more details.
  24. You should have received a copy of the GNU General Public License
  25. along with this program; if not, write to the Free Software
  26. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  27. *
  28. *@package Quasi
  29. * @subpackage Modules
  30. */
  31. class AccountInfoEditPanel extends QPanel
  32. {
  33. /**
  34. * @var ContentBlockView objControlBlock - usually the AccountManagerModule
  35. */
  36. protected $objControlBlock;
  37. /**
  38. * @var Account objAccount - local reference or instance of some relevant object ..
  39. */
  40. protected $objAccount;
  41. /**
  42. * @var PersonMetaControl mctPerson - meta control for Person data fields
  43. */
  44. protected $mctPerson;
  45. public $txtNamePrefix;
  46. public $txtFirstName;
  47. public $txtMiddleName;
  48. public $txtLastName;
  49. public $txtNameSuffix;
  50. public $txtNickName;
  51. public $txtEmailAddress;
  52. public $txtPhoneNumber;
  53. // public $txtAvatarUri;
  54. public $txtCompanyName;
  55. public $btnChangePassword;
  56. public $btnSave;
  57. /**
  58. * Module constructor
  59. * NOTE: This module ignores the required extra parameters ..
  60. *@param QPanel - parent controller object, usually AccountManagerModule.
  61. *@param mixed - extra parameters, ignored
  62. */
  63. public function __construct( QPanel $objControlBlock, $mixParameters=null)
  64. {
  65. //Parent should always be a ContentBlockView
  66. $this->objControlBlock =& $objControlBlock;
  67. try {
  68. parent::__construct($this->objControlBlock);
  69. } catch (QCallerException $objExc) {
  70. $objExc->IncrementOffset();
  71. throw $objExc;
  72. }
  73. $this->strTemplate = __QUASI_CORE_TEMPLATES__ . '/AccountInfoEditPanel.tpl.php';
  74. $this->objAccount =& IndexPage::$objAccount;
  75. $this->mctPerson = PersonMetaControl::Create($this, $this->objAccount->PersonId);
  76. $this->txtNamePrefix = $this->mctPerson->txtNamePrefix_Create();
  77. $this->txtFirstName = $this->mctPerson->txtFirstName_Create();
  78. $this->txtMiddleName = $this->mctPerson->txtMiddleName_Create();
  79. $this->txtLastName = $this->mctPerson->txtLastName_Create();
  80. $this->txtNameSuffix = $this->mctPerson->txtNameSuffix_Create();
  81. $this->txtNickName = $this->mctPerson->txtNickName_Create();
  82. $this->txtEmailAddress = $this->mctPerson->txtEmailAddress_Create();
  83. $this->txtPhoneNumber = $this->mctPerson->txtPhoneNumber_Create();
  84. // $this->txtAvatarUri = $this->mctPerson->txtAvatarUri_Create();
  85. $this->txtCompanyName = $this->mctPerson->txtCompanyName_Create();
  86. $this->btnSave = new QButton($this);
  87. $this->btnSave->Text = QApplication::Translate('Save');
  88. if(IndexPage::$blnAjaxOk)
  89. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  90. else
  91. $this->btnSave->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnSave_Click'));
  92. $this->btnSave->CausesValidation = $this;
  93. $this->btnChangePassword = new QButton($this);
  94. $this->btnChangePassword->Text = QApplication::Translate('Change Password or Username');
  95. if(IndexPage::$blnAjaxOk)
  96. $this->btnChangePassword->AddAction(new QClickEvent(), new QAjaxControlAction($this->objControlBlock, 'btnChangePassword_Click'));
  97. else
  98. $this->btnChangePassword->AddAction(new QClickEvent(), new QServerControlAction($this->objControlBlock, 'btnChangePassword_Click'));
  99. }
  100. /**
  101. * This Function is called when any input is sent - on failure the
  102. * fields are redrawn with optional error messages.
  103. */
  104. public function Validate()
  105. {
  106. $blnToReturn = true;
  107. // validate input here
  108. return $blnToReturn;
  109. }
  110. public function btnSave_Click($strFormId, $strControlId, $strParameter)
  111. {
  112. $this->mctPerson->SavePerson();
  113. if( $this->objControlBlock->lblMessage instanceof QLabel )
  114. $this->objControlBlock->lblMessage->Text = Quasi::Translate('Settings Saved') . '!';
  115. }
  116. public function __get($strName)
  117. {
  118. switch ($strName)
  119. {
  120. case 'Account':
  121. return $this->objAccount ;
  122. default:
  123. try {
  124. return parent::__get($strName);
  125. } catch (QCallerException $objExc) {
  126. $objExc->IncrementOffset();
  127. throw $objExc;
  128. }
  129. }
  130. }
  131. public function __set($strName, $mixValue)
  132. {
  133. switch ($strName)
  134. {
  135. case 'Account':
  136. try {
  137. return ($this->objAccount = QType::Cast($mixValue, 'Account' ));
  138. } catch (QInvalidCastException $objExc) {
  139. $objExc->IncrementOffset();
  140. throw $objExc;
  141. }
  142. default:
  143. try {
  144. return (parent::__set($strName, $mixValue));
  145. } catch (QCallerException $objExc) {
  146. $objExc->IncrementOffset();
  147. throw $objExc;
  148. }
  149. }
  150. }
  151. }//end class
  152. }//end define
  153. ?>