toggle_editor.php 763 B

123456789101112131415161718192021222324
  1. <?php
  2. $user_guid = (int) get_input('user_guid');
  3. $user = get_user($user_guid);
  4. if (empty($user)) {
  5. register_error(elgg_echo('error:missing_data'));
  6. forward(REFERER);
  7. }
  8. if ($user->isAdmin()) {
  9. register_error(elgg_echo('site_announcements:action:toggle_editor:error:is_admin', array($user->name)));
  10. forward(REFERER);
  11. }
  12. if (site_announcements_is_editor($user)) {
  13. elgg_unset_plugin_user_setting('editor', $user->getGUID(), 'site_announcements');
  14. system_message(elgg_echo('site_announcements:action:toggle_editor:unmake', array($user->name)));
  15. } else {
  16. elgg_set_plugin_user_setting('editor', time(), $user->getGUID(), 'site_announcements');
  17. system_message(elgg_echo('site_announcements:action:toggle_editor:make', array($user->name)));
  18. }
  19. forward(REFERER);