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.

757 lines
35 KiB

  1. <?php
  2. /**
  3. * This is a MetaControl class, providing a QForm or QPanel access to event handlers
  4. * and QControls to perform the Create, Edit, and Delete functionality
  5. * of the Account class. This code-generated class
  6. * contains all the basic elements to help a QPanel or QForm display an HTML form that can
  7. * manipulate a single Account object.
  8. *
  9. * To take advantage of some (or all) of these control objects, you
  10. * must create a new QForm or QPanel which instantiates a AccountMetaControl
  11. * class.
  12. *
  13. * Any and all changes to this file will be overwritten with any subsequent
  14. * code re-generation.
  15. *
  16. * @package Quinta CMS
  17. * @subpackage MetaControls
  18. * property-read Account $Account the actual Account data class being edited
  19. * property QLabel $IdControl
  20. * property-read QLabel $IdLabel
  21. * property QLabel $RegistrationDateControl
  22. * property-read QLabel $RegistrationDateLabel
  23. * property QTextBox $UsernameControl
  24. * property-read QLabel $UsernameLabel
  25. * property QTextBox $PasswordControl
  26. * property-read QLabel $PasswordLabel
  27. * property QTextBox $NotesControl
  28. * property-read QLabel $NotesLabel
  29. * property QLabel $LastLoginControl
  30. * property-read QLabel $LastLoginLabel
  31. * property QIntegerTextBox $LoginCountControl
  32. * property-read QLabel $LoginCountLabel
  33. * property QCheckBox $OnlineControl
  34. * property-read QLabel $OnlineLabel
  35. * property QCheckBox $OnetimePasswordControl
  36. * property-read QLabel $OnetimePasswordLabel
  37. * property QCheckBox $ValidPasswordControl
  38. * property-read QLabel $ValidPasswordLabel
  39. * property QListBox $TypeIdControl
  40. * property-read QLabel $TypeIdLabel
  41. * property QListBox $StatusIdControl
  42. * property-read QLabel $StatusIdLabel
  43. * property QListBox $PersonIdControl
  44. * property-read QLabel $PersonIdLabel
  45. * property-read string $TitleVerb a verb indicating whether or not this is being edited or created
  46. * property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
  47. */
  48. class AccountMetaControlGen extends QBaseClass {
  49. // General Variables
  50. protected $objAccount;
  51. protected $objParentObject;
  52. protected $strTitleVerb;
  53. protected $blnEditMode;
  54. // Controls that allow the editing of Account's individual data fields
  55. protected $lblId;
  56. protected $lblRegistrationDate;
  57. protected $txtUsername;
  58. protected $txtPassword;
  59. protected $txtNotes;
  60. protected $lblLastLogin;
  61. protected $txtLoginCount;
  62. protected $chkOnline;
  63. protected $chkOnetimePassword;
  64. protected $chkValidPassword;
  65. protected $lstType;
  66. protected $lstStatus;
  67. protected $lstPerson;
  68. // Controls that allow the viewing of Account's individual data fields
  69. protected $lblUsername;
  70. protected $lblPassword;
  71. protected $lblNotes;
  72. protected $lblLoginCount;
  73. protected $lblOnline;
  74. protected $lblOnetimePassword;
  75. protected $lblValidPassword;
  76. protected $lblTypeId;
  77. protected $lblStatusId;
  78. protected $lblPersonId;
  79. // QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References
  80. // QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References
  81. /**
  82. * Main constructor. Constructor OR static create methods are designed to be called in either
  83. * a parent QPanel or the main QForm when wanting to create a
  84. * AccountMetaControl to edit a single Account object within the
  85. * QPanel or QForm.
  86. *
  87. * This constructor takes in a single Account object, while any of the static
  88. * create methods below can be used to construct based off of individual PK ID(s).
  89. *
  90. * @param mixed $objParentObject QForm or QPanel which will be using this AccountMetaControl
  91. * @param Account $objAccount new or existing Account object
  92. */
  93. public function __construct($objParentObject, Account $objAccount) {
  94. // Setup Parent Object (e.g. QForm or QPanel which will be using this AccountMetaControl)
  95. $this->objParentObject = $objParentObject;
  96. // Setup linked Account object
  97. $this->objAccount = $objAccount;
  98. // Figure out if we're Editing or Creating New
  99. if ($this->objAccount->__Restored) {
  100. $this->strTitleVerb = QApplication::Translate('Edit');
  101. $this->blnEditMode = true;
  102. } else {
  103. $this->strTitleVerb = QApplication::Translate('Create');
  104. $this->blnEditMode = false;
  105. }
  106. }
  107. /**
  108. * Static Helper Method to Create using PK arguments
  109. * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  110. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  111. * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to
  112. * edit, or if we are also allowed to create a new one, etc.
  113. *
  114. * @param mixed $objParentObject QForm or QPanel which will be using this AccountMetaControl
  115. * @param integer $intId primary key value
  116. * @param QMetaControlCreateType $intCreateType rules governing Account object creation - defaults to CreateOrEdit
  117. * @return AccountMetaControl
  118. */
  119. public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  120. // Attempt to Load from PK Arguments
  121. if (strlen($intId)) {
  122. $objAccount = Account::Load($intId);
  123. // Account was found -- return it!
  124. if ($objAccount)
  125. return new AccountMetaControl($objParentObject, $objAccount);
  126. // If CreateOnRecordNotFound not specified, throw an exception
  127. else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
  128. throw new QCallerException('Could not find a Account object with PK arguments: ' . $intId);
  129. // If EditOnly is specified, throw an exception
  130. } else if ($intCreateType == QMetaControlCreateType::EditOnly)
  131. throw new QCallerException('No PK arguments specified');
  132. // If we are here, then we need to create a new record
  133. return new AccountMetaControl($objParentObject, new Account());
  134. }
  135. /**
  136. * Static Helper Method to Create using PathInfo arguments
  137. *
  138. * @param mixed $objParentObject QForm or QPanel which will be using this AccountMetaControl
  139. * @param QMetaControlCreateType $intCreateType rules governing Account object creation - defaults to CreateOrEdit
  140. * @return AccountMetaControl
  141. */
  142. public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  143. $intId = QApplication::PathInfo(0);
  144. return AccountMetaControl::Create($objParentObject, $intId, $intCreateType);
  145. }
  146. /**
  147. * Static Helper Method to Create using QueryString arguments
  148. *
  149. * @param mixed $objParentObject QForm or QPanel which will be using this AccountMetaControl
  150. * @param QMetaControlCreateType $intCreateType rules governing Account object creation - defaults to CreateOrEdit
  151. * @return AccountMetaControl
  152. */
  153. public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  154. $intId = QApplication::QueryString('intId');
  155. return AccountMetaControl::Create($objParentObject, $intId, $intCreateType);
  156. }
  157. ///////////////////////////////////////////////
  158. // PUBLIC CREATE and REFRESH METHODS
  159. ///////////////////////////////////////////////
  160. /**
  161. * Create and setup QLabel lblId
  162. * @param string $strControlId optional ControlId to use
  163. * @return QLabel
  164. */
  165. public function lblId_Create($strControlId = null) {
  166. $this->lblId = new QLabel($this->objParentObject, $strControlId);
  167. $this->lblId->Name = QApplication::Translate('Id');
  168. if ($this->blnEditMode)
  169. $this->lblId->Text = $this->objAccount->Id;
  170. else
  171. $this->lblId->Text = 'N/A';
  172. return $this->lblId;
  173. }
  174. /**
  175. * Create and setup QLabel lblRegistrationDate
  176. * @param string $strControlId optional ControlId to use
  177. * @return QLabel
  178. */
  179. public function lblRegistrationDate_Create($strControlId = null) {
  180. $this->lblRegistrationDate = new QLabel($this->objParentObject, $strControlId);
  181. $this->lblRegistrationDate->Name = QApplication::Translate('Registration Date');
  182. if ($this->blnEditMode)
  183. $this->lblRegistrationDate->Text = $this->objAccount->RegistrationDate;
  184. else
  185. $this->lblRegistrationDate->Text = 'N/A';
  186. return $this->lblRegistrationDate;
  187. }
  188. /**
  189. * Create and setup QTextBox txtUsername
  190. * @param string $strControlId optional ControlId to use
  191. * @return QTextBox
  192. */
  193. public function txtUsername_Create($strControlId = null) {
  194. $this->txtUsername = new QTextBox($this->objParentObject, $strControlId);
  195. $this->txtUsername->Name = QApplication::Translate('Username');
  196. $this->txtUsername->Text = $this->objAccount->Username;
  197. $this->txtUsername->Required = true;
  198. $this->txtUsername->MaxLength = Account::UsernameMaxLength;
  199. return $this->txtUsername;
  200. }
  201. /**
  202. * Create and setup QLabel lblUsername
  203. * @param string $strControlId optional ControlId to use
  204. * @return QLabel
  205. */
  206. public function lblUsername_Create($strControlId = null) {
  207. $this->lblUsername = new QLabel($this->objParentObject, $strControlId);
  208. $this->lblUsername->Name = QApplication::Translate('Username');
  209. $this->lblUsername->Text = $this->objAccount->Username;
  210. $this->lblUsername->Required = true;
  211. return $this->lblUsername;
  212. }
  213. /**
  214. * Create and setup QTextBox txtPassword
  215. * @param string $strControlId optional ControlId to use
  216. * @return QTextBox
  217. */
  218. public function txtPassword_Create($strControlId = null) {
  219. $this->txtPassword = new QTextBox($this->objParentObject, $strControlId);
  220. $this->txtPassword->Name = QApplication::Translate('Password');
  221. $this->txtPassword->Text = $this->objAccount->Password;
  222. $this->txtPassword->Required = true;
  223. $this->txtPassword->MaxLength = Account::PasswordMaxLength;
  224. return $this->txtPassword;
  225. }
  226. /**
  227. * Create and setup QLabel lblPassword
  228. * @param string $strControlId optional ControlId to use
  229. * @return QLabel
  230. */
  231. public function lblPassword_Create($strControlId = null) {
  232. $this->lblPassword = new QLabel($this->objParentObject, $strControlId);
  233. $this->lblPassword->Name = QApplication::Translate('Password');
  234. $this->lblPassword->Text = $this->objAccount->Password;
  235. $this->lblPassword->Required = true;
  236. return $this->lblPassword;
  237. }
  238. /**
  239. * Create and setup QTextBox txtNotes
  240. * @param string $strControlId optional ControlId to use
  241. * @return QTextBox
  242. */
  243. public function txtNotes_Create($strControlId = null) {
  244. $this->txtNotes = new QTextBox($this->objParentObject, $strControlId);
  245. $this->txtNotes->Name = QApplication::Translate('Notes');
  246. $this->txtNotes->Text = $this->objAccount->Notes;
  247. $this->txtNotes->TextMode = QTextMode::MultiLine;
  248. return $this->txtNotes;
  249. }
  250. /**
  251. * Create and setup QLabel lblNotes
  252. * @param string $strControlId optional ControlId to use
  253. * @return QLabel
  254. */
  255. public function lblNotes_Create($strControlId = null) {
  256. $this->lblNotes = new QLabel($this->objParentObject, $strControlId);
  257. $this->lblNotes->Name = QApplication::Translate('Notes');
  258. $this->lblNotes->Text = $this->objAccount->Notes;
  259. return $this->lblNotes;
  260. }
  261. /**
  262. * Create and setup QLabel lblLastLogin
  263. * @param string $strControlId optional ControlId to use
  264. * @return QLabel
  265. */
  266. public function lblLastLogin_Create($strControlId = null) {
  267. $this->lblLastLogin = new QLabel($this->objParentObject, $strControlId);
  268. $this->lblLastLogin->Name = QApplication::Translate('Last Login');
  269. if ($this->blnEditMode)
  270. $this->lblLastLogin->Text = $this->objAccount->LastLogin;
  271. else
  272. $this->lblLastLogin->Text = 'N/A';
  273. return $this->lblLastLogin;
  274. }
  275. /**
  276. * Create and setup QIntegerTextBox txtLoginCount
  277. * @param string $strControlId optional ControlId to use
  278. * @return QIntegerTextBox
  279. */
  280. public function txtLoginCount_Create($strControlId = null) {
  281. $this->txtLoginCount = new QIntegerTextBox($this->objParentObject, $strControlId);
  282. $this->txtLoginCount->Name = QApplication::Translate('Login Count');
  283. $this->txtLoginCount->Text = $this->objAccount->LoginCount;
  284. return $this->txtLoginCount;
  285. }
  286. /**
  287. * Create and setup QLabel lblLoginCount
  288. * @param string $strControlId optional ControlId to use
  289. * @param string $strFormat optional sprintf format to use
  290. * @return QLabel
  291. */
  292. public function lblLoginCount_Create($strControlId = null, $strFormat = null) {
  293. $this->lblLoginCount = new QLabel($this->objParentObject, $strControlId);
  294. $this->lblLoginCount->Name = QApplication::Translate('Login Count');
  295. $this->lblLoginCount->Text = $this->objAccount->LoginCount;
  296. $this->lblLoginCount->Format = $strFormat;
  297. return $this->lblLoginCount;
  298. }
  299. /**
  300. * Create and setup QCheckBox chkOnline
  301. * @param string $strControlId optional ControlId to use
  302. * @return QCheckBox
  303. */
  304. public function chkOnline_Create($strControlId = null) {
  305. $this->chkOnline = new QCheckBox($this->objParentObject, $strControlId);
  306. $this->chkOnline->Name = QApplication::Translate('Online');
  307. $this->chkOnline->Checked = $this->objAccount->Online;
  308. return $this->chkOnline;
  309. }
  310. /**
  311. * Create and setup QLabel lblOnline
  312. * @param string $strControlId optional ControlId to use
  313. * @return QLabel
  314. */
  315. public function lblOnline_Create($strControlId = null) {
  316. $this->lblOnline = new QLabel($this->objParentObject, $strControlId);
  317. $this->lblOnline->Name = QApplication::Translate('Online');
  318. $this->lblOnline->Text = ($this->objAccount->Online) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  319. return $this->lblOnline;
  320. }
  321. /**
  322. * Create and setup QCheckBox chkOnetimePassword
  323. * @param string $strControlId optional ControlId to use
  324. * @return QCheckBox
  325. */
  326. public function chkOnetimePassword_Create($strControlId = null) {
  327. $this->chkOnetimePassword = new QCheckBox($this->objParentObject, $strControlId);
  328. $this->chkOnetimePassword->Name = QApplication::Translate('Onetime Password');
  329. $this->chkOnetimePassword->Checked = $this->objAccount->OnetimePassword;
  330. return $this->chkOnetimePassword;
  331. }
  332. /**
  333. * Create and setup QLabel lblOnetimePassword
  334. * @param string $strControlId optional ControlId to use
  335. * @return QLabel
  336. */
  337. public function lblOnetimePassword_Create($strControlId = null) {
  338. $this->lblOnetimePassword = new QLabel($this->objParentObject, $strControlId);
  339. $this->lblOnetimePassword->Name = QApplication::Translate('Onetime Password');
  340. $this->lblOnetimePassword->Text = ($this->objAccount->OnetimePassword) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  341. return $this->lblOnetimePassword;
  342. }
  343. /**
  344. * Create and setup QCheckBox chkValidPassword
  345. * @param string $strControlId optional ControlId to use
  346. * @return QCheckBox
  347. */
  348. public function chkValidPassword_Create($strControlId = null) {
  349. $this->chkValidPassword = new QCheckBox($this->objParentObject, $strControlId);
  350. $this->chkValidPassword->Name = QApplication::Translate('Valid Password');
  351. $this->chkValidPassword->Checked = $this->objAccount->ValidPassword;
  352. return $this->chkValidPassword;
  353. }
  354. /**
  355. * Create and setup QLabel lblValidPassword
  356. * @param string $strControlId optional ControlId to use
  357. * @return QLabel
  358. */
  359. public function lblValidPassword_Create($strControlId = null) {
  360. $this->lblValidPassword = new QLabel($this->objParentObject, $strControlId);
  361. $this->lblValidPassword->Name = QApplication::Translate('Valid Password');
  362. $this->lblValidPassword->Text = ($this->objAccount->ValidPassword) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  363. return $this->lblValidPassword;
  364. }
  365. /**
  366. * Create and setup QListBox lstType
  367. * @param string $strControlId optional ControlId to use
  368. * @return QListBox
  369. */
  370. public function lstType_Create($strControlId = null) {
  371. $this->lstType = new QListBox($this->objParentObject, $strControlId);
  372. $this->lstType->Name = QApplication::Translate('Type');
  373. $this->lstType->Required = true;
  374. foreach (AccountType::$NameArray as $intId => $strValue)
  375. $this->lstType->AddItem(new QListItem($strValue, $intId, $this->objAccount->TypeId == $intId));
  376. return $this->lstType;
  377. }
  378. /**
  379. * Create and setup QLabel lblTypeId
  380. * @param string $strControlId optional ControlId to use
  381. * @return QLabel
  382. */
  383. public function lblTypeId_Create($strControlId = null) {
  384. $this->lblTypeId = new QLabel($this->objParentObject, $strControlId);
  385. $this->lblTypeId->Name = QApplication::Translate('Type');
  386. $this->lblTypeId->Text = ($this->objAccount->TypeId) ? AccountType::$NameArray[$this->objAccount->TypeId] : null;
  387. $this->lblTypeId->Required = true;
  388. return $this->lblTypeId;
  389. }
  390. /**
  391. * Create and setup QListBox lstStatus
  392. * @param string $strControlId optional ControlId to use
  393. * @return QListBox
  394. */
  395. public function lstStatus_Create($strControlId = null) {
  396. $this->lstStatus = new QListBox($this->objParentObject, $strControlId);
  397. $this->lstStatus->Name = QApplication::Translate('Status');
  398. $this->lstStatus->Required = true;
  399. foreach (AccountStatusType::$NameArray as $intId => $strValue)
  400. $this->lstStatus->AddItem(new QListItem($strValue, $intId, $this->objAccount->StatusId == $intId));
  401. return $this->lstStatus;
  402. }
  403. /**
  404. * Create and setup QLabel lblStatusId
  405. * @param string $strControlId optional ControlId to use
  406. * @return QLabel
  407. */
  408. public function lblStatusId_Create($strControlId = null) {
  409. $this->lblStatusId = new QLabel($this->objParentObject, $strControlId);
  410. $this->lblStatusId->Name = QApplication::Translate('Status');
  411. $this->lblStatusId->Text = ($this->objAccount->StatusId) ? AccountStatusType::$NameArray[$this->objAccount->StatusId] : null;
  412. $this->lblStatusId->Required = true;
  413. return $this->lblStatusId;
  414. }
  415. /**
  416. * Create and setup QListBox lstPerson
  417. * @param string $strControlId optional ControlId to use
  418. * @return QListBox
  419. */
  420. public function lstPerson_Create($strControlId = null) {
  421. $this->lstPerson = new QListBox($this->objParentObject, $strControlId);
  422. $this->lstPerson->Name = QApplication::Translate('Person');
  423. $this->lstPerson->Required = true;
  424. if (!$this->blnEditMode)
  425. $this->lstPerson->AddItem(QApplication::Translate('- Select One -'), null);
  426. $objPersonArray = Person::LoadAll();
  427. if ($objPersonArray) foreach ($objPersonArray as $objPerson) {
  428. $objListItem = new QListItem($objPerson->__toString(), $objPerson->Id);
  429. if (($this->objAccount->Person) && ($this->objAccount->Person->Id == $objPerson->Id))
  430. $objListItem->Selected = true;
  431. $this->lstPerson->AddItem($objListItem);
  432. }
  433. return $this->lstPerson;
  434. }
  435. /**
  436. * Create and setup QLabel lblPersonId
  437. * @param string $strControlId optional ControlId to use
  438. * @return QLabel
  439. */
  440. public function lblPersonId_Create($strControlId = null) {
  441. $this->lblPersonId = new QLabel($this->objParentObject, $strControlId);
  442. $this->lblPersonId->Name = QApplication::Translate('Person');
  443. $this->lblPersonId->Text = ($this->objAccount->Person) ? $this->objAccount->Person->__toString() : null;
  444. $this->lblPersonId->Required = true;
  445. return $this->lblPersonId;
  446. }
  447. /**
  448. * Refresh this MetaControl with Data from the local Account object.
  449. * @param boolean $blnReload reload Account from the database
  450. * @return void
  451. */
  452. public function Refresh($blnReload = false) {
  453. if ($blnReload)
  454. $this->objAccount->Reload();
  455. if ($this->lblId) if ($this->blnEditMode) $this->lblId->Text = $this->objAccount->Id;
  456. if ($this->lblRegistrationDate) if ($this->blnEditMode) $this->lblRegistrationDate->Text = $this->objAccount->RegistrationDate;
  457. if ($this->txtUsername) $this->txtUsername->Text = $this->objAccount->Username;
  458. if ($this->lblUsername) $this->lblUsername->Text = $this->objAccount->Username;
  459. if ($this->txtPassword) $this->txtPassword->Text = $this->objAccount->Password;
  460. if ($this->lblPassword) $this->lblPassword->Text = $this->objAccount->Password;
  461. if ($this->txtNotes) $this->txtNotes->Text = $this->objAccount->Notes;
  462. if ($this->lblNotes) $this->lblNotes->Text = $this->objAccount->Notes;
  463. if ($this->lblLastLogin) if ($this->blnEditMode) $this->lblLastLogin->Text = $this->objAccount->LastLogin;
  464. if ($this->txtLoginCount) $this->txtLoginCount->Text = $this->objAccount->LoginCount;
  465. if ($this->lblLoginCount) $this->lblLoginCount->Text = $this->objAccount->LoginCount;
  466. if ($this->chkOnline) $this->chkOnline->Checked = $this->objAccount->Online;
  467. if ($this->lblOnline) $this->lblOnline->Text = ($this->objAccount->Online) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  468. if ($this->chkOnetimePassword) $this->chkOnetimePassword->Checked = $this->objAccount->OnetimePassword;
  469. if ($this->lblOnetimePassword) $this->lblOnetimePassword->Text = ($this->objAccount->OnetimePassword) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  470. if ($this->chkValidPassword) $this->chkValidPassword->Checked = $this->objAccount->ValidPassword;
  471. if ($this->lblValidPassword) $this->lblValidPassword->Text = ($this->objAccount->ValidPassword) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  472. if ($this->lstType) $this->lstType->SelectedValue = $this->objAccount->TypeId;
  473. if ($this->lblTypeId) $this->lblTypeId->Text = ($this->objAccount->TypeId) ? AccountType::$NameArray[$this->objAccount->TypeId] : null;
  474. if ($this->lstStatus) $this->lstStatus->SelectedValue = $this->objAccount->StatusId;
  475. if ($this->lblStatusId) $this->lblStatusId->Text = ($this->objAccount->StatusId) ? AccountStatusType::$NameArray[$this->objAccount->StatusId] : null;
  476. if ($this->lstPerson) {
  477. $this->lstPerson->RemoveAllItems();
  478. if (!$this->blnEditMode)
  479. $this->lstPerson->AddItem(QApplication::Translate('- Select One -'), null);
  480. $objPersonArray = Person::LoadAll();
  481. if ($objPersonArray) foreach ($objPersonArray as $objPerson) {
  482. $objListItem = new QListItem($objPerson->__toString(), $objPerson->Id);
  483. if (($this->objAccount->Person) && ($this->objAccount->Person->Id == $objPerson->Id))
  484. $objListItem->Selected = true;
  485. $this->lstPerson->AddItem($objListItem);
  486. }
  487. }
  488. if ($this->lblPersonId) $this->lblPersonId->Text = ($this->objAccount->Person) ? $this->objAccount->Person->__toString() : null;
  489. }
  490. ///////////////////////////////////////////////
  491. // PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
  492. ///////////////////////////////////////////////
  493. ///////////////////////////////////////////////
  494. // PUBLIC ACCOUNT OBJECT MANIPULATORS
  495. ///////////////////////////////////////////////
  496. /**
  497. * This will save this object's Account instance,
  498. * updating only the fields which have had a control created for it.
  499. */
  500. public function SaveAccount() {
  501. try {
  502. // Update any fields for controls that have been created
  503. if ($this->txtUsername) $this->objAccount->Username = $this->txtUsername->Text;
  504. if ($this->txtPassword) $this->objAccount->Password = $this->txtPassword->Text;
  505. if ($this->txtNotes) $this->objAccount->Notes = $this->txtNotes->Text;
  506. if ($this->txtLoginCount) $this->objAccount->LoginCount = $this->txtLoginCount->Text;
  507. if ($this->chkOnline) $this->objAccount->Online = $this->chkOnline->Checked;
  508. if ($this->chkOnetimePassword) $this->objAccount->OnetimePassword = $this->chkOnetimePassword->Checked;
  509. if ($this->chkValidPassword) $this->objAccount->ValidPassword = $this->chkValidPassword->Checked;
  510. if ($this->lstType) $this->objAccount->TypeId = $this->lstType->SelectedValue;
  511. if ($this->lstStatus) $this->objAccount->StatusId = $this->lstStatus->SelectedValue;
  512. if ($this->lstPerson) $this->objAccount->PersonId = $this->lstPerson->SelectedValue;
  513. // Update any UniqueReverseReferences (if any) for controls that have been created for it
  514. // Save the Account object
  515. $this->objAccount->Save();
  516. // Finally, update any ManyToManyReferences (if any)
  517. } catch (QCallerException $objExc) {
  518. $objExc->IncrementOffset();
  519. throw $objExc;
  520. }
  521. }
  522. /**
  523. * This will DELETE this object's Account instance from the database.
  524. * It will also unassociate itself from any ManyToManyReferences.
  525. */
  526. public function DeleteAccount() {
  527. $this->objAccount->Delete();
  528. }
  529. ///////////////////////////////////////////////
  530. // PUBLIC GETTERS and SETTERS
  531. ///////////////////////////////////////////////
  532. /**
  533. * Override method to perform a property "Get"
  534. * This will get the value of $strName
  535. *
  536. * @param string $strName Name of the property to get
  537. * @return mixed
  538. */
  539. public function __get($strName) {
  540. switch ($strName) {
  541. // General MetaControlVariables
  542. case 'Account': return $this->objAccount;
  543. case 'TitleVerb': return $this->strTitleVerb;
  544. case 'EditMode': return $this->blnEditMode;
  545. // Controls that point to Account fields -- will be created dynamically if not yet created
  546. case 'IdControl':
  547. if (!$this->lblId) return $this->lblId_Create();
  548. return $this->lblId;
  549. case 'IdLabel':
  550. if (!$this->lblId) return $this->lblId_Create();
  551. return $this->lblId;
  552. case 'RegistrationDateControl':
  553. if (!$this->lblRegistrationDate) return $this->lblRegistrationDate_Create();
  554. return $this->lblRegistrationDate;
  555. case 'RegistrationDateLabel':
  556. if (!$this->lblRegistrationDate) return $this->lblRegistrationDate_Create();
  557. return $this->lblRegistrationDate;
  558. case 'UsernameControl':
  559. if (!$this->txtUsername) return $this->txtUsername_Create();
  560. return $this->txtUsername;
  561. case 'UsernameLabel':
  562. if (!$this->lblUsername) return $this->lblUsername_Create();
  563. return $this->lblUsername;
  564. case 'PasswordControl':
  565. if (!$this->txtPassword) return $this->txtPassword_Create();
  566. return $this->txtPassword;
  567. case 'PasswordLabel':
  568. if (!$this->lblPassword) return $this->lblPassword_Create();
  569. return $this->lblPassword;
  570. case 'NotesControl':
  571. if (!$this->txtNotes) return $this->txtNotes_Create();
  572. return $this->txtNotes;
  573. case 'NotesLabel':
  574. if (!$this->lblNotes) return $this->lblNotes_Create();
  575. return $this->lblNotes;
  576. case 'LastLoginControl':
  577. if (!$this->lblLastLogin) return $this->lblLastLogin_Create();
  578. return $this->lblLastLogin;
  579. case 'LastLoginLabel':
  580. if (!$this->lblLastLogin) return $this->lblLastLogin_Create();
  581. return $this->lblLastLogin;
  582. case 'LoginCountControl':
  583. if (!$this->txtLoginCount) return $this->txtLoginCount_Create();
  584. return $this->txtLoginCount;
  585. case 'LoginCountLabel':
  586. if (!$this->lblLoginCount) return $this->lblLoginCount_Create();
  587. return $this->lblLoginCount;
  588. case 'OnlineControl':
  589. if (!$this->chkOnline) return $this->chkOnline_Create();
  590. return $this->chkOnline;
  591. case 'OnlineLabel':
  592. if (!$this->lblOnline) return $this->lblOnline_Create();
  593. return $this->lblOnline;
  594. case 'OnetimePasswordControl':
  595. if (!$this->chkOnetimePassword) return $this->chkOnetimePassword_Create();
  596. return $this->chkOnetimePassword;
  597. case 'OnetimePasswordLabel':
  598. if (!$this->lblOnetimePassword) return $this->lblOnetimePassword_Create();
  599. return $this->lblOnetimePassword;
  600. case 'ValidPasswordControl':
  601. if (!$this->chkValidPassword) return $this->chkValidPassword_Create();
  602. return $this->chkValidPassword;
  603. case 'ValidPasswordLabel':
  604. if (!$this->lblValidPassword) return $this->lblValidPassword_Create();
  605. return $this->lblValidPassword;
  606. case 'TypeIdControl':
  607. if (!$this->lstType) return $this->lstType_Create();
  608. return $this->lstType;
  609. case 'TypeIdLabel':
  610. if (!$this->lblTypeId) return $this->lblTypeId_Create();
  611. return $this->lblTypeId;
  612. case 'StatusIdControl':
  613. if (!$this->lstStatus) return $this->lstStatus_Create();
  614. return $this->lstStatus;
  615. case 'StatusIdLabel':
  616. if (!$this->lblStatusId) return $this->lblStatusId_Create();
  617. return $this->lblStatusId;
  618. case 'PersonIdControl':
  619. if (!$this->lstPerson) return $this->lstPerson_Create();
  620. return $this->lstPerson;
  621. case 'PersonIdLabel':
  622. if (!$this->lblPersonId) return $this->lblPersonId_Create();
  623. return $this->lblPersonId;
  624. default:
  625. try {
  626. return parent::__get($strName);
  627. } catch (QCallerException $objExc) {
  628. $objExc->IncrementOffset();
  629. throw $objExc;
  630. }
  631. }
  632. }
  633. /**
  634. * Override method to perform a property "Set"
  635. * This will set the property $strName to be $mixValue
  636. *
  637. * @param string $strName Name of the property to set
  638. * @param string $mixValue New value of the property
  639. * @return mixed
  640. */
  641. public function __set($strName, $mixValue) {
  642. try {
  643. switch ($strName) {
  644. // Controls that point to Account fields
  645. case 'IdControl':
  646. return ($this->lblId = QType::Cast($mixValue, 'QControl'));
  647. case 'RegistrationDateControl':
  648. return ($this->lblRegistrationDate = QType::Cast($mixValue, 'QControl'));
  649. case 'UsernameControl':
  650. return ($this->txtUsername = QType::Cast($mixValue, 'QControl'));
  651. case 'PasswordControl':
  652. return ($this->txtPassword = QType::Cast($mixValue, 'QControl'));
  653. case 'NotesControl':
  654. return ($this->txtNotes = QType::Cast($mixValue, 'QControl'));
  655. case 'LastLoginControl':
  656. return ($this->lblLastLogin = QType::Cast($mixValue, 'QControl'));
  657. case 'LoginCountControl':
  658. return ($this->txtLoginCount = QType::Cast($mixValue, 'QControl'));
  659. case 'OnlineControl':
  660. return ($this->chkOnline = QType::Cast($mixValue, 'QControl'));
  661. case 'OnetimePasswordControl':
  662. return ($this->chkOnetimePassword = QType::Cast($mixValue, 'QControl'));
  663. case 'ValidPasswordControl':
  664. return ($this->chkValidPassword = QType::Cast($mixValue, 'QControl'));
  665. case 'TypeIdControl':
  666. return ($this->lstType = QType::Cast($mixValue, 'QControl'));
  667. case 'StatusIdControl':
  668. return ($this->lstStatus = QType::Cast($mixValue, 'QControl'));
  669. case 'PersonIdControl':
  670. return ($this->lstPerson = QType::Cast($mixValue, 'QControl'));
  671. default:
  672. return parent::__set($strName, $mixValue);
  673. }
  674. } catch (QCallerException $objExc) {
  675. $objExc->IncrementOffset();
  676. throw $objExc;
  677. }
  678. }
  679. }
  680. ?>