diff --git a/Basecamp.class.php b/Basecamp.class.php index 2ec8f32..b7ffe55 100644 --- a/Basecamp.class.php +++ b/Basecamp.class.php @@ -1,4 +1,4 @@ -account/$target"; } - + //- mark Projects - function getProjects() { - return $this->_makeAuthenticatedRequest($this->getAccountURL('projects.json')); + //- jilagan: Modified to support limit and offset parameters, since default only allows for + // 25 entries at a time and with offset = 0 + function getProjects($limit=25, $offset=0) { + return $this->_makeAuthenticatedRequest($this->getAccountURL('projects.json?limit=' . $limit . '&offset=' . $offset)); } function getProject($id,$native=false) { @@ -403,7 +405,8 @@ function createComment($project,$on,$id,$comment,$subscribers='',$attachmentName if ( $attachmentName ) { if ( $isFilename ) { - //createAttachment and get token + $attachment = $this->createAttachment($tokenOrFilename); + $token = $attachment->token; } else $token = $tokenOrFilename; $args['attachments'] = array(new Basecamp_Attachment($token,$attachmentName)); } @@ -537,8 +540,22 @@ function updateMilestone($source,$sourceid,$id,$summary='',$description='',$star function deleteMilestone($source,$sourceid,$id) { return $this->_makeAuthenticatedRequest($this->getAccountURL("$source/$sourceid/calendar_events/$id.json"),null,'DELETE'); + } + + //- mark Stars + + function getStars() { + return $this->_makeAuthenticatedRequest($this->getAccountURL('stars.json')); } + function starProject($projectid) { + return $this->_makeAuthenticatedRequest($this->getAccountURL("projects/$projectid/star.json"),json_encode(array('project_id'=>$projectid)),'POST'); + } + + function unStarProject($projectid) { + return $this->_makeAuthenticatedRequest($this->getAccountURL("projects/$projectid/star.json"),null,'DELETE'); + } + //- makeArray function _makeArray($arg) { if ( $arg && !is_array($arg) ) return array($arg); @@ -621,12 +638,21 @@ function _makeAuthenticatedRequest($resource,$params=array(),$method='GET',$head if ( $http_code == 401 ) { $response = json_encode(array('error_code'=>401,'error'=>'Unauthorized Access')); - } + } elseif ( $http_code == 403 ) { + $response = json_encode(array('error_code'=>403,'error'=>'Forbidden')); + } + elseif ( $http_code == 429 ) { + $response = json_encode(array('error_code'=>429,'error'=>'Too Many Requests')); + } + elseif ( $http_code == 422 ) { + $response = json_encode(array('error_code'=>422,'error'=>'Identical Record Created Within Last 5 Mins')); + } if ( $this->debug ) { print_r(curl_getinfo($ch)); - print $header; - print $response; + print "Header: $header\n"; + print "Params: ".print_r($params,1); + print "Response: $response\n"; } if ( $returnRawResponse ) return $response; diff --git a/Basecamp/Attachment.php b/Basecamp/Attachment.php index 48ec177..916ed65 100644 --- a/Basecamp/Attachment.php +++ b/Basecamp/Attachment.php @@ -1,4 +1,5 @@ -_basecamp->deleteProject($this->id); } + + function star() { + return $this->_basecamp->starProject($this->id); + } + + function unstar() { + return $this->_basecamp->unStarProject($this->id); + } + } ?> \ No newline at end of file