Example #1
0
 /**
  * Send a text message of this record to carrier using email gateway
  * 
  * @param string $phone
  * @param string $provider
  * @param int $item_number
  * @throws \Exception
  */
 public function textLocationTo($phone, $provider, $item_number)
 {
     $phone = preg_replace('/\\D/', "", $phone);
     // did we get 10?
     if (strlen($phone) != 10) {
         throw new \Exception("Please enter a 10 digit phone number, including area code");
     }
     $email = $phone . '@' . $provider;
     if ($this->holdings->length() == 0) {
         $this->fetchHoldings();
         // nothing here to text!
         if ($this->holdings->length() == 0) {
             return $this;
         }
     }
     // title
     $title = $this->getXerxesRecord()->getTitle();
     // item info
     $item = $this->holdings->getItems($item_number);
     $item_message = $item->location . " " . $item->callnumber;
     // make sure we don't go over sms size limit
     $title_length = strlen($title);
     $item_length = strlen($item_message);
     $total_length = $title_length + $item_length;
     if ($total_length > 150) {
         $title = substr($title, 0, $total_length - $item_length - 6) . "...";
     }
     $body = $title . " / " . $item_message;
     $email_client = new Email();
     return $email_client->send($email, 'library', $body);
     // @todo l18n this
 }
Example #2
0
 /**
  * Send a text message of this record to carrier using email gateway 
  * 
  * @param unknown_type $item_number
  */
 public function textLocationTo($email, $item_number)
 {
     if ($this->holdings->length() == 0) {
         $this->fetchHoldings();
         // nothing here to text!
         if ($this->holdings->length() == 0) {
             return $this;
         }
     }
     // title
     $title = $this->getXerxesRecord()->getTitle();
     // item info
     $item = $this->holdings->getItems($item_number);
     $item_message = $item->location . " " . $item->callnumber;
     // make sure we don't go over sms size limit
     $title_length = strlen($title);
     $item_length = strlen($item_message);
     $total_length = $title_length + $item_length;
     if ($total_length > 150) {
         $title = substr($title, 0, $total_length - $item_length - 6) . "...";
     }
     $body = $title . " / " . $item_message;
     $email_client = new Email();
     $email_client->send($email, 'library', $body);
     return $this;
 }
 /**
  * Email records to specified account
  */
 public function emailAction()
 {
     $id_array = $this->request->getParam('record', null, true);
     $return = $this->request->getParam('return');
     $email = $this->request->getParam('email');
     $subject = $this->request->getParam('subject', 'Saved Records');
     $notes = $this->request->getParam('notes');
     // user hasn't entered email, so show that page
     if ($email == null) {
         $this->response->setView('folder/email.xsl');
         return $this->response;
     }
     // save it for later, for convenience
     $this->request->setSessionData('email', $email);
     // get the records
     $this->response = $this->fetchAction();
     // convert to simple text
     $this->response->setView('citation/basic.xsl');
     $body = $notes . "\r\n\r\n\r\n" . $this->response->render('text')->getContent();
     // email it!
     $email_client = new Email();
     $result = $email_client->send($email, $subject, $body);
     // notify user and send them back
     $lang = $this->request->getParam("lang");
     $labels = $this->getLabels($lang);
     if ($result == true) {
         $this->request->setFlashMessage(Request::FLASH_MESSAGE_NOTICE, $labels->getLabel('text_folder_export_email_sent'));
     } else {
         $this->request->setFlashMessage(Request::FLASH_MESSAGE_NOTICE, $labels->getLabel('text_folder_export_email_error'));
     }
     return $this->redirectTo($return);
 }