[DATABASE] Various table schema related fixes

This commit is contained in:
Alexei Sorokin 2019-09-11 12:07:54 +03:00 committed by Diogo Peralta Cordeiro
parent bc97f34f5a
commit 2b0251213f
21 changed files with 242 additions and 224 deletions

View File

@ -19,7 +19,6 @@ defined('GNUSOCIAL') || die();
/** /**
* Table Definition for file_redirection * Table Definition for file_redirection
*/ */
class File_redirection extends Managed_DataObject class File_redirection extends Managed_DataObject
{ {
###START_AUTOCODE ###START_AUTOCODE
@ -51,7 +50,7 @@ class File_redirection extends Managed_DataObject
), ),
'primary key' => array('urlhash'), 'primary key' => array('urlhash'),
'foreign keys' => array( '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 <?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 * Table Definition for notice_source
*/ */
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
class Notice_source extends Managed_DataObject class Notice_source extends Managed_DataObject
{ {
###START_AUTOCODE ###START_AUTOCODE
@ -26,7 +43,7 @@ class Notice_source extends Managed_DataObject
'code' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'source code'), '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'), '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'), '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'), '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'), 'modified' => array('type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'),
), ),

View File

@ -1,9 +1,26 @@
<?php <?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 * Table Definition for oauth_association
*/ */
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
class Oauth_token_association extends Managed_DataObject class Oauth_token_association extends Managed_DataObject
{ {
###START_AUTOCODE ###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 */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
static function getByUserAndToken($user, $token) public static function getByUserAndToken($user, $token)
{ {
if (empty($user) || empty($token)) { if (empty($user) || empty($token)) {
return null; return null;
@ -49,8 +66,8 @@ class Oauth_token_association extends Managed_DataObject
), ),
'primary key' => array('profile_id', 'application_id', 'token'), 'primary key' => array('profile_id', 'application_id', 'token'),
'foreign keys' => array( 'foreign keys' => array(
'oauth_token_association_profile_fkey' => array('profile_id', array('profile' => 'id')), 'oauth_token_association_profile_fkey' => array('profile', array('profile_id' => 'id')),
'oauth_token_association_application_fkey' => array('application_id', array('application' => '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'), 'primary key' => array('tagger', 'tag'),
'unique keys' => array( 'unique keys' => array(
'profile_list_id_key' => array('id') 'profile_list_id_key' => array('id'),
'profile_list_tag_key' => array('tag'),
), ),
'foreign keys' => array( 'foreign keys' => array(
'profile_list_tagger_fkey' => array('profile', array('tagger' => 'id')), 'profile_list_tagger_fkey' => array('profile', array('tagger' => 'id')),

View File

@ -51,9 +51,9 @@ class Activitypub_pending_follow_requests extends Managed_DataObject
{ {
return [ return [
'fields' => [ 'fields' => [
'local_profile_id' => ['type' => 'integer', 'not null' => true], 'local_profile_id' => ['type' => 'int', 'not null' => true],
'remote_profile_id' => ['type' => 'integer', 'not null' => true], 'remote_profile_id' => ['type' => 'int', 'not null' => true],
'relation_id' => ['type' => 'serial', 'not null' => true], 'relation_id' => ['type' => 'serial', 'not null' => true],
], ],
'primary key' => ['relation_id'], 'primary key' => ['relation_id'],
'foreign keys' => [ 'foreign keys' => [

View File

@ -61,7 +61,7 @@ class Activitypub_profile extends Managed_DataObject
return [ return [
'fields' => [ 'fields' => [
'uri' => ['type' => 'text', 'not null' => true], 'uri' => ['type' => 'text', 'not null' => true],
'profile_id' => ['type' => 'integer'], 'profile_id' => ['type' => 'int', 'not null' => true],
'inboxuri' => ['type' => 'text', 'not null' => true], 'inboxuri' => ['type' => 'text', 'not null' => true],
'sharedInboxuri' => ['type' => 'text'], 'sharedInboxuri' => ['type' => 'text'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], '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 [ return [
'fields' => [ 'fields' => [
'profile_id' => ['type' => 'integer'], 'profile_id' => ['type' => 'int', 'not null' => true],
'private_key' => ['type' => 'text'], 'private_key' => ['type' => 'text'],
'public_key' => ['type' => 'text', 'not null' => true], 'public_key' => ['type' => 'text', 'not null' => true],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'], 'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was created'],

View File

@ -1,31 +1,31 @@
<?php <?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 * 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 * @category Data
* @package EmailReminder * @package EmailReminder
* @author Zach Copley <zach@status.net> * @author Zach Copley <zach@status.net>
* @copyright 2011 StatusNet, Inc. * @copyright 2011 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
defined('GNUSOCIAL') || die();
class Email_reminder extends Managed_DataObject class Email_reminder extends Managed_DataObject
{ {
public $__table = 'email_reminder'; 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 * @param int $days Number of days after the code was created
* @return boolean true if any Email_reminder records were found * @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 = new Email_reminder();
$reminder->type = $type; $reminder->type = $type;
$reminder->code = $object->code; $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 * @param int $days Number of days after the code was created
* @return int $result row ID of the new reminder record * @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 = new Email_reminder();
$reminder->type = $type; $reminder->type = $type;
$reminder->code = $object->code; $reminder->code = $object->code;
@ -83,9 +83,9 @@ class Email_reminder extends Managed_DataObject
if (empty($result)) { if (empty($result)) {
common_log_db_error($reminder, 'INSERT', __FILE__); common_log_db_error($reminder, 'INSERT', __FILE__);
throw new ServerException( throw new ServerException(
// TRANS: Server exception thrown when a reminder record could not be inserted into the database. // TRANS: Server exception thrown when a reminder record could not be inserted into the database.
_m('Database error inserting reminder record.') _m('Database error inserting reminder record.')
); );
} }
@ -108,13 +108,13 @@ class Email_reminder extends Managed_DataObject
), ),
'code' => array( 'code' => array(
'type' => 'varchar', 'type' => 'varchar',
'not null' => 'true', 'not null' => true,
'length' => 191, 'length' => 191,
'description' => 'confirmation code' 'description' => 'confirmation code'
), ),
'days' => array( 'days' => array(
'type' => 'int', 'type' => 'int',
'not null' => 'true', 'not null' => true,
'description' => 'number of days since code creation' 'description' => 'number of days since code creation'
), ),
'sent' => array( 'sent' => array(

View File

@ -94,8 +94,10 @@ class Happening extends Managed_DataObject
'unique keys' => array( 'unique keys' => array(
'happening_uri_key' => array('uri'), 'happening_uri_key' => array('uri'),
), ),
'foreign keys' => array('happening_profile_id__key' => array('profile', array('profile_id' => 'id')), 'foreign keys' => array(
'happening_uri__key' => array('notice', array('uri' => 'uri'))), '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'), 'indexes' => array('happening_created_idx' => array('created'),
'happening_start_end_idx' => array('start_time', 'end_time')), '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_uri_key' => array('uri'),
'rsvp_profile_event_key' => array('profile_id', 'event_uri'), 'rsvp_profile_event_key' => array('profile_id', 'event_uri'),
), ),
'foreign keys' => array('rsvp_event_uri_key' => array('happening', array('event_uri' => 'uri')), 'foreign keys' => array(
'rsvp_profile_id__key' => array('profile', array('profile_id' => 'id'))), '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')), 'indexes' => array('rsvp_created_idx' => array('created')),
); );
} }

View File

@ -73,7 +73,7 @@ class ModLog extends Managed_DataObject
'primary key' => array('id'), 'primary key' => array('id'),
'foreign keys' => array( 'foreign keys' => array(
'mod_log_profile_id_fkey' => array('profile', array('profile_id' => 'id')), '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( 'indexes' => array(
'mod_log_profile_id_created_idx' => array('profile_id', 'created'), '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'), 'secret' => array('type' => 'text', 'description' => 'HubSub stored secret'),
'sub_start' => array('type' => 'datetime', 'description' => 'subscription start'), 'sub_start' => array('type' => 'datetime', 'description' => 'subscription start'),
'sub_end' => array('type' => 'datetime', 'description' => 'subscription end'), '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'), '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' => array('type' => 'datetime', 'default' => null, 'description' => 'time of last failure, if ever'),
'last_error_msg' => array('type' => 'text', 'default' => null, 'description' => 'Last error _message_'), '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( return array(
'fields' => array( 'fields' => array(
'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true), 'uri' => array('type' => 'varchar', 'length' => 191, 'not null' => true),
'profile_id' => array('type' => 'integer'), 'profile_id' => array('type' => 'int'),
'group_id' => array('type' => 'integer'), 'group_id' => array('type' => 'int'),
'peopletag_id' => array('type' => 'integer'), 'peopletag_id' => array('type' => 'int'),
'feeduri' => array('type' => 'varchar', 'length' => 191), 'feeduri' => array('type' => 'varchar', 'length' => 191),
'salmonuri' => array('type' => 'varchar', 'length' => 191), 'salmonuri' => array('type' => 'varchar', 'length' => 191),
'avatar' => array('type' => 'text'), 'avatar' => array('type' => 'text'),

View File

@ -63,12 +63,12 @@ class User_openid_prefs extends Managed_DataObject
'description' => 'Per-user preferences for OpenID display', 'description' => 'Per-user preferences for OpenID display',
'fields' => [ 'fields' => [
'user_id' => [ 'user_id' => [
'type' => 'integer', 'type' => 'int',
'not null' => true, 'not null' => true,
'description' => 'User whose prefs we are saving' 'description' => 'User whose prefs we are saving'
], ],
'hide_profile_link' => [ 'hide_profile_link' => [
'type' => 'integer', 'type' => 'int',
'not null' => true, 'not null' => true,
'default' => 0, 'default' => 0,
'description' => 'Whether to hide profile links from profile block' 'description' => 'Whether to hide profile links from profile block'

View File

@ -1,46 +1,38 @@
<?php <?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 * Data class to record responses to polls
* *
* PHP version 5 * @category PollPlugin
* * @package GNUsocial
* @category PollPlugin * @author Brion Vibber <brion@status.net>
* @package StatusNet * @copyright 2011, StatusNet, Inc.
* @author Brion Vibber <brion@status.net> * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @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/>.
*/ */
if (!defined('STATUSNET')) { defined('GNUSOCIAL') || die();
exit(1);
}
/** /**
* For storing the poll options and such * For storing the poll options and such
* *
* @category PollPlugin * @copyright 2011, StatusNet, Inc.
* @package StatusNet * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @author Brion Vibber <brion@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
* *
* @see DB_DataObject * @see DB_DataObject
*/ */
class Poll_response extends Managed_DataObject class Poll_response extends Managed_DataObject
{ {
@ -69,7 +61,7 @@ class Poll_response extends Managed_DataObject
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'unique keys' => array( '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'), 'poll_response_poll_id_profile_id_key' => array('poll_id', 'profile_id'),
), ),
'indexes' => array( 'indexes' => array(

View File

@ -81,11 +81,11 @@ class QnA_Answer extends Managed_DataObject
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'unique keys' => array( 'unique keys' => array(
'question_uri_key' => array('uri'), 'qna_answer_uri_key' => array('uri'),
'question_id_profile_id_key' => array('question_id', 'profile_id'), 'qna_answer_question_id_profile_id_key' => array('question_id', 'profile_id'),
), ),
'indexes' => array( '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'), 'primary key' => array('id'),
'unique keys' => array( 'unique keys' => array(
'question_uri_key' => array('uri'), 'qna_question_uri_key' => array('uri'),
), ),
); );
} }

View File

@ -1,46 +1,38 @@
<?php <?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 * Data class to save users votes for
* *
* PHP version 5 * @category QnA
* * @package GNUsocial
* @category QnA * @author Zach Copley <zach@status.net>
* @package StatusNet * @copyright 2011 StatusNet, Inc.
* @author Zach Copley <zach@status.net> * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @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/>.
*/ */
if (!defined('STATUSNET')) { defined('GNUSOCIAL') || die();
exit(1);
}
/** /**
* For storing votes on question and answers * For storing votes on question and answers
* *
* @category QnA * @copyright 2011 StatusNet, Inc.
* @package StatusNet * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @author Zach Copley <zach@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
* *
* @see DB_DataObject * @see DB_DataObject
*/ */
class QnA_Vote extends Managed_DataObject class QnA_Vote extends Managed_DataObject
{ {
@ -87,11 +79,11 @@ class QnA_Vote extends Managed_DataObject
), ),
'primary key' => array('id'), 'primary key' => array('id'),
'indexes' => array( 'indexes' => array(
'profile_id_question_Id_index' => array( 'qna_vote_profile_id_question_id_idx' => array(
'profile_id', 'profile_id',
'question_id' 'question_id'
), ),
'profile_id_question_Id_index' => array( 'qna_vote_profile_id_question_id_idx' => array(
'profile_id', 'profile_id',
'answer_id' 'answer_id'
) )
@ -110,7 +102,7 @@ class QnA_Vote extends Managed_DataObject
* *
* @return Void * @return Void
*/ */
static function save($profile, $question, $answer, $vote) public static function save($profile, $question, $answer, $vote)
{ {
$v = new QnA_Vote(); $v = new QnA_Vote();
$v->id = UUID::gen(); $v->id = UUID::gen();

View File

@ -79,7 +79,7 @@ class Realtime_channel extends Managed_DataObject
'length' => 32, 'length' => 32,
'not null' => true, 'not null' => true,
'description' => 'shared secret key for this channel'), 'description' => 'shared secret key for this channel'),
'audience' => array('type' => 'integer', 'audience' => array('type' => 'int',
'not null' => true, 'not null' => true,
'default' => 0, 'default' => 0,
'description' => 'reference count'), 'description' => 'reference count'),

View File

@ -1,55 +1,43 @@
<?php <?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 * Plugin that requires the user to have a validated email address before they
* can post notices * 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 * @category Plugin
* @package StatusNet * @package GNUsocial
* @author Craig Andrews <candrews@integralblue.com> * @author Craig Andrews <candrews@integralblue.com>
* @author Brion Vibber <brion@status.net> * @author Brion Vibber <brion@status.net>
* @author Evan Prodromou <evan@status.net> * @author Evan Prodromou <evan@status.net>
* @author Mikael Nordfeldth <mmn@hethane.se>
* @copyright 2011 StatusNet Inc. http://status.net/ * @copyright 2011 StatusNet Inc. http://status.net/
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @copyright 2009-2013 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 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
if (!defined('STATUSNET') && !defined('LACONICA')) { defined('GNUSOCIAL') || die();
exit(1);
}
/** /**
* Plugin for requiring a validated email before posting. * Plugin for requiring a validated email before posting.
* *
* Enable this plugin using addPlugin('RequireValidatedEmail'); * 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-2013 Free Software Foundation, Inc http://www.fsf.org
* @copyright 2009-2010 StatusNet, Inc. * @copyright 2009-2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
class RequireValidatedEmailPlugin extends Plugin class RequireValidatedEmailPlugin extends Plugin
{ {
@ -84,8 +72,10 @@ class RequireValidatedEmailPlugin extends Plugin
public function onRouterInitialized(URLMapper $m) public function onRouterInitialized(URLMapper $m)
{ {
$m->('main/confirmfirst/:code', $m->connect(
['action' => 'confirmfirstemail']); 'main/confirmfirst/:code',
['action' => 'confirmfirstemail']
);
return true; return true;
} }
@ -121,7 +111,7 @@ class RequireValidatedEmailPlugin extends Plugin
* *
* @return bool hook result code * @return bool hook result code
*/ */
function onStartRegisterUser(&$user, &$profile) public function onStartRegisterUser(&$user, &$profile)
{ {
$email = $user->email; $email = $user->email;
@ -153,8 +143,10 @@ class RequireValidatedEmailPlugin extends Plugin
// that somebody's ok despite a non-validated email. // that somebody's ok despite a non-validated email.
// @todo FIXME: This isn't how to do it! Use Start*/End* instead // @todo FIXME: This isn't how to do it! Use Start*/End* instead
Event::handle('RequireValidatedEmailPlugin_Override', Event::handle(
array($user, &$knownGood)); 'RequireValidatedEmailPlugin_Override',
[$user, &$knownGood]
);
return $knownGood; return $knownGood;
} }
@ -188,7 +180,7 @@ class RequireValidatedEmailPlugin extends Plugin
* *
* @return bool true if user has a trusted OpenID. * @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')) { if ($this->trustedOpenIDs && class_exists('User_openid')) {
foreach ($this->trustedOpenIDs as $regex) { foreach ($this->trustedOpenIDs as $regex) {
@ -240,7 +232,7 @@ class RequireValidatedEmailPlugin extends Plugin
* *
* @return boolean hook value * @return boolean hook value
*/ */
function onStartMakeEntryForm($tag, $action, &$form) public function onStartMakeEntryForm($tag, $action, &$form)
{ {
$user = common_current_user(); $user = common_current_user();
if (!empty($user)) { if (!empty($user)) {
@ -259,7 +251,7 @@ class RequireValidatedEmailPlugin extends Plugin
* @param boolean $result if overriding, set to true/false has right * @param boolean $result if overriding, set to true/false has right
* @return boolean hook result value * @return boolean hook result value
*/ */
function onUserRightsCheck(Profile $profile, $right, &$result) public function onUserRightsCheck(Profile $profile, $right, &$result)
{ {
if ($right == Right::CREATEGROUP || if ($right == Right::CREATEGROUP ||
($this->disallowLogin && ($right == Right::WEBLOGIN || $right == Right::API))) { ($this->disallowLogin && ($right == Right::WEBLOGIN || $right == Right::API))) {
@ -272,7 +264,7 @@ class RequireValidatedEmailPlugin extends Plugin
return true; return true;
} }
function onLoginAction($action, &$login) public function onLoginAction($action, &$login)
{ {
if ($action == 'confirmfirstemail') { if ($action == 'confirmfirstemail') {
$login = true; $login = true;

View File

@ -1,48 +1,35 @@
<?php <?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 * Creates a dynamic sitemap for a StatusNet site
* *
* PHP version 5 * @package GNUsocial
*
* 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
* @author Evan Prodromou <evan@status.net> * @author Evan Prodromou <evan@status.net>
* @copyright 2010 StatusNet, Inc. * @copyright 2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
if (!defined('STATUSNET')) { defined('GNUSOCIAL') || die();
// This check helps protect against security problems;
// your code file can't be executed directly from the web.
exit(1);
}
/** /**
* Sitemap plugin * Sitemap plugin
* *
* @category Sample
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2010 StatusNet, Inc. * @copyright 2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
* @link http://status.net/
*/ */
class SitemapPlugin extends Plugin class SitemapPlugin extends Plugin
{ {
@ -58,7 +45,7 @@ class SitemapPlugin extends Plugin
* *
* @return boolean hook value. * @return boolean hook value.
*/ */
function onEndRobotsTxt($action) public function onEndRobotsTxt($action)
{ {
$url = common_local_url('sitemapindex'); $url = common_local_url('sitemapindex');
@ -76,25 +63,37 @@ class SitemapPlugin extends Plugin
*/ */
public function onRouterInitialized(URLMapper $m) public function onRouterInitialized(URLMapper $m)
{ {
$m->connect('sitemapindex.xml', $m->connect(
['action' => 'sitemapindex']); 'sitemapindex.xml',
['action' => 'sitemapindex']
);
$m->connect('notice-sitemap-:year-:month-:day-:index.xml', $m->connect(
['action' => 'noticesitemap'], 'notice-sitemap-:year-:month-:day-:index.xml',
['year' => '[0-9]{4}', ['action' => 'noticesitemap'],
'month' => '[01][0-9]', [
'day' => '[0123][0-9]', 'year' => '[0-9]{4}',
'index' => '[1-9][0-9]*']); 'month' => '[01][0-9]',
'day' => '[0123][0-9]',
'index' => '[1-9][0-9]*',
]
);
$m->connect('user-sitemap-:year-:month-:day-:index.xml', $m->connect(
['action' => 'usersitemap'), 'user-sitemap-:year-:month-:day-:index.xml',
['year' => '[0-9]{4}', ['action' => 'usersitemap'],
'month' => '[01][0-9]', [
'day' => '[0123][0-9]', 'year' => '[0-9]{4}',
'index' => '[1-9][0-9]*']); 'month' => '[01][0-9]',
'day' => '[0123][0-9]',
'index' => '[1-9][0-9]*',
]
);
$m->connect('panel/sitemap', $m->connect(
['action' => 'sitemapadminpanel']); 'panel/sitemap',
['action' => 'sitemapadminpanel']
);
return true; return true;
} }
@ -109,7 +108,7 @@ class SitemapPlugin extends Plugin
* *
* @return boolean hook value. * @return boolean hook value.
*/ */
function onStartShowHeadElements($action) public function onStartShowHeadElements($action)
{ {
$actionName = $action->trimmed('action'); $actionName = $action->trimmed('action');
@ -119,7 +118,6 @@ class SitemapPlugin extends Plugin
if (($singleUser && $actionName == 'showstream') || if (($singleUser && $actionName == 'showstream') ||
(!$singleUser && $actionName == 'public')) { (!$singleUser && $actionName == 'public')) {
$keys = array('yahookey' => 'y_key', $keys = array('yahookey' => 'y_key',
'bingkey' => 'msvalidate.01'); // XXX: is this the same for all sites? '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. * @return boolean hook value; true means continue processing, false means stop.
*/ */
function onCheckSchema() public function onCheckSchema()
{ {
$schema = Schema::get(); $schema = Schema::get();
@ -155,13 +153,19 @@ class SitemapPlugin extends Plugin
return true; return true;
} }
function onEndAdminPanelNav($menu) { public function onEndAdminPanelNav($menu)
{
if (AdminPanelAction::canAdmin('sitemap')) { if (AdminPanelAction::canAdmin('sitemap')) {
// TRANS: Menu item title/tooltip // TRANS: Menu item title/tooltip
$menu_title = _m('Sitemap configuration'); $menu_title = _m('Sitemap configuration');
// TRANS: Menu item for site administration // TRANS: Menu item for site administration
$menu->out->menuItem(common_local_url('sitemapadminpanel'), _m('MENU','Sitemap'), $menu->out->menuItem(
$menu_title, $action_name == 'sitemapadminpanel', 'nav_sitemap_admin_panel'); common_local_url('sitemapadminpanel'),
_m('MENU', 'Sitemap'),
$menu_title,
($action_name === 'sitemapadminpanel'),
'nav_sitemap_admin_panel'
);
} }
return true; return true;
} }