diff options
-rw-r--r-- | js/main.js | 13 | ||||
-rw-r--r-- | mod/notify.php | 13 | ||||
-rw-r--r-- | mod/ping.php | 43 | ||||
-rwxr-xr-x | util/updatetpl.py | 2 | ||||
-rw-r--r-- | view/tpl/nav.tpl | 10 | ||||
-rw-r--r-- | view/tpl/smarty3/nav.tpl | 10 |
6 files changed, 61 insertions, 30 deletions
diff --git a/js/main.js b/js/main.js index 458fc5e87..4d4a510e7 100644 --- a/js/main.js +++ b/js/main.js @@ -95,7 +95,11 @@ document.getElementById(theID).style.display = "none" } - + function markRead(notifType) { + $.get('ping?f=&markRead='+notifType); + if(timer) clearTimeout(timer); + timer = setTimeout(NavUpdate,2000); + } var src = null; var prev = null; @@ -789,13 +793,6 @@ function checkboxhighlight(box) { } } -function notifyMarkAll() { - $.get('notify/mark/all', function(data) { - if(timer) clearTimeout(timer); - timer = setTimeout(NavUpdate,1000); - }); -} - // code from http://www.tinymce.com/wiki.php/How-to_implement_a_custom_file_browser function fcFileBrowser (field_name, url, type, win) { diff --git a/mod/notify.php b/mod/notify.php index 3157e8ce8..23ba098b7 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -10,7 +10,7 @@ function notify_init(&$a) { intval(argv(2)), intval(local_user()) ); - if(count($r)) { + if($r) { q("update notify set seen = 1 where ( link = '%s' or ( parent != 0 and parent = %d and otype = '%s' )) and uid = %d", dbesc($r[0]['link']), intval($r[0]['parent']), @@ -24,15 +24,6 @@ function notify_init(&$a) { } - if(argc() > 2 && argv(1) === 'mark' && argv(2) === 'all' ) { - $r = q("update notify set seen = 1 where uid = %d", - intval(local_user()) - ); - $j = json_encode(array('result' => ($r) ? 'success' : 'fail')); - echo $j; - killme(); - } - } @@ -49,7 +40,7 @@ function notify_content(&$a) { intval(local_user()) ); - if (count($r) > 0) { + if($r) { foreach ($r as $it) { $notif_content .= replace_macros($not_tpl,array( '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'], diff --git a/mod/ping.php b/mod/ping.php index 477b9ff0d..4ab7a68cb 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -48,6 +48,49 @@ function ping_init(&$a) { killme(); } + if(x($_REQUEST,'markRead') && local_user()) { + switch($_REQUEST['markRead']) { + case 'network': + $r = q("update item set item_flags = ( item_flags ^ %d ) where (item_flags & %d) and uid = %d", + intval(ITEM_UNSEEN), + intval(ITEM_UNSEEN), + intval(local_user()) + ); + break; + + case 'home': + $r = q("update item set item_flags = ( item_flags ^ %d ) where (item_flags & %d) and (item_flags & %d) and uid = %d", + intval(ITEM_UNSEEN), + intval(ITEM_UNSEEN), + intval(ITEM_WALL), + intval(local_user()) + ); + break; + case 'messages': + $r = q("update mail set mail_flags = ( item_flags ^ %d ) where uid = %d and not (item_flags & %d)", + intval(MAIL_SEEN), + intval(local_user()), + intval(MAIL_SEEN) + ); + break; + case 'all_events': + $r = q("update event set ignore = 1 where ignore = 0 and uid = %d", + intval(local_user()) + ); + break; + + case 'notify': + $r = q("update notify set seen = 1 where uid = %d", + intval(local_user()) + ); + break; + + default: + break; + } + } + + if(argc() > 1 && argv(1) === 'notify') { $t = q("select count(*) as total from notify where uid = %d and seen = 0", intval(local_user()) diff --git a/util/updatetpl.py b/util/updatetpl.py index 1319387c6..d3dd7ef04 100755 --- a/util/updatetpl.py +++ b/util/updatetpl.py @@ -59,7 +59,7 @@ fnull = open(os.devnull, "w") for tplpath in tplpaths: print "Converting " + path + tplpath - subprocess.call(['python', path + 'mods/friendica-to-smarty-tpl.py', '-p', path + tplpath], stdout = fnull) + subprocess.call(['python', path + 'util/friendica-to-smarty-tpl.py', '-p', path + tplpath], stdout = fnull) fnull.close() diff --git a/view/tpl/nav.tpl b/view/tpl/nav.tpl index d17040db1..e98621aa4 100644 --- a/view/tpl/nav.tpl +++ b/view/tpl/nav.tpl @@ -17,7 +17,7 @@ <span id="net-update" class="nav-notify fakelink" rel="#nav-network-menu"></span> <ul id="nav-network-menu" class="menu-popup notify-menus" rel="network"> <li id="nav-network-see-all"><a href="$nav.network.all.0">$nav.network.all.1</a></li> - <li id="nav-network-mark-all"><a href="#" onclick="/*fixme*/ return false;">$nav.network.mark.1</a></li> + <li id="nav-network-mark-all"><a href="#" onclick="markRead('network'); return false;">$nav.network.mark.1</a></li> <li class="empty">$emptynotifications</li> </ul> </li> @@ -29,7 +29,7 @@ <span id="home-update" class="nav-notify fakelink" rel="#nav-home-menu"></span> <ul id="nav-home-menu" class="menu-popup notify-menus" rel="home"> <li id="nav-home-see-all"><a href="$nav.home.all.0">$nav.home.all.1</a></li> - <li id="nav-home-mark-all"><a href="#" onclick="/*fixme*/ return false;">$nav.home.mark.1</a></li> + <li id="nav-home-mark-all"><a href="#" onclick="markRead('home'); return false;">$nav.home.mark.1</a></li> <li class="empty">$emptynotifications</li> </ul> </li> @@ -41,7 +41,7 @@ <span id="mail-update" class="nav-notify fakelink" rel="#nav-messages-menu"></span> <ul id="nav-messages-menu" class="menu-popup notify-menus" rel="messages"> <li id="nav-messages-see-all"><a href="$nav.messages.all.0">$nav.messages.all.1</a></li> - <li id="nav-messages-mark-all"><a href="#">$nav.messages.mark.1</a></li> + <li id="nav-messages-mark-all"><a href="#" onclick="markRead('messages'); return false;">$nav.messages.mark.1</a></li> <li class="empty">$emptynotifications</li> </ul> </li> @@ -53,7 +53,7 @@ <span id="all_events-update" class="nav-notify fakelink" rel="#nav-all_events-menu"></span> <ul id="nav-all_events-menu" class="menu-popup notify-menus" rel="all_events"> <li id="nav-all_events-see-all"><a href="$nav.all_events.all.0">$nav.all_events.all.1</a></li> - <li id="nav-all_events-mark-all"><a href="#" onclick="/*fixme*/ return false;">$nav.all_events.mark.1</a></li> + <li id="nav-all_events-mark-all"><a href="#" onclick="markRead('all_events'); return false;">$nav.all_events.mark.1</a></li> <li class="empty">$emptynotifications</li> </ul> </li> @@ -76,7 +76,7 @@ <span id="notify-update" class="nav-notify fakelink" rel="#nav-notify-menu"></span> <ul id="nav-notify-menu" class="menu-popup notify-menus" rel="notify"> <li id="nav-notify-see-all"><a href="$nav.notifications.all.0">$nav.notifications.all.1</a></li> - <li id="nav-notify-mark-all"><a href="#" onclick="notifyMarkAll(); return false;">$nav.notifications.mark.1</a></li> + <li id="nav-notify-mark-all"><a href="#" onclick="markRead('notify'); return false;">$nav.notifications.mark.1</a></li> <li class="empty">$emptynotifications</li> </ul> </li> diff --git a/view/tpl/smarty3/nav.tpl b/view/tpl/smarty3/nav.tpl index 1459a31f4..261607e5b 100644 --- a/view/tpl/smarty3/nav.tpl +++ b/view/tpl/smarty3/nav.tpl @@ -22,7 +22,7 @@ <span id="net-update" class="nav-notify fakelink" rel="#nav-network-menu"></span> <ul id="nav-network-menu" class="menu-popup notify-menus" rel="network"> <li id="nav-network-see-all"><a href="{{$nav.network.all.0}}">{{$nav.network.all.1}}</a></li> - <li id="nav-network-mark-all"><a href="#" onclick="/*fixme*/ return false;">{{$nav.network.mark.1}}</a></li> + <li id="nav-network-mark-all"><a href="#" onclick="markRead('network'); return false;">{{$nav.network.mark.1}}</a></li> <li class="empty">{{$emptynotifications}}</li> </ul> </li> @@ -34,7 +34,7 @@ <span id="home-update" class="nav-notify fakelink" rel="#nav-home-menu"></span> <ul id="nav-home-menu" class="menu-popup notify-menus" rel="home"> <li id="nav-home-see-all"><a href="{{$nav.home.all.0}}">{{$nav.home.all.1}}</a></li> - <li id="nav-home-mark-all"><a href="#" onclick="/*fixme*/ return false;">{{$nav.home.mark.1}}</a></li> + <li id="nav-home-mark-all"><a href="#" onclick="markRead('home'); return false;">{{$nav.home.mark.1}}</a></li> <li class="empty">{{$emptynotifications}}</li> </ul> </li> @@ -46,7 +46,7 @@ <span id="mail-update" class="nav-notify fakelink" rel="#nav-messages-menu"></span> <ul id="nav-messages-menu" class="menu-popup notify-menus" rel="messages"> <li id="nav-messages-see-all"><a href="{{$nav.messages.all.0}}">{{$nav.messages.all.1}}</a></li> - <li id="nav-messages-mark-all"><a href="#">{{$nav.messages.mark.1}}</a></li> + <li id="nav-messages-mark-all"><a href="#" onclick="markRead('messages'); return false;">{{$nav.messages.mark.1}}</a></li> <li class="empty">{{$emptynotifications}}</li> </ul> </li> @@ -58,7 +58,7 @@ <span id="all_events-update" class="nav-notify fakelink" rel="#nav-all_events-menu"></span> <ul id="nav-all_events-menu" class="menu-popup notify-menus" rel="all_events"> <li id="nav-all_events-see-all"><a href="{{$nav.all_events.all.0}}">{{$nav.all_events.all.1}}</a></li> - <li id="nav-all_events-mark-all"><a href="#" onclick="/*fixme*/ return false;">{{$nav.all_events.mark.1}}</a></li> + <li id="nav-all_events-mark-all"><a href="#" onclick="markRead('all_events'); return false;">{{$nav.all_events.mark.1}}</a></li> <li class="empty">{{$emptynotifications}}</li> </ul> </li> @@ -81,7 +81,7 @@ <span id="notify-update" class="nav-notify fakelink" rel="#nav-notify-menu"></span> <ul id="nav-notify-menu" class="menu-popup notify-menus" rel="notify"> <li id="nav-notify-see-all"><a href="{{$nav.notifications.all.0}}">{{$nav.notifications.all.1}}</a></li> - <li id="nav-notify-mark-all"><a href="#" onclick="notifyMarkAll(); return false;">{{$nav.notifications.mark.1}}</a></li> + <li id="nav-notify-mark-all"><a href="#" onclick="markRead('notify'); return false;">{{$nav.notifications.mark.1}}</a></li> <li class="empty">{{$emptynotifications}}</li> </ul> </li> |