]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Issue #121 - use correct Group ID and strict User_group typing
authorMikael Nordfeldth <mmn@hethane.se>
Sat, 9 Jan 2016 13:06:31 +0000 (14:06 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Sat, 9 Jan 2016 13:06:50 +0000 (14:06 +0100)
lib/deletegroupform.php
lib/joinform.php
lib/leaveform.php
plugins/Directory/lib/sortablegrouplist.php

index 65bc34812e7039dbcc84dfc84632631b612d2ba0..97534905e4feb003d7ce55e1687262dcb8e3050b 100644 (file)
@@ -29,9 +29,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Form for deleting a group
@@ -58,9 +56,9 @@ class DeleteGroupForm extends Form
      * Constructor
      *
      * @param HTMLOutputter $out   output channel
-     * @param group         $group group to join
+     * @param User_group    $group group to join
      */
-    function __construct($out=null, $group=null)
+    function __construct(HTMLOutputter $out=null, User_group $group=null)
     {
         parent::__construct($out);
 
@@ -74,7 +72,7 @@ class DeleteGroupForm extends Form
      */
     function id()
     {
-        return 'group-delete-' . $this->group->id;
+        return 'group-delete-' . $this->group->getID();
     }
 
     /**
@@ -94,14 +92,13 @@ class DeleteGroupForm extends Form
      */
     function action()
     {
-        return common_local_url('deletegroup',
-                                array('id' => $this->group->id));
+        return common_local_url('deletegroup', array('id' => $this->group->getID()));
     }
 
     function formData()
     {
         $this->out->hidden($this->id() . '-returnto-action', 'groupbyid', 'returnto-action');
-        $this->out->hidden($this->id() . '-returnto-id', $this->group->id, 'returnto-id');
+        $this->out->hidden($this->id() . '-returnto-id', $this->group->getID(), 'returnto-id');
     }
 
     /**
index a1a6189b089b65a1989175bbe62be670bbc7aabb..ef868553fcc0917f494973f1a76d3e624b10f1e6 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
-
-require_once INSTALLDIR.'/lib/form.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Form for joining a group
@@ -57,9 +53,9 @@ class JoinForm extends Form
      * Constructor
      *
      * @param HTMLOutputter $out   output channel
-     * @param group         $group group to join
+     * @param User_group    $group group to join
      */
-    function __construct($out=null, $group=null)
+    function __construct(HTMLOutputter $out=null, User_group $group=null)
     {
         parent::__construct($out);
 
@@ -73,7 +69,7 @@ class JoinForm extends Form
      */
     function id()
     {
-        return 'group-join-' . $this->group->id;
+        return 'group-join-' . $this->group->getID();
     }
 
     /**
@@ -93,8 +89,7 @@ class JoinForm extends Form
      */
     function action()
     {
-        return common_local_url('joingroup',
-                                array('id' => $this->group->id));
+        return common_local_url('joingroup', array('id' => $this->group->getID()));
     }
 
     /**
index a32af18eda07083beae4a75c2af0a48187cb455c..9a4dc33f8e32066c03384012d63731e772c55b50 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
-
-require_once INSTALLDIR.'/lib/form.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Form for leaving a group
@@ -58,9 +54,9 @@ class LeaveForm extends Form
      * Constructor
      *
      * @param HTMLOutputter $out   output channel
-     * @param group         $group group to leave
+     * @param User_group    $group group to leave
      */
-    function __construct($out=null, $group=null)
+    function __construct(HTMLOutputter $out=null, User_group $group=null)
     {
         parent::__construct($out);
 
@@ -74,7 +70,7 @@ class LeaveForm extends Form
      */
     function id()
     {
-        return 'group-leave-' . $this->group->id;
+        return 'group-leave-' . $this->group->getID();
     }
 
     /**
@@ -94,8 +90,7 @@ class LeaveForm extends Form
      */
     function action()
     {
-        return common_local_url('leavegroup',
-                                array('id' => $this->group->id));
+        return common_local_url('leavegroup', array('id' => $this->group->getID()));
     }
 
     /**
index 94ee054df3a076a914fddea0fb54c62ff3665d54..0da705e9195a2527afe3cbe9daf9b55395db26eb 100644 (file)
@@ -196,7 +196,7 @@ class SortableGroupListItem extends SortableSubscriptionListItem
         $r2args['action'] = $action;
         if ($cur instanceof User && $cur->hasRight(Right::DELETEGROUP)) {
             $this->out->elementStart('li', 'entity_delete');
-            $df = new DeleteGroupForm($this->out, $this->profile, $r2args);
+            $df = new DeleteGroupForm($this->out, $this->profile->getGroup(), $r2args);
             $df->show();
             $this->out->elementEnd('li');
         }
@@ -224,10 +224,10 @@ class SortableGroupListItem extends SortableSubscriptionListItem
             // XXX: special-case for user looking at own
             // subscriptions page
             if ($user->isMember($this->profile->getGroup())) {
-                $lf = new LeaveForm($this->out, $this->profile);
+                $lf = new LeaveForm($this->out, $this->profile->getGroup());
                 $lf->show();
-            } else if (!Group_block::isBlocked($this->profile, $user->getProfile())) {
-                $jf = new JoinForm($this->out, $this->profile);
+            } else if (!Group_block::isBlocked($this->profile->getGroup(), $user->getProfile())) {
+                $jf = new JoinForm($this->out, $this->profile->getGroup());
                 $jf->show();
             }