From f9e602c44cc75c1b0129c1f1f70a7879efc7ff01 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 30 Mar 2019 22:54:20 +0100 Subject: [PATCH 01/16] Add remove cover button --- view/tpl/cover_photo.tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/view/tpl/cover_photo.tpl b/view/tpl/cover_photo.tpl index 5a5bf2286..a1c4a922d 100755 --- a/view/tpl/cover_photo.tpl +++ b/view/tpl/cover_photo.tpl @@ -102,7 +102,8 @@

- + +
From 1ee91dd690f195f56afed7151d51730aa476e592 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 30 Mar 2019 22:55:36 +0100 Subject: [PATCH 02/16] Add remove cover photo processing --- Zotlabs/Module/Cover_photo.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index b911ac991..822cc8ef6 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -48,6 +48,16 @@ class Cover_photo extends \Zotlabs\Web\Controller { $channel = \App::get_channel(); check_form_security_token_redirectOnErr('/cover_photo', 'cover_photo'); + + // Remove cover photo + if(isset($_POST['remove'])) { + q("update photo set photo_usage = %d where photo_usage = %d and uid = %d", + intval(PHOTO_NORMAL), + intval(PHOTO_COVER), + intval(local_channel()) + ); + goaway(z_root() . '/cover_photo'); + } if((array_key_exists('cropfinal',$_POST)) && ($_POST['cropfinal'] == 1)) { From b384b275466655659c063253e82962c3fe524f6f Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 30 Mar 2019 23:05:37 +0100 Subject: [PATCH 03/16] Revert "Add submit button styling" This reverts commit 0b996245d5ef54d23e7b06307c2b0abac5988dce --- view/tpl/profile_photo.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/tpl/profile_photo.tpl b/view/tpl/profile_photo.tpl index 4b39d9d3f..819502df5 100755 --- a/view/tpl/profile_photo.tpl +++ b/view/tpl/profile_photo.tpl @@ -124,7 +124,7 @@ {{/if}}
- +
From 595429fdde770644ae1d7d265de308818e2d29ef Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 30 Mar 2019 23:08:41 +0100 Subject: [PATCH 04/16] Add submit button styling --- view/tpl/profile_photo.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/tpl/profile_photo.tpl b/view/tpl/profile_photo.tpl index 819502df5..b2190dda3 100755 --- a/view/tpl/profile_photo.tpl +++ b/view/tpl/profile_photo.tpl @@ -124,7 +124,7 @@ {{/if}}
- +
From c305dc8d226d1d8bded4951662f06416a77c57be Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 1 Apr 2019 12:55:36 +0200 Subject: [PATCH 05/16] missing string --- Zotlabs/Module/Cover_photo.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 822cc8ef6..224107922 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -403,6 +403,7 @@ logger('gis: ' . print_r($gis,true)); '$lbl_profiles' => t('Select a profile:'), '$title' => t('Change Cover Photo'), '$submit' => t('Upload'), + '$remove' => t('Remove'), '$profiles' => $profiles, '$embedPhotos' => t('Use a photo from your albums'), '$embedPhotosModalTitle' => t('Use a photo from your albums'), From 242aeea24cdcd920dff0ecb4657af319972793ec Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 1 Apr 2019 13:15:16 +0200 Subject: [PATCH 06/16] Add text to cover remove button --- Zotlabs/Module/Cover_photo.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 822cc8ef6..224107922 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -403,6 +403,7 @@ logger('gis: ' . print_r($gis,true)); '$lbl_profiles' => t('Select a profile:'), '$title' => t('Change Cover Photo'), '$submit' => t('Upload'), + '$remove' => t('Remove'), '$profiles' => $profiles, '$embedPhotos' => t('Use a photo from your albums'), '$embedPhotosModalTitle' => t('Use a photo from your albums'), From a0a2c27973d8b923c3597c611eb23a8a1b010a85 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 2 Apr 2019 14:55:03 +0200 Subject: [PATCH 07/16] Revert "suggestion widget using feature_enabled still - upgrade to use apps." This reverts commit b2bdc73164f7ede118febf823f729e57e7f4950f --- Zotlabs/Widget/Suggestions.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Zotlabs/Widget/Suggestions.php b/Zotlabs/Widget/Suggestions.php index b4f384e9d..5fb3d3e8b 100644 --- a/Zotlabs/Widget/Suggestions.php +++ b/Zotlabs/Widget/Suggestions.php @@ -2,8 +2,6 @@ namespace Zotlabs\Widget; -use Zotlabs\Lib\Apps; - require_once('include/socgraph.php'); @@ -11,9 +9,9 @@ class Suggestions { function widget($arr) { + if((! local_channel()) || (! feature_enabled(local_channel(),'suggest'))) + return ''; - if((! local_channel()) || (! Apps::system_app_installed(local_channel(), 'Suggest Channels'))) - return EMPTY_STR; $r = suggestion_query(local_channel(),get_observer_hash(),0,20); From 4346d7605d14d4795fc75bedd8517b32287d0c2b Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 2 Apr 2019 14:59:35 +0200 Subject: [PATCH 08/16] Revert "Revert "suggestion widget using feature_enabled still - upgrade to use apps."" This reverts commit a0a2c27973d8b923c3597c611eb23a8a1b010a85 --- Zotlabs/Widget/Suggestions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Widget/Suggestions.php b/Zotlabs/Widget/Suggestions.php index 5fb3d3e8b..b4f384e9d 100644 --- a/Zotlabs/Widget/Suggestions.php +++ b/Zotlabs/Widget/Suggestions.php @@ -2,6 +2,8 @@ namespace Zotlabs\Widget; +use Zotlabs\Lib\Apps; + require_once('include/socgraph.php'); @@ -9,9 +11,9 @@ class Suggestions { function widget($arr) { - if((! local_channel()) || (! feature_enabled(local_channel(),'suggest'))) - return ''; + if((! local_channel()) || (! Apps::system_app_installed(local_channel(), 'Suggest Channels'))) + return EMPTY_STR; $r = suggestion_query(local_channel(),get_observer_hash(),0,20); From c9f3883c8c9c75ae0da69d04e3fe2ab275a3fc04 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 2 Apr 2019 15:12:32 +0200 Subject: [PATCH 09/16] Remove suggest channels from features --- include/features.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/features.php b/include/features.php index 35a4c0dd4..d021f9394 100644 --- a/include/features.php +++ b/include/features.php @@ -360,14 +360,6 @@ function get_features($filtered = true, $level = (-1)) { get_config('feature_lock','personal_tab') ], - [ - 'suggest', - t('Suggest Channels'), - t('Show friend and connection suggestions'), - false, - get_config('feature_lock','suggest') - ], - [ 'network_list_mode', t('Use blog/list mode'), From 410f37df1b46cde052f0317c957221df6e6a61dd Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 3 Apr 2019 00:15:34 +0200 Subject: [PATCH 10/16] Fix sync cover photo for clonned channels --- Zotlabs/Module/Cover_photo.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 224107922..df321ddb6 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -208,7 +208,10 @@ logger('gis: ' . print_r($gis,true)); $channel = \App::get_channel(); $this->send_cover_photo_activity($channel,$base_image,$profile); - + + $sync = attach_export_data($channel,$base_image['resource_id']); + if($sync) + build_sync_packet($channel['channel_id'],array('file' => array($sync))); } else @@ -225,7 +228,7 @@ logger('gis: ' . print_r($gis,true)); require_once('include/attach.php'); - $res = attach_store(\App::get_channel(), get_observer_hash(), '', array('album' => t('Cover Photos'), 'hash' => $hash)); + $res = attach_store(\App::get_channel(), get_observer_hash(), '', array('album' => t('Cover Photos'), 'hash' => $hash, 'nosync' => true)); logger('attach_store: ' . print_r($res,true)); From e33604887bfc2671d933f425215d8c264dcbcab9 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 3 Apr 2019 12:05:22 +0200 Subject: [PATCH 11/16] Sync cover photo removal with clones --- Zotlabs/Module/Cover_photo.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index df321ddb6..89bfcc281 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -51,11 +51,23 @@ class Cover_photo extends \Zotlabs\Web\Controller { // Remove cover photo if(isset($_POST['remove'])) { + + $r = q("SELECT resource_id FROM photo WHERE photo_usage = %d AND uid = %d LIMIT 1", + intval(PHOTO_COVER), + intval(local_channel()) + ); + q("update photo set photo_usage = %d where photo_usage = %d and uid = %d", intval(PHOTO_NORMAL), intval(PHOTO_COVER), intval(local_channel()) ); + + if($r) { + $sync = attach_export_data($channel,$r[0]['resource_id']); + if($sync) + build_sync_packet($channel['channel_id'],array('file' => array($sync))); + } goaway(z_root() . '/cover_photo'); } @@ -205,8 +217,7 @@ logger('gis: ' . print_r($gis,true)); ); return; } - - $channel = \App::get_channel(); + $this->send_cover_photo_activity($channel,$base_image,$profile); $sync = attach_export_data($channel,$base_image['resource_id']); From 0c2db1cea593ea0f59d1cd3c918a5bccaf90c4c5 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 4 Apr 2019 11:00:19 +0200 Subject: [PATCH 12/16] Skip removal if no cover image found --- Zotlabs/Module/Cover_photo.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 89bfcc281..b67c00cdc 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -56,18 +56,19 @@ class Cover_photo extends \Zotlabs\Web\Controller { intval(PHOTO_COVER), intval(local_channel()) ); - - q("update photo set photo_usage = %d where photo_usage = %d and uid = %d", - intval(PHOTO_NORMAL), - intval(PHOTO_COVER), - intval(local_channel()) - ); if($r) { + q("update photo set photo_usage = %d where photo_usage = %d and uid = %d", + intval(PHOTO_NORMAL), + intval(PHOTO_COVER), + intval(local_channel()) + ); + $sync = attach_export_data($channel,$r[0]['resource_id']); if($sync) build_sync_packet($channel['channel_id'],array('file' => array($sync))); } + goaway(z_root() . '/cover_photo'); } From e20c5cf9cf56eaf6af23676996fa8a1d63208899 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 5 Apr 2019 14:10:48 +0200 Subject: [PATCH 13/16] Prevent return wrong profile photo modification date by plugin --- Zotlabs/Module/Photo.php | 44 +++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 96a4e1f40..c31e63262 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -71,29 +71,31 @@ class Photo extends \Zotlabs\Web\Controller { $modified = filemtime($default); $default = z_root() . '/' . $default; $uid = $person; + + $data = ''; - $d = [ 'imgscale' => $resolution, 'channel_id' => $uid, 'default' => $default, 'data' => '', 'mimetype' => '' ]; - call_hooks('get_profile_photo',$d); - - $resolution = $d['imgscale']; - $uid = $d['channel_id']; - $default = $d['default']; - $data = $d['data']; - $mimetype = $d['mimetype']; - + $r = q("SELECT * FROM photo WHERE imgscale = %d AND uid = %d AND photo_usage = %d LIMIT 1", + intval($resolution), + intval($uid), + intval(PHOTO_PROFILE) + ); + if($r) { + $modified = strtotime($r[0]['edited'] . "Z"); + $data = dbunescbin($r[0]['content']); + $mimetype = $r[0]['mimetype']; + } + if(intval($r[0]['os_storage'])) + $data = file_get_contents($data); + if(! $data) { - $r = q("SELECT * FROM photo WHERE imgscale = %d AND uid = %d AND photo_usage = %d LIMIT 1", - intval($resolution), - intval($uid), - intval(PHOTO_PROFILE) - ); - if($r) { - $modified = strtotime($r[0]['edited'] . "Z"); - $data = dbunescbin($r[0]['content']); - $mimetype = $r[0]['mimetype']; - } - if(intval($r[0]['os_storage'])) - $data = file_get_contents($data); + $d = [ 'imgscale' => $resolution, 'channel_id' => $uid, 'default' => $default, 'data' => '', 'mimetype' => '' ]; + call_hooks('get_profile_photo',$d); + + $resolution = $d['imgscale']; + $uid = $d['channel_id']; + $default = $d['default']; + $data = $d['data']; + $mimetype = $d['mimetype']; } if(! $data) { From bd95c7b82afee463ffc1e2687f234df1d05e57f7 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 5 Apr 2019 14:15:40 +0200 Subject: [PATCH 14/16] Update Photo.php --- Zotlabs/Module/Photo.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index c31e63262..f397b952f 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -82,10 +82,11 @@ class Photo extends \Zotlabs\Web\Controller { if($r) { $modified = strtotime($r[0]['edited'] . "Z"); $data = dbunescbin($r[0]['content']); - $mimetype = $r[0]['mimetype']; + if(intval($r[0]['os_storage'])) + $data = file_get_contents($data); + else + $data = dbunescbin($r[0]['content']); } - if(intval($r[0]['os_storage'])) - $data = file_get_contents($data); if(! $data) { $d = [ 'imgscale' => $resolution, 'channel_id' => $uid, 'default' => $default, 'data' => '', 'mimetype' => '' ]; From ea4b4ddce46601ccd8adbb5ce5e127730f4b1e29 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 5 Apr 2019 14:17:39 +0200 Subject: [PATCH 15/16] Update Photo.php --- Zotlabs/Module/Photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index f397b952f..5a926ca6f 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -81,7 +81,7 @@ class Photo extends \Zotlabs\Web\Controller { ); if($r) { $modified = strtotime($r[0]['edited'] . "Z"); - $data = dbunescbin($r[0]['content']); + $mimetype = $r[0]['mimetype']; if(intval($r[0]['os_storage'])) $data = file_get_contents($data); else From 8e0b9b82e9e6791d264703e5b823f8cbd5504dff Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 5 Apr 2019 14:21:05 +0200 Subject: [PATCH 16/16] Update Photo.php --- Zotlabs/Module/Photo.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 5a926ca6f..6912322aa 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -80,12 +80,12 @@ class Photo extends \Zotlabs\Web\Controller { intval(PHOTO_PROFILE) ); if($r) { - $modified = strtotime($r[0]['edited'] . "Z"); - $mimetype = $r[0]['mimetype']; + $modified = strtotime($r[0]['edited'] . "Z"); + $mimetype = $r[0]['mimetype']; if(intval($r[0]['os_storage'])) - $data = file_get_contents($data); - else - $data = dbunescbin($r[0]['content']); + $data = file_get_contents($data); + else + $data = dbunescbin($r[0]['content']); } if(! $data) {