Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function scrumboard() {
// Grab sprints and find current sprint
// $filters = array(array('key' => SPRINT_STATE_ID, 'values' => array('Active')));
try {
$sprints = $api->item->getItems(SPRINT_APP_ID, array(
$sprints = PodioItem::filter( SPRINT_APP_ID, array(
'limit' => 5,
'sort_by' => 'created_on',
'sort_desc' => 1
Expand Down Expand Up @@ -63,19 +63,26 @@ function authorize() {
// Successful authorization. Store the access token in the session
if (!isset($_GET['error'])) {
try {
$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);
Podio::authenticate('authorization_code', array('code' => $_GET['code'], 'redirect_uri' => option('OAUTH_REDIRECT_URI')));
$_SESSION['access_token'] = Podio::$oauth->access_token;
$_SESSION['refresh_token'] = Podio::$oauth->refresh_token;
$story_app = PodioApp::get(STORY_APP_ID);
}
catch (PodioError $e) {
die("There was an error. The API responded with the error type <b>{$e->body['error']}</b> and the message <b>{$e->body['error_description']}</b><br><a href='".url_for('/')."'>Go back</a>");
}
}

if ($story_app) {
$_SESSION['story_app'] = $story_app;
$_SESSION['space'] = $api->space->get($_SESSION['story_app']['space_id']);
//$_SESSION['story_app'] = $story_app;
//$_SESSION['space'] = PodioSpace::get($_SESSION['story_app']['space_id']);
/*
$_SESSION['story_app'] and $_SESSION['space'] are only used inside check
in scrumboard() and their values are never used, so set them to something
just to pass these checks
*/
$_SESSION['space'] = STORY_APP_ID;
$_SESSION['story_app'] = STORY_APP_ID;
redirect_to('');
}
else {
Expand All @@ -94,17 +101,17 @@ function update_time_left() {
$state = $_POST['state'];

$data = array(array('value' => $state));
$api->item->updateFieldValue($item_id, ITEM_STATE_ID, $data);
PodioItemField::update($item_id, ITEM_STATE_ID, $data);

// Set time_left to '0' when moving to one of the 'done' states
if (in_array($state, array(STATE_DEV_DONE, STATE_QA_DONE, STATE_PO_DONE))) {
$api->item->updateFieldValue($item_id, ITEM_TIMELEFT_ID, array(array('value' => 0)), 1);
PodioItemField::update($item_id, ITEM_TIMELEFT_ID, array(array('value' => 0)), 1);
}
// Reset time left when moving to Not Started
elseif ($state == STATE_NOT_STARTED) {
$item = $api->item->getBasic($item_id);
$item = PodioItem::get_basic($item_id);
$item = new ScrumioItem($item);
$api->item->updateFieldValue($item_id, ITEM_TIMELEFT_ID, array(array('value' => $item->estimate*60*60)), 1);
PodioItemField::update($item_id, ITEM_TIMELEFT_ID, array(array('value' => $item->estimate*60*60)), 1);
}
return txt('ok');
}
Expand Down
2 changes: 1 addition & 1 deletion init.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
session_start();

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

// $api->debug = true;

Expand Down
6 changes: 3 additions & 3 deletions scrumio.classes.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function __construct($sprint) {
global $api;
try {
// Locate available states
$items_app = $api->app->get(ITEM_APP_ID);
$items_app = PodioApp::get(ITEM_APP_ID);
$this->states = array();
if(is_array($items_app['fields'])) {
foreach ($items_app['fields'] as $field) {
Expand All @@ -218,7 +218,7 @@ public function __construct($sprint) {
// Get all stories in this sprint
$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, array(
$stories = PodioItem::filter(STORY_APP_ID, array(
'limit' => 200,
'sort_by' => $sort_by,
'sort_desc' => $sort_desc,
Expand All @@ -236,7 +236,7 @@ public function __construct($sprint) {
$stories_estimates[$story['item_id']] = 0;
$stories_time_left[$story['item_id']] = 0;
}
$raw = $api->item->getItems(ITEM_APP_ID, array(
$raw = PodioItem::filter(ITEM_APP_ID, array(
'limit' => 200,
'sort_by' => 'title',
ITEM_STORY_ID => join(';', $stories_ids),
Expand Down