From 75128e8f68e829ad9e3670dac82f075d9632dba4 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 7 May 2016 23:05:48 +0200 Subject: make editblock use status_editor() --- include/conversation.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index ea5be221f..32a613eab 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1138,25 +1138,22 @@ function status_editor($a, $x, $popup = false) { if(x($x, 'hide_location')) $geotag = $setloc = $clearloc = ''; - $weblink = t('Insert web link'); + $mimetype = ((x($x,'mimetype')) ? $x['mimetype'] : 'text/bbcode'); + + $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 = ''; + $weblink = false; - $writefiles = perm_is_allowed($x['profile_uid'], get_observer_hash(), 'write_storage'); + $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 = ''; - } - $layoutselect = ''; if(array_key_exists('layout', $x) && $x['layout']) { if($x['layout'] === 'choose') { -- cgit v1.2.3 From e7a65c1f8d97b92e311beb064a7094216e23b119 Mon Sep 17 00:00:00 2001 From: Treer Date: Sun, 8 May 2016 20:44:30 +1000 Subject: improve non-ACL option description in ACL dialog --- include/PermissionDescription.php | 167 ++++++++++++++++++++++++++++++++++++++ include/acl_selectors.php | 27 +++++- 2 files changed, 190 insertions(+), 4 deletions(-) create mode 100644 include/PermissionDescription.php (limited to 'include') diff --git a/include/PermissionDescription.php b/include/PermissionDescription.php new file mode 100644 index 000000000..d5a3a972c --- /dev/null +++ b/include/PermissionDescription.php @@ -0,0 +1,167 @@ +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. + * + * @param string $description - the 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]; + $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. * -- cgit v1.2.3 From 2a14c7112834d4127f78ce177534045efe3c34a1 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 8 May 2016 19:12:52 -0700 Subject: convert media embed functions that deal with rewriting specific corporate services to addon hooks --- include/text.php | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'include') 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']; } /** -- cgit v1.2.3 From b6e0d8dee02b1ecbb1396b9b973e11b92cd3b35b Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 8 May 2016 20:19:23 -0700 Subject: clean up some cruft --- include/bbcode.php | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) (limited to 'include') 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); -- cgit v1.2.3 From 6f486a3393fe33db70ef2f1684dd3b79768d1137 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 9 May 2016 01:12:24 -0700 Subject: prevent recursion in the database driver when debugging is enabled and the system config is not yet loaded - caused by calling get_config and making db calls within the logger function; which we then attempt to log... --- include/dba/dba_driver.php | 23 ++++++++++++++++++----- include/dba/dba_mysqli.php | 8 ++++---- include/dba/dba_postgres.php | 4 ++-- 3 files changed, 24 insertions(+), 11 deletions(-) (limited to 'include') 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; } -- cgit v1.2.3 From 24c1dc528dd981fc73baab8dc47840439e81f3b7 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 9 May 2016 11:56:42 +0200 Subject: make editwebpage use status_editor() and fix storing of layout on webpage creation --- include/conversation.php | 13 +++++++++++-- include/items.php | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 32a613eab..48cb0af6b 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1144,7 +1144,7 @@ function status_editor($a, $x, $popup = false) { if($mimeselect) $mimeselect = mimetype_select($x['profile_uid'], $mimetype); else - $mimeselect = ''; + $mimeselect = ''; $weblink = (($mimetype === 'text/bbcode') ? t('Insert web link') : false); if(x($x, 'hide_weblink')) @@ -1154,6 +1154,15 @@ function status_editor($a, $x, $popup = false) { if(x($x, 'hide_attach')) $writefiles = false; + $layout = ((x($x,'layout')) ? $x['layout'] : 'default'); + + $layoutselect = ((x($x,'layoutselect')) ? $x['layoutselect'] : false); + if($layoutselect) + $layoutselect = layout_select($x['profile_uid'], $layout); + else + $layoutselect = ''; + +/* $layoutselect = ''; if(array_key_exists('layout', $x) && $x['layout']) { if($x['layout'] === 'choose') { @@ -1162,7 +1171,7 @@ function status_editor($a, $x, $popup = false) { else $layoutselect = ''; } - +*/ if(array_key_exists('channel_select',$x) && $x['channel_select']) { require_once('include/identity.php'); $id_select = identity_selector(); 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 +} -- cgit v1.2.3 From 7aeff7505be6bd5fd10b04efaedf0e35915e0154 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 9 May 2016 12:09:04 +0200 Subject: remove unused code and whitespace --- include/conversation.php | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 48cb0af6b..7c7f6732d 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1162,16 +1162,6 @@ function status_editor($a, $x, $popup = false) { else $layoutselect = ''; -/* - $layoutselect = ''; - if(array_key_exists('layout', $x) && $x['layout']) { - if($x['layout'] === 'choose') { - $layoutselect = layout_select($x['profile_uid']); - } - else - $layoutselect = ''; - } -*/ if(array_key_exists('channel_select',$x) && $x['channel_select']) { require_once('include/identity.php'); $id_select = identity_selector(); -- cgit v1.2.3 From 61909d2480dc7098932058c4a3ab076d32bdda3e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 9 May 2016 12:24:48 +0200 Subject: if we do not have a layout $layout should be empty not default --- include/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 7c7f6732d..8be0557e7 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1154,7 +1154,7 @@ function status_editor($a, $x, $popup = false) { if(x($x, 'hide_attach')) $writefiles = false; - $layout = ((x($x,'layout')) ? $x['layout'] : 'default'); + $layout = ((x($x,'layout')) ? $x['layout'] : ''); $layoutselect = ((x($x,'layoutselect')) ? $x['layoutselect'] : false); if($layoutselect) -- cgit v1.2.3 From ef97e5a0636c2563f696b8601619d963b363fe00 Mon Sep 17 00:00:00 2001 From: Treer Date: Tue, 10 May 2016 00:15:57 +1000 Subject: minor cleanup. No functional changes --- include/PermissionDescription.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/PermissionDescription.php b/include/PermissionDescription.php index d5a3a972c..75dd9ecf7 100644 --- a/include/PermissionDescription.php +++ b/include/PermissionDescription.php @@ -32,10 +32,11 @@ class PermissionDescription { } /** - * If the interpretation of an empty ACL can't be summarised with a global default permission + * 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 caption for the no-ACL option in the ACL dialog. + * @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) { @@ -44,8 +45,9 @@ class PermissionDescription { /** - * 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. + * 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 @@ -81,6 +83,15 @@ class PermissionDescription { 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 { -- cgit v1.2.3