midnight commit
This commit is contained in:
parent
4093327895
commit
edb7a9e15d
3 changed files with 49 additions and 3 deletions
|
@ -341,7 +341,7 @@ class User
|
|||
}
|
||||
|
||||
// Get all the friend of this user
|
||||
public function friends($level = 0)
|
||||
public function friends($level = 0, $noObj = false)
|
||||
{
|
||||
// User ID container
|
||||
$users = [];
|
||||
|
@ -381,10 +381,16 @@ class User
|
|||
break;
|
||||
}
|
||||
|
||||
// Check if we only requested the IDs
|
||||
if ($noObj) {
|
||||
// If so just return $users
|
||||
return $users;
|
||||
}
|
||||
|
||||
// Create the storage array
|
||||
$objects = [];
|
||||
|
||||
// Get all users
|
||||
// Create the user objects
|
||||
foreach ($users as $user) {
|
||||
// Create new object
|
||||
$objects[$user] = new User($user);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Sakura;
|
||||
|
||||
// Define Sakura version
|
||||
define('SAKURA_VERSION', '20151110');
|
||||
define('SAKURA_VERSION', '20151111');
|
||||
define('SAKURA_VLABEL', 'Eminence');
|
||||
define('SAKURA_COLOUR', '#6C3082');
|
||||
define('SAKURA_STABLE', false);
|
||||
|
|
|
@ -50,6 +50,46 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
|
|||
}
|
||||
}
|
||||
|
||||
// Check if friendOnline is set (so it doesn't tell you all your friends all online on first visit)
|
||||
$onlineNotify = isset($_SESSION['friendsOnline']) ? $_SESSION['friendsOnline'] : [];
|
||||
|
||||
// Populate the array
|
||||
foreach ($currentUser->friends(1) as $friend) {
|
||||
// Online status
|
||||
$online = $friend->isOnline();
|
||||
|
||||
// If true check if they're already in the array
|
||||
if($online && !in_array($friend->id(), $onlineNotify)) {
|
||||
// Add user to the online array
|
||||
$_SESSION['friendsOnline'][$friend->id()] = $friend->id();
|
||||
|
||||
// Add the notification to the display array
|
||||
$notifications[time()] = [
|
||||
'read' => 0,
|
||||
'title' => $friend->username() . ' is online.',
|
||||
'text' => '',
|
||||
'link' => '',
|
||||
'img' => '/a/' . $friend->id(),
|
||||
'timeout' => 2000,
|
||||
'sound' => false,
|
||||
];
|
||||
} elseif(!$online && in_array($friend->id(), $onlineNotify)) {
|
||||
// Remove the person from the array
|
||||
unset($_SESSION['friendsOnline'][$friend->id()]);
|
||||
|
||||
// Add the notification to the display array
|
||||
$notifications[time()] = [
|
||||
'read' => 0,
|
||||
'title' => $friend->username() . ' is offline.',
|
||||
'text' => '',
|
||||
'link' => '',
|
||||
'img' => '/a/' . $friend->id(),
|
||||
'timeout' => 2000,
|
||||
'sound' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Set header, convert the array to json, print it and exit
|
||||
print json_encode($notifications);
|
||||
exit;
|
||||
|
|
Reference in a new issue