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.

146 lines
4.4 KiB

  1. <?php
  2. if (!defined('QUINTACMS'))
  3. die("No quinta.");
  4. if (!defined("ACCOUNTINFOEDITPANEL.CLASS.PHP")) {
  5. define("ACCOUNTINFOEDITPANEL.CLASS.PHP", 1);
  6. /**
  7. * Class AccountInfoEditPanel - provides modifiable display of Account data
  8. *
  9. * @author Erik Winn <sidewalksoftware@gmail.com>
  10. *
  11. * @version 0.3
  12. *
  13. * @package Quinta
  14. * @subpackage Modules
  15. */
  16. class AccountInfoEditPanel extends QPanel {
  17. /**
  18. * @var ContentBlockController objControlBlock - usually the AccountManagerModule
  19. */
  20. protected $objControlBlock;
  21. /**
  22. * @var Account objAccount - local reference or instance of some relevant object ..
  23. */
  24. protected $objAccount;
  25. /**
  26. * @var PersonMetaControl mctPerson - meta control for Person data fields
  27. */
  28. protected $mctPerson;
  29. public $txtNamePrefix;
  30. public $txtFirstName;
  31. public $txtMiddleName;
  32. public $txtLastName;
  33. public $txtNameSuffix;
  34. public $txtNickName;
  35. // public $txtAvatarUri;
  36. public $txtCompanyName;
  37. public $btnChangePassword;
  38. public $btnSave;
  39. /**
  40. * Module constructor
  41. * NOTE: This module ignores the required extra parameters ..
  42. * @param QPanel - parent controller object, usually AccountManagerModule.
  43. * @param mixed - extra parameters, ignored
  44. */
  45. public function __construct(QPanel $objControlBlock, $mixParameters=null) {
  46. //Parent should always be a ContentBlockController
  47. $this->objControlBlock = & $objControlBlock;
  48. try {
  49. parent::__construct($this->objControlBlock);
  50. } catch (QCallerException $objExc) {
  51. $objExc->IncrementOffset();
  52. throw $objExc;
  53. }
  54. $this->strTemplate = __QUINTA_CORE_VIEWS__ . '/AccountInfoEditPanel.tpl.php';
  55. $this->objAccount = & IndexPage::$objAccount;
  56. $this->mctPerson = PersonMetaControl::Create($this, $this->objAccount->PersonId);
  57. $this->txtNamePrefix = $this->mctPerson->txtNamePrefix_Create();
  58. $this->txtFirstName = $this->mctPerson->txtFirstName_Create();
  59. $this->txtMiddleName = $this->mctPerson->txtMiddleName_Create();
  60. $this->txtLastName = $this->mctPerson->txtLastName_Create();
  61. $this->txtNameSuffix = $this->mctPerson->txtNameSuffix_Create();
  62. $this->txtNickName = $this->mctPerson->txtNickName_Create();
  63. // $this->txtAvatarUri = $this->mctPerson->txtAvatarUri_Create();
  64. $this->txtCompanyName = $this->mctPerson->txtCompanyName_Create();
  65. $this->btnSave = new QButton($this);
  66. $this->btnSave->Text = QApplication::Translate('Save');
  67. if (IndexPage::$blnAjaxOk)
  68. $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));
  69. else
  70. $this->btnSave->AddAction(new QClickEvent(), new QServerControlAction($this, 'btnSave_Click'));
  71. $this->btnSave->CausesValidation = $this;
  72. $this->btnChangePassword = new QButton($this);
  73. $this->btnChangePassword->Text = QApplication::Translate('Change Password or Username');
  74. if (IndexPage::$blnAjaxOk)
  75. $this->btnChangePassword->AddAction(new QClickEvent(), new QAjaxControlAction($this->objControlBlock, 'btnChangePassword_Click'));
  76. else
  77. $this->btnChangePassword->AddAction(new QClickEvent(), new QServerControlAction($this->objControlBlock, 'btnChangePassword_Click'));
  78. }
  79. /**
  80. * This Function is called when any input is sent - on failure the
  81. * fields are redrawn with optional error messages.
  82. */
  83. public function Validate() {
  84. $blnToReturn = true;
  85. // validate input here
  86. return $blnToReturn;
  87. }
  88. public function btnSave_Click($strFormId, $strControlId, $strParameter) {
  89. $this->mctPerson->SavePerson();
  90. if ($this->objControlBlock->lblMessage instanceof QLabel)
  91. $this->objControlBlock->lblMessage->Text = Quinta::Translate('Settings Saved') . '!';
  92. }
  93. public function __get($strName) {
  94. switch ($strName) {
  95. case 'Account':
  96. return $this->objAccount;
  97. default:
  98. try {
  99. return parent::__get($strName);
  100. } catch (QCallerException $objExc) {
  101. $objExc->IncrementOffset();
  102. throw $objExc;
  103. }
  104. }
  105. }
  106. public function __set($strName, $mixValue) {
  107. switch ($strName) {
  108. case 'Account':
  109. try {
  110. return ($this->objAccount = QType::Cast($mixValue, 'Account'));
  111. } catch (QInvalidCastException $objExc) {
  112. $objExc->IncrementOffset();
  113. throw $objExc;
  114. }
  115. default:
  116. try {
  117. return (parent::__set($strName, $mixValue));
  118. } catch (QCallerException $objExc) {
  119. $objExc->IncrementOffset();
  120. throw $objExc;
  121. }
  122. }
  123. }
  124. }
  125. //end class
  126. }//end define
  127. ?>