Merge pull request #185 from fabrixxm/master

Updated private message pages
This commit is contained in:
fabrixxm 2012-03-28 23:47:23 -07:00
commit 3ee529d095
13 changed files with 513 additions and 111 deletions

View file

@ -3,6 +3,35 @@
require_once('include/acl_selectors.php');
require_once('include/message.php');
function message_init(&$a) {
$tabs = array(
/*
array(
'label' => t('All'),
'url'=> $a->get_baseurl(true) . '/message',
'sel'=> ($a->argc == 1),
),
array(
'label' => t('Sent'),
'url' => $a->get_baseurl(true) . '/message/sent',
'sel'=> ($a->argv[1] == 'sent'),
),
*/
);
$new = array(
'label' => t('New Message'),
'url' => $a->get_baseurl(true) . '/message/new',
'sel'=> ($a->argv[1] == 'new'),
);
$tpl = get_markup_template('message_side.tpl');
$a->page['aside'] = replace_macros($tpl, array(
'$tabs'=>$tabs,
'$new'=>$new,
));
}
function message_post(&$a) {
if(! local_user()) {
@ -66,25 +95,7 @@ function message_content(&$a) {
$myprofile = $a->get_baseurl(true) . '/profile/' . $a->user['nickname'];
$tabs = array(
array(
'label' => t('Inbox'),
'url'=> $a->get_baseurl(true) . '/message',
'sel'=> (($a->argc == 1) ? 'active' : ''),
),
array(
'label' => t('Outbox'),
'url' => $a->get_baseurl(true) . '/message/sent',
'sel'=> (($a->argv[1] == 'sent') ? 'active' : ''),
),
array(
'label' => t('New Message'),
'url' => $a->get_baseurl(true) . '/message/new',
'sel'=> (($a->argv[1] == 'new') ? 'active' : ''),
),
);
$tpl = get_markup_template('common_tabs.tpl');
$tab_content = replace_macros($tpl, array('$tabs'=>$tabs));
$tpl = get_markup_template('mail_head.tpl');
@ -186,9 +197,9 @@ function message_content(&$a) {
$o .= $header;
if($a->argc == 2)
$eq = '='; // I'm not going to bother escaping this.
$eq = sprintf( "AND `from-url` = '%s'", dbesc($myprofile));
else
$eq = '!='; // or this.
$eq = '';
$r = q("SELECT count(*) AS `total` FROM `mail`
WHERE `mail`.`uid` = %d AND `from-url` $eq '%s' GROUP BY `parent-uri` ORDER BY `created` DESC",
@ -199,11 +210,12 @@ function message_content(&$a) {
$a->set_pager_total($r[0]['total']);
$r = q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`,
`mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` , `contact`.`network`
`mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` , `contact`.`network`,
count( * ) as count
FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
WHERE `mail`.`uid` = %d AND `from-url` $eq '%s' GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ",
WHERE `mail`.`uid` = %d $eq GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ",
intval(local_user()),
dbesc($myprofile),
//
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
@ -214,9 +226,15 @@ function message_content(&$a) {
$tpl = get_markup_template('mail_list.tpl');
foreach($r as $rr) {
if ($rr['from-url'] == $myprofile){
$partecipants = sprintf( t("You and %s"), $rr['name']);
} else {
$partecipants = sprintf( t("%s and You"), $rr['from-name']);
}
$o .= replace_macros($tpl, array(
'$id' => $rr['id'],
'$from_name' =>$rr['from-name'],
'$from_name' => $partecipants,
'$from_url' => (($rr['network'] === NETWORK_DFRN) ? $a->get_baseurl(true) . '/redir/' . $rr['contact-id'] : $rr['url']),
'$sparkle' => ' sparkle',
'$from_photo' => $rr['thumb'],
@ -224,7 +242,9 @@ function message_content(&$a) {
'$delete' => t('Delete conversation'),
'$body' => template_escape($rr['body']),
'$to_name' => template_escape($rr['name']),
'$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['mailcreated'], t('D, d M Y - g:i A'))
'$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['mailcreated'], t('D, d M Y - g:i A')),
'$seen' => $rr['mailseen'],
'$count' => sprintf( tt('%d message', '%d messages', $rr['count']), $rr['count']),
));
}
$o .= paginate($a);
@ -278,7 +298,8 @@ function message_content(&$a) {
));
$tpl = get_markup_template('mail_conv.tpl');
$mails = array();
$seen = 0;
foreach($messages as $message) {
if($message['from-url'] == $myprofile) {
$from_url = $myprofile;
@ -288,24 +309,35 @@ function message_content(&$a) {
$from_url = $a->get_baseurl(true) . '/redir/' . $message['contact-id'];
$sparkle = ' sparkle';
}
$o .= replace_macros($tpl, array(
'$id' => $message['id'],
'$from_name' => template_escape($message['from-name']),
'$from_url' => $from_url,
'$sparkle' => $sparkle,
'$from_photo' => $message['from-photo'],
'$subject' => template_escape($message['title']),
'$body' => template_escape(smilies(bbcode($message['body']))),
'$delete' => t('Delete message'),
'$to_name' => template_escape($message['name']),
'$date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A')
));
$mails[] = array(
'id' => $message['id'],
'from_name' => template_escape($message['from-name']),
'from_url' => $from_url,
'sparkle' => $sparkle,
'from_photo' => $message['from-photo'],
'subject' => template_escape($message['title']),
'body' => template_escape(smilies(bbcode($message['body']))),
'delete' => t('Delete message'),
'to_name' => template_escape($message['name']),
'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'),
);
$seen = $message['seen'];
}
$select = $message['name'] . '<input type="hidden" name="messageto" value="' . $contact_id . '" />';
$parent = '<input type="hidden" name="replyto" value="' . $message['parent-uri'] . '" />';
$tpl = get_markup_template('prv_message.tpl');
$o .= replace_macros($tpl,array(
$tpl = get_markup_template('mail_display.tpl');
$o = replace_macros($tpl, array(
'$thread_id' => $a->argv[1],
'$thread_subject' => $message['title'],
'$thread_seen' => $seen,
'$delete' => t('Delete conversation'),
'$mails' => $mails,
// reply
'$header' => t('Send Reply'),
'$to' => t('To:'),
'$subject' => t('Subject:'),
@ -318,6 +350,7 @@ function message_content(&$a) {
'$upload' => t('Upload photo'),
'$insert' => t('Insert web link'),
'$wait' => t('Please wait')
));
return $o;

View file

@ -1,13 +1,13 @@
<div class="mail-conv-outside-wrapper">
<div class="mail-conv-sender" >
<a href="$from_url" class="mail-conv-sender-url" ><img class="mframe mail-conv-sender-photo$sparkle" src="$from_photo" heigth="80" width="80" alt="$from_name" /></a>
<a href="$mail.from_url" class="mail-conv-sender-url" ><img class="mframe mail-conv-sender-photo$mail.sparkle" src="$mail.from_photo" heigth="80" width="80" alt="$mail.from_name" /></a>
</div>
<div class="mail-conv-detail" >
<div class="mail-conv-sender-name" >$from_name</div>
<div class="mail-conv-date">$date</div>
<div class="mail-conv-subject">$subject</div>
<div class="mail-conv-body">$body</div>
<div class="mail-conv-delete-wrapper" id="mail-conv-delete-wrapper-$id" ><a href="message/drop/$id" class="icon drophide delete-icon mail-list-delete-icon" onclick="return confirmDelete();" title="$delete" id="mail-conv-delete-icon-$id" class="mail-conv-delete-icon" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a></div><div class="mail-conv-delete-end"></div>
<div class="mail-conv-sender-name" >$mail.from_name</div>
<div class="mail-conv-date">$mail.date</div>
<div class="mail-conv-subject">$mail.subject</div>
<div class="mail-conv-body">$mail.body</div>
<div class="mail-conv-delete-wrapper" id="mail-conv-delete-wrapper-$mail.id" ><a href="message/drop/$mail.id" class="icon drophide delete-icon mail-list-delete-icon" onclick="return confirmDelete();" title="$mail.delete" id="mail-conv-delete-icon-$mail.id" class="mail-conv-delete-icon" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a></div><div class="mail-conv-delete-end"></div>
<div class="mail-conv-outside-wrapper-end"></div>
</div>
</div>

6
view/mail_display.tpl Normal file
View file

@ -0,0 +1,6 @@
{{ for $mails as $mail }}
{{ inc mail_conv.tpl }}{{endinc}}
{{ endfor }}
{{ inc prv_message.tpl }}{{ endinc }}

10
view/message_side.tpl Normal file
View file

@ -0,0 +1,10 @@
<div id="message-sidebar" class="widget">
<div id="message-new"><a href="$new.url" class="{{ if $new.sel }}newmessage-selected{{ endif }}">$new.label</a> </div>
<ul class="message-ul">
{{ for $tabs as $t }}
<li class="tool"><a href="$t.url" class="message-link{{ if $t.sel }}message-selected{{ endif }}">$t.label</a></li>
{{ endfor }}
</ul>
</div>

View file

@ -96,3 +96,12 @@
@JotPermissionLockBackgroundColor: @Grey4;
@JotLoadingBackgroundColor: @Grey1;
@JotPreviewBackgroundColor: @Yellow1;
@MessageNewBackgroundColor: @Blue1;
@MessageNewBorderColor: @Blue3;
@MessageNewColor: @Grey1;
@MailListBackgroundColor: #f6f7f8;
@MailDisplaySubjectColor: @Grey5;
@MailDisplaySubjectBackgroundColor: #f6f7f8;

View file

@ -0,0 +1,12 @@
<div id="fileas-sidebar" class="widget">
<h3>$title</h3>
<div id="nets-desc">$desc</div>
<ul class="fileas-ul">
<li class="tool {{ if $sel_all }}selected{{ endif }}"><a href="$base" class="fileas-link fileas-all">$all</a></li>
{{ for $terms as $term }}
<li class="tool {{ if $term.selected }}selected{{ endif }}"><a href="$base?f=&file=$term.name" class="fileas-link">$term.name</a></li>
{{ endfor }}
</ul>
</div>

View file

@ -0,0 +1,60 @@
<div class="wall-item-container $item.indent">
<div class="wall-item-item">
<div class="wall-item-info">
<div class="contact-photo-wrapper"
<a href="$mail.profile_url" target="redir" title="$mail.from_name" class="contact-photo-link" id="wall-item-photo-link-$mail.id">
<img src="$mail.from_photo" class="contact-photo$mail.sparkle" id="wall-item-photo-$mail.id" alt="$mail.from_name" />
</a>
</div>
</div>
<div class="wall-item-content">
$mail.body
</div>
</div>
<div class="wall-item-bottom">
<div class="wall-item-links">
</div>
<div class="wall-item-tags">
</div>
</div>
<div class="wall-item-bottom">
<div class="">
</div>
<div class="wall-item-actions">
<div class="wall-item-actions-author">
<a href="$mail.from_url" target="redir" class="wall-item-name-link"><span class="wall-item-name$mail.sparkle">$mail.from_name</span></a> <span class="wall-item-ago">$mail.date</span>
</div>
<div class="wall-item-actions-social">
</div>
<div class="wall-item-actions-tools">
<a href="message/drop/$mail.id" onclick="return confirmDelete();" class="icon delete s16" title="$mail.delete">$mail.delete</a>
</div>
</div>
</div>
<div class="wall-item-bottom">
</div>
</div>
{#
<div class="mail-conv-outside-wrapper">
<div class="mail-conv-sender" >
<a href="$mail.from_url" class="mail-conv-sender-url" ><img class="mframe mail-conv-sender-photo$mail.sparkle" src="$mail.from_photo" heigth="80" width="80" alt="$mail.from_name" /></a>
</div>
<div class="mail-conv-detail" >
<div class="mail-conv-sender-name" >$mail.from_name</div>
<div class="mail-conv-date">$mail.date</div>
<div class="mail-conv-subject">$mail.subject</div>
<div class="mail-conv-body">$mail.body</div>
<div class="mail-conv-delete-wrapper" id="mail-conv-delete-wrapper-$mail.id" ><a href="message/drop/$mail.id" class="icon drophide delete-icon mail-list-delete-icon" onclick="return confirmDelete();" title="$mail.delete" id="mail-conv-delete-icon-$mail.id" class="mail-conv-delete-icon" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a></div><div class="mail-conv-delete-end"></div>
<div class="mail-conv-outside-wrapper-end"></div>
</div>
</div>
<hr class="mail-conv-break" />
#}

View file

@ -0,0 +1,12 @@
<div id="mail-display-subject">
<span class="{{if $thread_seen}}seen{{else}}unseen{{endif}}">$thread_subject</span>
<a href="message/dropconv/$thread_id" onclick="return confirmDelete();" title="$delete" class="mail-delete icon s22 delete"></a>
</div>
{{ for $mails as $mail }}
<div id="tread-wrapper-$mail.id" class="tread-wrapper">
{{ inc mail_conv.tpl }}{{endinc}}
</div>
{{ endfor }}
{{ inc prv_message.tpl }}{{ endinc }}

View file

@ -0,0 +1,8 @@
<div class="mail-list-wrapper">
<span class="mail-subject {{if $seen}}seen{{else}}unseen{{endif}}"><a href="message/$id" class="mail-link">$subject</a></span>
<span class="mail-from">$from_name</span>
<span class="mail-date">$date</span>
<span class="mail-count">$count</span>
<a href="message/dropconv/$id" onclick="return confirmDelete();" title="$delete" class="mail-delete icon s22 delete"></a>
</div>

View file

@ -0,0 +1,10 @@
<div id="message-sidebar" class="widget">
<div id="message-new" class="{{ if $new.sel }}selected{{ endif }}"><a href="$new.url">$new.label</a> </div>
<ul class="message-ul">
{{ for $tabs as $t }}
<li class="tool {{ if $t.sel }}selected{{ endif }}"><a href="$t.url" class="message-link">$t.label</a></li>
{{ endfor }}
</ul>
</div>

View file

@ -0,0 +1,97 @@
<script language="javascript" type="text/javascript" src="$baseurl/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script>
<script language="javascript" type="text/javascript">
var plaintext = '$editselect';
if(plaintext != 'none') {
tinyMCE.init({
theme : "advanced",
mode : "specific_textareas",
editor_selector: /(profile-jot-text|prvmail-text)/,
plugins : "bbcode,paste",
theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
theme_advanced_blockformats : "blockquote,code",
gecko_spellcheck : true,
paste_text_sticky : true,
entity_encoding : "raw",
add_unload_trigger : false,
remove_linebreaks : false,
force_p_newlines : false,
force_br_newlines : true,
forced_root_block : '',
convert_urls: false,
content_css: "$baseurl/view/custom_tinymce.css",
//Character count
theme_advanced_path : false,
setup : function(ed) {
ed.onInit.add(function(ed) {
ed.pasteAsPlainText = true;
var editorId = ed.editorId;
var textarea = $('#'+editorId);
if (typeof(textarea.attr('tabindex')) != "undefined") {
$('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
textarea.attr('tabindex', null);
}
});
}
});
}
else
$("#prvmail-text").contact_autocomplete(baseurl+"/acl");
</script>
<script type="text/javascript" src="js/ajaxupload.js" ></script>
<script>
$(document).ready(function() {
var uploader = new window.AjaxUpload(
'prvmail-upload',
{ action: 'wall_upload/$nickname',
name: 'userfile',
onSubmit: function(file,ext) { $('#profile-rotator').show(); },
onComplete: function(file,response) {
tinyMCE.execCommand('mceInsertRawHTML',false,response);
$('#profile-rotator').hide();
}
}
);
});
function jotGetLink() {
reply = prompt("$linkurl");
if(reply && reply.length) {
$('#profile-rotator').show();
$.get('parse_url?url=' + reply, function(data) {
tinyMCE.execCommand('mceInsertRawHTML',false,data);
$('#profile-rotator').hide();
});
}
}
function linkdropper(event) {
var linkFound = event.dataTransfer.types.contains("text/uri-list");
if(linkFound)
event.preventDefault();
}
function linkdrop(event) {
var reply = event.dataTransfer.getData("text/uri-list");
event.target.textContent = reply;
event.preventDefault();
if(reply && reply.length) {
$('#profile-rotator').show();
$.get('parse_url?url=' + reply, function(data) {
tinyMCE.execCommand('mceInsertRawHTML',false,data);
$('#profile-rotator').hide();
});
}
}
</script>

View file

@ -319,41 +319,6 @@ aside {
img { width: 48px; height: 48px; }
}
}
/* mail view */
.mail-conv-sender,
.mail-conv-detail {
float: left;
}
.mail-conv-detail {
margin-left: 20px;
width: 500px;
}
.mail-conv-subject {
font-size: 1.4em;
margin: 10px 0;
}
.mail-conv-outside-wrapper-end {
clear: both;
}
.mail-conv-outside-wrapper {
margin-top: 30px;
}
.mail-conv-delete-wrapper {
float: right;
margin-right: 30px;
margin-top: 15px;
}
.mail-conv-break {
clear: both;
}
.mail-conv-delete-icon {
border: none;
}
/* group member */
#contact-edit-drop-link,
@ -938,6 +903,10 @@ ul.tabs {
textarea {
width: 400px;
}
input[type="checkbox"], input[type="radio"]{
width: auto;
}
textarea { height: 100px; }
.field_help {
display: block;
@ -981,6 +950,7 @@ ul.tabs {
&.radio .field_help { margin-left: 0px; }
}
#profile-edit-links li {
list-style: none;
margin-top: 10px;
@ -1085,6 +1055,90 @@ ul.tabs {
}
}
/* messages */
#message-new {
background: @MessageNewBackgroundColor;
border: 1px solid @MessageNewBorderColor;
width: 150px;
a {
color: @MessageNewColor;
text-align: center;
display: block;
font-weight: bold;
padding: 1em 0px;
}
}
.mail-list-wrapper {
background-color: @MailListBackgroundColor;
margin-bottom: 5px;
width: 100%; height: auto; overflow: hidden;
span { display: block; float: left; width: 20%; overflow: hidden;}
.mail-subject {
width: 30%;
padding:4px 0px 0px 4px;
a { display: block; }
&.unseen a { font-weight: bold; }
}
.mail-date { padding: 4px 4px 0px 4px; }
.mail-from { padding: 4px 4px 0px 4px; }
.mail-count { padding: 4px 4px 0px 4px; text-align: right;}
.mail-delete { float: right; }
}
#mail-display-subject {
background-color: @MailDisplaySubjectBackgroundColor;
color: @MailDisplaySubjectColor;
margin-bottom: 10px;
width: 100%; height: auto; overflow: hidden;
span { float: left; overflow: hidden; padding: 4px 0px 0px 10px;}
.mail-delete { float: right; .opaque(0.5);}
&:hover .mail-delete { .opaque(1); }
}
/* mail view */
/*
.mail-conv-sender,
.mail-conv-detail {
float: left;
}
.mail-conv-detail {
margin-left: 20px;
width: 500px;
}
.mail-conv-subject {
font-size: 1.4em;
margin: 10px 0;
}
.mail-conv-outside-wrapper-end {
clear: both;
}
.mail-conv-outside-wrapper {
margin-top: 30px;
}
.mail-conv-delete-wrapper {
float: right;
margin-right: 30px;
margin-top: 15px;
}
.mail-conv-break {
clear: both;
}
.mail-conv-delete-icon {
border: none;
}
*/
/* page footer */
footer { height: 100px; display: table-row; }

View file

@ -626,35 +626,6 @@ aside #profiles-menu {
width: 48px;
height: 48px;
}
/* mail view */
.mail-conv-sender, .mail-conv-detail {
float: left;
}
.mail-conv-detail {
margin-left: 20px;
width: 500px;
}
.mail-conv-subject {
font-size: 1.4em;
margin: 10px 0;
}
.mail-conv-outside-wrapper-end {
clear: both;
}
.mail-conv-outside-wrapper {
margin-top: 30px;
}
.mail-conv-delete-wrapper {
float: right;
margin-right: 30px;
margin-top: 15px;
}
.mail-conv-break {
clear: both;
}
.mail-conv-delete-icon {
border: none;
}
/* group member */
#contact-edit-drop-link, .mail-list-delete-wrapper, .group-delete-wrapper {
float: right;
@ -1355,6 +1326,9 @@ ul.tabs li .active {
.field input, .field textarea {
width: 400px;
}
.field input[type="checkbox"], .field input[type="radio"] {
width: auto;
}
.field textarea {
height: 100px;
}
@ -1503,6 +1477,123 @@ ul.tabs li .active {
left: 0px;
top: 63px;
}
/* messages */
#message-new {
background: #19aeff;
border: 1px solid #005c94;
width: 150px;
}
#message-new a {
color: #ffffff;
text-align: center;
display: block;
font-weight: bold;
padding: 1em 0px;
}
.mail-list-wrapper {
background-color: #f6f7f8;
margin-bottom: 5px;
width: 100%;
height: auto;
overflow: hidden;
}
.mail-list-wrapper span {
display: block;
float: left;
width: 20%;
overflow: hidden;
}
.mail-list-wrapper .mail-subject {
width: 30%;
padding: 4px 0px 0px 4px;
}
.mail-list-wrapper .mail-subject a {
display: block;
}
.mail-list-wrapper .mail-subject.unseen a {
font-weight: bold;
}
.mail-list-wrapper .mail-date {
padding: 4px 4px 0px 4px;
}
.mail-list-wrapper .mail-from {
padding: 4px 4px 0px 4px;
}
.mail-list-wrapper .mail-count {
padding: 4px 4px 0px 4px;
text-align: right;
}
.mail-list-wrapper .mail-delete {
float: right;
}
#mail-display-subject {
background-color: #f6f7f8;
color: #2d2d2d;
margin-bottom: 10px;
width: 100%;
height: auto;
overflow: hidden;
}
#mail-display-subject span {
float: left;
overflow: hidden;
padding: 4px 0px 0px 10px;
}
#mail-display-subject .mail-delete {
float: right;
opacity: 0.5;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
#mail-display-subject:hover .mail-delete {
opacity: 1;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
/* mail view */
/*
.mail-conv-sender,
.mail-conv-detail {
float: left;
}
.mail-conv-detail {
margin-left: 20px;
width: 500px;
}
.mail-conv-subject {
font-size: 1.4em;
margin: 10px 0;
}
.mail-conv-outside-wrapper-end {
clear: both;
}
.mail-conv-outside-wrapper {
margin-top: 30px;
}
.mail-conv-delete-wrapper {
float: right;
margin-right: 30px;
margin-top: 15px;
}
.mail-conv-break {
clear: both;
}
.mail-conv-delete-icon {
border: none;
}
*/
/* page footer */
footer {
height: 100px;