2015-08-18 23:29:45 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Everything you'd ever need from a specific user
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Sakura;
|
|
|
|
|
2015-12-29 21:52:19 +00:00
|
|
|
use Sakura\Perms;
|
|
|
|
use Sakura\Perms\Site;
|
|
|
|
|
2015-10-18 19:06:30 +00:00
|
|
|
/**
|
|
|
|
* Class User
|
|
|
|
* @package Sakura
|
|
|
|
*/
|
2015-09-14 20:51:23 +00:00
|
|
|
class User
|
|
|
|
{
|
2015-08-18 23:29:45 +00:00
|
|
|
// User data
|
2015-11-08 22:27:42 +00:00
|
|
|
private $data = [
|
|
|
|
'user_id' => 0,
|
|
|
|
'username' => 'User',
|
|
|
|
'username_clean' => 'user',
|
|
|
|
'password_hash' => '',
|
|
|
|
'password_salt' => '',
|
2015-12-31 14:51:01 +00:00
|
|
|
'password_algo' => 'disabled',
|
2015-11-08 22:27:42 +00:00
|
|
|
'password_iter' => 0,
|
|
|
|
'password_chan' => 0,
|
|
|
|
'email' => 'sakura@localhost',
|
2015-12-29 21:52:19 +00:00
|
|
|
'rank_main' => 1,
|
2015-11-08 22:27:42 +00:00
|
|
|
'user_colour' => '',
|
|
|
|
'register_ip' => '127.0.0.1',
|
|
|
|
'last_ip' => '127.0.0.1',
|
|
|
|
'user_title' => '',
|
|
|
|
'user_registered' => 0,
|
|
|
|
'user_last_online' => 0,
|
|
|
|
'user_birthday' => '',
|
|
|
|
'user_country' => 'XX',
|
|
|
|
'user_data' => '[]',
|
|
|
|
];
|
2015-11-07 22:58:02 +00:00
|
|
|
private $ranks = [];
|
|
|
|
private $mainRank = [];
|
2015-12-29 21:52:19 +00:00
|
|
|
private $permissions;
|
2015-12-29 01:27:49 +00:00
|
|
|
protected static $_userCache = [];
|
|
|
|
|
|
|
|
// Static initialiser
|
2016-01-02 17:55:31 +00:00
|
|
|
public static function construct($uid, $forceRefresh = false)
|
|
|
|
{
|
2015-12-29 01:27:49 +00:00
|
|
|
// Check if a user object isn't present in cache
|
|
|
|
if ($forceRefresh || !array_key_exists($uid, self::$_userCache)) {
|
|
|
|
// If not create a new object and cache it
|
|
|
|
self::$_userCache[$uid] = new User($uid);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the cached object
|
|
|
|
return self::$_userCache[$uid];
|
|
|
|
}
|
2015-08-18 23:29:45 +00:00
|
|
|
|
2016-01-04 20:14:09 +00:00
|
|
|
// Creating a new user
|
|
|
|
public static function create($username, $password, $email, $ranks = [2])
|
|
|
|
{
|
|
|
|
// Set a few variables
|
|
|
|
$usernameClean = Main::cleanString($username, true);
|
|
|
|
$emailClean = Main::cleanString($email, true);
|
|
|
|
$password = Hashing::createHash($password);
|
|
|
|
|
|
|
|
// Insert the user into the database
|
|
|
|
Database::insert('users', [
|
|
|
|
'username' => $username,
|
|
|
|
'username_clean' => $usernameClean,
|
|
|
|
'password_hash' => $password[3],
|
|
|
|
'password_salt' => $password[2],
|
|
|
|
'password_algo' => $password[0],
|
|
|
|
'password_iter' => $password[1],
|
|
|
|
'email' => $emailClean,
|
|
|
|
'rank_main' => 0,
|
|
|
|
'register_ip' => Main::getRemoteIP(),
|
|
|
|
'last_ip' => Main::getRemoteIP(),
|
|
|
|
'user_registered' => time(),
|
|
|
|
'user_last_online' => 0,
|
|
|
|
'user_country' => Main::getCountryCode(),
|
|
|
|
'user_data' => '[]',
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Get the last id
|
|
|
|
$userId = Database::lastInsertID();
|
|
|
|
|
|
|
|
// Create a user object
|
|
|
|
$user = self::construct($userId);
|
|
|
|
|
|
|
|
// Assign the default rank
|
|
|
|
$user->addRanks($ranks);
|
|
|
|
|
|
|
|
// Set the default rank
|
|
|
|
$user->setMainRank($ranks[0]);
|
|
|
|
|
|
|
|
// Return the user object
|
|
|
|
return $user;
|
|
|
|
}
|
|
|
|
|
2015-08-19 02:37:45 +00:00
|
|
|
// Initialise the user object
|
2015-12-29 01:27:49 +00:00
|
|
|
private function __construct($uid)
|
2015-09-14 20:51:23 +00:00
|
|
|
{
|
2015-08-18 23:29:45 +00:00
|
|
|
// Get the user database row
|
2015-11-08 22:27:42 +00:00
|
|
|
$getUser = Database::fetch(
|
2015-09-14 21:41:43 +00:00
|
|
|
'users',
|
|
|
|
false,
|
|
|
|
[
|
2015-10-10 21:17:50 +00:00
|
|
|
'user_id' => [$uid, '=', true],
|
2015-09-14 21:41:43 +00:00
|
|
|
'username_clean' => [Main::cleanString($uid, true), '=', true],
|
|
|
|
]
|
|
|
|
);
|
2015-08-21 22:07:45 +00:00
|
|
|
|
2015-08-19 02:37:45 +00:00
|
|
|
// Check if the user actually exists
|
2015-11-08 22:27:42 +00:00
|
|
|
if (!empty($getUser)) {
|
2015-08-19 02:37:45 +00:00
|
|
|
// If not assign as the fallback user
|
2015-11-08 22:27:42 +00:00
|
|
|
$this->data = $getUser;
|
2015-08-19 02:37:45 +00:00
|
|
|
}
|
|
|
|
|
2015-10-10 21:17:50 +00:00
|
|
|
// Decode the json in the user_data column
|
|
|
|
$this->data['user_data'] = json_decode(!empty($this->data['user_data']) ? $this->data['user_data'] : '[]', true);
|
2016-01-03 21:19:37 +00:00
|
|
|
|
|
|
|
// Get all ranks
|
|
|
|
$ranks = array_map(function($a) {
|
|
|
|
return $a['rank_id'];
|
|
|
|
}, Database::fetch('user_ranks', true, ['user_id' => [$this->data['user_id'], '=']]));
|
2015-08-18 23:29:45 +00:00
|
|
|
|
|
|
|
// Get the rows for all the ranks
|
2016-01-03 21:19:37 +00:00
|
|
|
foreach ($ranks as $rank) {
|
2015-08-19 02:37:45 +00:00
|
|
|
// Store the database row in the array
|
2015-12-29 21:52:19 +00:00
|
|
|
$this->ranks[$rank] = Rank::construct($rank);
|
2015-08-19 02:37:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if ranks were set
|
2015-09-14 20:51:23 +00:00
|
|
|
if (empty($this->ranks)) {
|
2015-08-19 02:37:45 +00:00
|
|
|
// If not assign the fallback rank
|
2016-01-04 20:14:09 +00:00
|
|
|
$this->ranks[1] = Rank::construct(1);
|
2015-08-19 02:37:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Assign the user's main rank to a special variable since we'll use it a lot
|
2015-09-14 21:41:43 +00:00
|
|
|
$this->mainRank = $this->ranks[
|
|
|
|
array_key_exists($this->data['rank_main'], $this->ranks) ?
|
|
|
|
$this->data['rank_main'] :
|
|
|
|
array_keys($this->ranks)[0]
|
|
|
|
];
|
2015-12-29 21:52:19 +00:00
|
|
|
|
|
|
|
// Init the permissions
|
|
|
|
$this->permissions = new Perms(Perms::SITE);
|
2015-08-19 02:37:45 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 22:58:02 +00:00
|
|
|
// Get user id
|
|
|
|
public function id()
|
2015-09-14 20:51:23 +00:00
|
|
|
{
|
2015-11-07 22:58:02 +00:00
|
|
|
return $this->data['user_id'];
|
|
|
|
}
|
2015-08-21 22:07:45 +00:00
|
|
|
|
2015-11-07 22:58:02 +00:00
|
|
|
// Get username (or clean variant)
|
|
|
|
public function username($clean = false)
|
|
|
|
{
|
|
|
|
return $this->data['username' . ($clean ? '_clean' : '')];
|
|
|
|
}
|
2015-08-21 22:07:45 +00:00
|
|
|
|
2015-11-07 22:58:02 +00:00
|
|
|
// Get password data
|
|
|
|
public function password()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'password_hash' => $this->data['password_hash'],
|
|
|
|
'password_salt' => $this->data['password_salt'],
|
|
|
|
'password_algo' => $this->data['password_algo'],
|
|
|
|
'password_iter' => $this->data['password_iter'],
|
|
|
|
'password_chan' => $this->data['password_chan'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get email
|
|
|
|
public function email()
|
|
|
|
{
|
|
|
|
return $this->data['email'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get main rank id
|
|
|
|
public function mainRank()
|
|
|
|
{
|
|
|
|
return $this->data['rank_main'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get all rank ids
|
2016-01-03 21:19:37 +00:00
|
|
|
public function ranks($obj = false)
|
2015-11-07 22:58:02 +00:00
|
|
|
{
|
2016-01-03 21:19:37 +00:00
|
|
|
return $obj ? $this->ranks : array_keys($this->ranks);
|
2015-08-21 22:07:45 +00:00
|
|
|
}
|
|
|
|
|
2015-08-19 02:37:45 +00:00
|
|
|
// Get the user's colour
|
2015-09-14 20:51:23 +00:00
|
|
|
public function colour()
|
|
|
|
{
|
2015-10-14 19:35:16 +00:00
|
|
|
return empty($this->data['user_colour']) ? $this->mainRank->colour() : $this->data['user_colour'];
|
2015-08-19 02:37:45 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 22:58:02 +00:00
|
|
|
// Get the user's ip
|
|
|
|
public function ip($last = false)
|
|
|
|
{
|
|
|
|
return $this->data[($last ? 'last' : 'register') . '_ip'];
|
|
|
|
}
|
|
|
|
|
2015-08-19 02:37:45 +00:00
|
|
|
// Get the user's title
|
2015-09-14 20:51:23 +00:00
|
|
|
public function userTitle()
|
|
|
|
{
|
2015-10-14 19:35:16 +00:00
|
|
|
return empty($this->data['user_title']) ? $this->mainRank->title() : $this->data['user_title'];
|
2015-08-19 02:37:45 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 22:58:02 +00:00
|
|
|
// Get user event times
|
|
|
|
public function dates()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'joined' => $this->data['user_registered'],
|
|
|
|
'lastOnline' => $this->data['user_last_online'],
|
|
|
|
'birth' => $this->data['user_birthday'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2015-08-19 02:37:45 +00:00
|
|
|
// Get the user's long and short country names
|
2015-09-14 20:51:23 +00:00
|
|
|
public function country()
|
|
|
|
{
|
2015-08-19 02:37:45 +00:00
|
|
|
return [
|
2015-10-10 21:17:50 +00:00
|
|
|
'long' => Main::getCountryName($this->data['user_country']),
|
|
|
|
'short' => $this->data['user_country'],
|
2015-08-19 02:37:45 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2015-11-07 22:58:02 +00:00
|
|
|
// Get the user's raw additional settings
|
|
|
|
public function userData()
|
|
|
|
{
|
|
|
|
return $this->data['user_data'];
|
|
|
|
}
|
|
|
|
|
2015-08-19 12:13:38 +00:00
|
|
|
// Check if a user is online
|
2015-11-10 23:34:48 +00:00
|
|
|
public function isOnline()
|
2015-09-14 20:51:23 +00:00
|
|
|
{
|
2015-11-11 21:54:56 +00:00
|
|
|
// Get all sessions
|
|
|
|
$sessions = Database::fetch('sessions', true, ['user_id' => [$this->id(), '=']]);
|
|
|
|
|
|
|
|
// If there's no entries just straight up return false
|
2015-11-11 21:56:03 +00:00
|
|
|
if (!$sessions) {
|
2015-11-11 21:54:56 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise use the standard method
|
2015-12-04 14:19:10 +00:00
|
|
|
return $this->data['user_last_online'] > (time() - Config::get('max_online_time'));
|
2015-08-19 12:13:38 +00:00
|
|
|
}
|
|
|
|
|
2015-11-10 23:34:48 +00:00
|
|
|
// Compatibility
|
|
|
|
public function checkOnline()
|
|
|
|
{
|
|
|
|
return $this->isOnline();
|
|
|
|
}
|
|
|
|
|
2015-08-19 12:13:38 +00:00
|
|
|
// Get user's forum statistics
|
2015-09-14 20:51:23 +00:00
|
|
|
public function forumStats()
|
|
|
|
{
|
2015-12-11 20:49:40 +00:00
|
|
|
return [
|
|
|
|
'posts' => Database::count(
|
|
|
|
'posts',
|
|
|
|
['poster_id' => [$this->id(), '=']]
|
|
|
|
)[0],
|
|
|
|
'topics' => count(Database::fetch(
|
|
|
|
'posts',
|
|
|
|
true,
|
|
|
|
['poster_id' => [$this->id(), '=']],
|
|
|
|
['post_time'],
|
|
|
|
null,
|
|
|
|
['topic_id']
|
|
|
|
)),
|
|
|
|
];
|
2015-08-19 12:13:38 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 22:58:02 +00:00
|
|
|
// Get amount of time since user events using the same format as dates()
|
|
|
|
public function elapsed($append = ' ago', $none = 'Just now')
|
|
|
|
{
|
|
|
|
$times = [];
|
|
|
|
|
|
|
|
foreach ($this->dates() as $key => $val) {
|
|
|
|
$times[$key] = Main::timeElapsed(is_string($val) ? strtotime($val) : $val, $append, $none);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $times;
|
|
|
|
}
|
|
|
|
|
2015-11-11 21:54:56 +00:00
|
|
|
// Add ranks to a user
|
2015-11-11 21:56:03 +00:00
|
|
|
public function addRanks($ranks)
|
|
|
|
{
|
2015-11-11 21:54:56 +00:00
|
|
|
// Update the ranks array
|
2016-01-03 21:19:37 +00:00
|
|
|
$ranks = array_diff(array_unique(array_merge($this->ranks(), $ranks)), $this->ranks());
|
2015-11-11 21:54:56 +00:00
|
|
|
|
|
|
|
// Save to the database
|
2016-01-03 21:19:37 +00:00
|
|
|
foreach ($ranks as $rank) {
|
|
|
|
Database::insert('user_ranks', [
|
|
|
|
'rank_id' => $rank,
|
|
|
|
'user_id' => $this->id(),
|
|
|
|
]);
|
|
|
|
}
|
2015-11-11 21:54:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remove ranks from a user
|
|
|
|
public function removeRanks($ranks)
|
|
|
|
{
|
|
|
|
// Current ranks
|
2016-01-03 21:19:37 +00:00
|
|
|
$remove = array_intersect($this->ranks(), $ranks);
|
2015-11-11 21:54:56 +00:00
|
|
|
|
|
|
|
// Iterate over the ranks
|
2016-01-03 21:19:37 +00:00
|
|
|
foreach ($remove as $rank) {
|
|
|
|
Database::delete('user_ranks', ['user_id' => [$this->id(), '='], 'rank_id' => [$rank, '=']]);
|
2015-11-11 21:54:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-08 22:31:52 +00:00
|
|
|
// Set the main rank of this user
|
|
|
|
public function setMainRank($rank)
|
|
|
|
{
|
|
|
|
// If it does exist update their row
|
2015-11-11 21:54:56 +00:00
|
|
|
Database::update('users', [
|
2015-11-08 22:31:52 +00:00
|
|
|
[
|
|
|
|
'rank_main' => $rank,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'user_id' => [$this->id(), '='],
|
|
|
|
],
|
|
|
|
]);
|
2015-11-08 22:27:42 +00:00
|
|
|
|
|
|
|
// Return true if everything was successful
|
2015-11-08 22:31:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-11-08 22:27:42 +00:00
|
|
|
|
2015-11-08 22:31:52 +00:00
|
|
|
// Check if this user has the specified ranks
|
|
|
|
public function hasRanks($ranks)
|
|
|
|
{
|
2015-11-07 22:58:02 +00:00
|
|
|
// Check if the main rank is the specified rank
|
2015-11-08 22:27:42 +00:00
|
|
|
if (in_array($this->mainRank->id(), $ranks)) {
|
2015-11-07 22:58:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If not go over all ranks and check if the user has them
|
|
|
|
foreach ($ranks as $rank) {
|
|
|
|
// We check if $rank is in $this->ranks and if yes return true
|
2016-01-03 21:19:37 +00:00
|
|
|
if (in_array($rank, $this->ranks())) {
|
2015-11-07 22:58:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If all fails return false
|
|
|
|
return false;
|
2015-11-08 22:31:52 +00:00
|
|
|
}
|
2015-11-08 22:27:42 +00:00
|
|
|
|
2015-10-12 18:25:37 +00:00
|
|
|
// Add a new friend
|
|
|
|
public function addFriend($uid)
|
|
|
|
{
|
|
|
|
// Create the foreign object
|
2015-12-29 01:27:49 +00:00
|
|
|
$user = User::construct($uid);
|
2015-10-12 18:25:37 +00:00
|
|
|
|
|
|
|
// Validate that the user exists
|
2015-12-29 21:52:19 +00:00
|
|
|
if ($user->permission(Site::DEACTIVATED)) {
|
2015-10-12 18:25:37 +00:00
|
|
|
return [0, 'USER_NOT_EXIST'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the user already has this user a friend
|
2015-11-11 21:54:56 +00:00
|
|
|
if ($this->isFriends($uid)) {
|
2015-10-12 18:25:37 +00:00
|
|
|
return [0, 'ALREADY_FRIENDS'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add friend
|
|
|
|
Database::insert('friends', [
|
2015-10-18 01:50:50 +00:00
|
|
|
'user_id' => $this->data['user_id'],
|
2015-10-12 18:25:37 +00:00
|
|
|
'friend_id' => $uid,
|
|
|
|
'friend_timestamp' => time(),
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Return true because yay
|
2015-11-11 21:54:56 +00:00
|
|
|
return [1, $user->isFriends($this->id()) ? 'FRIENDS' : 'NOT_MUTUAL'];
|
2015-10-12 18:25:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remove a friend
|
|
|
|
public function removeFriend($uid, $deleteRequest = false)
|
|
|
|
{
|
|
|
|
// Create the foreign object
|
2015-12-29 01:27:49 +00:00
|
|
|
$user = User::construct($uid);
|
2015-10-12 18:25:37 +00:00
|
|
|
|
|
|
|
// Validate that the user exists
|
2015-12-29 21:52:19 +00:00
|
|
|
if ($user->permission(Site::DEACTIVATED)) {
|
2015-10-12 18:25:37 +00:00
|
|
|
return [0, 'USER_NOT_EXIST'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the user has this user a friend
|
2015-11-11 21:54:56 +00:00
|
|
|
if (!$this->isFriends($uid)) {
|
2015-10-12 18:25:37 +00:00
|
|
|
return [0, 'ALREADY_REMOVED'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove friend
|
|
|
|
Database::delete('friends', [
|
2015-10-18 01:50:50 +00:00
|
|
|
'user_id' => [$this->data['user_id'], '='],
|
2015-10-12 18:25:37 +00:00
|
|
|
'friend_id' => [$uid, '='],
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Attempt to remove the request
|
|
|
|
if ($deleteRequest) {
|
|
|
|
Database::delete('friends', [
|
2015-10-18 01:50:50 +00:00
|
|
|
'friend_id' => [$this->data['user_id'], '='],
|
2015-10-12 18:25:37 +00:00
|
|
|
'user_id' => [$uid, '='],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return true because yay
|
|
|
|
return [1, 'REMOVED'];
|
|
|
|
}
|
|
|
|
|
2015-08-19 12:13:38 +00:00
|
|
|
// Check if the user is friends with the currently authenticated
|
2015-11-10 23:34:48 +00:00
|
|
|
public function isFriends($with)
|
2015-09-14 20:51:23 +00:00
|
|
|
{
|
2015-11-10 23:34:48 +00:00
|
|
|
// Accepted from this user
|
|
|
|
$user = Database::count('friends', [
|
|
|
|
'user_id' => [$this->id(), '='],
|
|
|
|
'friend_id' => [$with, '='],
|
|
|
|
])[0];
|
|
|
|
|
|
|
|
// And the other user
|
|
|
|
$friend = Database::count('friends', [
|
|
|
|
'user_id' => [$with, '='],
|
|
|
|
'friend_id' => [$this->id(), '='],
|
|
|
|
])[0];
|
|
|
|
|
|
|
|
if ($user && $friend) {
|
|
|
|
return 2; // Mutual friends
|
|
|
|
} elseif ($user) {
|
|
|
|
return 1; // Pending request
|
|
|
|
}
|
|
|
|
|
|
|
|
// Else return 0
|
|
|
|
return 0;
|
|
|
|
}
|
2015-10-12 18:25:37 +00:00
|
|
|
|
2015-11-10 23:34:48 +00:00
|
|
|
// Get all the friend of this user
|
2015-11-11 00:30:22 +00:00
|
|
|
public function friends($level = 0, $noObj = false)
|
2015-11-10 23:34:48 +00:00
|
|
|
{
|
|
|
|
// User ID container
|
|
|
|
$users = [];
|
|
|
|
|
|
|
|
// Select the correct level
|
|
|
|
switch ($level) {
|
|
|
|
case 2:
|
|
|
|
// Get all the current user's friends
|
|
|
|
$self = array_column(Database::fetch('friends', true, ['user_id' => [$this->id(), '=']]), 'friend_id');
|
|
|
|
// Get all the people that added this user as a friend
|
|
|
|
$others = array_column(Database::fetch('friends', true, ['friend_id' => [$this->id(), '=']]), 'user_id');
|
|
|
|
// Create a difference map
|
|
|
|
$users = array_intersect($self, $others);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
$users = array_column(Database::fetch('friends', true, ['user_id' => [$this->id(), '=']]), 'friend_id');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
// Get all the current user's friends
|
|
|
|
$self = array_column(Database::fetch('friends', true, ['user_id' => [$this->id(), '=']]), 'friend_id');
|
|
|
|
// Get all the people that added this user as a friend
|
|
|
|
$others = array_column(Database::fetch('friends', true, ['friend_id' => [$this->id(), '=']]), 'user_id');
|
|
|
|
// Create a difference map
|
|
|
|
$users = array_merge($others, $self);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -1:
|
|
|
|
// Get all the current user's friends
|
|
|
|
$self = array_column(Database::fetch('friends', true, ['user_id' => [$this->id(), '=']]), 'friend_id');
|
|
|
|
// Get all the people that added this user as a friend
|
|
|
|
$others = array_column(Database::fetch('friends', true, ['friend_id' => [$this->id(), '=']]), 'user_id');
|
|
|
|
// Create a difference map
|
|
|
|
$users = array_diff($others, $self);
|
|
|
|
break;
|
2015-10-12 18:25:37 +00:00
|
|
|
}
|
|
|
|
|
2015-11-11 00:30:22 +00:00
|
|
|
// Check if we only requested the IDs
|
|
|
|
if ($noObj) {
|
|
|
|
// If so just return $users
|
|
|
|
return $users;
|
|
|
|
}
|
|
|
|
|
2015-11-10 23:34:48 +00:00
|
|
|
// Create the storage array
|
|
|
|
$objects = [];
|
|
|
|
|
2015-11-11 00:30:22 +00:00
|
|
|
// Create the user objects
|
2015-11-10 23:34:48 +00:00
|
|
|
foreach ($users as $user) {
|
|
|
|
// Create new object
|
2015-12-29 01:27:49 +00:00
|
|
|
$objects[$user] = User::construct($user);
|
2015-10-12 18:25:37 +00:00
|
|
|
}
|
|
|
|
|
2015-11-10 23:34:48 +00:00
|
|
|
// Return the objects
|
|
|
|
return $objects;
|
2015-08-19 12:13:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the user is banned
|
2015-09-14 20:51:23 +00:00
|
|
|
public function checkBan()
|
|
|
|
{
|
2015-10-10 21:17:50 +00:00
|
|
|
return Bans::checkBan($this->data['user_id']);
|
2015-08-19 12:13:38 +00:00
|
|
|
}
|
|
|
|
|
2015-08-21 22:07:45 +00:00
|
|
|
// Check if the user has the proper permissions
|
2015-12-29 21:52:19 +00:00
|
|
|
public function permission($flag, $mode = null)
|
2015-09-14 20:51:23 +00:00
|
|
|
{
|
2015-12-29 21:52:19 +00:00
|
|
|
// Set mode
|
|
|
|
$this->permissions->mode($mode ? $mode : Perms::SITE);
|
|
|
|
|
|
|
|
// Set default permission value
|
|
|
|
$perm = 0;
|
|
|
|
|
|
|
|
// Bitwise OR it with the permissions for this forum
|
|
|
|
$perm = $this->permissions->user($this->id());
|
|
|
|
|
|
|
|
return $this->permissions->check($flag, $perm);
|
2015-08-21 22:07:45 +00:00
|
|
|
}
|
|
|
|
|
2015-10-06 21:05:39 +00:00
|
|
|
// Get a user's profile comments
|
|
|
|
public function profileComments()
|
|
|
|
{
|
2015-10-10 21:17:50 +00:00
|
|
|
return new Comments('profile-' . $this->data['user_id']);
|
2015-10-06 21:05:39 +00:00
|
|
|
}
|
|
|
|
|
2015-08-19 02:37:45 +00:00
|
|
|
// Get the user's profile fields
|
2015-09-14 20:51:23 +00:00
|
|
|
public function profileFields()
|
|
|
|
{
|
2015-08-19 02:37:45 +00:00
|
|
|
// Get profile fields
|
|
|
|
$profileFields = Database::fetch('profilefields');
|
|
|
|
|
|
|
|
// If there's nothing just return null
|
2015-09-14 20:51:23 +00:00
|
|
|
if (!count($profileFields)) {
|
2015-11-08 22:27:42 +00:00
|
|
|
return [];
|
2015-08-19 02:37:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Once again if nothing was returned just return null
|
2015-10-10 21:17:50 +00:00
|
|
|
if (empty($this->data['user_data']['profileFields'])) {
|
2015-11-08 22:27:42 +00:00
|
|
|
return [];
|
2015-08-19 02:37:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create output array
|
|
|
|
$profile = [];
|
|
|
|
|
|
|
|
// Check if profile fields aren't fake
|
2015-09-14 20:51:23 +00:00
|
|
|
foreach ($profileFields as $field) {
|
2015-08-19 02:37:45 +00:00
|
|
|
// Completely strip all special characters from the field name
|
2015-10-10 21:17:50 +00:00
|
|
|
$fieldName = Main::cleanString($field['field_name'], true, true);
|
2015-08-19 02:37:45 +00:00
|
|
|
|
|
|
|
// Check if the user has the current field set otherwise continue
|
2015-10-10 21:17:50 +00:00
|
|
|
if (!array_key_exists($fieldName, $this->data['user_data']['profileFields'])) {
|
2015-08-19 02:37:45 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assign field to output with value
|
2015-10-18 19:06:30 +00:00
|
|
|
$profile[$fieldName] = [];
|
2015-10-10 21:17:50 +00:00
|
|
|
$profile[$fieldName]['name'] = $field['field_name'];
|
|
|
|
$profile[$fieldName]['value'] = $this->data['user_data']['profileFields'][$fieldName];
|
|
|
|
$profile[$fieldName]['islink'] = $field['field_link'];
|
2015-08-19 02:37:45 +00:00
|
|
|
|
|
|
|
// If the field is set to be a link add a value for that as well
|
2015-10-10 21:17:50 +00:00
|
|
|
if ($field['field_link']) {
|
2015-09-14 21:41:43 +00:00
|
|
|
$profile[$fieldName]['link'] = str_replace(
|
|
|
|
'{{ VAL }}',
|
2015-10-10 21:17:50 +00:00
|
|
|
$this->data['user_data']['profileFields'][$fieldName],
|
|
|
|
$field['field_linkformat']
|
2015-09-14 21:41:43 +00:00
|
|
|
);
|
2015-08-19 02:37:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if we have additional options as well
|
2015-10-10 21:17:50 +00:00
|
|
|
if ($field['field_additional'] != null) {
|
2015-08-19 02:37:45 +00:00
|
|
|
// Decode the json of the additional stuff
|
2015-10-10 21:17:50 +00:00
|
|
|
$additional = json_decode($field['field_additional'], true);
|
2015-08-19 02:37:45 +00:00
|
|
|
|
|
|
|
// Go over all additional forms
|
2015-09-14 20:51:23 +00:00
|
|
|
foreach ($additional as $subName => $subField) {
|
2015-08-19 02:37:45 +00:00
|
|
|
// Check if the user has the current field set otherwise continue
|
2015-10-10 21:17:50 +00:00
|
|
|
if (!array_key_exists($subName, $this->data['user_data']['profileFields'])) {
|
2015-08-19 02:37:45 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assign field to output with value
|
2015-10-10 21:17:50 +00:00
|
|
|
$profile[$fieldName][$subName] = $this->data['user_data']['profileFields'][$subName];
|
2015-08-19 02:37:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return appropiate profile data
|
|
|
|
return $profile;
|
2015-08-18 23:29:45 +00:00
|
|
|
}
|
|
|
|
|
2015-08-21 22:07:45 +00:00
|
|
|
// Get the user's option fields
|
2015-09-14 20:51:23 +00:00
|
|
|
public function optionFields()
|
|
|
|
{
|
2015-08-21 22:07:45 +00:00
|
|
|
// Get option fields
|
|
|
|
$optionFields = Database::fetch('optionfields');
|
|
|
|
|
|
|
|
// If there's nothing just return null
|
2015-09-14 20:51:23 +00:00
|
|
|
if (!count($optionFields)) {
|
2015-11-08 22:27:42 +00:00
|
|
|
return [];
|
2015-08-21 22:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Once again if nothing was returned just return null
|
2015-10-10 21:17:50 +00:00
|
|
|
if (empty($this->data['user_data']['userOptions'])) {
|
2015-11-08 22:27:42 +00:00
|
|
|
return [];
|
2015-08-21 22:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create output array
|
|
|
|
$options = [];
|
|
|
|
|
|
|
|
// Check if profile fields aren't fake
|
2015-09-14 20:51:23 +00:00
|
|
|
foreach ($optionFields as $field) {
|
2015-08-21 22:07:45 +00:00
|
|
|
// Check if the user has the current field set otherwise continue
|
2015-10-10 21:17:50 +00:00
|
|
|
if (!array_key_exists($field['option_id'], $this->data['user_data']['userOptions'])) {
|
2015-08-21 22:07:45 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure the user has the proper permissions to use this option
|
2015-12-29 21:52:19 +00:00
|
|
|
if (!$this->permission(constant('Sakura\Perms\Site::' . $field['option_permission']))) {
|
2015-08-21 22:07:45 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assign field to output with value
|
2015-10-10 21:17:50 +00:00
|
|
|
$options[$field['option_id']] = $this->data['user_data']['userOptions'][$field['option_id']];
|
2015-08-21 22:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return appropiate profile data
|
|
|
|
return $options;
|
|
|
|
}
|
|
|
|
|
2015-08-19 12:13:38 +00:00
|
|
|
// Check if user has Premium
|
2015-11-11 21:54:56 +00:00
|
|
|
public function isPremium()
|
2015-09-14 20:51:23 +00:00
|
|
|
{
|
2015-08-19 12:13:38 +00:00
|
|
|
|
|
|
|
// Check if the user has static premium
|
2015-12-29 21:52:19 +00:00
|
|
|
if ($this->permission(Site::STATIC_PREMIUM)) {
|
2015-08-19 12:13:38 +00:00
|
|
|
return [2, 0, time() + 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Attempt to retrieve the premium record from the database
|
|
|
|
$getRecord = Database::fetch('premium', false, [
|
2015-10-10 21:17:50 +00:00
|
|
|
'user_id' => [$this->data['user_id'], '='],
|
2015-08-19 12:13:38 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
// If nothing was returned just return false
|
2015-09-14 20:51:23 +00:00
|
|
|
if (empty($getRecord)) {
|
2015-08-19 12:13:38 +00:00
|
|
|
return [0];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the Tenshi hasn't expired
|
2015-10-10 21:17:50 +00:00
|
|
|
if ($getRecord['premium_expire'] < time()) {
|
|
|
|
return [0, $getRecord['premium_start'], $getRecord['premium_expire']];
|
2015-08-19 12:13:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Else return the start and expiration date
|
2015-10-10 21:17:50 +00:00
|
|
|
return [1, $getRecord['premium_start'], $getRecord['premium_expire']];
|
2015-08-19 12:13:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get all warnings issued to the user
|
2015-09-14 20:51:23 +00:00
|
|
|
public function getWarnings()
|
|
|
|
{
|
2015-08-19 12:13:38 +00:00
|
|
|
// Do the database query
|
2015-10-17 20:58:51 +00:00
|
|
|
$getWarnings = Database::fetch('warnings', true, [
|
2015-10-10 21:17:50 +00:00
|
|
|
'user_id' => [$this->data['user_id'], '='],
|
2015-08-19 12:13:38 +00:00
|
|
|
]);
|
|
|
|
|
2015-10-17 20:58:51 +00:00
|
|
|
// Storage array
|
|
|
|
$warnings = [];
|
|
|
|
|
|
|
|
// Add special stuff
|
|
|
|
foreach ($getWarnings as $warning) {
|
|
|
|
// Check if it hasn't expired
|
|
|
|
if ($warning['warning_expires'] < time()) {
|
|
|
|
Database::delete('warnings', ['warning_id' => [$warning['warning_id'], '=']]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Text action
|
|
|
|
switch ($warning['warning_action']) {
|
|
|
|
default:
|
|
|
|
case '0':
|
|
|
|
$warning['warning_action_text'] = 'Warning';
|
|
|
|
break;
|
|
|
|
case '1':
|
|
|
|
$warning['warning_action_text'] = 'Silence';
|
|
|
|
break;
|
|
|
|
case '2':
|
|
|
|
$warning['warning_action_text'] = 'Restriction';
|
|
|
|
break;
|
|
|
|
case '3':
|
|
|
|
$warning['warning_action_text'] = 'Ban';
|
|
|
|
break;
|
|
|
|
case '4':
|
|
|
|
$warning['warning_action_text'] = 'Abyss';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Text expiration
|
|
|
|
$warning['warning_length'] = round(($warning['warning_expires'] - $warning['warning_issued']) / 60);
|
|
|
|
|
|
|
|
// Add to array
|
|
|
|
$warnings[$warning['warning_id']] = $warning;
|
|
|
|
}
|
|
|
|
|
2015-08-19 12:13:38 +00:00
|
|
|
// Return all the warnings
|
|
|
|
return $warnings;
|
|
|
|
}
|
2015-09-23 20:45:42 +00:00
|
|
|
|
2015-10-24 08:55:45 +00:00
|
|
|
// Get a user's userpage
|
2015-09-26 16:12:42 +00:00
|
|
|
public function userPage()
|
|
|
|
{
|
2015-10-10 21:17:50 +00:00
|
|
|
return isset($this->data['user_data']['userPage']) ?
|
2015-09-26 16:12:42 +00:00
|
|
|
Main::mdParse(
|
|
|
|
base64_decode(
|
2015-10-10 21:17:50 +00:00
|
|
|
$this->data['user_data']['userPage']
|
2015-09-26 16:12:42 +00:00
|
|
|
),
|
|
|
|
true
|
|
|
|
) :
|
|
|
|
null;
|
|
|
|
}
|
|
|
|
|
2015-10-24 08:55:45 +00:00
|
|
|
// Get a user's signature
|
|
|
|
public function signature()
|
|
|
|
{
|
|
|
|
return isset($this->data['user_data']['signature']) ?
|
2015-12-03 18:41:14 +00:00
|
|
|
BBcode::toHTML(
|
2015-12-02 14:38:40 +00:00
|
|
|
base64_decode(
|
|
|
|
$this->data['user_data']['signature']
|
2015-10-24 08:55:45 +00:00
|
|
|
)
|
2015-12-03 18:41:14 +00:00
|
|
|
) :
|
2015-10-24 08:55:45 +00:00
|
|
|
null;
|
|
|
|
}
|
|
|
|
|
2015-09-23 20:45:42 +00:00
|
|
|
// Get username change history
|
|
|
|
public function getUsernameHistory()
|
|
|
|
{
|
|
|
|
// Do the database query
|
|
|
|
$changes = Database::fetch('username_history', true, [
|
2015-10-10 21:17:50 +00:00
|
|
|
'user_id' => [$this->data['user_id'], '='],
|
2015-09-23 20:45:42 +00:00
|
|
|
], ['change_id', true]);
|
|
|
|
|
|
|
|
// Return all the warnings
|
|
|
|
return $changes;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set a new username
|
|
|
|
public function setUsername($username)
|
|
|
|
{
|
|
|
|
// Create a cleaned version
|
|
|
|
$username_clean = Main::cleanString($username, true);
|
|
|
|
|
|
|
|
// Check if the username is too short
|
2015-12-04 14:19:10 +00:00
|
|
|
if (strlen($username_clean) < Config::get('username_min_length')) {
|
2015-09-23 20:45:42 +00:00
|
|
|
return [0, 'TOO_SHORT'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the username is too long
|
2015-12-04 14:19:10 +00:00
|
|
|
if (strlen($username_clean) > Config::get('username_max_length')) {
|
2015-09-23 20:45:42 +00:00
|
|
|
return [0, 'TOO_LONG'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if this username hasn't been used in the last amount of days set in the config
|
|
|
|
$getOld = Database::fetch('username_history', false, [
|
|
|
|
'username_old_clean' => [$username_clean, '='],
|
2015-12-04 14:19:10 +00:00
|
|
|
'change_time' => [(Config::get('old_username_reserve') * 24 * 60 * 60), '>'],
|
2015-09-23 20:45:42 +00:00
|
|
|
], ['change_id', true]);
|
|
|
|
|
|
|
|
// Check if anything was returned
|
2015-11-25 20:18:52 +00:00
|
|
|
if ($getOld && $getOld['user_id'] != $this->id()) {
|
2015-09-23 20:45:42 +00:00
|
|
|
return [0, 'TOO_RECENT', $getOld['change_time']];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the username is already in use
|
|
|
|
$getInUse = Database::fetch('users', false, [
|
|
|
|
'username_clean' => [$username_clean, '='],
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Check if anything was returned
|
|
|
|
if ($getInUse) {
|
2015-10-11 21:22:36 +00:00
|
|
|
return [0, 'IN_USE', $getInUse['user_id']];
|
2015-09-23 20:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Insert into username_history table
|
|
|
|
Database::insert('username_history', [
|
|
|
|
'change_time' => time(),
|
2015-10-10 21:17:50 +00:00
|
|
|
'user_id' => $this->data['user_id'],
|
2015-09-23 20:45:42 +00:00
|
|
|
'username_new' => $username,
|
|
|
|
'username_new_clean' => $username_clean,
|
|
|
|
'username_old' => $this->data['username'],
|
|
|
|
'username_old_clean' => $this->data['username_clean'],
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Update userrow
|
|
|
|
Database::update('users', [
|
|
|
|
[
|
|
|
|
'username' => $username,
|
|
|
|
'username_clean' => $username_clean,
|
|
|
|
],
|
|
|
|
[
|
2015-10-11 21:22:36 +00:00
|
|
|
'user_id' => [$this->data['user_id'], '='],
|
2015-09-23 20:45:42 +00:00
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Return success
|
|
|
|
return [1, 'SUCCESS', $username];
|
|
|
|
}
|
2015-09-26 16:12:42 +00:00
|
|
|
|
|
|
|
// Set a new e-mail address
|
|
|
|
public function setEMailAddress($email)
|
|
|
|
{
|
|
|
|
// Validate e-mail address
|
|
|
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
|
|
return [0, 'INVALID'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the username is already in use
|
|
|
|
$getInUse = Database::fetch('users', false, [
|
|
|
|
'email' => [$email, '='],
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Check if anything was returned
|
|
|
|
if ($getInUse) {
|
2015-10-11 21:22:36 +00:00
|
|
|
return [0, 'IN_USE', $getInUse['user_id']];
|
2015-09-26 16:12:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update userrow
|
|
|
|
Database::update('users', [
|
|
|
|
[
|
|
|
|
'email' => $email,
|
|
|
|
],
|
|
|
|
[
|
2015-10-11 21:22:36 +00:00
|
|
|
'user_id' => [$this->data['user_id'], '='],
|
2015-09-26 16:12:42 +00:00
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Return success
|
|
|
|
return [1, 'SUCCESS', $email];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set a new password
|
|
|
|
public function setPassword($old, $new, $confirm)
|
|
|
|
{
|
|
|
|
// Validate password
|
|
|
|
switch ($this->data['password_algo']) {
|
2015-12-31 14:51:01 +00:00
|
|
|
// Disabled account
|
|
|
|
case 'disabled':
|
2015-09-26 16:12:42 +00:00
|
|
|
return [0, 'NO_LOGIN'];
|
|
|
|
|
|
|
|
// Default hashing method
|
|
|
|
default:
|
|
|
|
if (!Hashing::validatePassword($old, [
|
|
|
|
$this->data['password_algo'],
|
|
|
|
$this->data['password_iter'],
|
|
|
|
$this->data['password_salt'],
|
|
|
|
$this->data['password_hash'],
|
|
|
|
])) {
|
|
|
|
return [0, 'INCORRECT_PASSWORD', $this->data['password_chan']];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check password entropy
|
2015-12-04 14:19:10 +00:00
|
|
|
if (Main::pwdEntropy($new) < Config::get('min_entropy')) {
|
2015-09-26 16:12:42 +00:00
|
|
|
return [0, 'PASS_TOO_SHIT'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Passwords do not match
|
|
|
|
if ($new != $confirm) {
|
|
|
|
return [0, 'PASS_NOT_MATCH'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create hash
|
|
|
|
$password = Hashing::createHash($new);
|
|
|
|
|
|
|
|
// Update userrow
|
|
|
|
Database::update('users', [
|
|
|
|
[
|
|
|
|
'password_hash' => $password[3],
|
|
|
|
'password_salt' => $password[2],
|
|
|
|
'password_algo' => $password[0],
|
|
|
|
'password_iter' => $password[1],
|
|
|
|
'password_chan' => time(),
|
|
|
|
],
|
|
|
|
[
|
2015-10-11 21:22:36 +00:00
|
|
|
'user_id' => [$this->data['user_id'], '='],
|
2015-09-26 16:12:42 +00:00
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Return success
|
|
|
|
return [1, 'SUCCESS'];
|
|
|
|
}
|
2015-11-08 22:27:42 +00:00
|
|
|
|
2015-11-08 22:31:52 +00:00
|
|
|
// Update a user's userData
|
|
|
|
public function setUserData($data)
|
|
|
|
{
|
|
|
|
// Merge the arrays
|
|
|
|
$data = array_merge($this->userData(), $data);
|
2015-11-08 22:27:42 +00:00
|
|
|
|
2015-11-08 22:31:52 +00:00
|
|
|
// Encode it
|
|
|
|
$data = json_encode($data);
|
2015-11-08 22:27:42 +00:00
|
|
|
|
2015-11-08 22:31:52 +00:00
|
|
|
// Save it in the database
|
|
|
|
Database::update('users', [
|
2015-11-08 22:27:42 +00:00
|
|
|
[
|
|
|
|
'user_data' => $data,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'user_id' => [$this->id(), '='],
|
|
|
|
],
|
|
|
|
]);
|
2015-11-08 22:31:52 +00:00
|
|
|
}
|
2015-08-18 23:29:45 +00:00
|
|
|
}
|