update.class.php 3.7 KB

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