From 12528f033ad781fd30e82d6e5790c592ccdcadb9 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Thu, 25 Jun 2015 12:33:05 +0200 Subject: [PATCH 1/8] include jotnets in populate_acl --- include/acl_selectors.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/acl_selectors.php b/include/acl_selectors.php index b2c4b31c81..e0055f1c68 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -283,10 +283,15 @@ function get_acl_permissions($user = null) { } -function populate_acl($user = null,$celeb = false) { +function populate_acl($user = null,$celeb = false,$show_jotnets = true,$show_mail = false) { $perms = get_acl_permissions($user); + $jotnets = ''; + if($show_jotnets) { + call_hooks('jot_networks', $jotnets); + } + // We shouldn't need to prune deadguys from the block list. Either way they can't get the message. // Also no point enumerating groups and checking them, that will take place on delivery. @@ -337,6 +342,11 @@ function populate_acl($user = null,$celeb = false) { '$allowgid' => json_encode($perms['allow_gid']), '$denycid' => json_encode($perms['deny_cid']), '$denygid' => json_encode($perms['deny_gid']), + '$emailcc' => t('CC: email addresses'), + '$emtitle' => t('Example: bob@example.com, mary@example.com'), + '$jotnets' => $jotnets, + '$aclModalTitle' => t('Permissions'), + '$aclModalDismiss' => t('Close'), '$features' => array( "aclautomention"=>(feature_enabled($user['uid'],"aclautomention")?"true":"false") ), From bfebf9636b075ee2b27dab98c39535e7d2298b85 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Thu, 25 Jun 2015 12:38:09 +0200 Subject: [PATCH 2/8] acl for events and photos --- mod/events.php | 2 +- mod/photos.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mod/events.php b/mod/events.php index e9e1af05d8..92c128c1dd 100644 --- a/mod/events.php +++ b/mod/events.php @@ -507,7 +507,7 @@ function events_content(&$a) { '$sh_text' => t('Share this event'), '$sh_checked' => $sh_checked, '$preview' => t('Preview'), - '$acl' => (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user),false)), + '$acl' => (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user),false, false)), '$submit' => t('Submit') )); diff --git a/mod/photos.php b/mod/photos.php index 02ae0e76d2..8f11a523bb 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1139,11 +1139,11 @@ function photos_content(&$a) { if($a->theme['template_engine'] === 'internal') { $albumselect_e = template_escape($albumselect); - $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb))); + $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb,false))); } else { $albumselect_e = $albumselect; - $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb)); + $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb,false)); } $o .= replace_macros($tpl,array( From 94b21245bca0d139c6b4e498ed5de8342f55454a Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Thu, 25 Jun 2015 18:57:42 +0200 Subject: [PATCH 3/8] some more work to get acl data into populate_acl --- include/acl_selectors.php | 25 ++++++++++++++++++++++++- mod/network.php | 2 +- mod/photos.php | 4 ++-- mod/profile.php | 2 +- view/templates/acl_selector.tpl | 8 ++++++++ view/templates/jot.tpl | 4 ---- 6 files changed, 36 insertions(+), 9 deletions(-) diff --git a/include/acl_selectors.php b/include/acl_selectors.php index e0055f1c68..85a9f67592 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -283,12 +283,34 @@ function get_acl_permissions($user = null) { } -function populate_acl($user = null,$celeb = false,$show_jotnets = true,$show_mail = false) { +function populate_acl($user = null,$celeb = false,$show_jotnets = false) { $perms = get_acl_permissions($user); $jotnets = ''; if($show_jotnets) { + $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); + + $mail_enabled = false; + $pubmail_enabled = false; + + if(! $mail_disabled) { + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", + intval(local_user()) + ); + if(count($r)) { + $mail_enabled = true; + if(intval($r[0]['pubmail'])) + $pubmail_enabled = true; + } + } + + if($mail_enabled) { + $selected = (($pubmail_enabled) ? ' checked="checked" ' : ''); + $jotnets .= '
' + . t("Post to Email") . '
'; + } + call_hooks('jot_networks', $jotnets); } @@ -342,6 +364,7 @@ function populate_acl($user = null,$celeb = false,$show_jotnets = true,$show_mai '$allowgid' => json_encode($perms['allow_gid']), '$denycid' => json_encode($perms['deny_cid']), '$denygid' => json_encode($perms['deny_gid']), + '$networks' => $show_jotnets, '$emailcc' => t('CC: email addresses'), '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$jotnets' => $jotnets, diff --git a/mod/network.php b/mod/network.php index 7b3c92e249..c3de76413b 100644 --- a/mod/network.php +++ b/mod/network.php @@ -485,7 +485,7 @@ function network_content(&$a, $update = 0) { ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'), 'default_perms' => get_acl_permissions($a->user), - 'acl' => populate_acl((($group || $cid || $nets) ? $def_acl : $a->user), $celeb), + 'acl' => populate_acl((($group || $cid || $nets) ? $def_acl : $a->user), $celeb, true), 'bang' => (($group || $cid || $nets) ? '!' : ''), 'visitor' => 'block', 'profile_uid' => local_user(), diff --git a/mod/photos.php b/mod/photos.php index 8f11a523bb..02ae0e76d2 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1139,11 +1139,11 @@ function photos_content(&$a) { if($a->theme['template_engine'] === 'internal') { $albumselect_e = template_escape($albumselect); - $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb,false))); + $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb))); } else { $albumselect_e = $albumselect; - $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb,false)); + $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb)); } $o .= replace_macros($tpl,array( diff --git a/mod/profile.php b/mod/profile.php index e81cfd22c9..9eb2d34b6c 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -195,7 +195,7 @@ function profile_content(&$a, $update = 0) { 'default_location' => (($is_owner) ? $a->user['default-location'] : ''), 'nickname' => $a->profile['nickname'], 'lockstate' => (((is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'), - 'acl' => (($is_owner) ? populate_acl($a->user, $celeb) : ''), + 'acl' => (($is_owner) ? populate_acl($a->user, $celeb, true) : ''), 'bang' => '', 'visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'), 'profile_uid' => $a->profile['profile_uid'], diff --git a/view/templates/acl_selector.tpl b/view/templates/acl_selector.tpl index 6b6f1be4a9..c1220bc1e3 100644 --- a/view/templates/acl_selector.tpl +++ b/view/templates/acl_selector.tpl @@ -15,6 +15,14 @@ {{$hide}} +{{if $networks}} +
+
{{$emailcc}}
+
+{{if $jotnets}} +{{$jotnets}} +{{/if}}{{/if}} +