]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Some files got updated coding style
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 15 Apr 2014 08:49:20 +0000 (10:49 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 15 Apr 2014 08:49:20 +0000 (10:49 +0200)
Actions have $this->scoped as the current profile which we can gladly
replace all the $cur=common_current_user() with.

And we want the prepare/handle functions to be protected. Plus only
the prepare function uses $args (which _must_ be an array).

actions/attachment.php
actions/attachment_ajax.php
actions/attachment_thumbnail.php
actions/joingroup.php
actions/leavegroup.php

index 56ecceb860e00cd31e51816abbbd43fa66fb8afc..b532b81d88438ddbf5a91b3a5e854129137531fb 100644 (file)
@@ -60,7 +60,7 @@ class AttachmentAction extends Action
      * @return success flag
      */
 
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
@@ -123,13 +123,11 @@ class AttachmentAction extends Action
      *
      * Only handles get, so just show the page.
      *
-     * @param array $args $_REQUEST data (unused)
-     *
      * @return void
      */
-    function handle($args)
+    protected function handle()
     {
-        parent::handle($args);
+        parent::handle();
 
         if (empty($this->attachment->filename)) {
 
index fb7d15f8a2f0806fb07c0a62abed96cd2f7b67ff..24ecabacf2bebc4c91183f824937373071418873 100644 (file)
@@ -27,9 +27,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
 
 require_once INSTALLDIR.'/actions/attachment.php';
 
@@ -57,7 +55,7 @@ class Attachment_ajaxAction extends AttachmentAction
         }
     }
 
-    function handle($args)
+    protected function handle()
     {
         $this->showPage();
     }
index a90f8fd5f8aac8c7a3746ecb24deb3b763e8f7be..93df840d56a10046f7f938e8a96aadde5dade9a6 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
-
-require_once INSTALLDIR.'/actions/attachment.php';
+if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
 
 /**
  * Show notice attachments
@@ -44,7 +40,7 @@ require_once INSTALLDIR.'/actions/attachment.php';
  */
 class Attachment_thumbnailAction extends AttachmentAction
 {
-    function handle($args)
+    protected function handle()
     {
         $this->showPage();
     }
index c533ebdedb7d3dc2e7b8762a4910520d24553e89..065a0ac9a46ad8e6e4a97fed2066c377c67dc8d9 100644 (file)
@@ -27,9 +27,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Join a group
@@ -50,7 +48,7 @@ class JoingroupAction extends Action
     /**
      * Prepare to run
      */
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
@@ -91,14 +89,12 @@ class JoingroupAction extends Action
             $this->clientError(_('No such group.'), 404);
         }
 
-        $cur = common_current_user();
-
-        if ($cur->isMember($this->group)) {
+        if ($this->scoped->isMember($this->group)) {
             // TRANS: Client error displayed when trying to join a group while already a member.
             $this->clientError(_('You are already a member of that group.'), 403);
         }
 
-        if (Group_block::isBlocked($this->group, $cur->getProfile())) {
+        if (Group_block::isBlocked($this->group, $this->scoped)) {
             // TRANS: Client error displayed when trying to join a group while being blocked form joining it.
             $this->clientError(_('You have been blocked from that group by the admin.'), 403);
         }
@@ -111,27 +107,23 @@ class JoingroupAction extends Action
      *
      * On POST, add the current user to the group
      *
-     * @param array $args unused
-     *
      * @return void
      */
-    function handle($args)
+    protected function handle()
     {
-        parent::handle($args);
-
-        $cur = common_current_user();
+        parent::handle();
 
         try {
-            $result = $cur->joinGroup($this->group);
+            $result = $this->scoped->joinGroup($this->group);
         } catch (Exception $e) {
                common_log(LOG_ERR, sprintf("Couldn't join user %s to group %s: '%s'",
-                                                                       $cur->nickname,
+                                                                       $this->scoped->nickname,
                                                                        $this->group->nickname,
                                                                        $e->getMessage()));
             // TRANS: Server error displayed when joining a group failed in the database.
             // TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed.
             $this->serverError(sprintf(_('Could not join user %1$s to group %2$s.'),
-                                       $cur->nickname, $this->group->nickname));
+                                       $this->scoped->nickname, $this->group->nickname));
             return;
         }
 
@@ -140,7 +132,7 @@ class JoingroupAction extends Action
             $this->elementStart('head');
             // TRANS: Title for join group page after joining.
             $this->element('title', null, sprintf(_m('TITLE','%1$s joined group %2$s'),
-                                                  $cur->nickname,
+                                                  $this->scoped->nickname,
                                                   $this->group->nickname));
             $this->elementEnd('head');
             $this->elementStart('body');
index e0e2c278904249edc54b640909e4296f09b7f9de..f2182c58d2c6df73bc06dbe111b317dbebd44c80 100644 (file)
@@ -27,9 +27,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Leave a group
@@ -50,7 +48,7 @@ class LeavegroupAction extends Action
     /**
      * Prepare to run
      */
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
@@ -91,9 +89,7 @@ class LeavegroupAction extends Action
             $this->clientError(_('No such group.'), 404);
         }
 
-        $cur = common_current_user();
-
-        if (!$cur->isMember($this->group)) {
+        if (!$this->scoped->isMember($this->group)) {
             // TRANS: Client error displayed when trying to join a group while already a member.
             $this->clientError(_('You are not a member of that group.'), 403);
         }
@@ -106,24 +102,20 @@ class LeavegroupAction extends Action
      *
      * On POST, add the current user to the group
      *
-     * @param array $args unused
-     *
      * @return void
      */
-    function handle($args)
+    protected function handle()
     {
-        parent::handle($args);
-
-        $cur = common_current_user();
+        parent::handle();
 
         try {
-            $cur->leaveGroup($this->group);
+            $this->scoped->leaveGroup($this->group);
         } catch (Exception $e) {
-            common_log(LOG_ERR, "Error when {$cur->nickname} tried to leave {$this->group->nickname}: " . $e->getMessage());
+            common_log(LOG_ERR, "Error when {$this->scoped->nickname} tried to leave {$this->group->nickname}: " . $e->getMessage());
             // TRANS: Server error displayed when leaving a group failed in the database.
             // TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
             $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'),
-                                       $cur->nickname, $this->group->nickname));
+                                       $this->scoped->nickname, $this->group->nickname));
             return;
         }
 
@@ -132,7 +124,7 @@ class LeavegroupAction extends Action
             $this->elementStart('head');
             // TRANS: Title for leave group page after leaving.
             $this->element('title', null, sprintf(_m('TITLE','%1$s left group %2$s'),
-                                                  $cur->nickname,
+                                                  $this->scoped->nickname,
                                                   $this->group->nickname));
             $this->elementEnd('head');
             $this->elementStart('body');