Example #1
0
<?php

require_once "../../global.php";
require_once TEMPLATE_PATH . '/site/helper/format.php';
// check project
$slug = Filter::text($_GET['slug']);
$project = Project::getProjectFromSlug($slug);
if ($project == null) {
    $json = array('error' => 'That project does not exist.');
    exit(json_encode($json));
}
// validate task
$taskID = Filter::numeric($_GET['t']);
$task = Task::load($taskID);
if ($task == null) {
    $json = array('error' => 'That task does not exist.');
    exit(json_encode($json));
}
// // validate username
// $username = Filter::text($_GET['u']);
// $user = User::loadByUsername($username);
// // check if user has accepted task
// $accepted = Accepted::getByUserID($user->getID(), $task->getID());
// if($accepted == null) {
// $json = array('error' => 'That user has not accepted this task.');
// exit(json_encode($json));
// }
// move onto POST variables
$action = Filter::text($_POST['action']);
if ($action == 'create') {
    // get update content
Example #2
0
function getOnlineUsers($slug)
{
    $project = Project::getProjectFromSlug($slug);
    $allMembers = $project->getAllMembers();
    //For some reason allMembers doesn't return the project creator
    $creator = $project->getCreator();
    array_push($allMembers, $creator);
    $usersOnline = array();
    $userIds = '';
    foreach ($allMembers as $member) {
        //Check last time member sent a heart beat to the chat room
        //array_push($usersOnline,$member->getID());
        //I think this is faster then putting everything in an array and using implode
        $userIds .= $member->getID() . ",";
    }
    //Need to remove extra comma introduced in foreach loop
    $userIds = rtrim($userIds, ",");
    $usersOnline = Chat::getOnlineUsers($project->getID(), $userIds, 15);
    header('Content-type: application/json');
    echo json_encode($usersOnline);
    exit(0);
}