Exemplo n.º 1
0
 /**
  * Converts a sent SMS message down to a basic object for writing to the DB
  * @param MoodletxtOutboundSMS $sms Object to convert
  * @param object $existingRecord Existing DB record, if one exists
  * @return object Object for writing to the database
  * @version 2012031901
  * @since 2012031501
  */
 private function convertSMSBeanToStandardClass(MoodletxtOutboundSMS $sms, object $existingRecord = null)
 {
     if ($existingRecord == null) {
         $existingRecord = new object();
     }
     $existingRecord->messageid = $sms->getMessageId();
     $existingRecord->ticketnumber = $sms->getTicketNumber();
     $existingRecord->destination = $sms->getRecipientObject()->getRecipientNumber()->getPhoneNumber();
     $existingRecord->sendfirstname = $sms->getRecipientObject()->getFirstName();
     $existingRecord->sendlastname = $sms->getRecipientObject()->getLastName();
     return $existingRecord;
 }
Exemplo n.º 2
0
 /**
  * Builds message and status objects from parsed XML
  * @param SimpleXMLElement $node The node collection to create the object from
  * @return mixed[] Sent messages built from the XML
  * @see SentMessageStatus
  * @version 2012031501
  * @since 2011033101
  */
 private function buildStatusMessage($node)
 {
     $returnObjects = array();
     // Check that all required children for message object
     // build exist within passed data
     if (isset($node->{MoodletxtXMLConstants::$RESPONSE_STATUS_MESSAGE_TEXT}) && isset($node->{MoodletxtXMLConstants::$RESPONSE_STATUS_PHONE}) && isset($node->{MoodletxtXMLConstants::$RESPONSE_STATUS_TICKET}) && isset($node->{MoodletxtXMLConstants::$RESPONSE_STATUS_UNIQUE_ID})) {
         // Build object and shove it onto the parsed objects array
         $sentMessageObject = new MoodletxtOutboundSMS($this->outboundMessageObject->getId(), (int) $node->{MoodletxtXMLConstants::$RESPONSE_STATUS_TICKET}, (string) $node->{MoodletxtXMLConstants::$RESPONSE_STATUS_MESSAGE_TEXT});
         $sentMessageObject->setRecipientObject($this->outboundMessageObject->getMessageRecipientByKey((string) $node->{MoodletxtXMLConstants::$RESPONSE_STATUS_UNIQUE_ID}));
     }
     // Check if required children for status object exist
     if (isset($node->{MoodletxtXMLConstants::$RESPONSE_STATUS_TICKET}) && isset($node->{MoodletxtXMLConstants::$RESPONSE_STATUS_CODE}) && isset($node->{MoodletxtXMLConstants::$RESPONSE_STATUS_MESSAGE})) {
         // Build status object and shove onto array
         $statusObject = new MoodletxtOutboundSMSStatus((int) $node->{MoodletxtXMLConstants::$RESPONSE_STATUS_TICKET}, (int) $node->{MoodletxtXMLConstants::$RESPONSE_STATUS_CODE}, (string) $node->{MoodletxtXMLConstants::$RESPONSE_STATUS_MESSAGE}, time());
         if (isset($sentMessageObject)) {
             $sentMessageObject->addStatusUpdate($statusObject);
         } else {
             if ($this->getExistingSentMessageByTicketNumber($statusObject->getTicketNumber()) != null) {
                 $this->getExistingSentMessageByTicketNumber($statusObject->getTicketNumber())->addStatusUpdate($statusObject);
             } else {
                 array_push($returnObjects, $statusObject);
             }
         }
     }
     if (isset($sentMessageObject)) {
         array_push($returnObjects, $sentMessageObject);
     }
     return $returnObjects;
 }