update.class.php 3.7 KB

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