From 2fc0fcdc1807954a797790ed44eed13155ef9b47 Mon Sep 17 00:00:00 2001 From: Domovoy Date: Sun, 29 Jul 2012 19:53:04 +0200 Subject: [PATCH] Unlimited level threading is now a site option. --- include/conversation.php | 23 +++++++++++++---------- mod/admin.php | 3 +++ view/admin_site.tpl | 1 + 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index d32a9a6667..878fabc082 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -303,7 +303,7 @@ function localize_item(&$item){ * Recursively prepare a thread for HTML */ -function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $profile_owner, $collapse_all=false) { +function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $profile_owner, $thread_level=1) { $result = array(); $wall_template = 'wall_thread.tpl'; @@ -463,11 +463,11 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr } else { $indent = 'comment'; // Collapse comments - if(($nb_items > 2) || $collapse_all) { + if(($nb_items > 2) || ($thread_level > 2)) { if($items_seen == 1) { $firstcollapsed = true; } - if($collapse_all) { + if($thread_level > 2) { if($items_seen == $nb_items) $lastcollapsed = true; } @@ -581,11 +581,12 @@ function prepare_threads_body($a, $items, $cmnt_tpl, $page_writeable, $mode, $pr } $item_result['children'] = array(); - if(count($item['children'])) { - $collapse_all_children = $collapse_all; - if(!$toplevelpost && !$collapse_all) - $collapse_all_children = true; - $item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $page_writeable, $mode, $profile_owner, $collapse_all_children); + // Show children of children only if enabled + if(count($item['children']) + && (($thread_level < 2) || get_config('system','thread_allow'))) { + + $thread_level++; + $item_result['children'] = prepare_threads_body($a, $item['children'], $cmnt_tpl, $page_writeable, $mode, $profile_owner, $thread_level); } $item_result['private'] = $item['private']; $item_result['toplevel'] = ($toplevelpost ? 'toplevel_item' : ''); @@ -668,7 +669,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = fa // array with html for each thread (parent+comments) $threads = array(); $threadsid = -1; - + if($items && count($items)) { if($mode === 'network-new' || $mode === 'search' || $mode === 'community') { @@ -796,6 +797,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = fa { // Normal View + // Threaded comments, $thr_c is used for now since we don't know what other parts of friendica uses this function // Better not rely on the new code for stuff we haven't examined yet if($thr_c) { @@ -810,7 +812,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = fa } } - $threads = prepare_threads_body($a, $threads, $cmnt_tpl, $page_writeable, $mode, $profile_owner, $previewing); + $threads = prepare_threads_body($a, $threads, $cmnt_tpl, $page_writeable, $mode, $profile_owner); } else { @@ -1168,6 +1170,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false, $thr_c = fa $threads[$threadsid]['items'][] = $arr['output']; } + } } } diff --git a/mod/admin.php b/mod/admin.php index 05af01aa41..1752b3fe8f 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -250,6 +250,7 @@ function admin_page_site_post(&$a){ $block_public = ((x($_POST,'block_public')) ? True : False); $force_publish = ((x($_POST,'publish_all')) ? True : False); $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); + $thread_allow = ((x($_POST,'thread_allow')) ? True : False); $no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False); $no_openid = !((x($_POST,'no_openid')) ? True : False); $no_regfullname = !((x($_POST,'no_regfullname')) ? True : False); @@ -342,6 +343,7 @@ function admin_page_site_post(&$a){ } else { set_config('system','directory_submit_url', $global_directory); } + set_config('system','thread_allow', $thread_allow); set_config('system','block_extended_register', $no_multi_reg); set_config('system','no_openid', $no_openid); @@ -442,6 +444,7 @@ function admin_page_site(&$a) { '$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.")), '$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")), '$global_directory' => array('directory_submit_url', t("Global directory update URL"), get_config('system','directory_submit_url'), t("URL to update the global directory. If this is not set, the global directory is completely unavailable to the application.")), + '$thread_allow' => array('thread_allow', t("Allow threaded items"), get_config('system','thread_allow'), t("Allow infinite level threading for items on this site.")), '$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), get_config('system','block_extended_register'), t("Disallow users to register additional accounts for use as pages.")), '$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), t("OpenID support for registration and logins.")), diff --git a/view/admin_site.tpl b/view/admin_site.tpl index 3ca03262d4..e918ff7872 100644 --- a/view/admin_site.tpl +++ b/view/admin_site.tpl @@ -71,6 +71,7 @@ {{ inc field_checkbox.tpl with $field=$diaspora_enabled }}{{ endinc }} {{ inc field_checkbox.tpl with $field=$dfrn_only }}{{ endinc }} {{ inc field_input.tpl with $field=$global_directory }}{{ endinc }} + {{ inc field_checkbox.tpl with $field=$thread_allow }}{{ endinc }}
-- 2.39.5