From c9a4f40870311de6fe3623dcfd9c3150e006f4b4 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Thu, 23 Feb 2017 14:48:30 +0000 Subject: [PATCH 1/8] Add webservices for resources --- resources/admin/classes/domain/Resource.php | 17 ++++++++- resources/api/index.php | 42 +++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/resources/admin/classes/domain/Resource.php b/resources/admin/classes/domain/Resource.php index 0675b5625..3d04167ee 100644 --- a/resources/admin/classes/domain/Resource.php +++ b/resources/admin/classes/domain/Resource.php @@ -25,7 +25,22 @@ protected function defineIsbnOrIssn() {} protected function overridePrimaryKeyName() {} - + public function asArray() { + $rarray = array(); + foreach (array_keys($this->attributeNames) as $attributeName) { + if ($this->$attributeName != null) { + $rarray[$attributeName] = $this->$attributeName; + } + } + $identifiers = $this->getIsbnOrIssn(); + $rarray['isbnOrIssn'] = array(); + foreach ($identifiers as $identifier) { + array_push($rarray['isbnOrIssn'], $identifier->isbnOrIssn); + } + return $rarray; + + + } //returns resource objects by title public function getResourceByTitle($title) { diff --git a/resources/api/index.php b/resources/api/index.php index 52adbb359..ca83e1f7d 100644 --- a/resources/api/index.php +++ b/resources/api/index.php @@ -19,6 +19,7 @@ include_once '../admin/classes/domain/ResourcePayment.php'; include_once '../admin/classes/domain/AdministeringSite.php'; include_once '../admin/classes/domain/ResourceAdministeringSiteLink.php'; +include_once '../admin/classes/domain/ResourceRelationship.php'; include_once '../admin/classes/domain/Status.php'; include_once '../admin/classes/domain/User.php'; include_once '../admin/classes/domain/Workflow.php'; @@ -26,6 +27,8 @@ include_once '../admin/classes/domain/ResourceStep.php'; include_once '../admin/classes/domain/UserGroup.php'; include_once '../admin/classes/domain/Fund.php'; +include_once '../admin/classes/domain/IsbnOrIssn.php'; +include_once '../../licensing/admin/classes/domain/License.php'; if (!isAllowed()) { header('HTTP/1.0 403 Forbidden'); @@ -283,6 +286,45 @@ Flight::json($as->shortName); }); +Flight::route('GET /resources/@id', function($id) { + $r = new Resource(new NamedArguments(array('primaryKey' => $id))); + Flight::json($r->asArray()); + +}); + +Flight::route('GET /resources?identifier=@id', function($id) { + Flight::json($id); +}); + +Flight::route('GET /resources/@id/titles', function($id) { + $r = new Resource(new NamedArguments(array('primaryKey' => $id))); + $childResourceArray = array(); + $childResourceIDArray = array(); + foreach ($r->getChildResources() as $instance) { + foreach (array_keys($instance->attributeNames) as $attributeName) { + $sanitizedInstance[$attributeName] = $instance->$attributeName; + } + $sanitizedInstance[$instance->primaryKeyName] = $instance->primaryKey; + array_push($childResourceIDArray, $sanitizedInstance); + } + + foreach ($childResourceIDArray as $childResource){ + $childResourceObj = new Resource(new NamedArguments(array('primaryKey' => $childResource['resourceID']))); + array_push($childResourceArray, $childResourceObj->asArray()); + } + Flight::json($childResourceArray); +}); + +Flight::route('GET /resources/@id/licenses', function($id) { + $r = new Resource(new NamedArguments(array('primaryKey' => $id))); + $licensesArray = array(); + foreach($r->getLicenseArray() as $license) { + // TODO: We need a way to call Objects from other modules. Currently, this won't work: + $l = new License(new NamedArguments(array('primaryKey' => $license['licenseID']))); + array_push($licensesArray, $l); + } + Flight::json($licensesArray); +}); Flight::start(); From 61dddb4d2320ec77af364ed6585db99c1f599990 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Thu, 23 Feb 2017 15:17:28 +0000 Subject: [PATCH 2/8] Issue 145: Use singleton for database connection --- resources/admin/classes/common/DBService.php | 13 +++++++++++++ resources/admin/classes/common/DatabaseObject.php | 6 +++--- resources/admin/classes/domain/Resource.php | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/resources/admin/classes/common/DBService.php b/resources/admin/classes/common/DBService.php index 4cbc77ffb..35bc06c6a 100644 --- a/resources/admin/classes/common/DBService.php +++ b/resources/admin/classes/common/DBService.php @@ -22,6 +22,19 @@ class DBService extends Object { protected $db; protected $config; protected $error; + private static $_instance; //The single instance + + +/* + Get an instance of the Database + @return Instance + */ + public static function getInstance() { + if(!self::$_instance) { // If no instance then make one + self::$_instance = new self(); + } + return self::$_instance; + } protected function init(NamedArguments $arguments) { parent::init($arguments); diff --git a/resources/admin/classes/common/DatabaseObject.php b/resources/admin/classes/common/DatabaseObject.php index 4fafa6b45..dff15fb6c 100644 --- a/resources/admin/classes/common/DatabaseObject.php +++ b/resources/admin/classes/common/DatabaseObject.php @@ -52,10 +52,10 @@ protected function init(NamedArguments $arguments) { $this->primaryKeyName = $arguments->primaryKeyName; $this->primaryKey = $arguments->primaryKey; - $this->db = new DBService; + $this->db = DBService::getInstance();; $arguments->setDefaultValueForArgumentName('db',false); - $this->db = $arguments->db ? $arguments->db : new DBService; + $this->db = $arguments->db ? $arguments->db : DBService::getInstance(); $this->defineRelationships(); //$this->defineAttributes(); //now performed in load @@ -309,4 +309,4 @@ public function load() { } -?> \ No newline at end of file +?> diff --git a/resources/admin/classes/domain/Resource.php b/resources/admin/classes/domain/Resource.php index 3d04167ee..a022ae392 100644 --- a/resources/admin/classes/domain/Resource.php +++ b/resources/admin/classes/domain/Resource.php @@ -156,7 +156,7 @@ private function getRelatedResources($key) { $object = new ResourceRelationship(new NamedArguments(array('primaryKey' => $result['resourceRelationshipID']))); array_push($objects, $object); }else{ - $db = new DBService; + $db = DBService::getInstance(); foreach ($result as $row) { $object = new ResourceRelationship(new NamedArguments(array('primaryKey' => $row['resourceRelationshipID'],'db'=>$db))); array_push($objects, $object); From 38f8f8bfef1264620297be2f5ad0933f5be325d7 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Fri, 24 Feb 2017 11:03:20 +0000 Subject: [PATCH 3/8] Add webservices for licenses --- .../admin/classes/common/DatabaseObject.php | 11 +++++++- licensing/admin/classes/domain/Document.php | 12 ++++++++- licensing/admin/classes/domain/Expression.php | 11 +++++++- .../admin/classes/domain/ExpressionNote.php | 13 ++++++++- licensing/admin/classes/domain/License.php | 27 +++++++++++++++++++ resources/admin/classes/common/DBService.php | 5 ++++ resources/api/index.php | 13 ++++++--- 7 files changed, 85 insertions(+), 7 deletions(-) diff --git a/licensing/admin/classes/common/DatabaseObject.php b/licensing/admin/classes/common/DatabaseObject.php index f7a1331cc..7c27624fb 100644 --- a/licensing/admin/classes/common/DatabaseObject.php +++ b/licensing/admin/classes/common/DatabaseObject.php @@ -64,6 +64,15 @@ protected function init(NamedArguments $arguments) { protected function defineRelationships() {} protected function overridePrimaryKeyName() {} + protected function asArray() { + $aarray = array(); + foreach (array_keys($this->attributeNames) as $attributeName) { + if ($this->$attributeName != null) { + $aarray[$attributeName] = $this->$attributeName; + } + } + return $aarray; + } protected function defineAttributes() { // Figure out attributes from existing database @@ -298,4 +307,4 @@ public function load() { } -?> \ No newline at end of file +?> diff --git a/licensing/admin/classes/domain/Document.php b/licensing/admin/classes/domain/Document.php index 5b956d7d2..5c0d1cc23 100644 --- a/licensing/admin/classes/domain/Document.php +++ b/licensing/admin/classes/domain/Document.php @@ -23,6 +23,16 @@ protected function defineRelationships() {} protected function overridePrimaryKeyName() {} + protected function asArray() { + $aarray = array(); + foreach (array_keys($this->attributeNames) as $attributeName) { + if ($this->$attributeName != null) { + $aarray[$attributeName] = $this->$attributeName; + } + } + return $aarray; + } + //returns 1 or 0 indicating if this particular document has children agreements public function getNumberOfChildren(){ @@ -248,4 +258,4 @@ public function getExpressionsForDisplay(){ } -?> \ No newline at end of file +?> diff --git a/licensing/admin/classes/domain/Expression.php b/licensing/admin/classes/domain/Expression.php index 5b7d9f8cb..5813e1d47 100644 --- a/licensing/admin/classes/domain/Expression.php +++ b/licensing/admin/classes/domain/Expression.php @@ -23,7 +23,16 @@ protected function defineRelationships() {} protected function overridePrimaryKeyName() {} - + public function asArray() { + $aarray = array(); + foreach (array_keys($this->attributeNames) as $attributeName) { + if ($this->$attributeName != null) { + $aarray[$attributeName] = $this->$attributeName; + } + } + return $aarray; + // return parent::asArray(); + } diff --git a/licensing/admin/classes/domain/ExpressionNote.php b/licensing/admin/classes/domain/ExpressionNote.php index f5e7b3afb..1d9dfe348 100644 --- a/licensing/admin/classes/domain/ExpressionNote.php +++ b/licensing/admin/classes/domain/ExpressionNote.php @@ -23,6 +23,17 @@ protected function defineRelationships() {} protected function overridePrimaryKeyName() {} + public function asArray() { + $aarray = array(); + foreach (array_keys($this->attributeNames) as $attributeName) { + if ($this->$attributeName != null) { + $aarray[$attributeName] = $this->$attributeName; + } + } + return $aarray; + // return parent::asArray(); + } + //reorders expression note based on direction the user clicked @@ -67,4 +78,4 @@ public function reorder($dir, $oldSeq){ } -?> \ No newline at end of file +?> diff --git a/licensing/admin/classes/domain/License.php b/licensing/admin/classes/domain/License.php index 21cf4fcf3..ae7258b08 100644 --- a/licensing/admin/classes/domain/License.php +++ b/licensing/admin/classes/domain/License.php @@ -23,6 +23,33 @@ protected function defineRelationships() {} protected function overridePrimaryKeyName() {} + public function asArray() { + $larray = array(); + foreach (array_keys($this->attributeNames) as $attributeName) { + if ($this->$attributeName != null) { + $larray[$attributeName] = $this->$attributeName; + } + } + $doccount = 0; + foreach ($this->getDocuments() as $document) { + $larray['documents'][$doccount]['content'] = $document->asArray(); + $exprcount = 0; + foreach ($document->getExpressions() as $expression) { + $expressionType = new ExpressionType(new NamedArguments(array('primaryKey' => $expression->expressionTypeID))); + if ($expressionType->noteType == "Display") { + $larray['documents'][$doccount]['expressions'][$exprcount]['content'] = $expression->asArray(); + $notescount = 0; + foreach ($expression->getExpressionNotes() as $expressionNote) { + $larray['documents'][$doccount]['expressions'][$exprcount]['notes'][$notescount] = $expressionNote->asArray();; + $notescount++; + } + $exprcount++; + } + } + $doccount++; + } + return $larray; + } //returns array of Document objects - used by forms to get dropdowns of available documents diff --git a/resources/admin/classes/common/DBService.php b/resources/admin/classes/common/DBService.php index 35bc06c6a..d6970fdd6 100644 --- a/resources/admin/classes/common/DBService.php +++ b/resources/admin/classes/common/DBService.php @@ -66,6 +66,11 @@ protected function connect() { $this->checkForError(); } + public function changeDb($name = null) { + $dbName = ($name == null) ? $this->config->database->name : $this->config->settings->$name; + $this->db->select_db($dbName); + } + protected function disconnect() { //mysqli_close($this->db); } diff --git a/resources/api/index.php b/resources/api/index.php index ca83e1f7d..15907063b 100644 --- a/resources/api/index.php +++ b/resources/api/index.php @@ -29,6 +29,10 @@ include_once '../admin/classes/domain/Fund.php'; include_once '../admin/classes/domain/IsbnOrIssn.php'; include_once '../../licensing/admin/classes/domain/License.php'; +include_once '../../licensing/admin/classes/domain/Document.php'; +include_once '../../licensing/admin/classes/domain/Expression.php'; +include_once '../../licensing/admin/classes/domain/ExpressionNote.php'; +include_once '../../licensing/admin/classes/domain/ExpressionType.php'; if (!isAllowed()) { header('HTTP/1.0 403 Forbidden'); @@ -316,13 +320,16 @@ }); Flight::route('GET /resources/@id/licenses', function($id) { + $db = DBService::getInstance(); $r = new Resource(new NamedArguments(array('primaryKey' => $id))); $licensesArray = array(); - foreach($r->getLicenseArray() as $license) { - // TODO: We need a way to call Objects from other modules. Currently, this won't work: + $rla = $r->getLicenseArray(); + $db->changeDb('licensingDatabaseName'); + foreach($rla as $license) { $l = new License(new NamedArguments(array('primaryKey' => $license['licenseID']))); - array_push($licensesArray, $l); + array_push($licensesArray, $l->asArray()); } + $db->changeDb(); Flight::json($licensesArray); }); From 09db6a3e77f690f05d669859a775c9e3fba220ab Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Mon, 27 Feb 2017 15:02:52 +0000 Subject: [PATCH 4/8] Add webservices for licenses [WIP] --- resources/admin/classes/domain/Resource.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/resources/admin/classes/domain/Resource.php b/resources/admin/classes/domain/Resource.php index a022ae392..4f71ef07d 100644 --- a/resources/admin/classes/domain/Resource.php +++ b/resources/admin/classes/domain/Resource.php @@ -32,6 +32,23 @@ public function asArray() { $rarray[$attributeName] = $this->$attributeName; } } + + $status = new Status(new NamedArguments(array('primaryKey' => $this->statusID))); + $rarray['status'] = $status->shortName; + +/* + // TODO: This works in /resources but not in /resources/id/titles + $resourceType = new ResourceType(new NamedArguments(array('primaryKey' => $this->resourceTypeID))); + $rarray['resourceType'] = ($resourceType->shortName != null) ? $resourceType->shortName : null; + + $resourceFormat = new ResourceFormat(new NamedArguments(array('primaryKey' => $this->resourceFormatID))); + $rarray['resourceFormat'] = isset($resourceFormat->shortName) ? $resourceFormat->shortName : null; + + $acquisitionType = new AcquisitionType(new NamedArguments(array('primaryKey' => $this->acquisitionTypeID))); + $rarray['acquisitionType'] = isset($acquisitionType->shortName) ? $acquisitionType->shortName : null; +*/ + + $identifiers = $this->getIsbnOrIssn(); $rarray['isbnOrIssn'] = array(); foreach ($identifiers as $identifier) { From 71d06cb670f58ddb6e8c5d73b5efdbe09bcdc926 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Tue, 28 Feb 2017 11:07:32 +0000 Subject: [PATCH 5/8] Add webservices [WIP] --- licensing/admin/classes/domain/Document.php | 4 +++- licensing/admin/classes/domain/Expression.php | 3 ++- licensing/admin/classes/domain/License.php | 3 +-- management/admin/classes/domain/Document.php | 2 +- .../admin/classes/domain/Organization.php | 17 +++++++++++++++ resources/admin/classes/domain/Resource.php | 21 +++++++++++-------- resources/api/index.php | 14 +++++++++++++ 7 files changed, 50 insertions(+), 14 deletions(-) diff --git a/licensing/admin/classes/domain/Document.php b/licensing/admin/classes/domain/Document.php index 5c0d1cc23..cfde84763 100644 --- a/licensing/admin/classes/domain/Document.php +++ b/licensing/admin/classes/domain/Document.php @@ -23,13 +23,15 @@ protected function defineRelationships() {} protected function overridePrimaryKeyName() {} - protected function asArray() { + public function asArray() { $aarray = array(); foreach (array_keys($this->attributeNames) as $attributeName) { if ($this->$attributeName != null) { $aarray[$attributeName] = $this->$attributeName; } } + $documentType = new DocumentType(new NamedArguments(array("primaryKey" => $this->documentTypeID))); + $aarray['documentType'] = $documentType->shortName; return $aarray; } diff --git a/licensing/admin/classes/domain/Expression.php b/licensing/admin/classes/domain/Expression.php index 5813e1d47..80e907b1d 100644 --- a/licensing/admin/classes/domain/Expression.php +++ b/licensing/admin/classes/domain/Expression.php @@ -30,8 +30,9 @@ public function asArray() { $aarray[$attributeName] = $this->$attributeName; } } + $expressionType = new ExpressionType(new NamedArguments(array("primaryKey" => $this->expressionTypeID))); + $aarray['expressionType'] = $expressionType->shortName; return $aarray; - // return parent::asArray(); } diff --git a/licensing/admin/classes/domain/License.php b/licensing/admin/classes/domain/License.php index ae7258b08..00a9f6674 100644 --- a/licensing/admin/classes/domain/License.php +++ b/licensing/admin/classes/domain/License.php @@ -32,7 +32,7 @@ public function asArray() { } $doccount = 0; foreach ($this->getDocuments() as $document) { - $larray['documents'][$doccount]['content'] = $document->asArray(); + $larray['documents'][$doccount]['content'] = $document->asArray();; $exprcount = 0; foreach ($document->getExpressions() as $expression) { $expressionType = new ExpressionType(new NamedArguments(array('primaryKey' => $expression->expressionTypeID))); @@ -78,7 +78,6 @@ public function getDocuments(){ array_push($objects, $object); } } - return $objects; } diff --git a/management/admin/classes/domain/Document.php b/management/admin/classes/domain/Document.php index 0961a4bb3..a7ceaa108 100644 --- a/management/admin/classes/domain/Document.php +++ b/management/admin/classes/domain/Document.php @@ -248,4 +248,4 @@ public function getExpressionsForDisplay(){ } -?> \ No newline at end of file +?> diff --git a/organizations/admin/classes/domain/Organization.php b/organizations/admin/classes/domain/Organization.php index 0b9827236..6e7923c60 100644 --- a/organizations/admin/classes/domain/Organization.php +++ b/organizations/admin/classes/domain/Organization.php @@ -24,6 +24,23 @@ protected function defineRelationships() {} protected function overridePrimaryKeyName() {} + public function asArray() { + $rarray = array(); + foreach (array_keys($this->attributeNames) as $attributeName) { + if ($this->$attributeName != null) { + $rarray[$attributeName] = $this->$attributeName; + } + } + + $aliases = $this->getAliases(); + $rarray['aliases'] = array(); + foreach ($aliases as $alias) { + array_push($rarray['aliases'], $alias->name); + } + + return $rarray; + } + //returns array of parent organization objects diff --git a/resources/admin/classes/domain/Resource.php b/resources/admin/classes/domain/Resource.php index 4f71ef07d..14780f3f8 100644 --- a/resources/admin/classes/domain/Resource.php +++ b/resources/admin/classes/domain/Resource.php @@ -36,17 +36,20 @@ public function asArray() { $status = new Status(new NamedArguments(array('primaryKey' => $this->statusID))); $rarray['status'] = $status->shortName; -/* - // TODO: This works in /resources but not in /resources/id/titles - $resourceType = new ResourceType(new NamedArguments(array('primaryKey' => $this->resourceTypeID))); - $rarray['resourceType'] = ($resourceType->shortName != null) ? $resourceType->shortName : null; + if ($this->resourceTypeID) { + $resourceType = new ResourceType(new NamedArguments(array('primaryKey' => $this->resourceTypeID))); + $rarray['resourceType'] = $resourceType->shortName; + } - $resourceFormat = new ResourceFormat(new NamedArguments(array('primaryKey' => $this->resourceFormatID))); - $rarray['resourceFormat'] = isset($resourceFormat->shortName) ? $resourceFormat->shortName : null; + if ($this->resourceFormatID) { + $resourceFormat = new ResourceFormat(new NamedArguments(array('primaryKey' => $this->resourceFormatID))); + $rarray['resourceFormat'] = $resourceFormat->shortName; + } - $acquisitionType = new AcquisitionType(new NamedArguments(array('primaryKey' => $this->acquisitionTypeID))); - $rarray['acquisitionType'] = isset($acquisitionType->shortName) ? $acquisitionType->shortName : null; -*/ + if ($this->acquisitionTypeID) { + $acquisitionType = new AcquisitionType(new NamedArguments(array('primaryKey' => $this->acquisitionTypeID))); + $rarray['acquisitionType'] = $acquisitionType->shortName; + } $identifiers = $this->getIsbnOrIssn(); diff --git a/resources/api/index.php b/resources/api/index.php index 15907063b..b155aa207 100644 --- a/resources/api/index.php +++ b/resources/api/index.php @@ -30,9 +30,14 @@ include_once '../admin/classes/domain/IsbnOrIssn.php'; include_once '../../licensing/admin/classes/domain/License.php'; include_once '../../licensing/admin/classes/domain/Document.php'; +include_once '../../licensing/admin/classes/domain/DocumentType.php'; include_once '../../licensing/admin/classes/domain/Expression.php'; include_once '../../licensing/admin/classes/domain/ExpressionNote.php'; include_once '../../licensing/admin/classes/domain/ExpressionType.php'; +include_once '../../organizations/admin/classes/domain/Organization.php'; +include_once '../../organizations/admin/classes/domain/Alias.php'; + + if (!isAllowed()) { header('HTTP/1.0 403 Forbidden'); @@ -333,6 +338,15 @@ Flight::json($licensesArray); }); + +Flight::route('GET /organizations/@id', function($id) { + $db = DBService::getInstance(); + $db->changeDb('organizationsDatabaseName'); + $organization = new Organization(new NamedArguments(array('primaryKey' => $id))); + Flight::json($organization->asArray()); + $db->changeDb(); +}); + Flight::start(); function isAllowed() { From b2085a98ecf5786083ba6052f1f8ab4468c1707b Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Mon, 13 Mar 2017 13:46:23 +0000 Subject: [PATCH 6/8] Add resource search by isbn/issn --- resources/api/index.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/api/index.php b/resources/api/index.php index b155aa207..5a426dec9 100644 --- a/resources/api/index.php +++ b/resources/api/index.php @@ -301,8 +301,12 @@ }); -Flight::route('GET /resources?identifier=@id', function($id) { - Flight::json($id); +Flight::route('GET /resources/', function() { + $identifier = Flight::request()->query->identifier; + if ($identifier) { + $r = new Resource(); + Flight::json(array_map(function($value) { return $value->asArray(); }, $r->getResourceByIsbnOrISSN($identifier))); + } }); Flight::route('GET /resources/@id/titles', function($id) { From 4a437231a307fda1e4ce5eea231ff33ce13d8eb1 Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Thu, 14 Sep 2017 09:53:07 +0200 Subject: [PATCH 7/8] Handle organizations when the organization module is disabled --- resources/admin/classes/domain/Organization.php | 10 +++++++++- resources/api/index.php | 17 ++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/resources/admin/classes/domain/Organization.php b/resources/admin/classes/domain/Organization.php index 2bf8f72a1..18cd27251 100644 --- a/resources/admin/classes/domain/Organization.php +++ b/resources/admin/classes/domain/Organization.php @@ -24,7 +24,15 @@ protected function defineRelationships() {} protected function overridePrimaryKeyName() {} - + public function asArray() { + $rarray = array(); + foreach (array_keys($this->attributeNames) as $attributeName) { + if ($this->$attributeName != null) { + $rarray[$attributeName] = $this->$attributeName; + } + } + return $rarray; + } //returns number of children for this particular contact role public function getNumberOfChildren(){ diff --git a/resources/api/index.php b/resources/api/index.php index 5a426dec9..672d63fd9 100644 --- a/resources/api/index.php +++ b/resources/api/index.php @@ -34,7 +34,6 @@ include_once '../../licensing/admin/classes/domain/Expression.php'; include_once '../../licensing/admin/classes/domain/ExpressionNote.php'; include_once '../../licensing/admin/classes/domain/ExpressionType.php'; -include_once '../../organizations/admin/classes/domain/Organization.php'; include_once '../../organizations/admin/classes/domain/Alias.php'; @@ -344,11 +343,19 @@ Flight::route('GET /organizations/@id', function($id) { + $config = new Configuration(); $db = DBService::getInstance(); - $db->changeDb('organizationsDatabaseName'); - $organization = new Organization(new NamedArguments(array('primaryKey' => $id))); - Flight::json($organization->asArray()); - $db->changeDb(); + if ($config->settings->organizationsModule == 'Y') { + include_once '../../organizations/admin/classes/domain/Organization.php'; + $db->changeDb('organizationsDatabaseName'); + $organization = new Organization(new NamedArguments(array('primaryKey' => $id))); + Flight::json($organization->asArray()); + $db->changeDb(); + } else { + include_once '../admin/classes/domain/Organization.php'; + $organization = new Organization(new NamedArguments(array('primaryKey' => $id))); + Flight::json($organization->asArray()); + } }); Flight::start(); From 745e19ba28f58b3bc0071b4cf20da492f2ba90ac Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Tue, 19 Dec 2017 10:05:52 +0100 Subject: [PATCH 8/8] Fix for PR#299 --- resources/api/index.php | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/resources/api/index.php b/resources/api/index.php index 672d63fd9..773ba5eb9 100644 --- a/resources/api/index.php +++ b/resources/api/index.php @@ -2,41 +2,6 @@ require 'Flight/flight/Flight.php'; include_once '../directory.php'; -include_once '../admin/classes/common/NamedArguments.php'; -include_once '../admin/classes/common/Object.php'; -include_once '../admin/classes/common/DynamicObject.php'; -include_once '../admin/classes/common/Utility.php'; -include_once '../admin/classes/common/Configuration.php'; -include_once '../admin/classes/common/DBService.php'; -include_once '../admin/classes/common/DatabaseObject.php'; -include_once '../admin/classes/common/Email.php'; -include_once '../admin/classes/domain/Resource.php'; -include_once '../admin/classes/domain/ResourceType.php'; -include_once '../admin/classes/domain/AcquisitionType.php'; -include_once '../admin/classes/domain/ResourceFormat.php'; -include_once '../admin/classes/domain/NoteType.php'; -include_once '../admin/classes/domain/ResourceNote.php'; -include_once '../admin/classes/domain/ResourcePayment.php'; -include_once '../admin/classes/domain/AdministeringSite.php'; -include_once '../admin/classes/domain/ResourceAdministeringSiteLink.php'; -include_once '../admin/classes/domain/ResourceRelationship.php'; -include_once '../admin/classes/domain/Status.php'; -include_once '../admin/classes/domain/User.php'; -include_once '../admin/classes/domain/Workflow.php'; -include_once '../admin/classes/domain/Step.php'; -include_once '../admin/classes/domain/ResourceStep.php'; -include_once '../admin/classes/domain/UserGroup.php'; -include_once '../admin/classes/domain/Fund.php'; -include_once '../admin/classes/domain/IsbnOrIssn.php'; -include_once '../../licensing/admin/classes/domain/License.php'; -include_once '../../licensing/admin/classes/domain/Document.php'; -include_once '../../licensing/admin/classes/domain/DocumentType.php'; -include_once '../../licensing/admin/classes/domain/Expression.php'; -include_once '../../licensing/admin/classes/domain/ExpressionNote.php'; -include_once '../../licensing/admin/classes/domain/ExpressionType.php'; -include_once '../../organizations/admin/classes/domain/Alias.php'; - - if (!isAllowed()) { header('HTTP/1.0 403 Forbidden');