private function getGroupedWorkCover()
 {
     if ($this->loadGroupedWork()) {
         //Have not found a grouped work based on isbn or upc, check based on related records
         $relatedRecords = $this->groupedWork->getRelatedRecords(false);
         foreach ($relatedRecords as $relatedRecord) {
             if ($relatedRecord['source'] == 'OverDrive') {
                 if ($this->getOverDriveCover($relatedRecord['id'])) {
                     return true;
                 }
             } elseif ($relatedRecord['source'] == 'Hoopla') {
                 if ($this->getHooplaCover($relatedRecord['id'])) {
                     return true;
                 }
             } else {
                 /** @var GroupedWorkDriver $driver */
                 $driver = $relatedRecord['driver'];
                 //First check to see if there is a specific record defined in an 856 etc.
                 if (method_exists($driver, 'getMarcRecord') && $this->getCoverFromMarc($driver->getMarcRecord())) {
                     return true;
                 } else {
                     //Finally, check the isbns if we don't have an override
                     $isbns = $driver->getCleanISBNs();
                     if ($isbns) {
                         foreach ($isbns as $isbn) {
                             $this->isn = $isbn;
                             if ($this->getCoverFromProvider()) {
                                 return true;
                             }
                         }
                     }
                     $upcs = $driver->getCleanUPCs();
                     $this->isn = null;
                     if ($upcs) {
                         foreach ($upcs as $upc) {
                             $this->upc = ltrim($upc, '0');
                             if ($this->getCoverFromProvider()) {
                                 return true;
                             }
                             //If we tried trimming the leading zeroes, also try without.
                             if ($this->upc !== $upc) {
                                 $this->upc = $upc;
                                 if ($this->getCoverFromProvider()) {
                                     return true;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
Esempio n. 2
0
 function sendSMS()
 {
     global $configArray;
     global $interface;
     require_once ROOT_DIR . '/sys/Mailer.php';
     $sms = new SMSMailer();
     // Get Holdings
     $id = $_REQUEST['id'];
     require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php';
     $recordDriver = new GroupedWorkDriver($id);
     if (isset($_REQUEST['related_record'])) {
         $relatedRecord = $_REQUEST['related_record'];
         require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php';
         $recordDriver = new GroupedWorkDriver($id);
         $relatedRecords = $recordDriver->getRelatedRecords();
         foreach ($relatedRecords as $curRecord) {
             if ($curRecord['id'] = $relatedRecord) {
                 if (isset($curRecord['callNumber'])) {
                     $interface->assign('callnumber', $curRecord['callNumber']);
                 }
                 if (isset($curRecord['shelfLocation'])) {
                     $interface->assign('shelfLocation', strip_tags($curRecord['shelfLocation']));
                 }
             }
         }
     }
     $interface->assign('title', $recordDriver->getTitle());
     $interface->assign('recordId', $_GET['id']);
     $message = $interface->fetch('Emails/grouped-work-sms.tpl');
     $smsResult = $sms->text($_REQUEST['provider'], $_REQUEST['sms_phone_number'], $configArray['Site']['email'], $message);
     if ($smsResult === true) {
         $result = array('result' => true, 'message' => 'Your text message was sent successfully.');
     } elseif (PEAR_Singleton::isError($smsResult)) {
         $result = array('result' => false, 'message' => 'Your text message was count not be sent {$smsResult}.');
     } else {
         $result = array('result' => false, 'message' => 'Your text message could not be sent due to an unknown error.');
     }
     return json_encode($result);
 }