From 2174cdcd0ebda4ba62653791489f003bf085f282 Mon Sep 17 00:00:00 2001 From: Treer Date: Fri, 6 May 2016 01:34:52 +1000 Subject: Unify permissions dialog for network posts, channel posts, and remote posts * changes the warning from being about when a post is "sent" to when it's "shared", to match the Share button. * hyperlinks the "cannot be changed" part of the warning to the help file * adds some more content to the help file --- Zotlabs/Module/Channel.php | 10 +--------- Zotlabs/Module/Network.php | 10 +--------- Zotlabs/Module/Rpost.php | 2 +- doc/acl_dialog_post.html | 7 ++++++- include/acl_selectors.php | 37 ++++++++++++++++++++++++++++++++----- 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index d0c6d83d8..47c5f31fb 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -126,21 +126,13 @@ function get($update = 0, $load = false) { if($perms['post_wall']) { - // I'm trying to make two points in this description text - warn about finality of wall - // post permissions, and try to clear up confusion that these permissions set who is - // *shown* the post, istead of who is able to see the post, i.e. make it clear that clicking - // the "Show" button on a group does not post it to the feed of people in that group, it - // mearly allows those people to view the post if they are viewing/following this channel. - $aclDesc = t('Post permissions cannot be changed after a post is sent.
These permissions set who is allowed to view the post.'); - $aclContextHelpCmd = 'acl_dialog_post'; - $x = array( 'is_owner' => $is_owner, 'allow_location' => ((($is_owner || $observer) && (intval(get_pconfig(\App::$profile['profile_uid'],'system','use_browser_location')))) ? true : false), 'default_location' => (($is_owner) ? \App::$profile['channel_location'] : ''), 'nickname' => \App::$profile['channel_address'], 'lockstate' => (((strlen(\App::$profile['channel_allow_cid'])) || (strlen(\App::$profile['channel_allow_gid'])) || (strlen(\App::$profile['channel_deny_cid'])) || (strlen(\App::$profile['channel_deny_gid']))) ? 'lock' : 'unlock'), - 'acl' => (($is_owner) ? populate_acl($channel_acl,true,((\App::$profile['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : ''), $aclDesc, $aclContextHelpCmd) : ''), + 'acl' => (($is_owner) ? populate_acl($channel_acl,true,((\App::$profile['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : ''), get_post_aclDialogDescription(), 'acl_dialog_post') : ''), 'showacl' => (($is_owner) ? 'yes' : ''), 'bang' => '', 'visitor' => (($is_owner || $observer) ? true : false), diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index e4b936dc2..2badd7280 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -155,14 +155,6 @@ class Network extends \Zotlabs\Web\Controller { nav_set_selected('network'); - // I'm trying to make two points in this description text - warn about finality of wall - // post permissions, and try to clear up confusion that these permissions set who is - // *shown* the post, istead of who is able to see the post, i.e. make it clear that clicking - // the "Show" button on a group does not post it to the feed of people in that group, it - // mearly allows those people to view the post if they are viewing/following this channel. - $aclDesc = t('Post permissions cannot be changed after a post is sent.
These permissions set who is allowed to view the post.'); - $aclContextHelpCmd = 'acl_dialog_post'; - $channel_acl = array( 'allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], @@ -178,7 +170,7 @@ class Network extends \Zotlabs\Web\Controller { 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], 'lockstate' => (($private_editing || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - 'acl' => populate_acl((($private_editing) ? $def_acl : $channel_acl), true, (($channel['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : ''), $aclDesc, $aclContextHelpCmd), + 'acl' => populate_acl((($private_editing) ? $def_acl : $channel_acl), true, (($channel['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : ''), get_post_aclDialogDescription(), 'acl_dialog_post'), 'bang' => (($private_editing) ? '!' : ''), 'visitor' => true, 'profile_uid' => local_channel(), diff --git a/Zotlabs/Module/Rpost.php b/Zotlabs/Module/Rpost.php index 195949e1c..41889c35c 100644 --- a/Zotlabs/Module/Rpost.php +++ b/Zotlabs/Module/Rpost.php @@ -115,7 +115,7 @@ class Rpost extends \Zotlabs\Web\Controller { 'default_location' => $channel['channel_location'], 'nickname' => $channel['channel_address'], 'lockstate' => (($acl->is_private()) ? 'lock' : 'unlock'), - 'acl' => populate_acl($channel_acl,true,(($channel['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : '')), + 'acl' => populate_acl($channel_acl,true,(($channel['channel_r_stream'] & PERMS_PUBLIC) ? t('Public') : ''), get_post_aclDialogDescription(), 'acl_dialog_post'), 'bang' => '', 'visitor' => true, 'profile_uid' => local_channel(), diff --git a/doc/acl_dialog_post.html b/doc/acl_dialog_post.html index 19c366419..b387ec08e 100644 --- a/doc/acl_dialog_post.html +++ b/doc/acl_dialog_post.html @@ -5,7 +5,12 @@

Sometimes called Access Control List, or ACL, the permissions set who is able to see your new post.

-

Pressing the ACL button ( or ) beside the Submit button will display a dialog in which you can select what channels and/or privacy groups can see the post. You can also select who is explicitly denied access. For example, say you are planning a surprise party for a friend. You can send an invitation post to everyone in your Friends group except the friend you are surprising. In this case you "Show" the Friends group but "Don't show" that one person. +

Pressing the ACL button ( or ) beside the Submit button will display a dialog in which you can select what channels and/or privacy groups can see the post. You can also select who is explicitly denied access. For example, say you are planning a surprise party for a friend. You can send an invitation post to everyone in your Friends group except the friend you are surprising. In this case you "Show" the Friends group but "Don't show" that one person.

+ +
+
Tip:
+
The border color of each channel indicates whether that channel — or one of the groups it belongs to — has access to the post. The border color will also indicate when a channel [or group it belongs to] has been expliciyly set to "Don't show".
+

Why can't I edit a post's permissions after I saved it?

diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 584a70142..4cc01d15b 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -213,14 +213,14 @@ function fixacl(&$item) { /** * Builds a modal dialog for editing permissions, using acl_selector.tpl as the template. * -* @param array $default Optional access control list for the initial state of the dialog. +* @param array $default Optional access control list for the initial state of the dialog. * @param boolean $show_jotnets Whether plugins for federated networks should be included in the permissions dialog -* @param string $showall_caption An optional caption to describe the scope of an unrestricted post. e.g. "Public" -* @param string $dialog_description Optional message to include at the top of the dialog. E.g. "Warning: Post permissions cannot be changed once sent". -* @param string $context_help Allows the dialog to present a help icon. E.g. "acl_dialog_post" +* @param string $showall_caption An optional caption to describe the scope of an unrestricted post. e.g. "Public" +* @param string $dialog_description Optional message to include at the top of the dialog. E.g. "Warning: Post permissions cannot be changed once sent". +* @param string $context_help Allows the dialog to present a help icon. E.g. "acl_dialog_post" * @param boolean $readonly Not implemented yet. When implemented, the dialog will use acl_readonly.tpl instead, so that permissions may be viewed for posts that can no longer have their permissions changed. * -* @return string html modal dialog build from acl_selector.tpl +* @return string html modal dialog built from acl_selector.tpl */ function populate_acl($defaults = null,$show_jotnets = true, $showall_caption = '', $dialog_description = '', $context_help = '', $readonly = false) { @@ -273,3 +273,30 @@ function populate_acl($defaults = null,$show_jotnets = true, $showall_caption = } +/** +* Returns a string that's suitable for passing as the $dialog_description argument to a +* populate_acl() call for wall posts or network posts. +* +* This string is needed in 3 different files, and our .po translation system currently +* cannot be used as a string table (because the value is always the key is english) so +* I've centralized the value here (making this function name the "key") until we have a +* better way. +* +* @return string Description to present to user in modal permissions dialog +*/ +function get_post_aclDialogDescription() { + + // I'm trying to make two points in this description text - warn about finality of wall + // post permissions, and try to clear up confusion that these permissions set who is + // *shown* the post, istead of who is able to see the post, i.e. make it clear that clicking + // the "Show" button on a group does not post it to the feed of people in that group, it + // mearly allows those people to view the post if they are viewing/following this channel. + $description = t('Post permissions %s cannot be changed %s after a post is shared.
These permissions set who is allowed to view the post.'); + + // Lets keep the emphasis styling seperate from the translation. It may change. + $emphasisOpen = ''; + $emphasisClose = ''; + + return sprintf($description, $emphasisOpen, $emphasisClose); +} + -- cgit v1.2.3 From 2e3da0cbbbb753c8910e96a907cd031e5d95f7c2 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 5 May 2016 18:15:07 -0700 Subject: - Setup: check php version (5.4 required) - Comanche: implement conditionals. Currently the only supported tests are true/false for system config settings and supports the following forms: [if $config.system.foo] [widget=widget1][/widget] [else] [widget=widget2][/widget] [/if] [if $config.system.foo] [widget=widget1][/widget] [/if] --- Zotlabs/Module/Setup.php | 5 +++++ include/comanche.php | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index 3ac67e1c0..f8c14951b 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -407,6 +407,11 @@ class Setup extends \Zotlabs\Web\Controller { function check_php(&$phpath, &$checks) { $help = ''; + if(version_compare(PHP_VERSION, '5.4') < 0) { + $help .= t('PHP version 5.4 or greater is required.'); + $this->check_add($checks, t('PHP version'), false, false, $help); + } + if (strlen($phpath)) { $passed = file_exists($phpath); } else { diff --git a/include/comanche.php b/include/comanche.php index 4d55aee19..0a52eaf2b 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -53,6 +53,31 @@ function comanche_parser(&$a, $s, $pass = 0) { } } + $cnt = preg_match_all("/\[if (.*?)\](.*?)\[else\](.*?)\[\/if\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + if(comanche_test_condition($mtch[1])) { + $s = str_replace($mtch[0], $mtch[2], $s); + } + else { + $s = str_replace($mtch[0], $mtch[3], $s); + } + } + } + else { + $cnt = preg_match_all("/\[if (.*?)\](.*?)\[\/if\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + if(comanche_test_condition($mtch[1])) { + $s = str_replace($mtch[0], $mtch[2], $s); + } + else { + $s = str_replace($mtch[0], '', $s); + } + } + } + } + if($pass == 0) { $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $s, $matches); if($cnt) @@ -86,7 +111,6 @@ function comanche_parser(&$a, $s, $pass = 0) { App::$layout['webpage'] = comanche_webpage($a,$mtch[1]); } } - } else { $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER); @@ -100,6 +124,17 @@ function comanche_parser(&$a, $s, $pass = 0) { } +function comanche_test_condition($s) { + + if(preg_match("/[\$]config[\.](.*?)/",$s,$matches)) { + $x = explode('.',$s); + if(get_config($x[1],$x[2])) + return true; + } + return false; + +} + function comanche_menu($s, $class = '') { -- cgit v1.2.3