diff --git a/Zotlabs/Module/Blocks.php b/Zotlabs/Module/Blocks.php index 192a4aded..ed702befb 100644 --- a/Zotlabs/Module/Blocks.php +++ b/Zotlabs/Module/Blocks.php @@ -82,11 +82,7 @@ class Blocks extends \Zotlabs\Web\Controller { } $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype')); - - if(! $mimetype) { - $mimetype = 'choose'; - } - + $x = array( 'webpage' => ITEM_TYPE_BLOCK, 'is_owner' => true, @@ -96,6 +92,8 @@ class Blocks extends \Zotlabs\Web\Controller { 'showacl' => false, 'visitor' => true, 'mimetype' => $mimetype, + 'mimeselect' => true, + 'hide_location' => true, 'ptlabel' => t('Block Name'), 'profile_uid' => intval($owner), 'expanded' => true, diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 47c5f31fb..f55705442 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -9,6 +9,7 @@ require_once('include/security.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); require_once('include/permissions.php'); +require_once('include/PermissionDescription.php'); class Channel extends \Zotlabs\Web\Controller { @@ -132,7 +133,7 @@ function get($update = 0, $load = 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') : ''), get_post_aclDialogDescription(), 'acl_dialog_post') : ''), + 'acl' => (($is_owner) ? populate_acl($channel_acl,true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post') : ''), 'showacl' => (($is_owner) ? 'yes' : ''), 'bang' => '', 'visitor' => (($is_owner || $observer) ? true : false), diff --git a/Zotlabs/Module/Editblock.php b/Zotlabs/Module/Editblock.php index 0204d0994..a79962033 100644 --- a/Zotlabs/Module/Editblock.php +++ b/Zotlabs/Module/Editblock.php @@ -3,6 +3,7 @@ namespace Zotlabs\Module; require_once('include/identity.php'); require_once('include/acl_selectors.php'); +require_once('include/conversation.php'); class Editblock extends \Zotlabs\Web\Controller { @@ -95,81 +96,38 @@ class Editblock extends \Zotlabs\Web\Controller { return; } - $plaintext = true; - - $mimeselect = ''; $mimetype = $itm[0]['mimetype']; - if($mimetype != 'text/bbcode') - $plaintext = true; - - if(get_config('system','page_mimetype')) - $mimeselect = ''; - else - $mimeselect = mimetype_select($itm[0]['uid'],$mimetype); - - \App::$page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array( - '$baseurl' => z_root(), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), - '$pretext' => '', - '$ispublic' => ' ', // t('Visible to everybody'), - '$geotag' => '', - '$nickname' => $channel['channel_address'], - '$confirmdelete' => t('Delete block?'), - '$bbco_autocomplete'=> (($mimetype == 'text/bbcode') ? 'bbcode' : 'comanche-block') - )); - - $tpl = get_markup_template("jot.tpl"); - - $jotplugins = ''; - $jotnets = ''; - - call_hooks('jot_tool', $jotplugins); - call_hooks('jot_networks', $jotnets); - $rp = 'blocks/' . $channel['channel_address']; - $editor = replace_macros($tpl,array( - '$return_path' => $rp, - '$action' => 'item', - '$webpage' => ITEM_TYPE_BLOCK, - '$share' => t('Edit'), - '$bold' => t('Bold'), - '$italic' => t('Italic'), - '$underline' => t('Underline'), - '$quote' => t('Quote'), - '$code' => t('Code'), - '$writefiles' => (($mimetype == 'text/bbcode') ? perm_is_allowed($owner, get_observer_hash(), 'write_storage') : false), - '$attach' => t('Attach file'), - '$weblink' => (($mimetype == 'text/bbcode') ? t('Insert web link') : false), - '$setloc' => false, - '$noloc' => false, - '$permset' => t('Permission settings'), - '$ptyp' => $itm[0]['type'], - '$mimeselect' => $mimeselect, - '$content' => undo_post_tagging($itm[0]['body']), - '$post_id' => $post_id, - '$baseurl' => z_root(), - '$defloc' => $channel['channel_location'], - '$visitor' => true, - '$public' => t('Public post'), - '$jotnets' => $jotnets, - '$title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'), - '$placeholdertitle' => t('Title (optional)'), - '$pagetitle' => $block_title, - '$category' => '', - '$placeholdercategory' => t('Categories (optional, comma-separated list)'), - '$emtitle' => t('Example: bob@example.com, mary@example.com'), - '$lockstate' => $lockstate, - '$acl' => '', - '$bang' => '', - '$profile_uid' => (intval($channel['channel_id'])), - '$preview' => t('Preview'), - '$jotplugins' => $jotplugins, - '$sourceapp' => $itm[0]['app'], - '$defexpire' => '', - '$bbcode' => (($mimetype == 'text/bbcode') ? true : false) - )); + $x = array( + 'nickname' => $channel['channel_address'], + 'bbco_autocomplete'=> (($mimetype == 'text/bbcode') ? 'bbcode' : 'comanche-block'), + 'return_path' => $rp, + 'webpage' => ITEM_TYPE_BLOCK, + 'ptlabel' => t('Block Name'), + 'button' => t('Edit'), + 'writefiles' => (($mimetype == 'text/bbcode') ? perm_is_allowed($owner, get_observer_hash(), 'write_storage') : false), + 'weblink' => (($mimetype == 'text/bbcode') ? t('Insert web link') : false), + 'hide_voting' => true, + 'hide_future' => true, + 'hide_location' => true, + 'hide_expire' => true, + 'showacl' => false, + 'ptyp' => $itm[0]['type'], + 'mimeselect' => true, + 'mimetype' => $itm[0]['mimetype'], + 'body' => undo_post_tagging($itm[0]['body']), + 'post_id' => $post_id, + 'visitor' => true, + 'title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'), + 'placeholdertitle' => t('Title (optional)'), + 'pagetitle' => $block_title, + 'profile_uid' => (intval($channel['channel_id'])), + 'bbcode' => (($mimetype == 'text/bbcode') ? true : false) + ); + + $editor = status_editor($a, $x); $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit Block'), diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index 25ba1a39a..43edf2c00 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -85,6 +85,7 @@ class Editpost extends \Zotlabs\Web\Controller { 'hide_voting' => true, 'hide_future' => true, 'hide_location' => true, + 'mimetype' => $itm[0]['mimetype'], 'ptyp' => $itm[0]['obj_type'], 'body' => undo_post_tagging($itm[0]['body']), 'post_id' => $post_id, diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index d3b031db2..c2346c53b 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -3,46 +3,47 @@ namespace Zotlabs\Module; require_once('include/identity.php'); require_once('include/acl_selectors.php'); +require_once('include/conversation.php'); +require_once('include/PermissionDescription.php'); class Editwebpage extends \Zotlabs\Web\Controller { function init() { - + if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) { $sys = get_sys_channel(); if($sys && intval($sys['channel_id'])) { \App::$is_sys = true; } } - + if(argc() > 1) $which = argv(1); else return; - + profile_load($a,$which); - + } - - - function get() { - + + function get() { + if(! \App::$profile) { notice( t('Requested profile is not available.') . EOL ); \App::$error = 404; return; } - + $which = argv(1); - + $uid = local_channel(); $owner = 0; $channel = null; $observer = \App::get_observer(); - + $channel = \App::get_channel(); - + if(\App::$is_sys && is_site_admin()) { $sys = get_sys_channel(); if($sys && intval($sys['channel_id'])) { @@ -51,7 +52,7 @@ class Editwebpage extends \Zotlabs\Web\Controller { $observer = $sys; } } - + if(! $owner) { // Figure out who the page owner is. $r = q("select channel_id from channel where channel_address = '%s'", @@ -61,51 +62,50 @@ class Editwebpage extends \Zotlabs\Web\Controller { $owner = intval($r[0]['channel_id']); } } - + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); - + if(! perm_is_allowed($owner,$ob_hash,'write_pages')) { notice( t('Permission denied.') . EOL); return; } - + $is_owner = (($uid && $uid == $owner) ? true : false); - + $o = ''; - + // Figure out which post we're editing $post_id = ((argc() > 2) ? intval(argv(2)) : 0); - if(! $post_id) { notice( t('Item not found') . EOL); return; } - + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); - + $perms = get_all_perms($owner,$ob_hash); - + if(! $perms['write_pages']) { notice( t('Permission denied.') . EOL); return; } - + // We've already figured out which item we want and whose copy we need, // so we don't need anything fancy here - + $sql_extra = item_permissions_sql($owner); - + $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s $sql_extra LIMIT 1", intval($post_id), intval($owner) ); - + if(! $itm) { notice( t('Permission denied.') . EOL); return; } - + if(intval($itm[0]['item_obscured'])) { $key = get_config('system','prvkey'); if($itm[0]['title']) @@ -113,120 +113,67 @@ class Editwebpage extends \Zotlabs\Web\Controller { if($itm[0]['body']) $itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']),$key); } - + $item_id = q("select * from item_id where service = 'WEBPAGE' and iid = %d limit 1", intval($itm[0]['id']) ); if($item_id) $page_title = $item_id[0]['sid']; - - $plaintext = true; - + $mimetype = $itm[0]['mimetype']; - + if($mimetype === 'application/x-php') { if((! $uid) || ($uid != $itm[0]['uid'])) { notice( t('Permission denied.') . EOL); return; } } - - $mimeselect = ''; - if($mimetype != 'text/bbcode') - $plaintext = true; - - if(get_config('system','page_mimetype')) - $mimeselect = ''; - else - $mimeselect = mimetype_select($itm[0]['uid'],$mimetype); - - $layout = get_config('system','page_layout'); - if($layout) - $layoutselect = ''; - else - $layoutselect = layout_select($itm[0]['uid'],$itm[0]['layout_mid']); - - \App::$page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array( - '$baseurl' => z_root(), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), - '$pretext' => '', - '$ispublic' => ' ', // t('Visible to everybody'), - '$geotag' => $geotag, - '$nickname' => $channel['channel_address'], - '$confirmdelete' => t('Delete webpage?'), - '$bbco_autocomplete'=> (($mimetype == 'text/bbcode') ? 'bbcode' : '') - )); + $layout = $itm[0]['layout_mid']; $tpl = get_markup_template("jot.tpl"); - - $jotplugins = ''; - $jotnets = ''; - - call_hooks('jot_tool', $jotplugins); - call_hooks('jot_networks', $jotnets); - - // FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD - // instead of loading a sensible page. So, send folk to the webpage list. - + $rp = 'webpages/' . $which; - - $editor = replace_macros($tpl,array( - '$return_path' => $rp, - '$webpage' => ITEM_TYPE_WEBPAGE, - '$placeholdpagetitle' => t('Page link title'), - '$pagetitle' => $page_title, - '$writefiles' => (($mimetype == 'text/bbcode') ? perm_is_allowed($owner, get_observer_hash(), 'write_storage') : false), - '$action' => 'item', - '$share' => t('Edit'), - '$bold' => t('Bold'), - '$italic' => t('Italic'), - '$underline' => t('Underline'), - '$quote' => t('Quote'), - '$code' => t('Code'), - '$attach' => t('Attach file'), - '$weblink' => (($mimetype == 'text/bbcode') ? t('Insert web link') : false), - '$setloc' => false, //t('Set your location'), - '$noloc' => false, //((get_pconfig($uid, 'system', 'use_browser_location')) ? t('Clear browser location') : ''), - '$permset' => t('Permission settings'), - '$ptyp' => $itm[0]['type'], - '$content' => undo_post_tagging($itm[0]['body']), - '$post_id' => $post_id, - '$baseurl' => z_root(), - '$defloc' => $itm[0]['location'], - '$visitor' => ($is_owner) ? true : false, - '$acl' => populate_acl($itm[0],false), - '$showacl' => ($is_owner) ? true : false, - '$public' => t('Public post'), - '$jotnets' => $jotnets, - '$mimeselect' => $mimeselect, - '$layoutselect' => $layoutselect, - '$title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'), - '$placeholdertitle' => t('Title (optional)'), - '$category' => '', - '$placeholdercategory' => t('Categories (optional, comma-separated list)'), - '$emtitle' => t('Example: bob@example.com, mary@example.com'), + + $x = array( + 'nickname' => $channel['channel_address'], + 'bbco_autocomplete'=> (($mimetype == 'text/bbcode') ? 'bbcode' : ''), + 'return_path' => $rp, + 'webpage' => ITEM_TYPE_WEBPAGE, + 'ptlabel' => t('Page link'), + 'pagetitle' => $page_title, + 'writefiles' => (($mimetype == 'text/bbcode') ? perm_is_allowed($owner, get_observer_hash(), 'write_storage') : false), + 'button' => t('Edit'), + 'weblink' => (($mimetype == 'text/bbcode') ? t('Insert web link') : false), + 'hide_location' => true, + 'hide_voting' => true, + 'ptyp' => $itm[0]['type'], + 'body' => undo_post_tagging($itm[0]['body']), + 'post_id' => $post_id, + 'visitor' => ($is_owner) ? true : false, + 'acl' => populate_acl($itm[0],false,\PermissionDescription::fromGlobalPermission('view_pages')), + 'showacl' => ($is_owner) ? true : false, + 'mimetype' => $mimetype, + 'mimeselect' => true, + 'layout' => $layout, + 'layoutselect' => true, + 'title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'), 'lockstate' => (((strlen($itm[0]['allow_cid'])) || (strlen($itm[0]['allow_gid'])) || (strlen($itm[0]['deny_cid'])) || (strlen($itm[0]['deny_gid']))) ? 'lock' : 'unlock'), - '$bang' => '', - '$profile_uid' => (intval($owner)), - '$preview' => t('Preview'), - '$jotplugins' => $jotplugins, - '$sourceapp' => \App::$sourcename, - '$defexpire' => '', - '$bbcode' => (($mimetype == 'text/bbcode') ? true : false) - )); - + 'profile_uid' => (intval($owner)), + 'bbcode' => (($mimetype == 'text/bbcode') ? true : false) + ); + + $editor = status_editor($a, $x); + $o .= replace_macros(get_markup_template('edpost_head.tpl'), array( '$title' => t('Edit Webpage'), '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), '$editor' => $editor, '$id' => $itm[0]['id'] )); - + return $o; - + } - - - + } diff --git a/Zotlabs/Module/Events.php b/Zotlabs/Module/Events.php index a14e320b2..9519ca11b 100644 --- a/Zotlabs/Module/Events.php +++ b/Zotlabs/Module/Events.php @@ -6,6 +6,7 @@ require_once('include/bbcode.php'); require_once('include/datetime.php'); require_once('include/event.php'); require_once('include/items.php'); +require_once('include/PermissionDescription.php'); class Events extends \Zotlabs\Web\Controller { @@ -237,7 +238,7 @@ class Events extends \Zotlabs\Web\Controller { - function get() { + function get() { if(argc() > 2 && argv(1) == 'ical') { $event_id = argv(2); @@ -468,7 +469,9 @@ class Events extends \Zotlabs\Web\Controller { '$share' => array('share', t('Share this event'), $sh_checked, '', array(t('No'),t('Yes'))), '$preview' => t('Preview'), '$permissions' => t('Permission settings'), - '$acl' => (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults),false)), + // populating the acl dialog was a permission description from view_stream because Cal.php, which + // displays events, says "since we don't currently have an event permission - use the stream permission" + '$acl' => (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults), false, \PermissionDescription::fromGlobalPermission('view_stream'))), '$submit' => t('Submit'), '$advanced' => t('Advanced Options') diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php index 934a1e6a4..2861f31be 100644 --- a/Zotlabs/Module/Filestorage.php +++ b/Zotlabs/Module/Filestorage.php @@ -6,6 +6,8 @@ namespace Zotlabs\Module; */ require_once('include/attach.php'); +require_once('include/PermissionDescription.php'); + /** * @@ -132,7 +134,7 @@ class Filestorage extends \Zotlabs\Web\Controller { $cloudpath = get_cloudpath($f) . (intval($f['is_dir']) ? '?f=&davguest=1' : ''); $parentpath = get_parent_cloudpath($channel['channel_id'], $channel['channel_address'], $f['hash']); - $aclselect_e = populate_acl($f, false); + $aclselect_e = populate_acl($f, false, \PermissionDescription::fromGlobalPermission('view_storage')); $is_a_dir = (intval($f['is_dir']) ? true : false); $lockstate = (($f['allow_cid'] || $f['allow_gid'] || $f['deny_cid'] || $f['deny_gid']) ? 'lock' : 'unlock'); diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 2badd7280..c88258a78 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -6,6 +6,7 @@ require_once('include/group.php'); require_once('include/contact_widgets.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); +require_once('include/PermissionDescription.php'); @@ -170,7 +171,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') : ''), get_post_aclDialogDescription(), 'acl_dialog_post'), + 'acl' => populate_acl((($private_editing) ? $def_acl : $channel_acl), true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'), 'bang' => (($private_editing) ? '!' : ''), 'visitor' => true, 'profile_uid' => local_channel(), @@ -445,7 +446,7 @@ class Network extends \Zotlabs\Web\Controller { $ordering = "commented"; if($load) { - + // Fetch a page full of parent items for this page $r = q("SELECT distinct item.id AS item_id, $ordering FROM item @@ -468,7 +469,7 @@ class Network extends \Zotlabs\Web\Controller { ); $_SESSION['loadtime'] = datetime_convert(); } - + // Then fetch all the children of the parents that are on this page $parents_str = ''; $update_unseen = ''; diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 2b7f5525f..1659350a5 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -9,6 +9,7 @@ require_once('include/security.php'); require_once('include/Contact.php'); require_once('include/attach.php'); require_once('include/text.php'); +require_once('include/PermissionDescription.php'); @@ -632,7 +633,7 @@ class Photos extends \Zotlabs\Web\Controller { $lockstate = (($acl->is_private()) ? 'lock' : 'unlock'); } - $aclselect = (($_is_owner) ? populate_acl($channel_acl,false) : ''); + $aclselect = (($_is_owner) ? populate_acl($channel_acl,false, \PermissionDescription::fromGlobalPermission('view_storage')) : ''); // this is wrong but is to work around an issue with js_upload wherein it chokes if these variables // don't exist. They really should be set to a parseable representation of the channel's default permissions @@ -1022,7 +1023,7 @@ class Photos extends \Zotlabs\Web\Controller { if($can_post) { $album_e = $ph[0]['album']; $caption_e = $ph[0]['description']; - $aclselect_e = (($_is_owner) ? populate_acl($ph[0]) : ''); + $aclselect_e = (($_is_owner) ? populate_acl($ph[0], true, \PermissionDescription::fromGlobalPermission('view_storage')) : ''); $albums = ((array_key_exists('albums', \App::$data)) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'],\App::$data['observer'])); $_SESSION['album_return'] = bin2hex($ph[0]['album']); diff --git a/Zotlabs/Module/Rpost.php b/Zotlabs/Module/Rpost.php index 41889c35c..1396f2a55 100644 --- a/Zotlabs/Module/Rpost.php +++ b/Zotlabs/Module/Rpost.php @@ -7,6 +7,7 @@ require_once('include/items.php'); require_once('include/taxonomy.php'); require_once('include/conversation.php'); require_once('include/zot.php'); +require_once('include/PermissionDescription.php'); /** * remote post @@ -115,7 +116,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') : ''), get_post_aclDialogDescription(), 'acl_dialog_post'), + 'acl' => populate_acl($channel_acl, true, \PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'), 'bang' => '', 'visitor' => true, 'profile_uid' => local_channel(), diff --git a/Zotlabs/Module/Settings.php b/Zotlabs/Module/Settings.php index 413648c4d..a6293e842 100644 --- a/Zotlabs/Module/Settings.php +++ b/Zotlabs/Module/Settings.php @@ -2,6 +2,8 @@ namespace Zotlabs\Module; /** @file */ require_once('include/zot.php'); +require_once('include/PermissionDescription.php'); + class Settings extends \Zotlabs\Web\Controller { @@ -1064,7 +1066,7 @@ class Settings extends \Zotlabs\Web\Controller { '$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), intval($channel['channel_max_friend_req']) , t('May reduce spam activity')), '$permissions' => t('Default Post Permissions'), '$permdesc' => t("\x28click to open/close\x29"), - '$aclselect' => populate_acl($perm_defaults,false), + '$aclselect' => populate_acl($perm_defaults, false, \PermissionDescription::fromDescription(t('Use my default audience setting for the type of post'))), '$suggestme' => $suggestme, '$group_select' => $group_select, '$role' => array('permissions_role' , t('Channel permissions category:'), $permissions_role, '', get_roles()), diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php index 84d58058e..d8adb55b2 100644 --- a/Zotlabs/Module/Webpages.php +++ b/Zotlabs/Module/Webpages.php @@ -4,6 +4,7 @@ namespace Zotlabs\Module; require_once('include/identity.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); +require_once('include/PermissionDescription.php'); class Webpages extends \Zotlabs\Web\Controller { @@ -76,13 +77,7 @@ class Webpages extends \Zotlabs\Web\Controller { $mimetype = (($_REQUEST['mimetype']) ? $_REQUEST['mimetype'] : get_pconfig($owner,'system','page_mimetype')); - if(! $mimetype) { - $mimetype = 'choose'; - } - $layout = (($_REQUEST['layout']) ? $_REQUEST['layout'] : get_pconfig($owner,'system','page_layout')); - if(! $layout) - $layout = 'choose'; // Create a status editor (for now - we'll need a WYSIWYG eventually) to create pages // Nickname is set to the observers xchan, and profile_uid to the owner's. @@ -106,18 +101,21 @@ class Webpages extends \Zotlabs\Web\Controller { $o = profile_tabs($a, $is_owner, \App::$profile['channel_address']); $x = array( - 'webpage' => ITEM_TYPE_WEBPAGE, - 'is_owner' => true, - 'nickname' => \App::$profile['channel_address'], - 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - 'bang' => '', - 'acl' => (($is_owner) ? populate_acl($channel_acl,false) : ''), - 'showacl' => (($is_owner) ? true : false), - 'visitor' => true, + 'webpage' => ITEM_TYPE_WEBPAGE, + 'is_owner' => true, + 'nickname' => \App::$profile['channel_address'], + 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + 'acl' => (($is_owner) ? populate_acl($channel_acl,false, \PermissionDescription::fromGlobalPermission('view_pages')) : ''), + 'showacl' => (($is_owner) ? true : false), + 'visitor' => true, + 'hide_location' => true, + 'hide_voting' => true, 'profile_uid' => intval($owner), - 'mimetype' => $mimetype, - 'layout' => $layout, - 'expanded' => true, + 'mimetype' => $mimetype, + 'mimeselect' => true, + 'layout' => $layout, + 'layoutselect' => true, + 'expanded' => true, 'novoting'=> true, 'bbco_autocomplete' => 'bbcode', 'bbcode' => true diff --git a/boot.php b/boot.php index bc92778d4..a93e09405 100755 --- a/boot.php +++ b/boot.php @@ -313,15 +313,14 @@ define ( 'PERMS_A_REPUBLISH', 0x10000); define ( 'PERMS_W_LIKE', 0x20000); // General channel permissions - -define ( 'PERMS_PUBLIC' , 0x0001 ); -define ( 'PERMS_NETWORK' , 0x0002 ); -define ( 'PERMS_SITE' , 0x0004 ); -define ( 'PERMS_CONTACTS' , 0x0008 ); -define ( 'PERMS_SPECIFIC' , 0x0080 ); -define ( 'PERMS_AUTHED' , 0x0100 ); -define ( 'PERMS_PENDING' , 0x0200 ); - + // 0 = Only you +define ( 'PERMS_PUBLIC' , 0x0001 ); // anybody +define ( 'PERMS_NETWORK' , 0x0002 ); // anybody in this network +define ( 'PERMS_SITE' , 0x0004 ); // anybody on this site +define ( 'PERMS_CONTACTS' , 0x0008 ); // any of my connections +define ( 'PERMS_SPECIFIC' , 0x0080 ); // only specific connections +define ( 'PERMS_AUTHED' , 0x0100 ); // anybody authenticated (could include visitors from other networks) +define ( 'PERMS_PENDING' , 0x0200 ); // any connections including those who haven't yet been approved // Address book flags diff --git a/doc/acl_dialog_post.html b/doc/acl_dialog_post.html index b387ec08e..80b2c68b6 100644 --- a/doc/acl_dialog_post.html +++ b/doc/acl_dialog_post.html @@ -3,13 +3,11 @@

Post Permissions

-

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

+

The permissions dialog lets you select which 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".
+
+
Tip! +
The border color of each channel indicates whether that channel — or one of the groups it's a member of — will have access to the post. The border color will also indicate when a channel, or group it belongs to, has been explicitly set to "Don't show".

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

diff --git a/doc/dev-function-overview.md b/doc/dev-function-overview.md index 1ef80d343..fa8a98ff3 100644 --- a/doc/dev-function-overview.md +++ b/doc/dev-function-overview.md @@ -1,5 +1,5 @@ -Red development - some useful basic functions -============================================= +$Projectname development - some useful basic functions +====================================================== @@ -17,11 +17,11 @@ Returns authenticated string hash of Red global identifier, if authenticated via * get_app() -Returns the global app structure ($a). +Returns the global app structure ($a). No longer used as App is a static class * App::get_observer() -(App:: is usually assigned to the global $a), so App::get_observer() or App::get_observer() - returns an xchan structure representing the current viewer if authenticated (locally or remotely). +returns an xchan structure representing the current viewer if authenticated (locally or remotely). * get_config($family,$key), get_pconfig($uid,$family,$key) diff --git a/doc/developer_function_primer.bb b/doc/developer_function_primer.bb index 373454440..684fea569 100644 --- a/doc/developer_function_primer.bb +++ b/doc/developer_function_primer.bb @@ -1,4 +1,4 @@ -[b]Red development - some useful basic functions[/b] +[b]$Projectname development - some useful basic functions[/b] [b]get_account_id()[/b] @@ -18,7 +18,7 @@ Returns the global app structure ($a). [b]App::get_observer()[/b] -(App:: is usually assigned to the global $a), so $a->get_observer() or get_app()->get_observer() - returns an xchan structure representing the current viewer if authenticated (locally or remotely). +returns an xchan structure representing the current viewer if authenticated (locally or remotely). [b]get_config($family,$key), get_pconfig($uid,$family,$key), get_xconfig($xchan_hash,$family,$key)[/b] diff --git a/doc/hooklist.bb b/doc/hooklist.bb index 9331873b4..bb1bffcf0 100644 --- a/doc/hooklist.bb +++ b/doc/hooklist.bb @@ -70,6 +70,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the [zrl=[baseurl]/help/hook/bbcode]bbcode[/zrl] Called when converting bbcode to HTML +[zrl=[baseurl]/help/hook/bb_translate_video]bb_translate_video[/zrl] + Called when extracting embedded services from bbcode video elements (rarely used) + [zrl=[baseurl]/help/hook/channel_remove]channel_remove[/zrl] Called when removing a channel @@ -242,8 +245,11 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the [zrl=[baseurl]/help/hook/hostxrd]hostxrd[/zrl] Called when generating .well-known/hosts-meta for "old webfinger" (used by Diaspora protocol) +[zrl=[baseurl]/help/hook/html2bb_video]html2bb_video[/zrl] + Called when using the html2bbcode translation to handle embedded media + [zrl=[baseurl]/help/hook/html2bbcode]html2bbcode[/zrl] - Called when using the html2bbcode tranlsation + Called when using the html2bbcode translation [zrl=[baseurl]/help/hook/identity_basic_export]identity_basic_export[/zrl] Called when exporting a channel's basic information for backup or transfer diff --git a/include/PermissionDescription.php b/include/PermissionDescription.php new file mode 100644 index 000000000..75dd9ecf7 --- /dev/null +++ b/include/PermissionDescription.php @@ -0,0 +1,178 @@ +global_perm = $global_perm; + $this->channel_perm = $channel_perm; + + $this->fallback_description = ($description == '') ? t('Visible to your default audience') : $description; + } + + /** + * If the interpretation of an empty ACL can't be summarised with a global default permission + * or a specific permission setting then use this method and describe what it means instead. + * Remember to localize the description first. + * + * @param string $description - the localized caption for the no-ACL option in the ACL dialog. + * @return a new instance of PermissionDescription + */ + public static function fromDescription($description) { + return new PermissionDescription('', 0x80000, $description); + } + + + /** + * Use this method only if the interpretation of an empty ACL doesn't fall back to a global + * default permission. You should pass one of the constants from boot.php - PERMS_PUBLIC, + * PERMS_NETWORK etc. + * + * @param integer $perm - a single enumerated constant permission - PERMS_PUBLIC, PERMS_NETWORK etc. + * @return a new instance of PermissionDescription + */ + public static function fromStandalonePermission($perm) { + + $result = new PermissionDescription('', $perm); + + $checkPerm = $this->get_permission_description(); + if ($checkPerm == $this->fallback_description) { + $result = null; + logger('null PermissionDescription from unknown standalone permission: ' . $perm ,LOGGER_DEBUG, LOG_ERROR); + } + + return $result; + } + + /** + * This is the preferred way to create a PermissionDescription, as it provides the most details. + * Use this method if you know an empty ACL will result in one of the global default permissions + * being used, such as channel_r_stream (for which you would pass 'view_stream'). + * + * @param string $permname - a key for the global perms array from get_perms() in permissions.php, + * e.g. 'view_stream', 'view_profile', etc. + * @return a new instance of PermissionDescription + */ + public static function fromGlobalPermission($permname) { + + $result = null; + + $global_perms = get_perms(); + + if (array_key_exists($permname, $global_perms)) { + + $permDetails = $global_perms[$permname]; + + // It should be OK to always just read the permissions from App::$channel + // + // App::$profile is a union of channel and profile fields. + // The distinction is basically that App::$profile is pointing to the resource + // being observed. App::$channel is referring to the current logged-in channel + // member (if this is a local channel) e.g. the observer. We only show the ACL + // widget to the page owner (observer and observed are the same) so in that case + // I believe either may be safely used here. + $channelPerm = \App::$channel[$permDetails[0]]; + $result = new PermissionDescription($permDetails[1], $channelPerm); + } else { + // The acl dialog can handle null arguments, but it shouldn't happen + logger('null PermissionDescription from unknown global permission: ' . $permname ,LOGGER_DEBUG, LOG_ERROR); + } + return $result; + } + + + /** + * Gets a localized description of the permission, or a generic message if the permission + * is unknown. + * + * @return string description + */ + public function get_permission_description() { + + switch($this->channel_perm) { + + case 0: return t('Only me'); + case PERMS_PUBLIC: return t('Public'); + case PERMS_NETWORK: return t('Anybody in the $Projectname network'); + case PERMS_SITE: return sprintf(t('Any account on %s'), \App::get_hostname()); + case PERMS_CONTACTS: return t('Any of my connections'); + case PERMS_SPECIFIC: + // Because we're describing the permissions of an item with an empty ACL, + // the owner will be the only person able to see it if the permissions are + // set to "only specified connections". + return t('Only me (only specified contacts and me)'); + case PERMS_AUTHED: return t('Anybody authenticated (could include visitors from other networks)'); + case PERMS_PENDING: return t('Any connections including those who haven\'t yet been approved'); + default: return $this->fallback_description; + } + } + + /** + * Returns an icon css class name if an appropriate one is available, e.g. "fa-globe" for Public, + * otherwise returns empty string. + * + * @return string icon css class name (often FontAwesome) + */ + public function get_permission_icon() { + + switch($this->channel_perm) { + + case 0:/* only me */ return 'fa-eye-slash'; + case PERMS_PUBLIC: return 'fa-globe'; + case PERMS_NETWORK: return 'fa-share-alt-square'; // fa-share-alt-square is very similiar to the hubzilla logo, but we should create our own logo class to use + case PERMS_SITE: return 'fa-sitemap'; + case PERMS_CONTACTS: return 'fa-group'; + case PERMS_SPECIFIC: + // Because we're describing the permissions of an item with an empty ACL, + // the owner will be the only person able to see it if the permissions are + // set to "only specified connections". + return 'fa-eye-slash'; + case PERMS_AUTHED: return ''; + case PERMS_PENDING: return ''; + default: return ''; + } + } + + + /** + * Returns a localized description of where the permission came from, if this is known. + * If it's not know, or if the permission is standalone and didn't come from a default + * permission setting, then empty string is returned. + * + * @return string description or empty string + */ + public function get_permission_origin_description() { + + switch($this->global_perm) { + + case PERMS_R_STREAM: return t('This is your default setting for the audience of your normal stream, and posts.'); + case PERMS_R_PROFILE: return t('This is your default setting for who can view your default channel profile'); + case PERMS_R_ABOOK: return t('This is your default setting for who can view your connections'); + case PERMS_R_STORAGE: return t('This is your default setting for who can view your file storage and photos'); + case PERMS_R_PAGES: return t('This is your default setting for the audience of your webpages'); + default: return ''; + } + } + +} diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 4cc01d15b..ce0a32798 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -6,6 +6,9 @@ /** * @package acl_selectors */ + +require_once("include/PermissionDescription.php"); + function group_select($selname,$selclass,$preselected = false,$size = 4) { $a = get_app(); @@ -215,20 +218,34 @@ function fixacl(&$item) { * * @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 PermissionDescription $emptyACL_description - An optional description for the permission implied by selecting an empty ACL. Preferably an instance of PermissionDescription. * @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 built from acl_selector.tpl */ -function populate_acl($defaults = null,$show_jotnets = true, $showall_caption = '', $dialog_description = '', $context_help = '', $readonly = false) { +function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_description = '', $dialog_description = '', $context_help = '', $readonly = false) { $allow_cid = $allow_gid = $deny_cid = $deny_gid = false; + $showall_origin = ''; + $showall_icon = 'fa-globe'; - if(! $showall_caption) + + if(! $emptyACL_description) { $showall_caption = t('Visible to your default audience'); + } else if (is_a($emptyACL_description, 'PermissionDescription')) { + $showall_caption = $emptyACL_description->get_permission_description(); + $showall_origin = $emptyACL_description->get_permission_origin_description(); + $showall_icon = $emptyACL_description->get_permission_icon(); + + } else { + // For backwards compatibility we still accept a string... for now! + $showall_caption = $emptyACL_description; + } + + if(is_array($defaults)) { $allow_cid = ((strlen($defaults['allow_cid'])) ? explode('><', $defaults['allow_cid']) : array() ); @@ -252,6 +269,8 @@ function populate_acl($defaults = null,$show_jotnets = true, $showall_caption = $tpl = get_markup_template("acl_selector.tpl"); $o = replace_macros($tpl, array( '$showall' => $showall_caption, + '$showallOrigin' => $showall_origin, + '$showallIcon' => $showall_icon, '$showlimited' => t("Limit access:"), '$showlimitedDesc' => t('Select "Show" to allow viewing. "Don\'t show" lets you override and limit the scope of "Show".'), '$show' => t("Show"), @@ -278,7 +297,7 @@ function populate_acl($defaults = null,$show_jotnets = true, $showall_caption = * 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 +* cannot be used as a string table (because the value is always the key in english) so * I've centralized the value here (making this function name the "key") until we have a * better way. * diff --git a/include/bbcode.php b/include/bbcode.php index 7a7ea8ce6..fd2d2f97a 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -492,18 +492,6 @@ function bb_observer($Text) { function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) { - $a = get_app(); - - // Move all spaces out of the tags - // ....Uhm why? - // This is basically doing a trim() on the stuff in between tags, but it messes up - // carefully crafted bbcode and especially other pre-formatted code. - // Commenting out until we come up with a use case where it's needed. Then let's try and - // special case rather than a heavy-handed approach like this. - -// $Text = preg_replace("/\[(\w*)\](\s*)/ism", '$2[$1]', $Text); -// $Text = preg_replace("/(\s*)\[\/(\w*)\]/ism", '[/$2]$1', $Text); - // Hide all [noparse] contained bbtags by spacefying them if (strpos($Text,'[noparse]') !== false) { $Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_spacefy',$Text); @@ -834,9 +822,6 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) } - - - // Declare the format for [quote] layout $QuoteLayout = '
$1
'; @@ -978,37 +963,6 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) } } - // Youtube extensions -// if (strpos($Text,'[youtube]') !== false) { -// if ($tryoembed) { -// $Text = preg_replace_callback("/\[youtube\](https?:\/\/www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text); -// $Text = preg_replace_callback("/\[youtube\](www.youtube.com\/watch\?v\=.*?)\[\/youtube\]/ism", 'tryoembed', $Text); -// $Text = preg_replace_callback("/\[youtube\](https?:\/\/youtu.be\/.*?)\[\/youtube\]/ism", 'tryoembed', $Text); -// } -// $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $Text); -// $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/embed\/(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $Text); -// $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism", '[youtube]$1[/youtube]', $Text); - -// if ($tryoembed) -// $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '', $Text); -// else -// $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", "http://www.youtube.com/watch?v=$1", $Text); -// } -// if (strpos($Text,'[vimeo]') !== false) { -// if ($tryoembed) { -// $Text = preg_replace_callback("/\[vimeo\](https?:\/\/player.vimeo.com\/video\/[0-9]+).*?\[\/vimeo\]/ism", 'tryoembed', $Text); -// $Text = preg_replace_callback("/\[vimeo\](https?:\/\/vimeo.com\/[0-9]+).*?\[\/vimeo\]/ism", 'tryoembed', $Text); -// } - -// $Text = preg_replace("/\[vimeo\]https?:\/\/player.vimeo.com\/video\/([0-9]+)(.*?)\[\/vimeo\]/ism", '[vimeo]$1[/vimeo]', $Text); -// $Text = preg_replace("/\[vimeo\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/vimeo\]/ism", '[vimeo]$1[/vimeo]', $Text); - -// if ($tryoembed) -// $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '', $Text); -// else -// $Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", "http://vimeo.com/$1", $Text); -// } - // oembed tag $Text = oembed_bbcode2html($Text); diff --git a/include/conversation.php b/include/conversation.php index ea5be221f..8be0557e7 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1138,33 +1138,29 @@ function status_editor($a, $x, $popup = false) { if(x($x, 'hide_location')) $geotag = $setloc = $clearloc = ''; - $weblink = t('Insert web link'); - if(x($x, 'hide_weblink')) - $weblink = ''; + $mimetype = ((x($x,'mimetype')) ? $x['mimetype'] : 'text/bbcode'); - $writefiles = perm_is_allowed($x['profile_uid'], get_observer_hash(), 'write_storage'); + $mimeselect = ((x($x,'mimeselect')) ? $x['mimeselect'] : false); + if($mimeselect) + $mimeselect = mimetype_select($x['profile_uid'], $mimetype); + else + $mimeselect = ''; + + $weblink = (($mimetype === 'text/bbcode') ? t('Insert web link') : false); + if(x($x, 'hide_weblink')) + $weblink = false; + + $writefiles = (($mimetype === 'text/bbcode') ? perm_is_allowed($x['profile_uid'], get_observer_hash(), 'write_storage') : false); if(x($x, 'hide_attach')) $writefiles = false; - $mimeselect = ''; - if(array_key_exists('mimetype', $x) && $x['mimetype']) { - if($x['mimetype'] != 'text/bbcode') - $plaintext = true; - if($x['mimetype'] === 'choose') { - $mimeselect = mimetype_select($x['profile_uid']); - } - else - $mimeselect = ''; - } + $layout = ((x($x,'layout')) ? $x['layout'] : ''); - $layoutselect = ''; - if(array_key_exists('layout', $x) && $x['layout']) { - if($x['layout'] === 'choose') { - $layoutselect = layout_select($x['profile_uid']); - } - else - $layoutselect = ''; - } + $layoutselect = ((x($x,'layoutselect')) ? $x['layoutselect'] : false); + if($layoutselect) + $layoutselect = layout_select($x['profile_uid'], $layout); + else + $layoutselect = ''; if(array_key_exists('channel_select',$x) && $x['channel_select']) { require_once('include/identity.php'); diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index 3c5b0b67e..8e205a4aa 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -59,8 +59,9 @@ abstract class dba_driver { const NULL_DATE = '0000-00-00 00:00:00'; const UTC_NOW = 'UTC_TIMESTAMP()'; - protected $debug = 0; protected $db; + + public $debug = 0; public $connected = false; public $error = false; @@ -302,10 +303,10 @@ function q($sql) { $stmt = vsprintf($sql, $args); if($stmt === false) { if(version_compare(PHP_VERSION, '5.4.0') >= 0) - logger('dba: vsprintf error: ' . + db_logger('dba: vsprintf error: ' . print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 1), true),LOGGER_NORMAL,LOG_CRIT); else - logger('dba: vsprintf error: ' . print_r(debug_backtrace(), true),LOGGER_NORMAL,LOG_CRIT); + db_logger('dba: vsprintf error: ' . print_r(debug_backtrace(), true),LOGGER_NORMAL,LOG_CRIT); } return $db->q($stmt); } @@ -314,7 +315,7 @@ function q($sql) { * This will happen occasionally trying to store the * session data after abnormal program termination */ - logger('dba: no database: ' . print_r($args,true),LOGGER_NORMAL,LOG_CRIT); + db_logger('dba: no database: ' . print_r($args,true),LOGGER_NORMAL,LOG_CRIT); return false; } @@ -385,7 +386,19 @@ function db_getfunc($f) { if(isset($lookup[$f]) && isset($lookup[$f][ACTIVE_DBTYPE])) return $lookup[$f][ACTIVE_DBTYPE]; - logger('Unable to abstract DB function "'. $f . '" for dbtype ' . ACTIVE_DBTYPE, LOGGER_DEBUG, LOG_ERR); + db_logger('Unable to abstract DB function "'. $f . '" for dbtype ' . ACTIVE_DBTYPE, LOGGER_DEBUG, LOG_ERR); return $f; } +// The logger function may make DB calls internally to query the system logging parameters. +// This can cause a recursion if database debugging is enabled. +// So this function preserves the current database debugging state and then turns it off while +// doing the logger() call + +function db_logger($s,$level = LOGGER_NORMAL,$syslog = LOG_INFO) { + global $db; + $saved = $db->debug; + $db->debug = false; + logger($s,$level,$syslog); + $db->debug = $saved; +} \ No newline at end of file diff --git a/include/dba/dba_mysqli.php b/include/dba/dba_mysqli.php index 57a7559a1..afd2aa642 100755 --- a/include/dba/dba_mysqli.php +++ b/include/dba/dba_mysqli.php @@ -38,7 +38,7 @@ class dba_mysqli extends dba_driver { if($this->error) { - logger('dba_mysqli: ERROR: ' . printable($sql) . "\n" . $this->error, LOGGER_NORMAL, LOG_ERR); + db_logger('dba_mysqli: ERROR: ' . printable($sql) . "\n" . $this->error, LOGGER_NORMAL, LOG_ERR); if(file_exists('dbfail.out')) { file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . "\n" . $this->error . "\n", FILE_APPEND); } @@ -46,13 +46,13 @@ class dba_mysqli extends dba_driver { if(($result === true) || ($result === false)) { if($this->debug) { - logger('dba_mysqli: DEBUG: ' . printable($sql) . ' returns ' . (($result) ? 'true' : 'false'), LOGGER_NORMAL,(($result) ? LOG_INFO : LOG_ERR)); + db_logger('dba_mysqli: DEBUG: ' . printable($sql) . ' returns ' . (($result) ? 'true' : 'false'), LOGGER_NORMAL,(($result) ? LOG_INFO : LOG_ERR)); } return $result; } if($this->debug) { - logger('dba_mysqli: DEBUG: ' . printable($sql) . ' returned ' . $result->num_rows . ' results.', LOGGER_NORMAL, LOG_INFO); + db_logger('dba_mysqli: DEBUG: ' . printable($sql) . ' returned ' . $result->num_rows . ' results.', LOGGER_NORMAL, LOG_INFO); } $r = array(); @@ -61,7 +61,7 @@ class dba_mysqli extends dba_driver { $r[] = $x; $result->free_result(); if($this->debug) { - logger('dba_mysqli: ' . printable(print_r($r,true)), LOGGER_NORMAL, LOG_INFO); + db_logger('dba_mysqli: ' . printable(print_r($r,true)), LOGGER_NORMAL, LOG_INFO); } } return $r; diff --git a/include/dba/dba_postgres.php b/include/dba/dba_postgres.php index ba4366d13..03b29d703 100644 --- a/include/dba/dba_postgres.php +++ b/include/dba/dba_postgres.php @@ -50,7 +50,7 @@ class dba_postgres extends dba_driver { $this->error = pg_last_error($this->db); if($result === false || $this->error) { - //logger('dba_postgres: ' . printable($sql) . ' returned false.' . "\n" . $this->error); + //db_logger('dba_postgres: ' . printable($sql) . ' returned false.' . "\n" . $this->error); if(file_exists('dbfail.out')) file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND); } @@ -67,7 +67,7 @@ class dba_postgres extends dba_driver { $r[] = $x; pg_free_result($result); if($this->debug) - logger('dba_postgres: ' . printable(print_r($r,true))); + db_logger('dba_postgres: ' . printable(print_r($r,true))); } return $r; } diff --git a/include/items.php b/include/items.php index b3c9403e0..bef04237b 100755 --- a/include/items.php +++ b/include/items.php @@ -2223,7 +2223,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { dbesc($arr['layout_mid']), intval($arr['uid']) ); - if((! $l) || (! ($l[0]['item_type'] != ITEM_TYPE_PDL))) + if((! $l) || ($l[0]['item_type'] != ITEM_TYPE_PDL)) unset($arr['layout_mid']); } @@ -5664,4 +5664,4 @@ function sync_an_item($channel_id,$item_id) { ); build_sync_packet($channel_d,array('item' => array(encode_item($sync_item[0],true)),'item_id' => $rid)); } -} \ No newline at end of file +} diff --git a/include/text.php b/include/text.php index a3826de49..a2c0a3209 100644 --- a/include/text.php +++ b/include/text.php @@ -1895,32 +1895,15 @@ function cleardiv() { function bb_translate_video($s) { - - $matches = null; - $r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER); - if($r) { - foreach($matches as $mtch) { - if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be'))) - $s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s); - elseif(stristr($mtch[1],'vimeo')) - $s = str_replace($mtch[0],'[vimeo]' . $mtch[1] . '[/vimeo]',$s); - } - } - return $s; + $arr = array('string' => $s); + call_hooks('bb_translate_video',$arr); + return $arr['string']; } function html2bb_video($s) { - - $s = preg_replace('#]+>(.*?)https?://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+)(.*?)#ism', - '[youtube]$2[/youtube]', $s); - - $s = preg_replace('#](.*?)https?://www.youtube.com/embed/([A-Za-z0-9\-_=]+)(.*?)#ism', - '[youtube]$2[/youtube]', $s); - - $s = preg_replace('#](.*?)https?://player.vimeo.com/video/([0-9]+)(.*?)#ism', - '[vimeo]$2[/vimeo]', $s); - - return $s; + $arr = array('string' => $s); + call_hooks('html2bb_video',$arr); + return $arr['string']; } /** diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 547fe9ec3..ebabd68e4 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -1046,6 +1046,13 @@ a.rconnect:hover, a.rateme:hover, div.rateme:hover { font-size: 140%; } +#acl-info-icon, +#acl-info-icon:active { + font-size: 110%; + color: $link_colour; + text-decoration: none; +} + #acl-showall-caption { margin-left: 0.35em; } diff --git a/view/tpl/acl_selector.tpl b/view/tpl/acl_selector.tpl index 0df72747a..050417257 100755 --- a/view/tpl/acl_selector.tpl +++ b/view/tpl/acl_selector.tpl @@ -25,8 +25,12 @@
+ {{if $showallOrigin}} +   + {{/if}}