Skip to content

Commit

Permalink
Use new podio-php instead of legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
haugstrup committed Jan 15, 2012
1 parent a99172d commit 7289236
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
15 changes: 9 additions & 6 deletions index.php
Expand Up @@ -18,7 +18,11 @@ function scrumboard() {

// Grab sprints and find current sprint
// $filters = array(array('key' => SPRINT_STATE_ID, 'values' => array('Active')));
$sprints = $api->item->getItems(SPRINT_APP_ID, 5, 0, 'created_on', 1);
$sprints = $api->item->getItems(SPRINT_APP_ID, array(
'limit' => 5,
'sort_by' => 'created_on',
'sort_desc' => 1
));
foreach ($sprints['items'] as $item) {
if (params('id') == $item['item_id']) {
$current_sprint = $item;
Expand Down Expand Up @@ -46,16 +50,15 @@ function scrumboard() {

dispatch('/authorize', 'authorize');
function authorize() {
global $oauth;
global $api;

$story_app = NULL;

// Successful authorization. Store the access token in the session
if (!isset($_GET['error'])) {
$oauth->getAccessToken('authorization_code', array('code' => $_GET['code'], 'redirect_uri' => option('OAUTH_REDIRECT_URI')));
$api = new PodioAPI();
$_SESSION['access_token'] = $oauth->access_token;
$_SESSION['refresh_token'] = $oauth->refresh_token;
$api->authenticate('authorization_code', array('code' => $_GET['code'], 'redirect_uri' => option('OAUTH_REDIRECT_URI')));
$_SESSION['access_token'] = $api->oauth->access_token;
$_SESSION['refresh_token'] = $api->oauth->refresh_token;
$story_app = $api->app->get(STORY_APP_ID);
}

Expand Down
11 changes: 5 additions & 6 deletions init.php
Expand Up @@ -4,13 +4,12 @@
session_start();

// Setup API client and get access token
$oauth = PodioOAuth::instance();
$baseAPI = PodioBaseAPI::instance(CLIENT_ID, CLIENT_SECRET);
$api = Podio::instance(CLIENT_ID, CLIENT_SECRET);

// $api->debug = true;

// If there's an access token in the session, make podio-php use it
if (!empty($_SESSION['access_token'])) {
$oauth->access_token = $_SESSION['access_token'];
$oauth->refresh_token = $_SESSION['refresh_token'];
$api->oauth->access_token = $_SESSION['access_token'];
$api->oauth->refresh_token = $_SESSION['refresh_token'];
}
$api = new PodioAPI();

18 changes: 11 additions & 7 deletions scrumio.classes.php
Expand Up @@ -179,9 +179,6 @@ public function __construct($sprint) {
}
}
// Find active sprint
// $filters = array(array('key' => SPRINT_STATE_ID, 'values' => array('Active')));
// $sprints = $api->item->getItems(SPRINT_APP_ID, 1, 0, 'title', 0, $filters);
// $sprint = $sprints['items'][0];
$sprint_id = $sprint['item_id'];

// Set sprint properties
Expand All @@ -195,10 +192,14 @@ public function __construct($sprint) {
}

// Get all stories in this sprint
$filters = array(array('key' => STORY_SPRINT_ID, 'values' => array($sprint_id)));
$sort_by = defined('STORY_IMPORTANCE_ID') && STORY_IMPORTANCE_ID ? STORY_IMPORTANCE_ID : 'title';
$sort_desc = defined('STORY_IMPORTANCE_ID') && STORY_IMPORTANCE_ID ? 1 : 0;
$stories = $api->item->getItems(STORY_APP_ID, 200, 0, $sort_by, $sort_desc, $filters);
$stories = $api->item->getItems(STORY_APP_ID, array(
'limit' => 200,
'sort_by' => $sort_by,
'sort_desc' => $sort_desc,
STORY_SPRINT_ID => $sprint_id,
));

// Grab all story items for all stories in one go
$stories_ids = array();
Expand All @@ -211,8 +212,11 @@ public function __construct($sprint) {
$stories_estimates[$story['item_id']] = 0;
$stories_time_left[$story['item_id']] = 0;
}
$filters = array(array('key' => ITEM_STORY_ID, 'values' => $stories_ids));
$raw = $api->item->getItems(ITEM_APP_ID, 200, 0, 'title', 0, $filters);
$raw = $api->item->getItems(ITEM_APP_ID, array(
'limit' => 200,
'sort_by' => 'title',
ITEM_STORY_ID => join(';', $stories_ids),
));
foreach ($raw['items'] as $item) {
$item = new ScrumioItem($item);
$stories_items[$item->story_id][] = $item;
Expand Down

0 comments on commit 7289236

Please sign in to comment.