PageRenderTime 62ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/diem-project/diem
PHP | 703 lines | 551 code | 103 blank | 49 comment | 104 complexity | fc27cf9584ff47a53b650995aebe2f5c MD5 | raw file
Possible License(s): BSD-3-Clause, MIT, ISC
  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('dm_user_group_list')){
  125. $this->setWidget('dm_user_group_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmUserGroup', 'expanded' => true)));
  126. $this->setValidator('dm_user_group_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmUserGroup', 'required' => false)));
  127. }
  128. //one to many
  129. if($this->needsWidget('dm_user_permission_list')){
  130. $this->setWidget('dm_user_permission_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmUserPermission', 'expanded' => true)));
  131. $this->setValidator('dm_user_permission_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmUserPermission', 'required' => false)));
  132. }
  133. //one to many
  134. if($this->needsWidget('dm_record_permission_user_list')){
  135. $this->setWidget('dm_record_permission_user_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermissionUser', 'expanded' => true)));
  136. $this->setValidator('dm_record_permission_user_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermissionUser', 'required' => false)));
  137. }
  138. //one to many
  139. if($this->needsWidget('dm_record_permission_association_user_list')){
  140. $this->setWidget('dm_record_permission_association_user_list', new sfWidgetFormDmPaginatedDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermissionAssociationUser', 'expanded' => true)));
  141. $this->setValidator('dm_record_permission_association_user_list', new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'DmRecordPermissionAssociationUser', 'required' => false)));
  142. }
  143. $this->validatorSchema->setPostValidator(
  144. new sfValidatorAnd(array(
  145. new sfValidatorDoctrineUnique(array('model' => 'DmUser', 'column' => array('username'))),
  146. new sfValidatorDoctrineUnique(array('model' => 'DmUser', 'column' => array('email'))),
  147. new sfValidatorDoctrineUnique(array('model' => 'DmUser', 'column' => array('forgot_password_code'))),
  148. ))
  149. );
  150. $this->widgetSchema->setNameFormat('dm_user[%s]');
  151. $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
  152. $this->setupInheritance();
  153. parent::setup();
  154. // Unset automatic fields like 'created_at', 'updated_at', 'position'
  155. // override this method in your form to keep them
  156. parent::unsetAutoFields();
  157. }
  158. protected function doBind(array $values)
  159. {
  160. parent::doBind($values);
  161. }
  162. public function processValues($values)
  163. {
  164. $values = parent::processValues($values);
  165. return $values;
  166. }
  167. protected function doUpdateObject($values)
  168. {
  169. parent::doUpdateObject($values);
  170. }
  171. public function getModelName()
  172. {
  173. return 'DmUser';
  174. }
  175. public function updateDefaultsFromObject()
  176. {
  177. parent::updateDefaultsFromObject();
  178. if (isset($this->widgetSchema['groups_list']))
  179. {
  180. $this->setDefault('groups_list', array_merge((array)$this->getDefault('groups_list'),$this->object->Groups->getPrimaryKeys()));
  181. }
  182. if (isset($this->widgetSchema['permissions_list']))
  183. {
  184. $this->setDefault('permissions_list', array_merge((array)$this->getDefault('permissions_list'),$this->object->Permissions->getPrimaryKeys()));
  185. }
  186. if (isset($this->widgetSchema['records_list']))
  187. {
  188. $this->setDefault('records_list', array_merge((array)$this->getDefault('records_list'),$this->object->Records->getPrimaryKeys()));
  189. }
  190. if (isset($this->widgetSchema['records_permissions_associations_list']))
  191. {
  192. $this->setDefault('records_permissions_associations_list', array_merge((array)$this->getDefault('records_permissions_associations_list'),$this->object->RecordsPermissionsAssociations->getPrimaryKeys()));
  193. }
  194. if (isset($this->widgetSchema['dm_lock_list']))
  195. {
  196. $this->setDefault('dm_lock_list', array_merge((array)$this->getDefault('dm_lock_list'),$this->object->DmLock->getPrimaryKeys()));
  197. }
  198. if (isset($this->widgetSchema['posts_list']))
  199. {
  200. $this->setDefault('posts_list', array_merge((array)$this->getDefault('posts_list'),$this->object->Posts->getPrimaryKeys()));
  201. }
  202. if (isset($this->widgetSchema['dm_test_posts_list']))
  203. {
  204. $this->setDefault('dm_test_posts_list', array_merge((array)$this->getDefault('dm_test_posts_list'),$this->object->DmTestPosts->getPrimaryKeys()));
  205. }
  206. if (isset($this->widgetSchema['created_dm_test_domain_translations_list']))
  207. {
  208. $this->setDefault('created_dm_test_domain_translations_list', array_merge((array)$this->getDefault('created_dm_test_domain_translations_list'),$this->object->CreatedDmTestDomainTranslations->getPrimaryKeys()));
  209. }
  210. if (isset($this->widgetSchema['updated_dm_test_domain_translations_list']))
  211. {
  212. $this->setDefault('updated_dm_test_domain_translations_list', array_merge((array)$this->getDefault('updated_dm_test_domain_translations_list'),$this->object->UpdatedDmTestDomainTranslations->getPrimaryKeys()));
  213. }
  214. if (isset($this->widgetSchema['dm_user_group_list']))
  215. {
  216. $this->setDefault('dm_user_group_list', array_merge((array)$this->getDefault('dm_user_group_list'),$this->object->DmUserGroup->getPrimaryKeys()));
  217. }
  218. if (isset($this->widgetSchema['dm_user_permission_list']))
  219. {
  220. $this->setDefault('dm_user_permission_list', array_merge((array)$this->getDefault('dm_user_permission_list'),$this->object->DmUserPermission->getPrimaryKeys()));
  221. }
  222. if (isset($this->widgetSchema['dm_record_permission_user_list']))
  223. {
  224. $this->setDefault('dm_record_permission_user_list', array_merge((array)$this->getDefault('dm_record_permission_user_list'),$this->object->DmRecordPermissionUser->getPrimaryKeys()));
  225. }
  226. if (isset($this->widgetSchema['dm_record_permission_association_user_list']))
  227. {
  228. $this->setDefault('dm_record_permission_association_user_list', array_merge((array)$this->getDefault('dm_record_permission_association_user_list'),$this->object->DmRecordPermissionAssociationUser->getPrimaryKeys()));
  229. }
  230. }
  231. protected function doSave($con = null)
  232. {
  233. $this->saveGroupsList($con);
  234. $this->savePermissionsList($con);
  235. $this->saveRecordsList($con);
  236. $this->saveRecordsPermissionsAssociationsList($con);
  237. $this->saveDmLockList($con);
  238. $this->savePostsList($con);
  239. $this->saveDmTestPostsList($con);
  240. $this->saveCreatedDmTestDomainTranslationsList($con);
  241. $this->saveUpdatedDmTestDomainTranslationsList($con);
  242. $this->saveDmUserGroupList($con);
  243. $this->saveDmUserPermissionList($con);
  244. $this->saveDmRecordPermissionUserList($con);
  245. $this->saveDmRecordPermissionAssociationUserList($con);
  246. parent::doSave($con);
  247. }
  248. public function saveGroupsList($con = null)
  249. {
  250. if (!$this->isValid())
  251. {
  252. throw $this->getErrorSchema();
  253. }
  254. if (!isset($this->widgetSchema['groups_list']))
  255. {
  256. // somebody has unset this widget
  257. return;
  258. }
  259. if (null === $con)
  260. {
  261. $con = $this->getConnection();
  262. }
  263. $existing = $this->object->Groups->getPrimaryKeys();
  264. $values = $this->getValue('groups_list');
  265. if (!is_array($values))
  266. {
  267. $values = array();
  268. }
  269. $unlink = array_diff($existing, $values);
  270. if (count($unlink))
  271. {
  272. $this->object->unlink('Groups', array_values($unlink));
  273. }
  274. $link = array_diff($values, $existing);
  275. if (count($link))
  276. {
  277. $this->object->link('Groups', array_values($link));
  278. }
  279. }
  280. public function savePermissionsList($con = null)
  281. {
  282. if (!$this->isValid())
  283. {
  284. throw $this->getErrorSchema();
  285. }
  286. if (!isset($this->widgetSchema['permissions_list']))
  287. {
  288. // somebody has unset this widget
  289. return;
  290. }
  291. if (null === $con)
  292. {
  293. $con = $this->getConnection();
  294. }
  295. $existing = $this->object->Permissions->getPrimaryKeys();
  296. $values = $this->getValue('permissions_list');
  297. if (!is_array($values))
  298. {
  299. $values = array();
  300. }
  301. $unlink = array_diff($existing, $values);
  302. if (count($unlink))
  303. {
  304. $this->object->unlink('Permissions', array_values($unlink));
  305. }
  306. $link = array_diff($values, $existing);
  307. if (count($link))
  308. {
  309. $this->object->link('Permissions', array_values($link));
  310. }
  311. }
  312. public function saveRecordsList($con = null)
  313. {
  314. if (!$this->isValid())
  315. {
  316. throw $this->getErrorSchema();
  317. }
  318. if (!isset($this->widgetSchema['records_list']))
  319. {
  320. // somebody has unset this widget
  321. return;
  322. }
  323. if (null === $con)
  324. {
  325. $con = $this->getConnection();
  326. }
  327. $existing = $this->object->Records->getPrimaryKeys();
  328. $values = $this->getValue('records_list');
  329. if (!is_array($values))
  330. {
  331. $values = array();
  332. }
  333. $unlink = array_diff($existing, $values);
  334. if (count($unlink))
  335. {
  336. $this->object->unlink('Records', array_values($unlink));
  337. }
  338. $link = array_diff($values, $existing);
  339. if (count($link))
  340. {
  341. $this->object->link('Records', array_values($link));
  342. }
  343. }
  344. public function saveRecordsPermissionsAssociationsList($con = null)
  345. {
  346. if (!$this->isValid())
  347. {
  348. throw $this->getErrorSchema();
  349. }
  350. if (!isset($this->widgetSchema['records_permissions_associations_list']))
  351. {
  352. // somebody has unset this widget
  353. return;
  354. }
  355. if (null === $con)
  356. {
  357. $con = $this->getConnection();
  358. }
  359. $existing = $this->object->RecordsPermissionsAssociations->getPrimaryKeys();
  360. $values = $this->getValue('records_permissions_associations_list');
  361. if (!is_array($values))
  362. {
  363. $values = array();
  364. }
  365. $unlink = array_diff($existing, $values);
  366. if (count($unlink))
  367. {
  368. $this->object->unlink('RecordsPermissionsAssociations', array_values($unlink));
  369. }
  370. $link = array_diff($values, $existing);
  371. if (count($link))
  372. {
  373. $this->object->link('RecordsPermissionsAssociations', array_values($link));
  374. }
  375. }
  376. public function saveDmLockList($con = null)
  377. {
  378. if (!$this->isValid())
  379. {
  380. throw $this->getErrorSchema();
  381. }
  382. if (!isset($this->widgetSchema['dm_lock_list']))
  383. {
  384. // somebody has unset this widget
  385. return;
  386. }
  387. if (null === $con)
  388. {
  389. $con = $this->getConnection();
  390. }
  391. $existing = $this->object->DmLock->getPrimaryKeys();
  392. $values = $this->getValue('dm_lock_list');
  393. if (!is_array($values))
  394. {
  395. $values = array();
  396. }
  397. $unlink = array_diff($existing, $values);
  398. if (count($unlink))
  399. {
  400. $this->object->unlink('DmLock', array_values($unlink));
  401. }
  402. $link = array_diff($values, $existing);
  403. if (count($link))
  404. {
  405. $this->object->link('DmLock', array_values($link));
  406. }
  407. }
  408. public function savePostsList($con = null)
  409. {
  410. if (!$this->isValid())
  411. {
  412. throw $this->getErrorSchema();
  413. }
  414. if (!isset($this->widgetSchema['posts_list']))
  415. {
  416. // somebody has unset this widget
  417. return;
  418. }
  419. if (null === $con)
  420. {
  421. $con = $this->getConnection();
  422. }
  423. $existing = $this->object->Posts->getPrimaryKeys();
  424. $values = $this->getValue('posts_list');
  425. if (!is_array($values))
  426. {
  427. $values = array();
  428. }
  429. $unlink = array_diff($existing, $values);
  430. if (count($unlink))
  431. {
  432. $this->object->unlink('Posts', array_values($unlink));
  433. }
  434. $link = array_diff($values, $existing);
  435. if (count($link))
  436. {
  437. $this->object->link('Posts', array_values($link));
  438. }
  439. }
  440. public function saveDmTestPostsList($con = null)
  441. {
  442. if (!$this->isValid())
  443. {
  444. throw $this->getErrorSchema();
  445. }
  446. if (!isset($this->widgetSchema['dm_test_posts_list']))
  447. {
  448. // somebody has unset this widget
  449. return;
  450. }
  451. if (null === $con)
  452. {
  453. $con = $this->getConnection();
  454. }
  455. $existing = $this->object->DmTestPosts->getPrimaryKeys();
  456. $values = $this->getValue('dm_test_posts_list');
  457. if (!is_array($values))
  458. {
  459. $values = array();
  460. }
  461. $unlink = array_diff($existing, $values);
  462. if (count($unlink))
  463. {
  464. $this->object->unlink('DmTestPosts', array_values($unlink));
  465. }
  466. $link = array_diff($values, $existing);
  467. if (count($link))
  468. {
  469. $this->object->link('DmTestPosts', array_values($link));
  470. }
  471. }
  472. public function saveDmUserGroupList($con = null)
  473. {
  474. if (!$this->isValid())
  475. {
  476. throw $this->getErrorSchema();
  477. }
  478. if (!isset($this->widgetSchema['dm_user_group_list']))
  479. {
  480. // somebody has unset this widget
  481. return;
  482. }
  483. if (null === $con)
  484. {
  485. $con = $this->getConnection();
  486. }
  487. $existing = $this->object->DmUserGroup->getPrimaryKeys();
  488. $values = $this->getValue('dm_user_group_list');
  489. if (!is_array($values))
  490. {
  491. $values = array();
  492. }
  493. $unlink = array_diff($existing, $values);
  494. if (count($unlink))
  495. {
  496. $this->object->unlink('DmUserGroup', array_values($unlink));
  497. }
  498. $link = array_diff($values, $existing);
  499. if (count($link))
  500. {
  501. $this->object->link('DmUserGroup', array_values($link));
  502. }
  503. }
  504. public function saveDmUserPermissionList($con = null)
  505. {
  506. if (!$this->isValid())
  507. {
  508. throw $this->getErrorSchema();
  509. }
  510. if (!isset($this->widgetSchema['dm_user_permission_list']))
  511. {
  512. // somebody has unset this widget
  513. return;
  514. }
  515. if (null === $con)
  516. {
  517. $con = $this->getConnection();
  518. }
  519. $existing = $this->object->DmUserPermission->getPrimaryKeys();
  520. $values = $this->getValue('dm_user_permission_list');
  521. if (!is_array($values))
  522. {
  523. $values = array();
  524. }
  525. $unlink = array_diff($existing, $values);
  526. if (count($unlink))
  527. {
  528. $this->object->unlink('DmUserPermission', array_values($unlink));
  529. }
  530. $link = array_diff($values, $existing);
  531. if (count($link))
  532. {
  533. $this->object->link('DmUserPermission', array_values($link));
  534. }
  535. }
  536. public function saveDmRecordPermissionUserList($con = null)
  537. {
  538. if (!$this->isValid())
  539. {
  540. throw $this->getErrorSchema();
  541. }
  542. if (!isset($this->widgetSchema['dm_record_permission_user_list']))
  543. {
  544. // somebody has unset this widget
  545. return;
  546. }
  547. if (null === $con)
  548. {
  549. $con = $this->getConnection();
  550. }
  551. $existing = $this->object->DmRecordPermissionUser->getPrimaryKeys();
  552. $values = $this->getValue('dm_record_permission_user_list');
  553. if (!is_array($values))
  554. {
  555. $values = array();
  556. }
  557. $unlink = array_diff($existing, $values);
  558. if (count($unlink))
  559. {
  560. $this->object->unlink('DmRecordPermissionUser', array_values($unlink));
  561. }
  562. $link = array_diff($values, $existing);
  563. if (count($link))
  564. {
  565. $this->object->link('DmRecordPermissionUser', array_values($link));
  566. }
  567. }
  568. public function saveDmRecordPermissionAssociationUserList($con = null)
  569. {
  570. if (!$this->isValid())
  571. {
  572. throw $this->getErrorSchema();
  573. }
  574. if (!isset($this->widgetSchema['dm_record_permission_association_user_list']))
  575. {
  576. // somebody has unset this widget
  577. return;
  578. }
  579. if (null === $con)
  580. {
  581. $con = $this->getConnection();
  582. }
  583. $existing = $this->object->DmRecordPermissionAssociationUser->getPrimaryKeys();
  584. $values = $this->getValue('dm_record_permission_association_user_list');
  585. if (!is_array($values))
  586. {
  587. $values = array();
  588. }
  589. $unlink = array_diff($existing, $values);
  590. if (count($unlink))
  591. {
  592. $this->object->unlink('DmRecordPermissionAssociationUser', array_values($unlink));
  593. }
  594. $link = array_diff($values, $existing);
  595. if (count($link))
  596. {
  597. $this->object->link('DmRecordPermissionAssociationUser', array_values($link));
  598. }
  599. }
  600. }