update.class.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * Loads form customization profile editing panel
  4. *
  5. * @package modx
  6. * @subpackage manager.controllers
  7. */
  8. class SecurityFormsProfileUpdateManagerController extends modManagerController {
  9. public $profileArray = array();
  10. /**
  11. * Check for any permissions or requirements to load page
  12. * @return bool
  13. */
  14. public function checkPermissions() {
  15. return $this->modx->hasPermission('customize_forms');
  16. }
  17. /**
  18. * Register custom CSS/JS for the page
  19. * @return void
  20. */
  21. public function loadCustomCssJs() {
  22. $mgrUrl = $this->modx->getOption('manager_url',null,MODX_MANAGER_URL);
  23. $this->addJavascript($mgrUrl.'assets/modext/widgets/fc/modx.fc.common.js');
  24. $this->addJavascript($mgrUrl.'assets/modext/widgets/fc/modx.panel.fcprofile.js');
  25. $this->addJavascript($mgrUrl.'assets/modext/widgets/fc/modx.grid.fcset.js');
  26. $this->addJavascript($mgrUrl.'assets/modext/sections/fc/profile/update.js');
  27. $this->addHtml('<script type="text/javascript">
  28. // <![CDATA[
  29. Ext.onReady(function() {
  30. MODx.load({
  31. xtype: "modx-page-fc-profile-update"
  32. ,profile: "'.$this->profileArray['id'].'"
  33. ,record: '.$this->modx->toJSON($this->profileArray).'
  34. });
  35. });
  36. // ]]>
  37. </script>');
  38. }
  39. /**
  40. * Custom logic code here for setting placeholders, etc
  41. * @param array $scriptProperties
  42. * @return mixed
  43. */
  44. public function process(array $scriptProperties = array()) {
  45. $placeholders = array();
  46. if (empty($scriptProperties['id']) || strlen($scriptProperties['id']) !== strlen((integer)$scriptProperties['id'])) {
  47. return $this->failure($this->modx->lexicon('profile_err_ns'));
  48. }
  49. $profile = $this->modx->getObject('modFormCustomizationProfile', array('id' => $scriptProperties['id']));
  50. if (empty($profile)) return $this->failure($this->modx->lexicon('profile_err_nfs',array('id' => $scriptProperties['id'])));
  51. $this->profileArray = $profile->toArray();
  52. $c = $this->modx->newQuery('modUserGroup');
  53. $c->innerJoin('modFormCustomizationProfileUserGroup','FormCustomizationProfiles');
  54. $c->where(array(
  55. 'FormCustomizationProfiles.profile' => $profile->get('id'),
  56. ));
  57. $c->sortby('name','ASC');
  58. $usergroups = $this->modx->getCollection('modUserGroup',$c);
  59. $this->profileArray['usergroups'] = array();
  60. foreach ($usergroups as $usergroup) {
  61. $this->profileArray['usergroups'][] = array(
  62. $usergroup->get('id'),
  63. $usergroup->get('name'),
  64. );
  65. }
  66. $placeholders['profile'] = $this->profileArray;
  67. return $placeholders;
  68. }
  69. /**
  70. * Return the pagetitle
  71. *
  72. * @return string
  73. */
  74. public function getPageTitle() {
  75. return $this->modx->lexicon('form_customization');
  76. }
  77. /**
  78. * Return the location of the template file
  79. * @return string
  80. */
  81. public function getTemplateFile() {
  82. return '';
  83. }
  84. /**
  85. * Specify the language topics to load
  86. * @return array
  87. */
  88. public function getLanguageTopics() {
  89. return array('user','access','policy','formcustomization');
  90. }
  91. /**
  92. * Get the Help URL
  93. * @return string
  94. */
  95. public function getHelpUrl() {
  96. return 'Form+Customization+Profiles';
  97. }
  98. }