Some files got updated coding style
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).
This commit is contained in:
parent
90a593718f
commit
418b3c3c53
@ -60,7 +60,7 @@ class AttachmentAction extends Action
|
|||||||
* @return success flag
|
* @return success flag
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function prepare($args)
|
protected function prepare(array $args=array())
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
@ -123,13 +123,11 @@ class AttachmentAction extends Action
|
|||||||
*
|
*
|
||||||
* Only handles get, so just show the page.
|
* Only handles get, so just show the page.
|
||||||
*
|
*
|
||||||
* @param array $args $_REQUEST data (unused)
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function handle($args)
|
protected function handle()
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle();
|
||||||
|
|
||||||
if (empty($this->attachment->filename)) {
|
if (empty($this->attachment->filename)) {
|
||||||
|
|
||||||
|
@ -27,9 +27,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/actions/attachment.php';
|
require_once INSTALLDIR.'/actions/attachment.php';
|
||||||
|
|
||||||
@ -57,7 +55,7 @@ class Attachment_ajaxAction extends AttachmentAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle($args)
|
protected function handle()
|
||||||
{
|
{
|
||||||
$this->showPage();
|
$this->showPage();
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once INSTALLDIR.'/actions/attachment.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show notice attachments
|
* Show notice attachments
|
||||||
@ -44,7 +40,7 @@ require_once INSTALLDIR.'/actions/attachment.php';
|
|||||||
*/
|
*/
|
||||||
class Attachment_thumbnailAction extends AttachmentAction
|
class Attachment_thumbnailAction extends AttachmentAction
|
||||||
{
|
{
|
||||||
function handle($args)
|
protected function handle()
|
||||||
{
|
{
|
||||||
$this->showPage();
|
$this->showPage();
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Join a group
|
* Join a group
|
||||||
@ -50,7 +48,7 @@ class JoingroupAction extends Action
|
|||||||
/**
|
/**
|
||||||
* Prepare to run
|
* Prepare to run
|
||||||
*/
|
*/
|
||||||
function prepare($args)
|
protected function prepare(array $args=array())
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
@ -91,14 +89,12 @@ class JoingroupAction extends Action
|
|||||||
$this->clientError(_('No such group.'), 404);
|
$this->clientError(_('No such group.'), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cur = common_current_user();
|
if ($this->scoped->isMember($this->group)) {
|
||||||
|
|
||||||
if ($cur->isMember($this->group)) {
|
|
||||||
// TRANS: Client error displayed when trying to join a group while already a member.
|
// 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);
|
$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.
|
// 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);
|
$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
|
* On POST, add the current user to the group
|
||||||
*
|
*
|
||||||
* @param array $args unused
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function handle($args)
|
protected function handle()
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle();
|
||||||
|
|
||||||
$cur = common_current_user();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$result = $cur->joinGroup($this->group);
|
$result = $this->scoped->joinGroup($this->group);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
common_log(LOG_ERR, sprintf("Couldn't join user %s to group %s: '%s'",
|
common_log(LOG_ERR, sprintf("Couldn't join user %s to group %s: '%s'",
|
||||||
$cur->nickname,
|
$this->scoped->nickname,
|
||||||
$this->group->nickname,
|
$this->group->nickname,
|
||||||
$e->getMessage()));
|
$e->getMessage()));
|
||||||
// TRANS: Server error displayed when joining a group failed in the database.
|
// 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.
|
// 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.'),
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +132,7 @@ class JoingroupAction extends Action
|
|||||||
$this->elementStart('head');
|
$this->elementStart('head');
|
||||||
// TRANS: Title for join group page after joining.
|
// TRANS: Title for join group page after joining.
|
||||||
$this->element('title', null, sprintf(_m('TITLE','%1$s joined group %2$s'),
|
$this->element('title', null, sprintf(_m('TITLE','%1$s joined group %2$s'),
|
||||||
$cur->nickname,
|
$this->scoped->nickname,
|
||||||
$this->group->nickname));
|
$this->group->nickname));
|
||||||
$this->elementEnd('head');
|
$this->elementEnd('head');
|
||||||
$this->elementStart('body');
|
$this->elementStart('body');
|
||||||
|
@ -27,9 +27,7 @@
|
|||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Leave a group
|
* Leave a group
|
||||||
@ -50,7 +48,7 @@ class LeavegroupAction extends Action
|
|||||||
/**
|
/**
|
||||||
* Prepare to run
|
* Prepare to run
|
||||||
*/
|
*/
|
||||||
function prepare($args)
|
protected function prepare(array $args=array())
|
||||||
{
|
{
|
||||||
parent::prepare($args);
|
parent::prepare($args);
|
||||||
|
|
||||||
@ -91,9 +89,7 @@ class LeavegroupAction extends Action
|
|||||||
$this->clientError(_('No such group.'), 404);
|
$this->clientError(_('No such group.'), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cur = common_current_user();
|
if (!$this->scoped->isMember($this->group)) {
|
||||||
|
|
||||||
if (!$cur->isMember($this->group)) {
|
|
||||||
// TRANS: Client error displayed when trying to join a group while already a member.
|
// 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);
|
$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
|
* On POST, add the current user to the group
|
||||||
*
|
*
|
||||||
* @param array $args unused
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function handle($args)
|
protected function handle()
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle();
|
||||||
|
|
||||||
$cur = common_current_user();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$cur->leaveGroup($this->group);
|
$this->scoped->leaveGroup($this->group);
|
||||||
} catch (Exception $e) {
|
} 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: 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.
|
// 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.'),
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +124,7 @@ class LeavegroupAction extends Action
|
|||||||
$this->elementStart('head');
|
$this->elementStart('head');
|
||||||
// TRANS: Title for leave group page after leaving.
|
// TRANS: Title for leave group page after leaving.
|
||||||
$this->element('title', null, sprintf(_m('TITLE','%1$s left group %2$s'),
|
$this->element('title', null, sprintf(_m('TITLE','%1$s left group %2$s'),
|
||||||
$cur->nickname,
|
$this->scoped->nickname,
|
||||||
$this->group->nickname));
|
$this->group->nickname));
|
||||||
$this->elementEnd('head');
|
$this->elementEnd('head');
|
||||||
$this->elementStart('body');
|
$this->elementStart('body');
|
||||||
|
Loading…
Reference in New Issue
Block a user