Skip to content

Commit

Permalink
Merge pull request #41 from biblibre/NCSU_Propose_API_merged_repo
Browse files Browse the repository at this point in the history
Add an API to Coral (Issue #7)
  • Loading branch information
benheet authored Dec 2, 2016
2 parents 81c3b3a + 4596ee7 commit b200fae
Show file tree
Hide file tree
Showing 13 changed files with 662 additions and 2 deletions.
1 change: 1 addition & 0 deletions resources/README
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and follow instructions

For the manual install, refer to the Technical Documentation available on http://erm.library.nd.edu

For setting up the API, please see the README in resources/api/

**************************
License / Copyright notices
Expand Down
6 changes: 6 additions & 0 deletions resources/admin/classes/domain/Fund.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public function getNumberOfChildren(){
return $result['childCount'];
}

public function getFundIDFromFundCode($fundCode) {
$query = "SELECT fundID FROM Fund WHERE fundCode = '" . $fundCode . "';";
$result = $this->db->processQuery($query, 'assoc');
return isset($result['fundID']) ? $result['fundID'] : null;
}

//returns array of archived objects
public function getUnArchivedFunds(){

Expand Down
12 changes: 11 additions & 1 deletion resources/admin/classes/domain/NoteType.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public function getInitialNoteTypeID() {
}
}

public function getNoteTypeIDByName($name) {
$query = "SELECT * FROM NoteType WHERE shortName='$name' LIMIT 0,1";
$result = $this->db->processQuery($query, 'assoc');

if (isset($result['noteTypeID'])){
return $result['noteTypeID'];
}else{
return null;
}
}

//returns number of children for this particular contact role
public function getNumberOfChildren(){
Expand All @@ -79,4 +89,4 @@ public function getNumberOfChildren(){

}

?>
?>
5 changes: 4 additions & 1 deletion resources/admin/classes/domain/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2101,14 +2101,17 @@ public function enterNewWorkflow($workflowID = null){
$resourceStep->stepID = $step->stepID;
$resourceStep->priorStepID = $step->priorStepID;
$resourceStep->stepName = $step->stepName;
$resourceStep->stepStartDate = '';
$resourceStep->stepEndDate = '';
$resourceStep->archivingDate = '';
$resourceStep->endLoginID = '';
$resourceStep->userGroupID = $step->userGroupID;
$resourceStep->displayOrderSequence = $step->displayOrderSequence;

$resourceStep->save();

}


//Start the first step
//this handles updating the db and sending notifications for approval groups
foreach ($this->getFirstSteps() as $resourceStep) {
Expand Down
4 changes: 4 additions & 0 deletions resources/api/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
4 changes: 4 additions & 0 deletions resources/api/INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The API uses Flight, a fast, simple, extensible framework for PHP.
Just install Flight in this directory, so Flight.php is available like this: resources/api/Flight/flight/Flight.php

http://flightphp.com/
15 changes: 15 additions & 0 deletions resources/api/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Edit resources/admin/configuration.ini and fill apiAuthorizedIP in the [settings] section with the IP address of the client accessing the API:
apiAuthorizedIP="192.168.1.1"

You can set multiple IPs (comma-separated):
apiAuthorizedIP="192.168.1.1,192.168.2"

You can also set incomplete IPs so the whole range will be allowed:
apiAuthorizedIP="192.168.1"
(will authorize all IPs from 192.168.1.1 to 192.168.1.255)

If you are trying to access the API from the machine it is installed on, you can use the loopback interface (127.0.0.1).

Hint: if you don't know which IP address will be requesting the API, just leave apiAuthorizedIP blank (apiAuthorizedIP="") and access the example form with your browser ( http://yourcoral.tld/resources/api_client/ ), you will get an error like this:
You are not authorized to use this service.
Unauthorized IP: 127.0.0.1
Loading

0 comments on commit b200fae

Please sign in to comment.