update.class.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * Loads the policy management page
  4. *
  5. * @package modx
  6. * @subpackage manager.controllers
  7. */
  8. class SecurityAccessPolicyUpdateManagerController extends modManagerController {
  9. public $policyArray = 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('policy_edit');
  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/security/modx.panel.access.policy.js');
  24. $this->addJavascript($mgrUrl.'assets/modext/sections/security/access/policy/update.js');
  25. $this->addHtml('
  26. <script type="text/javascript">
  27. // <![CDATA[
  28. Ext.onReady(function() {
  29. MODx.load({
  30. xtype: "modx-page-access-policy"
  31. ,policy: "'.$this->policyArray['id'].'"
  32. ,record: '.$this->modx->toJSON($this->policyArray).'
  33. });
  34. });
  35. // ]]>
  36. </script>');
  37. }
  38. /**
  39. * Custom logic code here for setting placeholders, etc
  40. * @param array $scriptProperties
  41. * @return mixed
  42. */
  43. public function process(array $scriptProperties = array()) {
  44. $placeholders = array();
  45. if (empty($scriptProperties['id']) || strlen($scriptProperties['id']) !== strlen((integer)$scriptProperties['id'])) {
  46. return $this->failure($this->modx->lexicon('access_policy_err_ns'));
  47. }
  48. $policy = $this->modx->getObject('modAccessPolicy', array('id' => $scriptProperties['id']));
  49. if (empty($policy)) return $this->failure($this->modx->lexicon('access_policy_err_nf'));
  50. $placeholders['policy'] = $policy;
  51. /* setup policy array */
  52. $this->policyArray = $policy->get(array(
  53. 'id',
  54. 'name',
  55. 'description',
  56. 'lexicon',
  57. 'class',
  58. 'template',
  59. 'parent',
  60. ));
  61. $this->policyArray['permissions'] = $policy->getPermissions();
  62. $placeholders['policy'] = $this->policyArray;
  63. return $placeholders;
  64. }
  65. /**
  66. * Return the pagetitle
  67. *
  68. * @return string
  69. */
  70. public function getPageTitle() {
  71. return $this->modx->lexicon('policy').': '.$this->policyArray['name'];
  72. }
  73. /**
  74. * Return the location of the template file
  75. * @return string
  76. */
  77. public function getTemplateFile() {
  78. return '';
  79. }
  80. /**
  81. * Specify the language topics to load
  82. * @return array
  83. */
  84. public function getLanguageTopics() {
  85. return array('user','access','policy','context');
  86. }
  87. /**
  88. * Get the Help URL
  89. * @return string
  90. */
  91. public function getHelpUrl() {
  92. return 'Policies';
  93. }
  94. }