git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit fbec7c4e authored by mmn's avatar mmn

Issue #121 - use correct Group ID and strict User_group typing

parent d1e609a8
......@@ -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');
}
/**
......
......@@ -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()));
}
/**
......
......@@ -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()));
}
/**
......
......@@ -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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment