diff --git a/index.php b/index.php index aac71bf..faa292e 100644 --- a/index.php +++ b/index.php @@ -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 @@ -63,10 +63,10 @@ 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 {$e->body['error']} and the message {$e->body['error_description']}
Go back"); @@ -74,8 +74,15 @@ function authorize() { } 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 { @@ -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'); } diff --git a/init.php b/init.php index c4a70d1..7db65c1 100644 --- a/init.php +++ b/init.php @@ -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; diff --git a/scrumio.classes.php b/scrumio.classes.php index f09fda0..2999b30 100644 --- a/scrumio.classes.php +++ b/scrumio.classes.php @@ -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) { @@ -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, @@ -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),