[SCHEMA] Improve timestamp storage
Avoid the use of deprecated MariaDB "zero dates" globally. If they're present as attribute defaults somewhere, they will be replaced with NULL implicitly. The existing "zero dates" in MariaDB storage will be left intact and this should not present any issues. The "timestamp" type in table definitions now corresponds to DATETIME in MariaDB with "DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP", which should be close enough to the original behaviour for compatibility purposes. It is now the recommended type for "modified" attributes, because of the update trigger on MariaDB. But there is no such trigger implemented on PostgreSQL as of this moment.
This commit is contained in:
@@ -47,8 +47,8 @@ class Activitypub_profile extends Managed_DataObject
|
||||
public $homepage; // text()
|
||||
public $bio; // text() multiple_key
|
||||
public $location; // text()
|
||||
public $created; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/**
|
||||
* Return table definition for Schema setup and DB_DataObject usage.
|
||||
@@ -64,8 +64,8 @@ class Activitypub_profile extends Managed_DataObject
|
||||
'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'],
|
||||
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||
'created' => ['type' => 'datetime', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['profile_id'],
|
||||
'foreign keys' => [
|
||||
|
@@ -40,8 +40,8 @@ class Activitypub_rsa extends Managed_DataObject
|
||||
public $profile_id; // int(4) primary_key not_null
|
||||
public $private_key; // text() not_null
|
||||
public $public_key; // text() not_null
|
||||
public $created; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/**
|
||||
* Return table definition for Schema setup and DB_DataObject usage.
|
||||
@@ -56,8 +56,8 @@ class Activitypub_rsa extends Managed_DataObject
|
||||
'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'],
|
||||
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||
'created' => ['type' => 'datetime', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['profile_id'],
|
||||
'foreign keys' => [
|
||||
|
@@ -1,48 +1,41 @@
|
||||
<?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 favorites talley
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Data
|
||||
* @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) 2010, StatusNet, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @category Data
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Data class for favorites tally
|
||||
*
|
||||
* A class representing a total number of times a notice has been favored
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @category Action
|
||||
* @package GNUsocial
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class Fave_tally extends Managed_DataObject
|
||||
{
|
||||
@@ -52,8 +45,8 @@ class Fave_tally extends Managed_DataObject
|
||||
public $__table = 'fave_tally'; // table name
|
||||
public $notice_id; // int(4) primary_key not_null
|
||||
public $count; // int(4) not_null
|
||||
public $created; // datetime() not_null
|
||||
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -64,7 +57,7 @@ class Fave_tally extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'notice id'),
|
||||
'count' => array('type' => 'int', 'not null' => true, 'description' => 'the fave tally count'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('notice_id'),
|
||||
@@ -81,7 +74,7 @@ class Fave_tally extends Managed_DataObject
|
||||
*
|
||||
* @return Fave_tally $tally the tally data object
|
||||
*/
|
||||
static function increment($noticeID)
|
||||
public static function increment($noticeID)
|
||||
{
|
||||
$tally = Fave_tally::ensureTally($noticeID);
|
||||
|
||||
@@ -109,7 +102,7 @@ class Fave_tally extends Managed_DataObject
|
||||
*
|
||||
* @return Fave_tally $tally the tally data object
|
||||
*/
|
||||
static function decrement($noticeID)
|
||||
public static function decrement($noticeID)
|
||||
{
|
||||
$tally = Fave_tally::ensureTally($noticeID);
|
||||
|
||||
@@ -140,7 +133,7 @@ class Fave_tally extends Managed_DataObject
|
||||
*
|
||||
* @return Fave_tally the tally data object
|
||||
*/
|
||||
static function ensureTally($noticeID)
|
||||
public static function ensureTally($noticeID)
|
||||
{
|
||||
$tally = Fave_tally::getKV('notice_id', $noticeID);
|
||||
|
||||
@@ -172,7 +165,7 @@ class Fave_tally extends Managed_DataObject
|
||||
*
|
||||
* @return integer $total total number of time the notice has been favored
|
||||
*/
|
||||
static function countExistingFaves($noticeID)
|
||||
public static function countExistingFaves($noticeID)
|
||||
{
|
||||
$fave = new Fave();
|
||||
$fave->notice_id = $noticeID;
|
||||
|
@@ -20,21 +20,19 @@
|
||||
* @category Data
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2010, StatusNet, Inc.
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
|
||||
/**
|
||||
* Data class for email summaries
|
||||
*
|
||||
* Email summary information for users
|
||||
*
|
||||
* @category Action
|
||||
* @copyright 2010, StatusNet, Inc.
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
@@ -55,7 +53,7 @@ class Email_summary_status extends Managed_DataObject
|
||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
|
||||
'send_summary' => array('type' => 'bool', 'default' => true, 'not null' => true, 'description' => 'whether to send a summary or not'),
|
||||
'last_summary_id' => array('type' => 'int', 'description' => 'last summary id'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('user_id'),
|
||||
|
@@ -18,7 +18,7 @@
|
||||
* Allows administrators to define additional profile fields for the users of a GNU social installation.
|
||||
*
|
||||
* @category Widget
|
||||
* @package GNU social
|
||||
* @package GNUsocial
|
||||
* @author Max Shinn <trombonechamp@gmail.com>
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
@@ -35,8 +35,8 @@ class GNUsocialProfileExtensionField extends Managed_DataObject
|
||||
public $title; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $description; // text
|
||||
public $type; // varchar(191) not 255 because utf8mb4 takes more space
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef(): array
|
||||
{
|
||||
@@ -47,8 +47,8 @@ class GNUsocialProfileExtensionField extends Managed_DataObject
|
||||
'title' => ['type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'field title'],
|
||||
'description' => ['type' => 'text', 'not null' => true, 'description' => 'field description'],
|
||||
'type' => ['type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'field type'],
|
||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||
'created' => ['type' => 'datetime', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['id'],
|
||||
'indexes' => [
|
||||
|
@@ -18,7 +18,7 @@
|
||||
* Allows administrators to define additional profile fields for the users of a GNU social installation.
|
||||
*
|
||||
* @category Widget
|
||||
* @package GNU social
|
||||
* @package GNUsocial
|
||||
* @author Max Shinn <trombonechamp@gmail.com>
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
* @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
|
||||
@@ -34,8 +34,8 @@ class GNUsocialProfileExtensionResponse extends Managed_DataObject
|
||||
public $extension_id; // int(11)
|
||||
public $profile_id; // int(11)
|
||||
public $value; // text
|
||||
public $created; // datetime() not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
public static function schemaDef(): array
|
||||
{
|
||||
@@ -45,8 +45,8 @@ class GNUsocialProfileExtensionResponse extends Managed_DataObject
|
||||
'extension_id' => ['type' => 'int', 'not null' => true, 'description' => 'The extension field ID'],
|
||||
'profile_id' => ['type' => 'int', 'not null' => true, 'description' => 'Profile id that made the response'],
|
||||
'value' => ['type' => 'text', 'not null' => true, 'description' => 'response entry'],
|
||||
'created' => ['type' => 'datetime', 'not null' => true, 'default' => '0000-00-00 00:00:00', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||
'created' => ['type' => 'datetime', 'description' => 'date this record was created'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['id'],
|
||||
// Syntax: foreign_key_name => [remote_table, local_key => remote_key]]
|
||||
|
@@ -36,7 +36,7 @@ class Usage_stats extends Managed_DataObject
|
||||
public $__table = 'usage_stats'; // table name
|
||||
public $type; // varchar(191) unique_key not 255 because utf8mb4 takes more space
|
||||
public $count; // int(4)
|
||||
public $modified; // datetime() not_null default_CURRENT_TIMESTAMP
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
/**
|
||||
* Table Definition for usage_stats
|
||||
@@ -50,7 +50,7 @@ class Usage_stats extends Managed_DataObject
|
||||
'fields' => [
|
||||
'type' => ['type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'Type of countable entity'],
|
||||
'count' => ['type' => 'int', 'size' => 'int', 'default' => 0, 'description' => 'Number of entities of this type'],
|
||||
'modified' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
|
||||
],
|
||||
'primary key' => ['type'],
|
||||
'indexes' => [
|
||||
|
@@ -63,8 +63,8 @@ class Ostatus_profile extends Managed_DataObject
|
||||
'feeduri' => array('type' => 'varchar', 'length' => 191),
|
||||
'salmonuri' => array('type' => 'varchar', 'length' => 191),
|
||||
'avatar' => array('type' => 'text'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true),
|
||||
'modified' => array('type' => 'datetime', 'not null' => true),
|
||||
'created' => array('type' => 'datetime'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true),
|
||||
),
|
||||
'primary key' => array('uri'),
|
||||
'unique keys' => array(
|
||||
|
@@ -20,14 +20,12 @@
|
||||
* @category Data
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2010, StatusNet, Inc.
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
|
||||
/**
|
||||
* Data class for counting notices by date
|
||||
*
|
||||
@@ -38,10 +36,10 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
* of notices posted on that day. Since, after the end of the day,
|
||||
* this number doesn't change, it's a good candidate for persistent caching.
|
||||
*
|
||||
* @copyright 2010, StatusNet, Inc.
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
class Sitemap_notice_count extends Managed_DataObject
|
||||
{
|
||||
@@ -49,8 +47,8 @@ class Sitemap_notice_count extends Managed_DataObject
|
||||
|
||||
public $notice_date; // date primary_key not_null
|
||||
public $notice_count; // int(4)
|
||||
public $created; // datetime() not_null
|
||||
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -58,7 +56,7 @@ class Sitemap_notice_count extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'notice_date' => array('type' => 'date', 'not null' => true, 'description' => 'record date'),
|
||||
'notice_count' => array('type' => 'int', 'not null' => true, 'description' => 'the notice count'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('notice_date'),
|
||||
|
@@ -20,24 +20,22 @@
|
||||
* @category Data
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2010, StatusNet, Inc.
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
|
||||
/**
|
||||
* Data class for counting users by date
|
||||
*
|
||||
* We make a separate sitemap for each user registered by date.
|
||||
* To save ourselves some processing effort, we cache this data
|
||||
*
|
||||
* @copyright 2010, StatusNet, Inc.
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
class Sitemap_user_count extends Managed_DataObject
|
||||
{
|
||||
@@ -45,8 +43,8 @@ class Sitemap_user_count extends Managed_DataObject
|
||||
|
||||
public $registration_date; // date primary_key not_null
|
||||
public $user_count; // int(4)
|
||||
public $created; // datetime() not_null
|
||||
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -54,7 +52,7 @@ class Sitemap_user_count extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'registration_date' => array('type' => 'date', 'not null' => true, 'description' => 'record date'),
|
||||
'user_count' => array('type' => 'int', 'not null' => true, 'description' => 'the user count of the recorded date'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('registration_date'),
|
||||
|
@@ -1,65 +1,57 @@
|
||||
<?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 remembering notice-to-status mappings
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Data
|
||||
* @package StatusNet
|
||||
* @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) 2010, StatusNet, Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* @category Data
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Data class for mapping notices to statuses
|
||||
*
|
||||
* Notices flow back and forth between Twitter and StatusNet. We use this
|
||||
* table to remember which StatusNet notice corresponds to which Twitter
|
||||
* Notices flow back and forth between Twitter and GNU social. We use this
|
||||
* table to remember which GNU social notice corresponds to which Twitter
|
||||
* status.
|
||||
*
|
||||
* Note that notice_id is unique only within a single database; if you
|
||||
* want to share this data for some reason, get the notice's URI and use
|
||||
* that instead, since it's universally unique.
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @category Action
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2010 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*
|
||||
* @see DB_DataObject
|
||||
* @see DB_DataObject
|
||||
*/
|
||||
|
||||
class Notice_to_status extends Managed_DataObject
|
||||
{
|
||||
public $__table = 'notice_to_status'; // table name
|
||||
public $notice_id; // int(4) primary_key not_null
|
||||
public $status_id; // bigint not_null
|
||||
public $created; // datetime() not_null
|
||||
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null
|
||||
|
||||
public static function schemaDef()
|
||||
{
|
||||
@@ -67,7 +59,7 @@ class Notice_to_status extends Managed_DataObject
|
||||
'fields' => array(
|
||||
'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'local notice id'),
|
||||
'status_id' => array('type' => 'int', 'size' => 'big', 'not null' => true, 'description' => 'twitter status id'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('notice_id'),
|
||||
@@ -89,7 +81,7 @@ class Notice_to_status extends Managed_DataObject
|
||||
*
|
||||
* @return Notice_to_status new object for this value
|
||||
*/
|
||||
static function saveNew($notice_id, $status_id)
|
||||
public static function saveNew($notice_id, $status_id)
|
||||
{
|
||||
if (empty($notice_id)) {
|
||||
throw new Exception("Invalid notice_id $notice_id");
|
||||
|
@@ -1,48 +1,41 @@
|
||||
<?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 profile flags
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Data
|
||||
* @package StatusNet
|
||||
* @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) 2009, 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 Data
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
||||
defined('GNUSOCIAL') || die();
|
||||
|
||||
/**
|
||||
* Data class for profile flags
|
||||
*
|
||||
* A class representing a user flagging another profile for review.
|
||||
*
|
||||
* @category Action
|
||||
* @package StatusNet
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||
* @link http://status.net/
|
||||
* @category Action
|
||||
* @package GNUsocial
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class User_flag_profile extends Managed_DataObject
|
||||
{
|
||||
@@ -52,9 +45,9 @@ class User_flag_profile extends Managed_DataObject
|
||||
public $__table = 'user_flag_profile'; // table name
|
||||
public $profile_id; // int(11) primary_key not_null
|
||||
public $user_id; // int(11) primary_key not_null
|
||||
public $cleared; // datetime default_0000-00-00%2000%3A00%3A00
|
||||
public $created; // datetime() not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
public $cleared; // datetime()
|
||||
public $created; // datetime()
|
||||
public $modified; // timestamp() not_null
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@@ -66,7 +59,7 @@ class User_flag_profile extends Managed_DataObject
|
||||
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'profile id flagged'),
|
||||
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id of the actor'),
|
||||
'cleared' => array('type' => 'datetime', 'description' => 'when flag was removed'),
|
||||
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
||||
'created' => array('type' => 'datetime', 'description' => 'date this record was created'),
|
||||
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
||||
),
|
||||
'primary key' => array('profile_id', 'user_id'),
|
||||
@@ -85,7 +78,7 @@ class User_flag_profile extends Managed_DataObject
|
||||
*
|
||||
* @return boolean true if exists, else false
|
||||
*/
|
||||
static function exists($profile_id, $user_id)
|
||||
public static function exists($profile_id, $user_id)
|
||||
{
|
||||
$ufp = User_flag_profile::pkeyGet(array('profile_id' => $profile_id,
|
||||
'user_id' => $user_id));
|
||||
@@ -101,7 +94,7 @@ class User_flag_profile extends Managed_DataObject
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
static function create($user_id, $profile_id)
|
||||
public static function create($user_id, $profile_id)
|
||||
{
|
||||
$ufp = new User_flag_profile();
|
||||
|
||||
@@ -112,8 +105,10 @@ class User_flag_profile extends Managed_DataObject
|
||||
if (!$ufp->insert()) {
|
||||
// TRANS: Server exception.
|
||||
// TRANS: %d is a profile ID (number).
|
||||
$msg = sprintf(_m('Could not flag profile "%d" for review.'),
|
||||
$profile_id);
|
||||
$msg = sprintf(
|
||||
_m('Could not flag profile "%d" for review.'),
|
||||
$profile_id
|
||||
);
|
||||
throw new ServerException($msg);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user