]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/editpeopletag.php
Improved type-hint for following methods:
[quix0rs-gnu-social.git] / actions / editpeopletag.php
index 2bb03470d94367e5bd560fedc46683f3f01e2853..654fbee3393e8b908bb4bc30b3a3a174d294a4ca 100644 (file)
@@ -40,34 +40,41 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
  * @link     http://status.net/
  */
 
-class EditpeopletagAction extends OwnerDesignAction
+class EditpeopletagAction extends Action
 {
-
     var $msg, $confirm, $confirm_args=array();
 
     function title()
     {
         if ($_SERVER['REQUEST_METHOD'] == 'POST' && $this->boolean('delete')) {
-            return sprintf(_('Delete %s people tag'), $this->peopletag->tag);
+            // TRANS: Title for edit list page after deleting a tag.
+            // TRANS: %s is a list.
+            return sprintf(_('Delete %s list'), $this->peopletag->tag);
         }
-        return sprintf(_('Edit people tag %s'), $this->peopletag->tag);
+        // TRANS: Title for edit list page.
+        // TRANS: %s is a list.
+        return sprintf(_('Edit list %s'), $this->peopletag->tag);
     }
 
     /**
      * Prepare to run
      */
 
-    function prepare($args)
+    function prepare(array $args=array())
     {
         parent::prepare($args);
 
         if (!common_logged_in()) {
+            // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
             $this->clientError(_('Not logged in.'));
-            return false;
         }
 
         $id = $this->arg('id');
-        $tagger_arg = $this->arg('tagger');
+        if (common_config('singleuser', 'enabled')) {
+            $tagger_arg = User::singleUserNickname();
+        } else {
+            $tagger_arg = $this->arg('tagger');
+        }
         $tag_arg = $this->arg('tag');
 
         $tagger = common_canonical_nickname($tagger_arg);
@@ -80,39 +87,38 @@ class EditpeopletagAction extends OwnerDesignAction
         if ($tagger_arg != $tagger || $tag_arg != $tag) {
             $args = array('tagger' => $tagger, 'tag' => $tag);
             common_redirect(common_local_url('editpeopletag', $args), 301);
-            return false;
         }
 
         $user = null;
         if ($id) {
-            $this->peopletag = Profile_list::staticGet('id', $id);
+            $this->peopletag = Profile_list::getKV('id', $id);
             if (!empty($this->peopletag)) {
-                $user = User::staticGet('id', $this->peopletag->tagger);
+                $user = User::getKV('id', $this->peopletag->tagger);
             }
         } else {
             if (!$tagger) {
+                // TRANS: Error message displayed when trying to perform an action that requires a tagging user or ID.
                 $this->clientError(_('No tagger or ID.'), 404);
-                return false;
             }
 
-            $user = User::staticGet('nickname', $tagger);
+            $user = User::getKV('nickname', $tagger);
             $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
         }
 
         if (!$this->peopletag) {
-            $this->clientError(_('No such peopletag.'), 404);
-            return false;
+            // TRANS: Client error displayed when referring to a non-existing list.
+            $this->clientError(_('No such list.'), 404);
         }
 
         if (!$user) {
             // This should not be happening
+            // TRANS: Client error displayed when referring to non-local user.
             $this->clientError(_('Not a local user.'), 404);
-            return false;
         }
 
         if ($current->id != $user->id) {
+            // TRANS: Client error displayed when reting to edit a tag that was not self-created.
             $this->clientError(_('You must be the creator of the tag to edit it.'), 404);
-            return false;
         }
 
         $this->tagger = $user->getProfile();
@@ -129,8 +135,7 @@ class EditpeopletagAction extends OwnerDesignAction
      *
      * @return void
      */
-
-    function handle($args)
+    function handle(array $args=array())
     {
         parent::handle($args);
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@@ -208,7 +213,8 @@ class EditpeopletagAction extends OwnerDesignAction
             $this->element('p', 'instructions', $this->confirm);
         } else {
             $this->element('p', 'instructions',
-                           _('Use this form to edit the people tag.'));
+                           // TRANS: Form instruction for edit list form.
+                           _('Use this form to edit the list.'));
         }
     }
 
@@ -228,6 +234,7 @@ class EditpeopletagAction extends OwnerDesignAction
         $cancel      = $this->arg('cancel');
 
         if ($delete && $cancel) {
+            // TRANS: Form validation error displayed if the form data for deleting a tag was incorrect.
             $this->showForm(_('Delete aborted.'));
             return;
         }
@@ -235,24 +242,35 @@ class EditpeopletagAction extends OwnerDesignAction
         $set_private = $private && $this->peopletag->private != $private;
 
         if ($delete && !$confirm) {
+            // TRANS: Text in confirmation dialog for deleting a tag.
             $this->showConfirm(_('Deleting this tag will permanantly remove ' .
                                  'all its subscription and membership records. ' .
                                  'Do you still want to continue?'), array('delete' => 1));
             return;
         } else if (common_valid_tag($tag)) {
+            // TRANS: Form validation error displayed if a given tag is invalid.
             $this->showForm(_('Invalid tag.'));
             return;
         } else if ($tag != $this->peopletag->tag && $this->tagExists($tag)) {
+            // TRANS: Form validation error displayed if a given tag is already present.
+            // TRANS: %s is the already present tag.
             $this->showForm(sprintf(_('You already have a tag named %s.'), $tag));
             return;
         } else if (Profile_list::descriptionTooLong($description)) {
-            $this->showForm(sprintf(_('description is too long (max %d chars).'), Profile_list::maxDescription()));
+            $this->showForm(sprintf(
+                    // TRANS: Client error shown when providing too long a description when editing a list.
+                    // TRANS: %d is the maximum number of allowed characters.
+                    _m('Description is too long (maximum %d character).',
+                      'Description is too long (maximum %d characters).',
+                      Profile_list::maxDescription()),
+                    Profile_list::maxDescription()));
             return;
         } else if ($set_private && !$confirm && !$cancel) {
             $fwd = array('tag' => $tag,
                          'description' => $description,
                          'private' => (int) $private);
 
+            // TRANS: Text in confirmation dialog for setting a tag from public to private.
             $this->showConfirm(_('Setting a public tag as private will ' .
                                  'permanently remove all the existing ' .
                                  'subscriptions to it. Do you still want to continue?'), $fwd);
@@ -273,7 +291,8 @@ class EditpeopletagAction extends OwnerDesignAction
 
         if (!$result) {
             common_log_db_error($this->group, 'UPDATE', __FILE__);
-            $this->serverError(_('Could not update peopletag.'));
+            // TRANS: Server error displayed when updating a list fails.
+            $this->serverError(_('Could not update list.'));
         }
 
         $this->peopletag->query('COMMIT');
@@ -286,9 +305,7 @@ class EditpeopletagAction extends OwnerDesignAction
             // This might take quite a bit of time.
             $this->peopletag->delete();
             // send home.
-            common_redirect(common_local_url('all',
-                                         array('nickname' => $this->tagger->nickname)),
-                            303);
+            common_redirect(common_local_url('all', array('nickname' => $this->tagger->nickname)), 303);
         }
 
         if ($tag != $orig->tag) {
@@ -297,6 +314,7 @@ class EditpeopletagAction extends OwnerDesignAction
                                                    'tag'    => $tag)),
                             303);
         } else {
+            // TRANS: Edit list form success message.
             $this->showForm(_('Options saved.'));
         }
     }