update.class.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 the usergroup update page
  12. *
  13. * @package modx
  14. * @subpackage manager.controllers
  15. */
  16. class SecurityUserGroupUpdateManagerController extends modManagerController {
  17. /** @var modUserGroup $userGroup */
  18. public $userGroup;
  19. /**
  20. * Check for any permissions or requirements to load page
  21. * @return bool
  22. */
  23. public function checkPermissions() {
  24. return $this->modx->hasPermission('usergroup_view');
  25. }
  26. /**
  27. * Register custom CSS/JS for the page
  28. * @return void
  29. */
  30. public function loadCustomCssJs() {
  31. $mgrUrl = $this->modx->getOption('manager_url',null,MODX_MANAGER_URL);
  32. $this->addJavascript($mgrUrl.'assets/modext/widgets/core/modx.grid.settings.js');
  33. $this->addJavascript($mgrUrl.'assets/modext/widgets/security/modx.grid.user.group.settings.js');
  34. $this->addJavascript($mgrUrl.'assets/modext/widgets/security/modx.grid.user.group.context.js');
  35. $this->addJavascript($mgrUrl.'assets/modext/widgets/security/modx.grid.user.group.resource.js');
  36. $this->addJavascript($mgrUrl.'assets/modext/widgets/security/modx.grid.user.group.category.js');
  37. $this->addJavascript($mgrUrl.'assets/modext/widgets/security/modx.grid.user.group.source.js');
  38. $this->addJavascript($mgrUrl.'assets/modext/widgets/security/modx.grid.user.group.namespace.js');
  39. $this->addJavascript($mgrUrl.'assets/modext/widgets/security/modx.panel.user.group.js');
  40. $canEditUsers = $this->modx->hasPermission('usergroup_user_edit') ? 1 : 0;
  41. $canListUsers = $this->modx->hasPermission('usergroup_user_list') ? 1 : 0;
  42. $this->addJavascript($mgrUrl.'assets/modext/sections/security/usergroup/update.js');
  43. $this->addHtml('<script type="text/javascript">
  44. MODx.perm.usergroup_user_edit = '.$canEditUsers.';
  45. MODx.perm.usergroup_user_list = '.$canListUsers.';
  46. Ext.onReady(function() {
  47. MODx.load({
  48. xtype: "modx-page-user-group-update"
  49. ,record: '.$this->modx->toJSON($this->userGroup->toArray()).'
  50. });
  51. });
  52. </script>');
  53. }
  54. /**
  55. * Custom logic code here for setting placeholders, etc
  56. * @param array $scriptProperties
  57. * @return mixed
  58. */
  59. public function process(array $scriptProperties = array()) {
  60. $placeholders = array();
  61. if (empty($scriptProperties['id']) || strlen($scriptProperties['id']) !== strlen((integer)$scriptProperties['id'])) {
  62. $this->userGroup = $this->modx->newObject('modUserGroup');
  63. $this->userGroup->set('id',0);
  64. $this->userGroup->set('name',$this->modx->lexicon('anonymous'));
  65. } else {
  66. $this->userGroup = $this->modx->getObject('modUserGroup', array('id' => $scriptProperties['id']));
  67. if (empty($this->userGroup)) {
  68. $this->failure($this->modx->lexicon('usergroup_err_nf'));
  69. }
  70. }
  71. return $placeholders;
  72. }
  73. /**
  74. * Return the pagetitle
  75. *
  76. * @return string
  77. */
  78. public function getPageTitle() {
  79. $ugName = $this->userGroup ? $this->userGroup->get('name') : $this->modx->lexicon('anonymous');
  80. return $this->modx->lexicon('user_group').': '.$ugName;
  81. }
  82. /**
  83. * Return the location of the template file
  84. * @return string
  85. */
  86. public function getTemplateFile() {
  87. return '';
  88. }
  89. /**
  90. * Specify the language topics to load
  91. * @return array
  92. */
  93. public function getLanguageTopics() {
  94. return array('user','access','policy','context','setting');
  95. }
  96. /**
  97. * Get the Help URL
  98. * @return string
  99. */
  100. public function getHelpUrl() {
  101. return 'User+Groups';
  102. }
  103. }