From 95c7344557fc6345302aa676036367d1d1211f5e Mon Sep 17 00:00:00 2001 From: Alexei Sorokin Date: Wed, 11 Sep 2019 12:07:54 +0300 Subject: [PATCH] [DATABASE] Various table schema related fixes --- classes/File_redirection.php | 3 +- classes/Notice_source.php | 23 +++- classes/Oauth_token_association.php | 27 ++++- classes/Profile_list.php | 3 +- .../Activitypub_pending_follow_requests.php | 6 +- .../classes/Activitypub_profile.php | 2 +- .../ActivityPub/classes/Activitypub_rsa.php | 2 +- .../EmailReminder/classes/Email_reminder.php | 54 ++++----- plugins/Event/classes/Happening.php | 6 +- plugins/Event/classes/RSVP.php | 6 +- plugins/ModLog/classes/ModLog.php | 2 +- plugins/OStatus/classes/HubSub.php | 2 +- plugins/OStatus/classes/Ostatus_profile.php | 6 +- plugins/OpenID/classes/User_openid_prefs.php | 4 +- plugins/Poll/classes/Poll_response.php | 58 ++++----- plugins/QnA/classes/QnA_Answer.php | 6 +- plugins/QnA/classes/QnA_Question.php | 2 +- plugins/QnA/classes/QnA_Vote.php | 62 +++++----- plugins/Realtime/classes/Realtime_channel.php | 2 +- .../RequireValidatedEmailPlugin.php | 76 ++++++------ plugins/Sitemap/SitemapPlugin.php | 114 +++++++++--------- 21 files changed, 242 insertions(+), 224 deletions(-) diff --git a/classes/File_redirection.php b/classes/File_redirection.php index e051f372f9..853c341e78 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -19,7 +19,6 @@ defined('GNUSOCIAL') || die(); /** * Table Definition for file_redirection */ - class File_redirection extends Managed_DataObject { ###START_AUTOCODE @@ -51,7 +50,7 @@ class File_redirection extends Managed_DataObject ), 'primary key' => array('urlhash'), 'foreign keys' => array( - 'file_redirection_file_id_fkey' => array('file' => array('file_id' => 'id')), + 'file_redirection_file_id_fkey' => array('file', array('file_id' => 'id')), ), ); } diff --git a/classes/Notice_source.php b/classes/Notice_source.php index 43a8263d85..03f3ca1498 100644 --- a/classes/Notice_source.php +++ b/classes/Notice_source.php @@ -1,9 +1,26 @@ . + +defined('GNUSOCIAL') || die(); + +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; + /** * Table Definition for notice_source */ -require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; - class Notice_source extends Managed_DataObject { ###START_AUTOCODE @@ -26,7 +43,7 @@ class Notice_source extends Managed_DataObject 'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'source code'), 'name' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'name of the source'), 'url' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'url to link to'), - 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'date this record was created'), + 'notice_id' => array('type' => 'int', 'not null' => true, 'default' => 0, 'description' => 'date this record was created'), 'created' => array('type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'), 'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'), ), diff --git a/classes/Oauth_token_association.php b/classes/Oauth_token_association.php index 8c444e3b14..7ad0186614 100644 --- a/classes/Oauth_token_association.php +++ b/classes/Oauth_token_association.php @@ -1,9 +1,26 @@ . + +defined('GNUSOCIAL') || die(); + +require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; + /** * Table Definition for oauth_association */ -require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; - class Oauth_token_association extends Managed_DataObject { ###START_AUTOCODE @@ -19,7 +36,7 @@ class Oauth_token_association extends Managed_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - static function getByUserAndToken($user, $token) + public static function getByUserAndToken($user, $token) { if (empty($user) || empty($token)) { return null; @@ -49,8 +66,8 @@ class Oauth_token_association extends Managed_DataObject ), 'primary key' => array('profile_id', 'application_id', 'token'), 'foreign keys' => array( - 'oauth_token_association_profile_fkey' => array('profile_id', array('profile' => 'id')), - 'oauth_token_association_application_fkey' => array('application_id', array('application' => 'id')), + 'oauth_token_association_profile_fkey' => array('profile', array('profile_id' => 'id')), + 'oauth_token_association_application_fkey' => array('oauth_application', array('application_id' => 'id')), ) ); } diff --git a/classes/Profile_list.php b/classes/Profile_list.php index 04c8848415..f649b80ed1 100644 --- a/classes/Profile_list.php +++ b/classes/Profile_list.php @@ -59,7 +59,8 @@ class Profile_list extends Managed_DataObject ), 'primary key' => array('tagger', 'tag'), 'unique keys' => array( - 'profile_list_id_key' => array('id') + 'profile_list_id_key' => array('id'), + 'profile_list_tag_key' => array('tag'), ), 'foreign keys' => array( 'profile_list_tagger_fkey' => array('profile', array('tagger' => 'id')), diff --git a/plugins/ActivityPub/classes/Activitypub_pending_follow_requests.php b/plugins/ActivityPub/classes/Activitypub_pending_follow_requests.php index 27f8097015..80f3cae151 100644 --- a/plugins/ActivityPub/classes/Activitypub_pending_follow_requests.php +++ b/plugins/ActivityPub/classes/Activitypub_pending_follow_requests.php @@ -51,9 +51,9 @@ class Activitypub_pending_follow_requests extends Managed_DataObject { return [ 'fields' => [ - 'local_profile_id' => ['type' => 'integer', 'not null' => true], - 'remote_profile_id' => ['type' => 'integer', 'not null' => true], - 'relation_id' => ['type' => 'serial', 'not null' => true], + 'local_profile_id' => ['type' => 'int', 'not null' => true], + 'remote_profile_id' => ['type' => 'int', 'not null' => true], + 'relation_id' => ['type' => 'serial', 'not null' => true], ], 'primary key' => ['relation_id'], 'foreign keys' => [ diff --git a/plugins/ActivityPub/classes/Activitypub_profile.php b/plugins/ActivityPub/classes/Activitypub_profile.php index 80c73d8b09..5891b0b4ee 100644 --- a/plugins/ActivityPub/classes/Activitypub_profile.php +++ b/plugins/ActivityPub/classes/Activitypub_profile.php @@ -61,7 +61,7 @@ class Activitypub_profile extends Managed_DataObject return [ 'fields' => [ 'uri' => ['type' => 'text', 'not null' => true], - 'profile_id' => ['type' => 'integer'], + 'profile_id' => ['type' => 'int', 'not null' => true], 'inboxuri' => ['type' => 'text', 'not null' => true], 'sharedInboxuri' => ['type' => 'text'], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], diff --git a/plugins/ActivityPub/classes/Activitypub_rsa.php b/plugins/ActivityPub/classes/Activitypub_rsa.php index 80d638bb94..b93ee23f3f 100644 --- a/plugins/ActivityPub/classes/Activitypub_rsa.php +++ b/plugins/ActivityPub/classes/Activitypub_rsa.php @@ -53,7 +53,7 @@ class Activitypub_rsa extends Managed_DataObject { return [ 'fields' => [ - 'profile_id' => ['type' => 'integer'], + 'profile_id' => ['type' => 'int', 'not null' => true], 'private_key' => ['type' => 'text'], 'public_key' => ['type' => 'text', 'not null' => true], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], diff --git a/plugins/EmailReminder/classes/Email_reminder.php b/plugins/EmailReminder/classes/Email_reminder.php index 7af2cdf5e6..700a3aa20a 100644 --- a/plugins/EmailReminder/classes/Email_reminder.php +++ b/plugins/EmailReminder/classes/Email_reminder.php @@ -1,31 +1,31 @@ . + /** - * StatusNet - the distributed open-source microblogging tool - * Copyright (C) 2011, StatusNet, Inc. - * * Data class for email reminders * - * 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 EmailReminder * @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 later */ +defined('GNUSOCIAL') || die(); + class Email_reminder extends Managed_DataObject { public $__table = 'email_reminder'; @@ -46,8 +46,8 @@ class Email_reminder extends Managed_DataObject * @param int $days Number of days after the code was created * @return boolean true if any Email_reminder records were found */ - static function needsReminder($type, $object, $days = null) { - + public static function needsReminder($type, $object, $days = null) + { $reminder = new Email_reminder(); $reminder->type = $type; $reminder->code = $object->code; @@ -72,8 +72,8 @@ class Email_reminder extends Managed_DataObject * @param int $days Number of days after the code was created * @return int $result row ID of the new reminder record */ - static function recordReminder($type, $object, $days) { - + public static function recordReminder($type, $object, $days) + { $reminder = new Email_reminder(); $reminder->type = $type; $reminder->code = $object->code; @@ -83,9 +83,9 @@ class Email_reminder extends Managed_DataObject if (empty($result)) { common_log_db_error($reminder, 'INSERT', __FILE__); - throw new ServerException( - // TRANS: Server exception thrown when a reminder record could not be inserted into the database. - _m('Database error inserting reminder record.') + throw new ServerException( + // TRANS: Server exception thrown when a reminder record could not be inserted into the database. + _m('Database error inserting reminder record.') ); } @@ -108,13 +108,13 @@ class Email_reminder extends Managed_DataObject ), 'code' => array( 'type' => 'varchar', - 'not null' => 'true', + 'not null' => true, 'length' => 191, 'description' => 'confirmation code' ), 'days' => array( 'type' => 'int', - 'not null' => 'true', + 'not null' => true, 'description' => 'number of days since code creation' ), 'sent' => array( diff --git a/plugins/Event/classes/Happening.php b/plugins/Event/classes/Happening.php index 646a7e6d1e..574efc8260 100644 --- a/plugins/Event/classes/Happening.php +++ b/plugins/Event/classes/Happening.php @@ -94,8 +94,10 @@ class Happening extends Managed_DataObject 'unique keys' => array( 'happening_uri_key' => array('uri'), ), - 'foreign keys' => array('happening_profile_id__key' => array('profile', array('profile_id' => 'id')), - 'happening_uri__key' => array('notice', array('uri' => 'uri'))), + 'foreign keys' => array( + 'happening_profile_id_fkey' => array('profile', array('profile_id' => 'id')), + 'happening_uri_fkey' => array('notice', array('uri' => 'uri')) + ), 'indexes' => array('happening_created_idx' => array('created'), 'happening_start_end_idx' => array('start_time', 'end_time')), ); diff --git a/plugins/Event/classes/RSVP.php b/plugins/Event/classes/RSVP.php index f2ab8f0aa3..aaa850a258 100644 --- a/plugins/Event/classes/RSVP.php +++ b/plugins/Event/classes/RSVP.php @@ -85,8 +85,10 @@ class RSVP extends Managed_DataObject 'rsvp_uri_key' => array('uri'), 'rsvp_profile_event_key' => array('profile_id', 'event_uri'), ), - 'foreign keys' => array('rsvp_event_uri_key' => array('happening', array('event_uri' => 'uri')), - 'rsvp_profile_id__key' => array('profile', array('profile_id' => 'id'))), + 'foreign keys' => array( + 'rsvp_event_uri_fkey' => array('happening', array('event_uri' => 'uri')), + 'rsvp_profile_id_fkey' => array('profile', array('profile_id' => 'id')) + ), 'indexes' => array('rsvp_created_idx' => array('created')), ); } diff --git a/plugins/ModLog/classes/ModLog.php b/plugins/ModLog/classes/ModLog.php index 12af1fa2f2..c315ff8f08 100644 --- a/plugins/ModLog/classes/ModLog.php +++ b/plugins/ModLog/classes/ModLog.php @@ -73,7 +73,7 @@ class ModLog extends Managed_DataObject 'primary key' => array('id'), 'foreign keys' => array( 'mod_log_profile_id_fkey' => array('profile', array('profile_id' => 'id')), - 'mod_log_moderator_id_fkey' => array('user', array('user_id' => 'id')) + 'mod_log_moderator_id_fkey' => array('user', array('moderator_id' => 'id')) ), 'indexes' => array( 'mod_log_profile_id_created_idx' => array('profile_id', 'created'), diff --git a/plugins/OStatus/classes/HubSub.php b/plugins/OStatus/classes/HubSub.php index 28ea1fd9d6..6a62cab7ae 100644 --- a/plugins/OStatus/classes/HubSub.php +++ b/plugins/OStatus/classes/HubSub.php @@ -57,7 +57,7 @@ class HubSub extends Managed_DataObject 'secret' => array('type' => 'text', 'description' => 'HubSub stored secret'), 'sub_start' => array('type' => 'datetime', 'description' => 'subscription start'), 'sub_end' => array('type' => 'datetime', 'description' => 'subscription end'), - 'errors' => array('type' => 'integer', 'not null' => true, 'default' => 0, 'description' => 'Queue handling error count, is reset on success.'), + 'errors' => array('type' => 'int', 'not null' => true, 'default' => 0, 'description' => 'Queue handling error count, is reset on success.'), 'error_start' => array('type' => 'datetime', 'default' => null, 'description' => 'time of first error since latest success, should be null if no errors have been counted'), 'last_error' => array('type' => 'datetime', 'default' => null, 'description' => 'time of last failure, if ever'), 'last_error_msg' => array('type' => 'text', 'default' => null, 'description' => 'Last error _message_'), diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 4b47197a8c..0dcfb3d95b 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -51,9 +51,9 @@ class Ostatus_profile extends Managed_DataObject return array( 'fields' => array( 'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true), - 'profile_id' => array('type' => 'integer'), - 'group_id' => array('type' => 'integer'), - 'peopletag_id' => array('type' => 'integer'), + 'profile_id' => array('type' => 'int'), + 'group_id' => array('type' => 'int'), + 'peopletag_id' => array('type' => 'int'), 'feeduri' => array('type' => 'varchar', 'length' => 191), 'salmonuri' => array('type' => 'varchar', 'length' => 191), 'avatar' => array('type' => 'text'), 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/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/QnA/classes/QnA_Answer.php b/plugins/QnA/classes/QnA_Answer.php index 73a73154fe..a2e1c81f86 100644 --- a/plugins/QnA/classes/QnA_Answer.php +++ b/plugins/QnA/classes/QnA_Answer.php @@ -81,11 +81,11 @@ class QnA_Answer extends Managed_DataObject ), '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'), ) ); } diff --git a/plugins/QnA/classes/QnA_Question.php b/plugins/QnA/classes/QnA_Question.php index d90e3a2c1f..81ea0cdb56 100644 --- a/plugins/QnA/classes/QnA_Question.php +++ b/plugins/QnA/classes/QnA_Question.php @@ -77,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'), ), ); } 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 a4553017b1..e8431d0728 100644 --- a/plugins/Realtime/classes/Realtime_channel.php +++ b/plugins/Realtime/classes/Realtime_channel.php @@ -79,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'), 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/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; }