} break; case 'setProdUse': $expressionID = $_GET['expressionID']; $licenseID = $_GET['licenseID']; $productionUseInd = $_GET['productionUseInd']; //send email if prod use is being set if ($productionUseInd == "1") { $user = new User(); $toList = array(); $toList = $user->getSFXUpdateList(); $license = new License(new NamedArguments(array('primaryKey' => $licenseID))); $util = new Utility(); $emailMessage = "An expression in the licensing module has been approved for terms tool use.\n"; $emailMessage .= "License: " . $license->shortName . "\n\n"; $emailMessage .= "View License Record: " . $util->getPageURL() . "license.php?licenseID=" . $licenseID; $email = new Email(); $email->to = implode(", ", $toList); $email->subject = "Licensing - expression set to production use"; $email->message = $emailMessage; $email->send(); $response = "Approved for terms tool display."; } else { $response = "Removed from terms tool display."; } //save it in the expression record $expression = new Expression(new NamedArguments(array('primaryKey' => $_GET['expressionID']))); $expression->productionUseInd = $productionUseInd; try { $expression->save(); echo $response;
$sushiServices = new SushiService(); $sushiServicesArray = $sushiServices->getByDayOfMonth($day); $emailLog = "<h2>" . count($sushiServicesArray) . " SUSHI runs found for day: " . $day . "</h2>"; foreach ($sushiServicesArray as $sushiService) { $sushiService->setImportDates(); $emailLog .= "<h3>" . $sushiService->getServiceProvider() . "</h3>"; //try to run! try { $emailLog .= nl2br($sushiService->runAll($_POST['overwritePlatform'])); } catch (Exception $e) { $emailLog .= nl2br($e->getMessage()); } } //if more than one run, send email if (count($sushiServicesArray) > 0) { $emailLog .= "<br /><br />Log in to <a href='" . $util->getPageURL() . "sushi.php'>Sushi Administration</a> for more information."; //send email to email addresses listed in DB $logEmailAddress = new LogEmailAddress(); $emailAddresses = array(); foreach ($logEmailAddress->allAsArray() as $emailAddress) { $emailAddresses[] = $emailAddress['emailAddress']; } if (count($emailAddresses) > 0) { $email = new Email(); $email->to = implode(", ", $emailAddresses); $email->subject = "SUSHI Scheduled run log for " . format_date(date) . " - " . count($sushiServicesArray) . " runs"; $email->message = $emailLog; if ($email->send()) { echo "Run complete. Log has been emailed to " . implode(", ", $emailAddresses); } else { echo "Email to " . implode(", ", $emailAddresses) . " Failed!";
private function parseXML($fName, $reportLayout, $overwritePlatform) { ////////////////////////////////////// //PARSE XML!! ////////////////////////////////////// $serviceProvider = $this->getServiceProvider(); $xmlFileName = BASE_DIR . $fName; //read layouts ini file to get the available layouts $layoutsArray = parse_ini_file(BASE_DIR . "layouts.ini", true); $layoutColumns = array(); $reader = new XMLReader(); if (!$reader->open($xmlFileName, 'UTF-8')) { $this->logStatus("Failed trying to open XML File: " . $xmlFileName . ". This could be due to not having write access to the /sushistore/ directory."); $this->saveLogAndExit($reportLayout); } $layoutCode = ""; $countArray = array('ytd' => null, 'pdf' => null, 'html' => null); $txtOut = ""; $m = null; //month while ($reader->read()) { //First - get report information if ($reader->nodeType == XMLReader::ELEMENT && $reader->localName == 'Report' && count($layoutColumns) == '0') { $name = $reader->getAttribute("Name"); $version = $reader->getAttribute("Version"); $layoutCode = $name; if ($version == "3" || $version == "4") { $version = "R" . $version; } if ($version != '') { $layoutCode .= "_" . $version; } else { $layoutCode .= "_R" . $this->releaseNumber; } //At this point, determine the format of the report to port to csv from the layouts.ini file $layoutKey = $layoutsArray['ReportTypes'][$layoutCode]; $layoutColumns = $layoutsArray[$layoutKey]['columns']; //if this way of determining layout was unsuccessful, just use the layout sent in if (count($layoutColumns) == "0") { $layoutCode = $reportLayout . "_R" . $this->releaseNumber; $layoutKey = $layoutsArray['ReportTypes'][$layoutCode]; $layoutColumns = $layoutsArray[$layoutKey]['columns']; } $this->log("Layout validated successfully against layouts.ini : " . $layoutCode); } if ($reader->nodeType == XMLReader::ELEMENT && $reader->localName == 'ReportItems') { if (count($layoutColumns) == '0' || $layoutCode == '') { $this->logStatus("Failed determining layout: Reached report items before establishing layout. Please make sure this layout is set up in layouts.ini"); $this->saveLogAndExit($reportLayout); } //reset variables $identifierArray = array(); $reportArray = array('ytd' => null, 'ytdHTML' => null, 'ytdPDF' => null); //loop through each element under "Item" while ($reader->read()) { //get the element name if ($reader->nodeType == XMLReader::ELEMENT) { $elementName = trim($reader->localName); //move to next to get the text if ($elementName != "Instance" && $elementName != "ItemIdentifier" && $elementName != "Period") { $reader->read(); } if ($reader->nodeType == XMLReader::TEXT || $reader->nodeType == XMLReader::CDATA || $reader->nodeType == XMLReader::WHITESPACE || $reader->nodeType == XMLReader::SIGNIFICANT_WHITESPACE) { $elementValue = trim($reader->value); switch ($elementName) { case 'ItemPlatform': if ($overwritePlatform) { $reportArray['platform'] = $serviceProvider; } else { $reportArray['platform'] = $elementValue; } break; case 'ItemPublisher': $reportArray['publisher'] = $elementValue; break; case 'ItemName': $reportArray['title'] = $elementValue; break; case 'ActivityType': $reportArray['activityType'] = strtoupper($reader->value); break; case 'Type': $idType = strtoupper($reader->value); break; case 'Value': $identifierArray[$idType] = $reader->value; break; case 'Begin': $date = new DateTime($reader->value); if ($m === null) { $m = strtolower($date->format('M')); $countArray = array('ytd' => null, 'pdf' => null, 'html' => null); } else { if (strtolower($date->format('M')) !== $m) { $totalCountsArray[$m] = $countArray; $m = strtolower($date->format('M')); //$y = strtolower($date->format('Y')); $countArray = array('ytd' => null, 'pdf' => null, 'html' => null); } } break; case 'MetricType': $metricType = strtoupper($reader->value); //make sure metric types have conformity if (!(strpos($metricType, 'HTML') === false)) { $metricType = 'html'; } else { if (!(strpos($metricType, 'PDF') === false)) { $metricType = 'pdf'; } else { $metricType = 'ytd'; } } break; case 'Count': $countArray[$metricType] = $reader->value; break; } } //Finished parsing the Title!!! } else { if ($reader->nodeType == XMLReader::END_ELEMENT && $reader->localName == "ReportItems") { foreach ($identifierArray as $key => $value) { if (!(strrpos($key, 'PRINT') === false) && !(strrpos($key, 'ISSN') === false)) { $reportArray['issn'] = $value; } else { if (!(strrpos($key, 'ONLINE') === false) && !(strrpos($key, 'ISSN') === false)) { $reportArray['eissn'] = $value; } else { if (!(strpos($key, 'PRINT') === false) && !(strpos($key, 'ISBN') === false)) { $reportArray['isbn'] = $value; } else { if (!(strpos($key, 'ONLINE') === false) && !(strpos($key, 'ISBN') === false)) { $reportArray['eisbn'] = $value; } else { if (!(strpos($key, 'DOI') === false)) { $reportArray['doi'] = $value; } else { if (!(strpos($key, 'PROPRIETARY') === false)) { $reportArray['pi'] = $value; } } } } } } } //get the last array into the totals array $totalCountsArray[$m] = $countArray; //now figure out the months and the ytd, etc totals foreach ($totalCountsArray as $key => $countArray) { if ($key != '') { if (intval($countArray['ytd']) == "0") { $reportArray[$key] = intval($countArray['pdf']) + intval($countArray['html']); } else { $reportArray[$key] = intval($countArray['ytd']); } if ($reportArray['ytd'] === null) { $reportArray['ytd'] = intval($countArray['ytd']); } else { $reportArray['ytd'] += intval($countArray['ytd']); } if ($reportArray['ytdPDF'] === null) { $reportArray['ytdPDF'] = intval($countArray['pdf']); } else { $reportArray['ytdPDF'] += intval($countArray['pdf']); } if ($reportArray['ytdHTML'] === null) { $reportArray['ytdHTML'] = intval($countArray['html']); } else { $reportArray['ytdHTML'] += intval($countArray['html']); } } } //Now look at the report's layoutcode's columns to order them properly $finalArray = array(); foreach ($layoutColumns as $colName) { if (isset($reportArray[$colName])) { $finalArray[] = $reportArray[$colName]; } else { $finalArray[] = null; } } $txtOut .= implode($finalArray, "\t") . "\n"; $totalCountsArray = array(); break; } } } } } $reader->close(); if ($layoutKey == "" || count($layoutColumns) == '0' || $txtOut == "") { if (file_exists($xmlFileName)) { $this->logStatus("Failed XML parsing or no data was found."); $xml = simplexml_load_file($xmlFileName); $this->log("The following is the XML response:"); $this->log(htmlentities(file_get_contents($xmlFileName))); } else { $this->log("Failed loading XML file. Please verify you have write permissions on /sushistore/ directory."); } $this->saveLogAndExit($layoutCode); } #Save final text delimited "file" and log output on server $txtFile = strtotime("now") . '.txt'; $fp = fopen(BASE_DIR . 'archive/' . $txtFile, 'w'); fwrite($fp, $txtOut); fclose($fp); $this->log(""); $this->log("-- Sushi XML parsing completed --"); $this->log("Archive/Text File Name: " . Utility::getPageURL() . 'archive/' . $txtFile); $this->saveLogAndExit($layoutCode, $txtFile, true); }
$sushiServices = new SushiService(); $sushiServicesArray = $sushiServices->getByDayOfMonth($day); $emailLog = "<h2>" . count($sushiServicesArray) . _(" SUSHI runs found for day: ") . $day . "</h2>"; foreach ($sushiServicesArray as $sushiService) { $sushiService->setImportDates(); $emailLog .= "<h3>" . $sushiService->getServiceProvider() . "</h3>"; //try to run! try { $emailLog .= nl2br($sushiService->runAll($_POST['overwritePlatform'])); } catch (Exception $e) { $emailLog .= nl2br($e->getMessage()); } } //if more than one run, send email if (count($sushiServicesArray) > 0) { $emailLog .= "<br /><br />" . _("Log in to ") . "<a href='" . $util->getPageURL() . "sushi.php'>" . _("Sushi Administration") . "</a>" . _(" for more information."); //send email to email addresses listed in DB $logEmailAddress = new LogEmailAddress(); $emailAddresses = array(); foreach ($logEmailAddress->allAsArray() as $emailAddress) { $emailAddresses[] = $emailAddress['emailAddress']; } if (count($emailAddresses) > 0) { $email = new Email(); $email->to = implode(", ", $emailAddresses); $email->subject = _("SUSHI Scheduled run log for ") . format_date(date) . " - " . count($sushiServicesArray) . _(" runs"); $email->message = $emailLog; if ($email->send()) { echo _("Run complete. Log has been emailed to ") . implode(", ", $emailAddresses); } else { echo _("Email to ") . implode(", ", $emailAddresses) . _(" Failed!");