Various obvious bug fixes and better PHP 7 support
Many of these came from a XRevan86 patch
This commit is contained in:
parent
c4f962a7d0
commit
7967db6ff5
@ -56,20 +56,20 @@ class DeleteaccountAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
if (empty($cur)) {
|
||||
// TRANS: Client exception displayed trying to delete a user account while not logged in.
|
||||
throw new ClientException(_("Only logged-in users ".
|
||||
"can delete their account."), 403);
|
||||
throw new ClientException(_("Only logged-in users can delete their account."), 403);
|
||||
}
|
||||
|
||||
if (!$cur->hasRight(Right::DELETEACCOUNT)) {
|
||||
@ -83,20 +83,71 @@ class DeleteaccountAction extends Action
|
||||
/**
|
||||
* Handler method
|
||||
*
|
||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
||||
*
|
||||
* @return void
|
||||
* @throws AuthorizationException
|
||||
* @throws ServerException
|
||||
*/
|
||||
function handle($argarray=null)
|
||||
function handle()
|
||||
{
|
||||
parent::handle($argarray);
|
||||
parent::handle();
|
||||
|
||||
if ($this->isPost()) {
|
||||
$this->deleteAccount();
|
||||
} else {
|
||||
$this->showPage();
|
||||
}
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the current user's account
|
||||
*
|
||||
* Checks for the "I am sure." string to make sure the user really
|
||||
* wants to delete their account.
|
||||
*
|
||||
* Then, marks the account as deleted and begins the deletion process
|
||||
* (actually done by a back-end handler).
|
||||
*
|
||||
* If successful it logs the user out, and shows a brief completion message.
|
||||
*
|
||||
* @return void
|
||||
* @throws AuthorizationException
|
||||
* @throws ServerException
|
||||
*/
|
||||
function deleteAccount()
|
||||
{
|
||||
$this->checkSessionToken();
|
||||
// !!! If this string is changed, it also needs to be changed in DeleteAccountForm::formData()
|
||||
// TRANS: Confirmation text for user deletion. The user has to type this exactly the same, including punctuation.
|
||||
$iamsure = _('I am sure.');
|
||||
if ($this->trimmed('iamsure') != $iamsure) {
|
||||
// TRANS: Notification for user about the text that must be input to be able to delete a user account.
|
||||
// TRANS: %s is the text that needs to be input.
|
||||
$this->_error = sprintf(_('You must write "%s" exactly in the box.'), $iamsure);
|
||||
$this->showPage();
|
||||
return null;
|
||||
}
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
// Mark the account as deleted and shove low-level deletion tasks
|
||||
// to background queues. Removing a lot of posts can take a while...
|
||||
|
||||
if (!$cur->hasRole(Profile_role::DELETED)) {
|
||||
$cur->grantRole(Profile_role::DELETED);
|
||||
}
|
||||
|
||||
$qm = QueueManager::get();
|
||||
$qm->enqueue($cur, 'deluser');
|
||||
|
||||
// The user is really-truly logged out
|
||||
|
||||
common_set_user(null);
|
||||
common_real_login(false); // not logged in
|
||||
common_forgetme(); // don't log back in!
|
||||
|
||||
$this->_complete = true;
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,55 +190,6 @@ class DeleteaccountAction extends Action
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the current user's account
|
||||
*
|
||||
* Checks for the "I am sure." string to make sure the user really
|
||||
* wants to delete their account.
|
||||
*
|
||||
* Then, marks the account as deleted and begins the deletion process
|
||||
* (actually done by a back-end handler).
|
||||
*
|
||||
* If successful it logs the user out, and shows a brief completion message.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function deleteAccount()
|
||||
{
|
||||
$this->checkSessionToken();
|
||||
// !!! If this string is changed, it also needs to be changed in DeleteAccountForm::formData()
|
||||
// TRANS: Confirmation text for user deletion. The user has to type this exactly the same, including punctuation.
|
||||
$iamsure = _('I am sure.');
|
||||
if ($this->trimmed('iamsure') != $iamsure ) {
|
||||
// TRANS: Notification for user about the text that must be input to be able to delete a user account.
|
||||
// TRANS: %s is the text that needs to be input.
|
||||
$this->_error = sprintf(_('You must write "%s" exactly in the box.'), $iamsure);
|
||||
$this->showPage();
|
||||
return;
|
||||
}
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
// Mark the account as deleted and shove low-level deletion tasks
|
||||
// to background queues. Removing a lot of posts can take a while...
|
||||
|
||||
if (!$cur->hasRole(Profile_role::DELETED)) {
|
||||
$cur->grantRole(Profile_role::DELETED);
|
||||
}
|
||||
|
||||
$qm = QueueManager::get();
|
||||
$qm->enqueue($cur, 'deluser');
|
||||
|
||||
// The user is really-truly logged out
|
||||
|
||||
common_set_user(null);
|
||||
common_real_login(false); // not logged in
|
||||
common_forgetme(); // don't log back in!
|
||||
|
||||
$this->_complete = true;
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the page content.
|
||||
*
|
||||
@ -204,7 +206,7 @@ class DeleteaccountAction extends Action
|
||||
$this->element('p', 'confirmation',
|
||||
// TRANS: Confirmation that a user account has been deleted.
|
||||
_('Account deleted.'));
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!empty($this->_error)) {
|
||||
@ -276,15 +278,12 @@ class DeleteAccountForm extends Form
|
||||
$cur = common_current_user();
|
||||
|
||||
// TRANS: Form text for user deletion form.
|
||||
$msg = '<p>' . _('This will <strong>permanently delete</strong> '.
|
||||
'your account data from this server.') . '</p>';
|
||||
$msg = '<p>' . _('This will <strong>permanently delete</strong> your account data from this server.') . '</p>';
|
||||
|
||||
if ($cur->hasRight(Right::BACKUPACCOUNT)) {
|
||||
// TRANS: Additional form text for user deletion form shown if a user has account backup rights.
|
||||
// TRANS: %s is a URL to the backup page.
|
||||
$msg .= '<p>' . sprintf(_('You are strongly advised to '.
|
||||
'<a href="%s">back up your data</a>'.
|
||||
' before deletion.'),
|
||||
$msg .= '<p>' . sprintf(_('You are strongly advised to <a href="%s">back up your data</a> before deletion.'),
|
||||
common_local_url('backupaccount')) . '</p>';
|
||||
}
|
||||
|
||||
|
@ -63,13 +63,14 @@ class RestoreaccountAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
@ -89,20 +90,19 @@ class RestoreaccountAction extends Action
|
||||
/**
|
||||
* Handler method
|
||||
*
|
||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
||||
*
|
||||
* @return void
|
||||
* @throws ClientException
|
||||
*/
|
||||
function handle($argarray=null)
|
||||
function handle()
|
||||
{
|
||||
parent::handle($argarray);
|
||||
parent::handle();
|
||||
|
||||
if ($this->isPost()) {
|
||||
$this->restoreAccount();
|
||||
} else {
|
||||
$this->showPage();
|
||||
}
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,6 +111,8 @@ class RestoreaccountAction extends Action
|
||||
* Uses the UserActivityStream class; may take a long time!
|
||||
*
|
||||
* @return void
|
||||
* @throws ClientException
|
||||
* @throws Exception
|
||||
*/
|
||||
function restoreAccount()
|
||||
{
|
||||
@ -128,41 +130,33 @@ class RestoreaccountAction extends Action
|
||||
// TRANS: Client exception thrown when an uploaded file is larger than set in php.ini.
|
||||
throw new ClientException(_('The uploaded file exceeds the ' .
|
||||
'upload_max_filesize directive in php.ini.'));
|
||||
return;
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
throw new ClientException(
|
||||
// TRANS: Client exception.
|
||||
_('The uploaded file exceeds the MAX_FILE_SIZE directive' .
|
||||
' that was specified in the HTML form.'));
|
||||
return;
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
@unlink($_FILES['restorefile']['tmp_name']);
|
||||
// TRANS: Client exception.
|
||||
throw new ClientException(_('The uploaded file was only' .
|
||||
' partially uploaded.'));
|
||||
return;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
// TRANS: Client exception. No file; probably just a non-AJAX submission.
|
||||
throw new ClientException(_('No uploaded file.'));
|
||||
return;
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
// TRANS: Client exception thrown when a temporary folder is not present to store a file upload.
|
||||
throw new ClientException(_('Missing a temporary folder.'));
|
||||
return;
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
// TRANS: Client exception thrown when writing to disk is not possible during a file upload operation.
|
||||
throw new ClientException(_('Failed to write file to disk.'));
|
||||
return;
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
// TRANS: Client exception thrown when a file upload operation has been stopped by an extension.
|
||||
throw new ClientException(_('File upload stopped by extension.'));
|
||||
return;
|
||||
default:
|
||||
common_log(LOG_ERR, __METHOD__ . ": Unknown upload error " .
|
||||
$_FILES['restorefile']['error']);
|
||||
// TRANS: Client exception thrown when a file upload operation has failed with an unknown reason.
|
||||
throw new ClientException(_('System error uploading file.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = $_FILES['restorefile']['tmp_name'];
|
||||
@ -210,7 +204,7 @@ class RestoreaccountAction extends Action
|
||||
// Enqueue for processing.
|
||||
|
||||
$qm = QueueManager::get();
|
||||
$qm->enqueue(array(common_current_user(), $xml, false), 'feedimp');
|
||||
$qm->enqueue([common_current_user(), $xml, false], 'feedimp');
|
||||
|
||||
if ($qm instanceof UnQueueManager) {
|
||||
// No active queuing means we've actually just completed the job!
|
||||
|
@ -52,13 +52,14 @@ class SelftagAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
$this->tag = $this->trimmed('tag');
|
||||
|
||||
@ -67,7 +68,7 @@ class SelftagAction extends Action
|
||||
// TRANS: %s is the invalid list name.
|
||||
$this->clientError(sprintf(_('Not a valid list: %s.'),
|
||||
$this->tag));
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->page = ($this->arg('page')) ? $this->arg('page') : 1;
|
||||
@ -80,13 +81,11 @@ class SelftagAction extends Action
|
||||
/**
|
||||
* Handler method
|
||||
*
|
||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
* @return void is read only action?
|
||||
*/
|
||||
function handle($argarray)
|
||||
function handle()
|
||||
{
|
||||
parent::handle($argarray);
|
||||
parent::handle();
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
@ -94,8 +93,6 @@ class SelftagAction extends Action
|
||||
* Whips up a query to get a list of profiles based on the provided
|
||||
* people tag and page, initalizes a ProfileList widget, and displays
|
||||
* it to the user.
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
function showContent()
|
||||
{
|
||||
@ -195,7 +192,7 @@ class SelfTagProfileListItem extends ProfileListItem
|
||||
|
||||
$user = common_current_user();
|
||||
|
||||
if (!empty($user) && $user->id != $this->profile->id &&
|
||||
if (!empty($user) && $user->id != $this->profile->getID() &&
|
||||
$user->getProfile()->canTag($this->profile)) {
|
||||
$yourtags = new PeopleTagsWidget($this->out, $user, $this->profile);
|
||||
$yourtags->show();
|
||||
|
@ -48,27 +48,28 @@ require_once INSTALLDIR.'/lib/noticelist.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class SpamAction extends Action
|
||||
{
|
||||
var $page = null;
|
||||
var $notices = null;
|
||||
|
||||
function title() {
|
||||
function title()
|
||||
{
|
||||
return _("Latest Spam");
|
||||
}
|
||||
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page') + 0) : 1;
|
||||
|
||||
@ -99,12 +100,10 @@ class SpamAction 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()
|
||||
{
|
||||
parent::handle();
|
||||
|
||||
|
@ -54,14 +54,16 @@ class TrainAction 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);
|
||||
|
||||
// User must be logged in.
|
||||
|
||||
@ -111,12 +113,11 @@ class TrainAction extends Action
|
||||
/**
|
||||
* Handler method
|
||||
*
|
||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
||||
*
|
||||
* @return void
|
||||
* @throws ClientException
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
function handle()
|
||||
{
|
||||
// Train
|
||||
|
||||
|
@ -43,7 +43,6 @@ if (!defined('STATUSNET')) {
|
||||
*
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
|
||||
class Spam_score extends Managed_DataObject
|
||||
{
|
||||
const MAX_SCALE = 10000;
|
||||
@ -53,25 +52,8 @@ class Spam_score extends Managed_DataObject
|
||||
public $score; // float
|
||||
public $created; // datetime
|
||||
|
||||
function saveNew($notice, $result) {
|
||||
|
||||
$score = new Spam_score();
|
||||
|
||||
$score->notice_id = $notice->id;
|
||||
$score->score = $result->probability;
|
||||
$score->is_spam = $result->isSpam;
|
||||
$score->scaled = Spam_score::scale($score->score);
|
||||
$score->created = common_sql_now();
|
||||
$score->notice_created = $notice->created;
|
||||
|
||||
$score->insert();
|
||||
|
||||
self::blow('spam_score:notice_ids');
|
||||
|
||||
return $score;
|
||||
}
|
||||
|
||||
function save($notice, $result) {
|
||||
public static function save($notice, $result)
|
||||
{
|
||||
|
||||
$orig = null;
|
||||
$score = Spam_score::getKV('notice_id', $notice->id);
|
||||
@ -100,13 +82,6 @@ class Spam_score extends Managed_DataObject
|
||||
return $score;
|
||||
}
|
||||
|
||||
function delete($useWhere=false)
|
||||
{
|
||||
self::blow('spam_score:notice_ids');
|
||||
self::blow('spam_score:notice_ids;last');
|
||||
return parent::delete($useWhere);
|
||||
}
|
||||
|
||||
/**
|
||||
* The One True Thingy that must be defined and declared.
|
||||
*/
|
||||
@ -194,9 +169,35 @@ class Spam_score extends Managed_DataObject
|
||||
}
|
||||
}
|
||||
|
||||
function saveNew($notice, $result)
|
||||
{
|
||||
|
||||
$score = new Spam_score();
|
||||
|
||||
$score->notice_id = $notice->id;
|
||||
$score->score = $result->probability;
|
||||
$score->is_spam = $result->isSpam;
|
||||
$score->scaled = Spam_score::scale($score->score);
|
||||
$score->created = common_sql_now();
|
||||
$score->notice_created = $notice->created;
|
||||
|
||||
$score->insert();
|
||||
|
||||
self::blow('spam_score:notice_ids');
|
||||
|
||||
return $score;
|
||||
}
|
||||
|
||||
public static function scale($score)
|
||||
{
|
||||
$raw = round($score * Spam_score::MAX_SCALE);
|
||||
return max(0, min(Spam_score::MAX_SCALE, $raw));
|
||||
}
|
||||
|
||||
public function delete($useWhere = false)
|
||||
{
|
||||
self::blow('spam_score:notice_ids');
|
||||
self::blow('spam_score:notice_ids;last');
|
||||
return parent::delete($useWhere);
|
||||
}
|
||||
}
|
||||
|
@ -63,13 +63,14 @@ class ImportdeliciousAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
$cur = common_current_user();
|
||||
|
||||
@ -91,13 +92,12 @@ class ImportdeliciousAction extends Action
|
||||
/**
|
||||
* Handler method
|
||||
*
|
||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
||||
*
|
||||
* @return void
|
||||
* @throws ClientException
|
||||
*/
|
||||
function handle($argarray=null)
|
||||
function handle()
|
||||
{
|
||||
parent::handle($argarray);
|
||||
parent::handle();
|
||||
|
||||
if ($this->isPost()) {
|
||||
$this->importDelicious();
|
||||
@ -113,6 +113,7 @@ class ImportdeliciousAction extends Action
|
||||
* Uses the DeliciousBackupImporter class; may take a long time!
|
||||
*
|
||||
* @return void
|
||||
* @throws ClientException
|
||||
*/
|
||||
function importDelicious()
|
||||
{
|
||||
@ -130,42 +131,34 @@ class ImportdeliciousAction extends Action
|
||||
// TRANS: Client exception thrown when an uploaded file is too large.
|
||||
throw new ClientException(_m('The uploaded file exceeds the ' .
|
||||
'upload_max_filesize directive in php.ini.'));
|
||||
return;
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
throw new ClientException(
|
||||
// TRANS: Client exception thrown when an uploaded file is too large.
|
||||
_m('The uploaded file exceeds the MAX_FILE_SIZE directive' .
|
||||
' that was specified in the HTML form.'));
|
||||
return;
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
@unlink($_FILES[ImportDeliciousForm::FILEINPUT]['tmp_name']);
|
||||
// TRANS: Client exception thrown when a file was only partially uploaded.
|
||||
throw new ClientException(_m('The uploaded file was only' .
|
||||
' partially uploaded.'));
|
||||
return;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
// No file; probably just a non-AJAX submission.
|
||||
// TRANS: Client exception thrown when a file upload has failed.
|
||||
throw new ClientException(_m('No uploaded file.'));
|
||||
return;
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
// TRANS: Client exception thrown when a temporary folder is not present.
|
||||
throw new ClientException(_m('Missing a temporary folder.'));
|
||||
return;
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
// TRANS: Client exception thrown when writing to disk is not possible.
|
||||
throw new ClientException(_m('Failed to write file to disk.'));
|
||||
return;
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
// TRANS: Client exception thrown when a file upload has been stopped.
|
||||
throw new ClientException(_m('File upload stopped by extension.'));
|
||||
return;
|
||||
default:
|
||||
common_log(LOG_ERR, __METHOD__ . ": Unknown upload error " .
|
||||
$_FILES[ImportDeliciousForm::FILEINPUT]['error']);
|
||||
// TRANS: Client exception thrown when a file upload operation has failed.
|
||||
throw new ClientException(_m('System error uploading file.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = $_FILES[ImportDeliciousForm::FILEINPUT]['tmp_name'];
|
||||
@ -196,7 +189,7 @@ class ImportdeliciousAction extends Action
|
||||
// Enqueue for processing.
|
||||
|
||||
$qm = QueueManager::get();
|
||||
$qm->enqueue(array(common_current_user(), $html), 'dlcsback');
|
||||
$qm->enqueue([common_current_user(), $html], 'dlcsback');
|
||||
|
||||
if ($qm instanceof UnQueueManager) {
|
||||
// No active queuing means we've actually just completed the job!
|
||||
@ -272,7 +265,6 @@ class ImportDeliciousForm extends Form
|
||||
*
|
||||
* @param HTMLOutputter $out output channel
|
||||
*
|
||||
* @return ImportDeliciousForm this
|
||||
*/
|
||||
function __construct($out = null)
|
||||
{
|
||||
|
@ -54,13 +54,14 @@ class NoticebyurlAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
$this->file = File::getKV('id', $this->trimmed('id'));
|
||||
|
||||
@ -102,11 +103,9 @@ class NoticebyurlAction 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();
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class GloballoginAction extends GlobalApiAction
|
||||
{
|
||||
var $password;
|
||||
@ -52,14 +51,14 @@ class GloballoginAction extends GlobalApiAction
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
$password = $this->trimmed('password');
|
||||
|
||||
@ -75,14 +74,12 @@ class GloballoginAction extends GlobalApiAction
|
||||
/**
|
||||
* Handler method
|
||||
*
|
||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
function handle()
|
||||
{
|
||||
try {
|
||||
// FIXME: $email and $password aren't defined
|
||||
$url = DomainStatusNetworkPlugin::login($email, $password);
|
||||
$this->showSuccess(array('url' => $url));
|
||||
} catch (ClientException $ce) {
|
||||
|
@ -50,28 +50,28 @@ class GlobalrecoverAction extends GlobalApiAction
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = array())
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler method
|
||||
*
|
||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
function handle()
|
||||
{
|
||||
try {
|
||||
// FIXME: $email isn't defined
|
||||
DomainStatusNetworkPlugin::recoverPassword($email);
|
||||
$this->showSuccess();
|
||||
} catch (ClientException $ce) {
|
||||
|
@ -50,15 +50,15 @@ class GlobalregisterAction extends GlobalApiAction
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
try {
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
return true;
|
||||
} catch (ClientException $e) {
|
||||
$this->showError($e->getMessage(), $e->getCode());
|
||||
@ -73,12 +73,10 @@ class GlobalregisterAction extends GlobalApiAction
|
||||
/**
|
||||
* Handler method
|
||||
*
|
||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($argarray=null)
|
||||
function handle()
|
||||
{
|
||||
try {
|
||||
$confirm = DomainStatusNetworkPlugin::registerEmail($this->email);
|
||||
|
@ -75,9 +75,9 @@ class EmailregisterAction extends Action
|
||||
protected $error;
|
||||
protected $complete;
|
||||
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
if (common_config('site', 'closed')) {
|
||||
// TRANS: Client exception trown when registration by e-mail is not allowed.
|
||||
@ -182,11 +182,10 @@ class EmailregisterAction extends Action
|
||||
/**
|
||||
* Handler method
|
||||
*
|
||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
function handle($argarray=null)
|
||||
function handle()
|
||||
{
|
||||
$cur = common_current_user();
|
||||
|
||||
@ -259,6 +258,11 @@ class EmailregisterAction extends Action
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
function nicknameFromEmail($email)
|
||||
{
|
||||
return EmailRegistrationPlugin::nicknameFromEmail($email);
|
||||
}
|
||||
|
||||
function setPassword()
|
||||
{
|
||||
if (Event::handle('StartRegistrationTry', array($this))) {
|
||||
@ -400,11 +404,6 @@ class EmailregisterAction extends Action
|
||||
return false;
|
||||
}
|
||||
|
||||
function nicknameFromEmail($email)
|
||||
{
|
||||
return EmailRegistrationPlugin::nicknameFromEmail($email);
|
||||
}
|
||||
|
||||
/**
|
||||
* A local menu
|
||||
*
|
||||
|
@ -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();
|
||||
|
||||
@ -137,11 +139,9 @@ class GroupinboxAction extends GroupAction
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
@ -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);
|
||||
@ -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.
|
||||
|
@ -54,13 +54,15 @@ 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();
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
@ -66,13 +66,14 @@ class NewPollAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
$this->user = common_current_user();
|
||||
|
||||
@ -100,13 +101,11 @@ class NewPollAction 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()
|
||||
{
|
||||
parent::handle($argarray);
|
||||
parent::handle();
|
||||
|
||||
if ($this->isPost()) {
|
||||
$this->newPoll();
|
||||
|
@ -66,13 +66,14 @@ class RespondPollAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
if ($this->boolean('ajax')) {
|
||||
GNUsocial::setApi(true);
|
||||
}
|
||||
@ -109,13 +110,11 @@ class RespondPollAction 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()
|
||||
{
|
||||
parent::handle($argarray);
|
||||
parent::handle();
|
||||
|
||||
if ($this->isPost()) {
|
||||
$this->respondPoll();
|
||||
|
@ -66,13 +66,14 @@ class QnaclosequestionAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
if ($this->boolean('ajax')) {
|
||||
GNUsocial::setApi(true);
|
||||
}
|
||||
@ -104,13 +105,11 @@ class QnaclosequestionAction 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()
|
||||
{
|
||||
parent::handle($argarray);
|
||||
parent::handle();
|
||||
|
||||
if ($this->isPost()) {
|
||||
$this->closeQuestion();
|
||||
|
@ -45,11 +45,10 @@ if (!defined('STATUSNET')) {
|
||||
*/
|
||||
class QnanewanswerAction extends Action
|
||||
{
|
||||
public $question = null;
|
||||
protected $user = null;
|
||||
protected $error = null;
|
||||
protected $complete = null;
|
||||
|
||||
public $question = null;
|
||||
protected $content = null;
|
||||
|
||||
/**
|
||||
@ -66,13 +65,14 @@ class QnanewanswerAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
if ($this->boolean('ajax')) {
|
||||
GNUsocial::setApi(true);
|
||||
}
|
||||
@ -111,13 +111,11 @@ class QnanewanswerAction 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()
|
||||
{
|
||||
parent::handle($argarray);
|
||||
parent::handle();
|
||||
|
||||
if ($this->isPost()) {
|
||||
$this->newAnswer();
|
||||
@ -172,39 +170,24 @@ class QnanewanswerAction extends Action
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Answer form
|
||||
* @param string $msg An error message, if any
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showContent()
|
||||
function showForm($msg = null)
|
||||
{
|
||||
if (!empty($this->error)) {
|
||||
$this->element('p', 'error', $this->error);
|
||||
common_debug("show form - msg = $msg");
|
||||
if ($this->boolean('ajax')) {
|
||||
if ($msg) {
|
||||
$this->ajaxErrorMsg($msg);
|
||||
} else {
|
||||
$this->ajaxShowForm();
|
||||
}
|
||||
|
||||
$form = new QnanewanswerForm($this->question, $this);
|
||||
$form->show();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if read only.
|
||||
*
|
||||
* MAY override
|
||||
*
|
||||
* @param array $args other arguments
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
function isReadOnly($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
$_SERVER['REQUEST_METHOD'] == 'HEAD') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
$this->msg = $msg;
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -256,24 +239,39 @@ class QnanewanswerAction extends Action
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $msg An error message, if any
|
||||
* Show the Answer form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showForm($msg = null)
|
||||
function showContent()
|
||||
{
|
||||
common_debug("show form - msg = $msg");
|
||||
if ($this->boolean('ajax')) {
|
||||
if ($msg) {
|
||||
$this->ajaxErrorMsg($msg);
|
||||
} else {
|
||||
$this->ajaxShowForm();
|
||||
if (!empty($this->error)) {
|
||||
$this->element('p', 'error', $this->error);
|
||||
}
|
||||
|
||||
$form = new QnanewanswerForm($this->question, $this);
|
||||
$form->show();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->msg = $msg;
|
||||
$this->showPage();
|
||||
/**
|
||||
* Return true if read only.
|
||||
*
|
||||
* MAY override
|
||||
*
|
||||
* @param array $args other arguments
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
function isReadOnly($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
|
||||
$_SERVER['REQUEST_METHOD'] == 'HEAD') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,8 +286,11 @@ class NoticeAnswerListItem extends NoticeListItem
|
||||
* Also initializes the profile attribute.
|
||||
*
|
||||
* @param Notice $notice The notice we'll display
|
||||
* @param $out
|
||||
* @param $question
|
||||
* @param $answer
|
||||
*/
|
||||
function __construct($notice, $out=null, $question, $answer)
|
||||
function __construct($notice, $out, $question, $answer)
|
||||
{
|
||||
parent::__construct($notice, $out);
|
||||
$this->question = $question;
|
||||
@ -334,7 +335,7 @@ class NoticeAnswerListItem extends NoticeListItem
|
||||
$form->show();
|
||||
} else {
|
||||
// TRANS: Error message displayed when an answer has no content.
|
||||
$out->text(_m('Answer data is missing.'));
|
||||
$this->out->text(_m('Answer data is missing.'));
|
||||
}
|
||||
|
||||
$this->out->elementEnd('p');
|
||||
|
@ -65,13 +65,14 @@ class QnanewquestionAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
$this->user = common_current_user();
|
||||
|
||||
@ -96,13 +97,11 @@ class QnanewquestionAction 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()
|
||||
{
|
||||
parent::handle($argarray);
|
||||
parent::handle();
|
||||
|
||||
if ($this->isPost()) {
|
||||
$this->newQuestion();
|
||||
|
@ -65,13 +65,14 @@ class QnareviseanswerAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
if ($this->boolean('ajax')) {
|
||||
GNUsocial::setApi(true);
|
||||
}
|
||||
@ -107,13 +108,11 @@ class QnareviseanswerAction 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()
|
||||
{
|
||||
parent::handle($argarray);
|
||||
parent::handle();
|
||||
|
||||
if ($this->isPost()) {
|
||||
$this->checkSessionToken();
|
||||
@ -135,39 +134,38 @@ class QnareviseanswerAction extends Action
|
||||
}
|
||||
|
||||
/**
|
||||
* Revise the answer
|
||||
* Show the revise answer form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function reviseAnswer()
|
||||
function showContent()
|
||||
{
|
||||
$answer = $this->answer;
|
||||
if (!empty($this->error)) {
|
||||
$this->element('p', 'error', $this->error);
|
||||
}
|
||||
|
||||
if ($this->boolean('ajax')) {
|
||||
$this->showAjaxReviseForm();
|
||||
} else {
|
||||
$form = new QnareviseanswerForm($this->answer, $this);
|
||||
$form->show();
|
||||
}
|
||||
|
||||
try {
|
||||
$orig = clone($answer);
|
||||
$answer->content = $this->answerText;
|
||||
$answer->revisions++;
|
||||
$result = $answer->update($orig);
|
||||
} catch (ClientException $ce) {
|
||||
$this->error = $ce->getMessage();
|
||||
$this->showPage();
|
||||
return;
|
||||
}
|
||||
if ($this->boolean('ajax')) {
|
||||
common_debug("ajaxy part");
|
||||
|
||||
function showAjaxReviseForm()
|
||||
{
|
||||
$this->startHTML('text/xml;charset=utf-8');
|
||||
$this->elementStart('head');
|
||||
// TRANS: Page title after sending an answer.
|
||||
$this->element('title', null, _m('Answer'));
|
||||
// TRANS: Form title for sending an answer.
|
||||
$this->element('title', null, _m('TITLE', 'Answer'));
|
||||
$this->elementEnd('head');
|
||||
$this->elementStart('body');
|
||||
$form = new QnashowanswerForm($this, $answer);
|
||||
$form = new QnareviseanswerForm($this->answer, $this);
|
||||
$form->show();
|
||||
$this->elementEnd('body');
|
||||
$this->endHTML();
|
||||
} else {
|
||||
common_redirect($this->answer->getUrl(), 303);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,38 +211,39 @@ class QnareviseanswerAction extends Action
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the revise answer form
|
||||
* Revise the answer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function showContent()
|
||||
function reviseAnswer()
|
||||
{
|
||||
if (!empty($this->error)) {
|
||||
$this->element('p', 'error', $this->error);
|
||||
}
|
||||
|
||||
if ($this->boolean('ajax')) {
|
||||
$this->showAjaxReviseForm();
|
||||
} else {
|
||||
$form = new QnareviseanswerForm($this->answer, $this);
|
||||
$form->show();
|
||||
}
|
||||
$answer = $this->answer;
|
||||
|
||||
try {
|
||||
$orig = clone($answer);
|
||||
$answer->content = $this->answerText;
|
||||
$answer->revisions++;
|
||||
$result = $answer->update($orig);
|
||||
} catch (ClientException $ce) {
|
||||
$this->error = $ce->getMessage();
|
||||
$this->showPage();
|
||||
return;
|
||||
}
|
||||
|
||||
function showAjaxReviseForm()
|
||||
{
|
||||
if ($this->boolean('ajax')) {
|
||||
common_debug("ajaxy part");
|
||||
$this->startHTML('text/xml;charset=utf-8');
|
||||
$this->elementStart('head');
|
||||
// TRANS: Form title for sending an answer.
|
||||
$this->element('title', null, _m('TITLE','Answer'));
|
||||
// TRANS: Page title after sending an answer.
|
||||
$this->element('title', null, _m('Answer'));
|
||||
$this->elementEnd('head');
|
||||
$this->elementStart('body');
|
||||
$form = new QnareviseanswerForm($this->answer, $this);
|
||||
$form = new QnashowanswerForm($this, $answer);
|
||||
$form->show();
|
||||
$this->elementEnd('body');
|
||||
$this->endHTML();
|
||||
} else {
|
||||
common_redirect($this->answer->getUrl(), 303);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,13 +51,15 @@ class QnashowanswerAction extends ShownoticeAction
|
||||
/**
|
||||
* 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 = [])
|
||||
{
|
||||
Action::prepare($argarray);
|
||||
Action::prepare($args);
|
||||
|
||||
$this->id = $this->trimmed('id');
|
||||
|
||||
|
@ -51,13 +51,15 @@ class QnashowquestionAction extends ShownoticeAction
|
||||
/**
|
||||
* 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 = [])
|
||||
{
|
||||
Action::prepare($argarray);
|
||||
Action::prepare($args);
|
||||
|
||||
$this->id = $this->trimmed('id');
|
||||
|
||||
|
@ -66,13 +66,14 @@ class Qnavote extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
if ($this->boolean('ajax')) {
|
||||
GNUsocial::setApi(true);
|
||||
}
|
||||
@ -105,13 +106,11 @@ class Qnavote 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()
|
||||
{
|
||||
parent::handle($argarray);
|
||||
parent::handle();
|
||||
|
||||
if ($this->isPost()) {
|
||||
$this->answer();
|
||||
|
@ -52,13 +52,14 @@ class ClosechannelAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
if (!$this->isPost()) {
|
||||
// TRANS: Client exception. Do not translate POST.
|
||||
@ -85,11 +86,9 @@ class ClosechannelAction 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->channel->decrement();
|
||||
|
||||
|
@ -52,13 +52,14 @@ class KeepalivechannelAction extends Action
|
||||
/**
|
||||
* For initializing members of the class.
|
||||
*
|
||||
* @param array $argarray misc. arguments
|
||||
* @param array $args misc. arguments
|
||||
*
|
||||
* @return boolean true
|
||||
* @throws ClientException
|
||||
*/
|
||||
function prepare($argarray)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($argarray);
|
||||
parent::prepare($args);
|
||||
|
||||
if (!$this->isPost()) {
|
||||
// TRANS: Client exception. Do not translate POST.
|
||||
@ -85,11 +86,9 @@ class KeepalivechannelAction 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->channel->touch();
|
||||
|
||||
|
@ -54,13 +54,15 @@ class ConfirmfirstemailAction 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);
|
||||
$user = common_current_user();
|
||||
|
||||
if (!empty($user)) {
|
||||
@ -75,7 +77,6 @@ class ConfirmfirstemailAction extends Action
|
||||
if (empty($this->confirm)) {
|
||||
// TRANS: Client exception thrown when trying to register with a non-existing confirmation code.
|
||||
throw new ClientException(_m('Confirmation code not found.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->user = User::getKV('id', $this->confirm->user_id);
|
||||
@ -93,7 +94,7 @@ class ConfirmfirstemailAction extends Action
|
||||
throw new ServerException(sprintf(_m('Unrecognized address type %s.'), $type));
|
||||
}
|
||||
|
||||
if (!empty($this->user->email) && $this->user->email == $confirm->address) {
|
||||
if (!empty($this->user->email) && $this->user->email == $this->confirm->address) {
|
||||
// TRANS: Client error for an already confirmed email/jabber/sms address.
|
||||
throw new ClientException(_m('That address has already been confirmed.'));
|
||||
}
|
||||
@ -108,11 +109,9 @@ class ConfirmfirstemailAction extends Action
|
||||
if (strlen($password) < 6) {
|
||||
// TRANS: Client exception thrown when trying to register with too short a password.
|
||||
throw new ClientException(_m('Password too short.'));
|
||||
return;
|
||||
} else if (0 != strcmp($password, $confirm)) {
|
||||
// TRANS: Client exception thrown when trying to register without providing the same password twice.
|
||||
throw new ClientException(_m('Passwords do not match.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->password = $password;
|
||||
@ -124,11 +123,10 @@ class ConfirmfirstemailAction extends Action
|
||||
/**
|
||||
* Handler method
|
||||
*
|
||||
* @param array $argarray is ignored since it's now passed in in prepare()
|
||||
*
|
||||
* @return void
|
||||
* @throws AuthorizationException
|
||||
*/
|
||||
function handle($argarray=null)
|
||||
function handle()
|
||||
{
|
||||
$homepage = common_local_url('all',
|
||||
array('nickname' => $this->user->nickname));
|
||||
|
@ -77,7 +77,7 @@ Plugins are configured using public instance attributes. To set their values,
|
||||
site administrators use this syntax:
|
||||
|
||||
```php
|
||||
addPlugin('Sample', array('attr1' => 'foo', 'attr2' => 'bar'));
|
||||
addPlugin('Sample', ('attr1' => 'foo', 'attr2' => 'bar'));
|
||||
```
|
||||
|
||||
The same plugin class can be initialized multiple times with different arguments:
|
||||
@ -260,11 +260,11 @@ Take arguments for running
|
||||
This method is called first, and it lets the action class get all its arguments
|
||||
and validate them. It's also the time to fetch any relevant data from the database.
|
||||
|
||||
Action classes should run parent::prepare($args) as the first line of this
|
||||
method to make sure the default argument-processing happens.
|
||||
Action classes should run parent::prepare(array $args = []) as the first line
|
||||
of this method to make sure the default argument-processing happens.
|
||||
|
||||
```php
|
||||
function prepare($args)
|
||||
function prepare(array $args = [])
|
||||
{
|
||||
parent::prepare($args);
|
||||
|
||||
@ -286,9 +286,9 @@ should be done in the prepare() method; by the time handle() is called the
|
||||
action should be more or less ready to go.
|
||||
|
||||
```php
|
||||
function handle($args)
|
||||
function handle()
|
||||
{
|
||||
parent::handle($args);
|
||||
parent::handle();
|
||||
|
||||
$this->showPage();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user