PageRenderTime 56ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/dmCorePlugin/test/project/lib/form/doctrine/dmUserPlugin/base/BaseDmUserForm.class.php

https://github.com/66Ton99/diem
PHP | 877 lines | 693 code | 129 blank | 55 comment | 132 complexity | 855d3cbd5e1dfd2950a1aca7d076224b MD5 | raw file
Possible License(s): ISC, BSD-3-Clause
  1. <?php
  2. /**
  3. * DmUser form base class.
  4. *
  5. * @method DmUser getObject() Returns the current form's model object
  6. *
  7. * @package retest
  8. * @subpackage form
  9. * @author Your name here
  10. * @version SVN: $Id$
  11. * @generator Diem 5.4.0-DEV
  12. */
  13. abstract class BaseDmUserForm extends BaseFormDoctrine
  14. {
  15. public function setup()
  16. {
  17. parent::setup();
  18. //column
  19. if($this->needsWidget('id')){
  20. $this->setWidget('id', new sfWidgetFormInputHidden());
  21. $this->setValidator('id', new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)));
  22. }
  23. //column
  24. if($this->needsWidget('username')){
  25. $this->setWidget('username', new sfWidgetFormInputText());
  26. $this->setValidator('username', new sfValidatorString(array('max_length' => 255)));
  27. }
  28. //column
  29. if($this->needsWidget('email')){
  30. $this->setWidget('email', new sfWidgetFormInputText());
  31. $this->setValidator('email', new sfValidatorString(array('max_length' => 255)));
  32. }
  33. //column
  34. if($this->needsWidget('algorithm')){
  35. $this->setWidget('algorithm', new sfWidgetFormInputText());
  36. $this->setValidator('algorithm', new sfValidatorString(array('max_length' => 128, 'required' => false)));
  37. }
  38. //column
  39. if($this->needsWidget('salt')){
  40. $this->setWidget('salt', new sfWidgetFormInputText());
  41. $this->setValidator('salt', new sfValidatorString(array('max_length' => 128, 'required' => false)));
  42. }
  43. //column
  44. if($this->needsWidget('password')){
  45. $this->setWidget('password', new sfWidgetFormInputText());
  46. $this->setValidator('password', new sfValidatorString(array('max_length' => 128, 'required' => false)));
  47. }
  48. //column
  49. if($this->needsWidget('is_active')){
  50. $this->setWidget('is_active', new sfWidgetFormInputCheckbox());
  51. $this->setValidator('is_active', new sfValidatorBoolean(array('required' => false)));
  52. }
  53. //column
  54. if($this->needsWidget('is_super_admin')){
  55. $this->setWidget('is_super_admin', new sfWidgetFormInputCheckbox());
  56. $this->setValidator('is_super_admin', new sfValidatorBoolean(array('required' => false)));
  57. }
  58. //column
  59. if($this->needsWidget('last_login')){
  60. $this->setWidget('last_login', new sfWidgetFormDateTime());
  61. $this->setValidator('last_login', new sfValidatorDateTime(array('required' => false)));
  62. }
  63. //column
  64. if($this->needsWidget('forgot_password_code')){
  65. $this->setWidget('forgot_password_code', new sfWidgetFormInputText());
  66. $this->setValidator('forgot_password_code', new sfValidatorString(array('max_length' => 12, 'required' => false)));
  67. }
  68. //column
  69. if($this->needsWidget('created_at')){
  70. $this->setWidget('created_at', new sfWidgetFormDateTime());
  71. $this->setValidator('created_at', new sfValidatorDateTime());
  72. }
  73. //column
  74. if($this->needsWidget('updated_at')){
  75. $this->setWidget('updated_at', new sfWidgetFormDateTime());
  76. $this->setValidator('updated_at', new sfValidatorDateTime());
  77. }
  78. //many to many
  79. if($this->needsWidget('groups_list')){
  80. $this->setWidget('groups_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmGroup', 'expanded' => true)));
  81. $this->setValidator('groups_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmGroup', 'required' => false)));
  82. }
  83. //many to many
  84. if($this->needsWidget('permissions_list')){
  85. $this->setWidget('permissions_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmPermission', 'expanded' => true)));
  86. $this->setValidator('permissions_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmPermission', 'required' => false)));
  87. }
  88. //many to many
  89. if($this->needsWidget('records_list')){
  90. $this->setWidget('records_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermission', 'expanded' => true)));
  91. $this->setValidator('records_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermission', 'required' => false)));
  92. }
  93. //many to many
  94. if($this->needsWidget('records_permissions_associations_list')){
  95. $this->setWidget('records_permissions_associations_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermissionAssociation', 'expanded' => true)));
  96. $this->setValidator('records_permissions_associations_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermissionAssociation', 'required' => false)));
  97. }
  98. //one to many
  99. if($this->needsWidget('dm_lock_list')){
  100. $this->setWidget('dm_lock_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmLock', 'expanded' => true)));
  101. $this->setValidator('dm_lock_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmLock', 'required' => false)));
  102. }
  103. //one to many
  104. if($this->needsWidget('posts_list')){
  105. $this->setWidget('posts_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmTestPost', 'expanded' => true)));
  106. $this->setValidator('posts_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmTestPost', 'required' => false)));
  107. }
  108. //one to many
  109. if($this->needsWidget('dm_test_posts_list')){
  110. $this->setWidget('dm_test_posts_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmTestPost', 'expanded' => true)));
  111. $this->setValidator('dm_test_posts_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmTestPost', 'required' => false)));
  112. }
  113. //one to many
  114. if($this->needsWidget('created_dm_test_domain_translations_list')){
  115. $this->setWidget('created_dm_test_domain_translations_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmTestDomainTranslation', 'expanded' => true)));
  116. $this->setValidator('created_dm_test_domain_translations_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmTestDomainTranslation', 'required' => false)));
  117. }
  118. //one to many
  119. if($this->needsWidget('updated_dm_test_domain_translations_list')){
  120. $this->setWidget('updated_dm_test_domain_translations_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmTestDomainTranslation', 'expanded' => true)));
  121. $this->setValidator('updated_dm_test_domain_translations_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmTestDomainTranslation', 'required' => false)));
  122. }
  123. //one to many
  124. if($this->needsWidget('created_dm_test_fruits_list')){
  125. $this->setWidget('created_dm_test_fruits_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmTestFruit', 'expanded' => true)));
  126. $this->setValidator('created_dm_test_fruits_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmTestFruit', 'required' => false)));
  127. }
  128. //one to many
  129. if($this->needsWidget('updated_dm_test_fruits_list')){
  130. $this->setWidget('updated_dm_test_fruits_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmTestFruit', 'expanded' => true)));
  131. $this->setValidator('updated_dm_test_fruits_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmTestFruit', 'required' => false)));
  132. }
  133. //one to many
  134. if($this->needsWidget('dm_user_group_list')){
  135. $this->setWidget('dm_user_group_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmUserGroup', 'expanded' => true)));
  136. $this->setValidator('dm_user_group_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmUserGroup', 'required' => false)));
  137. }
  138. //one to many
  139. if($this->needsWidget('dm_user_permission_list')){
  140. $this->setWidget('dm_user_permission_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmUserPermission', 'expanded' => true)));
  141. $this->setValidator('dm_user_permission_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmUserPermission', 'required' => false)));
  142. }
  143. //one to many
  144. if($this->needsWidget('dm_record_permission_user_list')){
  145. $this->setWidget('dm_record_permission_user_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermissionUser', 'expanded' => true)));
  146. $this->setValidator('dm_record_permission_user_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermissionUser', 'required' => false)));
  147. }
  148. //one to many
  149. if($this->needsWidget('dm_record_permission_association_user_list')){
  150. $this->setWidget('dm_record_permission_association_user_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermissionAssociationUser', 'expanded' => true)));
  151. $this->setValidator('dm_record_permission_association_user_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermissionAssociationUser', 'required' => false)));
  152. }
  153. $this->validatorSchema->setPostValidator(
  154. new sfValidatorAnd(array(
  155. new sfValidatorDoctrineUnique(array('model' => 'DmUser', 'column' => array('username'))),
  156. new sfValidatorDoctrineUnique(array('model' => 'DmUser', 'column' => array('email'))),
  157. new sfValidatorDoctrineUnique(array('model' => 'DmUser', 'column' => array('forgot_password_code'))),
  158. ))
  159. );
  160. $this->widgetSchema->setNameFormat('dm_user[%s]');
  161. $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
  162. $this->setupInheritance();
  163. parent::setup();
  164. // Unset automatic fields like 'created_at', 'updated_at', 'position'
  165. // override this method in your form to keep them
  166. parent::unsetAutoFields();
  167. }
  168. protected function doBind(array $values)
  169. {
  170. parent::doBind($values);
  171. }
  172. public function processValues($values)
  173. {
  174. $values = parent::processValues($values);
  175. return $values;
  176. }
  177. protected function doUpdateObject($values)
  178. {
  179. parent::doUpdateObject($values);
  180. }
  181. public function getModelName()
  182. {
  183. return 'DmUser';
  184. }
  185. public function updateDefaultsFromObject()
  186. {
  187. parent::updateDefaultsFromObject();
  188. if (isset($this->widgetSchema['groups_list']))
  189. {
  190. $this->setDefault('groups_list', $this->object->Groups->getPrimaryKeys());
  191. }
  192. if (isset($this->widgetSchema['permissions_list']))
  193. {
  194. $this->setDefault('permissions_list', $this->object->Permissions->getPrimaryKeys());
  195. }
  196. if (isset($this->widgetSchema['records_list']))
  197. {
  198. $this->setDefault('records_list', $this->object->Records->getPrimaryKeys());
  199. }
  200. if (isset($this->widgetSchema['records_permissions_associations_list']))
  201. {
  202. $this->setDefault('records_permissions_associations_list', $this->object->RecordsPermissionsAssociations->getPrimaryKeys());
  203. }
  204. if (isset($this->widgetSchema['dm_lock_list']))
  205. {
  206. $this->setDefault('dm_lock_list', $this->object->DmLock->getPrimaryKeys());
  207. }
  208. if (isset($this->widgetSchema['posts_list']))
  209. {
  210. $this->setDefault('posts_list', $this->object->Posts->getPrimaryKeys());
  211. }
  212. if (isset($this->widgetSchema['dm_test_posts_list']))
  213. {
  214. $this->setDefault('dm_test_posts_list', $this->object->DmTestPosts->getPrimaryKeys());
  215. }
  216. if (isset($this->widgetSchema['created_dm_test_domain_translations_list']))
  217. {
  218. $this->setDefault('created_dm_test_domain_translations_list', $this->object->CreatedDmTestDomainTranslations->getPrimaryKeys());
  219. }
  220. if (isset($this->widgetSchema['updated_dm_test_domain_translations_list']))
  221. {
  222. $this->setDefault('updated_dm_test_domain_translations_list', $this->object->UpdatedDmTestDomainTranslations->getPrimaryKeys());
  223. }
  224. if (isset($this->widgetSchema['created_dm_test_fruits_list']))
  225. {
  226. $this->setDefault('created_dm_test_fruits_list', $this->object->CreatedDmTestFruits->getPrimaryKeys());
  227. }
  228. if (isset($this->widgetSchema['updated_dm_test_fruits_list']))
  229. {
  230. $this->setDefault('updated_dm_test_fruits_list', $this->object->UpdatedDmTestFruits->getPrimaryKeys());
  231. }
  232. if (isset($this->widgetSchema['dm_user_group_list']))
  233. {
  234. $this->setDefault('dm_user_group_list', $this->object->DmUserGroup->getPrimaryKeys());
  235. }
  236. if (isset($this->widgetSchema['dm_user_permission_list']))
  237. {
  238. $this->setDefault('dm_user_permission_list', $this->object->DmUserPermission->getPrimaryKeys());
  239. }
  240. if (isset($this->widgetSchema['dm_record_permission_user_list']))
  241. {
  242. $this->setDefault('dm_record_permission_user_list', $this->object->DmRecordPermissionUser->getPrimaryKeys());
  243. }
  244. if (isset($this->widgetSchema['dm_record_permission_association_user_list']))
  245. {
  246. $this->setDefault('dm_record_permission_association_user_list', $this->object->DmRecordPermissionAssociationUser->getPrimaryKeys());
  247. }
  248. }
  249. protected function doSave($con = null)
  250. {
  251. $this->saveGroupsList($con);
  252. $this->savePermissionsList($con);
  253. $this->saveRecordsList($con);
  254. $this->saveRecordsPermissionsAssociationsList($con);
  255. $this->saveDmLockList($con);
  256. $this->savePostsList($con);
  257. $this->saveDmTestPostsList($con);
  258. $this->saveCreatedDmTestDomainTranslationsList($con);
  259. $this->saveUpdatedDmTestDomainTranslationsList($con);
  260. $this->saveCreatedDmTestFruitsList($con);
  261. $this->saveUpdatedDmTestFruitsList($con);
  262. $this->saveDmUserGroupList($con);
  263. $this->saveDmUserPermissionList($con);
  264. $this->saveDmRecordPermissionUserList($con);
  265. $this->saveDmRecordPermissionAssociationUserList($con);
  266. parent::doSave($con);
  267. }
  268. public function saveGroupsList($con = null)
  269. {
  270. if (!$this->isValid())
  271. {
  272. throw $this->getErrorSchema();
  273. }
  274. if (!isset($this->widgetSchema['groups_list']))
  275. {
  276. // somebody has unset this widget
  277. return;
  278. }
  279. if (null === $con)
  280. {
  281. $con = $this->getConnection();
  282. }
  283. $existing = $this->object->Groups->getPrimaryKeys();
  284. $values = $this->getValue('groups_list');
  285. if (!is_array($values))
  286. {
  287. $values = array();
  288. }
  289. $unlink = array_diff($existing, $values);
  290. if (count($unlink))
  291. {
  292. $this->object->unlink('Groups', array_values($unlink));
  293. }
  294. $link = array_diff($values, $existing);
  295. if (count($link))
  296. {
  297. $this->object->link('Groups', array_values($link));
  298. }
  299. }
  300. public function savePermissionsList($con = null)
  301. {
  302. if (!$this->isValid())
  303. {
  304. throw $this->getErrorSchema();
  305. }
  306. if (!isset($this->widgetSchema['permissions_list']))
  307. {
  308. // somebody has unset this widget
  309. return;
  310. }
  311. if (null === $con)
  312. {
  313. $con = $this->getConnection();
  314. }
  315. $existing = $this->object->Permissions->getPrimaryKeys();
  316. $values = $this->getValue('permissions_list');
  317. if (!is_array($values))
  318. {
  319. $values = array();
  320. }
  321. $unlink = array_diff($existing, $values);
  322. if (count($unlink))
  323. {
  324. $this->object->unlink('Permissions', array_values($unlink));
  325. }
  326. $link = array_diff($values, $existing);
  327. if (count($link))
  328. {
  329. $this->object->link('Permissions', array_values($link));
  330. }
  331. }
  332. public function saveRecordsList($con = null)
  333. {
  334. if (!$this->isValid())
  335. {
  336. throw $this->getErrorSchema();
  337. }
  338. if (!isset($this->widgetSchema['records_list']))
  339. {
  340. // somebody has unset this widget
  341. return;
  342. }
  343. if (null === $con)
  344. {
  345. $con = $this->getConnection();
  346. }
  347. $existing = $this->object->Records->getPrimaryKeys();
  348. $values = $this->getValue('records_list');
  349. if (!is_array($values))
  350. {
  351. $values = array();
  352. }
  353. $unlink = array_diff($existing, $values);
  354. if (count($unlink))
  355. {
  356. $this->object->unlink('Records', array_values($unlink));
  357. }
  358. $link = array_diff($values, $existing);
  359. if (count($link))
  360. {
  361. $this->object->link('Records', array_values($link));
  362. }
  363. }
  364. public function saveRecordsPermissionsAssociationsList($con = null)
  365. {
  366. if (!$this->isValid())
  367. {
  368. throw $this->getErrorSchema();
  369. }
  370. if (!isset($this->widgetSchema['records_permissions_associations_list']))
  371. {
  372. // somebody has unset this widget
  373. return;
  374. }
  375. if (null === $con)
  376. {
  377. $con = $this->getConnection();
  378. }
  379. $existing = $this->object->RecordsPermissionsAssociations->getPrimaryKeys();
  380. $values = $this->getValue('records_permissions_associations_list');
  381. if (!is_array($values))
  382. {
  383. $values = array();
  384. }
  385. $unlink = array_diff($existing, $values);
  386. if (count($unlink))
  387. {
  388. $this->object->unlink('RecordsPermissionsAssociations', array_values($unlink));
  389. }
  390. $link = array_diff($values, $existing);
  391. if (count($link))
  392. {
  393. $this->object->link('RecordsPermissionsAssociations', array_values($link));
  394. }
  395. }
  396. public function saveDmLockList($con = null)
  397. {
  398. if (!$this->isValid())
  399. {
  400. throw $this->getErrorSchema();
  401. }
  402. if (!isset($this->widgetSchema['dm_lock_list']))
  403. {
  404. // somebody has unset this widget
  405. return;
  406. }
  407. if (null === $con)
  408. {
  409. $con = $this->getConnection();
  410. }
  411. $existing = $this->object->DmLock->getPrimaryKeys();
  412. $values = $this->getValue('dm_lock_list');
  413. if (!is_array($values))
  414. {
  415. $values = array();
  416. }
  417. $unlink = array_diff($existing, $values);
  418. if (count($unlink))
  419. {
  420. $this->object->unlink('DmLock', array_values($unlink));
  421. }
  422. $link = array_diff($values, $existing);
  423. if (count($link))
  424. {
  425. $this->object->link('DmLock', array_values($link));
  426. }
  427. }
  428. public function savePostsList($con = null)
  429. {
  430. if (!$this->isValid())
  431. {
  432. throw $this->getErrorSchema();
  433. }
  434. if (!isset($this->widgetSchema['posts_list']))
  435. {
  436. // somebody has unset this widget
  437. return;
  438. }
  439. if (null === $con)
  440. {
  441. $con = $this->getConnection();
  442. }
  443. $existing = $this->object->Posts->getPrimaryKeys();
  444. $values = $this->getValue('posts_list');
  445. if (!is_array($values))
  446. {
  447. $values = array();
  448. }
  449. $unlink = array_diff($existing, $values);
  450. if (count($unlink))
  451. {
  452. $this->object->unlink('Posts', array_values($unlink));
  453. }
  454. $link = array_diff($values, $existing);
  455. if (count($link))
  456. {
  457. $this->object->link('Posts', array_values($link));
  458. }
  459. }
  460. public function saveDmTestPostsList($con = null)
  461. {
  462. if (!$this->isValid())
  463. {
  464. throw $this->getErrorSchema();
  465. }
  466. if (!isset($this->widgetSchema['dm_test_posts_list']))
  467. {
  468. // somebody has unset this widget
  469. return;
  470. }
  471. if (null === $con)
  472. {
  473. $con = $this->getConnection();
  474. }
  475. $existing = $this->object->DmTestPosts->getPrimaryKeys();
  476. $values = $this->getValue('dm_test_posts_list');
  477. if (!is_array($values))
  478. {
  479. $values = array();
  480. }
  481. $unlink = array_diff($existing, $values);
  482. if (count($unlink))
  483. {
  484. $this->object->unlink('DmTestPosts', array_values($unlink));
  485. }
  486. $link = array_diff($values, $existing);
  487. if (count($link))
  488. {
  489. $this->object->link('DmTestPosts', array_values($link));
  490. }
  491. }
  492. public function saveCreatedDmTestDomainTranslationsList($con = null)
  493. {
  494. if (!$this->isValid())
  495. {
  496. throw $this->getErrorSchema();
  497. }
  498. if (!isset($this->widgetSchema['created_dm_test_domain_translations_list']))
  499. {
  500. // somebody has unset this widget
  501. return;
  502. }
  503. if (null === $con)
  504. {
  505. $con = $this->getConnection();
  506. }
  507. $existing = $this->object->CreatedDmTestDomainTranslations->getPrimaryKeys();
  508. $values = $this->getValue('created_dm_test_domain_translations_list');
  509. if (!is_array($values))
  510. {
  511. $values = array();
  512. }
  513. $unlink = array_diff($existing, $values);
  514. if (count($unlink))
  515. {
  516. $this->object->unlink('CreatedDmTestDomainTranslations', array_values($unlink));
  517. }
  518. $link = array_diff($values, $existing);
  519. if (count($link))
  520. {
  521. $this->object->link('CreatedDmTestDomainTranslations', array_values($link));
  522. }
  523. }
  524. public function saveUpdatedDmTestDomainTranslationsList($con = null)
  525. {
  526. if (!$this->isValid())
  527. {
  528. throw $this->getErrorSchema();
  529. }
  530. if (!isset($this->widgetSchema['updated_dm_test_domain_translations_list']))
  531. {
  532. // somebody has unset this widget
  533. return;
  534. }
  535. if (null === $con)
  536. {
  537. $con = $this->getConnection();
  538. }
  539. $existing = $this->object->UpdatedDmTestDomainTranslations->getPrimaryKeys();
  540. $values = $this->getValue('updated_dm_test_domain_translations_list');
  541. if (!is_array($values))
  542. {
  543. $values = array();
  544. }
  545. $unlink = array_diff($existing, $values);
  546. if (count($unlink))
  547. {
  548. $this->object->unlink('UpdatedDmTestDomainTranslations', array_values($unlink));
  549. }
  550. $link = array_diff($values, $existing);
  551. if (count($link))
  552. {
  553. $this->object->link('UpdatedDmTestDomainTranslations', array_values($link));
  554. }
  555. }
  556. public function saveCreatedDmTestFruitsList($con = null)
  557. {
  558. if (!$this->isValid())
  559. {
  560. throw $this->getErrorSchema();
  561. }
  562. if (!isset($this->widgetSchema['created_dm_test_fruits_list']))
  563. {
  564. // somebody has unset this widget
  565. return;
  566. }
  567. if (null === $con)
  568. {
  569. $con = $this->getConnection();
  570. }
  571. $existing = $this->object->CreatedDmTestFruits->getPrimaryKeys();
  572. $values = $this->getValue('created_dm_test_fruits_list');
  573. if (!is_array($values))
  574. {
  575. $values = array();
  576. }
  577. $unlink = array_diff($existing, $values);
  578. if (count($unlink))
  579. {
  580. $this->object->unlink('CreatedDmTestFruits', array_values($unlink));
  581. }
  582. $link = array_diff($values, $existing);
  583. if (count($link))
  584. {
  585. $this->object->link('CreatedDmTestFruits', array_values($link));
  586. }
  587. }
  588. public function saveUpdatedDmTestFruitsList($con = null)
  589. {
  590. if (!$this->isValid())
  591. {
  592. throw $this->getErrorSchema();
  593. }
  594. if (!isset($this->widgetSchema['updated_dm_test_fruits_list']))
  595. {
  596. // somebody has unset this widget
  597. return;
  598. }
  599. if (null === $con)
  600. {
  601. $con = $this->getConnection();
  602. }
  603. $existing = $this->object->UpdatedDmTestFruits->getPrimaryKeys();
  604. $values = $this->getValue('updated_dm_test_fruits_list');
  605. if (!is_array($values))
  606. {
  607. $values = array();
  608. }
  609. $unlink = array_diff($existing, $values);
  610. if (count($unlink))
  611. {
  612. $this->object->unlink('UpdatedDmTestFruits', array_values($unlink));
  613. }
  614. $link = array_diff($values, $existing);
  615. if (count($link))
  616. {
  617. $this->object->link('UpdatedDmTestFruits', array_values($link));
  618. }
  619. }
  620. public function saveDmUserGroupList($con = null)
  621. {
  622. if (!$this->isValid())
  623. {
  624. throw $this->getErrorSchema();
  625. }
  626. if (!isset($this->widgetSchema['dm_user_group_list']))
  627. {
  628. // somebody has unset this widget
  629. return;
  630. }
  631. if (null === $con)
  632. {
  633. $con = $this->getConnection();
  634. }
  635. $existing = $this->object->DmUserGroup->getPrimaryKeys();
  636. $values = $this->getValue('dm_user_group_list');
  637. if (!is_array($values))
  638. {
  639. $values = array();
  640. }
  641. $unlink = array_diff($existing, $values);
  642. if (count($unlink))
  643. {
  644. $this->object->unlink('DmUserGroup', array_values($unlink));
  645. }
  646. $link = array_diff($values, $existing);
  647. if (count($link))
  648. {
  649. $this->object->link('DmUserGroup', array_values($link));
  650. }
  651. }
  652. public function saveDmUserPermissionList($con = null)
  653. {
  654. if (!$this->isValid())
  655. {
  656. throw $this->getErrorSchema();
  657. }
  658. if (!isset($this->widgetSchema['dm_user_permission_list']))
  659. {
  660. // somebody has unset this widget
  661. return;
  662. }
  663. if (null === $con)
  664. {
  665. $con = $this->getConnection();
  666. }
  667. $existing = $this->object->DmUserPermission->getPrimaryKeys();
  668. $values = $this->getValue('dm_user_permission_list');
  669. if (!is_array($values))
  670. {
  671. $values = array();
  672. }
  673. $unlink = array_diff($existing, $values);
  674. if (count($unlink))
  675. {
  676. $this->object->unlink('DmUserPermission', array_values($unlink));
  677. }
  678. $link = array_diff($values, $existing);
  679. if (count($link))
  680. {
  681. $this->object->link('DmUserPermission', array_values($link));
  682. }
  683. }
  684. public function saveDmRecordPermissionUserList($con = null)
  685. {
  686. if (!$this->isValid())
  687. {
  688. throw $this->getErrorSchema();
  689. }
  690. if (!isset($this->widgetSchema['dm_record_permission_user_list']))
  691. {
  692. // somebody has unset this widget
  693. return;
  694. }
  695. if (null === $con)
  696. {
  697. $con = $this->getConnection();
  698. }
  699. $existing = $this->object->DmRecordPermissionUser->getPrimaryKeys();
  700. $values = $this->getValue('dm_record_permission_user_list');
  701. if (!is_array($values))
  702. {
  703. $values = array();
  704. }
  705. $unlink = array_diff($existing, $values);
  706. if (count($unlink))
  707. {
  708. $this->object->unlink('DmRecordPermissionUser', array_values($unlink));
  709. }
  710. $link = array_diff($values, $existing);
  711. if (count($link))
  712. {
  713. $this->object->link('DmRecordPermissionUser', array_values($link));
  714. }
  715. }
  716. public function saveDmRecordPermissionAssociationUserList($con = null)
  717. {
  718. if (!$this->isValid())
  719. {
  720. throw $this->getErrorSchema();
  721. }
  722. if (!isset($this->widgetSchema['dm_record_permission_association_user_list']))
  723. {
  724. // somebody has unset this widget
  725. return;
  726. }
  727. if (null === $con)
  728. {
  729. $con = $this->getConnection();
  730. }
  731. $existing = $this->object->DmRecordPermissionAssociationUser->getPrimaryKeys();
  732. $values = $this->getValue('dm_record_permission_association_user_list');
  733. if (!is_array($values))
  734. {
  735. $values = array();
  736. }
  737. $unlink = array_diff($existing, $values);
  738. if (count($unlink))
  739. {
  740. $this->object->unlink('DmRecordPermissionAssociationUser', array_values($unlink));
  741. }
  742. $link = array_diff($values, $existing);
  743. if (count($link))
  744. {
  745. $this->object->link('DmRecordPermissionAssociationUser', array_values($link));
  746. }
  747. }
  748. }