2010-10-27 04:21:30 +09:00
|
|
|
<?php
|
2019-09-11 17:25:39 +09:00
|
|
|
// 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/>.
|
|
|
|
|
2010-10-27 04:21:30 +09:00
|
|
|
/**
|
|
|
|
* Data class for counting greetings
|
|
|
|
*
|
2019-09-11 17:25:39 +09:00
|
|
|
* @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
|
2010-10-27 04:21:30 +09:00
|
|
|
*/
|
|
|
|
|
2019-09-11 17:25:39 +09:00
|
|
|
defined('GNUSOCIAL') || die();
|
2010-10-27 04:21:30 +09:00
|
|
|
|
|
|
|
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data class for counting greetings
|
|
|
|
*
|
|
|
|
* We use the DB_DataObject framework for data classes in StatusNet. Each
|
|
|
|
* table maps to a particular data class, making it easier to manipulate
|
|
|
|
* data.
|
|
|
|
*
|
|
|
|
* Data classes should extend Memcached_DataObject, the (slightly misnamed)
|
|
|
|
* extension of DB_DataObject that provides caching, internationalization,
|
|
|
|
* and other bits of good functionality to StatusNet-specific data classes.
|
|
|
|
*
|
2019-09-11 17:25:39 +09:00
|
|
|
* @category Action
|
|
|
|
* @copyright 2009, StatusNet, Inc.
|
|
|
|
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
2010-10-27 04:21:30 +09:00
|
|
|
*
|
2019-09-11 17:25:39 +09:00
|
|
|
* @see DB_DataObject
|
2010-10-27 04:21:30 +09:00
|
|
|
*/
|
2013-08-18 19:10:44 +09:00
|
|
|
class User_followeveryone_prefs extends Managed_DataObject
|
2010-10-27 04:21:30 +09:00
|
|
|
{
|
|
|
|
public $__table = 'user_followeveryone_prefs'; // table name
|
|
|
|
public $user_id; // int(4) primary_key not_null
|
2019-09-11 17:25:39 +09:00
|
|
|
public $followeveryone; // bool default_true
|
2013-08-20 00:08:18 +09:00
|
|
|
public $created; // datetime() not_null
|
|
|
|
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
2010-10-27 04:21:30 +09:00
|
|
|
|
2013-08-20 00:08:18 +09:00
|
|
|
public static function schemaDef()
|
2010-10-27 04:21:30 +09:00
|
|
|
{
|
2013-08-20 00:08:18 +09:00
|
|
|
return array(
|
|
|
|
'fields' => array(
|
|
|
|
'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
|
2019-09-11 17:25:39 +09:00
|
|
|
'followeveryone' => array('type' => 'bool', 'default' => true, 'description' => 'whether to follow everyone'),
|
2013-08-20 00:08:18 +09:00
|
|
|
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
|
|
|
|
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
|
|
|
|
),
|
|
|
|
'primary key' => array('user_id'),
|
|
|
|
'foreign keys' => array(
|
|
|
|
'user_followeveryone_prefs_user_id_fkey' => array('user', array('user_id' => 'id')),
|
|
|
|
),
|
|
|
|
);
|
2010-10-27 04:21:30 +09:00
|
|
|
}
|
|
|
|
|
2019-09-11 17:25:39 +09:00
|
|
|
public static function followEveryone($user_id)
|
2010-10-27 04:21:30 +09:00
|
|
|
{
|
2013-08-18 20:04:58 +09:00
|
|
|
$ufep = self::getKV('user_id', $user_id);
|
2010-10-27 04:21:30 +09:00
|
|
|
|
|
|
|
if (empty($ufep)) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return (bool)$ufep->followeveryone;
|
|
|
|
}
|
|
|
|
}
|
2010-10-27 04:33:35 +09:00
|
|
|
|
2019-09-11 17:25:39 +09:00
|
|
|
public static function savePref($user_id, $followEveryone)
|
2010-10-27 04:33:35 +09:00
|
|
|
{
|
2013-08-18 20:04:58 +09:00
|
|
|
$ufep = self::getKV('user_id', $user_id);
|
2010-10-27 04:33:35 +09:00
|
|
|
|
|
|
|
if (empty($ufep)) {
|
|
|
|
$ufep = new User_followeveryone_prefs();
|
|
|
|
$ufep->user_id = $user_id;
|
|
|
|
$ufep->followeveryone = $followEveryone;
|
|
|
|
$ufep->insert();
|
|
|
|
} else {
|
|
|
|
$orig = clone($ufep);
|
|
|
|
$ufep->followeveryone = $followEveryone;
|
|
|
|
$ufep->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-10-27 04:21:30 +09:00
|
|
|
}
|