public static function demo()
 {
     echo "LiquidPlanner email: ";
     $email = trim(fgets(STDIN));
     echo "LiquidPlanner password for {$email}: ";
     system('stty -echo');
     $password = trim(fgets(STDIN));
     system('stty echo');
     echo PHP_EOL;
     $lp = new LiquidPlanner($email, $password);
     $account = $lp->account();
     echo "You are {$account->user_name} ({$account->id})" . PHP_EOL;
     $workspaces = $lp->workspaces();
     $count = count($workspaces);
     $plural = $count == 1 ? '' : 's';
     echo "You have {$count} workspace{$plural}" . PHP_EOL;
     foreach ($workspaces as $ws) {
         echo " {$ws->name}\n";
     }
     $ws = $workspaces[0];
     $lp->workspace_id = $ws->id;
     $projects = $lp->projects();
     $count = count($projects);
     echo "These are the {$count} projects in your '{$ws->name}' workspace" . PHP_EOL;
     foreach ($projects as $i => $p) {
         echo ' ' . ($i + 1) . '. ' . $p->name . PHP_EOL;
     }
     echo "Should I add a task to your first project? (y for yes) ";
     $add_task = fgets(STDIN);
     if ('Y' == strtoupper(substr(trim($add_task), 0, 1))) {
         $task = array('name' => 'learn the API', 'parent_id' => $projects[0]->id);
         $result = $lp->create_task($task);
         $update = array('name' => 'learn more about the API', 'id' => $result->id);
         print_r($lp->update_task($update));
     }
 }
        return json_decode(curl_exec($this->_ch));
    }
    public function comment_stream($limit = 3)
    {
        return $this->get("/workspaces/{$this->workspace_id}/comment_stream?limit={$limit}");
    }
}
// LP config
$email = '';
$password = '';
$workspace_id = '';
// GeckoBoard config
$gecko_api_key = '';
$gecko_widget_key = '';
// Get most recent comments
$lp = new LiquidPlanner($email, $password);
$lp->workspace_id = $workspace_id;
$comments = $lp->comment_stream();
// translates an LP comment to the format GeckoBoard expects
function gecko_text($lp_comment)
{
    return array("text" => $lp_comment->comment, "type" => 0);
}
// apply translation across the comments we received
$gecko_data = array("api_key" => $gecko_api_key, "data" => array("item" => array_map("gecko_text", $comments)));
$gecko_json = json_encode($gecko_data);
$gecko_curl = curl_init();
curl_setopt($gecko_curl, CURLOPT_POST, true);
curl_setopt($gecko_curl, CURLOPT_URL, "https://push.geckoboard.com/v1/send/{$gecko_widget_key}");
curl_setopt($gecko_curl, CURLOPT_POSTFIELDS, $gecko_json);
curl_exec($gecko_curl);
 public static function demo()
 {
     echo "LiquidPlanner email: ";
     $email = trim(fgets(STDIN));
     echo "LiquidPlanner password for {$email}: ";
     system('stty -echo');
     $password = trim(fgets(STDIN));
     system('stty echo');
     echo PHP_EOL;
     $lp = new LiquidPlanner($email, $password);
     $workspaces = $lp->workspaces();
     $lp->workspace_id = $workspaces[0]->id;
     $help = $lp->help();
     if (!isset($help->Task) || !isset($help->Task->assignments)) {
         print "LiquidPlanner does not yet support multiple owners" . PHP_EOL;
         exit;
     }
     $two_tasks = $lp->tasks("?limit=2");
     $two_events = $lp->events("?limit=2");
     if (count($two_tasks) < 2 || count($two_events) < 2) {
         print "Make sure you have at least two tasks and at least two events." . PHP_EOL;
         exit;
     }
     $lp->member_lookup = $lp->workspace_members();
     $lp->team_lookup = $lp->workspace_teams();
     print "We're going to swap ownership for the first two tasks, and the " . "two events: " . PHP_EOL;
     print "Tasks: (before)" . PHP_EOL;
     foreach ($two_tasks as &$task) {
         $lp->inspect_ownership($task);
     }
     print "Events: (before)" . PHP_EOL;
     foreach ($two_events as &$event) {
         $lp->inspect_ownership($event);
     }
     list($assignment_1, $assignment_2) = array_map(function ($task) {
         return $task->assignments[0];
     }, $two_tasks);
     $two_tasks[0] = $lp->update_assignment($two_tasks[0]->id, array("assignment_id" => $assignment_1->id, "person_id" => isset($assignment_2->person_id) ? $assignment_2->person_id : NULL, "team_id" => isset($assignment_2->team_id) ? $assignment_2->team_id : NULL));
     $two_tasks[1] = $lp->update_assignment($two_tasks[1]->id, array("assignment_id" => $assignment_2->id, "person_id" => isset($assignment_1->person_id) ? $assignment_1->person_id : NULL, "team_id" => isset($assignment_1->team_id) ? $assignment_1->team_id : NULL));
     list($assignment_1, $assignment_2) = array_map(function ($event) use($lp) {
         return $lp->event_owners($event);
     }, $two_events);
     $two_events[0] = $lp->update_assignment($two_events[0]->id, $assignment_2);
     $two_events[1] = $lp->update_assignment($two_events[1]->id, $assignment_1);
     print "Tasks: (after)" . PHP_EOL;
     foreach ($two_tasks as &$task) {
         $lp->inspect_ownership($task);
     }
     print "Events: (after)" . PHP_EOL;
     foreach ($two_events as &$event) {
         $lp->inspect_ownership($event);
     }
 }
Example #4
0
    }
    return $alerts;
}
// jed - changing
// liquidplanner service!
$result = array('success' => false, 'message' => 'nothing done');
$action = 'status';
if (isset($_REQUEST['action'])) {
    $action = $_REQUEST['action'];
}
// email/pass
$email = $_REQUEST['email'];
$password = $_REQUEST['password'];
$workspace_id = $_REQUEST['workspace_id'];
//
$lp = new LiquidPlanner($email, $password);
// stashish this so we limit the calls - and it should not change for us...
$lp->workspace_id = $workspace_id;
// changing defaults
//$action = 'yesterday_todos';
$result['workspace_id'] = $workspace_id;
switch ($action) {
    case 'todays_todos':
        $members = $lp->members(true);
        $todos = array();
        foreach ($members as $member) {
            $tasks = $lp->upcoming_tasks($member->id, 20);
            $todos[] = array('member_id' => $member->id, 'first_name' => $member->first_name, 'last_name' => $member->last_name, 'email' => $member->email, 'avatar_url' => $member->avatar_url, 'tasks' => $tasks);
        }
        //$todos = processTodos($tasksByMember, $members);
        $result['tasks_today'] = $todos;