From 1c5eaa646c2129c2244bb38ca64e369ebfd080b6 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 8 Nov 2015 16:41:00 +0100 Subject: [PATCH 1/8] Only show valid contacts on the group side --- include/group.php | 20 +++++++++++--------- mod/group.php | 11 +++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/group.php b/include/group.php index b7e1963bf..fe29d39f1 100644 --- a/include/group.php +++ b/include/group.php @@ -156,9 +156,11 @@ function group_add_member($uid,$name,$member,$gid = 0) { function group_get_members($gid) { $ret = array(); if(intval($gid)) { - $r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member` - INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` - WHERE `gid` = %d AND `group_member`.`uid` = %d ORDER BY `contact`.`name` ASC ", + $r = q("SELECT `group_member`.`contact-id`, `contact`.* FROM `group_member` + INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` + WHERE `gid` = %d AND `group_member`.`uid` = %d AND + NOT `contact`.`self` AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + ORDER BY `contact`.`name` ASC ", intval($gid), intval(local_user()) ); @@ -171,14 +173,14 @@ function group_get_members($gid) { function group_public_members($gid) { $ret = 0; if(intval($gid)) { - $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` - INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` - WHERE `gid` = %d AND `group_member`.`uid` = %d + $r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member` + INNER JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id` + WHERE `gid` = %d AND `group_member`.`uid` = %d AND `contact`.`network` = '%s' AND `contact`.`notify` != '' ", intval($gid), intval(local_user()), dbesc(NETWORK_OSTATUS) - ); + ); if(count($r)) $ret = count($r); } @@ -187,7 +189,7 @@ function group_public_members($gid) { function mini_group_select($uid,$gid = 0) { - + $grps = array(); $o = ''; @@ -205,7 +207,7 @@ function mini_group_select($uid,$gid = 0) { $o = replace_macros(get_markup_template('group_selection.tpl'), array( '$label' => t('Default privacy group for new contacts'), - '$groups' => $grps + '$groups' => $grps )); return $o; } diff --git a/mod/group.php b/mod/group.php index 4a447713d..263586e2e 100644 --- a/mod/group.php +++ b/mod/group.php @@ -62,12 +62,12 @@ function group_post(&$a) { $a->page['aside'] = group_side(); } - return; + return; } function group_content(&$a) { $change = false; - + if(! local_user()) { notice( t('Permission denied') . EOL); return; @@ -172,7 +172,7 @@ function group_content(&$a) { '$form_security_token' => get_form_security_token("group_drop"), )); - + $context = $context + array( '$title' => t('Group Editor'), '$gname' => array('groupname',t('Group Name: '),$group['name'], ''), @@ -192,7 +192,7 @@ function group_content(&$a) { 'label_contacts' => t('All Contacts'), 'contacts' => array(), ); - + $sec_token = addslashes(get_form_security_token('group_member_change')); $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); foreach($members as $member) { @@ -226,8 +226,7 @@ function group_content(&$a) { echo replace_macros($tpl, $context); killme(); } - + return replace_macros($tpl, $context); } - From d522d7095ddbbdd1668cb5e90261edcc68f66b46 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Sun, 8 Nov 2015 16:55:44 +0100 Subject: [PATCH 2/8] quattro: add unread message count per groups --- js/main.js | 2 +- view/theme/quattro/dark/style.css | 17 +- view/theme/quattro/green/style.css | 17 +- view/theme/quattro/js/quattro.js | 143 +++++++++++++++++ view/theme/quattro/lilac/style.css | 23 ++- view/theme/quattro/quattro.less | 14 ++ .../templates/generic_links_widget.tpl | 5 +- view/theme/quattro/templates/group_side.tpl | 9 +- view/theme/quattro/theme.php | 149 +----------------- 9 files changed, 221 insertions(+), 158 deletions(-) create mode 100644 view/theme/quattro/js/quattro.js diff --git a/js/main.js b/js/main.js index 572a6ebfe..84940eb23 100644 --- a/js/main.js +++ b/js/main.js @@ -153,7 +153,7 @@ var notifications_empty = unescape($("#nav-notifications-menu").html()); /* nav update event */ - $('nav').bind('nav-update', function(e,data){; + $('nav').bind('nav-update', function(e,data){ var invalid = $(data).find('invalid').text(); if(invalid == 1) { window.location.href=window.location.href } diff --git a/view/theme/quattro/dark/style.css b/view/theme/quattro/dark/style.css index 485ac3938..93ee1ccd5 100644 --- a/view/theme/quattro/dark/style.css +++ b/view/theme/quattro/dark/style.css @@ -463,7 +463,7 @@ a:hover { text-decoration: underline; } blockquote { - background: #ffffff; + background: #FFFFFF; padding: 1em; margin-left: 1em; border-left: 1em solid #e6e6e6; @@ -1013,6 +1013,21 @@ aside .posted-date-selector-months { .widget .tool.selected { background: url('../../../images/selected.png') no-repeat left center; } +.widget .notify { + display: none; + background-color: #19AEFF; + border-radius: 5px; + font-size: 10px; + padding: 1px 3px; + min-width: 15px; + text-align: right; + float: right; + color: #ffffff; + margin-right: 10px; +} +.widget .notify.on { + display: block; +} /* widget: search */ #add-search-popup { width: 200px; diff --git a/view/theme/quattro/green/style.css b/view/theme/quattro/green/style.css index 345043ffb..ab50d93ae 100644 --- a/view/theme/quattro/green/style.css +++ b/view/theme/quattro/green/style.css @@ -463,7 +463,7 @@ a:hover { text-decoration: underline; } blockquote { - background: #ffffff; + background: #FFFFFF; padding: 1em; margin-left: 1em; border-left: 1em solid #e6e6e6; @@ -1013,6 +1013,21 @@ aside .posted-date-selector-months { .widget .tool.selected { background: url('../../../images/selected.png') no-repeat left center; } +.widget .notify { + display: none; + background-color: #19AEFF; + border-radius: 5px; + font-size: 10px; + padding: 1px 3px; + min-width: 15px; + text-align: right; + float: right; + color: #ffffff; + margin-right: 10px; +} +.widget .notify.on { + display: block; +} /* widget: search */ #add-search-popup { width: 200px; diff --git a/view/theme/quattro/js/quattro.js b/view/theme/quattro/js/quattro.js new file mode 100644 index 000000000..1a532b9d5 --- /dev/null +++ b/view/theme/quattro/js/quattro.js @@ -0,0 +1,143 @@ +$(document).ready(function(){ + $('nav').bind('nav-update', function(e,data){ + var notifCount = $(data).find('notif').attr('count'); + var intro = $(data).find('intro').text(); + var mail = $(data).find('mail').text(); + + $("tool notify").removeClass("on"); + $(data).find("group").each(function() { + var gid = this.id; + var gcount = this.innerHTML; + $(".group-"+gid+" .notify").addClass("on").text(gcount); + }); + + console.log(intro,mail); + + if (notifCount > 0 ) { + Tinycon.setBubble(notifCount); + } else { + Tinycon.setBubble(''); + } + + if (intro>0){ + $("#nav-introductions-link").addClass("on"); + } else { + $("#nav-introductions-link").removeClass("on"); + } + + if (mail>0){ + $("#nav-messages-link").addClass("on"); + } else { + $("#nav-messages-link").removeClass("on"); + } + + }); + + /* + * show and hide contact action buttons in + * contacts page on contacts' checkbox selection + */ + $('.contact-select').bind('click', function(e) { + var y = e.clientY; + var elm = $("#contacts-actions"); + y=y-40; + if (y<0) y=0; + if (y+elm.height() > $("html").height()) y=$("html").height()-elm.height(); + elm.css('top', y+"px"); + if ($(".contact-select:checked").length > 0) { + elm.show(); + } else { + elm.hide(); + } + }); +}); + +function insertFormatting(comment,BBcode,id) { + + var tmpStr = $("#comment-edit-text-" + id).val(); + if(tmpStr == comment) { + tmpStr = ""; + $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); + $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); + openMenu("comment-edit-submit-wrapper-" + id); + $("#comment-edit-text-" + id).val(tmpStr); + } + + textarea = document.getElementById("comment-edit-text-" +id); + if (document.selection) { + textarea.focus(); + selected = document.selection.createRange(); + if (BBcode == "url"){ + selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]"; + } else + selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; + } else if (textarea.selectionStart || textarea.selectionStart == "0") { + var start = textarea.selectionStart; + var end = textarea.selectionEnd; + if (BBcode == "url"){ + textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); + } else + textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); + } + return true; +} + +function showThread(id) { + $("#collapsed-comments-" + id).show() + $("#collapsed-comments-" + id + " .collapsed-comments").show() +} +function hideThread(id) { + $("#collapsed-comments-" + id).hide() + $("#collapsed-comments-" + id + " .collapsed-comments").hide() +} + + +function cmtBbOpen(id) { + $("#comment-edit-bb-" + id).show(); +} +function cmtBbClose(id) { + $("#comment-edit-bb-" + id).hide(); +} + +$(document).ready(function() { + + $('html').click(function() { $("#nav-notifications-menu" ).hide(); }); + + $('.group-edit-icon').hover( + function() { + $(this).addClass('icon'); $(this).removeClass('iconspacer');}, + function() { + $(this).removeClass('icon'); $(this).addClass('iconspacer');} + ); + + $('.sidebar-group-element').hover( + function() { + id = $(this).attr('id'); + $('#edit-' + id).addClass('icon'); $('#edit-' + id).removeClass('iconspacer');}, + + function() { + id = $(this).attr('id'); + $('#edit-' + id).removeClass('icon');$('#edit-' + id).addClass('iconspacer');} + ); + + + $('.savedsearchdrop').hover( + function() { + $(this).addClass('drop'); $(this).addClass('icon'); $(this).removeClass('iconspacer');}, + function() { + $(this).removeClass('drop'); $(this).removeClass('icon'); $(this).addClass('iconspacer');} + ); + + $('.savedsearchterm').hover( + function() { + id = $(this).attr('id'); + $('#drop-' + id).addClass('icon'); $('#drop-' + id).addClass('drophide'); $('#drop-' + id).removeClass('iconspacer');}, + + function() { + id = $(this).attr('id'); + $('#drop-' + id).removeClass('icon');$('#drop-' + id).removeClass('drophide'); $('#drop-' + id).addClass('iconspacer');} + ); + +}); + + diff --git a/view/theme/quattro/lilac/style.css b/view/theme/quattro/lilac/style.css index b2dec86c8..510b2f7c8 100644 --- a/view/theme/quattro/lilac/style.css +++ b/view/theme/quattro/lilac/style.css @@ -420,7 +420,7 @@ body { font-family: Liberation Sans, helvetica, arial, clean, sans-serif; font-size: 11px; - background-color: #f6ecf9; + background-color: #F6ECF9; color: #2d2d2d; margin: 50px 0px 0px 0px; display: table; @@ -463,7 +463,7 @@ a:hover { text-decoration: underline; } blockquote { - background: #ffffff; + background: #FFFFFF; padding: 1em; margin-left: 1em; border-left: 1em solid #e6e6e6; @@ -1013,6 +1013,21 @@ aside .posted-date-selector-months { .widget .tool.selected { background: url('../../../images/selected.png') no-repeat left center; } +.widget .notify { + display: none; + background-color: #19AEFF; + border-radius: 5px; + font-size: 10px; + padding: 1px 3px; + min-width: 15px; + text-align: right; + float: right; + color: #ffffff; + margin-right: 10px; +} +.widget .notify.on { + display: block; +} /* widget: search */ #add-search-popup { width: 200px; @@ -1689,7 +1704,7 @@ span[id^="showmore-wrap"] { height: 20px; width: 500px; font-weight: bold; - border: 1px solid #f6ecf9; + border: 1px solid #F6ECF9; } #jot #jot-title:-webkit-input-placeholder { font-weight: normal; @@ -1716,7 +1731,7 @@ span[id^="showmore-wrap"] { margin: 0px; height: 20px; width: 200px; - border: 1px solid #f6ecf9; + border: 1px solid #F6ECF9; } #jot #jot-category:hover { border: 1px solid #999999; diff --git a/view/theme/quattro/quattro.less b/view/theme/quattro/quattro.less index 7aede8df0..2faa7966f 100644 --- a/view/theme/quattro/quattro.less +++ b/view/theme/quattro/quattro.less @@ -442,6 +442,20 @@ aside { /*.action .s10 { width: 10px; overflow: hidden; padding: 0px;} .action .s16 { width: 16px; overflow: hidden; padding: 0px;}*/ + .notify { + display: none; + background-color: #19AEFF; + border-radius: 5px; + font-size: 10px; + padding: 1px 3px; + min-width: 15px; + text-align: right; + float: right; + color: rgb(255, 255, 255); + margin-right: 10px; + + &.on { display: block; } + } } /* widget: search */ diff --git a/view/theme/quattro/templates/generic_links_widget.tpl b/view/theme/quattro/templates/generic_links_widget.tpl index 6f7a082c1..426464a09 100644 --- a/view/theme/quattro/templates/generic_links_widget.tpl +++ b/view/theme/quattro/templates/generic_links_widget.tpl @@ -1,11 +1,12 @@
{{if $title}}

{{$title}}

{{/if}} {{if $desc}}
{{$desc}}
{{/if}} - +
    {{foreach $items as $item}} + {{$item|var_dump}} {{/foreach}}
- +
diff --git a/view/theme/quattro/templates/group_side.tpl b/view/theme/quattro/templates/group_side.tpl index d0fb5d62b..620d2de75 100644 --- a/view/theme/quattro/templates/group_side.tpl +++ b/view/theme/quattro/templates/group_side.tpl @@ -7,7 +7,7 @@ - + diff --git a/view/theme/quattro/theme.php b/view/theme/quattro/theme.php index 1be5c0267..a1cd29ee7 100644 --- a/view/theme/quattro/theme.php +++ b/view/theme/quattro/theme.php @@ -6,151 +6,10 @@ * Maintainer: Fabio * Maintainer: Tobias */ - + function quattro_init(&$a) { -$a->theme_info = array(); -set_template_engine($a, 'smarty3'); + $a->theme_info = array(); - -$a->page['htmlhead'] .= ''; -$a->page['htmlhead'] .= <<< EOT - -EOT; + $a->page['htmlhead'] .= ''; + $a->page['htmlhead'] .= '';; } From 3c1127e613f7e13cb14fb21577c2a69dd5072d3e Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Sun, 8 Nov 2015 17:04:39 +0100 Subject: [PATCH 3/8] remove debug code --- view/theme/quattro/templates/generic_links_widget.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/view/theme/quattro/templates/generic_links_widget.tpl b/view/theme/quattro/templates/generic_links_widget.tpl index 426464a09..1a26c9741 100644 --- a/view/theme/quattro/templates/generic_links_widget.tpl +++ b/view/theme/quattro/templates/generic_links_widget.tpl @@ -4,7 +4,6 @@
    {{foreach $items as $item}} - {{$item|var_dump}} {{/foreach}}
From c700a6fb37c7acc17a395a64dfaca5db275ff537 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Sun, 8 Nov 2015 18:02:04 +0100 Subject: [PATCH 4/8] duepuntozero, vier: add unread messages per group --- js/main.js | 7 +++++++ mod/ping.php | 26 +++++++++++++------------- view/templates/group_side.tpl | 9 +++++---- view/theme/duepuntozero/style.css | 11 +++++++++++ view/theme/quattro/js/quattro.js | 2 +- view/theme/vier/style.css | 17 ++++++++++++++--- 6 files changed, 51 insertions(+), 21 deletions(-) diff --git a/js/main.js b/js/main.js index 84940eb23..df454afe1 100644 --- a/js/main.js +++ b/js/main.js @@ -203,6 +203,13 @@ var birthdaystoday = $(data).find('birthdays-today').text(); if(birthdaystoday == 0) { $('#birthdays-update').removeClass('notif-birthdays-today') } else { $('#birthdays-update').addClass('notif-birthdays-today') } + $(".sidebar-group-li .notify").removeClass("show"); + $(data).find("group").each(function() { + var gid = this.id; + var gcount = this.innerHTML; + $(".group-"+gid+" .notify").addClass("show").text(gcount); + }); + var eNotif = $(data).find('notif') diff --git a/mod/ping.php b/mod/ping.php index a7a2755c5..30b5785ae 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -203,8 +203,8 @@ function ping_init(&$a) { if ($a->is_friendica_app() OR !$regularnotifications) $n['message'] = str_replace("{0}", $n['name'], $n['message']); - $local_time = datetime_convert('UTC',date_default_timezone_get(),$n['date']); - + $local_time = datetime_convert('UTC',date_default_timezone_get(),$n['date']); + call_hooks('ping_xmlize', $n); $notsxml = '%s'."\n"; return sprintf ( $notsxml, @@ -250,41 +250,41 @@ function ping_init(&$a) { $n = array( 'href' => $a->get_baseurl().'/notifications/intros/'.$i['id'], 'name' => $i['name'], - 'url' => $i['url'], + 'url' => $i['url'], 'photo' => $i['photo'], 'date' => $i['datetime'], 'seen' => false, - 'message' => t("{0} wants to be your friend"), + 'message' => t("{0} wants to be your friend"), ); $notifs[] = $n; } } - + if ($mail>0){ foreach ($mails as $i) { $n = array( 'href' => $a->get_baseurl().'/message/'.$i['id'], 'name' => $i['from-name'], - 'url' => $i['from-url'], + 'url' => $i['from-url'], 'photo' => $i['from-photo'], 'date' => $i['created'], 'seen' => false, - 'message' => t("{0} sent you a message"), + 'message' => t("{0} sent you a message"), ); $notifs[] = $n; } } - + if ($register>0){ foreach ($regs as $i) { $n = array( 'href' => $a->get_baseurl().'/admin/users/', 'name' => $i['name'], - 'url' => $i['url'], + 'url' => $i['url'], 'photo' => $i['micro'], 'date' => $i['created'], 'seen' => false, - 'message' => t("{0} requested registration"), + 'message' => t("{0} requested registration"), ); $notifs[] = $n; } @@ -363,7 +363,7 @@ function ping_get_notifications($uid) { $quit = true; else $offset += 50; - + foreach ($r AS $notification) { if (is_null($notification["visible"])) @@ -386,7 +386,7 @@ function ping_get_notifications($uid) { $notification["message"] = substr_replace($notification["message"],"{0}",$pos,strlen($notification["name"])); $notification['href'] = $a->get_baseurl() . '/notify/view/' . $notification['id']; - + if ($notification["visible"] AND !$notification["spam"] AND !$notification["deleted"] AND !is_array($result[$notification["parent"]])) { $result[$notification["parent"]] = $notification; @@ -395,6 +395,6 @@ function ping_get_notifications($uid) { } while ((count($result) < 50) AND !$quit); - + return($result); } diff --git a/view/templates/group_side.tpl b/view/templates/group_side.tpl index c7e1aa895..4905c2fa1 100644 --- a/view/templates/group_side.tpl +++ b/view/templates/group_side.tpl @@ -4,18 +4,19 @@