diff --git a/app/messages/app_config.php b/app/messages/app_config.php index 9e2d941f7d..c047988d51 100644 --- a/app/messages/app_config.php +++ b/app/messages/app_config.php @@ -96,7 +96,7 @@ $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the message direction.'; $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'message_date'; - $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamp'; + $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz'; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date'; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'timestamp'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the message date.'; diff --git a/app/messages/messages.php b/app/messages/messages.php index 9fd81312a2..7b2e3985c4 100644 --- a/app/messages/messages.php +++ b/app/messages/messages.php @@ -56,9 +56,31 @@ } unset ($prep_statement, $sql, $row, $record); +//get self (primary contact attachment) image, if any + if (!is_array($_SESSION['tmp']['messages']['contact_me'])) { + $sql = "select attachment_filename as filename, attachment_content as image from v_contact_attachments "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid = :contact_uuid "; + $sql .= "and attachment_primary = 1 "; + $bind[':contact_uuid'] = $_SESSION['user']['contact_uuid']; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(is_array($bind) ? $bind : null); + $_SESSION['tmp']['messages']['contact_me'] = $prep_statement->fetch(PDO::FETCH_NAMED); + unset ($sql, $bind, $prep_statement); + } + //additional includes require_once "resources/header.php"; +//resize thread window on window resize + echo "\n"; + //styles echo "\n"; if (!$refresh) { - echo "
\n"; + echo "
\n"; } //output messages @@ -165,28 +220,51 @@ } //message bubble - echo ""; - if ($message['message_text'] != '') { - echo str_replace("\n",'
',escape($message['message_text']))."
\n"; - } - if (is_array($message_media[$message['message_uuid']]) && sizeof($message_media[$message['message_uuid']]) != 0) { + echo ""; + //contact image + if ($message['message_direction'] == 'inbound') { //em + if (is_array($_SESSION['tmp']['messages']['contact_em'][$contact_uuid]) && sizeof($_SESSION['tmp']['messages']['contact_em'][$contact_uuid]) != 0) { + $attachment_type = strtolower(pathinfo($_SESSION['tmp']['messages']['contact_em'][$contact_uuid]['filename'], PATHINFO_EXTENSION)); + echo "
\n"; + echo "
\n"; + echo "
\n"; + } + } + else { //me + if (is_array($_SESSION['tmp']['messages']['contact_me']) && sizeof($_SESSION['tmp']['messages']['contact_me']) != 0) { + $attachment_type = strtolower(pathinfo($_SESSION['tmp']['messages']['contact_me']['filename'], PATHINFO_EXTENSION)); + echo "
\n"; + echo "
\n"; + echo "
\n"; + } + } + echo "
\n"; + //message + if ($message['message_text'] != '') { + echo "
".str_replace("\n",'
',escape($message['message_text']))."
\n"; + } + //attachments + if (is_array($message_media[$message['message_uuid']]) && sizeof($message_media[$message['message_uuid']]) != 0) { - foreach ($message_media[$message['message_uuid']] as $media) { - if ($media['type'] != 'txt') { - if ($media['type'] == 'jpg' || $media['type'] == 'jpeg' || $media['type'] == 'gif' || $media['type'] == 'png') { - echo ""; + foreach ($message_media[$message['message_uuid']] as $media) { + if ($media['type'] != 'txt') { + if ($media['type'] == 'jpg' || $media['type'] == 'jpeg' || $media['type'] == 'gif' || $media['type'] == 'png') { + echo ""; + } + else { + echo ""; + } + echo ""; + echo "".strtoupper($media['type']).' · '.strtoupper(byte_convert($media['size'])).""; + echo "\n"; + } + } + echo "
\n"; } - else { - echo ""; - } - echo ""; - echo "".strtoupper($media['type']).' · '.strtoupper(byte_convert($media['size'])).""; - echo "\n"; - } - } - } - echo " ".format_when_local($message['message_date'])."\n"; - echo "\n"; + //message when + echo "".(gmdate('m-d-Y') != format_when_local($message['message_date'],'d') ? format_when_local($message['message_date']) : format_when_local($message['message_date'],'t'))."\n"; + echo "
\n"; + echo "
\n"; } echo "\n"; } @@ -212,7 +290,7 @@ echo "\n"; echo " \n"; echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo "
\"".$text['label-refresh_pause']."\"\"".$text['label-refresh_pause']."\"
\n"; @@ -237,7 +315,7 @@ echo " $('#message_text').focus();\n"; echo " }\n"; } - echo " refresh_thread('".$number."','true');\n"; + echo " refresh_thread('".$number."', '".$contact_uuid."', 'true');\n"; echo " }\n"; echo " });\n"; echo " });\n"; diff --git a/themes/default/template.php b/themes/default/template.php index 155b40bd0c..ba9efa9c49 100644 --- a/themes/default/template.php +++ b/themes/default/template.php @@ -278,12 +278,13 @@ echo "