diff --git a/LangCodes.php b/LangCodes.php new file mode 100644 index 0000000..2d58bc7 --- /dev/null +++ b/LangCodes.php @@ -0,0 +1,23 @@ +'fr_FR', + 'en'=>'en_US' + ); + return $all_lang[$code]; + } + public function getNameLang($code_lang){ + $name_lang=array( + 'fr'=>_('French'), + 'en'=>_('English') + ); + return $name_lang[$code_lang]; + } +} +?> \ No newline at end of file diff --git a/admin.php b/admin.php index 04538f6..84c5e39 100644 --- a/admin.php +++ b/admin.php @@ -19,7 +19,7 @@ include_once 'directory.php'; -$pageTitle='Administration'; +$pageTitle=_('Administration'); include 'templates/header.php'; //set referring page @@ -37,7 +37,7 @@
|
- Administration
+
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
-
@@ -115,7 +116,7 @@
//end else for admin
}else{
- echo "You do not have permissions to access this screen.";
+ echo _("You do not have permissions to access this screen.");
}
include 'templates/footer.php';
diff --git a/admin/classes/common/DBService.php b/admin/classes/common/DBService.php
index fa37650..17dbcef 100644
--- a/admin/classes/common/DBService.php
+++ b/admin/classes/common/DBService.php
@@ -36,7 +36,7 @@ protected function dealloc() {
protected function checkForError() {
if ($this->error = $this->db->error) {
- throw new Exception("There was a problem with the database: " . $this->error);
+ throw new Exception(_("There was a problem with the database: ") . $this->error);
}
}
diff --git a/admin/classes/common/LdapPerson.php b/admin/classes/common/LdapPerson.php
index 7d933fe..c4c928d 100644
--- a/admin/classes/common/LdapPerson.php
+++ b/admin/classes/common/LdapPerson.php
@@ -31,7 +31,7 @@ public function __construct($userKey) {
$ds = ldap_connect($config->ldap->host);
//may need ldap_bind( $ds, $username, $password )
- $bd = ldap_bind($ds) or die(" Loading...
+
Could not connect to " . $config->ldap->host . ""); + $bd = ldap_bind($ds) or die(""._("Could not connect to ") . $config->ldap->host . ""); if ($bd){ $filter = $config->ldap->search_key . "=" . $userKey; diff --git a/admin/classes/common/Object.php b/admin/classes/common/Object.php index 5f30ba9..4a9e208 100644 --- a/admin/classes/common/Object.php +++ b/admin/classes/common/Object.php @@ -60,7 +60,7 @@ protected function setValueForKey($key, $value) { if (property_exists($this, $key)) { $this->$key = $value; } else { - throw new Exception("Cannot set value for undefined key ($key)."); + throw new Exception(_("Cannot set value for undefined key (").$key.")."); } } @@ -69,7 +69,7 @@ protected function valueForKey($key) { if (property_exists($this, $key)) { return $this->$key; } else { - throw new Exception("Cannot get value for undefined key ($key)."); + throw new Exception(_("Cannot set value for undefined key (").$key.")."); } } diff --git a/admin/classes/common/Utility.php b/admin/classes/common/Utility.php index 87e7c28..8aeed4a 100644 --- a/admin/classes/common/Utility.php +++ b/admin/classes/common/Utility.php @@ -118,7 +118,7 @@ public function createMessageFromTemplate($messageType, $resourceID, $resourceTi $defaultMessage .= $buffer; } if (!feof($fh)) { - return "Error: unexpected fgets() fail\n"; + return _("Error: unexpected fgets() fail")."\n"; } fclose($fh); @@ -130,7 +130,7 @@ public function createMessageFromTemplate($messageType, $resourceID, $resourceTi $resourceTitleInURL = str_replace('+', '%20', $resourceTitleInURL); $completionLink = str_replace('') contactRoles - FROM Contact C, ContactRole CR, ContactRoleProfile CRP - WHERE (archiveDate = '0000-00-00' OR archiveDate is null) - AND C.contactID = CRP.contactID - AND CRP.contactRoleID = CR.contactRoleID - AND resourceID = '" . $this->resourceID . "' - GROUP BY C.contactID - ORDER BY C.name"; - - $result = $this->db->processQuery($query, 'assoc'); - + if (!$moduleFilter || $moduleFilter == 'resources') { + //get resource specific contacts first + $query = "SELECT C.*, GROUP_CONCAT(CR.shortName SEPARATOR ' ') contactRoles + FROM Contact C, ContactRole CR, ContactRoleProfile CRP + WHERE (archiveDate = '0000-00-00' OR archiveDate is null) + AND C.contactID = CRP.contactID + AND CRP.contactRoleID = CR.contactRoleID + AND resourceID = '" . $this->resourceID . "' + GROUP BY C.contactID + ORDER BY C.name"; - //need to do this since it could be that there's only one request and this is how the dbservice returns result - if (isset($result['contactID'])){ + $result = $this->db->processQuery($query, 'assoc'); - foreach (array_keys($result) as $attributeName) { - $resultArray[$attributeName] = $result[$attributeName]; - } - array_push($contactsArray, $resultArray); + //need to do this since it could be that there's only one request and this is how the dbservice returns result + if (isset($result['contactID'])){ - }else{ - foreach ($result as $row) { - $resultArray = array(); - foreach (array_keys($row) as $attributeName) { - $resultArray[$attributeName] = $row[$attributeName]; + foreach (array_keys($result) as $attributeName) { + $resultArray[$attributeName] = $result[$attributeName]; } array_push($contactsArray, $resultArray); + + }else{ + foreach ($result as $row) { + $resultArray = array(); + foreach (array_keys($row) as $attributeName) { + $resultArray[$attributeName] = $row[$attributeName]; + } + + array_push($contactsArray, $resultArray); + } } } - //if the org module is installed also get the org contacts from org database - if ($config->settings->organizationsModule == 'Y'){ + if ($config->settings->organizationsModule == 'Y' && (!$moduleFilter || $moduleFilter == 'organizations')) { $dbName = $config->settings->organizationsDatabaseName; $query = "SELECT distinct OC.*, O.name organizationName, GROUP_CONCAT(DISTINCT CR.shortName SEPARATOR ' ') contactRoles @@ -748,11 +748,6 @@ public function getNotes($tabName = NULL){ return $objects; } - - - - - //returns array of the initial note object public function getInitialNote(){ $noteType = new NoteType(); @@ -776,11 +771,126 @@ public function getInitialNote(){ } + public function getIssues($archivedOnly=false){ + $query = "SELECT i.* + FROM Issue i + LEFT JOIN IssueRelationship ir ON ir.issueID=i.issueID + WHERE ir.entityID={$this->resourceID} AND ir.entityTypeID=2"; + if ($archivedOnly) { + $query .= " AND i.dateClosed IS NOT NULL"; + } else { + $query .= " AND i.dateClosed IS NULL"; + } + $query .= " ORDER BY i.dateCreated DESC"; + + $result = $this->db->processQuery($query, 'assoc'); + $objects = array(); + //need to do this since it could be that there's only one request and this is how the dbservice returns result + if (isset($result['issueID'])){ + $object = new Issue(new NamedArguments(array('primaryKey' => $result['issueID']))); + array_push($objects, $object); + }else{ + foreach ($result as $row) { + $object = new Issue(new NamedArguments(array('primaryKey' => $row['issueID']))); + array_push($objects, $object); + } + } + return $objects; + } + + public function getDowntime($archivedOnly=false){ + $query = "SELECT d.* + FROM Downtime d + WHERE d.entityID={$this->resourceID} AND d.entityTypeID=2"; + if ($archivedOnly) { + $query .= " AND d.endDate < CURDATE()"; + } else { + $query .= " AND d.endDate >= CURDATE()"; + } + $query .= " ORDER BY d.dateCreated DESC"; + + $result = $this->db->processQuery($query, 'assoc'); + + $objects = array(); + + //need to do this since it could be that there's only one request and this is how the dbservice returns result + if (isset($result['downtimeID'])){ + $object = new Downtime(new NamedArguments(array('primaryKey' => $result['downtimeID']))); + array_push($objects, $object); + }else{ + foreach ($result as $row) { + $object = new Downtime(new NamedArguments(array('primaryKey' => $row['downtimeID']))); + array_push($objects, $object); + } + } + return $objects; + } + + public function getExportableIssues($archivedOnly=false){ + if ($this->db->config->settings->organizationsModule == 'Y' && $this->db->config->settings->organizationsDatabaseName) { + $contactsDB = $this->db->config->settings->organizationsDatabaseName; + } else { + $contactsDB = $this->db->config->database->name; + } + + $query = "SELECT i.*,(SELECT GROUP_CONCAT(CONCAT(sc.name,' - ',sc.emailAddress) SEPARATOR ', ') + FROM IssueContact sic + LEFT JOIN `{$contactsDB}`.Contact sc ON sc.contactID=sic.contactID + WHERE sic.issueID=i.issueID) AS `contacts`, + (SELECT GROUP_CONCAT(se.titleText SEPARATOR ', ') + FROM IssueRelationship sir + LEFT JOIN Resource se ON (se.resourceID=sir.entityID AND sir.entityTypeID=2) + WHERE sir.issueID=i.issueID) AS `appliesto`, + (SELECT GROUP_CONCAT(sie.email SEPARATOR ', ') + FROM IssueEmail sie + WHERE sie.issueID=i.issueID) AS `CCs` + FROM Issue i + LEFT JOIN IssueRelationship ir ON ir.issueID=i.issueID + WHERE ir.entityID={$this->resourceID} AND ir.entityTypeID=2"; + if ($archivedOnly) { + $query .= " AND i.dateClosed IS NOT NULL"; + } else { + $query .= " AND i.dateClosed IS NULL"; + } + $query .= " ORDER BY i.dateCreated DESC"; + + $result = $this->db->processQuery($query, 'assoc'); + + $objects = array(); + + //need to do this since it could be that there's only one request and this is how the dbservice returns result + if (isset($result['issueID'])){ + return array($result); + }else{ + return $result; + } + } + + public function getExportableDowntimes($archivedOnly=false){ + + $query = "SELECT d.* + FROM Downtime d + WHERE d.entityID={$this->resourceID} AND d.entityTypeID=2"; + if ($archivedOnly) { + $query .= " AND d.endDate < CURDATE()"; + } else { + $query .= " AND d.endDate >= CURDATE()"; + } + $query .= " ORDER BY d.dateCreated DESC"; + $result = $this->db->processQuery($query, 'assoc'); + $objects = array(); + //need to do this since it could be that there's only one request and this is how the dbservice returns result + if (isset($result['downtimeID'])){ + return array($result); + }else{ + return $result; + } + } //returns array of attachments objects public function getAttachments(){ @@ -1599,19 +1709,27 @@ public function getOrganizationArray(){ } - - - - } return $resourceOrgArray; } + public function getSiblingResourcesArray($organizationID) { + $query = "SELECT DISTINCT r.resourceID, r.titleText FROM ResourceOrganizationLink rol + LEFT JOIN Resource r ON r.resourceID=rol.resourceID + WHERE rol.organizationID=".$organizationID." AND r.archiveDate IS NULL + ORDER BY r.titleText"; + $result = $this->db->processQuery($query, 'assoc'); + if($result["resourceID"]) { + return array($result); + } + + return $result; + } //gets an array of distinct organizations set up for this resource (organizationID, organization) public function getDistinctOrganizationArray(){ diff --git a/admin/classes/domain/ResourceStep.php b/admin/classes/domain/ResourceStep.php index 5022f2c..3d78fa8 100644 --- a/admin/classes/domain/ResourceStep.php +++ b/admin/classes/domain/ResourceStep.php @@ -33,47 +33,55 @@ public function completeStep(){ //mark this step complete $this->stepEndDate = date( 'Y-m-d' ); $this->endLoginID = $_SESSION['loginID']; - $this->save; + $this->save(); - //if there are next steps, start them - $nextStepArray = $this->getNextSteps(); + $this->startNextStepsOrComplete(); - if (count($nextStepArray) > 0){ - foreach ($nextStepArray as $nextResourceStep){ - - $nextResourceStep->startStep(); - - } + } + public function startNextStepsOrComplete(){ + //if there are next steps, start them + $nextStepArray = $this->getNextSteps(); - }else{ + if (count($nextStepArray) > 0){ + foreach ($nextStepArray as $nextResourceStep){ - //check if it just means that this branch is complete and there are still other steps open - if ($this->getNumberOfOpenSteps() == 0){ + $nextResourceStep->startStep(); - //otherwise if there are no more steps then we can mark the resource complete - $resource = new Resource(new NamedArguments(array('primaryKey' => $this->resourceID))); - $resource->completeWorkflow(); + } + } - } - } + //check if this branch is complete or if there are still other steps open + if ($this->getNumberOfOpenSteps() == 0){ + //if there are no more steps then we can mark the resource complete + $resource = new Resource(new NamedArguments(array('primaryKey' => $this->resourceID))); + $resource->completeWorkflow(); - } + } + } public function startStep(){ //start this step $this->stepStartDate = date( 'Y-m-d' ); - $this->save; + $this->save(); //send notifications $this->sendApprovalNotification(); - } + public function restartReassignedStep(){ + //restart step if it's active + if (!is_null($this->stepStartDate)){ + $this->stepStartDate = date( 'Y-m-d' ); + + $this->sendReassignedStepNotification(); + } + $this->save(); + } //returns array of resource step objects public function getNextSteps(){ @@ -101,9 +109,6 @@ public function getNextSteps(){ return $objects; } - - - //returns prior resource step object (resource step can only have one prior step) public function getPriorStep(){ @@ -144,6 +149,33 @@ public function getNumberOfOpenSteps(){ + //returns an array of later open step objects + public function getLaterOpenSteps(){ + $query = "SELECT * FROM ResourceStep + WHERE resourceID = '" . $this->resourceID . "' + AND displayOrderSequence > " . $this->displayOrderSequence . " + AND (stepEndDate IS NULL OR stepEndDate = '0000-00-00') + ORDER BY resourceStepID"; + + $result = $this->db->processQuery($query, 'assoc'); + + $objects = array(); + + //need to do this since it could be that there's only one request and this is how the dbservice returns result + if (isset($result['resourceStepID'])){ + $object = new ResourceStep(new NamedArguments(array('primaryKey' => $result['resourceStepID']))); + array_push($objects, $object); + }else{ + foreach ($result as $row) { + $object = new ResourceStep(new NamedArguments(array('primaryKey' => $row['resourceStepID']))); + array_push($objects, $object); + } + } + + return $objects; + } + + //sends email to the approval user group for this step public function sendApprovalNotification(){ @@ -158,7 +190,13 @@ public function sendApprovalNotification(){ if (($this->priorStepID) && ($this->priorStepID != '0')){ $priorResourceStep = $this->getPriorStep(); $priorStepName = $priorResourceStep->stepName; - $messageType='ResourceQueue'; + if ($priorResourceStep){ + $priorStepName = $priorResourceStep->stepName; + $messageType='ResourceQueue'; + }else{ + $messageType='DeletedPriorStep'; + } + }else{ $messageType='NewResource'; $priorStepName = ''; @@ -178,6 +216,29 @@ public function sendApprovalNotification(){ } + //sends email to the reassigned user group + public function sendReassignedStepNotification(){ + + $util = new Utility(); + + $userGroup = new UserGroup(new NamedArguments(array('primaryKey' => $this->userGroupID))); + $resource = new Resource(new NamedArguments(array('primaryKey' => $this->resourceID))); + + //only send if there is an email address set up for this group + if ($userGroup->emailAddress){ + + //formulate emil to be sent + $email = new Email(); + $email->message = $util->createMessageFromTemplate('ReassignedStep', $this->resourceID, $resource->titleText, $this->stepName, '',''); + $email->to = $userGroup->emailAddress; + $email->subject = "CORAL Alert: " . $resource->titleText; + + $email->send(); + } + + + } + } ?> \ No newline at end of file diff --git a/admin/configuration_sample.ini b/admin/configuration_sample.ini index 1378425..a7fc310 100644 --- a/admin/configuration_sample.ini +++ b/admin/configuration_sample.ini @@ -1,20 +1,20 @@ [settings] -licensingModule= +licensingModule=N licensingDatabaseName= -organizationsModule= +organizationsModule=N organizationsDatabaseName= -usageModule= +usageModule=N enhancedCostHistory=N -authModule= +authModule=N authDatabaseName= remoteAuthVariableName="_SERVER['REMOTE_USER']" defaultCurrency="USD" -enableAlerts="" -catalogURL="" -feedbackEmailAddress="" +enableAlerts= +catalogURL= +feedbackEmailAddress= testMode=N -testModeEmailAddress="" -defaultsort="" +testModeEmailAddress= +defaultsort= importISBNDedupingColumns="ISSN,ISBN" [database] diff --git a/admin/emails/DeletedPriorStep.txt b/admin/emails/DeletedPriorStep.txt new file mode 100644 index 0000000..fc0a27c --- /dev/null +++ b/admin/emails/DeletedPriorStep.txt @@ -0,0 +1,5 @@ +For resource: |