-
Notifications
You must be signed in to change notification settings - Fork 342
SMS/MMS Display Attached Media #342 #343
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,43 @@ | |
<h3>Transcription</h3> | ||
<?php endif; ?> | ||
<div class="message-transcript"><?php echo (is_null($message->content_text) ? "(no transcription)" : $message->content_text) ?></div> | ||
<?php if(substr($message->call_sid,0,2) == 'MM'): | ||
echo "<br><br><h3>Media Attachements</h3>"; | ||
|
||
$ci = & get_instance(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is almost all controller logic. Move the logic to Then here you can check |
||
|
||
require_once(APPPATH . 'libraries/twilio.php'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This library is old and deprecated. It should not be used. Instead use the newer if (substr($message->callused, 0, 2) == 'MM') {
$account = OpenVBX::getAccount();
$message = $account->messages->get($message->call_sid);
foreach ($message->media as $mediaItem) {
$details['media'][] = array(
'sid' => $mediaItem->sid,
'content_type' => $mediaItem->content_type,
'uri' => $mediaItem->uri,
);
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, let me know if the Twilio library gives you any crap here. The included library is a bit out of date and may be missing some fixes. If it is out of date either you can update it in your branch or I can update it in this repo and you can pull from upstream to get the changes. |
||
|
||
$ci->twilio = new TwilioRestClient($ci->twilio_sid,$ci->twilio_token,$ci->twilio_endpoint); | ||
|
||
$media_url = "Accounts/{$this->twilio_sid}/Messages/{$message->call_sid}/Media.xml"; | ||
|
||
$mediaObj = $ci->twilio->request($media_url, "GET"); | ||
|
||
$media_xml = $mediaObj->ResponseXml; | ||
|
||
foreach($media_xml->MediaList->Media as $media): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit pick: we can use the alternate syntax control when breaking from HTML, but once within PHP we should always use braces around control structures. |
||
|
||
$media_uri = 'https://api.twilio.com/2010-04-01/Accounts/'.$this->twilio_sid.'/Messages/'.$message->call_sid.'/Media/'.$media->Sid; | ||
|
||
if(strpos($media->ContentType,'image')!==false): | ||
echo '<img src="'.$media_uri.'" type="'.$media->ContentType.'">'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Image elements don't have a |
||
elseif(strpos($media->ContentType,'audio')!==false): | ||
echo '<audio controls>'; | ||
echo '<source src="'.$media_uri.'" type="'.$media->ContentType.'">'; | ||
echo 'Your browser does not support the audio element.</audio>'; | ||
elseif(strpos($media->ContentType,'video')!==false): | ||
echo '<video controls>'; | ||
echo '<source src="'.$media_uri.'" type="'.$media->ContentType.'">'; | ||
echo 'Your browser does not support the video element.</video>'; | ||
endif; | ||
|
||
echo '<br>'.$media->ContentType.': <a href="'.$media_uri.'">Click To Download</a>'; | ||
echo '<br><br>'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above with |
||
|
||
endforeach; | ||
|
||
endif; ?> | ||
</div><!-- .message-details-transcript --> | ||
|
||
</div><!-- .vbx-content-container --> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,11 +40,12 @@ | |
<input type="checkbox" name="message[id][]" value="<?php echo $item['id'] ?>" /> | ||
</div> | ||
</td> | ||
<td class="message-caller message-details-link"> | ||
<td class="message-caller message-details-link" style="width:220px"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that it is ok to let this column's size vary based on its content. |
||
<span class="phone-number"><?php echo $item['caller'] ?></span> | ||
<a href="<?php echo site_url("messages/details/{$item['id']}")?>" class="quick-call-button"><span class="replace"><?php echo $item['caller'] ?></span></a> | ||
<?php if($item['type'] == 'sms'): ?> | ||
<a href="<?php echo site_url("messages/details/{$item['id']}")?>" class="quick-sms-button"><span class="replace"><?php echo $item['caller'] ?></span></a> | ||
<?php echo (substr($item['sid'],0,2) == 'MM'?'<span class="phone-number" title="Click to View Media"> mms</span>':'') ?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, not sure about this. There's probably a more attractive way of doing this without having to create an icon for all the default themes. |
||
<?php endif; ?> | ||
|
||
<div id="quick-call-popup-<?php echo $item['id'] ?>" class="quick-call-popup hide"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't control spacing with
<br>
. This is what css is for.