]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/deleteuser.php
[OEMBED][UI] Skip adding an image thumbnail for oembed results if we
[quix0rs-gnu-social.git] / actions / deleteuser.php
index ac96b7b5d5498f28d80d09a3d0d3189287c1d374..d1b73f4746080cfebf7312f7fca0deefae372913 100644 (file)
@@ -27,9 +27,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Delete a user
@@ -44,35 +42,30 @@ class DeleteuserAction extends ProfileFormAction
 {
     var $user = null;
 
-    /**
-     * Take arguments for running
-     *
-     * @param array $args $_REQUEST args
-     *
-     * @return boolean success flag
-     */
-    function prepare($args)
+    function prepare(array $args=array())
     {
         if (!parent::prepare($args)) {
             return false;
         }
 
-        $cur = common_current_user();
-
-        assert(!empty($cur)); // checked by parent
+        assert($this->scoped instanceof Profile);
 
-        if (!$cur->hasRight(Right::DELETEUSER)) {
+        if (!$this->scoped->hasRight(Right::DELETEUSER)) {
             // TRANS: Client error displayed when trying to delete a user without having the right to delete users.
-            $this->clientError(_('You cannot delete users.'));
-            return false;
+            throw new AuthorizationException(_('You cannot delete users.'));
         }
 
-        $this->user = User::staticGet('id', $this->profile->id);
-
-        if (empty($this->user)) {
+        try {
+            $this->user = $this->profile->getUser();
+        } catch (NoSuchUserException $e) {
             // TRANS: Client error displayed when trying to delete a non-local user.
-            $this->clientError(_('You can only delete local users.'));
-            return false;
+            throw new ClientException(_('You can only delete local users.'));
+        }
+
+        // Only administrators can delete other privileged users (such as others who have the right to silence).
+        if ($this->profile->isPrivileged() && !$this->scoped->hasRole(Profile_role::ADMINISTRATOR)) {
+            // TRANS: Client error displayed when trying to delete a user that has been granted moderation privileges
+            throw new AuthorizationException(_('You cannot delete other privileged users.'));
         }
 
         return true;
@@ -87,7 +80,7 @@ class DeleteuserAction extends ProfileFormAction
      *
      * @return void
      */
-    function handle($args)
+    function handle()
     {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             if ($this->arg('no')) {
@@ -103,6 +96,8 @@ class DeleteuserAction extends ProfileFormAction
 
     function showContent() {
         $this->areYouSureForm();
+        $block = new AccountProfileBlock($this, $this->profile);
+        $block->show();        
     }
 
     function title() {
@@ -155,14 +150,14 @@ class DeleteuserAction extends ProfileFormAction
                       'submit form_action-primary',
                       'no',
                       // TRANS: Submit button title for 'No' when deleting a user.
-                      _('Do not delete this user'));
+                      _('Do not delete this user.'));
         $this->submit('form_action-yes',
                       // TRANS: Button label on the delete user form.
                       _m('BUTTON','Yes'),
                       'submit form_action-secondary',
                       'yes',
                       // TRANS: Submit button title for 'Yes' when deleting a user.
-                      _('Delete this user'));
+                      _('Delete this user.'));
         $this->elementEnd('fieldset');
         $this->elementEnd('form');
     }