From c29483b88cda69beb51f00ee8f2d262bc6784a24 Mon Sep 17 00:00:00 2001 From: marijus Date: Mon, 2 Feb 2015 15:18:44 +0100 Subject: respect parent dir permissions --- include/attach.php | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ view/tpl/attach_edit.tpl | 2 ++ 2 files changed, 76 insertions(+) diff --git a/include/attach.php b/include/attach.php index 155ddbc96..c38301e01 100644 --- a/include/attach.php +++ b/include/attach.php @@ -966,6 +966,35 @@ function pipe_streams($in, $out) { function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $no_activity) { + //if we got no object something went wrong + if(!$object) + return; + + $is_dir = (($object['flags'] & ATTACH_FLAG_DIR) ? true : false); + + //do not send activity for folders for now + if($is_dir) + return; + + //check for recursive perms if we are in a folder + if($object['folder']) { + + $folder_hash = $object['folder']; + + $r_perms = check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash); + + $allow_cid = $r_perms['allow_cid']; + $allow_gid = $r_perms['allow_gid']; + $deny_cid = $r_perms['deny_cid']; + $deny_gid = $r_perms['deny_gid']; + + if(!$allow_gid && !$allow_cid) { + notice( t('Allowed permissions for this file are not recursive. None of your allowed contacts will have access to this file.') . EOL); + $verb = 'update'; + } + + } + require_once('include/items.php'); $poster = get_app()->get_observer(); @@ -1124,3 +1153,48 @@ function get_file_activity_object($channel_id, $hash, $cloudpath) { return $object; } + +function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash) { + + $arr_allow_cid = expand_acl($allow_cid); + $arr_allow_gid = expand_acl($allow_gid); + $arr_deny_cid = expand_acl($deny_cid); + $arr_deny_gid = expand_acl($deny_gid); + + while($folder_hash) { + $x = q("SELECT * FROM attach WHERE hash = '%s'", + dbesc($folder_hash) + ); + + $parents_arr_allow_cid[] = expand_acl($x[0]['allow_cid']); + $parents_arr_allow_gid[] = expand_acl($x[0]['allow_gid']); + $parents_arr_deny_cid[] = expand_acl($x[0]['deny_cid']); + $parents_arr_deny_gid[] = expand_acl($x[0]['deny_gid']); + + $folder_hash = $x[0]['folder']; + } + + foreach($parents_arr_allow_gid as $folder_arr_allow_gid) { + $arr_allow_gid = array_intersect($arr_allow_gid, $folder_arr_allow_gid); + } + + foreach($parents_arr_allow_cid as $folder_arr_allow_cid) { + $arr_allow_cid = array_intersect($arr_allow_cid, $folder_arr_allow_cid); + } + + foreach($parents_arr_deny_gid as $folder_arr_deny_gid) { + $arr_deny_gid = array_merge($arr_deny_gid, $folder_arr_deny_gid); + } + + foreach($parents_arr_deny_cid as $folder_arr_deny_cid) { + $arr_deny_cid = array_merge($arr_deny_cid, $folder_arr_deny_cid); + } + + $ret['allow_gid'] = perms2str($arr_allow_gid); + $ret['allow_cid'] = perms2str($arr_allow_cid); + $ret['deny_gid'] = perms2str(array_unique($arr_deny_gid)); + $ret['deny_cid'] = perms2str(array_unique($arr_deny_cid)); + + return $ret; + +} diff --git a/view/tpl/attach_edit.tpl b/view/tpl/attach_edit.tpl index 5a8743919..4a438e8fd 100644 --- a/view/tpl/attach_edit.tpl +++ b/view/tpl/attach_edit.tpl @@ -22,11 +22,13 @@ {{/if}} + {{if !$isadir}}
+ {{/if}}
{{/if}} +
- -
- {{*/if*}} {{if $entry.public_forum}}
diff --git a/view/tpl/prep.tpl b/view/tpl/prep.tpl index 49dea7d72..924bea252 100644 --- a/view/tpl/prep.tpl +++ b/view/tpl/prep.tpl @@ -12,9 +12,10 @@
{{$r.xchan_name}}
-{{$rating_lbl}} {{$r.xlink_rating}} +
{{$rating_lbl}} {{$r.xlink_rating}}
{{if $r.xlink_rating_text}} -{{$rating_text_label}} {{$r.xlink_rating_text}} +
{{$rating_text_label}} {{$r.xlink_rating_text}} +
{{/if}}
-- cgit v1.2.3 From 8a78d1d5dfcb048b83345c0d832c71303de04cd5 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 15:52:57 -0800 Subject: that didn't look so good on a small screen - let it hang out on the right margin --- view/css/mod_directory.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/view/css/mod_directory.css b/view/css/mod_directory.css index b156e322a..1e140d933 100644 --- a/view/css/mod_directory.css +++ b/view/css/mod_directory.css @@ -3,13 +3,12 @@ clear: both; } .directory-name { -/* text-align: center; */ float: left; width: 250px; } .directory-rating { float: right; - margin-right: 20px; + margin-right: 5px; } .directory-photo { -- cgit v1.2.3 From 3f50313862f5c2ca9d7118b234b2f154c7fb736a Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 16:03:05 -0800 Subject: garbage in garbage out --- include/text.php | 4 ++-- include/zot.php | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/text.php b/include/text.php index d19519779..ef2fc2371 100644 --- a/include/text.php +++ b/include/text.php @@ -1946,9 +1946,9 @@ function find_xchan_in_array($xchan,$arr) { } function get_rel_link($j,$rel) { - if(count($j)) + if(is_array($j) && ($j)) foreach($j as $l) - if($l['rel'] === $rel) + if(array_key_exists('rel',$j) && $l['rel'] === $rel && array_key_exists('href',$l)) return $l['href']; return ''; diff --git a/include/zot.php b/include/zot.php index 04b6806c2..7002fee0a 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1084,6 +1084,11 @@ function zot_import($arr, $sender_url) { if(is_array($incoming)) { foreach($incoming as $i) { + if(! is_array($i)) { + logger('incoming is not an array'); + continue; + } + $result = null; if(array_key_exists('iv',$i['notify'])) { -- cgit v1.2.3 From 5cb2f55dbbe715219dd18c60345e341ed478a753 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 16:52:09 -0800 Subject: rating form work --- mod/prate.php | 5 +++++ view/css/mod_directory.css | 7 +++++++ view/js/mod_directory.js | 9 +++++++++ view/tpl/direntry.tpl | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mod/prate.php b/mod/prate.php index 30de97927..25d279a5b 100644 --- a/mod/prate.php +++ b/mod/prate.php @@ -3,6 +3,11 @@ function prate_post(&$a) { +logger('request: ' . print_r($_REQUEST,true)); +return; + + + if(! local_channel()) return; diff --git a/view/css/mod_directory.css b/view/css/mod_directory.css index 1e140d933..e93f23ec6 100644 --- a/view/css/mod_directory.css +++ b/view/css/mod_directory.css @@ -10,6 +10,13 @@ float: right; margin-right: 5px; } +.directory-slider { + padding: 15px; + width: 100px; +} +.directory-rating-text { + margin-top: 30px; +} .directory-photo { margin-left: 25px; diff --git a/view/js/mod_directory.js b/view/js/mod_directory.js index 74c8b414d..60bfe98ba 100644 --- a/view/js/mod_directory.js +++ b/view/js/mod_directory.js @@ -3,9 +3,18 @@ function dirdetails(hash) { $.get('dirprofile' + '?f=&hash=' + hash, function( data ) { $.colorbox({ maxWidth: "50%", maxHeight: "75%", html: data }); }); +} + + +function doRatings(hash) { + + var html = '
'; + + $.colorbox({maxwidth: "50%", maxHeight: "50%", html: html }); } + $(document).ready(function() { collapseHeight(); }); \ No newline at end of file diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl index 1761ed12d..461c5dcde 100755 --- a/view/tpl/direntry.tpl +++ b/view/tpl/direntry.tpl @@ -17,7 +17,7 @@ {{*if $entry.rateme*}}
{{if $entry.total_ratings}}{{/if}} - +
{{*/if*}} {{if $entry.public_forum}} -- cgit v1.2.3 From 17ffe122b309610208d769f0e2b41f53fcf9d254 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 18:10:55 -0800 Subject: ratings - mopping up, most everything but directory sync implemented --- include/js_strings.php | 3 +++ mod/connedit.php | 30 ++++++++++++++++++++++-------- mod/directory.php | 2 ++ mod/prate.php | 27 --------------------------- view/css/mod_directory.css | 16 +++++++++++++--- view/js/mod_directory.js | 4 ++-- view/theme/redbasic/css/style.css | 9 +++++++++ view/tpl/direntry.tpl | 6 +++--- view/tpl/js_strings.tpl | 3 +++ 9 files changed, 57 insertions(+), 43 deletions(-) diff --git a/include/js_strings.php b/include/js_strings.php index f4c0a631d..14293c5ce 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -16,6 +16,9 @@ function js_strings() { '$permschange' => t('Notice: Permissions have changed but have not yet been submitted.'), '$closeAll' => t('close all'), '$nothingnew' => t('Nothing new here'), + '$rating_desc' => t('Rate This Channel (this is public)'), + '$rating_val' => t('Rating'), + '$rating_text' => t('Describe (optional)'), '$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : ''), '$t02' => ((t('timeago.prefixFromNow') != 'timeago.prefixFromNow') ? t('timeago.prefixFromNow') : ''), diff --git a/mod/connedit.php b/mod/connedit.php index 79c7e6a4f..58366da6d 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -180,13 +180,11 @@ function connedit_post(&$a) { } - $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_rating = %d, abook_rating_text = '%s', abook_flags = %d + $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d where abook_id = %d AND abook_channel = %d", dbesc($profile_id), intval($abook_my_perms), intval($closeness), - intval($rating), - dbesc($rating_text), intval($abook_flags), intval($contact_id), intval(local_channel()) @@ -324,6 +322,7 @@ function connedit_content(&$a) { return login(); } + $channel = $a->get_channel(); $my_perms = get_channel_default_perms(local_channel()); $role = get_pconfig(local_channel(),'system','permissions_role'); if($role) { @@ -572,6 +571,21 @@ function connedit_content(&$a) { )); } + $rating_val = 0; + $rating_text = ''; + +dbg(1); + $xl = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1", + dbesc($channel['channel_hash']), + dbesc($contact['xchan_hash']) + ); +dbg(0); + if($xl) { + $rating_val = intval($xl[0]['xlink_rating']); + $rating_text = $xl[0]['xlink_rating_text']; + } + + $poco_rating = get_config('system','poco_rating_enable'); // if unset default to enabled @@ -581,7 +595,7 @@ function connedit_content(&$a) { if($poco_rating) { $rating = replace_macros(get_markup_template('rating_slider.tpl'),array( '$min' => -10, - '$val' => (($contact['abook_rating']) ? $contact['abook_rating'] : 0), + '$val' => $rating_val )); } else { @@ -621,11 +635,11 @@ function connedit_content(&$a) { '$viewprof' => t('View Profile'), '$clickme' => t('Click to open/close'), '$lbl_slider' => t('Slide to adjust your degree of friendship'), - '$lbl_rating' => t('Rating (this information may be public)'), - '$lbl_rating_txt' => t('Optionally explain your rating (this information may be public)'), - '$rating_txt' => $contact['abook_rating_text'], + '$lbl_rating' => t('Rating (this information is public)'), + '$lbl_rating_txt' => t('Optionally explain your rating (this information is public)'), + '$rating_txt' => $rating_text, '$rating' => $rating, - '$rating_val' => $contact['abook_rating'], + '$rating_val' => $rating_val, '$slide' => $slide, '$tabs' => $t, '$tab_str' => $tab_str, diff --git a/mod/directory.php b/mod/directory.php index d9316ef67..40ca93af9 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -261,6 +261,8 @@ function directory_content(&$a) { 'location' => $location, 'gender' => $gender, 'total_ratings' => $total_ratings, + 'viewrate' => true, + 'canrate' => ((local_channel()) ? true : false), 'pdesc' => $pdesc, 'marital' => $marital, 'homepage' => $homepage, diff --git a/mod/prate.php b/mod/prate.php index 25d279a5b..62f188891 100644 --- a/mod/prate.php +++ b/mod/prate.php @@ -3,11 +3,6 @@ function prate_post(&$a) { -logger('request: ' . print_r($_REQUEST,true)); -return; - - - if(! local_channel()) return; @@ -68,28 +63,6 @@ return; proc_run('php','include/ratenotif.php','rating',$record); } - $x = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1", - dbesc($target), - intval($local_channel()) - ); - if($x) { - $w = q("update abook set abook_rating = %d, abook_rating_text = '%s' where abook_xchan = '%s' and abook_channel = %d", - intval($rating), - dbesc($rating_text), - dbesc($target), - intval(local_channel()) - ); - $x = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", - dbesc($target), - intval($local_channel()) - ); - if($x) { - unset($x[0]['abook_id']); - unset($x[0]['abook_account']); - unset($x[0]['abook_channel']); - build_sync_packet(0, array('abook' => array($x[0]))); - } - } return; } diff --git a/view/css/mod_directory.css b/view/css/mod_directory.css index e93f23ec6..d4cf23b39 100644 --- a/view/css/mod_directory.css +++ b/view/css/mod_directory.css @@ -10,14 +10,24 @@ float: right; margin-right: 5px; } -.directory-slider { + +.slider-container { padding: 15px; - width: 100px; } -.directory-rating-text { + +.rating-text { margin-top: 30px; } +.directory-rating-text { + width: 90%; + margin-left: 5%; +} + +.directory-rating-submit { + margin-top: 15px; +} + .directory-photo { margin-left: 25px; } diff --git a/view/js/mod_directory.js b/view/js/mod_directory.js index 60bfe98ba..09b103352 100644 --- a/view/js/mod_directory.js +++ b/view/js/mod_directory.js @@ -8,9 +8,9 @@ function dirdetails(hash) { function doRatings(hash) { - var html = '
'; + var html = '
'+aStr['rating_desc']+'
'+aStr['rating_text']+'
'; - $.colorbox({maxwidth: "50%", maxHeight: "50%", html: html }); + $.colorbox({maxwidth: "50%", maxHeight: "50%", html: html, close: 'X' }); } diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index c637f30e4..cebc516da 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -575,6 +575,15 @@ footer { #cboxContent { color: $dirpopup_txtcol; + margin: 5px; +} + +#cboxClose { + margin: 10px; +} + +#colorbox { + margin: 5px; } #cboxContent a { diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl index 461c5dcde..1b84bca56 100755 --- a/view/tpl/direntry.tpl +++ b/view/tpl/direntry.tpl @@ -15,11 +15,11 @@
{{$entry.name}}{{if $entry.online}} {{/if}}
-{{*if $entry.rateme*}} +{{if $entry.viewrate}}
{{if $entry.total_ratings}}{{/if}} - +{{if $entry.canrate}}{{/if}}
-{{*/if*}} +{{/if}} {{if $entry.public_forum}}
{{$entry.forum_label}} @{{$entry.nickname}}+ diff --git a/view/tpl/js_strings.tpl b/view/tpl/js_strings.tpl index eb78c669f..9cfd84cf8 100755 --- a/view/tpl/js_strings.tpl +++ b/view/tpl/js_strings.tpl @@ -16,6 +16,9 @@ 'permschange' : "{{$permschange}}", 'closeAll' : "{{$closeAll}}", 'nothingnew' : "{{$nothingnew}}", + 'rating_desc' : "{{$rating_desc}}", + 'rating_val' : "{{$rating_val}}", + 'rating_text' : "{{$rating_text}}", 't01' : "{{$t01}}", 't02' : "{{$t02}}", -- cgit v1.2.3 From 86771547e6d04d046d3beeabb8e4486a59a7fcc6 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 18:35:54 -0800 Subject: finish off the sync functions --- include/dir_fns.php | 43 +++++++++++++++++++++++++++++++++++++++++++ mod/dirsearch.php | 5 +++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/include/dir_fns.php b/include/dir_fns.php index 6d06fddd1..8c0161ff1 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -216,6 +216,49 @@ function sync_directories($dirmode) { ); } } + if(count($j['ratings'])) { + foreach($j['ratings'] as $rr) { + $x = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1", + dbesc($rr['channel']), + dbesc($rr['target']) + ); + if($x && $x[0]['xlink_updated'] >= $rr['edited']) + continue; + $y = q("select xchan_pubkey from xchan where xchan_hash = '%s' limit 1", + dbesc($rr['channel']) + ); + if(! $y) { + logger('key unavailable on this site for ' . $rr['channel']); + continue; + } + if(! rsa_verify($rr['target'] . '.' . $rr['rating'] . '.' . $rr['rating_text'], base64url_decode($rr['signature']),$y[0]['xchan_pubkey'])) { + logger('failed to verify rating'); + continue; + } + + if($x) { + $z = q("update xlink set xlink_rating = %d, xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s' where xlink_id = %d", + intval($rr['rating']), + dbesc($rr['rating_text']), + dbesc($rr['signature']), + dbesc(datetime_convert()), + intval($x[0]['xlink_id']) + ); + logger('rating updated'); + } + else { + $z = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_sig, xlink_updated, xlink_static ) values( '%s', '%s', %d, '%s', '%s', 1 ) ", + dbesc($rr['channel']), + dbesc($rr['target']), + intval($rr['rating']), + dbesc($rr['rating_text']), + dbesc($rr['signature']), + dbesc(datetime_convert()) + ); + logger('rating created'); + } + } + } } } diff --git a/mod/dirsearch.php b/mod/dirsearch.php index 69b7e2eac..5a0a7cee8 100644 --- a/mod/dirsearch.php +++ b/mod/dirsearch.php @@ -213,11 +213,12 @@ function dirsearch_content(&$a) { dbesc($sync) ); if($r) { - $spkt['rating'] = array(); + $spkt['ratings'] = array(); foreach($r as $rr) { - $spkt['rating'][] = array( + $spkt['ratings'][] = array( 'type' => 'rating', 'encoding' => 'zot', + 'channel' => $rr['xlink_xchan'], 'target' => $rr['xlink_link'], 'rating' => intval($rr['xlink_rating']), 'rating_text' => $rr['xlink_rating_text'], -- cgit v1.2.3 From 4ead2cd79d3c7e5c29a11785a3ceefef6d3ba93f Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 21:19:29 -0800 Subject: final cleanup on ratings feature --- include/js_strings.php | 1 + mod/prate.php | 24 +++++++++++++++++++++++- view/css/mod_directory.css | 2 +- view/css/mod_events.css | 5 ----- view/js/mod_directory.js | 28 ++++++++++++++++++++++++++-- view/theme/redbasic/css/style.css | 5 ++++- view/tpl/direntry.tpl | 2 +- view/tpl/js_strings.tpl | 1 + 8 files changed, 57 insertions(+), 11 deletions(-) diff --git a/include/js_strings.php b/include/js_strings.php index 14293c5ce..56ffa9536 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -19,6 +19,7 @@ function js_strings() { '$rating_desc' => t('Rate This Channel (this is public)'), '$rating_val' => t('Rating'), '$rating_text' => t('Describe (optional)'), + '$submit' => t('Submit'), '$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : ''), '$t02' => ((t('timeago.prefixFromNow') != 'timeago.prefixFromNow') ? t('timeago.prefixFromNow') : ''), diff --git a/mod/prate.php b/mod/prate.php index 62f188891..b89d16f42 100644 --- a/mod/prate.php +++ b/mod/prate.php @@ -1,5 +1,26 @@ get_channel(); + + $target = argv(1); + if(! $target) + return; + + $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1", + dbesc($channel['channel_hash']), + dbesc($target) + ); + if($r) + json_return_and_die(array('rating' => $r[0]['xlink_rating'],'rating_text' => $r[0]['xlink_rating_text'])); + killme(); +} function prate_post(&$a) { @@ -63,7 +84,7 @@ function prate_post(&$a) { proc_run('php','include/ratenotif.php','rating',$record); } - return; + json_return_and_die(array('result' => true));; } @@ -75,3 +96,4 @@ function prate_post(&$a) { + diff --git a/view/css/mod_directory.css b/view/css/mod_directory.css index d4cf23b39..c562764ea 100644 --- a/view/css/mod_directory.css +++ b/view/css/mod_directory.css @@ -15,7 +15,7 @@ padding: 15px; } -.rating-text { +.rating-text-label { margin-top: 30px; } diff --git a/view/css/mod_events.css b/view/css/mod_events.css index 0aef13aa6..ba4ec9b61 100644 --- a/view/css/mod_events.css +++ b/view/css/mod_events.css @@ -10,8 +10,3 @@ margin-top: 15px; width: 400px; } - -.required { - color: #ff0000; - font-size: 1.2rem; -} \ No newline at end of file diff --git a/view/js/mod_directory.js b/view/js/mod_directory.js index 09b103352..87e4f92b5 100644 --- a/view/js/mod_directory.js +++ b/view/js/mod_directory.js @@ -6,14 +6,38 @@ function dirdetails(hash) { } +var ratingVal = 0; +var ratingText = ''; +var currentHash = ''; + +function fetchRatings(hash) { + $.get('prate/'+hash, function(data) { + if(typeof(data.rating) !== 'undefined') { + ratingVal = data.rating; + ratingText = data.rating_text; + } + buildRatingForm(hash); + }); +} + + function doRatings(hash) { + fetchRatings(hash); +} - var html = '
'+aStr['rating_desc']+'
'+aStr['rating_text']+'
'; +function buildRatingForm(hash) { + var html = '
'+aStr['rating_desc']+'
'+aStr['rating_text']+'
'; $.colorbox({maxwidth: "50%", maxHeight: "50%", html: html, close: 'X' }); - + currentHash = hash; } +function postRatings() { + $.post('prate',$('#ratings_form').serialize(),function(data) { + $.colorbox.remove(); + $('#edited-'+currentHash).show(); + },'json'); +} $(document).ready(function() { collapseHeight(); diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index cebc516da..cb58b6e11 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -1185,9 +1185,12 @@ nav .acpopup { .required { - color: #FF0000; + color: #ff0000; + font-size: 1.8rem; + margin-left: 5px; } + #event-start-text, #event-finish-text { margin-top: 10px; margin-bottom: 5px; diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl index 1b84bca56..b0a1084e8 100755 --- a/view/tpl/direntry.tpl +++ b/view/tpl/direntry.tpl @@ -17,7 +17,7 @@ {{if $entry.viewrate}}
{{if $entry.total_ratings}}{{/if}} -{{if $entry.canrate}}{{/if}} +{{if $entry.canrate}}{{/if}}
{{/if}} {{if $entry.public_forum}} diff --git a/view/tpl/js_strings.tpl b/view/tpl/js_strings.tpl index 9cfd84cf8..4eb9ae844 100755 --- a/view/tpl/js_strings.tpl +++ b/view/tpl/js_strings.tpl @@ -19,6 +19,7 @@ 'rating_desc' : "{{$rating_desc}}", 'rating_val' : "{{$rating_val}}", 'rating_text' : "{{$rating_text}}", + 'submit' : "{{$submit}}", 't01' : "{{$t01}}", 't02' : "{{$t02}}", -- cgit v1.2.3 From 0cc29af6d0c305efa35fbe3b0c7bc314f21b4166 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 22:55:01 -0800 Subject: order ratings friends first --- include/conversation.php | 4 ---- mod/ratings.php | 18 +++++++++++++++++- mod/ratingsearch.php | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 9429af754..952d7d322 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -619,10 +619,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $ $profile_link = zid($profile_link); $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); - if(x($a->contacts,$normalised)) - $profile_avatar = $a->contacts[$normalised]['thumb']; - else - $profile_avatar = ((strlen($item['author-avatar'])) ? $a->get_cached_avatar_image($item['author-avatar']) : $item['thumb']); $profile_name = $item['author']['xchan_name']; $profile_link = $item['author']['xchan_url']; diff --git a/mod/ratings.php b/mod/ratings.php index 4b94f0e52..66392fe2b 100644 --- a/mod/ratings.php +++ b/mod/ratings.php @@ -8,6 +8,9 @@ function ratings_init(&$a) { return; } + if(local_channel()) + load_contact_links(local_channel()); + $dirmode = intval(get_config('system','directory_mode')); $x = find_upstream_directory($dirmode); @@ -46,7 +49,20 @@ function ratings_init(&$a) { } $a->poi = $results['target']; - $a->data = $results['ratings']; + + $friends = array(); + $others = array(); + + if($results['ratings']) { + foreach($results['ratings'] as $n) { + if(array_key_exists($n['xchan_hash'],$a->contacts)) + $friends[] = $n; + else + $others[] = $n; + } + } + + $a->data = array_merge($friends,$others); if(! $a->data) { notice( t('No ratings') . EOL); diff --git a/mod/ratingsearch.php b/mod/ratingsearch.php index 9a537bf97..ec2db570b 100644 --- a/mod/ratingsearch.php +++ b/mod/ratingsearch.php @@ -42,7 +42,7 @@ function ratingsearch_init(&$a) { $ret['success'] = true; $r = q("select * from xlink left join xchan on xlink_xchan = xchan_hash - where xlink_link = '%s' and xlink_rating != 0 and xlink_static = 1", + where xlink_link = '%s' and xlink_rating != 0 and xlink_static = 1 order by xchan_name asc", dbesc($p[0]['xchan_hash']) ); -- cgit v1.2.3 From 127bf82187c266c2202fd33003e60b5061778cd7 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 23:30:07 -0800 Subject: probably enough for now - couldn't get the censorship filter in today, I think that's the only bit missing. --- mod/directory.php | 1 + mod/ratings.php | 2 +- view/tpl/direntry.tpl | 12 ++++++------ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mod/directory.php b/mod/directory.php index 40ca93af9..f19b1142e 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -277,6 +277,7 @@ function directory_content(&$a) { 'keywords' => $out, 'ignlink' => $suggest ? $a->get_baseurl() . '/directory?ignore=' . $rr['hash'] : '', 'ignore_label' => "Don't suggest", + 'safe' => $safe_mode ); $arr = array('contact' => $rr, 'entry' => $entry); diff --git a/mod/ratings.php b/mod/ratings.php index 66392fe2b..fe7865778 100644 --- a/mod/ratings.php +++ b/mod/ratings.php @@ -55,7 +55,7 @@ function ratings_init(&$a) { if($results['ratings']) { foreach($results['ratings'] as $n) { - if(array_key_exists($n['xchan_hash'],$a->contacts)) + if(is_array($a->contacts) && array_key_exists($n['xchan_hash'],$a->contacts)) $friends[] = $n; else $others[] = $n; diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl index b0a1084e8..db098baa1 100755 --- a/view/tpl/direntry.tpl +++ b/view/tpl/direntry.tpl @@ -1,8 +1,8 @@ -
+
-
-
-{{$entry.alttext}} +
+
+{{$entry.alttext}} {{if $entry.connect}} {{/if}} @@ -13,10 +13,10 @@
-
{{$entry.name}}{{if $entry.online}} {{/if}}
+
{{$entry.name}}{{if $entry.online}} {{/if}}
{{if $entry.viewrate}} -
{{if $entry.total_ratings}}{{/if}} +
{{if $entry.total_ratings}}{{/if}} {{if $entry.canrate}}{{/if}}
{{/if}} -- cgit v1.2.3 From 0357180164d9805ded2d00157d74b4b42b9d1055 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 23:33:06 -0800 Subject: remove extra debugging --- mod/connedit.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mod/connedit.php b/mod/connedit.php index 58366da6d..2c4c0cef8 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -574,12 +574,11 @@ function connedit_content(&$a) { $rating_val = 0; $rating_text = ''; -dbg(1); $xl = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1", dbesc($channel['channel_hash']), dbesc($contact['xchan_hash']) ); -dbg(0); + if($xl) { $rating_val = intval($xl[0]['xlink_rating']); $rating_text = $xl[0]['xlink_rating_text']; -- cgit v1.2.3 From 1ceb0a7fbab5957ae077ef4867266314c612f8ea Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Feb 2015 23:36:37 -0800 Subject: hide channel address in directory from hovertip if not logged into the matrix --- mod/directory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/directory.php b/mod/directory.php index f19b1142e..329e255cf 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -252,7 +252,7 @@ function directory_content(&$a) { 'public_forum' => $rr['public_forum'], 'photo' => $rr['photo'], 'hash' => $rr['hash'], - 'alttext' => $rr['name'] . ' ' . $rr['address'], + 'alttext' => $rr['name'] . ((local_channel() || remote_channel()) ? ' ' . $rr['address'] : ''), 'name' => $rr['name'], 'details' => $pdesc . $details, 'profile' => $profile, -- cgit v1.2.3 From e5849f9432c76697c1db7758e5c1b31a788052a4 Mon Sep 17 00:00:00 2001 From: marijus Date: Wed, 4 Feb 2015 22:55:22 +0100 Subject: not quite there yet but getting closer a little --- include/attach.php | 88 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 28 deletions(-) diff --git a/include/attach.php b/include/attach.php index 7ebc4489d..a300e34b0 100644 --- a/include/attach.php +++ b/include/attach.php @@ -966,6 +966,10 @@ function pipe_streams($in, $out) { function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $no_activity) { + require_once('include/items.php'); + + $poster = get_app()->get_observer(); + //if we got no object something went wrong if(!$object) return; @@ -975,6 +979,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, //do not send activity for folders for now if($is_dir) return; + /* //check for recursive perms if we are in a folder if($object['folder']) { @@ -983,22 +988,14 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $r_perms = check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash); - $allow_cid = $r_perms['allow_cid']; - $allow_gid = $r_perms['allow_gid']; - $deny_cid = $r_perms['deny_cid']; - $deny_gid = $r_perms['deny_gid']; - - if(!$allow_gid && !$allow_cid) { - notice( t('Allowed permissions for this file are not recursive. None of your allowed contacts will have access to this file.') . EOL); - $verb = 'update'; - $update = true; - } + $allow_cid = perms2str($r_perms['allow_cid']); + $allow_gid = perms2str($r_perms['allow_gid']); + $deny_cid = perms2str($r_perms['deny_cid']); + $deny_gid = perms2str($r_perms['deny_gid']); } */ - require_once('include/items.php'); - $poster = get_app()->get_observer(); $mid = item_message_id(); @@ -1162,40 +1159,75 @@ function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $fo $arr_deny_cid = expand_acl($deny_cid); $arr_deny_gid = expand_acl($deny_gid); + $count = 0; while($folder_hash) { - $x = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid, folder FROM attach WHERE hash = '%s'", + $x = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid, folder FROM attach WHERE hash = '%s' LIMIT 1", dbesc($folder_hash) ); - $parents_arr_allow_cid[] = expand_acl($x[0]['allow_cid']); - $parents_arr_allow_gid[] = expand_acl($x[0]['allow_gid']); - $parents_arr_deny_cid[] = expand_acl($x[0]['deny_cid']); - $parents_arr_deny_gid[] = expand_acl($x[0]['deny_gid']); + //only process private folders + if($x[0]['allow_cid'] || $x[0]['allow_gid'] || $x[0]['deny_cid'] || $x[0]['deny_gid']) { + + $parent_arr['allow_cid'][] = expand_acl($x[0]['allow_cid']); + $parent_arr['allow_gid'][] = expand_acl($x[0]['allow_gid']); + $parent_arr['deny_cid'][] = expand_acl($x[0]['deny_cid']); + $parent_arr['deny_gid'][] = expand_acl($x[0]['deny_gid']); + + $parents_arr = $parent_arr; + + $count++; + + } $folder_hash = $x[0]['folder']; + } - foreach($parents_arr_allow_gid as $folder_arr_allow_gid) { - $arr_allow_gid = array_intersect($arr_allow_gid, $folder_arr_allow_gid); + //if there are no perms on the file we get them from the first parent folder + if(!$arr_allow_cid && !$arr_allow_gid && !$arr_deny_cid && !$arr_deny_gid) { + $arr_allow_cid = $parent_arr['allow_cid'][0]; + $arr_allow_gid = $parent_arr['allow_gid'][0]; + $arr_deny_cid = $parent_arr['deny_cid'][0]; + $arr_deny_gid = $parent_arr['deny_gid'][0]; } - foreach($parents_arr_allow_cid as $folder_arr_allow_cid) { - $arr_allow_cid = array_intersect($arr_allow_cid, $folder_arr_allow_cid); + //allow_cid + foreach ($parents_arr['allow_cid'] as $folder_arr_allow_cid) { + foreach ($folder_arr_allow_cid as $ac_hash) { + $count_values[$ac_hash]++; + } + } + foreach ($arr_allow_cid as $fac_hash) { + if(($count_values[$fac_hash]) && ($count_values[$fac_hash] == $count)) + $r_arr_allow_cid[] = $fac_hash; } - foreach($parents_arr_deny_gid as $folder_arr_deny_gid) { + + //allow_gid + foreach ($parents_arr['allow_gid'] as $folder_arr_allow_gid) { + foreach ($folder_arr_allow_gid as $ag_hash) { + $count_values[$ag_hash]++; + } + } + foreach ($arr_allow_gid as $fag_hash) { + if(($count_values[$fag_hash]) && ($count_values[$fag_hash] == $count)) + $r_arr_allow_gid[] = $fag_hash; + } + + //deny_gid + foreach($parents_arr['deny_gid'] as $folder_arr_deny_gid) { $arr_deny_gid = array_merge($arr_deny_gid, $folder_arr_deny_gid); } - foreach($parents_arr_deny_cid as $folder_arr_deny_cid) { + //deny_cid + foreach($parents_arr['deny_cid'] as $folder_arr_deny_cid) { $arr_deny_cid = array_merge($arr_deny_cid, $folder_arr_deny_cid); } - $ret['allow_gid'] = perms2str($arr_allow_gid); - $ret['allow_cid'] = perms2str($arr_allow_cid); - $ret['deny_gid'] = perms2str(array_unique($arr_deny_gid)); - $ret['deny_cid'] = perms2str(array_unique($arr_deny_cid)); + $ret['allow_gid'] = $r_arr_allow_gid; + $ret['allow_cid'] = $r_arr_allow_cid; + $ret['deny_gid'] = array_unique($r_arr_deny_gid); + $ret['deny_cid'] = array_unique($r_arr_deny_cid); return $ret; - } -- cgit v1.2.3 From 398894851628ccb99090e9d70b92a9a909ef7015 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 15:48:39 -0800 Subject: first cut at rating widget. The flaw is that it is limited because it requires local_channel() (formerly local_user()). We need to extend this to take you home like rpost does if you're logged in as remote_channel() - and/or we need zot to send the rating message to the source channel and target in addition to the directories. --- include/identity.php | 6 ++++++ include/widgets.php | 27 +++++++++++++++++++++++++++ version.inc | 2 +- view/css/mod_directory.css | 21 --------------------- view/css/widgets.css | 24 ++++++++++++++++++++++++ view/pdl/mod_ratings.pdl | 1 + view/theme/redbasic/css/style.css | 23 +++++++++++++++++++++-- view/tpl/profile_vcard.tpl | 3 ++- 8 files changed, 82 insertions(+), 25 deletions(-) diff --git a/include/identity.php b/include/identity.php index 2fc183368..aef6471e5 100644 --- a/include/identity.php +++ b/include/identity.php @@ -943,6 +943,11 @@ logger('online: ' . $profile['online']); $tpl = get_markup_template('profile_vcard.tpl'); +// This isn't ideal here because it requires local_channel(). +// We need the rating widget to recognise and take you home if you're remote. +// require_once('include/widgets.php'); +// $z = widget_rating(array('target' => $profile['channel_hash'])); + $o .= replace_macros($tpl, array( '$profile' => $profile, '$connect' => $connect, @@ -954,6 +959,7 @@ logger('online: ' . $profile['online']); '$homepage' => $homepage, '$chanmenu' => $channel_menu, '$diaspora' => $diaspora, + '$rating' => $z, '$contact_block' => $contact_block, )); diff --git a/include/widgets.php b/include/widgets.php index 523318850..71407ad3d 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -903,3 +903,30 @@ function widget_random_block($arr) { return $o; } + + +function widget_rating($arr) { + $a = get_app(); + if(! local_channel()) + return; + + $channel = $a->get_channel(); + + if($arr['target']) + $hash = $arr['target']; + else + $hash = $a->poi['xchan_hash']; + + if(! $hash) + return; + + if($hash == $channel['channel_hash']) + return; + + head_add_js('ratings.js'); + + $o = '
'; + $o .= '
'; + return $o; + +} \ No newline at end of file diff --git a/version.inc b/version.inc index b7a74f141..8d8816a23 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-02-01.934 +2015-02-04.935 diff --git a/view/css/mod_directory.css b/view/css/mod_directory.css index c562764ea..7b149d744 100644 --- a/view/css/mod_directory.css +++ b/view/css/mod_directory.css @@ -6,27 +6,6 @@ float: left; width: 250px; } -.directory-rating { - float: right; - margin-right: 5px; -} - -.slider-container { - padding: 15px; -} - -.rating-text-label { - margin-top: 30px; -} - -.directory-rating-text { - width: 90%; - margin-left: 5%; -} - -.directory-rating-submit { - margin-top: 15px; -} .directory-photo { margin-left: 25px; diff --git a/view/css/widgets.css b/view/css/widgets.css index 4db87e633..43d132276 100644 --- a/view/css/widgets.css +++ b/view/css/widgets.css @@ -104,3 +104,27 @@ li:hover .group-edit-icon { .chatroomlist td { padding: 0 5px 0; } + +/* ratings */ + +.directory-rating { + float: right; + margin-right: 5px; +} + +.slider-container { + padding: 15px; +} + +.rating-text-label { + margin-top: 30px; +} + +.directory-rating-text { + width: 90%; + margin-left: 5%; +} + +.directory-rating-submit { + margin-top: 15px; +} diff --git a/view/pdl/mod_ratings.pdl b/view/pdl/mod_ratings.pdl index 3d40386cd..0b6e32283 100644 --- a/view/pdl/mod_ratings.pdl +++ b/view/pdl/mod_ratings.pdl @@ -1,5 +1,6 @@ [region=aside] [widget=vcard][/widget] +[widget=rating][/widget] [widget=suggestions][/widget] [widget=findpeople][/widget] [/region] diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index cb58b6e11..32ded75ba 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -771,6 +771,19 @@ footer { clear: both; } +div.rateme { + display: block; + color: $nav_active_icon_colour; + background-color: $nav_bg; + -webkit-border-radius: $radiuspx ; + -moz-border-radius: $radiuspx; + border-radius: $radiuspx; + border: 1px solid $nav_bd; + padding: 5px; + font-weight: bold; + clear: both; +} + #pause { position: fixed; bottom: 5px; @@ -1442,16 +1455,22 @@ div.jGrowl div.jGrowl-notification { width: 90%; } -a.rconnect { +a.rconnect, div.rateme { color: $nav_active_icon_colour; text-decoration: none; + font-weight: normal; outline: none; } -a.rconnect:hover { +a.rconnect:hover, div.rateme:hover { color: #0080FF; + text-decoration: none; } +.widget.rateme { + margin-top: 15px; + padding: 0; +} /* header */ header { diff --git a/view/tpl/profile_vcard.tpl b/view/tpl/profile_vcard.tpl index bff3148f3..bc093ebb5 100755 --- a/view/tpl/profile_vcard.tpl +++ b/view/tpl/profile_vcard.tpl @@ -50,10 +50,11 @@ {{if $connect}} {{$connect}} {{/if}} - +
+ {{$chanmenu}} {{$contact_block}} -- cgit v1.2.3 From 48a145a8ed341c1f28f941be2eaab053c172e3f1 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 15:52:12 -0800 Subject: add the required js file --- view/js/ratings.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 view/js/ratings.js diff --git a/view/js/ratings.js b/view/js/ratings.js new file mode 100644 index 000000000..3d48ecca5 --- /dev/null +++ b/view/js/ratings.js @@ -0,0 +1,34 @@ + +var ratingVal = 0; +var ratingText = ''; +var currentHash = ''; + +function fetchRatings(hash) { + $.get('prate/'+hash, function(data) { + if(typeof(data.rating) !== 'undefined') { + ratingVal = data.rating; + ratingText = data.rating_text; + } + buildRatingForm(hash); + }); +} + + +function doRatings(hash) { + fetchRatings(hash); +} + +function buildRatingForm(hash) { + var html = '
'+aStr['rating_desc']+'
'+aStr['rating_text']+'
'; + + $.colorbox({maxwidth: "50%", maxHeight: "50%", html: html, close: 'X' }); + currentHash = hash; +} + +function postRatings() { + $.post('prate',$('#ratings_form').serialize(),function(data) { + $.colorbox.remove(); + $('#edited-'+currentHash).show(); + },'json'); +} + -- cgit v1.2.3 From 561bab4ece9fa5844a0cb00f3cbd75e0855b2796 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 17:32:29 -0800 Subject: remote rating and addition of rate-me to channel profile sidebar --- include/identity.php | 6 +- include/widgets.php | 38 +++++++-- mod/rate.php | 158 ++++++++++++++++++++++++++++++++++++++ view/css/mod_rate.css | 8 ++ view/pdl/mod_rate.pdl | 3 + view/theme/redbasic/css/style.css | 6 +- view/tpl/profile_vcard.tpl | 2 + view/tpl/rating_form.tpl | 22 ++++++ 8 files changed, 228 insertions(+), 15 deletions(-) create mode 100644 mod/rate.php create mode 100644 view/css/mod_rate.css create mode 100644 view/pdl/mod_rate.pdl create mode 100644 view/tpl/rating_form.tpl diff --git a/include/identity.php b/include/identity.php index aef6471e5..415e85f2f 100644 --- a/include/identity.php +++ b/include/identity.php @@ -943,10 +943,8 @@ logger('online: ' . $profile['online']); $tpl = get_markup_template('profile_vcard.tpl'); -// This isn't ideal here because it requires local_channel(). -// We need the rating widget to recognise and take you home if you're remote. -// require_once('include/widgets.php'); -// $z = widget_rating(array('target' => $profile['channel_hash'])); + require_once('include/widgets.php'); + $z = widget_rating(array('target' => $profile['channel_hash'])); $o .= replace_macros($tpl, array( '$profile' => $profile, diff --git a/include/widgets.php b/include/widgets.php index 71407ad3d..7d2aaeb99 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -907,10 +907,6 @@ function widget_random_block($arr) { function widget_rating($arr) { $a = get_app(); - if(! local_channel()) - return; - - $channel = $a->get_channel(); if($arr['target']) $hash = $arr['target']; @@ -920,13 +916,39 @@ function widget_rating($arr) { if(! $hash) return; - if($hash == $channel['channel_hash']) - return; + $url = ''; + $remote = false; + + if(remote_channel() && ! local_channel()) { + $ob = $a->get_observer(); + if($ob && $ob['xchan_url']) { + $p = parse_url($ob['xchan_url']); + if($p) { + $url = $p['scheme'] . '://' . $p['host'] . (($p['port']) ? ':' . $p['port'] : ''); + $url .= '/rate?f=&target=' . urlencode($hash); + } + $remote = true; + } + } - head_add_js('ratings.js'); + if(local_channel()) { + $channel = $a->get_channel(); + + if($hash == $channel['channel_hash']) + return; + + head_add_js('ratings.js'); + + } + + if((! $remote) && (! local_channel())) + return; $o = '
'; - $o .= '
'; + if($remote) + $o .= ' ' . t('Rate Me') . '
'; + else + $o .= '
'; return $o; } \ No newline at end of file diff --git a/mod/rate.php b/mod/rate.php new file mode 100644 index 000000000..694b88ddd --- /dev/null +++ b/mod/rate.php @@ -0,0 +1,158 @@ +get_channel(); + + $target = $_REQUEST['target']; + if(! $target) + return; + + $a->data['target'] = $target; + + if($target) { + $r = q("SELECT * FROM xchan where xchan_hash like '%s' LIMIT 1", + dbesc($target) + ); + if($r) { + $a->poi = $r[0]; + } + } + + + return; + +} + + +function rate_post(&$a) { + + if(! local_channel()) + return; + + if(! $a->data['target']) + return; + + if(! $_REQUEST['execute']) + return; + + $channel = $a->get_channel(); + + $rating = intval($_POST['rating']); + if($rating < (-10)) + $rating = (-10); + if($rating > 10) + $rating = 10; + + $rating_text = trim(escape_tags($_REQUEST['rating_text'])); + + $signed = $a->data['target'] . '.' . $rating . '.' . $rating_text; + + $sig = base64url_encode(rsa_sign($signed,$channel['channel_prvkey'])); + + $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1", + dbesc($channel['channel_hash']), + dbesc($a->data['target']) + ); + + if($z) { + $record = $z[0]['xlink_id']; + $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s' + where xlink_id = %d", + intval($rating), + dbesc($rating_text), + dbesc($sig), + dbesc(datetime_convert()), + intval($record) + ); + } + else { + $w = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_sig, xlink_updated, xlink_static ) values ( '%s', '%s', %d, '%s', '%s', '%s', 1 ) ", + dbesc($channel['channel_hash']), + dbesc($a->data['target']), + intval($rating), + dbesc($rating_text), + dbesc($sig), + dbesc(datetime_convert()) + ); + $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1", + dbesc($channel['channel_hash']), + dbesc($a->data['target']) + ); + if($z) + $record = $z[0]['xlink_id']; + } + + if($record) { + proc_run('php','include/ratenotif.php','rating',$record); + } + +} + + + +function rate_content(&$a) { + + if(! local_channel()) { + notice( t('Permission denied.') . EOL); + return; + } + +// if(! $a->data['target']) { +// notice( t('No recipients.') . EOL); +// return; +// } + + $poco_rating = get_config('system','poco_rating_enable'); + if((! $poco_rating) && ($poco_rating !== false)) { + notice('Ratings are disabled on this site.'); + return; + } + + $channel = $a->get_channel(); + + $r = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1", + dbesc($channel['channel_hash']), + dbesc($a->data['target']) + ); + if($r) + $a->data['xlink'] = $r[0]; + + $rating_val = $r[0]['xlink_rating']; + $rating_text = $r[0]['xlink_rating_text']; + + + // if unset default to enabled + if($poco_rating === false) + $poco_rating = true; + + if($poco_rating) { + $rating = replace_macros(get_markup_template('rating_slider.tpl'),array( + '$min' => -10, + '$val' => $rating_val + )); + } + else { + $rating = false; + } + + $o = replace_macros(get_markup_template('rating_form.tpl'),array( + '$header' => t('Rating'), + 'target' => $a->data['target'], + '$tgt_name' => (($a->poi && $a->poi['xchan_name']) ? $a->poi['xchan_name'] : sprintf( t('Remote Channel [%s] (not yet known on this site)'), substr($a->data['target'],0,16))), + '$lbl_rating' => t('Rating (this information is public)'), + '$lbl_rating_txt' => t('Optionally explain your rating (this information is public)'), + '$rating_txt' => $rating_text, + '$rating' => $rating, + '$rating_val' => $rating_val, + '$slide' => $slide, + '$submit' => t('Submit') + )); + + return $o; + +} \ No newline at end of file diff --git a/view/css/mod_rate.css b/view/css/mod_rate.css new file mode 100644 index 000000000..58e87b9b4 --- /dev/null +++ b/view/css/mod_rate.css @@ -0,0 +1,8 @@ +#rating-slider { + width: 600px !important; +} + +#rating-text { + width: 400px; + height: 60px; +} diff --git a/view/pdl/mod_rate.pdl b/view/pdl/mod_rate.pdl new file mode 100644 index 000000000..d8f50ad7a --- /dev/null +++ b/view/pdl/mod_rate.pdl @@ -0,0 +1,3 @@ +[region=aside] +[widget=vcard][/widget] +[/region] diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 32ded75ba..1aa7cc729 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -771,7 +771,7 @@ footer { clear: both; } -div.rateme { +a.rateme, div.rateme { display: block; color: $nav_active_icon_colour; background-color: $nav_bg; @@ -1455,14 +1455,14 @@ div.jGrowl div.jGrowl-notification { width: 90%; } -a.rconnect, div.rateme { +a.rconnect, a.rateme, div.rateme { color: $nav_active_icon_colour; text-decoration: none; font-weight: normal; outline: none; } -a.rconnect:hover, div.rateme:hover { +a.rconnect:hover, a.rateme:hover, div.rateme:hover { color: #0080FF; text-decoration: none; } diff --git a/view/tpl/profile_vcard.tpl b/view/tpl/profile_vcard.tpl index bc093ebb5..cae920c5d 100755 --- a/view/tpl/profile_vcard.tpl +++ b/view/tpl/profile_vcard.tpl @@ -51,6 +51,8 @@ {{$connect}} {{/if}} +{{$rating}} +
diff --git a/view/tpl/rating_form.tpl b/view/tpl/rating_form.tpl new file mode 100644 index 000000000..216bf6ede --- /dev/null +++ b/view/tpl/rating_form.tpl @@ -0,0 +1,22 @@ +

{{$header}}

+ +
{{$tgt_name}}
+ +

{{$lbl_rating}}

+ +
+ +{{$rating}} + + + + + +

{{$lbl_rating_txt}}

+ + +
+ + + +
\ No newline at end of file -- cgit v1.2.3 From 24b198a50c54736ad137a342c30814033b27eff7 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 17:34:53 -0800 Subject: honour the rating enable setting (which we really do need to rename since it isn't poco any more) --- include/widgets.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/widgets.php b/include/widgets.php index 7d2aaeb99..5eda9008b 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -908,6 +908,11 @@ function widget_random_block($arr) { function widget_rating($arr) { $a = get_app(); + $poco_rating = get_config('system','poco_rating_enable'); + if((! $poco_rating) && ($poco_rating !== false)) { + return; + } + if($arr['target']) $hash = $arr['target']; else -- cgit v1.2.3 From 6e84dbe493a660b391c519c331aaa79878adf933 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 18:18:04 -0800 Subject: add 'view ratings' to the widget. It's actually two stacked widgets rather than a widget with two entries. That's the only way we can keep the theming consistent with the rconnect button. --- include/widgets.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/widgets.php b/include/widgets.php index 5eda9008b..a94bf03dc 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -951,9 +951,13 @@ function widget_rating($arr) { $o = '
'; if($remote) - $o .= ' ' . t('Rate Me') . '
'; + $o .= ' ' . t('Rate Me') . ''; else - $o .= '
'; + $o .= ''; + + $o .= '
'; + return $o; } \ No newline at end of file -- cgit v1.2.3 From 24355430a8ca8420aa0c1d42e9c38932d1cd54f7 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 18:26:59 -0800 Subject: allow anybody to view ratings - including oneself. Only allow authenticated folks to edit them. --- include/widgets.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/widgets.php b/include/widgets.php index a94bf03dc..e995b213f 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -946,16 +946,16 @@ function widget_rating($arr) { } - if((! $remote) && (! local_channel())) - return; - - $o = '
'; - if($remote) - $o .= ' ' . t('Rate Me') . ''; - else - $o .= ''; + if(($remote) || (local_channel())) { + $o = '
'; + if($remote) + $o .= ' ' . t('Rate Me') . ''; + else + $o .= ''; + $o .= '
'; + } - $o .= '
' . t('View Ratings') . ''; + $o .= ''; return $o; -- cgit v1.2.3 From 5a0ccbfcf375acad49a0f7e818fe5611c2f858cc Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 18:31:12 -0800 Subject: forgot to add the self exclusion --- include/widgets.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/widgets.php b/include/widgets.php index e995b213f..d457db07d 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -936,17 +936,19 @@ function widget_rating($arr) { } } + $self = false; + if(local_channel()) { $channel = $a->get_channel(); if($hash == $channel['channel_hash']) - return; + $self = true; head_add_js('ratings.js'); } - if(($remote) || (local_channel())) { + if((($remote) || (local_channel())) && (! $self)) { $o = '
'; if($remote) $o .= ' ' . t('Rate Me') . ''; -- cgit v1.2.3 From 646a874390be8f92736866118d7215e8cb80fb8a Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Feb 2015 20:28:36 -0800 Subject: diaspora public posts not delivering to sys channel if there were no other subscribers --- include/diaspora.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index ada90e476..8047d0e64 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -35,11 +35,16 @@ function diaspora_dispatch_public($msg) { logger('diaspora_public: delivering to: ' . $rr['channel_name'] . ' (' . $rr['channel_address'] . ') '); diaspora_dispatch($rr,$msg); } - if($sys) - diaspora_dispatch($sys,$msg); } - else - logger('diaspora_public: no subscribers'); + else { + if(! $sys) + logger('diaspora_public: no subscribers'); + } + + if($sys) { + logger('diaspora_public: delivering to sys.'); + diaspora_dispatch($sys,$msg); + } } -- cgit v1.2.3 From 84843984b8c80a2d60394d466a17b821bfb867d7 Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Thu, 5 Feb 2015 09:14:24 -0800 Subject: typo/cleanup pg only --- install/update.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/install/update.php b/install/update.php index 597da4e3b..2ea64bc37 100644 --- a/install/update.php +++ b/install/update.php @@ -1515,10 +1515,11 @@ function update_r1133() { xp_client varchar( 20 ) NOT NULL DEFAULT '', xp_channel bigint NOT NULL DEFAULT '0', xp_perm varchar( 64 ) NOT NULL DEFAULT '', - PRIMARY KEY (\"xp_id\") )"); - $r2 = q("create index \"xp_client\" on xperm (\"xp_client\", - create index \"xp_channel\" on xperm (\"xp_channel\"), - create index \"xp_perm\" on xperm (\"xp_perm\") "); + PRIMARY KEY (xp_id) )"); + $r2 = 0; + foreach(array('xp_client', 'xp_channel', 'xp_perm') as $fld) + $r2 += (empty(q("create index $fld on xperm ($fld)")) ? 0 : 1); + $r = (($r1 && $r2) ? true : false); } else { -- cgit v1.2.3 From 88488fdfbb58aa04b450af1691aba7cea1bce8ab Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Thu, 5 Feb 2015 09:15:26 -0800 Subject: escape dates --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index 04b6806c2..5faabd5ec 100644 --- a/include/zot.php +++ b/include/zot.php @@ -420,7 +420,7 @@ function zot_refresh($them,$channel = null, $force = false) { where abook_xchan = '%s' and abook_channel = %d and not (abook_flags & %d) > 0 ", intval($their_perms), - dbesc($next_birthday), + dbescdate($next_birthday), dbesc($x['hash']), intval($channel['channel_id']), intval(ABOOK_FLAG_SELF) -- cgit v1.2.3 From be0e6ed6d7467991b51f40266ad9a149cdcda247 Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 5 Feb 2015 21:16:21 +0100 Subject: make file activity respect parent dir permissions work --- include/attach.php | 88 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 22 deletions(-) diff --git a/include/attach.php b/include/attach.php index a300e34b0..38fe3173b 100644 --- a/include/attach.php +++ b/include/attach.php @@ -980,13 +980,14 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, if($is_dir) return; -/* //check for recursive perms if we are in a folder if($object['folder']) { $folder_hash = $object['folder']; - $r_perms = check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash); + $r_perms = recursive_activity_recipients($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash); + + print_r($r_perms); killme(); $allow_cid = perms2str($r_perms['allow_cid']); $allow_gid = perms2str($r_perms['allow_gid']); @@ -994,8 +995,6 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid = perms2str($r_perms['deny_gid']); } -*/ - $mid = item_message_id(); @@ -1147,12 +1146,13 @@ function get_file_activity_object($channel_id, $hash, $cloudpath) { 'created' => $x[0]['created'], 'edited' => $x[0]['edited'] ); - return $object; } -function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash) { +function recursive_activity_recipients($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash) { + + $poster = get_app()->get_observer(); $arr_allow_cid = expand_acl($allow_cid); $arr_allow_gid = expand_acl($allow_gid); @@ -1170,11 +1170,19 @@ function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $fo $parent_arr['allow_cid'][] = expand_acl($x[0]['allow_cid']); $parent_arr['allow_gid'][] = expand_acl($x[0]['allow_gid']); + + //TODO: should find a much better solution for the allow_cid <-> allow_gid problem. + //Do not use allow_gid for now. Instead lookup the members of the group directly and add them to allow_cid. + if($parent_arr['allow_gid']) { + foreach($parent_arr['allow_gid'][$count] as $gid) { + $in_group = in_group($gid); + $parent_arr['allow_cid'][$count] = array_unique(array_merge($parent_arr['allow_cid'][$count], $in_group)); + } + } + $parent_arr['deny_cid'][] = expand_acl($x[0]['deny_cid']); $parent_arr['deny_gid'][] = expand_acl($x[0]['deny_gid']); - $parents_arr = $parent_arr; - $count++; } @@ -1183,6 +1191,16 @@ function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $fo } + //if none of the parent folders is private just return file perms + if(!$parent_arr['allow_cid'] && !$parent_arr['allow_gid'] && !$parent_arr['deny_cid'] && !$parent_arr['deny_gid']) { + $ret['allow_gid'] = $arr_allow_gid; + $ret['allow_cid'] = $arr_allow_cid; + $ret['deny_gid'] = $arr_deny_gid; + $ret['deny_cid'] = $arr_deny_cid; + + return $ret; + } + //if there are no perms on the file we get them from the first parent folder if(!$arr_allow_cid && !$arr_allow_gid && !$arr_deny_cid && !$arr_deny_gid) { $arr_allow_cid = $parent_arr['allow_cid'][0]; @@ -1192,42 +1210,68 @@ function check_recursive_perms($allow_cid, $allow_gid, $deny_cid, $deny_gid, $fo } //allow_cid - foreach ($parents_arr['allow_cid'] as $folder_arr_allow_cid) { + $r_arr_allow_cid = false; + foreach ($parent_arr['allow_cid'] as $folder_arr_allow_cid) { foreach ($folder_arr_allow_cid as $ac_hash) { $count_values[$ac_hash]++; } } foreach ($arr_allow_cid as $fac_hash) { - if(($count_values[$fac_hash]) && ($count_values[$fac_hash] == $count)) + if($count_values[$fac_hash] == $count) $r_arr_allow_cid[] = $fac_hash; } - //allow_gid - foreach ($parents_arr['allow_gid'] as $folder_arr_allow_gid) { + $r_arr_allow_gid = false; + foreach ($parent_arr['allow_gid'] as $folder_arr_allow_gid) { foreach ($folder_arr_allow_gid as $ag_hash) { $count_values[$ag_hash]++; } } foreach ($arr_allow_gid as $fag_hash) { - if(($count_values[$fag_hash]) && ($count_values[$fag_hash] == $count)) + if($count_values[$fag_hash] == $count) $r_arr_allow_gid[] = $fag_hash; } //deny_gid - foreach($parents_arr['deny_gid'] as $folder_arr_deny_gid) { - $arr_deny_gid = array_merge($arr_deny_gid, $folder_arr_deny_gid); + foreach($parent_arr['deny_gid'] as $folder_arr_deny_gid) { + $r_arr_deny_gid = array_merge($arr_deny_gid, $folder_arr_deny_gid); } + $r_arr_deny_gid = array_unique($r_arr_deny_gid); //deny_cid - foreach($parents_arr['deny_cid'] as $folder_arr_deny_cid) { - $arr_deny_cid = array_merge($arr_deny_cid, $folder_arr_deny_cid); + foreach($parent_arr['deny_cid'] as $folder_arr_deny_cid) { + $r_arr_deny_cid = array_merge($arr_deny_cid, $folder_arr_deny_cid); + } + $r_arr_deny_cid = array_unique($r_arr_deny_cid); + + //if none is allowed restrict to self + if(($r_arr_allow_gid === false) && ($r_arr_allow_gid === false)) { + $ret['allow_cid'] = $poster['xchan_hash']; + } else { + $ret['allow_gid'] = $r_arr_allow_gid; + $ret['allow_cid'] = $r_arr_allow_cid; + $ret['deny_gid'] = $r_arr_deny_gid; + $ret['deny_cid'] = $r_arr_deny_cid; } - - $ret['allow_gid'] = $r_arr_allow_gid; - $ret['allow_cid'] = $r_arr_allow_cid; - $ret['deny_gid'] = array_unique($r_arr_deny_gid); - $ret['deny_cid'] = array_unique($r_arr_deny_cid); return $ret; + +} + +function in_group($group_id) { + //TODO: make these two queries one with a join. + $x = q("SELECT id FROM groups WHERE hash = '%s'", + dbesc($group_id) + ); + + $r = q("SELECT xchan FROM group_member WHERE gid = %d", + intval($x[0]['id']) + ); + + foreach($r as $ig) { + $group_members[] = $ig['xchan']; + } + + return $group_members; } -- cgit v1.2.3 From 1d5321798af534368a6f902a109f8efd3c53bd6b Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 5 Feb 2015 21:31:05 +0100 Subject: forgot to remove some debug stuff --- include/attach.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/attach.php b/include/attach.php index 38fe3173b..1b89480b3 100644 --- a/include/attach.php +++ b/include/attach.php @@ -987,8 +987,6 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $r_perms = recursive_activity_recipients($allow_cid, $allow_gid, $deny_cid, $deny_gid, $folder_hash); - print_r($r_perms); killme(); - $allow_cid = perms2str($r_perms['allow_cid']); $allow_gid = perms2str($r_perms['allow_gid']); $deny_cid = perms2str($r_perms['deny_cid']); -- cgit v1.2.3 From 1abb17c88050264168b6e6ff493e73ecd12706c1 Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 5 Feb 2015 21:46:46 +0100 Subject: typo --- include/attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/attach.php b/include/attach.php index 1b89480b3..f61fea9a5 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1244,7 +1244,7 @@ function recursive_activity_recipients($allow_cid, $allow_gid, $deny_cid, $deny_ $r_arr_deny_cid = array_unique($r_arr_deny_cid); //if none is allowed restrict to self - if(($r_arr_allow_gid === false) && ($r_arr_allow_gid === false)) { + if(($r_arr_allow_gid === false) && ($r_arr_allow_cid === false)) { $ret['allow_cid'] = $poster['xchan_hash']; } else { $ret['allow_gid'] = $r_arr_allow_gid; -- cgit v1.2.3 From 331c72b3be4e6b2c469d14be2bd4d057e7de1dec Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Feb 2015 14:46:08 -0800 Subject: author profile photo in reshare wasn't linked --- include/bbcode.php | 2 +- version.inc | 2 +- view/theme/redbasic/css/style.css | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 7067fcd39..8f2b5bd38 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -216,7 +216,7 @@ function bb_ShareAttributes($match) { $headline = '
'; if ($avatar != "") - $headline .= '' . $author . ''; + $headline .= '' . $author . ''; // Bob Smith wrote the following post 2 hours ago diff --git a/version.inc b/version.inc index 8d8816a23..c06a0d149 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-02-04.935 +2015-02-05.936 diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 1aa7cc729..4afeac0b0 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -162,6 +162,18 @@ header { filter:alpha(opacity=$nav_percent_min_opacity); } +/* experimental - increase size of notification counts on hover + * to make the notification dropdowns more accessible on portable devices. + * Currently they are mostly inaccessible without using huge magnifications. + * The question is if you can actually hover on a portable touchscreen device. + +.badge.dropdown-toggle:hover { + width: 2rem; + height: 2rem; +} + +*/ + #powered-by { font-size: 0.5rem; position: absolute; -- cgit v1.2.3 From 1b5bd1d808637696b31f197c2b2194f00b903952 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Feb 2015 15:11:51 -0800 Subject: increase size of rating value to make it stand out a bit. --- view/css/mod_ratings.css | 5 +++++ view/theme/redbasic/css/style.css | 12 ------------ view/tpl/prep.tpl | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/view/css/mod_ratings.css b/view/css/mod_ratings.css index 86d6f5ed3..c9f75c58c 100644 --- a/view/css/mod_ratings.css +++ b/view/css/mod_ratings.css @@ -13,4 +13,9 @@ .rating-value { margin-top: 10px; +} + +.prep-rating-value { + margin-left: 10px; + font-size: 1.5rem; } \ No newline at end of file diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 4afeac0b0..1aa7cc729 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -162,18 +162,6 @@ header { filter:alpha(opacity=$nav_percent_min_opacity); } -/* experimental - increase size of notification counts on hover - * to make the notification dropdowns more accessible on portable devices. - * Currently they are mostly inaccessible without using huge magnifications. - * The question is if you can actually hover on a portable touchscreen device. - -.badge.dropdown-toggle:hover { - width: 2rem; - height: 2rem; -} - -*/ - #powered-by { font-size: 0.5rem; position: absolute; diff --git a/view/tpl/prep.tpl b/view/tpl/prep.tpl index 924bea252..9ebe3ac54 100644 --- a/view/tpl/prep.tpl +++ b/view/tpl/prep.tpl @@ -12,7 +12,7 @@
{{$r.xchan_name}}
-
{{$rating_lbl}} {{$r.xlink_rating}}
+
{{$rating_lbl}} {{$r.xlink_rating}}
{{if $r.xlink_rating_text}}
{{$rating_text_label}} {{$r.xlink_rating_text}}
-- cgit v1.2.3 From 68978ad1c08daeb55581b95b4328905df42c847b Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Feb 2015 15:28:46 -0800 Subject: collapse overly-verbose ratings --- view/js/mod_ratings.js | 4 ++++ view/tpl/prep.tpl | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 view/js/mod_ratings.js diff --git a/view/js/mod_ratings.js b/view/js/mod_ratings.js new file mode 100644 index 000000000..0f7cab5e3 --- /dev/null +++ b/view/js/mod_ratings.js @@ -0,0 +1,4 @@ + +$(document).ready(function() { + collapseHeight(); +}); diff --git a/view/tpl/prep.tpl b/view/tpl/prep.tpl index 9ebe3ac54..83a86372c 100644 --- a/view/tpl/prep.tpl +++ b/view/tpl/prep.tpl @@ -10,7 +10,7 @@ {{$r.xchan_addr}}
-
+
{{$r.xchan_name}}
{{$rating_lbl}} {{$r.xlink_rating}}
{{if $r.xlink_rating_text}} -- cgit v1.2.3 From 153719a20a88b8d4e9c562b185f94e1af72de1de Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Feb 2015 16:13:26 -0800 Subject: another issue with diaspora postings to sys channel - sys has no connections, hence no abook records. --- include/diaspora.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index 8047d0e64..0e275a079 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -272,8 +272,6 @@ function diaspora_process_outbound($arr) { } - - function diaspora_handle_from_contact($contact_hash) { logger("diaspora_handle_from_contact: contact id is " . $contact_hash, LOGGER_DEBUG); @@ -291,11 +289,21 @@ function diaspora_get_contact_by_handle($uid,$handle) { if(diaspora_is_blacklisted($handle)) return false; + require_once('include/identity.php'); + + $sys = get_sys_channel(); + if(($sys) && ($sys['channel_id'] == $uid)) { + $r = q("SELECT * FROM xchan where xchan_addr = '%s' limit 1", + dbesc($handle) + ); + } + else { + $r = q("SELECT * FROM abook left join xchan on xchan_hash = abook_xchan where xchan_addr = '%s' and abook_channel = %d limit 1", + dbesc($handle), + intval($uid) + ); + } - $r = q("SELECT * FROM abook left join xchan on xchan_hash = abook_xchan where xchan_addr = '%s' and abook_channel = %d limit 1", - dbesc($handle), - intval($uid) - ); return (($r) ? $r[0] : false); } -- cgit v1.2.3 From fe8a08a47482dabe1a406ca41a02dc058f25f92a Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Feb 2015 17:29:35 -0800 Subject: over-ride permissions for sys channel delivery from diaspora --- include/diaspora.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index 0e275a079..736be4f08 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -42,6 +42,7 @@ function diaspora_dispatch_public($msg) { } if($sys) { + $sys['system'] = true; logger('diaspora_public: delivering to sys.'); diaspora_dispatch($sys,$msg); } @@ -49,10 +50,13 @@ function diaspora_dispatch_public($msg) { -function diaspora_dispatch($importer,$msg,$attempt=1) { +function diaspora_dispatch($importer,$msg) { $ret = 0; + if(! array_key_exists('system',$importer)) + $importer['system'] = false; + $enabled = intval(get_config('system','diaspora_enabled')); if(! $enabled) { logger('mod-diaspora: disabled'); @@ -105,7 +109,7 @@ function diaspora_dispatch($importer,$msg,$attempt=1) { $ret = diaspora_signed_retraction($importer,$xmlbase->relayable_retraction,$msg); } elseif($xmlbase->photo) { - $ret = diaspora_photo($importer,$xmlbase->photo,$msg,$attempt); + $ret = diaspora_photo($importer,$xmlbase->photo,$msg); } elseif($xmlbase->conversation) { $ret = diaspora_conversation($importer,$xmlbase->conversation,$msg); @@ -796,7 +800,7 @@ function diaspora_post($importer,$xml,$msg) { } - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream'))) { logger('diaspora_post: Ignoring this author.'); return 202; } @@ -983,7 +987,7 @@ function diaspora_reshare($importer,$xml,$msg) { if(! $contact) return; - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream'))) { logger('diaspora_reshare: Ignoring this author: ' . $diaspora_handle . ' ' . print_r($xml,true)); return 202; } @@ -1150,7 +1154,7 @@ function diaspora_asphoto($importer,$xml,$msg) { if(! $contact) return; - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream'))) { logger('diaspora_asphoto: Ignoring this author.'); return 202; } @@ -1255,7 +1259,7 @@ function diaspora_comment($importer,$xml,$msg) { return; } - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'post_comments')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'post_comments'))) { logger('diaspora_comment: Ignoring this author.'); return 202; } @@ -1732,7 +1736,7 @@ function diaspora_message($importer,$xml,$msg) { } -function diaspora_photo($importer,$xml,$msg,$attempt=1) { +function diaspora_photo($importer,$xml,$msg) { $a = get_app(); @@ -1760,7 +1764,7 @@ function diaspora_photo($importer,$xml,$msg,$attempt=1) { return; } - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'send_stream'))) { logger('diaspora_photo: Ignoring this author.'); return 202; } @@ -1819,7 +1823,7 @@ function diaspora_like($importer,$xml,$msg) { } - if(! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'post_comments')) { + if((! $importer['system']) && (! perm_is_allowed($importer['channel_id'],$contact['xchan_hash'],'post_comments'))) { logger('diaspora_like: Ignoring this author.'); return 202; } -- cgit v1.2.3 From b948fbaeda84f4358722222b4a2d5555ef10b82e Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Feb 2015 19:09:42 -0800 Subject: allow post expiration to be set from a config (and therefore a plugin/addon) --- include/conversation.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/conversation.php b/include/conversation.php index 952d7d322..27b52ba6e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1134,6 +1134,9 @@ function status_editor($a,$x,$popup=false) { if(x($x,'nopreview')) $preview = ''; + $defexpire = ((($z = get_pconfig($x['profile_uid'],'system','default_post_expire')) && (! $webpage)) ? $z : ''); + + $cipher = get_pconfig($x['profile_uid'],'system','default_cipher'); if(! $cipher) $cipher = 'aes256'; @@ -1191,7 +1194,7 @@ function status_editor($a,$x,$popup=false) { '$preview' => $preview, '$source' => ((x($x,'source')) ? $x['source'] : ''), '$jotplugins' => $jotplugins, - '$defexpire' => '', + '$defexpire' => $defexpire, '$feature_expire' => ((feature_enabled($x['profile_uid'],'content_expire') && (! $webpage)) ? true : false), '$expires' => t('Set expiration date'), '$feature_encrypt' => ((feature_enabled($x['profile_uid'],'content_encrypt') && (! $webpage)) ? true : false), -- cgit v1.2.3