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.

844 lines
40 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 Person 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 Person 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 PersonMetaControl
  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 Person $Person the actual Person data class being edited
  19. * property QLabel $IdControl
  20. * property-read QLabel $IdLabel
  21. * property QTextBox $NamePrefixControl
  22. * property-read QLabel $NamePrefixLabel
  23. * property QTextBox $FirstNameControl
  24. * property-read QLabel $FirstNameLabel
  25. * property QTextBox $MiddleNameControl
  26. * property-read QLabel $MiddleNameLabel
  27. * property QTextBox $LastNameControl
  28. * property-read QLabel $LastNameLabel
  29. * property QTextBox $NameSuffixControl
  30. * property-read QLabel $NameSuffixLabel
  31. * property QTextBox $NickNameControl
  32. * property-read QLabel $NickNameLabel
  33. * property QTextBox $AvatarUriControl
  34. * property-read QLabel $AvatarUriLabel
  35. * property QTextBox $CompanyNameControl
  36. * property-read QLabel $CompanyNameLabel
  37. * property QListBox $OwnerPersonIdControl
  38. * property-read QLabel $OwnerPersonIdLabel
  39. * property QCheckBox $IsVirtualControl
  40. * property-read QLabel $IsVirtualLabel
  41. * property QListBox $AccountControl
  42. * property-read QLabel $AccountLabel
  43. * property QListBox $UsergroupControl
  44. * property-read QLabel $UsergroupLabel
  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 PersonMetaControlGen extends QBaseClass {
  49. // General Variables
  50. protected $objPerson;
  51. protected $objParentObject;
  52. protected $strTitleVerb;
  53. protected $blnEditMode;
  54. // Controls that allow the editing of Person's individual data fields
  55. protected $lblId;
  56. protected $txtNamePrefix;
  57. protected $txtFirstName;
  58. protected $txtMiddleName;
  59. protected $txtLastName;
  60. protected $txtNameSuffix;
  61. protected $txtNickName;
  62. protected $txtAvatarUri;
  63. protected $txtCompanyName;
  64. protected $lstOwnerPerson;
  65. protected $chkIsVirtual;
  66. // Controls that allow the viewing of Person's individual data fields
  67. protected $lblNamePrefix;
  68. protected $lblFirstName;
  69. protected $lblMiddleName;
  70. protected $lblLastName;
  71. protected $lblNameSuffix;
  72. protected $lblNickName;
  73. protected $lblAvatarUri;
  74. protected $lblCompanyName;
  75. protected $lblOwnerPersonId;
  76. protected $lblIsVirtual;
  77. // QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References
  78. protected $lstAccount;
  79. protected $lstUsergroups;
  80. // QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References
  81. protected $lblAccount;
  82. protected $lblUsergroups;
  83. /**
  84. * Main constructor. Constructor OR static create methods are designed to be called in either
  85. * a parent QPanel or the main QForm when wanting to create a
  86. * PersonMetaControl to edit a single Person object within the
  87. * QPanel or QForm.
  88. *
  89. * This constructor takes in a single Person object, while any of the static
  90. * create methods below can be used to construct based off of individual PK ID(s).
  91. *
  92. * @param mixed $objParentObject QForm or QPanel which will be using this PersonMetaControl
  93. * @param Person $objPerson new or existing Person object
  94. */
  95. public function __construct($objParentObject, Person $objPerson) {
  96. // Setup Parent Object (e.g. QForm or QPanel which will be using this PersonMetaControl)
  97. $this->objParentObject = $objParentObject;
  98. // Setup linked Person object
  99. $this->objPerson = $objPerson;
  100. // Figure out if we're Editing or Creating New
  101. if ($this->objPerson->__Restored) {
  102. $this->strTitleVerb = QApplication::Translate('Edit');
  103. $this->blnEditMode = true;
  104. } else {
  105. $this->strTitleVerb = QApplication::Translate('Create');
  106. $this->blnEditMode = false;
  107. }
  108. }
  109. /**
  110. * Static Helper Method to Create using PK arguments
  111. * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  112. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  113. * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to
  114. * edit, or if we are also allowed to create a new one, etc.
  115. *
  116. * @param mixed $objParentObject QForm or QPanel which will be using this PersonMetaControl
  117. * @param integer $intId primary key value
  118. * @param QMetaControlCreateType $intCreateType rules governing Person object creation - defaults to CreateOrEdit
  119. * @return PersonMetaControl
  120. */
  121. public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  122. // Attempt to Load from PK Arguments
  123. if (strlen($intId)) {
  124. $objPerson = Person::Load($intId);
  125. // Person was found -- return it!
  126. if ($objPerson)
  127. return new PersonMetaControl($objParentObject, $objPerson);
  128. // If CreateOnRecordNotFound not specified, throw an exception
  129. else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
  130. throw new QCallerException('Could not find a Person object with PK arguments: ' . $intId);
  131. // If EditOnly is specified, throw an exception
  132. } else if ($intCreateType == QMetaControlCreateType::EditOnly)
  133. throw new QCallerException('No PK arguments specified');
  134. // If we are here, then we need to create a new record
  135. return new PersonMetaControl($objParentObject, new Person());
  136. }
  137. /**
  138. * Static Helper Method to Create using PathInfo arguments
  139. *
  140. * @param mixed $objParentObject QForm or QPanel which will be using this PersonMetaControl
  141. * @param QMetaControlCreateType $intCreateType rules governing Person object creation - defaults to CreateOrEdit
  142. * @return PersonMetaControl
  143. */
  144. public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  145. $intId = QApplication::PathInfo(0);
  146. return PersonMetaControl::Create($objParentObject, $intId, $intCreateType);
  147. }
  148. /**
  149. * Static Helper Method to Create using QueryString arguments
  150. *
  151. * @param mixed $objParentObject QForm or QPanel which will be using this PersonMetaControl
  152. * @param QMetaControlCreateType $intCreateType rules governing Person object creation - defaults to CreateOrEdit
  153. * @return PersonMetaControl
  154. */
  155. public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
  156. $intId = QApplication::QueryString('intId');
  157. return PersonMetaControl::Create($objParentObject, $intId, $intCreateType);
  158. }
  159. ///////////////////////////////////////////////
  160. // PUBLIC CREATE and REFRESH METHODS
  161. ///////////////////////////////////////////////
  162. /**
  163. * Create and setup QLabel lblId
  164. * @param string $strControlId optional ControlId to use
  165. * @return QLabel
  166. */
  167. public function lblId_Create($strControlId = null) {
  168. $this->lblId = new QLabel($this->objParentObject, $strControlId);
  169. $this->lblId->Name = QApplication::Translate('Id');
  170. if ($this->blnEditMode)
  171. $this->lblId->Text = $this->objPerson->Id;
  172. else
  173. $this->lblId->Text = 'N/A';
  174. return $this->lblId;
  175. }
  176. /**
  177. * Create and setup QTextBox txtNamePrefix
  178. * @param string $strControlId optional ControlId to use
  179. * @return QTextBox
  180. */
  181. public function txtNamePrefix_Create($strControlId = null) {
  182. $this->txtNamePrefix = new QTextBox($this->objParentObject, $strControlId);
  183. $this->txtNamePrefix->Name = QApplication::Translate('Name Prefix');
  184. $this->txtNamePrefix->Text = $this->objPerson->NamePrefix;
  185. $this->txtNamePrefix->MaxLength = Person::NamePrefixMaxLength;
  186. return $this->txtNamePrefix;
  187. }
  188. /**
  189. * Create and setup QLabel lblNamePrefix
  190. * @param string $strControlId optional ControlId to use
  191. * @return QLabel
  192. */
  193. public function lblNamePrefix_Create($strControlId = null) {
  194. $this->lblNamePrefix = new QLabel($this->objParentObject, $strControlId);
  195. $this->lblNamePrefix->Name = QApplication::Translate('Name Prefix');
  196. $this->lblNamePrefix->Text = $this->objPerson->NamePrefix;
  197. return $this->lblNamePrefix;
  198. }
  199. /**
  200. * Create and setup QTextBox txtFirstName
  201. * @param string $strControlId optional ControlId to use
  202. * @return QTextBox
  203. */
  204. public function txtFirstName_Create($strControlId = null) {
  205. $this->txtFirstName = new QTextBox($this->objParentObject, $strControlId);
  206. $this->txtFirstName->Name = QApplication::Translate('First Name');
  207. $this->txtFirstName->Text = $this->objPerson->FirstName;
  208. $this->txtFirstName->Required = true;
  209. $this->txtFirstName->MaxLength = Person::FirstNameMaxLength;
  210. return $this->txtFirstName;
  211. }
  212. /**
  213. * Create and setup QLabel lblFirstName
  214. * @param string $strControlId optional ControlId to use
  215. * @return QLabel
  216. */
  217. public function lblFirstName_Create($strControlId = null) {
  218. $this->lblFirstName = new QLabel($this->objParentObject, $strControlId);
  219. $this->lblFirstName->Name = QApplication::Translate('First Name');
  220. $this->lblFirstName->Text = $this->objPerson->FirstName;
  221. $this->lblFirstName->Required = true;
  222. return $this->lblFirstName;
  223. }
  224. /**
  225. * Create and setup QTextBox txtMiddleName
  226. * @param string $strControlId optional ControlId to use
  227. * @return QTextBox
  228. */
  229. public function txtMiddleName_Create($strControlId = null) {
  230. $this->txtMiddleName = new QTextBox($this->objParentObject, $strControlId);
  231. $this->txtMiddleName->Name = QApplication::Translate('Middle Name');
  232. $this->txtMiddleName->Text = $this->objPerson->MiddleName;
  233. $this->txtMiddleName->MaxLength = Person::MiddleNameMaxLength;
  234. return $this->txtMiddleName;
  235. }
  236. /**
  237. * Create and setup QLabel lblMiddleName
  238. * @param string $strControlId optional ControlId to use
  239. * @return QLabel
  240. */
  241. public function lblMiddleName_Create($strControlId = null) {
  242. $this->lblMiddleName = new QLabel($this->objParentObject, $strControlId);
  243. $this->lblMiddleName->Name = QApplication::Translate('Middle Name');
  244. $this->lblMiddleName->Text = $this->objPerson->MiddleName;
  245. return $this->lblMiddleName;
  246. }
  247. /**
  248. * Create and setup QTextBox txtLastName
  249. * @param string $strControlId optional ControlId to use
  250. * @return QTextBox
  251. */
  252. public function txtLastName_Create($strControlId = null) {
  253. $this->txtLastName = new QTextBox($this->objParentObject, $strControlId);
  254. $this->txtLastName->Name = QApplication::Translate('Last Name');
  255. $this->txtLastName->Text = $this->objPerson->LastName;
  256. $this->txtLastName->Required = true;
  257. $this->txtLastName->MaxLength = Person::LastNameMaxLength;
  258. return $this->txtLastName;
  259. }
  260. /**
  261. * Create and setup QLabel lblLastName
  262. * @param string $strControlId optional ControlId to use
  263. * @return QLabel
  264. */
  265. public function lblLastName_Create($strControlId = null) {
  266. $this->lblLastName = new QLabel($this->objParentObject, $strControlId);
  267. $this->lblLastName->Name = QApplication::Translate('Last Name');
  268. $this->lblLastName->Text = $this->objPerson->LastName;
  269. $this->lblLastName->Required = true;
  270. return $this->lblLastName;
  271. }
  272. /**
  273. * Create and setup QTextBox txtNameSuffix
  274. * @param string $strControlId optional ControlId to use
  275. * @return QTextBox
  276. */
  277. public function txtNameSuffix_Create($strControlId = null) {
  278. $this->txtNameSuffix = new QTextBox($this->objParentObject, $strControlId);
  279. $this->txtNameSuffix->Name = QApplication::Translate('Name Suffix');
  280. $this->txtNameSuffix->Text = $this->objPerson->NameSuffix;
  281. $this->txtNameSuffix->MaxLength = Person::NameSuffixMaxLength;
  282. return $this->txtNameSuffix;
  283. }
  284. /**
  285. * Create and setup QLabel lblNameSuffix
  286. * @param string $strControlId optional ControlId to use
  287. * @return QLabel
  288. */
  289. public function lblNameSuffix_Create($strControlId = null) {
  290. $this->lblNameSuffix = new QLabel($this->objParentObject, $strControlId);
  291. $this->lblNameSuffix->Name = QApplication::Translate('Name Suffix');
  292. $this->lblNameSuffix->Text = $this->objPerson->NameSuffix;
  293. return $this->lblNameSuffix;
  294. }
  295. /**
  296. * Create and setup QTextBox txtNickName
  297. * @param string $strControlId optional ControlId to use
  298. * @return QTextBox
  299. */
  300. public function txtNickName_Create($strControlId = null) {
  301. $this->txtNickName = new QTextBox($this->objParentObject, $strControlId);
  302. $this->txtNickName->Name = QApplication::Translate('Nick Name');
  303. $this->txtNickName->Text = $this->objPerson->NickName;
  304. $this->txtNickName->MaxLength = Person::NickNameMaxLength;
  305. return $this->txtNickName;
  306. }
  307. /**
  308. * Create and setup QLabel lblNickName
  309. * @param string $strControlId optional ControlId to use
  310. * @return QLabel
  311. */
  312. public function lblNickName_Create($strControlId = null) {
  313. $this->lblNickName = new QLabel($this->objParentObject, $strControlId);
  314. $this->lblNickName->Name = QApplication::Translate('Nick Name');
  315. $this->lblNickName->Text = $this->objPerson->NickName;
  316. return $this->lblNickName;
  317. }
  318. /**
  319. * Create and setup QTextBox txtAvatarUri
  320. * @param string $strControlId optional ControlId to use
  321. * @return QTextBox
  322. */
  323. public function txtAvatarUri_Create($strControlId = null) {
  324. $this->txtAvatarUri = new QTextBox($this->objParentObject, $strControlId);
  325. $this->txtAvatarUri->Name = QApplication::Translate('Avatar Uri');
  326. $this->txtAvatarUri->Text = $this->objPerson->AvatarUri;
  327. $this->txtAvatarUri->MaxLength = Person::AvatarUriMaxLength;
  328. return $this->txtAvatarUri;
  329. }
  330. /**
  331. * Create and setup QLabel lblAvatarUri
  332. * @param string $strControlId optional ControlId to use
  333. * @return QLabel
  334. */
  335. public function lblAvatarUri_Create($strControlId = null) {
  336. $this->lblAvatarUri = new QLabel($this->objParentObject, $strControlId);
  337. $this->lblAvatarUri->Name = QApplication::Translate('Avatar Uri');
  338. $this->lblAvatarUri->Text = $this->objPerson->AvatarUri;
  339. return $this->lblAvatarUri;
  340. }
  341. /**
  342. * Create and setup QTextBox txtCompanyName
  343. * @param string $strControlId optional ControlId to use
  344. * @return QTextBox
  345. */
  346. public function txtCompanyName_Create($strControlId = null) {
  347. $this->txtCompanyName = new QTextBox($this->objParentObject, $strControlId);
  348. $this->txtCompanyName->Name = QApplication::Translate('Company Name');
  349. $this->txtCompanyName->Text = $this->objPerson->CompanyName;
  350. $this->txtCompanyName->MaxLength = Person::CompanyNameMaxLength;
  351. return $this->txtCompanyName;
  352. }
  353. /**
  354. * Create and setup QLabel lblCompanyName
  355. * @param string $strControlId optional ControlId to use
  356. * @return QLabel
  357. */
  358. public function lblCompanyName_Create($strControlId = null) {
  359. $this->lblCompanyName = new QLabel($this->objParentObject, $strControlId);
  360. $this->lblCompanyName->Name = QApplication::Translate('Company Name');
  361. $this->lblCompanyName->Text = $this->objPerson->CompanyName;
  362. return $this->lblCompanyName;
  363. }
  364. /**
  365. * Create and setup QListBox lstOwnerPerson
  366. * @param string $strControlId optional ControlId to use
  367. * @return QListBox
  368. */
  369. public function lstOwnerPerson_Create($strControlId = null) {
  370. $this->lstOwnerPerson = new QListBox($this->objParentObject, $strControlId);
  371. $this->lstOwnerPerson->Name = QApplication::Translate('Owner Person');
  372. $this->lstOwnerPerson->AddItem(QApplication::Translate('- Select One -'), null);
  373. $objOwnerPersonArray = Person::LoadAll();
  374. if ($objOwnerPersonArray) foreach ($objOwnerPersonArray as $objOwnerPerson) {
  375. $objListItem = new QListItem($objOwnerPerson->__toString(), $objOwnerPerson->Id);
  376. if (($this->objPerson->OwnerPerson) && ($this->objPerson->OwnerPerson->Id == $objOwnerPerson->Id))
  377. $objListItem->Selected = true;
  378. $this->lstOwnerPerson->AddItem($objListItem);
  379. }
  380. return $this->lstOwnerPerson;
  381. }
  382. /**
  383. * Create and setup QLabel lblOwnerPersonId
  384. * @param string $strControlId optional ControlId to use
  385. * @return QLabel
  386. */
  387. public function lblOwnerPersonId_Create($strControlId = null) {
  388. $this->lblOwnerPersonId = new QLabel($this->objParentObject, $strControlId);
  389. $this->lblOwnerPersonId->Name = QApplication::Translate('Owner Person');
  390. $this->lblOwnerPersonId->Text = ($this->objPerson->OwnerPerson) ? $this->objPerson->OwnerPerson->__toString() : null;
  391. return $this->lblOwnerPersonId;
  392. }
  393. /**
  394. * Create and setup QCheckBox chkIsVirtual
  395. * @param string $strControlId optional ControlId to use
  396. * @return QCheckBox
  397. */
  398. public function chkIsVirtual_Create($strControlId = null) {
  399. $this->chkIsVirtual = new QCheckBox($this->objParentObject, $strControlId);
  400. $this->chkIsVirtual->Name = QApplication::Translate('Is Virtual');
  401. $this->chkIsVirtual->Checked = $this->objPerson->IsVirtual;
  402. return $this->chkIsVirtual;
  403. }
  404. /**
  405. * Create and setup QLabel lblIsVirtual
  406. * @param string $strControlId optional ControlId to use
  407. * @return QLabel
  408. */
  409. public function lblIsVirtual_Create($strControlId = null) {
  410. $this->lblIsVirtual = new QLabel($this->objParentObject, $strControlId);
  411. $this->lblIsVirtual->Name = QApplication::Translate('Is Virtual');
  412. $this->lblIsVirtual->Text = ($this->objPerson->IsVirtual) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  413. return $this->lblIsVirtual;
  414. }
  415. /**
  416. * Create and setup QListBox lstAccount
  417. * @param string $strControlId optional ControlId to use
  418. * @return QListBox
  419. */
  420. public function lstAccount_Create($strControlId = null) {
  421. $this->lstAccount = new QListBox($this->objParentObject, $strControlId);
  422. $this->lstAccount->Name = QApplication::Translate('Account');
  423. $this->lstAccount->AddItem(QApplication::Translate('- Select One -'), null);
  424. $objAccountArray = Account::LoadAll();
  425. if ($objAccountArray) foreach ($objAccountArray as $objAccount) {
  426. $objListItem = new QListItem($objAccount->__toString(), $objAccount->Id);
  427. if ($objAccount->PersonId == $this->objPerson->Id)
  428. $objListItem->Selected = true;
  429. $this->lstAccount->AddItem($objListItem);
  430. }
  431. // Because Account's Account is not null, if a value is already selected, it cannot be changed.
  432. if ($this->lstAccount->SelectedValue)
  433. $this->lstAccount->Enabled = false;
  434. return $this->lstAccount;
  435. }
  436. /**
  437. * Create and setup QLabel lblAccount
  438. * @param string $strControlId optional ControlId to use
  439. * @return QLabel
  440. */
  441. public function lblAccount_Create($strControlId = null) {
  442. $this->lblAccount = new QLabel($this->objParentObject, $strControlId);
  443. $this->lblAccount->Name = QApplication::Translate('Account');
  444. $this->lblAccount->Text = ($this->objPerson->Account) ? $this->objPerson->Account->__toString() : null;
  445. return $this->lblAccount;
  446. }
  447. /**
  448. * Create and setup QListBox lstUsergroups
  449. * @param string $strControlId optional ControlId to use
  450. * @return QListBox
  451. */
  452. public function lstUsergroups_Create($strControlId = null) {
  453. $this->lstUsergroups = new QListBox($this->objParentObject, $strControlId);
  454. $this->lstUsergroups->Name = QApplication::Translate('Usergroups');
  455. $this->lstUsergroups->SelectionMode = QSelectionMode::Multiple;
  456. $objAssociatedArray = $this->objPerson->GetUsergroupArray();
  457. $objUsergroupArray = Usergroup::LoadAll();
  458. if ($objUsergroupArray) foreach ($objUsergroupArray as $objUsergroup) {
  459. $objListItem = new QListItem($objUsergroup->__toString(), $objUsergroup->Id);
  460. foreach ($objAssociatedArray as $objAssociated) {
  461. if ($objAssociated->Id == $objUsergroup->Id)
  462. $objListItem->Selected = true;
  463. }
  464. $this->lstUsergroups->AddItem($objListItem);
  465. }
  466. return $this->lstUsergroups;
  467. }
  468. /**
  469. * Create and setup QLabel lblUsergroups
  470. * @param string $strControlId optional ControlId to use
  471. * @param string $strGlue glue to display in between each associated object
  472. * @return QLabel
  473. */
  474. public function lblUsergroups_Create($strControlId = null, $strGlue = ', ') {
  475. $this->lblUsergroups = new QLabel($this->objParentObject, $strControlId);
  476. $this->lblUsergroups->Name = QApplication::Translate('Usergroups');
  477. $objAssociatedArray = $this->objPerson->GetUsergroupArray();
  478. $strItems = array();
  479. foreach ($objAssociatedArray as $objAssociated)
  480. $strItems[] = $objAssociated->__toString();
  481. $this->lblUsergroups->Text = implode($strGlue, $strItems);
  482. return $this->lblUsergroups;
  483. }
  484. /**
  485. * Refresh this MetaControl with Data from the local Person object.
  486. * @param boolean $blnReload reload Person from the database
  487. * @return void
  488. */
  489. public function Refresh($blnReload = false) {
  490. if ($blnReload)
  491. $this->objPerson->Reload();
  492. if ($this->lblId) if ($this->blnEditMode) $this->lblId->Text = $this->objPerson->Id;
  493. if ($this->txtNamePrefix) $this->txtNamePrefix->Text = $this->objPerson->NamePrefix;
  494. if ($this->lblNamePrefix) $this->lblNamePrefix->Text = $this->objPerson->NamePrefix;
  495. if ($this->txtFirstName) $this->txtFirstName->Text = $this->objPerson->FirstName;
  496. if ($this->lblFirstName) $this->lblFirstName->Text = $this->objPerson->FirstName;
  497. if ($this->txtMiddleName) $this->txtMiddleName->Text = $this->objPerson->MiddleName;
  498. if ($this->lblMiddleName) $this->lblMiddleName->Text = $this->objPerson->MiddleName;
  499. if ($this->txtLastName) $this->txtLastName->Text = $this->objPerson->LastName;
  500. if ($this->lblLastName) $this->lblLastName->Text = $this->objPerson->LastName;
  501. if ($this->txtNameSuffix) $this->txtNameSuffix->Text = $this->objPerson->NameSuffix;
  502. if ($this->lblNameSuffix) $this->lblNameSuffix->Text = $this->objPerson->NameSuffix;
  503. if ($this->txtNickName) $this->txtNickName->Text = $this->objPerson->NickName;
  504. if ($this->lblNickName) $this->lblNickName->Text = $this->objPerson->NickName;
  505. if ($this->txtAvatarUri) $this->txtAvatarUri->Text = $this->objPerson->AvatarUri;
  506. if ($this->lblAvatarUri) $this->lblAvatarUri->Text = $this->objPerson->AvatarUri;
  507. if ($this->txtCompanyName) $this->txtCompanyName->Text = $this->objPerson->CompanyName;
  508. if ($this->lblCompanyName) $this->lblCompanyName->Text = $this->objPerson->CompanyName;
  509. if ($this->lstOwnerPerson) {
  510. $this->lstOwnerPerson->RemoveAllItems();
  511. $this->lstOwnerPerson->AddItem(QApplication::Translate('- Select One -'), null);
  512. $objOwnerPersonArray = Person::LoadAll();
  513. if ($objOwnerPersonArray) foreach ($objOwnerPersonArray as $objOwnerPerson) {
  514. $objListItem = new QListItem($objOwnerPerson->__toString(), $objOwnerPerson->Id);
  515. if (($this->objPerson->OwnerPerson) && ($this->objPerson->OwnerPerson->Id == $objOwnerPerson->Id))
  516. $objListItem->Selected = true;
  517. $this->lstOwnerPerson->AddItem($objListItem);
  518. }
  519. }
  520. if ($this->lblOwnerPersonId) $this->lblOwnerPersonId->Text = ($this->objPerson->OwnerPerson) ? $this->objPerson->OwnerPerson->__toString() : null;
  521. if ($this->chkIsVirtual) $this->chkIsVirtual->Checked = $this->objPerson->IsVirtual;
  522. if ($this->lblIsVirtual) $this->lblIsVirtual->Text = ($this->objPerson->IsVirtual) ? QApplication::Translate('Yes') : QApplication::Translate('No');
  523. if ($this->lstAccount) {
  524. $this->lstAccount->RemoveAllItems();
  525. $this->lstAccount->AddItem(QApplication::Translate('- Select One -'), null);
  526. $objAccountArray = Account::LoadAll();
  527. if ($objAccountArray) foreach ($objAccountArray as $objAccount) {
  528. $objListItem = new QListItem($objAccount->__toString(), $objAccount->Id);
  529. if ($objAccount->PersonId == $this->objPerson->Id)
  530. $objListItem->Selected = true;
  531. $this->lstAccount->AddItem($objListItem);
  532. }
  533. // Because Account's Account is not null, if a value is already selected, it cannot be changed.
  534. if ($this->lstAccount->SelectedValue)
  535. $this->lstAccount->Enabled = false;
  536. else
  537. $this->lstAccount->Enabled = true;
  538. }
  539. if ($this->lblAccount) $this->lblAccount->Text = ($this->objPerson->Account) ? $this->objPerson->Account->__toString() : null;
  540. if ($this->lstUsergroups) {
  541. $this->lstUsergroups->RemoveAllItems();
  542. $objAssociatedArray = $this->objPerson->GetUsergroupArray();
  543. $objUsergroupArray = Usergroup::LoadAll();
  544. if ($objUsergroupArray) foreach ($objUsergroupArray as $objUsergroup) {
  545. $objListItem = new QListItem($objUsergroup->__toString(), $objUsergroup->Id);
  546. foreach ($objAssociatedArray as $objAssociated) {
  547. if ($objAssociated->Id == $objUsergroup->Id)
  548. $objListItem->Selected = true;
  549. }
  550. $this->lstUsergroups->AddItem($objListItem);
  551. }
  552. }
  553. if ($this->lblUsergroups) {
  554. $objAssociatedArray = $this->objPerson->GetUsergroupArray();
  555. $strItems = array();
  556. foreach ($objAssociatedArray as $objAssociated)
  557. $strItems[] = $objAssociated->__toString();
  558. $this->lblUsergroups->Text = implode($strGlue, $strItems);
  559. }
  560. }
  561. ///////////////////////////////////////////////
  562. // PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
  563. ///////////////////////////////////////////////
  564. protected function lstUsergroups_Update() {
  565. if ($this->lstUsergroups) {
  566. $this->objPerson->UnassociateAllUsergroups();
  567. $objSelectedListItems = $this->lstUsergroups->SelectedItems;
  568. if ($objSelectedListItems) foreach ($objSelectedListItems as $objListItem) {
  569. $this->objPerson->AssociateUsergroup(Usergroup::Load($objListItem->Value));
  570. }
  571. }
  572. }
  573. ///////////////////////////////////////////////
  574. // PUBLIC PERSON OBJECT MANIPULATORS
  575. ///////////////////////////////////////////////
  576. /**
  577. * This will save this object's Person instance,
  578. * updating only the fields which have had a control created for it.
  579. */
  580. public function SavePerson() {
  581. try {
  582. // Update any fields for controls that have been created
  583. if ($this->txtNamePrefix) $this->objPerson->NamePrefix = $this->txtNamePrefix->Text;
  584. if ($this->txtFirstName) $this->objPerson->FirstName = $this->txtFirstName->Text;
  585. if ($this->txtMiddleName) $this->objPerson->MiddleName = $this->txtMiddleName->Text;
  586. if ($this->txtLastName) $this->objPerson->LastName = $this->txtLastName->Text;
  587. if ($this->txtNameSuffix) $this->objPerson->NameSuffix = $this->txtNameSuffix->Text;
  588. if ($this->txtNickName) $this->objPerson->NickName = $this->txtNickName->Text;
  589. if ($this->txtAvatarUri) $this->objPerson->AvatarUri = $this->txtAvatarUri->Text;
  590. if ($this->txtCompanyName) $this->objPerson->CompanyName = $this->txtCompanyName->Text;
  591. if ($this->lstOwnerPerson) $this->objPerson->OwnerPersonId = $this->lstOwnerPerson->SelectedValue;
  592. if ($this->chkIsVirtual) $this->objPerson->IsVirtual = $this->chkIsVirtual->Checked;
  593. // Update any UniqueReverseReferences (if any) for controls that have been created for it
  594. if ($this->lstAccount) $this->objPerson->Account = Account::Load($this->lstAccount->SelectedValue);
  595. // Save the Person object
  596. $this->objPerson->Save();
  597. // Finally, update any ManyToManyReferences (if any)
  598. $this->lstUsergroups_Update();
  599. } catch (QCallerException $objExc) {
  600. $objExc->IncrementOffset();
  601. throw $objExc;
  602. }
  603. }
  604. /**
  605. * This will DELETE this object's Person instance from the database.
  606. * It will also unassociate itself from any ManyToManyReferences.
  607. */
  608. public function DeletePerson() {
  609. $this->objPerson->UnassociateAllUsergroups();
  610. $this->objPerson->Delete();
  611. }
  612. ///////////////////////////////////////////////
  613. // PUBLIC GETTERS and SETTERS
  614. ///////////////////////////////////////////////
  615. /**
  616. * Override method to perform a property "Get"
  617. * This will get the value of $strName
  618. *
  619. * @param string $strName Name of the property to get
  620. * @return mixed
  621. */
  622. public function __get($strName) {
  623. switch ($strName) {
  624. // General MetaControlVariables
  625. case 'Person': return $this->objPerson;
  626. case 'TitleVerb': return $this->strTitleVerb;
  627. case 'EditMode': return $this->blnEditMode;
  628. // Controls that point to Person fields -- will be created dynamically if not yet created
  629. case 'IdControl':
  630. if (!$this->lblId) return $this->lblId_Create();
  631. return $this->lblId;
  632. case 'IdLabel':
  633. if (!$this->lblId) return $this->lblId_Create();
  634. return $this->lblId;
  635. case 'NamePrefixControl':
  636. if (!$this->txtNamePrefix) return $this->txtNamePrefix_Create();
  637. return $this->txtNamePrefix;
  638. case 'NamePrefixLabel':
  639. if (!$this->lblNamePrefix) return $this->lblNamePrefix_Create();
  640. return $this->lblNamePrefix;
  641. case 'FirstNameControl':
  642. if (!$this->txtFirstName) return $this->txtFirstName_Create();
  643. return $this->txtFirstName;
  644. case 'FirstNameLabel':
  645. if (!$this->lblFirstName) return $this->lblFirstName_Create();
  646. return $this->lblFirstName;
  647. case 'MiddleNameControl':
  648. if (!$this->txtMiddleName) return $this->txtMiddleName_Create();
  649. return $this->txtMiddleName;
  650. case 'MiddleNameLabel':
  651. if (!$this->lblMiddleName) return $this->lblMiddleName_Create();
  652. return $this->lblMiddleName;
  653. case 'LastNameControl':
  654. if (!$this->txtLastName) return $this->txtLastName_Create();
  655. return $this->txtLastName;
  656. case 'LastNameLabel':
  657. if (!$this->lblLastName) return $this->lblLastName_Create();
  658. return $this->lblLastName;
  659. case 'NameSuffixControl':
  660. if (!$this->txtNameSuffix) return $this->txtNameSuffix_Create();
  661. return $this->txtNameSuffix;
  662. case 'NameSuffixLabel':
  663. if (!$this->lblNameSuffix) return $this->lblNameSuffix_Create();
  664. return $this->lblNameSuffix;
  665. case 'NickNameControl':
  666. if (!$this->txtNickName) return $this->txtNickName_Create();
  667. return $this->txtNickName;
  668. case 'NickNameLabel':
  669. if (!$this->lblNickName) return $this->lblNickName_Create();
  670. return $this->lblNickName;
  671. case 'AvatarUriControl':
  672. if (!$this->txtAvatarUri) return $this->txtAvatarUri_Create();
  673. return $this->txtAvatarUri;
  674. case 'AvatarUriLabel':
  675. if (!$this->lblAvatarUri) return $this->lblAvatarUri_Create();
  676. return $this->lblAvatarUri;
  677. case 'CompanyNameControl':
  678. if (!$this->txtCompanyName) return $this->txtCompanyName_Create();
  679. return $this->txtCompanyName;
  680. case 'CompanyNameLabel':
  681. if (!$this->lblCompanyName) return $this->lblCompanyName_Create();
  682. return $this->lblCompanyName;
  683. case 'OwnerPersonIdControl':
  684. if (!$this->lstOwnerPerson) return $this->lstOwnerPerson_Create();
  685. return $this->lstOwnerPerson;
  686. case 'OwnerPersonIdLabel':
  687. if (!$this->lblOwnerPersonId) return $this->lblOwnerPersonId_Create();
  688. return $this->lblOwnerPersonId;
  689. case 'IsVirtualControl':
  690. if (!$this->chkIsVirtual) return $this->chkIsVirtual_Create();
  691. return $this->chkIsVirtual;
  692. case 'IsVirtualLabel':
  693. if (!$this->lblIsVirtual) return $this->lblIsVirtual_Create();
  694. return $this->lblIsVirtual;
  695. case 'AccountControl':
  696. if (!$this->lstAccount) return $this->lstAccount_Create();
  697. return $this->lstAccount;
  698. case 'AccountLabel':
  699. if (!$this->lblAccount) return $this->lblAccount_Create();
  700. return $this->lblAccount;
  701. case 'UsergroupControl':
  702. if (!$this->lstUsergroups) return $this->lstUsergroups_Create();
  703. return $this->lstUsergroups;
  704. case 'UsergroupLabel':
  705. if (!$this->lblUsergroups) return $this->lblUsergroups_Create();
  706. return $this->lblUsergroups;
  707. default:
  708. try {
  709. return parent::__get($strName);
  710. } catch (QCallerException $objExc) {
  711. $objExc->IncrementOffset();
  712. throw $objExc;
  713. }
  714. }
  715. }
  716. /**
  717. * Override method to perform a property "Set"
  718. * This will set the property $strName to be $mixValue
  719. *
  720. * @param string $strName Name of the property to set
  721. * @param string $mixValue New value of the property
  722. * @return mixed
  723. */
  724. public function __set($strName, $mixValue) {
  725. try {
  726. switch ($strName) {
  727. // Controls that point to Person fields
  728. case 'IdControl':
  729. return ($this->lblId = QType::Cast($mixValue, 'QControl'));
  730. case 'NamePrefixControl':
  731. return ($this->txtNamePrefix = QType::Cast($mixValue, 'QControl'));
  732. case 'FirstNameControl':
  733. return ($this->txtFirstName = QType::Cast($mixValue, 'QControl'));
  734. case 'MiddleNameControl':
  735. return ($this->txtMiddleName = QType::Cast($mixValue, 'QControl'));
  736. case 'LastNameControl':
  737. return ($this->txtLastName = QType::Cast($mixValue, 'QControl'));
  738. case 'NameSuffixControl':
  739. return ($this->txtNameSuffix = QType::Cast($mixValue, 'QControl'));
  740. case 'NickNameControl':
  741. return ($this->txtNickName = QType::Cast($mixValue, 'QControl'));
  742. case 'AvatarUriControl':
  743. return ($this->txtAvatarUri = QType::Cast($mixValue, 'QControl'));
  744. case 'CompanyNameControl':
  745. return ($this->txtCompanyName = QType::Cast($mixValue, 'QControl'));
  746. case 'OwnerPersonIdControl':
  747. return ($this->lstOwnerPerson = QType::Cast($mixValue, 'QControl'));
  748. case 'IsVirtualControl':
  749. return ($this->chkIsVirtual = QType::Cast($mixValue, 'QControl'));
  750. case 'AccountControl':
  751. return ($this->lstAccount = QType::Cast($mixValue, 'QControl'));
  752. case 'UsergroupControl':
  753. return ($this->lstUsergroups = QType::Cast($mixValue, 'QControl'));
  754. default:
  755. return parent::__set($strName, $mixValue);
  756. }
  757. } catch (QCallerException $objExc) {
  758. $objExc->IncrementOffset();
  759. throw $objExc;
  760. }
  761. }
  762. }
  763. ?>