From b597e27c4d68dd2564a265f20789285bfc8a1b30 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 31 Jan 2015 00:42:27 -0800 Subject: revup --- version.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.inc b/version.inc index ff47debf0..7386960a0 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-01-30.932 +2015-01-31.933 -- cgit v1.2.3 From a7e5c7ce64f3649cafba48f4c89135dae52a5ca4 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 31 Jan 2015 14:52:29 -0800 Subject: issue #885, autoperms not working for diaspora connections --- include/diaspora.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/diaspora.php b/include/diaspora.php index 8f2f93209..ada90e476 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -688,7 +688,7 @@ function diaspora_request($importer,$xml) { $default_perms = $x['perms_accept']; } if(! $default_perms) - $default_perms = intval(get_pconfig($channel['channel_id'],'system','autoperms')); + $default_perms = intval(get_pconfig($importer['channel_id'],'system','autoperms')); $their_perms = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK|PERMS_W_STREAM|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT|PERMS_R_STORAGE|PERMS_R_PAGES; -- cgit v1.2.3 From 22ad8f413d021d8de4abb200b5645a51a384a998 Mon Sep 17 00:00:00 2001 From: marijus Date: Sun, 1 Feb 2015 12:48:25 +0100 Subject: add multipart/mixed to getIconFromType() --- include/text.php | 1 + 1 file changed, 1 insertion(+) diff --git a/include/text.php b/include/text.php index 5c8242e79..13f3f2fdf 100644 --- a/include/text.php +++ b/include/text.php @@ -2388,6 +2388,7 @@ function getIconFromType($type) { $iconMap = array( //Folder t('Collection') => 'icon-folder-close', + 'multipart/mixed' => 'icon-folder-close', //dirs in attach use this mime type //Common file 'application/octet-stream' => 'icon-file-alt', //Text -- cgit v1.2.3 From e238b639f86e0204a3e5d86df9fe987073e877c4 Mon Sep 17 00:00:00 2001 From: jeroenpraat Date: Mon, 2 Feb 2015 00:00:13 +0100 Subject: typo, see #884 --- view/nl/register_open_eml.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/view/nl/register_open_eml.tpl b/view/nl/register_open_eml.tpl index 07e7beb76..e634664a6 100644 --- a/view/nl/register_open_eml.tpl +++ b/view/nl/register_open_eml.tpl @@ -11,9 +11,9 @@ bezoeken en een nieuwe wachtwoord aanvragen. Je kan daarna inloggen, een kanaal meteen via 'instellingen > account' (linksboven) het account verwijderen (onderaan). Excuses voor het eventuele ongemak. -Wanneer dit account wel door jou is aangemaakt: Dank je en welkom op de {{sitename}}. +Wanneer dit account wel door jou is aangemaakt: Dank je en welkom op de {{$sitename}}. Vriendelijke groet, - Beheerder {{sitename}} ({{$siteurl}}) + Beheerder {{$sitename}} ({{$siteurl}}) - \ No newline at end of file + -- cgit v1.2.3 From b1a92d620ebf760a3cfd83f6fb62990494d3ad60 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Feb 2015 15:10:52 -0800 Subject: two tracks proceeding in parallel - first adding the ability to store a digital signature with ratings so that directories can pass them around, second provide some directory registration functions so we can obtain a list of directories from somewhere (to pass ratings around between them). This gives the primary directory role some value as that is where you register your directory. --- boot.php | 15 ++++++++++- include/poller.php | 4 +++ install/schema_mysql.sql | 1 + install/schema_postgres.sql | 1 + install/update.php | 9 ++++++- mod/regdir.php | 64 +++++++++++++++++++++++++++++++++++++++++++++ mod/zfinger.php | 9 ++++++- version.inc | 2 +- 8 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 mod/regdir.php diff --git a/boot.php b/boot.php index 96dee2c46..2f8d1c08f 100755 --- a/boot.php +++ b/boot.php @@ -49,7 +49,7 @@ define ( 'RED_PLATFORM', 'redmatrix' ); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1135 ); +define ( 'DB_UPDATE_VERSION', 1136 ); /** * Constant with a HTML line break. @@ -2194,6 +2194,19 @@ function get_directory_realm() { return DIRECTORY_REALM; } +/** + * @brief Return the primary directory server. + * + * @return string + */ +function get_directory_primary() { + if($x = get_config('system', 'directory_primary')) + return $x; + + return DIRECTORY_FALLBACK_MASTER; +} + + /** * @brief return relative date of last completed poller execution diff --git a/include/poller.php b/include/poller.php index dc310fe16..fd78ce087 100644 --- a/include/poller.php +++ b/include/poller.php @@ -164,6 +164,10 @@ function poller_run($argv, $argc){ db_utcnow(), db_quoteinterval('14 DAY') ); + $dirmode = intval(get_config('system','directory_mode')); + if($dirmode == DIRECTORY_MODE_SECONDARY) { + logger('regdir: ' . print_r(z_fetch_url(get_directory_primary() . '/regdir?f=&url=' . z_root() . '&realm=' . get_directory_realm()),true)); + } /** * End Cron Weekly diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql index ba41073f8..8addc0af9 100644 --- a/install/schema_mysql.sql +++ b/install/schema_mysql.sql @@ -1533,6 +1533,7 @@ CREATE TABLE IF NOT EXISTS `xlink` ( `xlink_rating_text` TEXT NOT NULL DEFAULT '', `xlink_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `xlink_static` tinyint(1) NOT NULL DEFAULT '0', + `xlink_sig` text NOT NULL DEFAULT '', PRIMARY KEY (`xlink_id`), KEY `xlink_xchan` (`xlink_xchan`), KEY `xlink_link` (`xlink_link`), diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index 2fcc7f9ba..b68a7cb97 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -1146,6 +1146,7 @@ CREATE TABLE "xlink" ( "xlink_rating_text" TEXT NOT NULL DEFAULT '', "xlink_updated" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "xlink_static" numeric(1) NOT NULL DEFAULT '0', + "xlink_sig" text NOT NULL DEFAULT '', PRIMARY KEY ("xlink_id") ); create index "xlink_xchan" on xlink ("xlink_xchan"); diff --git a/install/update.php b/install/update.php index 597da4e3b..4cd1ced5d 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ false); + + $url = $_REQUEST['url']; + + + // we probably don't need the realm as we will find out in the probe. + // What we may want to die is throw an error if you're trying to register in a different realm + // so this configuration issue can be discovered. + + $realm = $_REQUEST['realm']; + if(! $realm) + $realm = DIRECTORY_REALM; + + $dirmode = intval(get_config('system','directory_mode')); + + if($dirmode == DIRECTORY_MODE_NORMAL) { + $ret['message'] = t('This site is not a directory server'); + json_return_and_die($ret); + } + + $m = null; + if($url) { + $m = parse_url($url); + + if((! $m) || (! @dns_get_record($m['host'], DNS_A + DNS_CNAME + DNS_PTR)) || (! filter_var($m['host'], FILTER_VALIDATE_IP) )) { + $result['message'] = 'unparseable url'; + json_return_and_die($result); + } + + $f = zot_finger('sys@' . $m['host']); + if($f['success']) { + $j = json_decode($f['body'],true); + if($j['success'] && $j['guid']) { + $x = import_xchan($j); + if($x['success']) { + $result['success'] = true; + json_return_and_die($result); + } + } + } + + json_return_and_die($result); + } + else { + $r = q("select site_url from site where site_flags in ( 1, 2 ) and site_realm = '%s'", + dbesc(get_directory_realm()) + ); + if($r) { + $result['success'] = true; + $result['directories'] = array(); + foreach($r as $rr) + $result['directories'][] = $rr['site_url']; + json_return_and_die($result); + } + } + json_return_and_die($result); + + +} \ No newline at end of file diff --git a/mod/zfinger.php b/mod/zfinger.php index 6f4febc6f..f4b7efd96 100644 --- a/mod/zfinger.php +++ b/mod/zfinger.php @@ -99,13 +99,14 @@ function zfinger_init(&$a) { $id = $e['channel_id']; + $sys_channel = (($e['channel_pageflags'] & PAGE_SYSTEM) ? true : false); $special_channel = (($e['channel_pageflags'] & PAGE_PREMIUM) ? true : false); $adult_channel = (($e['channel_pageflags'] & PAGE_ADULT) ? true : false); $censored = (($e['channel_pageflags'] & PAGE_CENSORED) ? true : false); $searchable = (($e['channel_pageflags'] & PAGE_HIDDEN) ? false : true); $deleted = (($e['xchan_flags'] & XCHAN_FLAGS_DELETED) ? true : false); - if($deleted || $censored) + if($deleted || $censored || $sys_channel) $searchable = false; $public_forum = false; @@ -237,6 +238,12 @@ function zfinger_init(&$a) { $dirmode = get_config('system','directory_mode'); if(($dirmode === false) || ($dirmode == DIRECTORY_MODE_NORMAL)) $ret['site']['directory_mode'] = 'normal'; + + // downgrade mis-configured primaries + + if($dirmode == DIRECTORY_MODE_PRIMARY && z_root() != get_directory_primary()) + $dirmode = DIRECTORY_MODE_SECONDARY; + if($dirmode == DIRECTORY_MODE_PRIMARY) $ret['site']['directory_mode'] = 'primary'; elseif($dirmode == DIRECTORY_MODE_SECONDARY) diff --git a/version.inc b/version.inc index 7386960a0..b7a74f141 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-01-31.933 +2015-02-01.934 -- cgit v1.2.3 From e58bef049d7736d448f7bb5688affe491b9e24b1 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Feb 2015 15:41:01 -0800 Subject: admin/dbsync not reporting failed updates --- install/update.php | 2 +- mod/admin.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install/update.php b/install/update.php index 4cd1ced5d..c6e4535e1 100644 --- a/install/update.php +++ b/install/update.php @@ -1556,4 +1556,4 @@ function update_r1135() { if($r) return UPDATE_SUCCESS; return UPDATE_FAILED; -} \ No newline at end of file +} diff --git a/mod/admin.php b/mod/admin.php index ec922cc72..e1808fd55 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -562,7 +562,7 @@ function admin_page_dbsync(&$a) { if(count($r)) { foreach($r as $rr) { $upd = intval(substr($rr['k'],8)); - if($upd < 1139 || $rr['v'] === 'success') + if($rr['v'] === 'success') continue; $failed[] = $upd; } -- cgit v1.2.3 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