From 6b23c3e1796b818ce893ed919f2e2bdd000c83fb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 27 Sep 2018 14:56:47 +0200 Subject: implement conversation tools (settings/conversation), remove additional features from the settings menu and get rid of skill levels --- Zotlabs/Lib/ThreadItem.php | 7 +++- Zotlabs/Module/Settings/Conversation.php | 60 ++++++++++++++++++++++++++++ Zotlabs/Module/Settings/Features.php | 35 +---------------- Zotlabs/Widget/Settings_menu.php | 8 ---- include/conversation.php | 1 + include/features.php | 67 ++++++++++++++------------------ view/js/main.js | 29 ++++++++++++++ view/tpl/conv_frame.tpl | 15 ++++++- view/tpl/conv_item.tpl | 6 ++- view/tpl/jot.tpl | 8 ++-- view/tpl/settings_features.tpl | 21 ---------- view/tpl/settings_module.tpl | 21 +++++----- view/tpl/settings_module_ajax.tpl | 11 ++++++ 13 files changed, 169 insertions(+), 120 deletions(-) create mode 100644 Zotlabs/Module/Settings/Conversation.php create mode 100644 view/tpl/settings_module_ajax.tpl diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index f8a7366f8..ac24806a6 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -259,7 +259,7 @@ class ThreadItem { $forged = ((($item['sig']) && (! intval($item['item_verified']))) ? t('Message signature incorrect') : ''); $unverified = '' ; // (($this->is_wall_to_wall() && (! intval($item['item_verified']))) ? t('Message cannot be verified') : ''); - + $settings = ''; // FIXME - check this permission if($conv->get_profile_owner() == local_channel()) { @@ -267,6 +267,8 @@ class ThreadItem { 'tagit' => t("Add Tag"), 'classtagger' => "", ); + + $settings = t('Conversation Tools'); } $has_bookmarks = false; @@ -436,7 +438,8 @@ class ThreadItem { 'preview_lbl' => t('This is an unsaved preview'), 'wait' => t('Please wait'), 'submid' => str_replace(['+','='], ['',''], base64_encode($item['mid'])), - 'thread_level' => $thread_level + 'thread_level' => $thread_level, + 'settings' => $settings ); $arr = array('item' => $item, 'output' => $tmp_item); diff --git a/Zotlabs/Module/Settings/Conversation.php b/Zotlabs/Module/Settings/Conversation.php new file mode 100644 index 000000000..43e59a3c2 --- /dev/null +++ b/Zotlabs/Module/Settings/Conversation.php @@ -0,0 +1,60 @@ + 'settings/' . $module, + '$form_security_token' => get_form_security_token('settings_' . $module), + '$title' => t('Conversation Settings'), + '$features' => process_module_features_get(local_channel(), $features), + '$submit' => t('Submit') + )); + + if($aj) { + echo $o; + killme(); + } + else { + return $o; + } + } + +} diff --git a/Zotlabs/Module/Settings/Features.php b/Zotlabs/Module/Settings/Features.php index 888032c28..6a3ab104b 100644 --- a/Zotlabs/Module/Settings/Features.php +++ b/Zotlabs/Module/Settings/Features.php @@ -26,44 +26,14 @@ class Features { function get() { $arr = []; - $harr = []; - if(intval($_REQUEST['techlevel'])) - $level = intval($_REQUEST['techlevel']); - else { - $level = get_account_techlevel(); - } - - if(! intval($level)) { - notice( t('Permission denied.') . EOL); - return; - } - - $techlevels = \Zotlabs\Lib\Techlevels::levels(); - - // This page isn't accessible at techlevel 0 - - unset($techlevels[0]); - - $def_techlevel = (($level > 0) ? $level : 1); - $techlock = get_config('system','techlevel_lock'); - - $all_features_raw = get_features(false); - - foreach($all_features_raw as $fname => $fdata) { - foreach(array_slice($fdata,1) as $f) { - $harr[$f[0]] = ((intval(feature_enabled(local_channel(),$f[0]))) ? "1" : ''); - } - } - - $features = get_features(true,$level); + $features = get_features(false); foreach($features as $fname => $fdata) { $arr[$fname] = array(); $arr[$fname][0] = $fdata[0]; foreach(array_slice($fdata,1) as $f) { $arr[$fname][1][] = array('feature_' . $f[0],$f[1],((intval(feature_enabled(local_channel(),$f[0]))) ? "1" : ''),$f[2],array(t('Off'),t('On'))); - unset($harr[$f[0]]); } } @@ -71,10 +41,7 @@ class Features { $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_features"), '$title' => t('Additional Features'), - '$techlevel' => [ 'techlevel', t('Your technical skill level'), $def_techlevel, t('Used to provide a member experience and additional features consistent with your comfort level'), $techlevels ], - '$techlock' => $techlock, '$features' => $arr, - '$hiddens' => $harr, '$baseurl' => z_root(), '$submit' => t('Submit'), )); diff --git a/Zotlabs/Widget/Settings_menu.php b/Zotlabs/Widget/Settings_menu.php index ecf93ec78..92f615452 100644 --- a/Zotlabs/Widget/Settings_menu.php +++ b/Zotlabs/Widget/Settings_menu.php @@ -45,14 +45,6 @@ class Settings_menu { ); - if(get_account_techlevel() > 0 && get_features()) { - $tabs[] = array( - 'label' => t('Additional features'), - 'url' => z_root().'/settings/features', - 'selected' => ((argv(1) === 'features') ? 'active' : ''), - ); - } - $tabs[] = array( 'label' => t('Addon settings'), 'url' => z_root().'/settings/featured', diff --git a/include/conversation.php b/include/conversation.php index 28a339479..dc3f45e45 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -888,6 +888,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa '$user' => App::$user, '$threads' => $threads, '$wait' => t('Loading...'), + '$conversation_tools' => t('Conversation Tools'), '$dropping' => ($page_dropping?t('Delete Selected Items'):False), )); diff --git a/include/features.php b/include/features.php index 8dcf4517d..5584ba3e4 100644 --- a/include/features.php +++ b/include/features.php @@ -71,10 +71,36 @@ function get_features($filtered = true, $level = (-1)) { $arr = [ - // Item tools - 'tools' => [ + 'calendar' => [ + + t('CalDAV'), + + [ + 'cal_first_day', + t('Start calendar week on Monday'), + t('Default is Sunday'), + false, + get_config('feature_lock','cal_first_day') + ] + + ], + + 'connections' => [ + + t('Connections'), + + [ + 'connfilter', + t('Connection Filtering'), + t('Filter incoming posts from connections based on keywords/content'), + false, + get_config('feature_lock','connfilter') + ] + ], + + 'conversation' => [ - t('Post/Comment Tools'), + t('Conversation'), [ 'commtag', @@ -82,7 +108,6 @@ function get_features($filtered = true, $level = (-1)) { t('Ability to tag existing posts'), false, get_config('feature_lock','commtag'), - feature_level('commtag',1), ], [ @@ -91,7 +116,6 @@ function get_features($filtered = true, $level = (-1)) { t('Add emoji reaction ability to posts'), true, get_config('feature_lock','emojis'), - feature_level('emojis',1), ], [ @@ -100,7 +124,6 @@ function get_features($filtered = true, $level = (-1)) { t('Ability to file posts under folders'), false, get_config('feature_lock','filing'), - feature_level('filing',2), ], [ @@ -109,7 +132,6 @@ function get_features($filtered = true, $level = (-1)) { t('Ability to dislike posts/comments'), false, get_config('feature_lock','dislike'), - feature_level('dislike',1), ], [ @@ -118,7 +140,6 @@ function get_features($filtered = true, $level = (-1)) { t('Ability to mark special posts with a star indicator'), false, get_config('feature_lock','star_posts'), - feature_level('star_posts',1), ], [ @@ -127,40 +148,10 @@ function get_features($filtered = true, $level = (-1)) { t('Provide a personal tag cloud on your channel page'), false, get_config('feature_lock','tagadelic'), - feature_level('tagadelic',2), - ], - ], - -############################################ -############################################ - - 'calendar' => [ - - t('CalDAV'), - - [ - 'cal_first_day', - t('Start calendar week on Monday'), - t('Default is Sunday'), - false, - get_config('feature_lock','cal_first_day') ] ], - 'connections' => [ - - t('Connections'), - - [ - 'connfilter', - t('Connection Filtering'), - t('Filter incoming posts from connections based on keywords/content'), - false, - get_config('feature_lock','connfilter') - ] - ], - 'directory' => [ t('Directory'), diff --git a/view/js/main.js b/view/js/main.js index 17f94dd16..48277f5cc 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -41,6 +41,8 @@ $.ajaxSetup({cache: false}); $(document).ready(function() { $(document).on('click focus', '.comment-edit-form', handle_comment_form); + $(document).on('click', '.conversation-settings-link', getConversationSettings); + $(document).on('click', '#settings_module_ajax_submit', postConversationSettings); jQuery.timeago.settings.strings = { prefixAgo : aStr['t01'], @@ -122,6 +124,33 @@ $(document).ready(function() { }); +function getConversationSettings() { + $.get('settings/conversation/?f=&aj=1',function(data) { + $('#conversation_settings_body').html(data); + }); + + + +} + +function postConversationSettings() { + $.post( + 'settings/conversation', + $('#settings_module_ajax_form').serialize() + "&auto_update=" + next_page + ); + + if(next_page === 1) { + page_load = true; + } + + $('#conversation_settings').modal('hide'); + + if(timer) clearTimeout(timer); + timer = setTimeout(updateInit,100); + + return false; +} + function datasrc2src(selector) { $(selector).each(function(i, el) { $(el).attr("src", $(el).data("src")); diff --git a/view/tpl/conv_frame.tpl b/view/tpl/conv_frame.tpl index 8aa865076..c6b3b0d9b 100755 --- a/view/tpl/conv_frame.tpl +++ b/view/tpl/conv_frame.tpl @@ -4,5 +4,16 @@
- - + diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl index 05c3d7ae0..5720a2a5f 100755 --- a/view/tpl/conv_item.tpl +++ b/view/tpl/conv_item.tpl @@ -183,6 +183,10 @@ {{$item.dreport}} {{/if}} + {{if $item.settings}} + + {{$item.settings}} + {{/if}} @@ -210,7 +214,7 @@