From 20fbf670db15809fd01b155773aab38e6298f670 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 30 Dec 2015 00:26:50 +0100 Subject: [PATCH 1/8] photo aside widget for profile page --- include/features.php | 6 ++ include/photos.php | 142 +++++++++++++++++++++++++++++ mod/photos.php | 66 ++------------ mod/profile.php | 4 + view/global.css | 15 +++ view/templates/widget_photos.tpl | 18 ++++ view/theme/duepuntozero/style.css | 13 ++- view/theme/frost-mobile/style.css | 15 ++- view/theme/frost/style.css | 19 +++- view/theme/quattro/dark/style.css | 5 +- view/theme/quattro/green/style.css | 5 +- view/theme/quattro/lilac/style.css | 11 ++- view/theme/quattro/quattro.less | 1 + view/theme/smoothly/style.css | 9 ++ view/theme/vier/style.css | 6 ++ 15 files changed, 263 insertions(+), 72 deletions(-) create mode 100644 view/templates/widget_photos.tpl diff --git a/include/features.php b/include/features.php index 2639604576..8b3ad5d3f6 100644 --- a/include/features.php +++ b/include/features.php @@ -79,6 +79,12 @@ function get_features() { array('savedsearch', t('Saved Searches'), t('Save search terms for re-use'),false), ), + // Profile sidebar widgets + 'profile-widgets' => array( + t('Profile Sidebar Widgets'), + array('photos_widget', t('Show last Photos'), t('Show your last Photos on the Profile Page Sidebar'),false), + ), + // Network tabs 'net_tabs' => array( t('Network Tabs'), diff --git a/include/photos.php b/include/photos.php index 93a565b511..fed4ab10c1 100644 --- a/include/photos.php +++ b/include/photos.php @@ -4,6 +4,148 @@ * @brief Functions related to photo handling. */ + +/** + * @brief Get the permissions for the photos page + * + * @param int $owner_uid Owner of the photos page + * @param bool $community_page If it's an forum account + * + * @return array + *......'can_post' + *......'visitor' + *......'contact' + * 'remote_contact' + * .....'contact_id' + * 'groups' + */ +function photos_permissions($owner_uid, $community_page = 0) { + + $arr = array(); + + if((local_user()) && (local_user() == $owner_uid)) + $arr['can_post'] = true; + else { + if($community_page && remote_user()) { + if(is_array($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $v) { + if($v['uid'] == $owner_uid) { + $arr['contact_id'] = $v['cid']; + break; + } + } + } + if($arr['contact_id']) { + + $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", + intval($arr['contact_id']), + intval($owner_uid) + ); + if(count($r)) { + $arr['can_post'] = true; + $arr['contact'] = $r[0]; + $arr['remote_contact'] = true; + $arr['visitor'] = $cid; + } + } + } + } + + // perhaps they're visiting - but not a community page, so they wouldn't have write access + + if(remote_user() && (! $arr['visitor'])) { + $arr['contact_id'] = 0; + if(is_array($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $v) { + if($v['uid'] == $owner_uid) { + $arr['contact_id'] = $v['cid']; + break; + } + } + } + if($arr['contact_id']) { + $arr['groups'] = init_groups_visitor($arr['contact_id']); + $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", + intval($arr['contact_id']), + intval($owner_uid) + ); + if(count($r)) { + $arr['contact'] = $r[0]; + $arr['remote_contact'] = true; + } + } + } + + if(! $arr['remote_contact']) { + if(local_user()) { + $arr['contact_id'] = $_SESSION['cid']; + $arr['contact'] = $a->contact; + } + } + + return $arr; +} + +/** + * @brief Construnct a widget with last uploaded photos + * + * It displays the last 9 photos + * + * @param array $profile_data + *......'profile_uid'...=> The user.id of the profile (owner of the hotos) + *......'nickname'......=> Nick of the owner of the profile + *......'page-flags'....=> Account type of the profile + * + * @return string + *......formatted html + * + * @template widget_photos.tpl + */ +function widget_photos($profile_data) { + + $community_page = (($profile_data['page-flags'] == PAGE_COMMUNITY) ? true : false); + $nickname = $profile_data['nickname']; + $owner_id = $profile_data['profile_uid']; + + $phototypes = Photo::supportedTypes(); + $photos_perms = photos_permissions($owner_id, $community_page); + + $sql_extra = permissions_sql($owner_id, $photos_perms['remote_contact'], $photos_perms['groups']); + + $r = q("SELECT `resource-id`, `id`, `filename`, `type`, max(`scale`) AS `scale` FROM `photo` + WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' AND `album` != '%s' + $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT 9", + intval($owner_id), + dbesc('Contact Photos'), + dbesc( t('Contact Photos')), + dbesc( t('Profile Photos')) + ); + + $photos = array(); + if(count($r)) { + foreach($r as $rr) { + $ext = $phototypes[$rr['type']]; + + $photos[] = array( + 'id' => $rr['id'], + 'src' => z_root() . '/photos/' . $nickname . '/image/' . $rr['resource-id'], + 'photo' => z_root() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext, + 'alt_text' => $rr['filename'], + ); + } + + $tpl = get_markup_template('widget_photos.tpl'); + $o .= replace_macros($tpl, array( + '$title' => t('Photos'), + '$photos' => $photos, + '$photo_albums_page' => z_root() . '/photos/' . $nickname, + '$photo_albums_page_title' => t('Vist the Photo Albums'), + )); + + return $o; + } +} + function getGps($exifCoord, $hemi) { $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0; $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0; diff --git a/mod/photos.php b/mod/photos.php index a9dade6a81..cd2026c252 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1023,63 +1023,13 @@ function photos_content(&$a) { $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false); - if((local_user()) && (local_user() == $owner_uid)) - $can_post = true; - else { - if($community_page && remote_user()) { - if(is_array($_SESSION['remote'])) { - foreach($_SESSION['remote'] as $v) { - if($v['uid'] == $owner_uid) { - $contact_id = $v['cid']; - break; - } - } - } - if($contact_id) { + // get the access rights for photos + $photos_perms = photos_permissions($owner_uid, $community_page); - $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval($owner_uid) - ); - if(count($r)) { - $can_post = true; - $contact = $r[0]; - $remote_contact = true; - $visitor = $cid; - } - } - } - } - - // perhaps they're visiting - but not a community page, so they wouldn't have write access - - if(remote_user() && (! $visitor)) { - $contact_id = 0; - if(is_array($_SESSION['remote'])) { - foreach($_SESSION['remote'] as $v) { - if($v['uid'] == $owner_uid) { - $contact_id = $v['cid']; - break; - } - } - } - if($contact_id) { - $groups = init_groups_visitor($contact_id); - $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval($owner_uid) - ); - if(count($r)) { - $contact = $r[0]; - $remote_contact = true; - } - } - } - - if(! $remote_contact) { - if(local_user()) { - $contact_id = $_SESSION['cid']; - $contact = $a->contact; + // convert keys of the $photo_persms array into variables + if(count($photos_perms)) { + foreach ($photos_perms as $key => $value) { + ${$key} = $value; } } @@ -1088,7 +1038,7 @@ function photos_content(&$a) { return; } - $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups); + $sql_extra = permissions_sql($owner_uid, $remote_contact, $groups); $o = ""; @@ -1842,7 +1792,7 @@ function photos_content(&$a) { $a->set_pager_itemspage(20); } - $r = q("SELECT `resource-id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo` + $r = q("SELECT `resource-id`, `id`, `filename`, `type`, `album`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d", intval($a->data['user']['uid']), diff --git a/mod/profile.php b/mod/profile.php index 26bd395230..0913573a83 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -181,6 +181,10 @@ function profile_content(&$a, $update = 0) { $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false); $commvisitor = (($commpage && $remote_contact == true) ? true : false); + if(feature_enabled($a->profile['profile_uid'],'photos_widget')) { + require_once('include/photos.php'); + $a->page['aside'] .= widget_photos($a->profile); + } $a->page['aside'] .= posted_date_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true); $a->page['aside'] .= categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : '')); diff --git a/view/global.css b/view/global.css index 05940508ca..09168a52bd 100644 --- a/view/global.css +++ b/view/global.css @@ -321,3 +321,18 @@ ul.credits li { .p-addr { clear: both; } + +.widget-photo { + float: left; +} + +.widget-photo-link { + margin: 0 2px 2px 0; +} + +img.widget-photo-img { + width: 48px; + height: 48px; + object-fit: cover; + padding-right: 2px; +} diff --git a/view/templates/widget_photos.tpl b/view/templates/widget_photos.tpl new file mode 100644 index 0000000000..1e56c8df16 --- /dev/null +++ b/view/templates/widget_photos.tpl @@ -0,0 +1,18 @@ + + \ No newline at end of file diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index c004eb53d0..bfffeb2503 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -140,12 +140,12 @@ nav #banner #logo-text a:hover { text-decoration: none; } .nav-commlink, .nav-login-link { - display: block; - height: 15px; + display: block; + height: 15px; margin-top: 67px; margin-right: 2px; - //padding: 6px 10px; - padding: 6px 3px; + /* padding: 6px 10px; */ + padding: 6px 3px; float: left; bottom: 140px; border: 1px solid #babdb6; @@ -244,7 +244,7 @@ section { display:block; float:left; padding: 0.4em; - //margin-right: 1em; + /*margin-right: 1em; */ margin-right: 3px ; } .tab.active { @@ -2164,6 +2164,9 @@ aside input[type='text'] { } +.widget h3 a { + color: #000000; +} /*.photos { height: auto; diff --git a/view/theme/frost-mobile/style.css b/view/theme/frost-mobile/style.css index 400b23c10b..94e5120c01 100644 --- a/view/theme/frost-mobile/style.css +++ b/view/theme/frost-mobile/style.css @@ -2541,6 +2541,14 @@ a.mail-list-link { margin: 10px 0 10px; } +.widget-photo { + float: left; +} + +.widget-photo-link { + margin: 0 2px 2px 0; +} + #sidebar-group-list ul { list-style-type: none; } @@ -2626,12 +2634,15 @@ aside input[type='text'] { -webkit-border-radius:5px; border-radius:5px; } + +.widget h3 a { + color: #505050; +} + .widget.settings-widget { padding: 0; } - - /*.photos { height: auto; overflow: auto; diff --git a/view/theme/frost/style.css b/view/theme/frost/style.css index 3dd400c76b..3adf91ad67 100644 --- a/view/theme/frost/style.css +++ b/view/theme/frost/style.css @@ -2356,6 +2356,21 @@ a.mail-list-link { margin: 10px 0 10px; } +.widget-photo { + float: left; +} + +.widget-photo-link { + margin: 0 2px 2px 0; +} + +img.widget-photo-img { + width: 48px; + height: 48px; + object-fit: cover; + padding-right: 2px; +} + #sidebar-group-list ul { list-style-type: none; } @@ -2446,9 +2461,11 @@ aside input[type='text'] { -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; - } +.widget h3 a { + color: #505050; +} /*.photos { height: auto; diff --git a/view/theme/quattro/dark/style.css b/view/theme/quattro/dark/style.css index 847017ee5b..ebb9977416 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; @@ -1007,6 +1007,9 @@ aside .posted-date-selector-months { padding: 0; margin: 2px; } +.widget h3 a { + color: #2d2d2d; +} .widget .action { opacity: 0.1; -webkit-transition: all 0.2s ease-in-out; diff --git a/view/theme/quattro/green/style.css b/view/theme/quattro/green/style.css index 4cfcb59273..5c2661e919 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; @@ -1007,6 +1007,9 @@ aside .posted-date-selector-months { padding: 0; margin: 2px; } +.widget h3 a { + color: #2d2d2d; +} .widget .action { opacity: 0.1; -webkit-transition: all 0.2s ease-in-out; diff --git a/view/theme/quattro/lilac/style.css b/view/theme/quattro/lilac/style.css index 2ff7cfcb0c..32f1ccaf6a 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 0 0 0; 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; @@ -1007,6 +1007,9 @@ aside .posted-date-selector-months { padding: 0; margin: 2px; } +.widget h3 a { + color: #2d2d2d; +} .widget .action { opacity: 0.1; -webkit-transition: all 0.2s ease-in-out; @@ -1753,7 +1756,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; @@ -1780,7 +1783,7 @@ span[id^="showmore-wrap"] { margin: 0; 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 681cfcc374..8822fc3ded 100644 --- a/view/theme/quattro/quattro.less +++ b/view/theme/quattro/quattro.less @@ -454,6 +454,7 @@ aside { margin-bottom: 2em; h3 { padding: 0; margin: 2px;} + h3 a { color: @BodyColor; } .action { .opaque(0.1); } input.action { .opaque(0.5); } &:hover .title .action { .opaque(1); } diff --git a/view/theme/smoothly/style.css b/view/theme/smoothly/style.css index b9f094932d..5123307493 100644 --- a/view/theme/smoothly/style.css +++ b/view/theme/smoothly/style.css @@ -1019,6 +1019,15 @@ ul .sidebar-group-li .icon { text-shadow: -1px 0px 0px #bdbdbd; } +.widget h3 a { + color: #626262; +} + +.widget h3 a:hover, .widget h3 a:focus { + color: #6da6c4; + text-decoration: none; +} + #connect-desc { margin-left: 10px; } diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index e53ac45f74..df503e273a 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -1141,6 +1141,12 @@ aside h4, right_aside h4 { padding: 0px; margin: 2px; } +.widget h3 a { + color: #737373; +} +.widget h3 a:hover { + color: black; +} .widget .action { opacity: 0.1; -webkit-transition: all 0.2s ease-in-out; From 3366e530cdd6ae2a7433a19a27dbe85bedabaea9 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 30 Dec 2015 00:37:24 +0100 Subject: [PATCH 2/8] photo aside widget: little polish --- include/features.php | 2 +- include/photos.php | 2 +- view/templates/widget_photos.tpl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/features.php b/include/features.php index 8b3ad5d3f6..7dceaa4bc0 100644 --- a/include/features.php +++ b/include/features.php @@ -82,7 +82,7 @@ function get_features() { // Profile sidebar widgets 'profile-widgets' => array( t('Profile Sidebar Widgets'), - array('photos_widget', t('Show last Photos'), t('Show your last Photos on the Profile Page Sidebar'),false), + array('photos_widget', t('Show last Photos'), t('Show your last Photos in the Profile Page Sidebar'),false), ), // Network tabs diff --git a/include/photos.php b/include/photos.php index fed4ab10c1..3c40f11f8a 100644 --- a/include/photos.php +++ b/include/photos.php @@ -92,7 +92,7 @@ function photos_permissions($owner_uid, $community_page = 0) { * It displays the last 9 photos * * @param array $profile_data - *......'profile_uid'...=> The user.id of the profile (owner of the hotos) + *......'profile_uid'...=> The user.id of the profile (owner of the photos) *......'nickname'......=> Nick of the owner of the profile *......'page-flags'....=> Account type of the profile * diff --git a/view/templates/widget_photos.tpl b/view/templates/widget_photos.tpl index 1e56c8df16..abd403a172 100644 --- a/view/templates/widget_photos.tpl +++ b/view/templates/widget_photos.tpl @@ -15,4 +15,4 @@
- \ No newline at end of file + From 1ab022f4df94f4526e88cb20703dda64bd60c889 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sun, 3 Jan 2016 15:45:02 +0100 Subject: [PATCH 3/8] photos aside widget: move dependencies to the header --- mod/profile.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mod/profile.php b/mod/profile.php index 0913573a83..83e3e37958 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -1,6 +1,7 @@ argc > 1) $which = $a->argv[1]; else { - $r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1"); + $r = q("SELECT `nickname` FROM `user` WHERE `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 ORDER BY RAND() LIMIT 1"); if(count($r)) { goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']); } @@ -181,10 +182,9 @@ function profile_content(&$a, $update = 0) { $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false); $commvisitor = (($commpage && $remote_contact == true) ? true : false); - if(feature_enabled($a->profile['profile_uid'],'photos_widget')) { - require_once('include/photos.php'); + if(feature_enabled($a->profile['profile_uid'],'photos_widget')) $a->page['aside'] .= widget_photos($a->profile); - } + $a->page['aside'] .= posted_date_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true); $a->page['aside'] .= categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : '')); @@ -225,9 +225,9 @@ function profile_content(&$a, $update = 0) { FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND - (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' - OR item.verb = '" . ACTIVITY_DISLIKE . "' OR item.verb = '" . ACTIVITY_ATTEND . "' - OR item.verb = '" . ACTIVITY_ATTENDNO . "' OR item.verb = '" . ACTIVITY_ATTENDMAYBE . "') + (`item`.`deleted` = 0 OR `item`.`verb` = '" . ACTIVITY_LIKE ."' + OR `item`.`verb` = '" . ACTIVITY_DISLIKE . "' OR `item`.`verb` = '" . ACTIVITY_ATTEND . "' + OR `item`.`verb` = '" . ACTIVITY_ATTENDNO . "' OR `item`.`verb` = '" . ACTIVITY_ATTENDMAYBE . "') AND `item`.`moderated` = 0 and `item`.`unseen` = 1 AND `item`.`wall` = 1 $sql_extra From 29c671bb22b51f2ee703bfa3f662d4b1b6c6f4aa Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sun, 3 Jan 2016 16:09:05 +0100 Subject: [PATCH 4/8] photos aside widget:permissions cleanup --- mod/photos.php | 63 ++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index cd2026c252..1985875f18 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1013,11 +1013,11 @@ function photos_content(&$a) { // Setup permissions structures // - $can_post = false; - $visitor = 0; - $contact = null; - $remote_contact = false; - $contact_id = 0; + $photos_perms['can_post'] = false; + $photos_perms['visitor'] = 0; + $photos_perms['contact'] = null; + $photos_perms['remote_contact'] = false; + $photos_perms['contact_id'] = 0; $owner_uid = $a->data['user']['uid']; @@ -1026,19 +1026,12 @@ function photos_content(&$a) { // get the access rights for photos $photos_perms = photos_permissions($owner_uid, $community_page); - // convert keys of the $photo_persms array into variables - if(count($photos_perms)) { - foreach ($photos_perms as $key => $value) { - ${$key} = $value; - } - } - - if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) { + if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $photos_perms['remote_contact'])) { notice( t('Access to this item is restricted.') . EOL); return; } - $sql_extra = permissions_sql($owner_uid, $remote_contact, $groups); + $sql_extra = permissions_sql($owner_uid, $photos_perms['remote_contact'], $photos_perms['groups']); $o = ""; @@ -1051,7 +1044,7 @@ function photos_content(&$a) { */ if($datatype === 'upload') { - if(! ($can_post)) { + if(! ($photos_perms['can_post'])) { notice( t('Permission denied.')); return; } @@ -1121,11 +1114,11 @@ function photos_content(&$a) { if($a->theme['template_engine'] === 'internal') { $albumselect_e = template_escape($albumselect); - $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user))); + $aclselect_e = (($photos_perms['visitor']) ? '' : template_escape(populate_acl($a->user))); } else { $albumselect_e = $albumselect; - $aclselect_e = (($visitor) ? '' : populate_acl($a->user)); + $aclselect_e = (($photos_perms['visitor']) ? '' : populate_acl($a->user)); } $o .= replace_macros($tpl,array( @@ -1193,7 +1186,7 @@ function photos_content(&$a) { //edit album name if($cmd === 'edit') { if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { - if($can_post) { + if($photos_perms['can_post']) { $edit_tpl = get_markup_template('album_edit.tpl'); if($a->theme['template_engine'] === 'internal') { @@ -1216,7 +1209,7 @@ function photos_content(&$a) { } else { if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { - if($can_post) { + if($photos_perms['can_post']) { $edit = array(t('Edit Album'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit'); } } @@ -1266,7 +1259,7 @@ function photos_content(&$a) { $o .= replace_macros($tpl, array( '$photos' => $photos, '$album' => $album, - '$can_post' => $can_post, + '$can_post' => $photos_perms['can_post'], '$upload' => array(t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)), '$order' => $order, '$edit' => $edit @@ -1333,7 +1326,7 @@ function photos_content(&$a) { break; } } - $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : ''); + $edit_suffix = ((($cmd === 'edit') && ($photos_perms['can_post'])) ? '/edit' : ''); $prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); $nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); } @@ -1356,7 +1349,7 @@ function photos_content(&$a) { $tools = Null; $lock = Null; - if($can_post && ($ph[0]['uid'] == $owner_uid)) { + if($photos_perms['can_post'] && ($ph[0]['uid'] == $owner_uid)) { $tools = array( 'edit' => array($a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))), 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource-id'], t('Use as profile photo')), @@ -1479,7 +1472,7 @@ function photos_content(&$a) { $edit = Null; - if(($cmd === 'edit') && ($can_post)) { + if(($cmd === 'edit') && ($photos_perms['can_post'])) { $edit_tpl = get_markup_template('photo_edit.tpl'); // Private/public post links for the non-JS ACL form @@ -1551,7 +1544,7 @@ function photos_content(&$a) { $likebuttons = ''; - if($can_post || can_write_wall($a,$owner_uid)) { + if($photos_perms['can_post'] || can_write_wall($a,$owner_uid)) { $likebuttons = replace_macros($like_tpl,array( '$id' => $link_item['id'], '$likethis' => t("I like this \x28toggle\x29"), @@ -1564,7 +1557,7 @@ function photos_content(&$a) { $comments = ''; if(! count($r)) { - if($can_post || can_write_wall($a,$owner_uid)) { + if($photos_perms['can_post'] || can_write_wall($a,$owner_uid)) { if($link_item['last-child']) { $comments .= replace_macros($cmnt_tpl,array( '$return_path' => '', @@ -1573,9 +1566,9 @@ function photos_content(&$a) { '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, - '$mylink' => $contact['url'], + '$mylink' => $photos_perms['contact']['url'], '$mytitle' => t('This is you'), - '$myphoto' => $contact['thumb'], + '$myphoto' => $photos_perms['contact']['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), @@ -1612,7 +1605,7 @@ function photos_content(&$a) { - if($can_post || can_write_wall($a,$owner_uid)) { + if($photos_perms['can_post'] || can_write_wall($a,$owner_uid)) { if($link_item['last-child']) { $comments .= replace_macros($cmnt_tpl,array( '$return_path' => '', @@ -1621,9 +1614,9 @@ function photos_content(&$a) { '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, - '$mylink' => $contact['url'], + '$mylink' => $photos_perms['contact']['url'], '$mytitle' => t('This is you'), - '$myphoto' => $contact['thumb'], + '$myphoto' => $photos_perms['contact']['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), @@ -1665,7 +1658,7 @@ function photos_content(&$a) { - $dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user())); + $dropping = (($item['contact-id'] == $photos_perms['contact_id']) || ($item['uid'] == local_user())); $drop = array( 'dropping' => $dropping, 'pagedrop' => false, @@ -1699,7 +1692,7 @@ function photos_content(&$a) { '$comment' => $comment )); - if($can_post || can_write_wall($a,$owner_uid)) { + if($photos_perms['can_post'] || can_write_wall($a,$owner_uid)) { if($item['last-child']) { $comments .= replace_macros($cmnt_tpl,array( @@ -1709,9 +1702,9 @@ function photos_content(&$a) { '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $owner_uid, - '$mylink' => $contact['url'], + '$mylink' => $photos_perms['contact']['url'], '$mytitle' => t('This is you'), - '$myphoto' => $contact['thumb'], + '$myphoto' => $photos_perms['contact']['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), @@ -1847,7 +1840,7 @@ function photos_content(&$a) { $tpl = get_markup_template('photos_recent.tpl'); $o .= replace_macros($tpl, array( '$title' => t('Recent Photos'), - '$can_post' => $can_post, + '$can_post' => $photos_perms['can_post'], '$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['user']['nickname'].'/upload'), '$photos' => $photos, )); From fcf7a791f1979b77a64275f63d0b0b3602fb1d36 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Mon, 4 Jan 2016 11:46:19 +0100 Subject: [PATCH 5/8] Revert "Merge pull request #2223 from rabuzarus/2912_photo_widget" This reverts commit 83e54f70d3204525ba16ea3faf5f17cd001fbc9e, reversing changes made to ecf576bdd0b801d33f3ccbc8d908729be47c3e7f. --- include/features.php | 6 -- include/photos.php | 142 ----------------------------- mod/photos.php | 119 +++++++++++++++++------- mod/profile.php | 12 +-- view/global.css | 15 --- view/templates/widget_photos.tpl | 18 ---- view/theme/duepuntozero/style.css | 13 +-- view/theme/frost-mobile/style.css | 15 +-- view/theme/frost/style.css | 19 +--- view/theme/quattro/dark/style.css | 5 +- view/theme/quattro/green/style.css | 5 +- view/theme/quattro/lilac/style.css | 11 +-- view/theme/quattro/quattro.less | 1 - view/theme/smoothly/style.css | 9 -- view/theme/vier/style.css | 6 -- 15 files changed, 106 insertions(+), 290 deletions(-) delete mode 100644 view/templates/widget_photos.tpl diff --git a/include/features.php b/include/features.php index 7dceaa4bc0..2639604576 100644 --- a/include/features.php +++ b/include/features.php @@ -79,12 +79,6 @@ function get_features() { array('savedsearch', t('Saved Searches'), t('Save search terms for re-use'),false), ), - // Profile sidebar widgets - 'profile-widgets' => array( - t('Profile Sidebar Widgets'), - array('photos_widget', t('Show last Photos'), t('Show your last Photos in the Profile Page Sidebar'),false), - ), - // Network tabs 'net_tabs' => array( t('Network Tabs'), diff --git a/include/photos.php b/include/photos.php index 3c40f11f8a..93a565b511 100644 --- a/include/photos.php +++ b/include/photos.php @@ -4,148 +4,6 @@ * @brief Functions related to photo handling. */ - -/** - * @brief Get the permissions for the photos page - * - * @param int $owner_uid Owner of the photos page - * @param bool $community_page If it's an forum account - * - * @return array - *......'can_post' - *......'visitor' - *......'contact' - * 'remote_contact' - * .....'contact_id' - * 'groups' - */ -function photos_permissions($owner_uid, $community_page = 0) { - - $arr = array(); - - if((local_user()) && (local_user() == $owner_uid)) - $arr['can_post'] = true; - else { - if($community_page && remote_user()) { - if(is_array($_SESSION['remote'])) { - foreach($_SESSION['remote'] as $v) { - if($v['uid'] == $owner_uid) { - $arr['contact_id'] = $v['cid']; - break; - } - } - } - if($arr['contact_id']) { - - $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", - intval($arr['contact_id']), - intval($owner_uid) - ); - if(count($r)) { - $arr['can_post'] = true; - $arr['contact'] = $r[0]; - $arr['remote_contact'] = true; - $arr['visitor'] = $cid; - } - } - } - } - - // perhaps they're visiting - but not a community page, so they wouldn't have write access - - if(remote_user() && (! $arr['visitor'])) { - $arr['contact_id'] = 0; - if(is_array($_SESSION['remote'])) { - foreach($_SESSION['remote'] as $v) { - if($v['uid'] == $owner_uid) { - $arr['contact_id'] = $v['cid']; - break; - } - } - } - if($arr['contact_id']) { - $arr['groups'] = init_groups_visitor($arr['contact_id']); - $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", - intval($arr['contact_id']), - intval($owner_uid) - ); - if(count($r)) { - $arr['contact'] = $r[0]; - $arr['remote_contact'] = true; - } - } - } - - if(! $arr['remote_contact']) { - if(local_user()) { - $arr['contact_id'] = $_SESSION['cid']; - $arr['contact'] = $a->contact; - } - } - - return $arr; -} - -/** - * @brief Construnct a widget with last uploaded photos - * - * It displays the last 9 photos - * - * @param array $profile_data - *......'profile_uid'...=> The user.id of the profile (owner of the photos) - *......'nickname'......=> Nick of the owner of the profile - *......'page-flags'....=> Account type of the profile - * - * @return string - *......formatted html - * - * @template widget_photos.tpl - */ -function widget_photos($profile_data) { - - $community_page = (($profile_data['page-flags'] == PAGE_COMMUNITY) ? true : false); - $nickname = $profile_data['nickname']; - $owner_id = $profile_data['profile_uid']; - - $phototypes = Photo::supportedTypes(); - $photos_perms = photos_permissions($owner_id, $community_page); - - $sql_extra = permissions_sql($owner_id, $photos_perms['remote_contact'], $photos_perms['groups']); - - $r = q("SELECT `resource-id`, `id`, `filename`, `type`, max(`scale`) AS `scale` FROM `photo` - WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' AND `album` != '%s' - $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT 9", - intval($owner_id), - dbesc('Contact Photos'), - dbesc( t('Contact Photos')), - dbesc( t('Profile Photos')) - ); - - $photos = array(); - if(count($r)) { - foreach($r as $rr) { - $ext = $phototypes[$rr['type']]; - - $photos[] = array( - 'id' => $rr['id'], - 'src' => z_root() . '/photos/' . $nickname . '/image/' . $rr['resource-id'], - 'photo' => z_root() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext, - 'alt_text' => $rr['filename'], - ); - } - - $tpl = get_markup_template('widget_photos.tpl'); - $o .= replace_macros($tpl, array( - '$title' => t('Photos'), - '$photos' => $photos, - '$photo_albums_page' => z_root() . '/photos/' . $nickname, - '$photo_albums_page_title' => t('Vist the Photo Albums'), - )); - - return $o; - } -} - function getGps($exifCoord, $hemi) { $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0; $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0; diff --git a/mod/photos.php b/mod/photos.php index 1985875f18..a9dade6a81 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1013,25 +1013,82 @@ function photos_content(&$a) { // Setup permissions structures // - $photos_perms['can_post'] = false; - $photos_perms['visitor'] = 0; - $photos_perms['contact'] = null; - $photos_perms['remote_contact'] = false; - $photos_perms['contact_id'] = 0; + $can_post = false; + $visitor = 0; + $contact = null; + $remote_contact = false; + $contact_id = 0; $owner_uid = $a->data['user']['uid']; $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false); - // get the access rights for photos - $photos_perms = photos_permissions($owner_uid, $community_page); + if((local_user()) && (local_user() == $owner_uid)) + $can_post = true; + else { + if($community_page && remote_user()) { + if(is_array($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $v) { + if($v['uid'] == $owner_uid) { + $contact_id = $v['cid']; + break; + } + } + } + if($contact_id) { - if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $photos_perms['remote_contact'])) { + $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", + intval($contact_id), + intval($owner_uid) + ); + if(count($r)) { + $can_post = true; + $contact = $r[0]; + $remote_contact = true; + $visitor = $cid; + } + } + } + } + + // perhaps they're visiting - but not a community page, so they wouldn't have write access + + if(remote_user() && (! $visitor)) { + $contact_id = 0; + if(is_array($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $v) { + if($v['uid'] == $owner_uid) { + $contact_id = $v['cid']; + break; + } + } + } + if($contact_id) { + $groups = init_groups_visitor($contact_id); + $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", + intval($contact_id), + intval($owner_uid) + ); + if(count($r)) { + $contact = $r[0]; + $remote_contact = true; + } + } + } + + if(! $remote_contact) { + if(local_user()) { + $contact_id = $_SESSION['cid']; + $contact = $a->contact; + } + } + + if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) { notice( t('Access to this item is restricted.') . EOL); return; } - $sql_extra = permissions_sql($owner_uid, $photos_perms['remote_contact'], $photos_perms['groups']); + $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups); $o = ""; @@ -1044,7 +1101,7 @@ function photos_content(&$a) { */ if($datatype === 'upload') { - if(! ($photos_perms['can_post'])) { + if(! ($can_post)) { notice( t('Permission denied.')); return; } @@ -1114,11 +1171,11 @@ function photos_content(&$a) { if($a->theme['template_engine'] === 'internal') { $albumselect_e = template_escape($albumselect); - $aclselect_e = (($photos_perms['visitor']) ? '' : template_escape(populate_acl($a->user))); + $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user))); } else { $albumselect_e = $albumselect; - $aclselect_e = (($photos_perms['visitor']) ? '' : populate_acl($a->user)); + $aclselect_e = (($visitor) ? '' : populate_acl($a->user)); } $o .= replace_macros($tpl,array( @@ -1186,7 +1243,7 @@ function photos_content(&$a) { //edit album name if($cmd === 'edit') { if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { - if($photos_perms['can_post']) { + if($can_post) { $edit_tpl = get_markup_template('album_edit.tpl'); if($a->theme['template_engine'] === 'internal') { @@ -1209,7 +1266,7 @@ function photos_content(&$a) { } else { if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { - if($photos_perms['can_post']) { + if($can_post) { $edit = array(t('Edit Album'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit'); } } @@ -1259,7 +1316,7 @@ function photos_content(&$a) { $o .= replace_macros($tpl, array( '$photos' => $photos, '$album' => $album, - '$can_post' => $photos_perms['can_post'], + '$can_post' => $can_post, '$upload' => array(t('Upload New Photos'), $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)), '$order' => $order, '$edit' => $edit @@ -1326,7 +1383,7 @@ function photos_content(&$a) { break; } } - $edit_suffix = ((($cmd === 'edit') && ($photos_perms['can_post'])) ? '/edit' : ''); + $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : ''); $prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); $nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); } @@ -1349,7 +1406,7 @@ function photos_content(&$a) { $tools = Null; $lock = Null; - if($photos_perms['can_post'] && ($ph[0]['uid'] == $owner_uid)) { + if($can_post && ($ph[0]['uid'] == $owner_uid)) { $tools = array( 'edit' => array($a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))), 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource-id'], t('Use as profile photo')), @@ -1472,7 +1529,7 @@ function photos_content(&$a) { $edit = Null; - if(($cmd === 'edit') && ($photos_perms['can_post'])) { + if(($cmd === 'edit') && ($can_post)) { $edit_tpl = get_markup_template('photo_edit.tpl'); // Private/public post links for the non-JS ACL form @@ -1544,7 +1601,7 @@ function photos_content(&$a) { $likebuttons = ''; - if($photos_perms['can_post'] || can_write_wall($a,$owner_uid)) { + if($can_post || can_write_wall($a,$owner_uid)) { $likebuttons = replace_macros($like_tpl,array( '$id' => $link_item['id'], '$likethis' => t("I like this \x28toggle\x29"), @@ -1557,7 +1614,7 @@ function photos_content(&$a) { $comments = ''; if(! count($r)) { - if($photos_perms['can_post'] || can_write_wall($a,$owner_uid)) { + if($can_post || can_write_wall($a,$owner_uid)) { if($link_item['last-child']) { $comments .= replace_macros($cmnt_tpl,array( '$return_path' => '', @@ -1566,9 +1623,9 @@ function photos_content(&$a) { '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, - '$mylink' => $photos_perms['contact']['url'], + '$mylink' => $contact['url'], '$mytitle' => t('This is you'), - '$myphoto' => $photos_perms['contact']['thumb'], + '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), @@ -1605,7 +1662,7 @@ function photos_content(&$a) { - if($photos_perms['can_post'] || can_write_wall($a,$owner_uid)) { + if($can_post || can_write_wall($a,$owner_uid)) { if($link_item['last-child']) { $comments .= replace_macros($cmnt_tpl,array( '$return_path' => '', @@ -1614,9 +1671,9 @@ function photos_content(&$a) { '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, - '$mylink' => $photos_perms['contact']['url'], + '$mylink' => $contact['url'], '$mytitle' => t('This is you'), - '$myphoto' => $photos_perms['contact']['thumb'], + '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), @@ -1658,7 +1715,7 @@ function photos_content(&$a) { - $dropping = (($item['contact-id'] == $photos_perms['contact_id']) || ($item['uid'] == local_user())); + $dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user())); $drop = array( 'dropping' => $dropping, 'pagedrop' => false, @@ -1692,7 +1749,7 @@ function photos_content(&$a) { '$comment' => $comment )); - if($photos_perms['can_post'] || can_write_wall($a,$owner_uid)) { + if($can_post || can_write_wall($a,$owner_uid)) { if($item['last-child']) { $comments .= replace_macros($cmnt_tpl,array( @@ -1702,9 +1759,9 @@ function photos_content(&$a) { '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $owner_uid, - '$mylink' => $photos_perms['contact']['url'], + '$mylink' => $contact['url'], '$mytitle' => t('This is you'), - '$myphoto' => $photos_perms['contact']['thumb'], + '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), @@ -1785,7 +1842,7 @@ function photos_content(&$a) { $a->set_pager_itemspage(20); } - $r = q("SELECT `resource-id`, `id`, `filename`, `type`, `album`, max(`scale`) AS `scale` FROM `photo` + $r = q("SELECT `resource-id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d", intval($a->data['user']['uid']), @@ -1840,7 +1897,7 @@ function photos_content(&$a) { $tpl = get_markup_template('photos_recent.tpl'); $o .= replace_macros($tpl, array( '$title' => t('Recent Photos'), - '$can_post' => $photos_perms['can_post'], + '$can_post' => $can_post, '$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['user']['nickname'].'/upload'), '$photos' => $photos, )); diff --git a/mod/profile.php b/mod/profile.php index 83e3e37958..26bd395230 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -1,7 +1,6 @@ argc > 1) $which = $a->argv[1]; else { - $r = q("SELECT `nickname` FROM `user` WHERE `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 ORDER BY RAND() LIMIT 1"); + $r = q("select nickname from user where blocked = 0 and account_expired = 0 and account_removed = 0 and verified = 1 order by rand() limit 1"); if(count($r)) { goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']); } @@ -182,9 +181,6 @@ function profile_content(&$a, $update = 0) { $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false); $commvisitor = (($commpage && $remote_contact == true) ? true : false); - if(feature_enabled($a->profile['profile_uid'],'photos_widget')) - $a->page['aside'] .= widget_photos($a->profile); - $a->page['aside'] .= posted_date_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true); $a->page['aside'] .= categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : '')); @@ -225,9 +221,9 @@ function profile_content(&$a, $update = 0) { FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND - (`item`.`deleted` = 0 OR `item`.`verb` = '" . ACTIVITY_LIKE ."' - OR `item`.`verb` = '" . ACTIVITY_DISLIKE . "' OR `item`.`verb` = '" . ACTIVITY_ATTEND . "' - OR `item`.`verb` = '" . ACTIVITY_ATTENDNO . "' OR `item`.`verb` = '" . ACTIVITY_ATTENDMAYBE . "') + (`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' + OR item.verb = '" . ACTIVITY_DISLIKE . "' OR item.verb = '" . ACTIVITY_ATTEND . "' + OR item.verb = '" . ACTIVITY_ATTENDNO . "' OR item.verb = '" . ACTIVITY_ATTENDMAYBE . "') AND `item`.`moderated` = 0 and `item`.`unseen` = 1 AND `item`.`wall` = 1 $sql_extra diff --git a/view/global.css b/view/global.css index 09168a52bd..05940508ca 100644 --- a/view/global.css +++ b/view/global.css @@ -321,18 +321,3 @@ ul.credits li { .p-addr { clear: both; } - -.widget-photo { - float: left; -} - -.widget-photo-link { - margin: 0 2px 2px 0; -} - -img.widget-photo-img { - width: 48px; - height: 48px; - object-fit: cover; - padding-right: 2px; -} diff --git a/view/templates/widget_photos.tpl b/view/templates/widget_photos.tpl deleted file mode 100644 index abd403a172..0000000000 --- a/view/templates/widget_photos.tpl +++ /dev/null @@ -1,18 +0,0 @@ - - diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index bfffeb2503..c004eb53d0 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -140,12 +140,12 @@ nav #banner #logo-text a:hover { text-decoration: none; } .nav-commlink, .nav-login-link { - display: block; - height: 15px; + display: block; + height: 15px; margin-top: 67px; margin-right: 2px; - /* padding: 6px 10px; */ - padding: 6px 3px; + //padding: 6px 10px; + padding: 6px 3px; float: left; bottom: 140px; border: 1px solid #babdb6; @@ -244,7 +244,7 @@ section { display:block; float:left; padding: 0.4em; - /*margin-right: 1em; */ + //margin-right: 1em; margin-right: 3px ; } .tab.active { @@ -2164,9 +2164,6 @@ aside input[type='text'] { } -.widget h3 a { - color: #000000; -} /*.photos { height: auto; diff --git a/view/theme/frost-mobile/style.css b/view/theme/frost-mobile/style.css index 94e5120c01..400b23c10b 100644 --- a/view/theme/frost-mobile/style.css +++ b/view/theme/frost-mobile/style.css @@ -2541,14 +2541,6 @@ a.mail-list-link { margin: 10px 0 10px; } -.widget-photo { - float: left; -} - -.widget-photo-link { - margin: 0 2px 2px 0; -} - #sidebar-group-list ul { list-style-type: none; } @@ -2634,15 +2626,12 @@ aside input[type='text'] { -webkit-border-radius:5px; border-radius:5px; } - -.widget h3 a { - color: #505050; -} - .widget.settings-widget { padding: 0; } + + /*.photos { height: auto; overflow: auto; diff --git a/view/theme/frost/style.css b/view/theme/frost/style.css index 3adf91ad67..3dd400c76b 100644 --- a/view/theme/frost/style.css +++ b/view/theme/frost/style.css @@ -2356,21 +2356,6 @@ a.mail-list-link { margin: 10px 0 10px; } -.widget-photo { - float: left; -} - -.widget-photo-link { - margin: 0 2px 2px 0; -} - -img.widget-photo-img { - width: 48px; - height: 48px; - object-fit: cover; - padding-right: 2px; -} - #sidebar-group-list ul { list-style-type: none; } @@ -2461,11 +2446,9 @@ aside input[type='text'] { -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; + } -.widget h3 a { - color: #505050; -} /*.photos { height: auto; diff --git a/view/theme/quattro/dark/style.css b/view/theme/quattro/dark/style.css index ebb9977416..847017ee5b 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; @@ -1007,9 +1007,6 @@ aside .posted-date-selector-months { padding: 0; margin: 2px; } -.widget h3 a { - color: #2d2d2d; -} .widget .action { opacity: 0.1; -webkit-transition: all 0.2s ease-in-out; diff --git a/view/theme/quattro/green/style.css b/view/theme/quattro/green/style.css index 5c2661e919..4cfcb59273 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; @@ -1007,9 +1007,6 @@ aside .posted-date-selector-months { padding: 0; margin: 2px; } -.widget h3 a { - color: #2d2d2d; -} .widget .action { opacity: 0.1; -webkit-transition: all 0.2s ease-in-out; diff --git a/view/theme/quattro/lilac/style.css b/view/theme/quattro/lilac/style.css index 32f1ccaf6a..2ff7cfcb0c 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 0 0 0; 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; @@ -1007,9 +1007,6 @@ aside .posted-date-selector-months { padding: 0; margin: 2px; } -.widget h3 a { - color: #2d2d2d; -} .widget .action { opacity: 0.1; -webkit-transition: all 0.2s ease-in-out; @@ -1756,7 +1753,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; @@ -1783,7 +1780,7 @@ span[id^="showmore-wrap"] { margin: 0; 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 8822fc3ded..681cfcc374 100644 --- a/view/theme/quattro/quattro.less +++ b/view/theme/quattro/quattro.less @@ -454,7 +454,6 @@ aside { margin-bottom: 2em; h3 { padding: 0; margin: 2px;} - h3 a { color: @BodyColor; } .action { .opaque(0.1); } input.action { .opaque(0.5); } &:hover .title .action { .opaque(1); } diff --git a/view/theme/smoothly/style.css b/view/theme/smoothly/style.css index 5123307493..b9f094932d 100644 --- a/view/theme/smoothly/style.css +++ b/view/theme/smoothly/style.css @@ -1019,15 +1019,6 @@ ul .sidebar-group-li .icon { text-shadow: -1px 0px 0px #bdbdbd; } -.widget h3 a { - color: #626262; -} - -.widget h3 a:hover, .widget h3 a:focus { - color: #6da6c4; - text-decoration: none; -} - #connect-desc { margin-left: 10px; } diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index 418ef057fc..84b3ff2361 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -1190,12 +1190,6 @@ aside h4, right_aside h4 { padding: 0px; margin: 2px; } -.widget h3 a { - color: #737373; -} -.widget h3 a:hover { - color: black; -} .widget .action { opacity: 0.1; -webkit-transition: all 0.2s ease-in-out; From 8d9a905c8073bd7bf3eec0aed6d9ac95f9d5792d Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 10 Jan 2016 23:08:25 +0100 Subject: [PATCH 6/8] Bugfix: Public posts to Diaspora could fail --- include/Scrape.php | 7 ++++--- include/cron.php | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/Scrape.php b/include/Scrape.php index cb192c77c2..9cc7086157 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -559,10 +559,11 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) { $pubkey = $hcard_key; } } - if($diaspora && $diaspora_base && $diaspora_guid) { - if($mode == PROBE_DIASPORA || ! $notify) { - $notify = $diaspora_base . 'receive/users/' . $diaspora_guid; + $diaspora_notify = $diaspora_base.'receive/users/'.$diaspora_guid; + + if($mode == PROBE_DIASPORA || ! $notify || ($notify == $diaspora_notify)) { + $notify = $diaspora_notify; $batch = $diaspora_base . 'receive/public' ; } if(strpos($url,'@')) diff --git a/include/cron.php b/include/cron.php index a6e81f6bfd..78d5ca1541 100644 --- a/include/cron.php +++ b/include/cron.php @@ -229,6 +229,24 @@ function cron_run(&$argv, &$argc){ set_config('system','cache_last_cleared', time()); } + // Repair missing Diaspora settings + $r = q("SELECT `id`, `url` FROM `contact` + WHERE `uid` > 0 AND `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '') + ORDER BY RAND() LIMIT 50", dbesc(NETWORK_DIASPORA)); + if ($r) { + foreach ($r AS $contact) { + if (poco_reachable($contact["url"])) { + $data = probe_url($contact["url"]); + if ($data["network"] == NETWORK_DIASPORA) { + logger("Repair contact ".$contact["id"]." ".$contact["url"], LOGGER_DEBUG); + q("UPDATE `contact` SET `batch` = '%s', `notify` = '%s', `poll` = '%s', pubkey = '%s' WHERE `id` = %d", + dbesc($data["batch"]), dbesc($data["notify"]), dbesc($data["poll"]), dbesc($data["pubkey"]), + intval($contact["id"])); + } + } + } + } + $manual_id = 0; $generation = 0; $force = false; From bfdbc0c81821f48a5d7965fde3fae8127ee87084 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Mon, 11 Jan 2016 07:54:52 +0100 Subject: [PATCH 7/8] don't mention FB in newhere tipps --- mod/newmember.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mod/newmember.php b/mod/newmember.php index 8028e7e08d..aa55c3a098 100644 --- a/mod/newmember.php +++ b/mod/newmember.php @@ -45,11 +45,6 @@ function newmember_content(&$a) { $o .= '
    '; - if(in_array('facebook', $a->plugins)) - $o .= '
  • ' . '' . t('Facebook') . '
    ' . t("Authorise the Facebook Connector if you currently have a Facebook account and we will \x28optionally\x29 import all your Facebook friends and conversations.") . '
  • ' . EOL; - else - $o .= '
  • ' . '' . t('Facebook') . '
    ' . t("If this is your own personal server, installing the Facebook addon may ease your transition to the free social web.") . '
  • ' . EOL; - $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); if(! $mail_disabled) From 5c568df9a6d0136d44e60a2d9a45393efff35b69 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Mon, 11 Jan 2016 08:57:51 +0100 Subject: [PATCH 8/8] remove unsupported themes from list of allowed themes --- htconfig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htconfig.php b/htconfig.php index 508de9a323..fe6c0d82ee 100644 --- a/htconfig.php +++ b/htconfig.php @@ -57,7 +57,7 @@ $a->config['system']['huburl'] = '[internal]'; // allowed themes (change this from admin panel after installation) -$a->config['system']['allowed_themes'] = 'dispy,quattro,vier,darkzero,duepuntozero,greenzero,purplezero,slackr,diabook'; +$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero'; // default system theme