Example #1
0
    /* update this user's last login */
    $_user->setLastLogin(mktime());
    /* update this user's last known ip address */
    $_user->setLastIP($_SERVER['REMOTE_ADDR']);
    /* save it to prevent planwatch weirdness */
    $_user->save();
    /* create an object representing the target user (or a string representing the page) */
    if (isset($_GET['id'])) {
        $section = str_replace(' ', '', $_GET['id']);
        if ($section == $_user->getUsername()) {
            $_target =& $_user;
        } else {
            if (Planworld::isValidUser($section)) {
                $_target = User::factory($section);
            } else {
                if ($section == 'random') {
                    $_target = User::factory(Planworld::getRandomUser());
                } else {
                    $_target = $section;
                }
            }
        }
        /* force fetching of update / login times if the target user is remote */
        if (is_object($_target) && $_target->getType() == 'planworld') {
            $_target->forceUpdate();
        }
    }
    /* update the current status of online users (including this one) */
    Online::clearIdle();
    Online::updateUser($_user, $_target);
}
Example #2
0
function planGet($params)
{
    $planText = "Could not retrieve plan.";
    /* Grab arguments and generate variables and objects from them. */
    $argToken =& $params[0];
    $argUsernameToGet =& $params[1];
    $argPlanDate =& $params[2];
    $tokenObject = new NodeToken();
    $tokenObject->retrieveToken($argToken);
    if ($tokenObject->valid && $argUsernameToGet != null) {
        $sourceUsername = $tokenObject->usernameFromUid($tokenObject->uid);
        $sourceUser = User::factory($sourceUsername);
        $targetUser = User::factory($argUsernameToGet);
        /* Do a bunch of housekeeping that would otherwise be in prepend.php
        		Check that file for commentary. */
        $sourceUser->setLastLogin(mktime());
        $sourceUser->save();
        if (is_object($targetUser) && $targetUser->getType() == 'planworld') {
            $targetUser->forceUpdate();
        }
        Online::clearIdle();
        Online::updateUser($sourceUser, $targetUser);
        /* Real work: Get plan and send to user (snitch handled by call). */
        $planText = $targetUser->getPlan($sourceUser, $argPlanDate);
        /* Do the work necessary to mark the target user's plan as read.
        		Note that this is harder because of Object Orientation.
        		Also note this section as a good reference for how to drill deep into
        		the planworld libraries to make sure everything happens correctly. */
        $sourceUser->loadPlanwatch();
        $sourceUser->planwatch->markSeen($targetUser);
        $sourceUser->save();
        statusCode(200);
    } else {
        statusCode(401);
        $planText = "Could not retrieve plan.";
    }
    return $planText;
}
Example #3
0
function xmlrpc_clientPlanRead($method_name, $params)
{
    $planText = "Could not retrieve plan.";
    /* Grab arguments and generate variables and objects from them. */
    $argToken =& $params[0];
    $argUsernameToGet =& $params[1];
    $argPlanDate =& $params[2];
    $tokenObject = new NodeToken();
    $tokenObject->retrieveToken($argToken);
    $sourceUsername = $tokenObject->usernameFromUid($tokenObject->uid);
    $sourceUser = User::factory($sourceUsername);
    $targetUser = User::factory($argUsernameToGet);
    /* Do a bunch of housekeeping that would otherwise be in prepend.php
    	Check that file for commentary. */
    $sourceUser->setLastLogin(mktime());
    $sourceUser->save();
    if (is_object($targetUser) && $targetUser->getType() == 'planworld') {
        $targetUser->forceUpdate();
    }
    Online::clearIdle();
    Online::updateUser($sourceUser, $targetUser);
    /* Real work: Get plan and send to user (snitch handled by call). */
    $planText = $sourceUser->getPlan($targetUser, $argPlanDate);
    return $planText;
}