- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @copyright 2008-2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class OpenidsettingsAction extends SettingsAction
{
@@ -100,17 +92,26 @@ class OpenidsettingsAction extends SettingsAction
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
// TRANS: Field label.
- $this->input('openid_url', _m('OpenID URL'), null,
- // TRANS: Form guide.
- _m('An OpenID URL which identifies you.'),
- null, true,
- ['placeholder'=>'https://example.com/you']);
+ $this->input(
+ 'openid_url',
+ _m('OpenID URL'),
+ null,
+ // TRANS: Form guide.
+ _m('An OpenID URL which identifies you.'),
+ null,
+ true,
+ ['placeholder' => 'https://example.com/you']
+ );
$this->elementEnd('li');
$this->elementStart('li');
// TRANS: Field label.
- $this->checkbox('openid-synch', _m('Synchronize Account'), false,
- // TRANS: Form guide.
- _m('Synchronize GNU social profile with this OpenID identity.'));
+ $this->checkbox(
+ 'openid-synch',
+ _m('Synchronize Account'),
+ false,
+ // TRANS: Form guide.
+ _m('Synchronize GNU social profile with this OpenID identity.')
+ );
$this->elementEnd('li');
$this->elementEnd('ul');
// TRANS: Button text for adding an OpenID URL.
@@ -129,13 +130,16 @@ class OpenidsettingsAction extends SettingsAction
$this->element('h2', null, _m('HEADER', 'OpenID Actions'));
if ($cnt == 1 && !$this->scoped->hasPassword()) {
- $this->element('p', 'form_guide',
- // TRANS: Form guide.
- _m('You can\'t remove your main OpenID account ' .
- 'without either adding a password to your ' .
- 'GNU social account or another OpenID account. ' .
- 'You can synchronize your profile with your ' .
- 'OpenID by clicking the button labeled "Synchronize".'));
+ $this->element(
+ 'p',
+ 'form_guide',
+ // TRANS: Form guide.
+ _m('You can\'t remove your main OpenID account ' .
+ 'without either adding a password to your ' .
+ 'GNU social account or another OpenID account. ' .
+ 'You can synchronize your profile with your ' .
+ 'OpenID by clicking the button labeled "Synchronize".')
+ );
if ($oid->fetch()) {
$this->elementStart('form', ['method' => 'POST',
@@ -152,12 +156,15 @@ class OpenidsettingsAction extends SettingsAction
$this->elementEnd('form');
}
} else {
- $this->element('p', 'form_guide',
- // TRANS: Form guide.
- _m('You can remove an OpenID from your account ' .
- 'by clicking the button labeled "Remove". ' .
- 'You can synchronize your profile with an OpenID ' .
- 'by clicking the button labeled "Synchronize".'));
+ $this->element(
+ 'p',
+ 'form_guide',
+ // TRANS: Form guide.
+ _m('You can remove an OpenID from your account ' .
+ 'by clicking the button labeled "Remove". ' .
+ 'You can synchronize your profile with an OpenID ' .
+ 'by clicking the button labeled "Synchronize".')
+ );
$idx = 0;
while ($oid->fetch()) {
@@ -191,26 +198,38 @@ class OpenidsettingsAction extends SettingsAction
// TRANS: Fieldset legend.
$this->element('legend', null, _m('OpenID Trusted Sites'));
$this->hidden('token', common_session_token());
- $this->element('p', 'form_guide',
- // TRANS: Form guide.
- _m('The following sites are allowed to access your ' .
- 'identity and log you in. You can remove a site from ' .
- 'this list to deny it access to your OpenID.'));
+ $this->element(
+ 'p',
+ 'form_guide',
+ // TRANS: Form guide.
+ _m('The following sites are allowed to access your ' .
+ 'identity and log you in. You can remove a site from ' .
+ 'this list to deny it access to your OpenID.')
+ );
$this->elementStart('ul', 'form_data');
$user_openid_trustroot = new User_openid_trustroot();
$user_openid_trustroot->user_id = $this->scoped->getID();
if ($user_openid_trustroot->find()) {
while ($user_openid_trustroot->fetch()) {
$this->elementStart('li');
- $this->element('input', ['name' => 'openid_trustroot[]',
- 'type' => 'checkbox',
- 'class' => 'checkbox',
- 'value' => $user_openid_trustroot->trustroot,
- 'id' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot)]);
- $this->element('label',
- ['class'=>'checkbox',
- 'for' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot)],
- $user_openid_trustroot->trustroot);
+ $this->element(
+ 'input',
+ [
+ 'name' => 'openid_trustroot[]',
+ 'type' => 'checkbox',
+ 'class' => 'checkbox',
+ 'value' => $user_openid_trustroot->trustroot,
+ 'id' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot),
+ ]
+ );
+ $this->element(
+ 'label',
+ [
+ 'class'=>'checkbox',
+ 'for' => 'openid_trustroot_' . crc32($user_openid_trustroot->trustroot),
+ ],
+ $user_openid_trustroot->trustroot
+ );
$this->elementEnd('li');
}
}
@@ -363,7 +382,7 @@ class OpenidsettingsAction extends SettingsAction
$orig = clone($prefs);
}
- $prefs->hide_profile_link = $this->booleanintstring('hide_profile_link');
+ $prefs->hide_profile_link = $this->boolean('hide_profile_link');
if ($orig instanceof User_openid_prefs) {
$prefs->update($orig);
diff --git a/plugins/OpenID/classes/User_openid_prefs.php b/plugins/OpenID/classes/User_openid_prefs.php
index ae0b9e2fbf..0d1d999ed8 100644
--- a/plugins/OpenID/classes/User_openid_prefs.php
+++ b/plugins/OpenID/classes/User_openid_prefs.php
@@ -63,12 +63,12 @@ class User_openid_prefs extends Managed_DataObject
'description' => 'Per-user preferences for OpenID display',
'fields' => [
'user_id' => [
- 'type' => 'integer',
+ 'type' => 'int',
'not null' => true,
'description' => 'User whose prefs we are saving'
],
'hide_profile_link' => [
- 'type' => 'integer',
+ 'type' => 'int',
'not null' => true,
'default' => 0,
'description' => 'Whether to hide profile links from profile block'
diff --git a/plugins/OpenID/openid.php b/plugins/OpenID/openid.php
index 964d098030..5237cc81ea 100644
--- a/plugins/OpenID/openid.php
+++ b/plugins/OpenID/openid.php
@@ -1,25 +1,25 @@
.
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social 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.
+//
+// GNU social 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 GNU social. If not, see .
+
+/**
+ * @copyright 2008, 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
require_once('Auth/OpenID.php');
require_once('Auth/OpenID/Consumer.php');
@@ -49,19 +49,19 @@ function oid_store()
}
$db = DB::connect($dsn, $options);
- if (PEAR::isError($db)) {
+ if ((new PEAR)->isError($db)) {
throw new ServerException($db->getMessage());
}
switch (common_config('db', 'type')) {
+ case 'pgsql':
+ $store = new Auth_OpenID_PostgreSQLStore($db);
+ break;
case 'mysql':
$store = new Auth_OpenID_MySQLStore($db);
break;
- case 'postgresql':
- $store = new Auth_OpenID_PostgreSQLStore($db);
- break;
default:
- throw new ServerException(_m('Unknown DB type for OpenID.'));
+ throw new ServerException('Unknown DB type selected.');
}
}
return $store;
@@ -90,9 +90,11 @@ function oid_clear_last()
function oid_set_last($openid_url)
{
- common_set_cookie(OPENID_COOKIE_KEY,
- $openid_url,
- time() + OPENID_COOKIE_EXPIRY);
+ common_set_cookie(
+ OPENID_COOKIE_KEY,
+ $openid_url,
+ time() + OPENID_COOKIE_EXPIRY
+ );
}
function oid_get_last()
@@ -119,7 +121,7 @@ function oid_link_user($id, $canonical, $display)
$oid->created = common_sql_now();
if (!$oid->insert()) {
- $err = &$_PEAR->getStaticProperty('DB_DataObject','lastError');
+ $err = &$_PEAR->getStaticProperty('DB_DataObject', 'lastError');
return false;
}
@@ -149,9 +151,11 @@ function oid_check_immediate($openid_url, $backto=null)
$_SESSION['openid_immediate_backto'] = $backto;
- oid_authenticate($openid_url,
- 'finishimmediate',
- true);
+ oid_authenticate(
+ $openid_url,
+ 'finishimmediate',
+ true
+ );
}
function oid_authenticate($openid_url, $returnto, $immediate=false)
@@ -177,23 +181,27 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
common_log(LOG_ERR, __METHOD__ . ": mystery fail contacting $openid_url");
// TRANS: OpenID plugin message. Given when an OpenID is not valid.
throw new ServerException(_m('Not a valid OpenID.'));
- } else if (Auth_OpenID::isFailure($auth_request)) {
+ } elseif (Auth_OpenID::isFailure($auth_request)) {
common_log(LOG_ERR, __METHOD__ . ": OpenID fail to $openid_url: $auth_request->message");
// TRANS: OpenID plugin server error. Given when the OpenID authentication request fails.
// TRANS: %s is the failure message.
throw new ServerException(sprintf(_m('OpenID failure: %s.'), $auth_request->message));
}
- $sreg_request = Auth_OpenID_SRegRequest::build(// Required
- array(),
- // Optional
- array('nickname',
- 'email',
- 'fullname',
- 'language',
- 'timezone',
- 'postcode',
- 'country'));
+ $sreg_request = Auth_OpenID_SRegRequest::build(
+ // Required
+ [],
+ // Optional
+ [
+ 'nickname',
+ 'email',
+ 'fullname',
+ 'language',
+ 'timezone',
+ 'postcode',
+ 'country',
+ ]
+ );
if ($sreg_request) {
$auth_request->addExtension($sreg_request);
@@ -224,9 +232,11 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
// autosubmitter for now.
//
//if ($auth_request->shouldSendRedirect()) {
- $redirect_url = $auth_request->redirectURL($trust_root,
- $process_url,
- $immediate);
+ $redirect_url = $auth_request->redirectURL(
+ $trust_root,
+ $process_url,
+ $immediate
+ );
if (Auth_OpenID::isFailure($redirect_url)) {
// TRANS: OpenID plugin server error. Given when the OpenID authentication request cannot be redirected.
// TRANS: %s is the failure message.
@@ -266,11 +276,14 @@ function oid_authenticate($openid_url, $returnto, $immediate=false)
function _oid_print_instructions()
{
- common_element('div', 'instructions',
- // TRANS: OpenID plugin user instructions.
- _m('This form should automatically submit itself. '.
- 'If not, click the submit button to go to your '.
- 'OpenID provider.'));
+ common_element(
+ 'div',
+ 'instructions',
+ // TRANS: OpenID plugin user instructions.
+ _m('This form should automatically submit itself. '.
+ 'If not, click the submit button to go to your '.
+ 'OpenID provider.')
+ );
}
/**
@@ -382,22 +395,22 @@ function oid_check_teams($response)
class AutosubmitAction extends Action
{
- var $form_html = null;
- var $form_id = null;
+ public $form_html = null;
+ public $form_id = null;
- function handle()
+ public function handle()
{
parent::handle();
$this->showPage();
}
- function title()
+ public function title()
{
// TRANS: Title
return _m('OpenID Login Submission');
}
- function showContent()
+ public function showContent()
{
$this->raw('');
// @todo FIXME: This would be better using standard CSS class, but the present theme's a bit scary.
@@ -414,10 +427,13 @@ class AutosubmitAction extends Action
$this->raw($this->form_html);
}
- function showScripts()
+ public function showScripts()
{
parent::showScripts();
- $this->element('script', null,
- 'document.getElementById(\'' . $this->form_id . '\').submit();');
+ $this->element(
+ 'script',
+ null,
+ 'document.getElementById(\'' . $this->form_id . '\').submit();'
+ );
}
}
diff --git a/plugins/Poll/classes/Poll.php b/plugins/Poll/classes/Poll.php
index 6a97a52441..2a3c679dde 100644
--- a/plugins/Poll/classes/Poll.php
+++ b/plugins/Poll/classes/Poll.php
@@ -1,46 +1,38 @@
.
+
/**
* Data class to mark notices as bookmarks
*
- * PHP version 5
- *
- * @category PollPlugin
- * @package StatusNet
- * @author Brion Vibber
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
- *
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2011, StatusNet, Inc.
- *
- * 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 .
+ * @category PollPlugin
+ * @package GNUsocial
+ * @author Brion Vibber
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* For storing the poll options and such
*
- * @category PollPlugin
- * @package StatusNet
- * @author Brion Vibber
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
- * @see DB_DataObject
+ * @see DB_DataObject
*/
class Poll extends Managed_DataObject
{
@@ -136,7 +128,9 @@ class Poll extends Managed_DataObject
$pr = new Poll_response();
$pr->poll_id = $this->id;
$pr->groupBy('selection');
- $pr->selectAdd('count(profile_id) as votes');
+ $pr->selectAdd();
+ $pr->selectAdd('selection');
+ $pr->selectAdd('COUNT(profile_id) AS votes');
$pr->find();
$raw = array();
diff --git a/plugins/Poll/classes/Poll_response.php b/plugins/Poll/classes/Poll_response.php
index 1997f4b64f..91f6a7cf14 100644
--- a/plugins/Poll/classes/Poll_response.php
+++ b/plugins/Poll/classes/Poll_response.php
@@ -1,46 +1,38 @@
.
+
/**
* Data class to record responses to polls
*
- * PHP version 5
- *
- * @category PollPlugin
- * @package StatusNet
- * @author Brion Vibber
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
- *
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2011, StatusNet, Inc.
- *
- * 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 .
+ * @category PollPlugin
+ * @package GNUsocial
+ * @author Brion Vibber
+ * @copyright 2011, StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* For storing the poll options and such
*
- * @category PollPlugin
- * @package StatusNet
- * @author Brion Vibber
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @copyright 2011, StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
- * @see DB_DataObject
+ * @see DB_DataObject
*/
class Poll_response extends Managed_DataObject
{
@@ -69,7 +61,7 @@ class Poll_response extends Managed_DataObject
),
'primary key' => array('id'),
'unique keys' => array(
- 'poll_uri_key' => array('uri'),
+ 'poll_response_uri_key' => array('uri'),
'poll_response_poll_id_profile_id_key' => array('poll_id', 'profile_id'),
),
'indexes' => array(
diff --git a/plugins/Poll/classes/User_poll_prefs.php b/plugins/Poll/classes/User_poll_prefs.php
index 450a6b9cfb..cf3272e2bc 100644
--- a/plugins/Poll/classes/User_poll_prefs.php
+++ b/plugins/Poll/classes/User_poll_prefs.php
@@ -1,44 +1,37 @@
.
+
/**
* Data class to record user prefs for polls
*
- * PHP version 5
- *
- * @category PollPlugin
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
- *
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2012, StatusNet, Inc.
- *
- * 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 .
+ * @category PollPlugin
+ * @package GNUsocial
+ * @author Brion Vibber
+ * @author Evan Prodromou
+ * @copyright 2012, StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* For storing the poll prefs
*
- * @category PollPlugin
- * @package StatusNet
- * @author Brion Vibber
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @copyright 2012, StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
* @see DB_DataObject
*/
@@ -46,7 +39,7 @@ class User_poll_prefs extends Managed_DataObject
{
public $__table = 'user_poll_prefs'; // table name
public $user_id; // int id
- public $hide_responses; // boolean
+ public $hide_responses; // bool
public $created; // datetime
public $modified; // datetime
@@ -59,7 +52,7 @@ class User_poll_prefs extends Managed_DataObject
'description' => 'Record of user preferences for polls',
'fields' => array(
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
- 'hide_responses' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'Hide all poll responses'),
+ 'hide_responses' => array('type' => 'bool', 'default' => false, 'description' => 'Hide all poll responses'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
),
diff --git a/plugins/QnA/actions/qnaclosequestion.php b/plugins/QnA/actions/qnaclosequestion.php
index 4c2abb6536..57ab3ee1fd 100644
--- a/plugins/QnA/actions/qnaclosequestion.php
+++ b/plugins/QnA/actions/qnaclosequestion.php
@@ -1,47 +1,36 @@
.
+
/**
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2011, StatusNet, Inc.
- *
* Close a question to further answers
*
- * 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 .
- *
* @category QnA
- * @package StatusNet
+ * @package GNUsocial
* @author Zach Copley
* @copyright 2011 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or late
*/
-if (!defined('STATUSNET')) {
- // This check helps protect against security problems;
- // your code file can't be executed directly from the web.
- exit(1);
-}
+
+defined('GNUSOCIAL') || die();
/**
* Close a question to new answers
*
- * @category QnA
- * @package StatusNet
- * @author Zach Copley
* @copyright 2010 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or late
*/
class QnaclosequestionAction extends Action
{
@@ -57,7 +46,7 @@ class QnaclosequestionAction extends Action
*
* @return string Action title
*/
- function title()
+ public function title()
{
// TRANS: Page title for close a question
return _m('Close question');
@@ -71,7 +60,7 @@ class QnaclosequestionAction extends Action
* @return boolean true
* @throws ClientException
*/
- function prepare(array $args = [])
+ public function prepare(array $args = [])
{
parent::prepare($args);
if ($this->boolean('ajax')) {
@@ -107,7 +96,7 @@ class QnaclosequestionAction extends Action
*
* @return void
*/
- function handle()
+ public function handle()
{
parent::handle();
@@ -125,7 +114,7 @@ class QnaclosequestionAction extends Action
*
* @return void
*/
- function closeQuestion()
+ public function closeQuestion()
{
$user = common_current_user();
@@ -136,9 +125,8 @@ class QnaclosequestionAction extends Action
}
$orig = clone($this->question);
- $this->question->closed = 1;
+ $this->question->closed = true;
$this->question->update($orig);
-
} catch (ClientException $ce) {
$this->error = $ce->getMessage();
$this->showPage();
@@ -166,7 +154,7 @@ class QnaclosequestionAction extends Action
*
* @return void
*/
- function showContent()
+ public function showContent()
{
if (!empty($this->error)) {
$this->element('p', 'error', $this->error);
@@ -184,7 +172,7 @@ class QnaclosequestionAction extends Action
*
* @return boolean is read only action?
*/
- function isReadOnly($args)
+ public function isReadOnly($args)
{
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
$_SERVER['REQUEST_METHOD'] == 'HEAD') {
diff --git a/plugins/QnA/actions/qnareviseanswer.php b/plugins/QnA/actions/qnareviseanswer.php
index e23195531f..7ae912c68d 100644
--- a/plugins/QnA/actions/qnareviseanswer.php
+++ b/plugins/QnA/actions/qnareviseanswer.php
@@ -1,47 +1,36 @@
.
- *
- * @category QnA
- * @package StatusNet
- * @author Zach Copley
- * @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')) {
- // This check helps protect against security problems;
- // your code file can't be executed directly from the web.
- exit(1);
-}
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social 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.
+//
+// GNU social 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 GNU social. If not, see .
/**
* Revise an answer
*
* @category QnA
- * @package StatusNet
+ * @package GNUsocial
* @author Zach Copley
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
+ */
+
+defined('GNUSOCIAL') || die();
+
+/**
+ * Revise an answer
+ *
* @copyright 2010 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class QnareviseanswerAction extends Action
{
@@ -56,7 +45,7 @@ class QnareviseanswerAction extends Action
*
* @return string Action title
*/
- function title()
+ public function title()
{
// TRANS: Page title for revising a question
return _m('Revise answer');
@@ -70,7 +59,7 @@ class QnareviseanswerAction extends Action
* @return boolean true
* @throws ClientException
*/
- function prepare(array $args = [])
+ public function prepare(array $args = [])
{
parent::prepare($args);
if ($this->boolean('ajax')) {
@@ -110,7 +99,7 @@ class QnareviseanswerAction extends Action
*
* @return void
*/
- function handle()
+ public function handle()
{
parent::handle();
@@ -119,7 +108,7 @@ class QnareviseanswerAction extends Action
if ($this->arg('revise')) {
$this->showContent();
return;
- } else if ($this->arg('best')) {
+ } elseif ($this->arg('best')) {
if ($this->user->id == $this->question->profile_id) {
$this->markBest();
return;
@@ -138,7 +127,7 @@ class QnareviseanswerAction extends Action
*
* @return void
*/
- function showContent()
+ public function showContent()
{
if (!empty($this->error)) {
$this->element('p', 'error', $this->error);
@@ -154,7 +143,7 @@ class QnareviseanswerAction extends Action
return;
}
- function showAjaxReviseForm()
+ public function showAjaxReviseForm()
{
$this->startHTML('text/xml;charset=utf-8');
$this->elementStart('head');
@@ -173,7 +162,7 @@ class QnareviseanswerAction extends Action
*
* @return void
*/
- function markBest()
+ public function markBest()
{
$question = $this->question;
$answer = $this->answer;
@@ -181,12 +170,12 @@ class QnareviseanswerAction extends Action
try {
// close the question to further answers
$orig = clone($question);
- $question->closed = 1;
+ $question->closed = true;
$result = $question->update($orig);
// mark this answer an the best answer
$orig = clone($answer);
- $answer->best = 1;
+ $answer->best = true;
$result = $answer->update($orig);
} catch (ClientException $ce) {
$this->error = $ce->getMessage();
@@ -215,7 +204,7 @@ class QnareviseanswerAction extends Action
*
* @return void
*/
- function reviseAnswer()
+ public function reviseAnswer()
{
$answer = $this->answer;
@@ -255,7 +244,7 @@ class QnareviseanswerAction extends Action
*
* @return boolean is read only action?
*/
- function isReadOnly($args)
+ public function isReadOnly($args)
{
if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
$_SERVER['REQUEST_METHOD'] == 'HEAD') {
diff --git a/plugins/QnA/classes/QnA_Answer.php b/plugins/QnA/classes/QnA_Answer.php
index 2aa69cf5a3..a2e1c81f86 100644
--- a/plugins/QnA/classes/QnA_Answer.php
+++ b/plugins/QnA/classes/QnA_Answer.php
@@ -1,46 +1,38 @@
.
+
/**
* Data class to save answers to questions
*
- * PHP version 5
- *
- * @category QnA
- * @package StatusNet
- * @author Zach Copley
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
- *
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2011, StatusNet, Inc.
- *
- * 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 .
+ * @category QnA
+ * @package GNUsocial
+ * @author Zach Copley
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('STATUSNET') || die();
/**
* For storing answers
*
- * @category QnA
- * @package StatusNet
- * @author Zach Copley
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
- * @see DB_DataObject
+ * @see DB_DataObject
*/
class QnA_Answer extends Managed_DataObject
{
@@ -51,7 +43,7 @@ class QnA_Answer extends Managed_DataObject
public $uri; // varchar(191) not 255 because utf8mb4 takes more space
public $question_id; // char(36) -> question.id UUID
public $profile_id; // int -> question.id
- public $best; // (boolean) int -> whether the question asker has marked this as the best answer
+ public $best; // bool -> whether the question asker has marked this as the best answer
public $revisions; // int -> count of revisions to this answer
public $content; // text -> response text
public $created; // datetime
@@ -82,18 +74,18 @@ class QnA_Answer extends Managed_DataObject
'description' => 'UUID of question being responded to',
),
'content' => array('type' => 'text'), // got a better name?
- 'best' => array('type' => 'int', 'size' => 'tiny'),
+ 'best' => array('type' => 'bool'),
'revisions' => array('type' => 'int'),
'profile_id' => array('type' => 'int'),
'created' => array('type' => 'datetime', 'not null' => true),
),
'primary key' => array('id'),
'unique keys' => array(
- 'question_uri_key' => array('uri'),
- 'question_id_profile_id_key' => array('question_id', 'profile_id'),
+ 'qna_answer_uri_key' => array('uri'),
+ 'qna_answer_question_id_profile_id_key' => array('question_id', 'profile_id'),
),
'indexes' => array(
- 'profile_id_question_id_index' => array('profile_id', 'question_id'),
+ 'qna_answer_profile_id_question_id_idx' => array('profile_id', 'question_id'),
)
);
}
@@ -105,7 +97,7 @@ class QnA_Answer extends Managed_DataObject
*
* @return QnA_Answer found response or null
*/
- static function getByNotice($notice)
+ public static function getByNotice($notice)
{
$answer = self::getKV('uri', $notice->uri);
if (empty($answer)) {
@@ -119,17 +111,17 @@ class QnA_Answer extends Managed_DataObject
*
* @return Notice
*/
- function getNotice()
+ public function getNotice()
{
return Notice::getKV('uri', $this->uri);
}
- static function fromNotice($notice)
+ public static function fromNotice($notice)
{
return QnA_Answer::getKV('uri', $notice->uri);
}
- function getUrl()
+ public function getUrl()
{
return $this->getNotice()->getUrl();
}
@@ -139,29 +131,29 @@ class QnA_Answer extends Managed_DataObject
*
* @return QnA_Question
*/
- function getQuestion()
+ public function getQuestion()
{
$question = QnA_Question::getKV('id', $this->question_id);
if (empty($question)) {
// TRANS: Exception thown when getting a question with a non-existing ID.
// TRANS: %s is the non-existing question ID.
- throw new Exception(sprintf(_m('No question with ID %s'),$this->question_id));
+ throw new Exception(sprintf(_m('No question with ID %s'), $this->question_id));
}
return $question;
}
- function getProfile()
+ public function getProfile()
{
$profile = Profile::getKV('id', $this->profile_id);
if (empty($profile)) {
// TRANS: Exception thown when getting a profile with a non-existing ID.
// TRANS: %s is the non-existing profile ID.
- throw new Exception(sprintf(_m('No profile with ID %s'),$this->profile_id));
+ throw new Exception(sprintf(_m('No profile with ID %s'), $this->profile_id));
}
return $profile;
}
- function asHTML()
+ public function asHTML()
{
return self::toHTML(
$this->getProfile(),
@@ -170,7 +162,7 @@ class QnA_Answer extends Managed_DataObject
);
}
- function asString()
+ public function asString()
{
return self::toString(
$this->getProfile(),
@@ -179,7 +171,7 @@ class QnA_Answer extends Managed_DataObject
);
}
- static function toHTML($profile, $question, $answer)
+ public static function toHTML($profile, $question, $answer)
{
$notice = $question->getNotice();
@@ -201,7 +193,7 @@ class QnA_Answer extends Managed_DataObject
htmlspecialchars(
// Notification of how often an answer was revised.
// TRANS: %s is the number of answer revisions.
- sprintf(_m('%s revision','%s revisions',$answer->revisions), $answer->revisions)
+ sprintf(_m('%s revision', '%s revisions', $answer->revisions), $answer->revisions)
)
);
$out->elementEnd('span');
@@ -212,7 +204,7 @@ class QnA_Answer extends Managed_DataObject
return $out->getString();
}
- static function toString($profile, $question, $answer)
+ public static function toString($profile, $question, $answer)
{
// @todo FIXME: unused variable?
$notice = $question->getNotice();
@@ -237,7 +229,7 @@ class QnA_Answer extends Managed_DataObject
*
* @return Notice saved notice
*/
- static function saveNew($profile, $question, $text, $options = null)
+ public static function saveNew($profile, $question, $text, $options = null)
{
if (empty($options)) {
$options = array();
@@ -248,7 +240,7 @@ class QnA_Answer extends Managed_DataObject
$answer->profile_id = $profile->id;
$answer->question_id = $question->id;
$answer->revisions = 0;
- $answer->best = 0;
+ $answer->best = false;
$answer->content = $text;
$answer->created = common_sql_now();
$answer->uri = common_local_url(
diff --git a/plugins/QnA/classes/QnA_Question.php b/plugins/QnA/classes/QnA_Question.php
index b531838677..81ea0cdb56 100644
--- a/plugins/QnA/classes/QnA_Question.php
+++ b/plugins/QnA/classes/QnA_Question.php
@@ -1,46 +1,38 @@
.
+
/**
* Data class to mark a notice as a question
*
- * PHP version 5
- *
- * @category QnA
- * @package StatusNet
- * @author Zach Copley
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
- *
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2011, StatusNet, Inc.
- *
- * 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 .
+ * @category QnA
+ * @package GNUsocial
+ * @author Zach Copley
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* For storing a question
*
- * @category QnA
- * @package StatusNet
- * @author Zach Copley
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
- * @see DB_DataObject
+ * @see DB_DataObject
*/
class QnA_Question extends Managed_DataObject
{
@@ -52,7 +44,7 @@ class QnA_Question extends Managed_DataObject
public $profile_id; // int -> profile.id
public $title; // text
public $description; // text
- public $closed; // int (boolean) whether a question is closed
+ public $closed; // bool -> whether a question is closed
public $created; // datetime
/**
@@ -76,7 +68,7 @@ class QnA_Question extends Managed_DataObject
),
'profile_id' => array('type' => 'int'),
'title' => array('type' => 'text'),
- 'closed' => array('type' => 'int', 'size' => 'tiny'),
+ 'closed' => array('type' => 'bool'),
'description' => array('type' => 'text'),
'created' => array(
'type' => 'datetime',
@@ -85,7 +77,7 @@ class QnA_Question extends Managed_DataObject
),
'primary key' => array('id'),
'unique keys' => array(
- 'question_uri_key' => array('uri'),
+ 'qna_question_uri_key' => array('uri'),
),
);
}
@@ -97,28 +89,28 @@ class QnA_Question extends Managed_DataObject
*
* @return Question found question or null
*/
- static function getByNotice($notice)
+ public static function getByNotice($notice)
{
return self::getKV('uri', $notice->uri);
}
- function getNotice()
+ public function getNotice()
{
return Notice::getKV('uri', $this->uri);
}
- function getUrl()
+ public function getUrl()
{
return $this->getNotice()->getUrl();
}
- function getProfile()
+ public function getProfile()
{
$profile = Profile::getKV('id', $this->profile_id);
if (empty($profile)) {
// TRANS: Exception trown when getting a profile for a non-existing ID.
// TRANS: %s is the provided profile ID.
- throw new Exception(sprintf(_m('No profile with ID %s'),$this->profile_id));
+ throw new Exception(sprintf(_m('No profile with ID %s'), $this->profile_id));
}
return $profile;
}
@@ -130,7 +122,7 @@ class QnA_Question extends Managed_DataObject
*
* @return Answer object or null
*/
- function getAnswer(Profile $profile)
+ public function getAnswer(Profile $profile)
{
$a = new QnA_Answer();
$a->question_id = $this->id;
@@ -143,7 +135,7 @@ class QnA_Question extends Managed_DataObject
}
}
- function getAnswers()
+ public function getAnswers()
{
$a = new QnA_Answer();
$a->question_id = $this->id;
@@ -155,7 +147,7 @@ class QnA_Question extends Managed_DataObject
}
}
- function countAnswers()
+ public function countAnswers()
{
$a = new QnA_Answer();
@@ -164,22 +156,22 @@ class QnA_Question extends Managed_DataObject
return $a->count();
}
- static function fromNotice($notice)
+ public static function fromNotice($notice)
{
return QnA_Question::getKV('uri', $notice->uri);
}
- function asHTML()
+ public function asHTML()
{
return self::toHTML($this->getProfile(), $this);
}
- function asString()
+ public function asString()
{
return self::toString($this->getProfile(), $this);
}
- static function toHTML($profile, $question)
+ public static function toHTML($profile, $question)
{
$notice = $question->getNotice();
@@ -205,7 +197,7 @@ class QnA_Question extends Managed_DataObject
$out->elementStart('span', 'answer-count');
// TRANS: Number of given answers to a question.
// TRANS: %s is the number of given answers.
- $out->text(sprintf(_m('%s answer','%s answers',$cnt), $cnt));
+ $out->text(sprintf(_m('%s answer', '%s answers', $cnt), $cnt));
$out->elementEnd('span');
}
@@ -221,7 +213,7 @@ class QnA_Question extends Managed_DataObject
return $out->getString();
}
- static function toString($profile, $question, $answers)
+ public static function toString($profile, $question, $answers)
{
return sprintf(htmlspecialchars($question->description));
}
@@ -237,7 +229,7 @@ class QnA_Question extends Managed_DataObject
*
* @return Notice saved notice
*/
- static function saveNew($profile, $title, $description, $options = array())
+ public static function saveNew($profile, $title, $description, $options = [])
{
$q = new QnA_Question();
diff --git a/plugins/QnA/classes/QnA_Vote.php b/plugins/QnA/classes/QnA_Vote.php
index 13679acd2c..7a1d0911f6 100644
--- a/plugins/QnA/classes/QnA_Vote.php
+++ b/plugins/QnA/classes/QnA_Vote.php
@@ -1,46 +1,38 @@
.
+
/**
* Data class to save users votes for
*
- * PHP version 5
- *
- * @category QnA
- * @package StatusNet
- * @author Zach Copley
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
- *
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2011, StatusNet, Inc.
- *
- * 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 .
+ * @category QnA
+ * @package GNUsocial
+ * @author Zach Copley
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* For storing votes on question and answers
*
- * @category QnA
- * @package StatusNet
- * @author Zach Copley
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
- * @see DB_DataObject
+ * @see DB_DataObject
*/
class QnA_Vote extends Managed_DataObject
{
@@ -87,11 +79,11 @@ class QnA_Vote extends Managed_DataObject
),
'primary key' => array('id'),
'indexes' => array(
- 'profile_id_question_Id_index' => array(
+ 'qna_vote_profile_id_question_id_idx' => array(
'profile_id',
'question_id'
),
- 'profile_id_question_Id_index' => array(
+ 'qna_vote_profile_id_question_id_idx' => array(
'profile_id',
'answer_id'
)
@@ -110,7 +102,7 @@ class QnA_Vote extends Managed_DataObject
*
* @return Void
*/
- static function save($profile, $question, $answer, $vote)
+ public static function save($profile, $question, $answer, $vote)
{
$v = new QnA_Vote();
$v->id = UUID::gen();
diff --git a/plugins/Realtime/classes/Realtime_channel.php b/plugins/Realtime/classes/Realtime_channel.php
index 7541593433..e8431d0728 100644
--- a/plugins/Realtime/classes/Realtime_channel.php
+++ b/plugins/Realtime/classes/Realtime_channel.php
@@ -1,36 +1,18 @@
.
- *
- * @category Realtime
- * @package StatusNet
- * @author Evan Prodromou
- * @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);
-}
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social 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.
+//
+// GNU social 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 GNU social. If not, see .
/**
* A channel for real-time browser data
@@ -38,11 +20,20 @@ if (!defined('STATUSNET')) {
* For each user currently browsing the site, we want to know which page they're on
* so we can send real-time updates to their browser.
*
- * @category Realtime
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @category Realtime
+ * @package GNUsocial
+ * @author Evan Prodromou
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
+ */
+
+defined('GNUSOCIAL') || die();
+
+/**
+ * A channel for real-time browser data
+ *
+ * @copyright 2011 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
* @see DB_DataObject
*/
@@ -88,7 +79,7 @@ class Realtime_channel extends Managed_DataObject
'length' => 32,
'not null' => true,
'description' => 'shared secret key for this channel'),
- 'audience' => array('type' => 'integer',
+ 'audience' => array('type' => 'int',
'not null' => true,
'default' => 0,
'description' => 'reference count'),
@@ -111,7 +102,7 @@ class Realtime_channel extends Managed_DataObject
);
}
- static function saveNew($user_id, $action, $arg1, $arg2)
+ public static function saveNew($user_id, $action, $arg1, $arg2)
{
$channel = new Realtime_channel();
@@ -131,7 +122,7 @@ class Realtime_channel extends Managed_DataObject
return $channel;
}
- static function getChannel($user_id, $action, $arg1, $arg2)
+ public static function getChannel($user_id, $action, $arg1, $arg2)
{
$channel = self::fetchChannel($user_id, $action, $arg1, $arg2);
@@ -152,7 +143,7 @@ class Realtime_channel extends Managed_DataObject
return $channel;
}
- static function getAllChannels($action, $arg1, $arg2)
+ public static function getAllChannels($action, $arg1, $arg2)
{
$channel = new Realtime_channel();
@@ -170,9 +161,9 @@ class Realtime_channel extends Managed_DataObject
$channel->arg2 = $arg2;
}
- $channel->whereAdd('modified > "' . common_sql_date(time() - self::TIMEOUT) . '"');
+ $channel->whereAdd(sprintf("modified > TIMESTAMP '%s'", common_sql_date(time() - self::TIMEOUT)));
- $channels = array();
+ $channels = [];
if ($channel->find()) {
$channels = $channel->fetchAll();
@@ -181,7 +172,7 @@ class Realtime_channel extends Managed_DataObject
return $channels;
}
- static function fetchChannel($user_id, $action, $arg1, $arg2)
+ public static function fetchChannel($user_id, $action, $arg1, $arg2)
{
$channel = new Realtime_channel();
@@ -213,7 +204,7 @@ class Realtime_channel extends Managed_DataObject
}
}
- function increment()
+ public function increment()
{
// XXX: race
$orig = clone($this);
@@ -222,7 +213,7 @@ class Realtime_channel extends Managed_DataObject
$this->update($orig);
}
- function touch()
+ public function touch()
{
// XXX: race
$orig = clone($this);
@@ -230,7 +221,7 @@ class Realtime_channel extends Managed_DataObject
$this->update($orig);
}
- function decrement()
+ public function decrement()
{
// XXX: race
if ($this->audience == 1) {
diff --git a/plugins/Realtime/scripts/cleanupchannels.php b/plugins/Realtime/scripts/cleanupchannels.php
index 4aa0a4ba50..31ed304d4a 100755
--- a/plugins/Realtime/scripts/cleanupchannels.php
+++ b/plugins/Realtime/scripts/cleanupchannels.php
@@ -1,23 +1,27 @@
#!/usr/bin/env php
.
+
/*
- * StatusNet - a distributed open-source microblogging tool
- * Copyright (C) 2011, StatusNet, Inc.
- *
* Script to print out current version of the software
*
- * 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 .
+ * @package Realtime
+ * @author Mikael Nordfeldth
+ * @copyright 2011, StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
define('INSTALLDIR', realpath(__DIR__ . '/../../..'));
@@ -42,7 +46,7 @@ function cleanupChannels()
$rc->selectAdd();
$rc->selectAdd('channel_key');
- $rc->whereAdd('modified < "' . common_sql_date(time() - Realtime_channel::TIMEOUT) . '"');
+ $rc->whereAdd(sprintf("modified < TIMESTAMP '%s'", common_sql_date(time() - Realtime_channel::TIMEOUT)));
if ($rc->find()) {
$keys = $rc->fetchAll();
diff --git a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
index a4a544784a..819b01b07b 100644
--- a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
+++ b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
@@ -1,55 +1,43 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
* Plugin that requires the user to have a validated email address before they
* can post notices
*
- * PHP version 5
- *
- * LICENCE: 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 .
- *
* @category Plugin
- * @package StatusNet
+ * @package GNUsocial
* @author Craig Andrews
* @author Brion Vibber
* @author Evan Prodromou
+ * @author Mikael Nordfeldth
* @copyright 2011 StatusNet Inc. http://status.net/
- * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @copyright 2009-2013 Free Software Foundation, Inc http://www.fsf.org
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* Plugin for requiring a validated email before posting.
*
* Enable this plugin using addPlugin('RequireValidatedEmail');
- *
- * @category Plugin
- * @package StatusNet
- * @author Craig Andrews
- * @author Brion Vibber
- * @author Evan Prodromou
- * @author Mikael Nordfeldth
* @copyright 2009-2013 Free Software Foundation, Inc http://www.fsf.org
* @copyright 2009-2010 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class RequireValidatedEmailPlugin extends Plugin
{
@@ -84,8 +72,10 @@ class RequireValidatedEmailPlugin extends Plugin
public function onRouterInitialized(URLMapper $m)
{
- $m->('main/confirmfirst/:code',
- ['action' => 'confirmfirstemail']);
+ $m->connect(
+ 'main/confirmfirst/:code',
+ ['action' => 'confirmfirstemail']
+ );
return true;
}
@@ -121,7 +111,7 @@ class RequireValidatedEmailPlugin extends Plugin
*
* @return bool hook result code
*/
- function onStartRegisterUser(&$user, &$profile)
+ public function onStartRegisterUser(&$user, &$profile)
{
$email = $user->email;
@@ -153,8 +143,10 @@ class RequireValidatedEmailPlugin extends Plugin
// that somebody's ok despite a non-validated email.
// @todo FIXME: This isn't how to do it! Use Start*/End* instead
- Event::handle('RequireValidatedEmailPlugin_Override',
- array($user, &$knownGood));
+ Event::handle(
+ 'RequireValidatedEmailPlugin_Override',
+ [$user, &$knownGood]
+ );
return $knownGood;
}
@@ -188,7 +180,7 @@ class RequireValidatedEmailPlugin extends Plugin
*
* @return bool true if user has a trusted OpenID.
*/
- function hasTrustedOpenID(User $user)
+ public function hasTrustedOpenID(User $user)
{
if ($this->trustedOpenIDs && class_exists('User_openid')) {
foreach ($this->trustedOpenIDs as $regex) {
@@ -240,7 +232,7 @@ class RequireValidatedEmailPlugin extends Plugin
*
* @return boolean hook value
*/
- function onStartMakeEntryForm($tag, $action, &$form)
+ public function onStartMakeEntryForm($tag, $action, &$form)
{
$user = common_current_user();
if (!empty($user)) {
@@ -259,7 +251,7 @@ class RequireValidatedEmailPlugin extends Plugin
* @param boolean $result if overriding, set to true/false has right
* @return boolean hook result value
*/
- function onUserRightsCheck(Profile $profile, $right, &$result)
+ public function onUserRightsCheck(Profile $profile, $right, &$result)
{
if ($right == Right::CREATEGROUP ||
($this->disallowLogin && ($right == Right::WEBLOGIN || $right == Right::API))) {
@@ -272,7 +264,7 @@ class RequireValidatedEmailPlugin extends Plugin
return true;
}
- function onLoginAction($action, &$login)
+ public function onLoginAction($action, &$login)
{
if ($action == 'confirmfirstemail') {
$login = true;
diff --git a/plugins/SearchSub/SearchSubPlugin.php b/plugins/SearchSub/SearchSubPlugin.php
index ad5acd4221..86da11a0ed 100644
--- a/plugins/SearchSub/SearchSubPlugin.php
+++ b/plugins/SearchSub/SearchSubPlugin.php
@@ -110,6 +110,8 @@ class SearchSubPlugin extends Plugin
// with a lot of searches!
$sub = new SearchSub();
$sub->groupBy('search');
+ $sub->selectAdd();
+ $sub->selectAdd('search');
$sub->find();
while ($sub->fetch()) {
$search = $sub->search;
diff --git a/plugins/SensitiveContent/actions/sensitivecontentsettings.php b/plugins/SensitiveContent/actions/sensitivecontentsettings.php
index 482a893958..0c7171bc0a 100644
--- a/plugins/SensitiveContent/actions/sensitivecontentsettings.php
+++ b/plugins/SensitiveContent/actions/sensitivecontentsettings.php
@@ -1,51 +1,72 @@
.
-if (!defined('GNUSOCIAL')) { exit(1); }
+defined('GNUSOCIAL') || die();
class SensitiveContentSettingsAction extends SettingsAction
{
- function title()
- {
- return _m('Sensitive content settings');
- }
+ public function title()
+ {
+ return _m('Sensitive content settings');
+ }
- function getInstructions()
- {
- return _m('Set preferences for display of "sensitive" content');
- }
+ public function getInstructions()
+ {
+ return _m('Set preferences for display of "sensitive" content');
+ }
- function showContent()
- {
+ public function showContent()
+ {
+ $user = $this->scoped->getUser();
- $user = $this->scoped->getUser();
+ $this->elementStart(
+ 'form',
+ [
+ 'method' => 'post',
+ 'id' => 'sensitivecontent',
+ 'class' => 'form_settings',
+ 'action' => common_local_url('sensitivecontentsettings'),
+ ]
+ );
- $this->elementStart('form', array('method' => 'post',
- 'id' => 'sensitivecontent',
- 'class' => 'form_settings',
- 'action' => common_local_url('sensitivecontentsettings')));
+ $this->elementStart('fieldset');
+ $this->hidden('token', common_session_token());
+ $this->elementStart('ul', 'form_data');
- $this->elementStart('fieldset');
- $this->hidden('token', common_session_token());
- $this->elementStart('ul', 'form_data');
-
- $this->elementStart('li');
- $this->checkbox('hidesensitive', _('Hide attachments in posts hashtagged #NSFW'),
- ($this->arg('hidesensitive')) ?
- $this->boolean('hidesensitive') : $this->scoped->getPref('MoonMan','hide_sensitive',0));
- $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->checkbox(
+ 'hidesensitive',
+ _('Hide attachments in posts hashtagged #NSFW'),
+ ($this->arg('hidesensitive') ?
+ $this->boolean('hidesensitive') : $this->scoped->getPref('MoonMan', 'hide_sensitive', 0))
+ );
+ $this->elementEnd('li');
- $this->elementEnd('ul');
- $this->submit('save', _m('BUTTON','Save'));
+ $this->elementEnd('ul');
+ $this->submit('save', _m('BUTTON', 'Save'));
- $this->elementEnd('fieldset');
- $this->elementEnd('form');
- }
+ $this->elementEnd('fieldset');
+ $this->elementEnd('form');
+ }
- function doPost()
- {
- $hidesensitive = $this->booleanintstring('hidesensitive');
- $this->scoped->setPref('MoonMan','hide_sensitive', $hidesensitive);
- return _('Settings saved.');
- }
+ public function doPost()
+ {
+ $hidesensitive = $this->boolean('hidesensitive') ? '1' : '0';
+ $this->scoped->setPref('MoonMan', 'hide_sensitive', $hidesensitive);
+ return _('Settings saved.');
+ }
}
diff --git a/plugins/Sitemap/SitemapPlugin.php b/plugins/Sitemap/SitemapPlugin.php
index 1cb70d6509..9b15ec2d6c 100644
--- a/plugins/Sitemap/SitemapPlugin.php
+++ b/plugins/Sitemap/SitemapPlugin.php
@@ -1,48 +1,35 @@
.
+
/**
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2010, StatusNet, Inc.
- *
* Creates a dynamic sitemap for a StatusNet site
*
- * 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 .
- *
- * @category Sample
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @copyright 2010 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- // This check helps protect against security problems;
- // your code file can't be executed directly from the web.
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* Sitemap plugin
*
- * @category Sample
- * @package StatusNet
- * @author Evan Prodromou
* @copyright 2010 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class SitemapPlugin extends Plugin
{
@@ -58,7 +45,7 @@ class SitemapPlugin extends Plugin
*
* @return boolean hook value.
*/
- function onEndRobotsTxt($action)
+ public function onEndRobotsTxt($action)
{
$url = common_local_url('sitemapindex');
@@ -76,25 +63,37 @@ class SitemapPlugin extends Plugin
*/
public function onRouterInitialized(URLMapper $m)
{
- $m->connect('sitemapindex.xml',
- ['action' => 'sitemapindex']);
+ $m->connect(
+ 'sitemapindex.xml',
+ ['action' => 'sitemapindex']
+ );
- $m->connect('notice-sitemap-:year-:month-:day-:index.xml',
- ['action' => 'noticesitemap'],
- ['year' => '[0-9]{4}',
- 'month' => '[01][0-9]',
- 'day' => '[0123][0-9]',
- 'index' => '[1-9][0-9]*']);
+ $m->connect(
+ 'notice-sitemap-:year-:month-:day-:index.xml',
+ ['action' => 'noticesitemap'],
+ [
+ 'year' => '[0-9]{4}',
+ 'month' => '[01][0-9]',
+ 'day' => '[0123][0-9]',
+ 'index' => '[1-9][0-9]*',
+ ]
+ );
- $m->connect('user-sitemap-:year-:month-:day-:index.xml',
- ['action' => 'usersitemap'),
- ['year' => '[0-9]{4}',
- 'month' => '[01][0-9]',
- 'day' => '[0123][0-9]',
- 'index' => '[1-9][0-9]*']);
+ $m->connect(
+ 'user-sitemap-:year-:month-:day-:index.xml',
+ ['action' => 'usersitemap'],
+ [
+ 'year' => '[0-9]{4}',
+ 'month' => '[01][0-9]',
+ 'day' => '[0123][0-9]',
+ 'index' => '[1-9][0-9]*',
+ ]
+ );
- $m->connect('panel/sitemap',
- ['action' => 'sitemapadminpanel']);
+ $m->connect(
+ 'panel/sitemap',
+ ['action' => 'sitemapadminpanel']
+ );
return true;
}
@@ -109,7 +108,7 @@ class SitemapPlugin extends Plugin
*
* @return boolean hook value.
*/
- function onStartShowHeadElements($action)
+ public function onStartShowHeadElements($action)
{
$actionName = $action->trimmed('action');
@@ -119,7 +118,6 @@ class SitemapPlugin extends Plugin
if (($singleUser && $actionName == 'showstream') ||
(!$singleUser && $actionName == 'public')) {
-
$keys = array('yahookey' => 'y_key',
'bingkey' => 'msvalidate.01'); // XXX: is this the same for all sites?
@@ -146,7 +144,7 @@ class SitemapPlugin extends Plugin
*
* @return boolean hook value; true means continue processing, false means stop.
*/
- function onCheckSchema()
+ public function onCheckSchema()
{
$schema = Schema::get();
@@ -155,13 +153,19 @@ class SitemapPlugin extends Plugin
return true;
}
- function onEndAdminPanelNav($menu) {
+ public function onEndAdminPanelNav($menu)
+ {
if (AdminPanelAction::canAdmin('sitemap')) {
// TRANS: Menu item title/tooltip
$menu_title = _m('Sitemap configuration');
// TRANS: Menu item for site administration
- $menu->out->menuItem(common_local_url('sitemapadminpanel'), _m('MENU','Sitemap'),
- $menu_title, $action_name == 'sitemapadminpanel', 'nav_sitemap_admin_panel');
+ $menu->out->menuItem(
+ common_local_url('sitemapadminpanel'),
+ _m('MENU', 'Sitemap'),
+ $menu_title,
+ ($action_name === 'sitemapadminpanel'),
+ 'nav_sitemap_admin_panel'
+ );
}
return true;
}
diff --git a/plugins/Sitemap/classes/Sitemap_notice_count.php b/plugins/Sitemap/classes/Sitemap_notice_count.php
index 9e523dfbc7..9cc5faeb3e 100644
--- a/plugins/Sitemap/classes/Sitemap_notice_count.php
+++ b/plugins/Sitemap/classes/Sitemap_notice_count.php
@@ -1,35 +1,30 @@
.
+
/**
* Data class for counting notice postings by date
*
- * PHP version 5
- *
- * @category Data
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
- *
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2010, StatusNet, Inc.
- *
- * 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 .
+ * @category Data
+ * @package GNUsocial
+ * @author Evan Prodromou
+ * @copyright 2010, StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
@@ -43,11 +38,8 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
* of notices posted on that day. Since, after the end of the day,
* this number doesn't change, it's a good candidate for persistent caching.
*
- * @category Data
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @copyright 2010, StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
* @see DB_DataObject
*/
@@ -73,7 +65,7 @@ class Sitemap_notice_count extends Managed_DataObject
);
}
- static function getAll()
+ public static function getAll()
{
$noticeCounts = self::cacheGet('sitemap:notice:counts');
@@ -90,9 +82,9 @@ class Sitemap_notice_count extends Managed_DataObject
if (!$n) { // No counts saved yet
$noticeCounts = self::initializeCounts();
- } else if ($snc->notice_date < $today) { // There are counts but not up to today
+ } elseif ($snc->notice_date < $today) { // There are counts but not up to today
$noticeCounts = self::fillInCounts($snc->notice_date);
- } else if ($snc->notice_date == $today) { // Refresh today's
+ } elseif ($snc->notice_date === $today) { // Refresh today's
$noticeCounts[$today] = self::updateToday();
}
@@ -110,7 +102,7 @@ class Sitemap_notice_count extends Managed_DataObject
return $noticeCounts;
}
- static function initializeCounts()
+ public static function initializeCounts()
{
$firstDate = self::getFirstDate(); // awww
$today = self::today();
@@ -126,7 +118,7 @@ class Sitemap_notice_count extends Managed_DataObject
return $counts;
}
- static function fillInCounts($lastDate)
+ public static function fillInCounts($lastDate)
{
$today = self::today();
@@ -145,7 +137,7 @@ class Sitemap_notice_count extends Managed_DataObject
return $counts;
}
- static function updateToday()
+ public static function updateToday()
{
$today = self::today();
@@ -155,17 +147,20 @@ class Sitemap_notice_count extends Managed_DataObject
return $n;
}
- static function getCount($d)
+ public static function getCount($d)
{
$notice = new Notice();
- $notice->whereAdd('created BETWEEN "'.$d.' 00:00:00" AND "'.self::incrementDay($d).' 00:00:00"');
+ $notice->whereAdd(
+ "created BETWEEN TIMESTAMP '" . $d . " 00:00:00' AND " .
+ "TIMESTAMP '" . self::incrementDay($d) . " 00:00:00'"
+ );
$notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
$n = $notice->count();
return $n;
}
- static function insertCount($d, $n)
+ public static function insertCount($d, $n)
{
$snc = new Sitemap_notice_count();
@@ -180,7 +175,7 @@ class Sitemap_notice_count extends Managed_DataObject
}
}
- static function updateCount($d, $n)
+ public static function updateCount($d, $n)
{
$snc = Sitemap_notice_count::getKV('notice_date', DB_DataObject_Cast::date($d));
@@ -202,23 +197,23 @@ class Sitemap_notice_count extends Managed_DataObject
}
}
- static function incrementDay($d)
+ public static function incrementDay($d)
{
$dt = self::dateStrToInt($d);
return self::dateIntToStr($dt + 24 * 60 * 60);
}
- static function dateStrToInt($d)
+ public static function dateStrToInt($d)
{
return strtotime($d.' 00:00:00');
}
- static function dateIntToStr($dt)
+ public static function dateIntToStr($dt)
{
return date('Y-m-d', $dt);
}
- static function getFirstDate()
+ public static function getFirstDate()
{
$n = new Notice();
@@ -233,7 +228,7 @@ class Sitemap_notice_count extends Managed_DataObject
}
}
- static function today()
+ public static function today()
{
return self::dateIntToStr(time());
}
diff --git a/plugins/Sitemap/classes/Sitemap_user_count.php b/plugins/Sitemap/classes/Sitemap_user_count.php
index 865cf246e7..7e22ef15ac 100644
--- a/plugins/Sitemap/classes/Sitemap_user_count.php
+++ b/plugins/Sitemap/classes/Sitemap_user_count.php
@@ -1,35 +1,30 @@
.
+
/**
* Data class for counting user registrations by date
*
- * PHP version 5
- *
- * @category Data
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
- *
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2010, StatusNet, Inc.
- *
- * 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 .
+ * @category Data
+ * @package GNUsocial
+ * @author Evan Prodromou
+ * @copyright 2010, StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
@@ -39,11 +34,8 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
* We make a separate sitemap for each user registered by date.
* To save ourselves some processing effort, we cache this data
*
- * @category Action
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @copyright 2010, StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
* @see DB_DataObject
*/
@@ -69,12 +61,11 @@ class Sitemap_user_count extends Managed_DataObject
);
}
- static function getAll()
+ public static function getAll()
{
$userCounts = self::cacheGet('sitemap:user:counts');
if ($userCounts === false) {
-
$suc = new Sitemap_user_count();
$suc->orderBy('registration_date DESC');
@@ -87,9 +78,9 @@ class Sitemap_user_count extends Managed_DataObject
if (!$n) { // No counts saved yet
$userCounts = self::initializeCounts();
- } else if ($suc->registration_date < $today) { // There are counts but not up to today
+ } elseif ($suc->registration_date < $today) { // There are counts but not up to today
$userCounts = self::fillInCounts($suc->registration_date);
- } else if ($suc->registration_date == $today) { // Refresh today's
+ } elseif ($suc->registration_date === $today) { // Refresh today's
$userCounts[$today] = self::updateToday();
}
@@ -107,7 +98,7 @@ class Sitemap_user_count extends Managed_DataObject
return $userCounts;
}
- static function initializeCounts()
+ public static function initializeCounts()
{
$firstDate = self::getFirstDate(); // awww
$today = self::today();
@@ -123,7 +114,7 @@ class Sitemap_user_count extends Managed_DataObject
return $counts;
}
- static function fillInCounts($lastDate)
+ public static function fillInCounts($lastDate)
{
$today = self::today();
@@ -142,7 +133,7 @@ class Sitemap_user_count extends Managed_DataObject
return $counts;
}
- static function updateToday()
+ public static function updateToday()
{
$today = self::today();
@@ -152,16 +143,19 @@ class Sitemap_user_count extends Managed_DataObject
return $n;
}
- static function getCount($d)
+ public static function getCount($d)
{
$user = new User();
- $user->whereAdd('created BETWEEN "'.$d.' 00:00:00" AND "'.self::incrementDay($d).' 00:00:00"');
+ $user->whereAdd(
+ "created BETWEEN TIMESTAMP '" . $d . " 00:00:00' AND " .
+ "TIMESTAMP '" . self::incrementDay($d) . " 00:00:00'"
+ );
$n = $user->count();
return $n;
}
- static function insertCount($d, $n)
+ public static function insertCount($d, $n)
{
$suc = new Sitemap_user_count();
@@ -175,7 +169,7 @@ class Sitemap_user_count extends Managed_DataObject
}
}
- static function updateCount($d, $n)
+ public static function updateCount($d, $n)
{
$suc = Sitemap_user_count::getKV('registration_date', DB_DataObject_Cast::date($d));
@@ -196,23 +190,23 @@ class Sitemap_user_count extends Managed_DataObject
}
}
- static function incrementDay($d)
+ public static function incrementDay($d)
{
$dt = self::dateStrToInt($d);
return self::dateIntToStr($dt + 24 * 60 * 60);
}
- static function dateStrToInt($d)
+ public static function dateStrToInt($d)
{
return strtotime($d.' 00:00:00');
}
- static function dateIntToStr($dt)
+ public static function dateIntToStr($dt)
{
return date('Y-m-d', $dt);
}
- static function getFirstDate()
+ public static function getFirstDate()
{
$u = new User();
$u->selectAdd();
@@ -225,7 +219,7 @@ class Sitemap_user_count extends Managed_DataObject
}
}
- static function today()
+ public static function today()
{
return self::dateIntToStr(time());
}
diff --git a/plugins/SlicedFavorites/actions/favoritedslice.php b/plugins/SlicedFavorites/actions/favoritedslice.php
index 31e93cd396..3e8339a313 100644
--- a/plugins/SlicedFavorites/actions/favoritedslice.php
+++ b/plugins/SlicedFavorites/actions/favoritedslice.php
@@ -1,40 +1,36 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
* List of popular notices
*
- * PHP version 5
- *
- * LICENCE: 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 .
- *
* @category Public
- * @package StatusNet
+ * @package GNUsocial
* @author Zach Copley
* @author Evan Prodromou
* @copyright 2008-2009 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
class FavoritedSliceAction extends FavoritedAction
{
- private $includeUsers = array(), $excludeUsers = array();
+ private $includeUsers = [];
+ private $excludeUsers = [];
/**
* Take arguments for running
@@ -45,7 +41,7 @@ class FavoritedSliceAction extends FavoritedAction
*
* @todo move queries from showContent() to here
*/
- function prepare(array $args = array())
+ public function prepare(array $args = [])
{
parent::prepare($args);
@@ -72,7 +68,7 @@ class FavoritedSliceAction extends FavoritedAction
*
* @return void
*/
- function showContent()
+ public function showContent()
{
$slice = $this->sliceWhereClause();
if (!$slice) {
@@ -80,28 +76,21 @@ class FavoritedSliceAction extends FavoritedAction
}
$weightexpr = common_sql_weight('fave.modified', common_config('popular', 'dropoff'));
- $cutoff = sprintf("fave.modified > '%s'",
- common_sql_date(time() - common_config('popular', 'cutoff')));
-
- $qry = 'SELECT notice.*, '.
- $weightexpr . ' as weight ' .
- 'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
- "WHERE $cutoff AND $slice " .
- 'GROUP BY id,profile_id,uri,content,rendered,url,created,notice.modified,reply_to,is_local,source,notice.conversation ' .
- 'ORDER BY weight DESC';
+ $cutoff = sprintf(
+ "fave.modified > TIMESTAMP '%s'",
+ common_sql_date(time() - common_config('popular', 'cutoff'))
+ );
$offset = ($this->page - 1) * NOTICES_PER_PAGE;
$limit = NOTICES_PER_PAGE + 1;
- if (common_config('db', 'type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
+ $qry = 'SELECT notice.*, ' . $weightexpr . ' AS weight ' .
+ 'FROM notice INNER JOIN fave ON notice.id = fave.notice_id ' .
+ 'WHERE ' . $cutoff . ' AND ' . $slice . ' ' .
+ 'GROUP BY id, profile_id, uri, content, rendered, url, created, notice.modified, reply_to, is_local, source, notice.conversation ' .
+ 'ORDER BY weight DESC LIMIT ' . $limit . ' OFFSET ' . $offset;
- $notice = Memcached_DataObject::cachedQuery('Notice',
- $qry,
- 600);
+ $notice = Memcached_DataObject::cachedQuery('Notice', $qry, 600);
$nl = new NoticeList($notice, $this);
@@ -111,8 +100,12 @@ class FavoritedSliceAction extends FavoritedAction
$this->showEmptyList();
}
- $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
- $this->page, 'favorited');
+ $this->pagination(
+ $this->page > 1,
+ $cnt > NOTICES_PER_PAGE,
+ $this->page,
+ 'favorited'
+ );
}
private function sliceWhereClause()
@@ -122,11 +115,11 @@ class FavoritedSliceAction extends FavoritedAction
if (count($include) == 1) {
return "profile_id = " . intval($include[0]);
- } else if (count($include) > 1) {
+ } elseif (count($include) > 1) {
return "profile_id IN (" . implode(',', $include) . ")";
- } else if (count($exclude) == 1) {
+ } elseif (count($exclude) === 1) {
return "profile_id != " . intval($exclude[0]);
- } else if (count($exclude) > 1) {
+ } elseif (count($exclude) > 1) {
return "profile_id NOT IN (" . implode(',', $exclude) . ")";
} else {
return false;
diff --git a/plugins/SphinxSearch/README b/plugins/SphinxSearch/README
index 873a8cf692..a8e0d20d8b 100644
--- a/plugins/SphinxSearch/README
+++ b/plugins/SphinxSearch/README
@@ -22,7 +22,7 @@ client side, which itself depends on the sphinx development files.
"pecl install sphinx" should take care of that. Add "extension=sphinx.so"
to your php.ini and reload apache to enable it.
-You can update your MySQL or Postgresql databases to drop their fulltext
+You can update your MariaDB or PostgreSQL databases to drop their fulltext
search indexes, since they're now provided by sphinx.
diff --git a/plugins/TagCloud/lib/grouptagcloudsection.php b/plugins/TagCloud/lib/grouptagcloudsection.php
index 5ed14560ce..d83ded10b5 100644
--- a/plugins/TagCloud/lib/grouptagcloudsection.php
+++ b/plugins/TagCloud/lib/grouptagcloudsection.php
@@ -1,35 +1,30 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
* Personal tag cloud section
*
- * PHP version 5
- *
- * LICENCE: 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 .
- *
* @category Widget
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @copyright 2009 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* Group tag cloud section
@@ -42,22 +37,22 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
*/
class GroupTagCloudSection extends TagCloudSection
{
- var $group = null;
+ public $group = null;
- function __construct($out=null, $group=null)
+ public function __construct($out = null, $group = null)
{
parent::__construct($out);
$this->group = $group;
}
- function title()
+ public function title()
{
// TRANS: Title for group tag cloud section.
// TRANS: %s is a group name.
return _('Tags');
}
- function getTags()
+ public function getTags()
{
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
// @fixme should we use the cutoff too? Doesn't help with indexing per-group.
@@ -75,31 +70,22 @@ class GroupTagCloudSection extends TagCloudSection
}
$namestring = implode(',', $quoted);
-
- $qry = 'SELECT notice_tag.tag, '.
- $weightexpr . ' as weight ' .
- 'FROM notice_tag JOIN notice ' .
- 'ON notice_tag.notice_id = notice.id ' .
- 'JOIN group_inbox on group_inbox.notice_id = notice.id ' .
- 'WHERE group_inbox.group_id = %d ' .
- 'AND notice_tag.tag not in (%s) '.
- 'GROUP BY notice_tag.tag ' .
- 'ORDER BY weight DESC ';
-
$limit = TAGS_PER_SECTION;
- $offset = 0;
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
+ $qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' AS weight ' .
+ 'FROM notice_tag INNER JOIN notice ' .
+ 'ON notice_tag.notice_id = notice.id ' .
+ 'INNER JOIN group_inbox ON group_inbox.notice_id = notice.id ' .
+ 'WHERE group_inbox.group_id = %d ' .
+ 'AND notice_tag.tag NOT IN (%s) '.
+ 'GROUP BY notice_tag.tag ' .
+ 'ORDER BY weight DESC LIMIT ' . $limit;
- $tag = Memcached_DataObject::cachedQuery('Notice_tag',
- sprintf($qry,
- $this->group->id,
- $namestring),
- 3600);
+ $tag = Memcached_DataObject::cachedQuery(
+ 'Notice_tag',
+ sprintf($qry, $this->group->id, $namestring),
+ 3600
+ );
return $tag;
}
}
diff --git a/plugins/TagCloud/lib/inboxtagcloudsection.php b/plugins/TagCloud/lib/inboxtagcloudsection.php
index 4268ee4854..ba89bd5b7f 100644
--- a/plugins/TagCloud/lib/inboxtagcloudsection.php
+++ b/plugins/TagCloud/lib/inboxtagcloudsection.php
@@ -1,42 +1,36 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
* Personal tag cloud section
*
- * PHP version 5
- *
- * LICENCE: 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 .
- *
* @category Widget
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @copyright 2009 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('GNUSOCIAL')) { exit(1); }
+defined('GNUSOCIAL') || die();
/**
* Personal tag cloud section
*
- * @category Widget
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @copyright 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class InboxTagCloudSection extends TagCloudSection
{
@@ -44,19 +38,19 @@ class InboxTagCloudSection extends TagCloudSection
protected $target = null;
- function __construct($out=null, Profile $target)
+ public function __construct($out = null, Profile $target)
{
parent::__construct($out);
$this->target = $target;
}
- function title()
+ public function title()
{
// TRANS: Title for inbox tag cloud section.
return _m('TITLE', 'Trends');
}
- function getTags()
+ public function getTags()
{
// FIXME: Get the Profile::current() value some other way
// to avoid confusion between background stuff and session.
@@ -70,22 +64,15 @@ class InboxTagCloudSection extends TagCloudSection
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
+ $limit = TAGS_PER_SECTION;
+
$qry = 'SELECT notice_tag.tag, '.
$weightexpr . ' as weight ' .
'FROM notice_tag JOIN notice ' .
'ON notice_tag.notice_id = notice.id ' .
'WHERE notice.id in (' . implode(',', $ids) . ')'.
'GROUP BY notice_tag.tag ' .
- 'ORDER BY weight DESC ';
-
- $limit = TAGS_PER_SECTION;
- $offset = 0;
-
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
+ 'ORDER BY weight DESC LIMIT ' . $limit;
$t = new Notice_tag();
@@ -101,7 +88,7 @@ class InboxTagCloudSection extends TagCloudSection
return new ArrayWrapper($tag);
}
- function showMore()
+ public function showMore()
{
}
}
diff --git a/plugins/TagCloud/lib/personaltagcloudsection.php b/plugins/TagCloud/lib/personaltagcloudsection.php
index e46aa2d662..f99a7d3825 100644
--- a/plugins/TagCloud/lib/personaltagcloudsection.php
+++ b/plugins/TagCloud/lib/personaltagcloudsection.php
@@ -1,85 +1,72 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
* Personal tag cloud section
*
- * PHP version 5
- *
- * LICENCE: 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 .
- *
* @category Widget
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @copyright 2009 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('GNUSOCIAL')) { exit(1); }
+defined('GNUSOCIAL') || die();
/**
* Personal tag cloud section
*
- * @category Widget
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @copyright 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class PersonalTagCloudSection extends TagCloudSection
{
protected $profile = null;
- function __construct(HTMLOutputter $out, Profile $profile)
+ public function __construct(HTMLOutputter $out, Profile $profile)
{
parent::__construct($out);
$this->profile = $profile;
}
- function title()
+ public function title()
{
// TRANS: Title for personal tag cloud section.
- return _m('TITLE','Tags');
+ return _m('TITLE', 'Tags');
}
- function getTags()
+ public function getTags()
{
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
- $qry = 'SELECT notice_tag.tag, '.
- $weightexpr . ' as weight ' .
- 'FROM notice_tag JOIN notice ' .
- 'ON notice_tag.notice_id = notice.id ' .
- 'WHERE notice.profile_id = %d ' .
- 'GROUP BY notice_tag.tag ' .
- 'ORDER BY weight DESC ';
-
$limit = TAGS_PER_SECTION;
- $offset = 0;
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
+ $qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' AS weight ' .
+ 'FROM notice_tag INNER JOIN notice ' .
+ 'ON notice_tag.notice_id = notice.id ' .
+ 'WHERE notice.profile_id = %d ' .
+ 'GROUP BY notice_tag.tag ' .
+ 'ORDER BY weight DESC LIMIT ' . $limit;
- $tag = Memcached_DataObject::cachedQuery('Notice_tag',
- sprintf($qry,
- $this->profile->getID()),
- 3600);
+ $tag = Memcached_DataObject::cachedQuery(
+ 'Notice_tag',
+ sprintf($qry, $this->profile->getID()),
+ 3600
+ );
return $tag;
}
}
diff --git a/plugins/TagCloud/lib/publictagcloudsection.php b/plugins/TagCloud/lib/publictagcloudsection.php
index bf88091a90..d7fd597baa 100644
--- a/plugins/TagCloud/lib/publictagcloudsection.php
+++ b/plugins/TagCloud/lib/publictagcloudsection.php
@@ -1,59 +1,51 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
* Public tag cloud section
*
- * PHP version 5
- *
- * LICENCE: 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 .
- *
* @category Widget
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @copyright 2009 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* Public tag cloud section
*
- * @category Widget
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @copyright 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class PublicTagCloudSection extends TagCloudSection
{
- function __construct($out=null)
+ public function __construct($out = null)
{
parent::__construct($out);
}
- function title()
+ public function title()
{
// TRANS: Title for inbox tag cloud section.
return _m('TITLE', 'Trends');
}
- function getTags()
+ public function getTags()
{
$profile = Profile::current();
@@ -66,7 +58,6 @@ class PublicTagCloudSection extends TagCloudSection
$tag = Memcached_DataObject::cacheGet($keypart);
if ($tag === false) {
-
$stream = new PublicNoticeStream($profile);
$ids = $stream->getNoticeIds(0, 500, null, null);
@@ -77,22 +68,14 @@ class PublicTagCloudSection extends TagCloudSection
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
- $qry = 'SELECT notice_tag.tag, '.
- $weightexpr . ' as weight ' .
+ $limit = TAGS_PER_SECTION;
+
+ $qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' AS weight ' .
'FROM notice_tag JOIN notice ' .
'ON notice_tag.notice_id = notice.id ' .
'WHERE notice.id in (' . implode(',', $ids) . ') '.
'GROUP BY notice_tag.tag ' .
- 'ORDER BY weight DESC ';
-
- $limit = TAGS_PER_SECTION;
- $offset = 0;
-
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
+ 'ORDER BY weight DESC LIMIT ' . $limit;
$t = new Notice_tag();
@@ -111,7 +94,7 @@ class PublicTagCloudSection extends TagCloudSection
return new ArrayWrapper($tag);
}
- function showMore()
+ public function showMore()
{
}
}
diff --git a/plugins/TagCloud/lib/subpeopletagcloudsection.php b/plugins/TagCloud/lib/subpeopletagcloudsection.php
index b23a82240d..59ad1949b1 100644
--- a/plugins/TagCloud/lib/subpeopletagcloudsection.php
+++ b/plugins/TagCloud/lib/subpeopletagcloudsection.php
@@ -1,77 +1,64 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
* Personal tag cloud section
*
- * PHP version 5
- *
- * LICENCE: 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 .
- *
* @category Widget
- * @package StatusNet
+ * @package GNUsocial
* @author Evan Prodromou
* @copyright 2009 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
/**
* Personal tag cloud section
*
- * @category Widget
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @copyright 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class SubPeopleTagCloudSection extends TagCloudSection
{
- function getTags()
+ public function getTags()
{
$qry = $this->query();
- $limit = TAGS_PER_SECTION;
- $offset = 0;
+ $qry .= ' LIMIT ' . TAGS_PER_SECTION;
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
-
- $profile_tag = Memcached_DataObject::cachedQuery('Profile_tag',
- sprintf($qry,
- $this->out->user->id));
+ $profile_tag = Memcached_DataObject::cachedQuery(
+ 'Profile_tag',
+ sprintf($qry, $this->out->user->id)
+ );
return $profile_tag;
}
- function tagUrl($tag) {
+ public function tagUrl($tag)
+ {
return common_local_url('peopletag', array('tag' => $tag));
}
- function showTag($tag, $weight, $relative) {
+ public function showTag($tag, $weight, $relative)
+ {
$rel = 'tag-cloud-';
- $rel .= 1+intval(7 * $relative * $weight - 0.01);
+ $rel .= 1 + (int) (7 * $relative * $weight - 0.01);
$this->out->elementStart('li', $rel);
$this->out->element('a', array('href' => $this->tagUrl($tag)), $tag);
$this->out->elementEnd('li');
}
}
-
diff --git a/plugins/TwitterBridge/classes/Twitter_synch_status.php b/plugins/TwitterBridge/classes/Twitter_synch_status.php
index 28f60b9b3e..af871e0f02 100644
--- a/plugins/TwitterBridge/classes/Twitter_synch_status.php
+++ b/plugins/TwitterBridge/classes/Twitter_synch_status.php
@@ -1,35 +1,30 @@
.
+
/**
* Store last-touched ID for various timelines
*
- * PHP version 5
- *
- * @category Data
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
- *
- * StatusNet - the distributed open-source microblogging tool
- * Copyright (C) 2010, StatusNet, Inc.
- *
- * 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 .
+ * @category Data
+ * @package GNUsocial
+ * @author Evan Prodromou
+ * @copyright 2010 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
@@ -40,13 +35,11 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
* So, we store the last ID we see from a timeline, and store it. Next time
* around, we use that ID in the since_id parameter.
*
- * @category Action
- * @package StatusNet
- * @author Evan Prodromou
- * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
- * @link http://status.net/
+ * @category Action
+ * @copyright 2010 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*
- * @see DB_DataObject
+ * @see DB_DataObject
*/
class Twitter_synch_status extends Managed_DataObject
{
@@ -62,7 +55,7 @@ class Twitter_synch_status extends Managed_DataObject
return array(
'fields' => array(
'foreign_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'Foreign message ID'),
- 'timeline' => array('type' => 'varchar', 'length' => 191, 'description' => 'timeline name'),
+ 'timeline' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'timeline name'),
'last_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'last id fetched'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
@@ -71,7 +64,7 @@ class Twitter_synch_status extends Managed_DataObject
);
}
- static function getLastId($foreign_id, $timeline)
+ public static function getLastId($foreign_id, $timeline)
{
$tss = self::pkeyGet(array('foreign_id' => $foreign_id,
'timeline' => $timeline));
@@ -83,7 +76,7 @@ class Twitter_synch_status extends Managed_DataObject
}
}
- static function setLastId($foreign_id, $timeline, $last_id)
+ public static function setLastId($foreign_id, $timeline, $last_id)
{
$tss = self::pkeyGet(array('foreign_id' => $foreign_id,
'timeline' => $timeline));
diff --git a/plugins/TwitterBridge/lib/twitterimport.php b/plugins/TwitterBridge/lib/twitterimport.php
index cdbe4a3a69..57ed90fc38 100644
--- a/plugins/TwitterBridge/lib/twitterimport.php
+++ b/plugins/TwitterBridge/lib/twitterimport.php
@@ -1,35 +1,30 @@
.
+
/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * PHP version 5
- *
- * LICENCE: 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 .
- *
* @category Plugin
- * @package StatusNet
+ * @package GNUsocial
* @author Zach Copley
* @author Julien C
* @author Brion Vibber
* @copyright 2009-2010 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+defined('GNUSOCIAL') || die();
require_once dirname(__DIR__) . '/twitter.php';
@@ -38,14 +33,8 @@ require_once dirname(__DIR__) . '/twitter.php';
* Is used by both the polling twitterstatusfetcher.php daemon, and the
* in-progress streaming import.
*
- * @category Plugin
- * @package StatusNet
- * @author Zach Copley
- * @author Julien C
- * @author Brion Vibber
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
- * @link http://twitter.com/
+ * @copyright 2009-2010 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class TwitterImport
{
@@ -74,12 +63,12 @@ class TwitterImport
return $notice;
}
- function name()
+ public function name()
{
return get_class($this);
}
- function saveStatus($status)
+ public function saveStatus($status)
{
$profile = $this->ensureProfile($status->user);
@@ -103,7 +92,7 @@ class TwitterImport
}
$dupe = Notice::getKV('uri', $statusUri);
- if($dupe instanceof Notice) {
+ if ($dupe instanceof Notice) {
// Add it to our record
Notice_to_status::saveNew($dupe->id, $statusId);
common_log(
@@ -123,24 +112,29 @@ class TwitterImport
$author = $original->getProfile();
// TRANS: Message used to repeat a notice. RT is the abbreviation of 'retweet'.
// TRANS: %1$s is the repeated user's name, %2$s is the repeated notice.
- $content = sprintf(_m('RT @%1$s %2$s'),
- $author->nickname,
- $original->content);
+ $content = sprintf(
+ _m('RT @%1$s %2$s'),
+ $author->nickname,
+ $original->content
+ );
if (Notice::contentTooLong($content)) {
$contentlimit = Notice::maxContent();
$content = mb_substr($content, 0, $contentlimit - 4) . ' ...';
}
- $repeat = Notice::saveNew($profile->id,
- $content,
- 'twitter',
- array('repeat_of' => $original->id,
- 'uri' => $statusUri,
- 'is_local' => Notice::GATEWAY,
- 'object_type' => ActivityObject::NOTE,
- 'verb' => ActivityVerb::POST
- ));
+ $repeat = Notice::saveNew(
+ $profile->id,
+ $content,
+ 'twitter',
+ [
+ 'repeat_of' => $original->id,
+ 'uri' => $statusUri,
+ 'is_local' => Notice::GATEWAY,
+ 'object_type' => ActivityObject::NOTE,
+ 'verb' => ActivityVerb::POST,
+ ]
+ );
common_log(LOG_INFO, "Saved {$repeat->id} as a repeat of {$original->id}");
Notice_to_status::saveNew($repeat->id, $statusId);
return $repeat;
@@ -183,11 +177,10 @@ class TwitterImport
$notice->is_local = Notice::GATEWAY;
- $notice->content = html_entity_decode($this->linkify($status, FALSE), ENT_QUOTES, 'UTF-8');
- $notice->rendered = $this->linkify($status, TRUE);
+ $notice->content = html_entity_decode($this->linkify($status, false), ENT_QUOTES, 'UTF-8');
+ $notice->rendered = $this->linkify($status, true);
if (Event::handle('StartNoticeSave', array(&$notice))) {
-
if (empty($notice->conversation)) {
$conv = Conversation::create();
common_log(LOG_INFO, "No known conversation for status {$statusId} so a new one ({$conv->getID()}) was created.");
@@ -221,7 +214,7 @@ class TwitterImport
*
* @return string URI
*/
- function makeStatusURI($username, $id)
+ public function makeStatusURI($username, $id)
{
return 'https://twitter.com/'
. $username
@@ -283,7 +276,7 @@ class TwitterImport
if (empty($id)) {
throw new Exception('Failed insert');
}
- } catch(Exception $e) {
+ } catch (Exception $e) {
common_log(LOG_WARNING, __METHOD__ . " Couldn't insert profile: " . $e->getMessage());
common_log_db_error($profile, 'INSERT', __FILE__);
$profile->query("ROLLBACK");
@@ -314,8 +307,13 @@ class TwitterImport
if ($avatar->filename === $filename) {
return null;
}
- common_debug(__METHOD__ . " - Updating profile avatar (profile_id={$profile->id}) " .
- "from {$avatar->filename} to {$filename}");
+ common_debug(sprintf(
+ '%s - Updating profile avatar (profile_id=%d) from %s to %s',
+ __METHOD__,
+ $profile->id,
+ $avatar->filename,
+ $filename
+ ));
// else we continue with creating a new avatar
} catch (NoAvatarException $e) {
// Avatar was not found. We can catch NoAvatarException or FileNotFoundException
@@ -367,7 +365,7 @@ class TwitterImport
$avatar = new Avatar();
$avatar->profile_id = $profile->id;
- $avatar->original = 1; // this is an original/"uploaded" avatar
+ $avatar->original = true; // this is an original/"uploaded" avatar
$avatar->mediatype = $mediatype;
$avatar->filename = $filename;
$avatar->width = $this->avatarsize;
@@ -416,7 +414,7 @@ class TwitterImport
const HASHTAG = 2;
const MENTION = 3;
- function linkify($status, $html = FALSE)
+ public function linkify($status, $html = false)
{
$text = $status->text;
@@ -424,10 +422,20 @@ class TwitterImport
$statusId = twitter_id($status);
common_log(LOG_WARNING, "No entities data for {$statusId}; trying to fake up links ourselves.");
$text = common_replace_urls_callback($text, 'common_linkify');
- $text = preg_replace_callback('/(^|\"\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/',
- function ($m) { return $m[1].'#'.TwitterStatusFetcher::tagLink($m[2]); }, $text);
- $text = preg_replace_callback('/(^|\s+)@([a-z0-9A-Z_]{1,64})/',
- function ($m) { return $m[1].'@'.TwitterStatusFetcher::atLink($m[2]); }, $text);
+ $text = preg_replace_callback(
+ '/(^|\"\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/',
+ function ($m) {
+ return $m[1] . '#'.TwitterStatusFetcher::tagLink($m[2]);
+ },
+ $text
+ );
+ $text = preg_replace_callback(
+ '/(^|\s+)@([a-z0-9A-Z_]{1,64})/',
+ function ($m) {
+ return $m[1] . '@'.TwitterStatusFetcher::atLink($m[2]);
+ },
+ $text
+ );
return $text;
}
@@ -472,21 +480,21 @@ class TwitterImport
$cursor = $start;
}
$orig = $this->twitEscape(mb_substr($text, $start, $end - $start));
- switch($type) {
+ switch ($type) {
case self::URL:
$linkText = $this->makeUrlLink($object, $orig, $html);
break;
case self::HASHTAG:
if ($html) {
$linkText = $this->makeHashtagLink($object, $orig);
- }else{
+ } else {
$linkText = $orig;
}
break;
case self::MENTION:
if ($html) {
$linkText = $this->makeMentionLink($object, $orig);
- }else{
+ } else {
$linkText = $orig;
}
break;
@@ -503,7 +511,7 @@ class TwitterImport
return $result;
}
- function twitEscape($str)
+ public function twitEscape($str)
{
// Twitter seems to preemptive turn < and > into < and >
// but doesn't for &, so while you may have some magic protection
@@ -516,31 +524,31 @@ class TwitterImport
return htmlspecialchars(html_entity_decode($str, ENT_COMPAT, 'UTF-8'));
}
- function makeUrlLink($object, $orig, $html)
+ public function makeUrlLink($object, $orig, $html)
{
if ($html) {
return ''.htmlspecialchars($object->display_url).'';
- }else{
+ } else {
return htmlspecialchars($object->expanded_url);
}
}
- function makeHashtagLink($object, $orig)
+ public function makeHashtagLink($object, $orig)
{
return "#" . self::tagLink($object->text, substr($orig, 1));
}
- function makeMentionLink($object, $orig)
+ public function makeMentionLink($object, $orig)
{
return "@".self::atLink($object->screen_name, $object->name, substr($orig, 1));
}
- static function tagLink($tag, $orig)
+ public static function tagLink($tag, $orig)
{
return "{$orig}";
}
- static function atLink($screenName, $fullName, $orig)
+ public static function atLink($screenName, $fullName, $orig)
{
if (!empty($fullName)) {
return "{$orig}";
@@ -549,7 +557,7 @@ class TwitterImport
}
}
- function saveStatusMentions($notice, $status)
+ public function saveStatusMentions($notice, $status)
{
$mentions = array();
@@ -582,7 +590,7 @@ class TwitterImport
* @param Notice $notice
* @param object $status
*/
- function saveStatusAttachments(Notice $notice, $status)
+ public function saveStatusAttachments(Notice $notice, $status)
{
if (common_config('attachments', 'process_links')) {
if (!empty($status->entities) && !empty($status->entities->urls)) {
diff --git a/plugins/TwitterBridge/scripts/initialize_notice_to_status.php b/plugins/TwitterBridge/scripts/initialize_notice_to_status.php
index f4a60c479d..14e56a1191 100755
--- a/plugins/TwitterBridge/scripts/initialize_notice_to_status.php
+++ b/plugins/TwitterBridge/scripts/initialize_notice_to_status.php
@@ -1,21 +1,25 @@
#!/usr/bin/env php
.
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social 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.
+//
+// GNU social 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 GNU social. If not, see .
+
+/**
+ * @package TwitterBridge
+ * @author Evan Prodromou
+ * @copyright 2010, StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
@@ -37,11 +41,13 @@ require_once INSTALLDIR.'/scripts/commandline.inc';
$n = new Notice();
-$n->query('SELECT notice.id, notice.uri ' .
- 'FROM notice LEFT JOIN notice_to_status ' .
- 'ON notice.id = notice_to_status.notice_id ' .
- 'WHERE notice.source = "twitter"' .
- 'AND notice_to_status.status_id IS NULL');
+$n->query(
+ 'SELECT notice.id, notice.uri ' .
+ 'FROM notice LEFT JOIN notice_to_status ' .
+ 'ON notice.id = notice_to_status.notice_id ' .
+ "WHERE notice.source = 'twitter'" .
+ 'AND notice_to_status.status_id IS NULL'
+);
while ($n->fetch()) {
if (preg_match('/^http://twitter.com(/#!)?/[\w_.]+/status/(\d+)$/', $n->uri, $match)) {
diff --git a/scripts/allsites.php b/scripts/allsites.php
index c23685c721..b65b57597c 100755
--- a/scripts/allsites.php
+++ b/scripts/allsites.php
@@ -1,21 +1,25 @@
#!/usr/bin/env php
.
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social 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.
+//
+// GNU social 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 GNU social. If not, see .
+
+/**
+ * @package GNUsocial
+ * @author Evan Prodromou
+ * @copyright 2009, StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
// Abort if called from a web server
@@ -37,8 +41,8 @@ ENDOFHELP;
require_once INSTALLDIR.'/scripts/commandline.inc';
-function print_all_sites() {
-
+function print_all_sites()
+{
$sn = new Status_network();
if ($sn->find()) {
@@ -49,14 +53,16 @@ function print_all_sites() {
return;
}
-function print_tagged_sites($tag) {
-
+function print_tagged_sites($tag)
+{
$sn = new Status_network();
- $sn->query('select status_network.nickname '.
- 'from status_network join status_network_tag '.
- 'on status_network.site_id = status_network_tag.site_id '.
- 'where status_network_tag.tag = "' . $tag . '"');
+ $sn->query(
+ 'SELECT status_network.nickname '.
+ 'FROM status_network INNER JOIN status_network_tag '.
+ 'ON status_network.site_id = status_network_tag.site_id '.
+ "WHERE status_network_tag.tag = '" . $sn->escape($tag) . "'"
+ );
while ($sn->fetch()) {
print "$sn->nickname\n";
@@ -65,16 +71,18 @@ function print_tagged_sites($tag) {
return;
}
-function print_untagged_sites($tag) {
-
+function print_untagged_sites($tag)
+{
$sn = new Status_network();
- $sn->query('select status_network.nickname '.
- 'from status_network '.
- 'where not exists '.
- '(select tag from status_network_tag '.
- 'where site_id = status_network.site_id '.
- 'and tag = "'.$tag.'")');
+ $sn->query(
+ 'SELECT status_network.nickname '.
+ 'FROM status_network '.
+ 'WHERE NOT EXISTS '.
+ '(SELECT tag FROM status_network_tag '.
+ 'WHERE site_id = status_network.site_id '.
+ "AND tag = '" . $sn->escape($tag) . "')"
+ );
while ($sn->fetch()) {
print "$sn->nickname\n";
@@ -86,7 +94,7 @@ function print_untagged_sites($tag) {
if (have_option('t', 'tagged')) {
$tag = get_option_value('t', 'tagged');
print_tagged_sites($tag);
-} else if (have_option('w', 'not-tagged')) {
+} elseif (have_option('w', 'not-tagged')) {
$tag = get_option_value('w', 'not-tagged');
print_untagged_sites($tag);
} else {
diff --git a/scripts/makegroupadmin.php b/scripts/makegroupadmin.php
index 58277c9ea2..4e2eb4ed32 100755
--- a/scripts/makegroupadmin.php
+++ b/scripts/makegroupadmin.php
@@ -1,21 +1,25 @@
#!/usr/bin/env php
.
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social 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.
+//
+// GNU social 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 GNU social. If not, see .
+
+/**
+ * @package GNUsocial
+ * @author Evan Prodromou
+ * @copyright 2008, 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
define('INSTALLDIR', dirname(__DIR__));
@@ -44,7 +48,6 @@ if (empty($nickname) || empty($groupname)) {
}
try {
-
$user = User::getKV('nickname', $nickname);
if (empty($user)) {
@@ -78,12 +81,11 @@ try {
$orig = clone($member);
- $member->is_admin = 1;
+ $member->is_admin = true;
if (!$member->update($orig)) {
throw new Exception("Can't make '$nickname' admin of '$groupname'.");
}
-
} catch (Exception $e) {
print $e->getMessage() . "\n";
exit(1);
diff --git a/scripts/remove_duplicate_file_urls.php b/scripts/remove_duplicate_file_urls.php
index 9754820d98..5a36bc9d68 100755
--- a/scripts/remove_duplicate_file_urls.php
+++ b/scripts/remove_duplicate_file_urls.php
@@ -1,21 +1,23 @@
#!/usr/bin/env php
.
+// This file is part of GNU social - https://www.gnu.org/software/social
+//
+// GNU social 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.
+//
+// GNU social 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 GNU social. If not, see .
+
+/**
+ * @copyright 2008, 2009 StatusNet, Inc.
+ * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
define('INSTALLDIR', dirname(__DIR__));
@@ -44,7 +46,7 @@ if (!have_option('y', 'yes')) {
}
$file = new File();
-$file->query('SELECT id, url, COUNT(*) AS c FROM file GROUP BY url HAVING c > 1');
+$file->query('SELECT url FROM file GROUP BY url HAVING COUNT(*) > 1');
print "\nFound {$file->N} URLs with duplicate entries in file table";
while ($file->fetch()) {
// We've got a URL that is duplicated in the file table
@@ -54,7 +56,7 @@ while ($file->fetch()) {
print "\nDeleting duplicate entries in file table for URL: {$file->url} [";
// Leave one of the URLs in the database by using ->find(true)
// and only deleting starting with this fetch.
- while($dupfile->fetch()) {
+ while ($dupfile->fetch()) {
print ".";
$dupfile->delete();
}
@@ -65,7 +67,7 @@ while ($file->fetch()) {
}
$file = new File_redirection();
-$file->query('SELECT file_id, url, COUNT(*) AS c FROM file_redirection GROUP BY url HAVING c > 1');
+$file->query('SELECT url FROM file_redirection GROUP BY url HAVING COUNT(*) > 1');
print "\nFound {$file->N} URLs with duplicate entries in file_redirection table";
while ($file->fetch()) {
// We've got a URL that is duplicated in the file_redirection table
@@ -75,7 +77,7 @@ while ($file->fetch()) {
print "\nDeleting duplicate entries in file table for URL: {$file->url} [";
// Leave one of the URLs in the database by using ->find(true)
// and only deleting starting with this fetch.
- while($dupfile->fetch()) {
+ while ($dupfile->fetch()) {
print ".";
$dupfile->delete();
}
diff --git a/scripts/resend_confirm_address.php b/scripts/resend_confirm_address.php
index 0c7b54c11f..449d1b1edf 100755
--- a/scripts/resend_confirm_address.php
+++ b/scripts/resend_confirm_address.php
@@ -1,5 +1,19 @@
#!/usr/bin/env php
.
define('INSTALLDIR', dirname(__DIR__));
define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
@@ -17,7 +31,7 @@ all lingering confirmations.
NOTE: You probably want to do something like this to your database first so
only relatively fresh accounts get resent this:
- DELETE FROM confirm_address WHERE modified < DATE_SUB(NOW(), INTERVAL 1 month);
+ DELETE FROM confirm_address WHERE modified < (CURRENT_TIMESTAMP - INTERVAL '1' MONTH);
Options:
diff --git a/scripts/upgrade.php b/scripts/upgrade.php
index 92e1c87c9d..1178d59769 100755
--- a/scripts/upgrade.php
+++ b/scripts/upgrade.php
@@ -249,7 +249,7 @@ function fixupConversationURIs()
while ($conv->fetch()) {
$uri = common_local_url('conversation', ['id' => $conv->id]);
$sql = sprintf(
- 'UPDATE conversation SET uri="%1$s" WHERE id="%2$d";',
+ 'UPDATE conversation SET uri = \'%1$s\' WHERE id = %2$d;',
$conv->escape($uri),
$conv->id
);
@@ -379,7 +379,7 @@ function initSubscriptionURI()
$sub->decache();
$sub->query(sprintf(
'UPDATE subscription '.
- 'SET uri = "%s" '.
+ "SET uri = '%s' " .
'WHERE subscriber = %d '.
'AND subscribed = %d',
$sub->escape(Subscription::newUri($sub->getSubscriber(), $sub->getSubscribed(), $sub->created)),
@@ -408,7 +408,7 @@ function initGroupMemberURI()
$mem->decache();
$mem->query(sprintf(
'UPDATE group_member '.
- 'SET uri = "%s" '.
+ "SET uri = '%s' " .
'WHERE profile_id = %d ' .
'AND group_id = %d',
Group_member::newUri(Profile::getByID($mem->profile_id), User_group::getByID($mem->group_id), $mem->created),
@@ -443,7 +443,7 @@ function initProfileLists()
$plist->tagger = $ptag->tagger;
$plist->tag = $ptag->tag;
- $plist->private = 0;
+ $plist->private = false;
$plist->created = common_sql_now();
$plist->modified = $plist->created;
$plist->mainpage = common_local_url(
@@ -537,7 +537,7 @@ function deleteLocalFileThumbnailsWithoutFilename()
while ($file->fetch()) {
$thumbs = new File_thumbnail();
$thumbs->file_id = $file->id;
- $thumbs->whereAdd('filename IS NULL OR filename = ""');
+ $thumbs->whereAdd("filename IS NULL OR filename = ''");
// Checking if there were any File_thumbnail entries without filename
if (!$thumbs->find()) {
continue;
@@ -560,7 +560,7 @@ function deleteMissingLocalFileThumbnails()
printfnq("Removing all local File_thumbnail entries without existing files...");
$thumbs = new File_thumbnail();
- $thumbs->whereAdd('filename IS NOT NULL AND filename != ""');
+ $thumbs->whereAdd("filename IS NOT NULL AND filename != ''");
// Checking if there were any File_thumbnail entries without filename
if ($thumbs->find()) {
while ($thumbs->fetch()) {
@@ -583,7 +583,7 @@ function setFilehashOnLocalFiles()
printfnq('Ensuring all local files have the filehash field set...');
$file = new File();
- $file->whereAdd('filename IS NOT NULL AND filename != ""'); // local files
+ $file->whereAdd("filename IS NOT NULL AND filename != ''"); // local files
$file->whereAdd('filehash IS NULL', 'AND'); // without filehash value
if ($file->find()) {
@@ -605,11 +605,27 @@ function fixupFileThumbnailUrlhash()
{
printfnq("Setting urlhash for File_thumbnail entries: ");
+ switch (common_config('db', 'type')) {
+ case 'pgsql':
+ $url_sha256 = 'encode(sha256(CAST("url" AS bytea)), \'hex\')';
+ break;
+ case 'mysql':
+ $url_sha256 = 'sha2(`url`, 256)';
+ break;
+ default:
+ throw new Exception('Unknown DB type selected.');
+ }
+
$thumb = new File_thumbnail();
- $thumb->query('UPDATE '.$thumb->escapedTableName().' SET urlhash=SHA2(url, 256) WHERE'.
- ' url IS NOT NULL AND'. // find all entries with a url value
- ' url != "" AND'. // precaution against non-null empty strings
- ' urlhash IS NULL'); // but don't touch those we've already calculated
+ $thumb->query(sprintf(
+ 'UPDATE %1$s ' .
+ 'SET urlhash = %2$s ' .
+ 'WHERE url IS NOT NULL ' . // find all entries with a url value
+ "AND url <> '' " . // precaution against non-null empty strings
+ 'AND urlhash IS NULL', // but don't touch those we've already calculated
+ $thumb->escapedTableName(),
+ $url_sha256
+ ));
printfnq("DONE.\n");
}