[DATABASE] Various table schema related fixes

This commit is contained in:
Alexei Sorokin 2019-09-11 12:07:54 +03:00
parent 0c936e54ba
commit 95c7344557
21 changed files with 242 additions and 224 deletions

View File

@ -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')),
),
);
}

View File

@ -1,9 +1,26 @@
<?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 <http://www.gnu.org/licenses/>.
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'),
),

View File

@ -1,9 +1,26 @@
<?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 <http://www.gnu.org/licenses/>.
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')),
)
);
}

View File

@ -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')),

View File

@ -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' => [

View File

@ -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'],

View File

@ -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'],

View File

@ -1,31 +1,31 @@
<?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 <http://www.gnu.org/licenses/>.
/**
* 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 <http://www.gnu.org/licenses/>.
*
* @category Data
* @package EmailReminder
* @author Zach Copley <zach@status.net>
* @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(

View File

@ -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')),
);

View File

@ -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')),
);
}

View File

@ -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'),

View File

@ -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_'),

View File

@ -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'),

View File

@ -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'

View File

@ -1,46 +1,38 @@
<?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 <http://www.gnu.org/licenses/>.
/**
* Data class to record responses to polls
*
* PHP version 5
*
* @category PollPlugin
* @package StatusNet
* @author Brion Vibber <brion@status.net>
* @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 <http://www.gnu.org/licenses/>.
* @category PollPlugin
* @package GNUsocial
* @author Brion Vibber <brion@status.net>
* @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 <brion@status.net>
* @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(

View File

@ -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'),
)
);
}

View File

@ -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'),
),
);
}

View File

@ -1,46 +1,38 @@
<?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 <http://www.gnu.org/licenses/>.
/**
* Data class to save users votes for
*
* PHP version 5
*
* @category QnA
* @package StatusNet
* @author Zach Copley <zach@status.net>
* @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 <http://www.gnu.org/licenses/>.
* @category QnA
* @package GNUsocial
* @author Zach Copley <zach@status.net>
* @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 <zach@status.net>
* @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();

View File

@ -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'),

View File

@ -1,55 +1,43 @@
<?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 <http://www.gnu.org/licenses/>.
/**
* 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 <http://www.gnu.org/licenses/>.
*
* @category Plugin
* @package StatusNet
* @package GNUsocial
* @author Craig Andrews <candrews@integralblue.com>
* @author Brion Vibber <brion@status.net>
* @author Evan Prodromou <evan@status.net>
* @author Mikael Nordfeldth <mmn@hethane.se>
* @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 <candrews@integralblue.com>
* @author Brion Vibber <brion@status.net>
* @author Evan Prodromou <evan@status.net>
* @author Mikael Nordfeldth <mmn@hethane.se>
* @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;

View File

@ -1,48 +1,35 @@
<?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 <http://www.gnu.org/licenses/>.
/**
* 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 <http://www.gnu.org/licenses/>.
*
* @category Sample
* @package StatusNet
* @package GNUsocial
* @author Evan Prodromou <evan@status.net>
* @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 <evan@status.net>
* @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;
}