From cdc52ba88418f4289f8712ade232e429242f82e7 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Jan 2015 16:27:27 -0800 Subject: change deletion behaviour of linked photo items. Previously deleting the visible item in the conversation deleted the photo as well. Now photos must be deleted in the photos module. Deleting the linked item removes any attached conversation elements (likes, etc.) and sets the conversation item to hidden. This may create an issue in the future if we move the photo tags, title, or other photo elements to the linked item rather than the photo. Noting here so this can potentially be discovered and remembered at that time. --- include/items.php | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 4c533aedc..e9e78acc5 100755 --- a/include/items.php +++ b/include/items.php @@ -3939,7 +3939,7 @@ function drop_items($items) { // $stage = 1 => set deleted flag on the item and perform intial notifications // $stage = 2 => perform low level delete at a later stage -function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { +function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = false) { $a = get_app(); @@ -3959,6 +3959,8 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { $item = $r[0]; + $linked_item = (($item['resource_id']) ? true : false); + $ok_to_delete = false; // system deletion @@ -3980,10 +3982,11 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { // hook calls a remote process which loops. We'll delete it properly in a second. $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ) WHERE id = %d", - intval(ITEM_DELETED), + intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED), intval($item['id']) ); + $arr = array('item' => $item, 'interactive' => $interactive, 'stage' => $stage); call_hooks('drop_item', $arr ); @@ -3995,10 +3998,10 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { ); if($items) { foreach($items as $i) - delete_item_lowlevel($i,$stage); + delete_item_lowlevel($i,$stage,$force); } else - delete_item_lowlevel($item,$stage); + delete_item_lowlevel($item,$stage,$force); if(! $interactive) return 1; @@ -4030,8 +4033,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { // It merely destroys all resources associated with an item. // Please do not use without a suitable wrapper. -function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { +function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL,$force = false) { + $linked_item = (($item['resource_id']) ? true : false); switch($stage) { case DROPITEM_PHASE2: @@ -4047,7 +4051,7 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { case DROPITEM_PHASE1: $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), changed = '%s', edited = '%s' WHERE id = %d", - intval(ITEM_DELETED), + intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($item['id']) @@ -4058,7 +4062,7 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { default: $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '', changed = '%s', edited = '%s' WHERE id = %d", - intval(ITEM_DELETED), + intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($item['id']) @@ -4074,25 +4078,6 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { intval($item['uid']) ); - // If item is a link to a photo/event resource, nuke all the associated photos/events - // This only applies to photos uploaded from the photos page. Photos inserted into a post do not - // generate a resource_id and therefore aren't intimately linked to the item. - - if(strlen($item['resource_id'])) { - if($item['resource_type'] === 'event') { - q("delete from event where event_hash = '%s' and uid = %d", - dbesc($item['resource_id']), - intval($item['uid']) - ); - } - elseif($item['resource_type'] === 'photo') { - q("DELETE FROM `photo` WHERE `resource_id` = '%s' AND `uid` = %d ", - dbesc($item['resource_id']), - intval($item['uid']) - ); - } - } - // network deletion request. Keep the message structure so that we can deliver delete notifications. // Come back after several days (or perhaps a month) to do the lowlevel delete (DROPITEM_PHASE2). @@ -4115,8 +4100,7 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { intval(TERM_OBJ_POST) ); -// FIXME remove notifications for this item - + // FIXME remove notifications for this item return true; } -- cgit v1.2.3 From 66cef7531a182dcf122ddb2ea695628b4d083bd8 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Jan 2015 16:36:10 -0800 Subject: don't wipe out the item body of a linked item to a photo when doing a normal delete and not forced --- include/items.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index e9e78acc5..dd9dbc7f9 100755 --- a/include/items.php +++ b/include/items.php @@ -4060,13 +4060,24 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL,$force = false) { case DROPITEM_NORMAL: default: - $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '', - changed = '%s', edited = '%s' WHERE id = %d", - intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($item['id']) - ); + if($linked_item && ! $force) { + $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), + changed = '%s', edited = '%s' WHERE id = %d", + intval(ITEM_HIDDEN), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + } + else { + $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '', + changed = '%s', edited = '%s' WHERE id = %d", + intval(ITEM_DELETED), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + } break; } -- cgit v1.2.3 From 1b3e52af2dc4f2872c666784b284a5ba0a8de61d Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Jan 2015 18:33:39 -0800 Subject: theme toggle issue when viewing mod/cloud of another channel --- include/RedDAV/RedBrowser.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php index 709f6339b..ddeed74be 100644 --- a/include/RedDAV/RedBrowser.php +++ b/include/RedDAV/RedBrowser.php @@ -267,6 +267,15 @@ class RedBrowser extends DAV\Browser\Plugin { get_app()->page['content'] = $html; load_pdl(get_app()); + + $theme_info_file = "view/theme/" . current_theme() . "/php/theme.php"; + if (file_exists($theme_info_file)){ + require_once($theme_info_file); + if (function_exists(str_replace('-', '_', current_theme()) . '_init')) { + $func = str_replace('-', '_', current_theme()) . '_init'; + $func($a); + } + } construct_page(get_app()); } -- cgit v1.2.3 From 2fc0d641393a56f056e50af65c82147a6a392f85 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Jan 2015 19:29:43 -0800 Subject: uninitialised theme parent in mod/cloud --- include/RedDAV/RedBrowser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php index ddeed74be..9ea2b9808 100644 --- a/include/RedDAV/RedBrowser.php +++ b/include/RedDAV/RedBrowser.php @@ -273,7 +273,7 @@ class RedBrowser extends DAV\Browser\Plugin { require_once($theme_info_file); if (function_exists(str_replace('-', '_', current_theme()) . '_init')) { $func = str_replace('-', '_', current_theme()) . '_init'; - $func($a); + $func(get_app()); } } construct_page(get_app()); -- cgit v1.2.3 From 93735df2c78b249d5735834c190dc91bad336172 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Tue, 13 Jan 2015 17:54:40 +0100 Subject: Allow tags in mail, many profile fields, and admin info --- include/identity.php | 14 +------------- include/text.php | 2 +- 2 files changed, 2 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index 2f400520f..d98f39cb7 100644 --- a/include/identity.php +++ b/include/identity.php @@ -1205,21 +1205,9 @@ function advanced_profile(&$a) { if($txt = prepare_text($a->profile['dislikes'])) $profile['dislikes'] = array( t('Dislikes:'), $txt); - if($txt = prepare_text($a->profile['contact'])) $profile['contact'] = array( t('Contact information and Social Networks:'), $txt); - // Support tags in the other channels field (probably want to restrict it to channels only?) - $txt = $a->profile['channels']; - $matches = get_tags($txt); - $access_tag = ''; - $str_tags = ''; - foreach($matches as $m) { - $success = handle_tag($a, $txt, $access_tag, $str_tags, $a->profile_uid, $m); // Use uid of the profile maker - } - - if($txt = prepare_text($txt)) { - $profile['channels'] = array( t('My other channels:'), $txt); - } + if($txt = prepare_text($a->profile['channels'])) $profile['channels'] = array( t('My other channels:'), $txt); if($txt = prepare_text($a->profile['music'])) $profile['music'] = array( t('Musical interests:'), $txt); diff --git a/include/text.php b/include/text.php index 035c092a6..6b579e35c 100644 --- a/include/text.php +++ b/include/text.php @@ -2351,7 +2351,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) { return array('replaced' => $replaced, 'termtype' => $termtype, 'term' => $newname, 'url' => $url, 'contact' => $r[0]); } -function linkify_tags($a, &$body, $uid, $profile_uid) { +function linkify_tags($a, &$body, $uid) { $str_tags = ''; $tagged = array(); $result = array(); -- cgit v1.2.3 From dfdef0af0d045bdb0eb6e5ed557579966891e1a0 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 Jan 2015 18:30:30 -0800 Subject: provide a setting to control ALLOWCODE permissions at the channel level - it isn't always appropriate to apply this to all channels in an account. --- include/text.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 6b579e35c..18ef22d28 100644 --- a/include/text.php +++ b/include/text.php @@ -92,10 +92,10 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') { return escape_tags($s); if($type == 'text/plain') return escape_tags($s); - $r = q("select account_id, account_roles from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", + $r = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", intval($channel_id) ); - if($r && ($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE)) { + if($r && (($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE))) { if(local_user() && (get_account_id() == $r[0]['account_id'])) { return $s; } @@ -1584,13 +1584,13 @@ function mimetype_select($channel_id, $current = 'text/bbcode') { 'text/plain' ); - $r = q("select account_id, account_roles from account left join channel on account_id = channel_account_id where + $r = q("select account_id, account_roles, channel_pageflags from account left join channel on account_id = channel_account_id where channel_id = %d limit 1", intval($channel_id) ); if($r) { - if($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) { + if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) { if(local_user() && get_account_id() == $r[0]['account_id']) $x[] = 'application/x-php'; } -- cgit v1.2.3 From 7090b58f68251b8c4b39332f2ea051e95ead3df3 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 Jan 2015 20:54:27 -0800 Subject: check mentions against the appropriate xchan_url and not a hard-coded /channel/ string --- include/items.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index dd9dbc7f9..5812efa90 100755 --- a/include/items.php +++ b/include/items.php @@ -2673,7 +2673,7 @@ function tag_deliver($uid,$item_id) { * Fetch stuff we need - a channel and an item */ - $u = q("select * from channel where channel_id = %d limit 1", + $u = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($uid) ); if(! $u) @@ -2811,7 +2811,7 @@ function tag_deliver($uid,$item_id) { if($terms) logger('tag_deliver: post mentions: ' . print_r($terms,true), LOGGER_DATA); - $link = normalise_link($a->get_baseurl() . '/channel/' . $u[0]['channel_address']); + $link = normalise_link($u[0]['xchan_url']); if($terms) { foreach($terms as $term) { @@ -2952,7 +2952,7 @@ function tgroup_check($uid,$item) { if(! perm_is_allowed($uid,$item['author_xchan'],'tag_deliver')) return false; - $u = q("select * from channel where channel_id = %d limit 1", + $u = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($uid) ); @@ -2964,7 +2964,7 @@ function tgroup_check($uid,$item) { if($terms) logger('tgroup_check: post mentions: ' . print_r($terms,true), LOGGER_DATA); - $link = normalise_link($a->get_baseurl() . '/channel/' . $u[0]['channel_address']); + $link = normalise_link($u[0]['xchan_url']); if($terms) { foreach($terms as $term) { -- cgit v1.2.3