From ea4d1b5101022f928336a20f193f8f73adb4d5a7 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 30 Sep 2017 15:17:47 -0700 Subject: [PATCH 01/13] use imagick converter for large photos --- Zotlabs/Module/Admin/Site.php | 3 ++ include/photos.php | 79 ++++++++++++++++++++++++++++++++++- view/tpl/admin_site.tpl | 1 + 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index 4946e3433..d3d058c53 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -62,6 +62,7 @@ class Site { $feed_contacts = ((x($_POST,'feed_contacts')) ? intval($_POST['feed_contacts']) : 0); $verify_email = ((x($_POST,'verify_email')) ? 1 : 0); $techlevel_lock = ((x($_POST,'techlock')) ? intval($_POST['techlock']) : 0); + $imagick_path = ((x($_POST,'imagick_path')) ? trim($_POST['imagick_path']) : ''); $techlevel = null; if(array_key_exists('techlevel', $_POST)) @@ -82,6 +83,7 @@ class Site { set_config('system', 'reply_address', $reply_address); set_config('system', 'from_email', $from_email); set_config('system', 'from_email_name' , $from_email_name); + set_config('system', 'imagick_convert_path' , $imagick_path); set_config('system', 'techlevel_lock', $techlevel_lock); @@ -317,6 +319,7 @@ class Site { '$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(get_config('system','delivery_interval'))?get_config('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")), '$delivery_batch_count' => array('delivery_batch_count', t('Deliveries per process'),(x(get_config('system','delivery_batch_count'))?get_config('system','delivery_batch_count'):1), t("Number of deliveries to attempt in a single operating system process. Adjust if necessary to tune system performance. Recommend: 1-5.")), '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")), + '$imagick_path' => array('imagick_path', t("Path to ImageMagick convert program"), get_config('system','imagick_convert_path'), t("If set, use this program to generate photo thumbnails for huge images ( > 4000 pixels in either dimension), otherwise memory exhaustion may occur. Example: /usr/bin/convert")), '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")), '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported (grid/network) content'), intval(get_config('system','default_expire_days')), t('0 for no expiration of imported content')), '$form_security_token' => get_form_security_token("admin_site"), diff --git a/include/photos.php b/include/photos.php index c7c8fc0a4..5de68f162 100644 --- a/include/photos.php +++ b/include/photos.php @@ -66,7 +66,19 @@ function photo_upload($channel, $observer, $args) { $os_storage = 0; if($args['os_syspath'] && $args['getimagesize']) { - $imagedata = @file_get_contents($args['os_syspath']); + if($args['getimagesize'][0] > 1600 || $args['getimagesize'][1] > 1600) { + $imagick_path = get_config('system','imagick_convert_path'); + if($imagick_path && @file_exists($imagick_path)) { + $tmp_name = $args['os_syspath'] . '-001'; + $newsize = photo_calculate_1600_scale($args['getimagesize']); + exec($imagick_path . ' ' . $args['os_syspath'] . ' -resize ' . $newsize . '^ ' . $tmp_name); + $imagedata = @file_get_contents($tmp_name); + @unlink($tmp_name); + } + } + else { + $imagedata = @file_get_contents($args['os_syspath']); + } $filename = $args['filename']; $filesize = strlen($imagedata); // this is going to be deleted if it exists @@ -122,7 +134,6 @@ function photo_upload($channel, $observer, $args) { } logger('photo_upload: loading the contents of ' . $src , LOGGER_DEBUG); - $imagedata = @file_get_contents($src); } @@ -428,6 +439,70 @@ function photo_upload($channel, $observer, $args) { return $ret; } + +function photo_calculate_1600_scale($arr) { + + $max = 1600; + $width = $arr[0]; + $height = $arr[1]; + + $dest_width = $dest_height = 0; + + if((! $width)|| (! $height)) + return FALSE; + + if($width > $max && $height > $max) { + + // very tall image (greater than 16:9) + // constrain the width - let the height float. + + if((($height * 9) / 16) > $width) { + $dest_width = $max; + $dest_height = intval(( $height * $max ) / $width); + } + + // else constrain both dimensions + + elseif($width > $height) { + $dest_width = $max; + $dest_height = intval(( $height * $max ) / $width); + } + else { + $dest_width = intval(( $width * $max ) / $height); + $dest_height = $max; + } + } + else { + if( $width > $max ) { + $dest_width = $max; + $dest_height = intval(( $height * $max ) / $width); + } + else { + if( $height > $max ) { + // very tall image (greater than 16:9) + // but width is OK - don't do anything + + if((($height * 9) / 16) > $width) { + $dest_width = $width; + $dest_height = $height; + } + else { + $dest_width = intval(( $width * $max ) / $height); + $dest_height = $max; + } + } + else { + $dest_width = $width; + $dest_height = $height; + } + } + } + + return $dest_width . 'x' . $dest_height; + +} + + /** * @brief Returns a list with all photo albums observer is allowed to see. * diff --git a/view/tpl/admin_site.tpl b/view/tpl/admin_site.tpl index e995f82b2..d6ff34f93 100755 --- a/view/tpl/admin_site.tpl +++ b/view/tpl/admin_site.tpl @@ -82,6 +82,7 @@

{{$advanced}}

+ {{include file="field_input.tpl" field=$imagick_path}} {{include file="field_input.tpl" field=$proxy}} {{include file="field_input.tpl" field=$proxyuser}} {{include file="field_input.tpl" field=$timeout}} From 9dcbef4cb16bc2ac3c669832a8fbb2a583e48130 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 1 Oct 2017 18:22:55 -0700 Subject: [PATCH 02/13] profile photo propagation issue if the local xchan_photo_[l|m|s] fields were changed from the /photo/profile/l/n form to photo/[hash] form by a clone operation. --- Zotlabs/Module/Profile_photo.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php index 47b627015..27e6bc445 100644 --- a/Zotlabs/Module/Profile_photo.php +++ b/Zotlabs/Module/Profile_photo.php @@ -158,6 +158,9 @@ class Profile_photo extends \Zotlabs\Web\Controller { intval(local_channel()) ); + + + send_profile_photo_activity($channel,$base_image,$profile); } @@ -174,12 +177,17 @@ class Profile_photo extends \Zotlabs\Web\Controller { // We'll set the updated profile-photo timestamp even if it isn't the default profile, // so that browsers will do a cache update unconditionally + // Also set links back to site-specific profile photo url in case it was + // changed to a generic URL by a clone operation. Otherwise the new photo may + // not get pushed to other sites correctly. - - $r = q("UPDATE xchan set xchan_photo_mimetype = '%s', xchan_photo_date = '%s' + $r = q("UPDATE xchan set xchan_photo_mimetype = '%s', xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s' where xchan_hash = '%s'", dbesc($im->getType()), dbesc(datetime_convert()), + dbesc(z_root() . '/photo/profile/l/' . $channel['channel_id']), + dbesc(z_root() . '/photo/profile/m/' . $channel['channel_id']), + dbesc(z_root() . '/photo/profile/s/' . $channel['channel_id']), dbesc($channel['xchan_hash']) ); From a3c2ef408408e44898caf15b3c0cfa1f634538b6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 2 Oct 2017 12:11:52 +0200 Subject: [PATCH 03/13] wiki: show save button and commit input field in all tabs if there is unsaved content. fix #853 --- view/tpl/wiki.tpl | 62 ++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl index 70a13806d..3047dbb80 100644 --- a/view/tpl/wiki.tpl +++ b/view/tpl/wiki.tpl @@ -1,7 +1,7 @@ -
+
- [{{$typename}}]  + [{{$typename}}]  {{if $showPageControls}} {{/if}} - {{if $showPageControls}} -
-
-
- -
- -
-
-
-
- {{/if}}
@@ -74,6 +62,16 @@
+ {{if $showPageControls}} + + {{/if}}
@@ -106,6 +104,7 @@ window.wiki_page_name = '{{$page}}'; window.wiki_page_content = '{{$content|escape:'javascript'}}'; window.wiki_page_commit = '{{$commit}}'; + window.saved = true; $("#generic-modal-ok-{{$wikiModalID}}").removeClass('btn-primary'); $("#generic-modal-ok-{{$wikiModalID}}").addClass('btn-danger'); @@ -174,10 +173,16 @@ adjustInlineEditorHeight(); } }, 500); // Return the focus to the editor allowing immediate text entry - $('#page-tools').show(); + $('#page-tools, #id_{{$commitMsg.0}}_wrapper').show(); }); $('#wiki-get-preview').click(function (ev) { + if(window.saved) { + $('#page-tools, #id_{{$commitMsg.0}}_wrapper').hide(); + } + else { + $('#page-tools').hide(); + } $.post("wiki/{{$channel_address}}/preview", { {{if !$mimeType || $mimeType == 'text/markdown'}} content: editor.getValue(), @@ -188,24 +193,28 @@ mimetype: '{{$mimeType}}' }, function (data) { - if (data.success) { - $('#wiki-preview').html(data.html); - {{if !$mimeType || $mimeType == 'text/markdown'}} - $("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"}); - {{/if}} - $('#page-tools').hide(); - } else { - window.console.log('Error previewing page.'); - } + if (data.success) { + $('#wiki-preview').html(data.html); + {{if !$mimeType || $mimeType == 'text/markdown'}} + $("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"}); + {{/if}} + } else { + window.console.log('Error previewing page.'); + } }, 'json'); ev.preventDefault(); }); $('#wiki-get-history').click(function (ev) { + if(window.saved) { + $('#page-tools, #id_{{$commitMsg.0}}_wrapper').hide(); + } + else { + $('#page-tools').hide(); + } $.post("wiki/{{$channel_address}}/history/page", {name: window.wiki_page_name, resource_id: window.wiki_resource_id}, function (data) { if (data.success) { $('#page-history-list').html(data.historyHTML); - $('#page-tools').hide(); } else { window.console.log('Error getting page history.'); } @@ -254,6 +263,7 @@ }, function (data) { if (data.success) { + window.saved = true; window.console.log('Page saved successfully.'); window.wiki_page_content = currentContent; $('#id_commitMsg').val(''); // Clear the commit message box @@ -446,6 +456,7 @@ {{if !$mimeType || $mimeType == 'text/markdown'}} $("#wiki-toc").toc({content: "#wiki-preview", headings: "h1,h2,h3,h4"}); window.editor.on("input", function() { + window.saved = false; if(window.editor.getSession().getUndoManager().isClean()) { $('#save-page').addClass('disabled'); } else { @@ -454,6 +465,7 @@ }); {{else}} window.editor.on("input", function() { + window.saved = false; $('#save-page').removeClass('disabled'); }); {{if $mimeType == 'text/bbcode'}} From 1f8b705a6a35545c281f5bf1d4a2c66404e58343 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 2 Oct 2017 12:16:53 +0200 Subject: [PATCH 04/13] whitespace --- view/tpl/wiki.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl index 3047dbb80..22480be5b 100644 --- a/view/tpl/wiki.tpl +++ b/view/tpl/wiki.tpl @@ -218,9 +218,9 @@ } else { window.console.log('Error getting page history.'); } - }, 'json'); - ev.preventDefault(); - }); + }, 'json'); + ev.preventDefault(); + }); function wiki_refresh_page_list() { if (window.wiki_resource_id === '') { From c200808fbb01c09d683860a6a65a4111ef1d3051 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 2 Oct 2017 12:54:25 +0200 Subject: [PATCH 05/13] fix community tags not preserved on post edit. issue #865 --- Zotlabs/Module/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 3e023ae8b..af504330a 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -694,7 +694,7 @@ class Item extends \Zotlabs\Web\Controller { foreach($t as $t1) { $post_tags[] = array( 'uid' => $profile_uid, - 'ttype' => $t1['type'], + 'ttype' => $t1['ttype'], 'otype' => TERM_OBJ_POST, 'term' => $t1['term'], 'url' => $t1['url'], From 5abdee73ee451eb1efd44f0d4a5c6697f36d25b0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 2 Oct 2017 16:26:33 -0700 Subject: [PATCH 06/13] Clone sync deletions to comments (which belong to you) on wall posts (which do not). --- Zotlabs/Module/Item.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 3e023ae8b..34e818578 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -1105,21 +1105,28 @@ class Item extends \Zotlabs\Web\Controller { // if this is a different page type or it's just a local delete // but not by the item author or owner, do a simple deletion - + + $complex = false; + if(intval($i[0]['item_type']) || ($local_delete && (! $can_delete))) { drop_item($i[0]['id']); } else { // complex deletion that needs to propagate and be performed in phases drop_item($i[0]['id'],true,DROPITEM_PHASE1); - $r = q("select * from item where id = %d", - intval($i[0]['id']) - ); - if($r) { - xchan_query($r); - $sync_item = fetch_post_tags($r); - build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true)))); - } + $complex = true; + } + + $r = q("select * from item where id = %d", + intval($i[0]['id']) + ); + if($r) { + xchan_query($r); + $sync_item = fetch_post_tags($r); + build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true)))); + } + + if($complex) { tag_deliver($i[0]['uid'],$i[0]['id']); } } From 9e24b28376f8274ad4a384d760aee62082eba496 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 2 Oct 2017 17:57:17 -0700 Subject: [PATCH 07/13] Hubzilla issue #866 allow navbar to be used when cover photo is displayed - also scroll cover photo on keyup event. --- view/tpl/cover_photo_widget.tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/view/tpl/cover_photo_widget.tpl b/view/tpl/cover_photo_widget.tpl index a9c384d2f..7404a740c 100755 --- a/view/tpl/cover_photo_widget.tpl +++ b/view/tpl/cover_photo_widget.tpl @@ -8,7 +8,8 @@ aside_padding_top = parseInt($('aside').css('padding-top')); section_padding_top = parseInt($('section').css('padding-top')); - $(document).on('click', slideUpCover); + $('#cover-photo').on('click', slideUpCover); + $('#cover-photo').on('keyup', slideUpCover); if($('#cover-photo').length && $(window).width() > 755) { if($(window).scrollTop() < $('#cover-photo').height()) { From 40e747ecde0e849efc85ddc33f40dce7061dec7b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 2 Oct 2017 18:46:24 -0700 Subject: [PATCH 08/13] remove server role selection details from install documentation, no longer needed --- install/INSTALL.txt | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/install/INSTALL.txt b/install/INSTALL.txt index 754504a33..88269f032 100644 --- a/install/INSTALL.txt +++ b/install/INSTALL.txt @@ -7,14 +7,14 @@ such as XAMPP and WAMP are not officially supported at this time - however we welcome patches if you manage to get it working. Be aware that this software is more than a simple web application. It is a -complex communications system which more closely resembles an email server -than a web server. For reliability and performance, messages are delivered in -the background and are queued for later delivery when sites are down. This -kind of functionality requires a bit more of the host system than the typical -blog. Not every PHP/MySQL hosting provider will be able to support the -Hubzilla. Many will - but please review the requirements and confirm these -with your hosting provider prior to installation. (And preferably before -entering into a long-term contract.) +complex communications and content management system which more closely +resembles an email server than a web server. For reliability and performance, +messages are delivered in the background and are queued for later delivery +when sites are down. This kind of functionality requires a bit more of the +host system than the typical blog. Not every PHP/MySQL hosting provider will +be able to support Hubzilla. Many will - but please review the requirements +and confirm these with your hosting provider prior to installation. (And +preferably before entering into a long-term contract.) If you encounter installation issues, please let us know via the Github issue tracker where you downloaded the software. Please be as clear as @@ -75,27 +75,6 @@ location may prevent some of these services from working correctly. This should not be a problem with Apache, but may be an issue with nginx or other web server platforms. -**Server Roles** - -During installation you will be asked to choose a server role. Your choices are -1. Basic -2. Standard -3. Pro - -Basic is highly simplified, with almost all the advanced functionality and -complexity removed or permanently disabled. - -Standard is typically used for federated network use, when you wish to interact -with other networks using other protocols. Not all the built in features and -functionality work correctly when other networks are involved. All advanced -and complex features are available to all members by default. - -Pro is for sites that wish to make full use of the built-in abilities and -features, but **not** to interact with other networks. Advanced features are -enabled according to a per-account 'techlevel' which reduces complexity -initially and allows members to adjust the software complexity to match their -technical abilities. - **Installation** 1. Requirements @@ -173,7 +152,8 @@ technical abilities. cd mywebsite util/update_addon_repo hzaddons - - Create searchable representations of the online documentation. You may do this any time + - Once the software is configured and the database installed, create searchable + representations of the online documentation. You may do this any time that the documentation is updated. cd mywebsite From f571b753b6af5c92afe86d55b814fb6e8d57ba17 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 2 Oct 2017 20:27:04 -0700 Subject: [PATCH 09/13] import: special handling required for channel photo in the xchan record when not seizing 'primary' --- Zotlabs/Module/Import.php | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 40ce8f6d1..2b16ff4e1 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -278,20 +278,31 @@ class Import extends \Zotlabs\Web\Controller { create_table_from_array('xchan',$xchan); require_once('include/photo/photo_driver.php'); - $photos = import_xchan_photo($xchan['xchan_photo_l'],$xchan['xchan_hash']); - if($photos[4]) - $photodate = NULL_DATE; - else - $photodate = $xchan['xchan_photo_date']; - $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s', xchan_photo_date = '%s' where xchan_hash = '%s'", - dbesc($photos[0]), - dbesc($photos[1]), - dbesc($photos[2]), - dbesc($photos[3]), - dbesc($photodate), - dbesc($xchan['xchan_hash']) - ); + if($xchan['xchan_hash'] === $channel['channel_hash']) { + $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s' where xchan_hash = '%s'", + dbesc(z_root() . '/photo/profile/l/' . $channel['channel_id']), + dbesc(z_root() . '/photo/profile/m/' . $channel['channel_id']), + dbesc(z_root() . '/photo/profile/s/' . $channel['channel_id']), + dbesc($xchan['xchan_hash']) + ); + } + else { + $photos = import_xchan_photo($xchan['xchan_photo_l'],$xchan['xchan_hash']); + if($photos[4]) + $photodate = NULL_DATE; + else + $photodate = $xchan['xchan_photo_date']; + + $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s', xchan_photo_date = '%s' where xchan_hash = '%s'", + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + dbesc($photos[3]), + dbesc($photodate), + dbesc($xchan['xchan_hash']) + ); + } } logger('import step 7'); From 66511d8f078cebdbad34bf1b40097159c2335bf4 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 3 Oct 2017 10:53:08 +0200 Subject: [PATCH 10/13] move common connections widget to left aside --- include/contact_widgets.php | 8 +++---- view/pdl/mod_channel.pdl | 5 +---- view/tpl/remote_friends_common.tpl | 36 ++++++++++-------------------- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/include/contact_widgets.php b/include/contact_widgets.php index e5bb696f8..a13f87573 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -143,7 +143,7 @@ function cardcategories_widget($baseurl,$selected = '') { -function common_friends_visitor_widget($profile_uid,$cnt = 10) { +function common_friends_visitor_widget($profile_uid,$cnt = 25) { if(local_channel() == $profile_uid) return; @@ -161,14 +161,14 @@ function common_friends_visitor_widget($profile_uid,$cnt = 10) { return; $r = common_friends($profile_uid,$observer_hash,0,$cnt,true); - + return replace_macros(get_markup_template('remote_friends_common.tpl'), array( - '$desc' => sprintf( t('Common connections: %d'), $t), + '$desc' => t('Common Connections'), '$base' => z_root(), '$uid' => $profile_uid, '$cid' => $observer, '$linkmore' => (($t > $cnt) ? 'true' : ''), - '$more' => t('show more'), + '$more' => sprintf( t('View all %d common connections'), $t), '$items' => $r )); diff --git a/view/pdl/mod_channel.pdl b/view/pdl/mod_channel.pdl index 967dd89b4..45ce31720 100644 --- a/view/pdl/mod_channel.pdl +++ b/view/pdl/mod_channel.pdl @@ -3,12 +3,9 @@ [/region] [region=aside] [widget=fullprofile][/widget] +[widget=common_friends][/widget] [widget=archive][var=wall]1[/var][/widget] [widget=categories][/widget] [widget=tagcloud_wall][var=limit]24[/var][/widget] [/region] -[region=content] -[widget=common_friends][/widget] -$content -[/region] diff --git a/view/tpl/remote_friends_common.tpl b/view/tpl/remote_friends_common.tpl index 7ec1a2e6b..9e149b574 100755 --- a/view/tpl/remote_friends_common.tpl +++ b/view/tpl/remote_friends_common.tpl @@ -1,28 +1,16 @@
-
- -
- {{if $items}} - {{foreach $items as $item}} -
-
- - {{$item.xchan_name}} - -
-
- -
-
- {{/foreach}} - {{/if}} -
- {{if $linkmore}}{{/if}} +

{{$desc}}

+ {{if $linkmore}} + {{$more}} + {{/if}} + {{if $items}} +
+ {{foreach $items as $item}} +
+ {{$item.xchan_name}}
+ {{/foreach}}
-
+ {{/if}} +
From fa93114804801bceabea06570e8eee602167600a Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 3 Oct 2017 11:37:45 +0200 Subject: [PATCH 11/13] some basic work on mod common --- Zotlabs/Module/Common.php | 31 +++++++++++++++---------------- view/tpl/common_friends.tpl | 24 +++++++++++++----------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Zotlabs/Module/Common.php b/Zotlabs/Module/Common.php index 2f3c57267..eebc56d2b 100644 --- a/Zotlabs/Module/Common.php +++ b/Zotlabs/Module/Common.php @@ -25,7 +25,7 @@ class Common extends \Zotlabs\Web\Controller { } - function get() { + function get() { $o = ''; @@ -34,38 +34,37 @@ class Common extends \Zotlabs\Web\Controller { $observer_hash = get_observer_hash(); - if(! perm_is_allowed(\App::$profile['profile_uid'],$observer_hash,'view_contacts')) { notice( t('Permission denied.') . EOL); return; } - $o .= '

' . t('Common connections') . '

'; - $t = count_common_friends(\App::$profile['profile_uid'],$observer_hash); if(! $t) { notice( t('No connections in common.') . EOL); - return $o; + return; } $r = common_friends(\App::$profile['profile_uid'],$observer_hash); if($r) { - - $tpl = get_markup_template('common_friends.tpl'); - foreach($r as $rr) { - $o .= replace_macros($tpl,array( - '$url' => $rr['xchan_url'], - '$name' => $rr['xchan_name'], - '$photo' => $rr['xchan_photo_m'], - '$tags' => '' - )); + $items[] = [ + 'url' => $rr['xchan_url'], + 'name' => $rr['xchan_name'], + 'photo' => $rr['xchan_photo_m'], + 'tags' => '' + ]; } - - $o .= cleardiv(); } + + $tpl = get_markup_template('common_friends.tpl'); + + $o = replace_macros($tpl, [ + '$title' => t('View Common Connections'), + '$items' => $items + ]); return $o; } diff --git a/view/tpl/common_friends.tpl b/view/tpl/common_friends.tpl index fa2cf5a13..b99075210 100755 --- a/view/tpl/common_friends.tpl +++ b/view/tpl/common_friends.tpl @@ -1,15 +1,17 @@
-
- - {{$name}} - +
+

{{$title}}

-
-
- {{$name}} +
+ {{foreach $items as $item}} +
+ + {{$item.name}} + +
+ {{$item.name}} +
+
+ {{/foreach}}
- {{if $note}} -
{{$note}}
- {{/if}} -
From 295ed07d40ea330ef438d9cad8fe3af8fd265507 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 4 Oct 2017 13:37:17 +0200 Subject: [PATCH 12/13] bring back notifications for account approvals --- Zotlabs/Module/Ping.php | 24 ++++++++++++++++++++++++ include/nav.php | 2 ++ view/js/main.js | 4 ++-- view/tpl/nav.tpl | 15 +++++++++++++-- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index 1a76f4f7b..66ab1a386 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -340,6 +340,30 @@ class Ping extends \Zotlabs\Web\Controller { killme(); } + if((argc() > 1 && (argv(1) === 'register')) && is_site_admin()) { + $result = array(); + + $r = q("SELECT account_email, account_created from account where (account_flags & %d) > 0", + intval(ACCOUNT_PENDING) + ); + if($r) { + foreach($r as $rr) { + $result[] = array( + 'notify_link' => z_root() . '/admin/accounts', + 'name' => $rr['account_email'], + 'url' => '', + 'photo' => get_default_profile_photo(48), + 'when' => relative_date($rr['account_created']), + 'hclass' => ('notify-unseen'), + 'message' => t('requires approval') + ); + } + } + logger('ping (register): ' . print_r($result, true), LOGGER_DATA); + echo json_encode(array('notify' => $result)); + killme(); + } + if(argc() > 1 && (argv(1) === 'all_events')) { $bd_format = t('g A l F d') ; // 8 AM Friday January 18 diff --git a/include/nav.php b/include/nav.php index 01decb2bf..eccb89764 100644 --- a/include/nav.php +++ b/include/nav.php @@ -180,6 +180,8 @@ EOT; $nav['intros'] = array('connections/ifpending', t('Connections'), "", t('Connections'),'connections_nav_btn'); + if(is_site_admin()) + $nav['registrations'] = array('admin/accounts', t('Registrations'), "", t('Registrations'),'registrations_nav_btn'); $nav['notifications'] = array('notifications/system', t('Notices'), "", t('Notifications'),'notifications_nav_btn'); diff --git a/view/js/main.js b/view/js/main.js index 73b2f3616..dc40db360 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -444,7 +444,7 @@ function NavUpdate() { updateCountsOnly = false; - if(data.network || data.home || data.intros || data.mail || data.all_events || data.notify || data.files || data.pubs) { + if(data.network || data.home || data.intros || data.register || data.mail || data.all_events || data.notify || data.files || data.pubs) { $('#notifications-btn').css('opacity', 1); } else { @@ -490,7 +490,7 @@ function NavUpdate() { if(data.notify == 0) { data.notify = ''; $('.notify-update, .notify-button').hide(); } else { $('.notify-update, .notify-button').show(); } $('.notify-update').html(data.notify); - if(data.register == 0) { data.register = ''; $('.register-update').removeClass('show'); } else { $('.register-update').addClass('show'); } + if(data.register == 0) { data.register = ''; $('.register-update, .register-button').hide(); } else { $('.register-update, .register-button').show(); } $('.register-update').html(data.register); if(data.events == 0) { data.events = ''; $('.events-update, .events-button').hide(); } else { $('.events-update, .events-button').show(); } diff --git a/view/tpl/nav.tpl b/view/tpl/nav.tpl index 72860aebe..0d0b0b600 100755 --- a/view/tpl/nav.tpl +++ b/view/tpl/nav.tpl @@ -128,7 +128,7 @@ {{/if}} {{if $nav.intros}}
{{/if}} + {{if $nav.registrations}} + + {{/if}} {{if $nav.notifications}}
{{/if}} + {{if $nav.files}} + + {{/if}} {{if $nav.login && !$userinfo}} {{/if}} - {{if $nav.files}} - - {{/if}} + {{if $nav.pubs}}