Various obvious bug fixes and better PHP 7 support

Many of these came from a XRevan86 patch
This commit is contained in:
Diogo Cordeiro
2019-04-26 00:34:17 +01:00
parent c4f962a7d0
commit 7967db6ff5
28 changed files with 652 additions and 681 deletions

View File

@@ -51,13 +51,15 @@ class GroupinboxAction extends GroupAction
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
* @param array $args misc. arguments
*
* @return boolean true
* @throws ClientException
* @throws NicknameException
*/
function prepare($argarray)
function prepare(array $args = [])
{
parent::prepare($argarray);
parent::prepare($args);
$cur = common_current_user();
@@ -101,8 +103,8 @@ class GroupinboxAction extends GroupAction
}
$this->gm = Group_message::forGroup($this->group,
($this->page - 1) * MESSAGES_PER_PAGE,
MESSAGES_PER_PAGE + 1);
($this->page - 1) * MESSAGES_PER_PAGE,
MESSAGES_PER_PAGE + 1);
return true;
}
@@ -128,20 +130,18 @@ class GroupinboxAction extends GroupAction
$this->element('p', 'guide', _m('This group has not received any private messages.'));
}
$this->pagination($this->page > 1,
$cnt > MESSAGES_PER_PAGE,
$this->page,
'groupinbox',
array('nickname' => $this->group->nickname));
$cnt > MESSAGES_PER_PAGE,
$this->page,
'groupinbox',
array('nickname' => $this->group->nickname));
}
/**
* Handler method
*
* @param array $argarray is ignored since it's now passed in in prepare()
*
* @return void
*/
function handle($argarray=null)
function handle()
{
$this->showPage();
}
@@ -176,8 +176,8 @@ class GroupinboxAction extends GroupAction
// TRANS: Page title for any but first group page.
// TRANS: %1$s is a group name, $2$s is a page number.
return sprintf(_m('%1$s group inbox, page %2$d'),
$base,
$this->page);
$base,
$this->page);
}
}
@@ -190,7 +190,7 @@ class GroupinboxAction extends GroupAction
*/
function showPageNotice()
{
$instr = $this->getInstructions();
$instr = $this->getInstructions();
$output = common_markup_to_html($instr);
$this->elementStart('div', 'instructions');

View File

@@ -53,13 +53,15 @@ class NewgroupmessageAction extends Action
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
* @param array $args misc. arguments
*
* @return boolean true
* @throws ClientException
* @throws NicknameException
*/
function prepare($argarray)
function prepare(array $args = [])
{
parent::prepare($argarray);
parent::prepare($args);
$this->user = common_current_user();
@@ -71,7 +73,7 @@ class NewgroupmessageAction extends Action
if (!$this->user->hasRight(Right::NEWMESSAGE)) {
// TRANS: Exception thrown when user %s is not allowed to send a private group message.
throw new Exception(sprintf(_m('User %s is not allowed to send private messages.'),
$this->user->nickname));
$this->user->nickname));
}
$nicknameArg = $this->trimmed('nickname');
@@ -112,11 +114,9 @@ class NewgroupmessageAction extends Action
/**
* Handler method
*
* @param array $argarray is ignored since it's now passed in in prepare()
*
* @return void
*/
function handle($argarray=null)
function handle()
{
if ($this->isPost()) {
$this->sendNewMessage();
@@ -125,12 +125,6 @@ class NewgroupmessageAction extends Action
}
}
function showNoticeForm()
{
$form = new GroupMessageForm($this, $this->group);
$form->show();
}
function sendNewMessage()
{
$gm = Group_message::send($this->user, $this->group, $this->text);
@@ -143,10 +137,10 @@ class NewgroupmessageAction extends Action
$this->elementEnd('head');
$this->elementStart('body');
$this->element('p',
array('id' => 'command_result'),
// TRANS: Succes text after sending a direct message to group %s.
sprintf(_m('Direct message to %s sent.'),
$this->group->nickname));
array('id' => 'command_result'),
// TRANS: Succes text after sending a direct message to group %s.
sprintf(_m('Direct message to %s sent.'),
$this->group->nickname));
$this->elementEnd('body');
$this->endHTML();
} else {
@@ -154,6 +148,12 @@ class NewgroupmessageAction extends Action
}
}
function showNoticeForm()
{
$form = new GroupMessageForm($this, $this->group);
$form->show();
}
function title()
{
// TRANS: Title of form for new private group message.

View File

@@ -54,20 +54,22 @@ class ShowgroupmessageAction extends Action
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
* @param array $args misc. arguments
*
* @return boolean true
* @throws ClientException
* @throws ServerException
*/
function prepare($argarray)
function prepare(array $args = [])
{
parent::prepare($argarray);
parent::prepare($args);
$this->user = common_current_user();
if (empty($this->user)) {
// TRANS: Client exception thrown when trying to view group private messages without being logged in.
throw new ClientException(_m('Only logged-in users can view private messages.'),
403);
403);
}
$id = $this->trimmed('id');
@@ -104,11 +106,9 @@ class ShowgroupmessageAction extends Action
/**
* Handler method
*
* @param array $argarray is ignored since it's now passed in in prepare()
*
* @return void
*/
function handle($argarray=null)
function handle()
{
$this->showPage();
}
@@ -121,9 +121,9 @@ class ShowgroupmessageAction extends Action
// TRANS: Title for private group message.
// TRANS: %1$s is the sender name, %2$s is the group name, %3$s is a timestamp.
return sprintf(_m('Message from %1$s to group %2$s on %3$s'),
$this->sender->nickname,
$this->group->nickname,
common_exact_date($this->gm->created));
$this->sender->nickname,
$this->group->nickname,
common_exact_date($this->gm->created));
}
/**
@@ -161,8 +161,8 @@ class ShowgroupmessageAction extends Action
function lastModified()
{
return max(strtotime($this->group->modified),
strtotime($this->sender->modified),
strtotime($this->gm->modified));
strtotime($this->sender->modified),
strtotime($this->gm->modified));
}
/**
@@ -182,11 +182,11 @@ class ShowgroupmessageAction extends Action
}
return 'W/"' . implode(':', array($this->arg('action'),
common_user_cache_hash(),
common_language(),
$this->gm->id,
strtotime($this->sender->modified),
strtotime($this->group->modified),
$avtime)) . '"';
common_user_cache_hash(),
common_language(),
$this->gm->id,
strtotime($this->sender->modified),
strtotime($this->group->modified),
$avtime)) . '"';
}
}