From ba20913c2b1fde5fdc9a25e5efa0c1d3a55d74c4 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 8 Jan 2013 02:49:08 -0800 Subject: lots of notification tweaks --- include/enotify.php | 6 +++--- js/main.js | 16 ++++++++-------- mod/notify.php | 1 + mod/ping.php | 39 +++++++++++++++++++++++++++++++++++++++ view/theme/redbasic/css/style.css | 7 +++++++ view/tpl/nav.tpl | 12 ++++++------ 6 files changed, 64 insertions(+), 17 deletions(-) diff --git a/include/enotify.php b/include/enotify.php index 140baf104..0e83adf08 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -324,11 +324,11 @@ function notification($params) { } $itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id; - $msg = replace_macros($epreamble,array('$itemlink' => $itemlink)); + $msg = str_replace('$itemlink',$itemlink,$epreamble); $r = q("update notify set msg = '%s' where id = %d and uid = %d limit 1", dbesc($msg), intval($notify_id), - intval($params['uid']) + intval($datarray['uid']) ); @@ -345,7 +345,7 @@ function notification($params) { $r = q("select `id` from `notify-threads` where `master-parent-item` = %d and `receiver-uid` = %d limit 1", intval($params['parent']), - intval($params['uid']) ); + intval($datarray['uid']) ); // If so, create the record of it and use a message-id smtp header. diff --git a/js/main.js b/js/main.js index 59c55551b..169717404 100644 --- a/js/main.js +++ b/js/main.js @@ -534,11 +534,11 @@ function updateConvItems(mode,data) { /* notifications template */ var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html()); - var notifications_all = unescape($('
').append( $("#nav-notifications-see-all").clone() ).html()); //outerHtml hack - var notifications_mark = unescape($('
').append( $("#nav-notifications-mark-all").clone() ).html()); //outerHtml hack - var notifications_empty = unescape($("#nav-notifications-menu").html()); + var notifications_all = unescape($('
').append( $("#nav-" + notifyType + "-see-all").clone() ).html()); //outerHtml hack + var notifications_mark = unescape($('
').append( $("#nav-" + notifyType + "-mark-all").clone() ).html()); //outerHtml hack + var notifications_empty = unescape($("#nav-" + notifyType + "-menu").html()); - var notify_menu = $("#nav-notifications-menu"); + var notify_menu = $("#nav-" + notifyType + "-menu"); var pingExCmd = 'ping/' + notifyType + ((localUser != 0) ? '?f=&uid=' + localUser : ''); $.get(pingExCmd,function(data) { @@ -549,16 +549,16 @@ function updateConvItems(mode,data) { if(data.notify.length==0){ - $("#nav-notifications-menu").html(notifications_empty); + $("#nav-" + notifyType + "-menu").html(notifications_empty); } else { - $("#nav-notifications-menu").html(notifications_all + notifications_mark); + $("#nav-" + notifyType + "-menu").html(notifications_all + notifications_mark); $(data.notify).each(function() { - text = ""+this.name+"" + ' ' + this.message; + text = ""+this.name+"" + ' ' + this.message + '
'; html = notifications_tpl.format(this.notify_link,this.photo,text,this.when,this.class); - $("#nav-notifications-menu").append(html); + $("#nav-" + notifyType + "-menu").append(html); }); } diff --git a/mod/notify.php b/mod/notify.php index dd26bfe7e..3157e8ce8 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -23,6 +23,7 @@ function notify_init(&$a) { goaway($a->get_baseurl(true)); } + if(argc() > 2 && argv(1) === 'mark' && argv(2) === 'all' ) { $r = q("update notify set seen = 1 where uid = %d", intval(local_user()) diff --git a/mod/ping.php b/mod/ping.php index 76d139711..b128cffeb 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -82,6 +82,42 @@ function ping_init(&$a) { 'class' => (($zz['seen']) ? 'notify-seen' : 'notify-unseen'), 'message' => strip_tags(bbcode($zz['msg'])) ); + logger('notifs: ' . print_r($notifs,true)); + } + + + } + + echo json_encode(array('notify' => $notifs)); + killme(); + + } + + + if(argc() > 1 && argv(1) === 'messages') { + + $channel = $a->get_channel(); + $t = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan + where channel_id = %d and ( mail_flags & %d ) and not (mail_flags & %d ) + and from_xchan != '%s' order by created desc limit 0,50", + intval(local_user()), + intval(MAIL_SEEN), + intval(MAIL_DELETED), + dbesc($channel['channel_hash']) + ); + + if($t) { + foreach($t as $zz) { +// $msg = sprintf( t('sent you a private message.'), $zz['xchan_name']); + $notifs[] = array( + 'notify_link' => $a->get_baseurl() . '/message/' . $zz['id'], + 'name' => $zz['xchan_name'], + 'url' => $zz['xchan_url'], + 'photo' => $zz['xchan_photo_s'], + 'when' => relative_date($zz['created']), + 'class' => (($zz['mail_flags'] & MAIL_SEEN) ? 'notify-seen' : 'notify-unseen'), + 'message' => t('sent you a private message'), + ); } } @@ -90,6 +126,9 @@ function ping_init(&$a) { } + + + if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) { $result = array(); diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index d6cee8825..b855a045a 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -3774,6 +3774,13 @@ ul.menu-popup { /* top: 90px; */ /* left: 400px; */ } + +.notify-menus { + width: 320px !important; + max-height: 400px; + overflow-y: scroll;overflow-style:scrollbar; +} + #nav-notifications-menu { width: 320px; max-height: 400px; diff --git a/view/tpl/nav.tpl b/view/tpl/nav.tpl index c952ca93c..1b4247280 100644 --- a/view/tpl/nav.tpl +++ b/view/tpl/nav.tpl @@ -29,7 +29,7 @@