From fbec7c4e75df33957ff21f8766d679de95cf0735 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sat, 9 Jan 2016 14:06:31 +0100 Subject: [PATCH] Issue #121 - use correct Group ID and strict User_group typing --- lib/deletegroupform.php | 15 ++++++--------- lib/joinform.php | 15 +++++---------- lib/leaveform.php | 15 +++++---------- plugins/Directory/lib/sortablegrouplist.php | 8 ++++---- 4 files changed, 20 insertions(+), 33 deletions(-) diff --git a/lib/deletegroupform.php b/lib/deletegroupform.php index 65bc34812e..97534905e4 100644 --- a/lib/deletegroupform.php +++ b/lib/deletegroupform.php @@ -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'); } /** diff --git a/lib/joinform.php b/lib/joinform.php index a1a6189b08..ef868553fc 100644 --- a/lib/joinform.php +++ b/lib/joinform.php @@ -28,11 +28,7 @@ * @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())); } /** diff --git a/lib/leaveform.php b/lib/leaveform.php index a32af18eda..9a4dc33f8e 100644 --- a/lib/leaveform.php +++ b/lib/leaveform.php @@ -28,11 +28,7 @@ * @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())); } /** diff --git a/plugins/Directory/lib/sortablegrouplist.php b/plugins/Directory/lib/sortablegrouplist.php index 94ee054df3..0da705e919 100644 --- a/plugins/Directory/lib/sortablegrouplist.php +++ b/plugins/Directory/lib/sortablegrouplist.php @@ -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(); }