class DeleteaccountAction extends Action
{
private $_complete = false;
- private $_error = null;
+ private $_error = null;
/**
* 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)) {
/**
* 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 true if read only.
- *
- * MAY override
- *
- * @param array $args other arguments
- *
- * @return boolean is read only action?
- */
- function isReadOnly($args)
- {
- return false;
- }
-
- /**
- * Return last modified, if applicable.
- *
- * MAY override
- *
- * @return string last modified http header
- */
- function lastModified()
- {
- // For comparison with If-Last-Modified
- // If not applicable, return null
- return null;
- }
-
- /**
- * Return etag, if applicable.
- *
- * MAY override
- *
- * @return string etag http header
- */
- function etag()
- {
return null;
}
* If successful it logs the user out, and shows a brief completion message.
*
* @return void
+ * @throws AuthorizationException
+ * @throws ServerException
*/
function deleteAccount()
{
// !!! 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 ) {
+ 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;
+ return null;
}
$cur = common_current_user();
$this->showPage();
}
+ /**
+ * Return true if read only.
+ *
+ * MAY override
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean is read only action?
+ */
+ function isReadOnly($args)
+ {
+ return false;
+ }
+
+ /**
+ * Return last modified, if applicable.
+ *
+ * MAY override
+ *
+ * @return string last modified http header
+ */
+ function lastModified()
+ {
+ // For comparison with If-Last-Modified
+ // If not applicable, return null
+ return null;
+ }
+
+ /**
+ * Return etag, if applicable.
+ *
+ * MAY override
+ *
+ * @return string etag http header
+ */
+ function etag()
+ {
+ return null;
+ }
+
/**
* Shows the page content.
*
{
if ($this->_complete) {
$this->element('p', 'confirmation',
- // TRANS: Confirmation that a user account has been deleted.
- _('Account deleted.'));
- return;
+ // TRANS: Confirmation that a user account has been deleted.
+ _('Account deleted.'));
+ return null;
}
if (!empty($this->_error)) {
$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.'),
- common_local_url('backupaccount')) . '</p>';
+ $msg .= '<p>' . sprintf(_('You are strongly advised to <a href="%s">back up your data</a> before deletion.'),
+ common_local_url('backupaccount')) . '</p>';
}
$this->out->elementStart('p');
// TRANS: Confirmation text for user deletion. The user has to type this exactly the same, including punctuation.
$iamsure = _("I am sure.");
$this->out->input('iamsure',
- // TRANS: Field label for delete account confirmation entry.
- _('Confirm'),
- null,
- // TRANS: Input title for the delete account field.
- // TRANS: %s is the text that needs to be input.
- sprintf(_('Enter "%s" to confirm that '.
- 'you want to delete your account.'),$iamsure ));
+ // TRANS: Field label for delete account confirmation entry.
+ _('Confirm'),
+ null,
+ // TRANS: Input title for the delete account field.
+ // TRANS: %s is the text that needs to be input.
+ sprintf(_('Enter "%s" to confirm that ' .
+ 'you want to delete your account.'), $iamsure));
}
/**
function formActions()
{
$this->out->submit('submit',
- // TRANS: Button text for user account deletion.
- _m('BUTTON', 'Delete'),
- 'submit',
- null,
- // TRANS: Button title for user account deletion.
- _('Permanently delete your account.'));
+ // TRANS: Button text for user account deletion.
+ _m('BUTTON', 'Delete'),
+ 'submit',
+ null,
+ // TRANS: Button title for user account deletion.
+ _('Permanently delete your account.'));
}
}
/**
* 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();
/**
* 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;
}
/**
* Uses the UserActivityStream class; may take a long time!
*
* @return void
+ * @throws ClientException
+ * @throws Exception
*/
function restoreAccount()
{
// 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'];
// 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!
/**
* 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');
// 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;
/**
* 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();
}
* 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()
{
$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();
* Copyright (C) 2012, StatusNet, Inc.
*
* Stream of latest spam messages
- *
+ *
* PHP version 5
*
* This program is free software: you can redistribute it and/or modify
exit(1);
}
-require_once INSTALLDIR.'/lib/noticelist.php';
+require_once INSTALLDIR . '/lib/noticelist.php';
/**
* SpamAction
- *
+ *
* Shows the latest spam on the service
- *
+ *
* @category Spam
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @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;
+ $this->page = ($this->arg('page')) ? ($this->arg('page') + 0) : 1;
// User must be logged in.
$stream = new SpamNoticeStream($this->scoped);
- $this->notices = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
- NOTICES_PER_PAGE + 1);
+ $this->notices = $stream->getNotices(($this->page - 1) * NOTICES_PER_PAGE,
+ NOTICES_PER_PAGE + 1);
- if($this->page > 1 && $this->notices->N == 0) {
+ if ($this->page > 1 && $this->notices->N == 0) {
throw new ClientException(_('No such page.'), 404);
}
/**
* 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();
$this->showEmptyList();
}
- $this->pagination($this->page > 1,
- $cnt > NOTICES_PER_PAGE,
- $this->page,
- 'spam');
+ $this->pagination($this->page > 1,
+ $cnt > NOTICES_PER_PAGE,
+ $this->page,
+ 'spam');
}
function showEmptyList()
/**
* 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.
/**
* 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
<?php
- /**
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2011, StatusNet, Inc.
- *
- * Score of a notice by activity spam service
- *
- * PHP version 5
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * @category Spam
- * @package StatusNet
- * @author Evan Prodromou <evan@status.net>
- * @copyright 2011 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
- * @link http://status.net/
- */
+/**
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2011, StatusNet, Inc.
+ *
+ * Score of a notice by activity spam service
+ *
+ * PHP version 5
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Spam
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2011 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
+ * @link http://status.net/
+ */
if (!defined('STATUSNET')) {
exit(1);
*
* @see DB_DataObject
*/
-
class Spam_score extends Managed_DataObject
{
const MAX_SCALE = 10000;
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;
+ $orig = null;
$score = Spam_score::getKV('notice_id', $notice->id);
if (empty($score)) {
$orig = clone($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_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;
if (empty($orig)) {
} else {
$score->update($orig);
}
-
+
self::blow('spam_score:notice_ids');
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.
*/
'description' => 'score of the notice per activityspam',
'fields' => array(
'notice_id' => array('type' => 'int',
- 'not null' => true,
- 'description' => 'notice getting scored'),
+ 'not null' => true,
+ 'description' => 'notice getting scored'),
'score' => array('type' => 'double',
- 'not null' => true,
- 'description' => 'score for the notice (0.0, 1.0)'),
+ 'not null' => true,
+ 'description' => 'score for the notice (0.0, 1.0)'),
'scaled' => array('type' => 'int',
- 'description' => 'scaled score for the notice (0, 10000)'),
+ 'description' => 'scaled score for the notice (0, 10000)'),
'is_spam' => array('type' => 'tinyint',
- 'description' => 'flag for spamosity'),
+ 'description' => 'flag for spamosity'),
'created' => array('type' => 'datetime',
- 'not null' => true,
- 'description' => 'date this record was created'),
+ 'not null' => true,
+ 'description' => 'date this record was created'),
'notice_created' => array('type' => 'datetime',
- 'description' => 'date the notice was created'),
+ 'description' => 'date the notice was created'),
),
'primary key' => array('notice_id'),
'foreign keys' => array(
{
$score = new Spam_score();
$score->whereAdd('scaled IS NULL');
-
+
if ($score->find()) {
while ($score->fetch()) {
$orig = clone($score);
{
$score = new Spam_score();
$score->whereAdd('is_spam IS NULL');
-
+
if ($score->find()) {
while ($score->fetch()) {
$orig = clone($score);
{
$score = new Spam_score();
$score->whereAdd('notice_created IS NULL');
-
+
if ($score->find()) {
while ($score->fetch()) {
$notice = Notice::getKV('id', $score->notice_id);
}
}
+ 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);
+ }
}
/**
* 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 thrown when trying to import bookmarks without being logged in.
- throw new ClientException(_m('Only logged-in users can '.
- 'import del.icio.us backups.'),
- 403);
+ throw new ClientException(_m('Only logged-in users can ' .
+ 'import del.icio.us backups.'),
+ 403);
}
if (!$cur->hasRight(BookmarkPlugin::IMPORTDELICIOUS)) {
/**
* 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();
* Uses the DeliciousBackupImporter class; may take a long time!
*
* @return void
+ * @throws ClientException
*/
function importDelicious()
{
}
switch ($_FILES[ImportDeliciousForm::FILEINPUT]['error']) {
- case UPLOAD_ERR_OK: // success, jump out
- break;
- case UPLOAD_ERR_INI_SIZE:
- // 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;
+ case UPLOAD_ERR_OK: // success, jump out
+ break;
+ case UPLOAD_ERR_INI_SIZE:
+ // 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.'));
+ 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.'));
+ 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.'));
+ 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.'));
+ 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.'));
+ 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.'));
+ case UPLOAD_ERR_EXTENSION:
+ // TRANS: Client exception thrown when a file upload has been stopped.
+ throw new ClientException(_m('File upload stopped by extension.'));
+ 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.'));
}
$filename = $_FILES[ImportDeliciousForm::FILEINPUT]['tmp_name'];
if (!file_exists($filename)) {
// TRANS: Server exception thrown when a file upload cannot be found.
// TRANS: %s is the file that could not be found.
- throw new ServerException(sprintf(_m('No such file "%s".'),$filename));
+ throw new ServerException(sprintf(_m('No such file "%s".'), $filename));
}
if (!is_file($filename)) {
// TRANS: Server exception thrown when a file upload is incorrect.
// TRANS: %s is the irregular file.
- throw new ServerException(sprintf(_m('Not a regular file: "%s".'),$filename));
+ throw new ServerException(sprintf(_m('Not a regular file: "%s".'), $filename));
}
if (!is_readable($filename)) {
// TRANS: Server exception thrown when a file upload is not readable.
// TRANS: %s is the file that could not be read.
- throw new ServerException(sprintf(_m('File "%s" not readable.'),$filename));
+ throw new ServerException(sprintf(_m('File "%s" not readable.'), $filename));
}
common_debug(sprintf("Getting backup from file '%s'.", $filename));
// 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!
{
if ($this->success) {
$this->element('p', null,
- // TRANS: Success message after importing bookmarks.
- _m('Bookmarks have been imported. Your bookmarks should now appear in search and your profile page.'));
+ // TRANS: Success message after importing bookmarks.
+ _m('Bookmarks have been imported. Your bookmarks should now appear in search and your profile page.'));
} else if ($this->inprogress) {
$this->element('p', null,
- // TRANS: Busy message for importing bookmarks.
- _m('Bookmarks are being imported. Please wait a few minutes for results.'));
+ // TRANS: Busy message for importing bookmarks.
+ _m('Bookmarks are being imported. Please wait a few minutes for results.'));
} else {
$form = new ImportDeliciousForm($this);
$form->show();
*
* @param HTMLOutputter $out output channel
*
- * @return ImportDeliciousForm this
*/
- function __construct($out=null)
+ function __construct($out = null)
{
parent::__construct($out);
$this->enctype = 'multipart/form-data';
$this->out->elementStart('p', 'instructions');
// TRANS: Form instructions for importing bookmarks.
- $this->out->raw(_m('You can upload a backed-up '.
- 'delicious.com bookmarks file.'));
+ $this->out->raw(_m('You can upload a backed-up ' .
+ 'delicious.com bookmarks file.'));
$this->out->elementEnd('p');
$this->out->elementStart('ul', 'form_data');
- $this->out->elementStart('li', array ('id' => 'settings_attach'));
+ $this->out->elementStart('li', array('id' => 'settings_attach'));
$this->out->element('input', array('name' => self::FILEINPUT,
- 'type' => 'file',
- 'id' => self::FILEINPUT));
+ 'type' => 'file',
+ 'id' => self::FILEINPUT));
$this->out->elementEnd('li');
$this->out->elementEnd('ul');
function formActions()
{
$this->out->submit('submit',
- // TRANS: Button text on form to import bookmarks.
- _m('BUTTON', 'Upload'),
- 'submit',
- null,
- // TRANS: Button title on form to import bookmarks.
- _m('Upload the file.'));
+ // TRANS: Button text on form to import bookmarks.
+ _m('BUTTON', 'Upload'),
+ 'submit',
+ null,
+ // TRANS: Button title on form to import bookmarks.
+ _m('Upload the file.'));
}
}
/**
* 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'));
/**
* 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();
}
* Copyright (C) 2011, StatusNet, Inc.
*
* Log into a site globally
- *
+ *
* PHP version 5
*
* This program is free software: you can redistribute it and/or modify
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class GloballoginAction extends GlobalApiAction
{
var $password;
/**
* 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');
/**
* 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) {
/**
* 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) {
/**
* 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());
/**
* 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);
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.
function title()
{
switch ($this->state) {
- case self::NEWREGISTER:
- case self::NEWEMAIL:
- // TRANS: Title for registration page.
- return _m('TITLE','Register');
- break;
- case self::SETPASSWORD:
- case self::CONFIRMINVITE:
- case self::CONFIRMREGISTER:
- // TRANS: Title for page where to register with a confirmation code.
- return _m('TITLE','Complete registration');
- break;
+ case self::NEWREGISTER:
+ case self::NEWEMAIL:
+ // TRANS: Title for registration page.
+ return _m('TITLE', 'Register');
+ break;
+ case self::SETPASSWORD:
+ case self::CONFIRMINVITE:
+ case self::CONFIRMREGISTER:
+ // TRANS: Title for page where to register with a confirmation code.
+ return _m('TITLE', 'Complete registration');
+ break;
}
}
/**
* 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();
}
switch ($this->state) {
- case self::NEWREGISTER:
- $this->showRegistrationForm();
- break;
- case self::NEWEMAIL:
- $this->registerUser();
- break;
- case self::CONFIRMINVITE:
- $this->confirmRegistration();
- break;
- case self::CONFIRMREGISTER:
- $this->confirmRegistration();
- break;
- case self::SETPASSWORD:
- $this->setPassword();
- break;
+ case self::NEWREGISTER:
+ $this->showRegistrationForm();
+ break;
+ case self::NEWEMAIL:
+ $this->registerUser();
+ break;
+ case self::CONFIRMINVITE:
+ $this->confirmRegistration();
+ break;
+ case self::CONFIRMREGISTER:
+ $this->confirmRegistration();
+ break;
+ case self::SETPASSWORD:
+ $this->setPassword();
+ break;
}
return;
}
// TRANS: Confirmation text after initial registration.
// TRANS: %s an e-mail address.
$prompt = sprintf(_m('An email was sent to %s to confirm that address. Check your email inbox for instructions.'),
- $this->email);
+ $this->email);
$this->complete = $prompt;
$nickname = $this->nicknameFromEmail($email);
$this->form = new ConfirmRegistrationForm($this,
- $nickname,
- $email,
- $this->code);
+ $nickname,
+ $email,
+ $this->code);
$this->showPage();
}
+ function nicknameFromEmail($email)
+ {
+ return EmailRegistrationPlugin::nicknameFromEmail($email);
+ }
+
function setPassword()
{
if (Event::handle('StartRegistrationTry', array($this))) {
try {
$fields = array('nickname' => $this->nickname,
- 'email' => $email,
- 'password' => $this->password1,
- 'email_confirmed' => true);
+ 'email' => $email,
+ 'password' => $this->password1,
+ 'email_confirmed' => true);
if (!empty($this->invitation)) {
$fields['code'] = $this->invitation->code;
$headers['From'] = mail_notify_from();
$headers['To'] = trim($confirm->address);
- // TRANS: Subject for confirmation e-mail.
- // TRANS: %s is the StatusNet sitename.
+ // TRANS: Subject for confirmation e-mail.
+ // TRANS: %s is the StatusNet sitename.
$headers['Subject'] = sprintf(_m('Confirm your registration on %s'), $sitename);
$confirmUrl = common_local_url('register', array('code' => $confirm->code));
// TRANS: Body for confirmation e-mail.
// TRANS: %1$s is the StatusNet sitename, %2$s is the confirmation URL.
- $body = sprintf(_m('Someone (probably you) has requested an account on %1$s using this email address.'.
- "\n".
- 'To confirm the address, click the following URL or copy it into the address bar of your browser.'.
- "\n".
- '%2$s'.
- "\n".
- 'If it was not you, you can safely ignore this message.'),
- $sitename,
- $confirmUrl);
+ $body = sprintf(_m('Someone (probably you) has requested an account on %1$s using this email address.' .
+ "\n" .
+ 'To confirm the address, click the following URL or copy it into the address bar of your browser.' .
+ "\n" .
+ '%2$s' .
+ "\n" .
+ 'If it was not you, you can safely ignore this message.'),
+ $sitename,
+ $confirmUrl);
mail_send($recipients, $headers, $body);
}
return false;
}
- function nicknameFromEmail($email)
- {
- return EmailRegistrationPlugin::nicknameFromEmail($email);
- }
-
/**
* A local menu
*
/**
* 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();
}
$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;
}
$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();
}
// 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);
}
}
*/
function showPageNotice()
{
- $instr = $this->getInstructions();
+ $instr = $this->getInstructions();
$output = common_markup_to_html($instr);
$this->elementStart('div', 'instructions');
/**
* 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();
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');
/**
* 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();
}
}
- function showNoticeForm()
- {
- $form = new GroupMessageForm($this, $this->group);
- $form->show();
- }
-
function sendNewMessage()
{
$gm = Group_message::send($this->user, $this->group, $this->text);
$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 {
}
}
+ function showNoticeForm()
+ {
+ $form = new GroupMessageForm($this, $this->group);
+ $form->show();
+ }
+
function title()
{
// TRANS: Title of form for new private group message.
/**
* 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');
/**
* 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();
}
// 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));
}
/**
function lastModified()
{
return max(strtotime($this->group->modified),
- strtotime($this->sender->modified),
- strtotime($this->gm->modified));
+ strtotime($this->sender->modified),
+ strtotime($this->gm->modified));
}
/**
}
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)) . '"';
}
}
/**
* 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();
/**
* 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();
*/
class RespondPollAction extends Action
{
- protected $user = null;
- protected $error = null;
- protected $complete = null;
+ protected $user = null;
+ protected $error = null;
+ protected $complete = null;
- protected $poll = null;
- protected $selection = null;
+ protected $poll = null;
+ protected $selection = null;
/**
* Returns the title of the 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);
}
if (empty($this->user)) {
// TRANS: Client exception thrown trying to respond to a poll while not logged in.
throw new ClientException(_m('You must be logged in to respond to a poll.'),
- 403);
+ 403);
}
if ($this->isPost()) {
/**
* 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();
{
try {
$notice = Poll_response::saveNew($this->user->getProfile(),
- $this->poll,
- $this->selection);
+ $this->poll,
+ $this->selection);
} catch (ClientException $ce) {
$this->error = $ce->getMessage();
$this->showPage();
*/
class QnaclosequestionAction extends Action
{
- protected $user = null;
- protected $error = null;
- protected $complete = null;
+ protected $user = null;
+ protected $error = null;
+ protected $complete = null;
- protected $question = null;
- protected $answer = null;
+ protected $question = null;
+ protected $answer = null;
/**
* Returns the title of the 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);
}
if (empty($this->user)) {
throw new ClientException(
- // TRANS: Client exception thrown trying to close a question when not logged in
+ // TRANS: Client exception thrown trying to close a question when not logged in
_m("You must be logged in to close a question."),
403
);
/**
* 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();
*/
class QnanewanswerAction extends Action
{
- protected $user = null;
- protected $error = null;
+ public $question = null;
+ protected $user = null;
+ protected $error = null;
protected $complete = null;
-
- public $question = null;
- protected $content = null;
+ protected $content = null;
/**
* Returns the title of the 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);
}
if (empty($this->user)) {
throw new ClientException(
- // TRANS: Client exception thrown trying to answer a question while not logged in.
+ // TRANS: Client exception thrown trying to answer a question while not logged in.
_m("You must be logged in to answer to a question."),
403
);
if (empty($this->question)) {
throw new ClientException(
- // TRANS: Client exception thrown trying to respond to a non-existing question.
+ // TRANS: Client exception thrown trying to respond to a non-existing question.
_m('Invalid or missing question.'),
404
);
/**
* 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();
}
/**
- * 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();
+ }
+ return;
}
- $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();
}
/**
$this->startHTML('text/xml;charset=utf-8', true);
$this->elementStart('head');
// TRANS: Title for form to send answer to a question.
- $this->element('title', null, _m('TITLE','Your answer'));
+ $this->element('title', null, _m('TITLE', 'Your answer'));
$this->elementEnd('head');
$this->elementStart('body');
}
/**
- * @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();
- }
- return;
+ if (!empty($this->error)) {
+ $this->element('p', 'error', $this->error);
}
- $this->msg = $msg;
- $this->showPage();
+ $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;
+ }
}
}
* 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;
- $this->answer = $answer;
+ $this->answer = $answer;
}
$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');
*/
class QnanewquestionAction extends Action
{
- protected $user = null;
- protected $error = null;
- protected $complete = null;
- protected $title = null;
+ protected $user = null;
+ protected $error = null;
+ protected $complete = null;
+ protected $title = null;
protected $description = null;
/**
/**
* 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();
if (empty($this->user)) {
throw new ClientException(
- // TRANS: Client exception thrown trying to create a Question while not logged in.
+ // TRANS: Client exception thrown trying to create a Question while not logged in.
_m('You must be logged in to post a question.'),
403
);
$this->checkSessionToken();
}
- $this->title = $this->trimmed('title');
+ $this->title = $this->trimmed('title');
$this->description = $this->trimmed('description');
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()
{
- parent::handle($argarray);
+ parent::handle();
if ($this->isPost()) {
$this->newQuestion();
*
* @param Notice $notice The notice we'll display
*/
- function __construct($notice, $out=null)
+ function __construct($notice, $out = null)
{
parent::__construct($notice, $out);
}
*/
class QnareviseanswerAction extends Action
{
- protected $user = null;
- protected $error = null;
+ protected $user = null;
+ protected $error = null;
protected $question = null;
- protected $answer = null;
- protected $content = null;
+ protected $answer = null;
+ protected $content = null;
/**
* Returns the title of the 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);
}
if (empty($this->user)) {
throw new ClientException(
- // TRANS: Client exception thrown trying to answer a question while not logged in.
+ // TRANS: Client exception thrown trying to answer a question while not logged in.
_m("You must be logged in to answer to a question."),
403
);
$id = substr($this->trimmed('id'), 7);
- $this->answer = QnA_Answer::getKV('id', $id);
+ $this->answer = QnA_Answer::getKV('id', $id);
$this->question = $this->answer->getQuestion();
if (empty($this->answer) || empty($this->question)) {
throw new ClientException(
- // TRANS: Client exception thrown trying to respond to a non-existing question.
+ // TRANS: Client exception thrown trying to respond to a non-existing question.
_m('Invalid or missing answer.'),
404
);
/**
* 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();
}
/**
- * Revise the answer
+ * Show the revise answer form
*
* @return void
*/
- function reviseAnswer()
+ function showContent()
{
- $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;
+ if (!empty($this->error)) {
+ $this->element('p', 'error', $this->error);
}
+
if ($this->boolean('ajax')) {
- common_debug("ajaxy part");
- $this->startHTML('text/xml;charset=utf-8');
- $this->elementStart('head');
- // TRANS: Page title after sending an answer.
- $this->element('title', null, _m('Answer'));
- $this->elementEnd('head');
- $this->elementStart('body');
- $form = new QnashowanswerForm($this, $answer);
- $form->show();
- $this->elementEnd('body');
- $this->endHTML();
+ $this->showAjaxReviseForm();
} else {
- common_redirect($this->answer->getUrl(), 303);
+ $form = new QnareviseanswerForm($this->answer, $this);
+ $form->show();
}
+
+ return;
+ }
+
+ function showAjaxReviseForm()
+ {
+ $this->startHTML('text/xml;charset=utf-8');
+ $this->elementStart('head');
+ // TRANS: Form title for sending an answer.
+ $this->element('title', null, _m('TITLE', 'Answer'));
+ $this->elementEnd('head');
+ $this->elementStart('body');
+ $form = new QnareviseanswerForm($this->answer, $this);
+ $form->show();
+ $this->elementEnd('body');
+ $this->endHTML();
}
/**
function markBest()
{
$question = $this->question;
- $answer = $this->answer;
+ $answer = $this->answer;
try {
// close the question to further answers
}
/**
- * Show the revise answer form
+ * Revise the answer
*
* @return void
*/
- function showContent()
+ function reviseAnswer()
{
- if (!empty($this->error)) {
- $this->element('p', 'error', $this->error);
- }
+ $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;
+ }
if ($this->boolean('ajax')) {
- $this->showAjaxReviseForm();
- } else {
- $form = new QnareviseanswerForm($this->answer, $this);
+ common_debug("ajaxy part");
+ $this->startHTML('text/xml;charset=utf-8');
+ $this->elementStart('head');
+ // TRANS: Page title after sending an answer.
+ $this->element('title', null, _m('Answer'));
+ $this->elementEnd('head');
+ $this->elementStart('body');
+ $form = new QnashowanswerForm($this, $answer);
$form->show();
+ $this->elementEnd('body');
+ $this->endHTML();
+ } else {
+ common_redirect($this->answer->getUrl(), 303);
}
-
- return;
- }
-
- function showAjaxReviseForm()
- {
- $this->startHTML('text/xml;charset=utf-8');
- $this->elementStart('head');
- // TRANS: Form title for sending an answer.
- $this->element('title', null, _m('TITLE','Answer'));
- $this->elementEnd('head');
- $this->elementStart('body');
- $form = new QnareviseanswerForm($this->answer, $this);
- $form->show();
- $this->elementEnd('body');
- $this->endHTML();
}
/**
/**
* 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');
$question = $this->answer->getQuestion();
return sprintf(
- // TRANS: Page title.
- // TRANS: %1$s is the user who answered a question, %2$s is the question.
+ // TRANS: Page title.
+ // TRANS: %1$s is the user who answered a question, %2$s is the question.
_m('%1$s\'s answer to "%2$s"'),
$this->user->nickname,
$question->title
/**
* 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');
if (!empty($user)) {
$profile = $user->getProfile();
- $answer = QnA_Question::getAnswer($profile);
+ $answer = QnA_Question::getAnswer($profile);
if (empty($answer)) {
$form = new QnanewanswerForm($this, $this->question, false);
$form->show();
function title()
{
return sprintf(
- // TRANS: Page title for a question.
- // TRANS: %1$s is the nickname of the user who asked the question, %2$s is the question.
+ // TRANS: Page title for a question.
+ // TRANS: %1$s is the nickname of the user who asked the question, %2$s is the question.
_m('%1$s\'s question: %2$s'),
$this->user->nickname,
$this->question->title
*/
class Qnavote extends Action
{
- protected $user = null;
- protected $error = null;
- protected $complete = null;
+ protected $user = null;
+ protected $error = null;
+ protected $complete = null;
- protected $question = null;
- protected $answer = null;
+ protected $question = null;
+ protected $answer = null;
/**
* Returns the title of the 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);
}
if (empty($this->user)) {
// TRANS: Client exception thrown trying to answer a question while not logged in.
throw new ClientException(_m('You must be logged in to answer to a question.'),
- 403);
+ 403);
}
if ($this->isPost()) {
/**
* 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();
class ClosechannelAction extends Action
{
protected $channelKey = null;
- protected $channel = null;
+ protected $channel = null;
/**
* 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.
/**
* 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();
* Copyright (C) 2011, StatusNet, Inc.
*
* action periodically pinged by a page to keep a channel alive
- *
+ *
* PHP version 5
*
* This program is free software: you can redistribute it and/or modify
class KeepalivechannelAction extends Action
{
protected $channelKey = null;
- protected $channel = null;
+ protected $channel = null;
/**
* 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.
/**
* 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();
/**
* 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)) {
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);
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.'));
}
$this->checkSessionToken();
$password = $this->trimmed('password');
- $confirm = $this->trimmed('confirm');
+ $confirm = $this->trimmed('confirm');
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;
/**
* 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));
+ array('nickname' => $this->user->nickname));
if ($this->isPost()) {
$this->confirmUser();
function showContent()
{
$this->element('p', 'instructions',
- // TRANS: Form instructions. %s is the nickname of the to be registered user.
- sprintf(_m('You have confirmed the email address for your new user account %s. '.
- 'Use the form below to set your new password.'),
- $this->user->nickname));
+ // TRANS: Form instructions. %s is the nickname of the to be registered user.
+ sprintf(_m('You have confirmed the email address for your new user account %s. ' .
+ 'Use the form below to set your new password.'),
+ $this->user->nickname));
$form = new ConfirmFirstEmailForm($this, $this->code);
$form->show();
function action()
{
return common_local_url('confirmfirstemail',
- array('code' => $this->code));
+ array('code' => $this->code));
}
function formClass()
$this->out->elementStart('li');
// TRANS: Field label.
$this->out->password('password', _m('New password'),
- // TRANS: Field title for password field.
- _m('6 or more characters.'));
+ // TRANS: Field title for password field.
+ _m('6 or more characters.'));
$this->out->elementEnd('li');
$this->out->elementStart('li');
// TRANS: Field label for repeat password field.
- $this->out->password('confirm', _m('LABEL','Confirm'),
- // TRANS: Field title for repeat password field.
- _m('Same as password above.'));
+ $this->out->password('confirm', _m('LABEL', 'Confirm'),
+ // TRANS: Field title for repeat password field.
+ _m('Same as password above.'));
$this->out->elementEnd('li');
$this->out->elementEnd('ul');
}
function formActions()
{
// TRANS: Button text for completing registration by e-mail.
- $this->out->submit('save', _m('BUTTON','Save'));
+ $this->out->submit('save', _m('BUTTON', 'Save'));
}
}
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:
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);
action should be more or less ready to go.
```php
-function handle($args)
+function handle()
{
- parent::handle($args);
+ parent::handle();
$this->showPage();
}