[DATABASE] Fix index identifiers and clean up redundant ones
This commit is contained in:
parent
f3ab63957d
commit
665e4574da
@ -51,7 +51,6 @@ class Attention extends Managed_DataObject
|
||||
'attention_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'attention_notice_id_idx' => array('notice_id'),
|
||||
'attention_profile_id_idx' => array('profile_id'),
|
||||
),
|
||||
);
|
||||
|
@ -52,9 +52,6 @@ class Avatar extends Managed_DataObject
|
||||
'foreign keys' => array(
|
||||
'avatar_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'avatar_profile_id_idx' => array('profile_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,6 @@ class File_thumbnail extends Managed_DataObject
|
||||
),
|
||||
'primary key' => array('file_id', 'width', 'height'),
|
||||
'indexes' => array(
|
||||
'file_thumbnail_file_id_idx' => array('file_id'),
|
||||
'file_thumbnail_urlhash_idx' => array('urlhash'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
|
@ -50,8 +50,7 @@ class File_to_post extends Managed_DataObject
|
||||
'file_to_post_post_id_fkey' => array('notice', array('post_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'file_id_idx' => array('file_id'),
|
||||
'post_id_idx' => array('post_id'),
|
||||
'file_to_post_post_id_idx' => array('post_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -60,12 +60,9 @@ class Foreign_link extends Managed_DataObject
|
||||
'primary key' => array('user_id', 'foreign_id', 'service'),
|
||||
'foreign keys' => array(
|
||||
'foreign_link_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||
'foreign_link_foreign_id_fkey' => array('foreign_user', array('foreign_id' => 'id', 'service' => 'service')),
|
||||
'foreign_link_foreign_id_service_fkey' => array('foreign_user', array('foreign_id' => 'id', 'service' => 'service')),
|
||||
'foreign_link_service_fkey' => array('foreign_service', array('service' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'foreign_user_user_id_idx' => array('user_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -47,12 +47,11 @@ class Foreign_subscription extends Managed_DataObject
|
||||
'primary key' => array('service', 'subscriber', 'subscribed'),
|
||||
'foreign keys' => array(
|
||||
'foreign_subscription_service_fkey' => array('foreign_service', array('service' => 'id')),
|
||||
'foreign_subscription_subscriber_fkey' => array('foreign_user', array('subscriber' => 'id', 'service' => 'service')),
|
||||
'foreign_subscription_subscribed_fkey' => array('foreign_user', array('subscribed' => 'id', 'service' => 'service')),
|
||||
'foreign_subscription_subscriber_service_fkey' => array('foreign_user', array('subscriber' => 'id', 'service' => 'service')),
|
||||
'foreign_subscription_subscribed_service_fkey' => array('foreign_user', array('subscribed' => 'id', 'service' => 'service')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'foreign_subscription_subscriber_idx' => array('service', 'subscriber'),
|
||||
'foreign_subscription_subscribed_idx' => array('service', 'subscribed'),
|
||||
'foreign_subscription_service_subscribed_idx' => array('service', 'subscribed'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -56,8 +56,6 @@ class Group_member extends Managed_DataObject
|
||||
'group_member_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
// @fixme probably we want a (profile_id, created) index here?
|
||||
'group_member_profile_id_idx' => array('profile_id'),
|
||||
'group_member_created_idx' => array('created'),
|
||||
'group_member_profile_id_created_idx' => array('profile_id', 'created'),
|
||||
'group_member_group_id_created_idx' => array('group_id', 'created'),
|
||||
|
@ -61,7 +61,7 @@ class Invitation extends Managed_DataObject
|
||||
'invitation_registered_user_id_fkey' => array('user', array('registered_user_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'invitation_address_idx' => array('address', 'address_type'),
|
||||
'invitation_address_address_type_idx' => array('address', 'address_type'),
|
||||
'invitation_user_id_idx' => array('user_id'),
|
||||
'invitation_registered_user_id_idx' => array('registered_user_id'),
|
||||
),
|
||||
|
@ -114,7 +114,7 @@ class Notice extends Managed_DataObject
|
||||
'notice_object_type_idx' => array('object_type'),
|
||||
'notice_verb_idx' => array('verb'),
|
||||
'notice_url_idx' => array('url'), // Qvitter wants this
|
||||
'notice_replyto_idx' => array('reply_to')
|
||||
'notice_reply_to_idx' => array('reply_to')
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -52,9 +52,6 @@ class Notice_prefs extends Managed_DataObject
|
||||
'foreign keys' => array(
|
||||
'notice_prefs_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'notice_prefs_notice_id_idx' => array('notice_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -65,9 +65,9 @@ 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', array('profile_id' => 'id')),
|
||||
'oauth_token_association_application_fkey' => array('oauth_application', array('application_id' => 'id')),
|
||||
)
|
||||
'oauth_token_association_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
'oauth_token_association_application_id_fkey' => array('oauth_application', array('application_id' => 'id')),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,6 @@ class Profile_list extends Managed_DataObject
|
||||
'indexes' => array(
|
||||
'profile_list_modified_idx' => array('modified'),
|
||||
'profile_list_tag_idx' => array('tag'),
|
||||
'profile_list_tagger_tag_idx' => array('tagger', 'tag'),
|
||||
'profile_list_tagged_count_idx' => array('tagged_count'),
|
||||
'profile_list_subscriber_count_idx' => array('subscriber_count'),
|
||||
),
|
||||
|
@ -51,9 +51,6 @@ class Profile_prefs extends Managed_DataObject
|
||||
'foreign keys' => array(
|
||||
'profile_prefs_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'profile_prefs_profile_id_idx' => array('profile_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ class Profile_tag_subscription extends Managed_DataObject
|
||||
),
|
||||
'primary key' => array('profile_tag_id', 'profile_id'),
|
||||
'foreign keys' => array(
|
||||
'profile_tag_subscription_profile_list_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')),
|
||||
'profile_tag_subscription_profile_tag_id_fkey' => array('profile_list', array('profile_tag_id' => 'id')),
|
||||
'profile_tag_subscription_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
|
@ -49,7 +49,6 @@ class Reply extends Managed_DataObject
|
||||
'reply_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'reply_notice_id_idx' => array('notice_id'),
|
||||
'reply_profile_id_idx' => array('profile_id'),
|
||||
'reply_replied_id_idx' => array('replied_id'),
|
||||
'reply_profile_id_modified_notice_id_idx' => array('profile_id', 'modified', 'notice_id')
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @copyright 2008, 2009, StatusNet, Inc.
|
||||
* @copyright 2008, 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
@ -59,8 +59,8 @@ class Subscription extends Managed_DataObject
|
||||
'subscription_uri_key' => array('uri'),
|
||||
),
|
||||
'indexes' => array(
|
||||
'subscription_subscriber_idx' => array('subscriber', 'created'),
|
||||
'subscription_subscribed_idx' => array('subscribed', 'created'),
|
||||
'subscription_subscriber_created_idx' => array('subscriber', 'created'),
|
||||
'subscription_subscribed_created_idx' => array('subscribed', 'created'),
|
||||
'subscription_token_idx' => array('token'),
|
||||
),
|
||||
);
|
||||
|
@ -55,7 +55,7 @@ class Token extends Managed_DataObject
|
||||
),
|
||||
'primary key' => array('consumer_key', 'tok'),
|
||||
'foreign keys' => array(
|
||||
'token_consumer_key_fkey' => array('consumer', array('consumer_key'=> 'consumer_key')),
|
||||
'token_consumer_key_fkey' => array('consumer', array('consumer_key' => 'consumer_key')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class User_group extends Managed_DataObject
|
||||
// when it's safe and everyone's run upgrade.php 'user_profile_id_key' => array('profile_id'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'user_group_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
'user_group_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'user_group_nickname_idx' => array('nickname'),
|
||||
|
@ -59,7 +59,7 @@ class User_im_prefs extends Managed_DataObject
|
||||
),
|
||||
'primary key' => array('user_id', 'transport'),
|
||||
'unique keys' => array(
|
||||
'transport_screenname_key' => array('transport', 'screenname'),
|
||||
'user_im_prefs_transport_screenname_key' => array('transport', 'screenname'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'user_im_prefs_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||
|
@ -46,12 +46,12 @@ class User_username extends Managed_DataObject
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('provider_name', 'username'),
|
||||
'indexes' => array(
|
||||
'user_id_idx' => array('user_id')
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'user_username_user_id_fkey' => array('user', array('user_id' => 'id')),
|
||||
),
|
||||
'indexes' => array(
|
||||
'user_username_user_id_idx' => array('user_id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,9 @@ class Realtime_channel extends Managed_DataObject
|
||||
'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['channel_key'],
|
||||
'unique keys' => ['realtime_channel_user_page_idx' => ['user_id', 'action', 'arg1', 'arg2']],
|
||||
'unique keys' => [
|
||||
'realtime_channel_user_id_action_arg1_arg2_key' => ['user_id', 'action', 'arg1', 'arg2'],
|
||||
],
|
||||
'foreign keys' => [
|
||||
'realtime_channel_user_id_fkey' => ['user', ['user_id' => 'id']],
|
||||
],
|
||||
|
@ -48,8 +48,7 @@ class Fave extends Managed_DataObject
|
||||
'fave_user_id_fkey' => array('profile', array('user_id' => 'id')), // note: formerly referenced notice.id, but we can now record remote users' favorites
|
||||
),
|
||||
'indexes' => array(
|
||||
'fave_notice_id_idx' => array('notice_id'),
|
||||
'fave_user_id_idx' => array('user_id', 'modified'),
|
||||
'fave_user_id_modified_idx' => array('user_id', 'modified'),
|
||||
'fave_modified_idx' => array('modified'),
|
||||
),
|
||||
);
|
||||
|
@ -84,24 +84,24 @@ class Message extends Managed_DataObject
|
||||
'indexes' => array(
|
||||
// @fixme these are really terrible indexes, since you can only sort on one of them at a time.
|
||||
// looks like we really need a (to_profile, created) for inbox and a (from_profile, created) for outbox
|
||||
'message_from_idx' => array('from_profile'),
|
||||
'message_to_idx' => array('to_profile'),
|
||||
'message_from_profile_idx' => array('from_profile'),
|
||||
'message_to_profile_idx' => array('to_profile'),
|
||||
'message_created_idx' => array('created'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function getFrom()
|
||||
public function getFrom()
|
||||
{
|
||||
return Profile::getKV('id', $this->from_profile);
|
||||
}
|
||||
|
||||
function getTo()
|
||||
public function getTo()
|
||||
{
|
||||
return Profile::getKV('id', $this->to_profile);
|
||||
}
|
||||
|
||||
function getSource()
|
||||
public function getSource()
|
||||
{
|
||||
if (empty($this->source)) {
|
||||
return false;
|
||||
@ -133,7 +133,7 @@ class Message extends Managed_DataObject
|
||||
return $ns;
|
||||
}
|
||||
|
||||
function asActivity()
|
||||
public function asActivity()
|
||||
{
|
||||
$act = new Activity();
|
||||
|
||||
|
@ -135,7 +135,7 @@ class Email_reminder extends Managed_DataObject
|
||||
),
|
||||
'primary key' => array('type', 'code', 'days'),
|
||||
'indexes' => array(
|
||||
'sent_idx' => array('sent'),
|
||||
'email_reminder_sent_idx' => array('sent'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -1,33 +1,30 @@
|
||||
<?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 for happenings
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Data
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@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/>.
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Data class for happenings
|
||||
@ -38,10 +35,9 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
* "Happening" seemed good enough.
|
||||
*
|
||||
* @category Event
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see Managed_DataObject
|
||||
*/
|
||||
@ -98,8 +94,10 @@ class Happening extends Managed_DataObject
|
||||
'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')),
|
||||
'indexes' => array(
|
||||
'happening_created_idx' => array('created'),
|
||||
'happening_start_time_end_time_idx' => array('start_time', 'end_time'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -131,6 +129,7 @@ class Happening extends Managed_DataObject
|
||||
switch ($extra[0]) {
|
||||
case 'dtstart':
|
||||
$dtstart = $extra[2];
|
||||
break;
|
||||
case 'dtend':
|
||||
$dtend = $extra[2];
|
||||
break;
|
||||
@ -143,11 +142,11 @@ class Happening extends Managed_DataObject
|
||||
$url = $extra[2];
|
||||
}
|
||||
}
|
||||
if(empty($dtstart)) {
|
||||
if (empty($dtstart)) {
|
||||
// TRANS: Exception thrown when has no start date
|
||||
throw new Exception(_m('No start date for event.'));
|
||||
}
|
||||
if(empty($dtend)) {
|
||||
if (empty($dtend)) {
|
||||
// TRANS: Exception thrown when has no end date
|
||||
throw new Exception(_m('No end date for event.'));
|
||||
}
|
||||
@ -211,7 +210,7 @@ class Happening extends Managed_DataObject
|
||||
return Notice::getByKeys(array('uri'=>$this->getUri()));
|
||||
}
|
||||
|
||||
static function fromStored(Notice $stored)
|
||||
public static function fromStored(Notice $stored)
|
||||
{
|
||||
if (!ActivityUtils::compareTypes($stored->getObjectType(), [self::OBJECT_TYPE])) {
|
||||
throw new ServerException('Notice is not of type '.self::OBJECT_TYPE);
|
||||
@ -219,18 +218,20 @@ class Happening extends Managed_DataObject
|
||||
return self::getByKeys(array('uri'=>$stored->getUri()));
|
||||
}
|
||||
|
||||
function getRSVPs()
|
||||
public function getRSVPs()
|
||||
{
|
||||
return RSVP::forEvent($this);
|
||||
}
|
||||
|
||||
function getRSVP($profile)
|
||||
public function getRSVP($profile)
|
||||
{
|
||||
return RSVP::pkeyGet(array('profile_id' => $profile->getID(),
|
||||
'event_uri' => $this->getUri()));
|
||||
return RSVP::pkeyGet([
|
||||
'profile_id' => $profile->getID(),
|
||||
'event_uri' => $this->getUri(),
|
||||
]);
|
||||
}
|
||||
|
||||
static public function getObjectType()
|
||||
public static function getObjectType()
|
||||
{
|
||||
return self::OBJECT_TYPE;
|
||||
}
|
||||
|
@ -1,42 +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 for event RSVPs
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Data
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@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/>.
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Data class for event RSVPs
|
||||
*
|
||||
* @category Event
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see Managed_DataObject
|
||||
*/
|
||||
@ -83,7 +79,7 @@ class RSVP extends Managed_DataObject
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
'rsvp_uri_key' => array('uri'),
|
||||
'rsvp_profile_event_key' => array('profile_id', 'event_uri'),
|
||||
'rsvp_profile_id_event_uri_key' => array('profile_id', 'event_uri'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'rsvp_event_uri_fkey' => array('happening', array('event_uri' => 'uri')),
|
||||
@ -93,7 +89,7 @@ class RSVP extends Managed_DataObject
|
||||
);
|
||||
}
|
||||
|
||||
static public function beforeSchemaUpdate()
|
||||
public static function beforeSchemaUpdate()
|
||||
{
|
||||
$table = strtolower(get_called_class());
|
||||
$schema = Schema::get();
|
||||
@ -128,7 +124,7 @@ class RSVP extends Managed_DataObject
|
||||
print "Resuming core schema upgrade...";
|
||||
}
|
||||
|
||||
static function saveActivityObject(Activity $act, Notice $stored)
|
||||
public static function saveActivityObject(Activity $act, Notice $stored)
|
||||
{
|
||||
$target = Notice::getByKeys(array('uri'=>$act->target->id));
|
||||
if (!ActivityUtils::compareTypes($target->getObjectType(), [ Happening::OBJECT_TYPE ])) {
|
||||
@ -138,9 +134,10 @@ class RSVP extends Managed_DataObject
|
||||
// FIXME: Maybe we need some permission handling here, though I think it's taken care of in saveActivity?
|
||||
|
||||
try {
|
||||
$other = RSVP::getByKeys( [ 'profile_id' => $stored->getProfile()->getID(),
|
||||
$other = RSVP::getByKeys([
|
||||
'profile_id' => $stored->getProfile()->getID(),
|
||||
'event_uri' => $target->getUri(),
|
||||
] );
|
||||
]);
|
||||
// TRANS: Client exception thrown when trying to save an already existing RSVP ("please respond").
|
||||
throw new AlreadyFulfilledException(_m('RSVP already exists.'));
|
||||
} catch (NoResultException $e) {
|
||||
@ -162,7 +159,7 @@ class RSVP extends Managed_DataObject
|
||||
return $rsvp;
|
||||
}
|
||||
|
||||
static public function getObjectType()
|
||||
public static function getObjectType()
|
||||
{
|
||||
return ActivityObject::ACTIVITY;
|
||||
}
|
||||
@ -181,7 +178,7 @@ class RSVP extends Managed_DataObject
|
||||
return $actobj;
|
||||
}
|
||||
|
||||
static function codeFor($verb)
|
||||
public static function codeFor($verb)
|
||||
{
|
||||
switch (true) {
|
||||
case ActivityUtils::compareVerbs($verb, [RSVP::POSITIVE]):
|
||||
@ -195,11 +192,11 @@ class RSVP extends Managed_DataObject
|
||||
break;
|
||||
default:
|
||||
// TRANS: Exception thrown when requesting an undefined verb for RSVP.
|
||||
throw new Exception(sprintf(_m('Unknown verb "%s".'),$verb));
|
||||
throw new Exception(sprintf(_m('Unknown verb "%s".'), $verb));
|
||||
}
|
||||
}
|
||||
|
||||
static function verbFor($code)
|
||||
public static function verbFor($code)
|
||||
{
|
||||
switch ($code) {
|
||||
case 'Y':
|
||||
@ -235,18 +232,18 @@ class RSVP extends Managed_DataObject
|
||||
return Notice::getByKeys(['uri' => $this->getUri()]);
|
||||
}
|
||||
|
||||
static function fromStored(Notice $stored)
|
||||
public static function fromStored(Notice $stored)
|
||||
{
|
||||
return self::getByKeys(['uri' => $stored->getUri()]);
|
||||
}
|
||||
|
||||
static function byEventAndActor(Happening $event, Profile $actor)
|
||||
public static function byEventAndActor(Happening $event, Profile $actor)
|
||||
{
|
||||
return self::getByKeys(['event_uri' => $event->getUri(),
|
||||
'profile_id' => $actor->getID()]);
|
||||
}
|
||||
|
||||
static function forEvent(Happening $event)
|
||||
public static function forEvent(Happening $event)
|
||||
{
|
||||
$keypart = sprintf('rsvp:for-event:%s', $event->getUri());
|
||||
|
||||
@ -287,31 +284,35 @@ class RSVP extends Managed_DataObject
|
||||
return $rsvps;
|
||||
}
|
||||
|
||||
function getProfile()
|
||||
public function getProfile()
|
||||
{
|
||||
return Profile::getByID($this->profile_id);
|
||||
}
|
||||
|
||||
function getEvent()
|
||||
public function getEvent()
|
||||
{
|
||||
return Happening::getByKeys(['uri' => $this->getEventUri()]);
|
||||
}
|
||||
|
||||
function asHTML()
|
||||
public function asHTML()
|
||||
{
|
||||
return self::toHTML($this->getProfile(),
|
||||
return self::toHTML(
|
||||
$this->getProfile(),
|
||||
$this->getEvent(),
|
||||
$this->response);
|
||||
$this->response
|
||||
);
|
||||
}
|
||||
|
||||
function asString()
|
||||
public function asString()
|
||||
{
|
||||
return self::toString($this->getProfile(),
|
||||
return self::toString(
|
||||
$this->getProfile(),
|
||||
$this->getEvent(),
|
||||
$this->response);
|
||||
$this->response
|
||||
);
|
||||
}
|
||||
|
||||
static function toHTML(Profile $profile, Happening $event, $response)
|
||||
public static function toHTML(Profile $profile, Happening $event, $response)
|
||||
{
|
||||
$fmt = null;
|
||||
|
||||
@ -337,7 +338,7 @@ class RSVP extends Managed_DataObject
|
||||
default:
|
||||
// TRANS: Exception thrown when requesting a user's RSVP status for a non-existing response code.
|
||||
// TRANS: %s is the non-existing response code.
|
||||
throw new Exception(sprintf(_m('Unknown response code %s.'),$response));
|
||||
throw new Exception(sprintf(_m('Unknown response code %s.'), $response));
|
||||
}
|
||||
|
||||
if (empty($event)) {
|
||||
@ -350,14 +351,16 @@ class RSVP extends Managed_DataObject
|
||||
$eventTitle = $event->title;
|
||||
}
|
||||
|
||||
return sprintf($fmt,
|
||||
return sprintf(
|
||||
$fmt,
|
||||
htmlspecialchars($profile->getUrl()),
|
||||
htmlspecialchars($profile->getBestName()),
|
||||
htmlspecialchars($eventUrl),
|
||||
htmlspecialchars($eventTitle));
|
||||
htmlspecialchars($eventTitle)
|
||||
);
|
||||
}
|
||||
|
||||
static function toString($profile, $event, $response)
|
||||
public static function toString($profile, $event, $response)
|
||||
{
|
||||
$fmt = null;
|
||||
|
||||
@ -380,7 +383,7 @@ class RSVP extends Managed_DataObject
|
||||
default:
|
||||
// TRANS: Exception thrown when requesting a user's RSVP status for a non-existing response code.
|
||||
// TRANS: %s is the non-existing response code.
|
||||
throw new Exception(sprintf(_m('Unknown response code %s.'),$response));
|
||||
throw new Exception(sprintf(_m('Unknown response code %s.'), $response));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -392,9 +395,11 @@ class RSVP extends Managed_DataObject
|
||||
$eventTitle = $event->title;
|
||||
}
|
||||
|
||||
return sprintf($fmt,
|
||||
return sprintf(
|
||||
$fmt,
|
||||
$profile->getBestName(),
|
||||
$eventTitle);
|
||||
$eventTitle
|
||||
);
|
||||
}
|
||||
|
||||
public function delete($useWhere=false)
|
||||
|
@ -1,25 +1,25 @@
|
||||
<?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.
|
||||
*
|
||||
* 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/>.
|
||||
* @copyright 1012 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* DataObject class to store extended profile fields. Allows for storing
|
||||
@ -98,7 +98,7 @@ class Profile_detail extends Managed_DataObject
|
||||
],
|
||||
'primary key' => ['id'],
|
||||
'unique keys' => [
|
||||
'profile_detail_profile_id_field_name_value_index' => ['profile_id', 'field_name', 'value_index']
|
||||
'profile_detail_profile_id_field_name_value_index_key' => ['profile_id', 'field_name', 'value_index']
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -48,36 +48,49 @@ class ModLog extends Managed_DataObject
|
||||
*/
|
||||
public static function schemaDef()
|
||||
{
|
||||
return array('description' => 'Log of moderation events',
|
||||
'fields' => array(
|
||||
'id' => array('type' => 'varchar',
|
||||
return [
|
||||
'description' => 'Log of moderation events',
|
||||
'fields' => [
|
||||
'id' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 36,
|
||||
'not null' => true,
|
||||
'description' => 'unique event ID'),
|
||||
'profile_id' => array('type' => 'int',
|
||||
'description' => 'unique event ID',
|
||||
],
|
||||
'profile_id' => [
|
||||
'type' => 'int',
|
||||
'not null' => true,
|
||||
'description' => 'profile getting the role'),
|
||||
'moderator_id' => array('type' => 'int',
|
||||
'description' => 'profile granting or revoking the role'),
|
||||
'role' => array('type' => 'varchar',
|
||||
'description' => 'profile getting the role',
|
||||
],
|
||||
'moderator_id' => [
|
||||
'type' => 'int',
|
||||
'description' => 'profile granting or revoking the role',
|
||||
],
|
||||
'role' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 32,
|
||||
'not null' => true,
|
||||
'description' => 'role granted or revoked'),
|
||||
'is_grant' => array('type' => 'bool',
|
||||
'description' => 'role granted or revoked',
|
||||
],
|
||||
'is_grant' => [
|
||||
'type' => 'bool',
|
||||
'default' => true,
|
||||
'description' => 'Was this a grant or revocation of a role'),
|
||||
'created' => array('type' => 'datetime',
|
||||
'description' => 'Was this a grant or revocation of a role',
|
||||
],
|
||||
'created' => [
|
||||
'type' => 'datetime',
|
||||
'not null' => true,
|
||||
'description' => 'date this record was created')
|
||||
),
|
||||
'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('moderator_id' => 'id'))
|
||||
),
|
||||
'indexes' => array(
|
||||
'mod_log_profile_id_created_idx' => array('profile_id', 'created'),
|
||||
),
|
||||
);
|
||||
'description' => 'date this record was created',
|
||||
],
|
||||
],
|
||||
'primary key' => ['id'],
|
||||
'foreign keys' => [
|
||||
'modlog_profile_id_fkey' => ['profile', ['profile_id' => 'id']],
|
||||
'modlog_moderator_id_fkey' => ['user', ['moderator_id' => 'id']],
|
||||
],
|
||||
'indexes' => [
|
||||
'modlog_profile_id_created_idx' => ['profile_id', 'created'],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -53,9 +53,6 @@ class Usage_stats extends Managed_DataObject
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['type'],
|
||||
'indexes' => [
|
||||
'user_stats_idx' => ['type'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -1,45 +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/>.
|
||||
|
||||
/**
|
||||
* StatusNet - the distributed open-source microblogging tool
|
||||
* Copyright (C) 2012, StatusNet, Inc.
|
||||
*
|
||||
* User_openid_prefs.php
|
||||
*
|
||||
* 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 OpenID
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2012 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')) {
|
||||
exit(1);
|
||||
}
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Store preferences for OpenID use in StatusNet
|
||||
*
|
||||
* @category OpenID
|
||||
* @package StatusNet
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
@ -85,9 +78,9 @@ class User_openid_prefs extends Managed_DataObject
|
||||
],
|
||||
],
|
||||
'primary key' => ['user_id'],
|
||||
'foreign keys' => ['user_openid_prefs_user_id_fkey' => ['user', ['user_id' => 'id']],
|
||||
'foreign keys' => [
|
||||
'user_openid_prefs_user_id_fkey' => ['user', ['user_id' => 'id']],
|
||||
],
|
||||
'indexes' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
* @category PollPlugin
|
||||
* @package GNUsocial
|
||||
* @author Brion Vibber <brion@status.net>
|
||||
* @copyright 2011, StatusNet, Inc.
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
@ -29,7 +29,7 @@ defined('GNUSOCIAL') || die();
|
||||
/**
|
||||
* For storing the poll options and such
|
||||
*
|
||||
* @copyright 2011, StatusNet, Inc.
|
||||
* @copyright 2011 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
@ -65,7 +65,7 @@ class Poll_response extends Managed_DataObject
|
||||
'poll_response_poll_id_profile_id_key' => array('poll_id', 'profile_id'),
|
||||
),
|
||||
'indexes' => array(
|
||||
'poll_response_profile_id_poll_id_index' => array('profile_id', 'poll_id'),
|
||||
'poll_response_profile_id_poll_id_idx' => array('profile_id', 'poll_id'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class SearchSub extends Managed_DataObject
|
||||
),
|
||||
'indexes' => array(
|
||||
'searchsub_created_idx' => array('created'),
|
||||
'searchsub_profile_id_tag_idx' => array('profile_id', 'search'),
|
||||
'searchsub_profile_id_search_idx' => array('profile_id', 'search'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class Notice_to_status extends Managed_DataObject
|
||||
),
|
||||
'primary key' => array('notice_id'),
|
||||
'unique keys' => array(
|
||||
'status_id_key' => array('status_id'),
|
||||
'notice_to_status_status_id_key' => array('status_id'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'notice_to_status_notice_id_fkey' => array('notice', array('notice_id' => 'id')),
|
||||
|
Loading…
Reference in New Issue
Block a user