diff --git a/acp/ajaxchat_module.php b/acp/ajaxchat_module.php index 3d2e7bc..754a8d3 100644 --- a/acp/ajaxchat_module.php +++ b/acp/ajaxchat_module.php @@ -20,9 +20,6 @@ class ajaxchat_module /** @var \phpbb\config\config */ public $new_config = []; - /** @var string form key */ - public $form_key; - /** @var \phpbb\config\config */ protected $config; @@ -38,9 +35,15 @@ class ajaxchat_module /** @var \phpbb\request\request */ protected $request; + /** @var string */ + protected $phpbb_root_path; + + /** @var string */ + protected $php_ext; + public function main($id, $mode) { - global $phpbb_container, $table_prefix; + global $phpbb_container, $table_prefix, $phpbb_root_path, $phpEx; if (!defined('CHAT_TABLE')) { @@ -57,14 +60,18 @@ public function main($id, $mode) // Initialization $this->auth = $phpbb_container->get('auth'); $this->config = $phpbb_container->get('config'); + $this->config_text = $phpbb_container->get('config_text'); $this->db = $phpbb_container->get('dbal.conn'); $this->user = $phpbb_container->get('user'); $this->template = $phpbb_container->get('template'); $this->request = $phpbb_container->get('request'); - + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $phpEx; + // Add the posting lang file needed by BBCodes + $this->user->add_lang(array('posting')); $this->u_action = $this->request->variable('action', '', true); - $submit = ($this->request->is_set_post('submit')) ? true : false; + $submit = ($this->request->is_set_post('submit')) ? true : false; $this->form_key = 'acp_ajax_chat'; add_form_key($this->form_key); @@ -88,26 +95,24 @@ public function main($id, $mode) 'status_online_chat' => ['lang' => 'STATUS_ONLINE_CHAT', 'validate' => 'int', 'type' => 'number:0:9999', 'explain' => true], 'status_idle_chat' => ['lang' => 'STATUS_IDLE_CHAT', 'validate' => 'int', 'type' => 'number:0:9999', 'explain' => true], 'status_offline_chat' => ['lang' => 'STATUS_OFFLINE_CHAT', 'validate' => 'int', 'type' => 'number:0:9999', 'explain' => true], - 'legend2' => 'AJAX_CHAT_RULES', - 'rule_ajax_chat' => ['lang' => 'RULES_AJAX_CHAT', 'validate' => 'string', 'type' => 'textarea:4:70', 'explain' => true], - 'legend3' => 'AJAX_CHAT_LOCATION', + 'legend2' => 'AJAX_CHAT_LOCATION', 'location_ajax_chat_override' => ['lang' => 'LOCATION_AJAX_CHAT_OVERRIDE', 'validate' => 'bool', 'type' => 'radio:enabled_enabled', 'explain' => true], 'location_ajax_chat' => ['lang' => 'LOCATION_AJAX_CHAT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true], 'viewforum_ajax_chat_override' => ['lang' => 'VIEWFORUM_AJAX_CHAT_OVERRIDE', 'validate' => 'bool', 'type' => 'radio:enabled_enabled', 'explain' => true], 'viewtopic_ajax_chat_override' => ['lang' => 'VIEWTOPIC_AJAX_CHAT_OVERRIDE', 'validate' => 'bool', 'type' => 'radio:enabled_enabled', 'explain' => true], - 'legend4' => 'AJAX_CHAT_POSTS', + 'legend3' => 'AJAX_CHAT_POSTS', 'ajax_chat_forum_posts' => ['lang' => 'FORUM_POSTS_AJAX_CHAT', 'validate' => 'bool', 'type' => 'radio:enabled_enabled', 'explain' => false], 'ajax_chat_forum_topic' => ['lang' => 'FORUM_POSTS_AJAX_CHAT_TOPIC', 'validate' => 'bool', 'type' => 'radio:enabled_enabled', 'explain' => false], 'ajax_chat_forum_reply' => ['lang' => 'FORUM_POSTS_AJAX_CHAT_REPLY', 'validate' => 'bool', 'type' => 'radio:enabled_enabled', 'explain' => false], 'ajax_chat_forum_edit' => ['lang' => 'FORUM_POSTS_AJAX_CHAT_EDIT', 'validate' => 'bool', 'type' => 'radio:enabled_enabled', 'explain' => false], 'ajax_chat_forum_quote' => ['lang' => 'FORUM_POSTS_AJAX_CHAT_QUOTE', 'validate' => 'bool', 'type' => 'radio:enabled_enabled', 'explain' => false], - 'legend5' => 'AJAX_CHAT_PRUNE', + 'legend4' => 'AJAX_CHAT_PRUNE', 'prune_ajax_chat' => ['lang' => 'PRUNE_AJAX_CHAT', 'validate' => 'bool', 'type' => 'radio:enabled_enabled', 'explain' => true], 'prune_keep_ajax_chat' => ['lang' => 'PRUNE_KEEP_AJAX_CHAT', 'validate' => 'int', 'type' => 'number', 'explain' => false], 'prune_now' => ['lang' => 'PRUNE_NOW', 'validate' => 'bool', 'type' => 'custom', 'explain' => false, 'method' => 'prune_chat'], 'truncate_now' => ['lang' => 'TRUNCATE_NOW', 'validate' => 'bool', 'type' => 'custom', 'explain' => false, 'method' => 'truncate_chat'], 'ajax_chat_counter' => ['lang' => 'CHAT_COUNTER', 'validate' => 'bool', 'type' => 'custom', 'explain' => false, 'method' => 'chat_counter'], - 'legend6' => 'ACP_SUBMIT_CHANGES' + 'legend5' => 'ACP_SUBMIT_CHANGES' ], ]; @@ -252,6 +257,21 @@ protected function do_submit_stuff($display_vars, $special_functions = []) validate_config_vars($display_vars['vars'], $cfg_array, $error); + // Get new chat rules text from the form + $data['chat_rules_text'] = $this->request->variable('ajax_chat_rule_text', '', true); + + // Prepare chat rules text for storage + generate_text_for_storage( + $data['chat_rules_text'], + $data['chat_rules_uid'], + $data['chat_rules_bitfield'], + $data['chat_rules_options'], + !$this->request->variable('disable_bbcode', false), + !$this->request->variable('disable_magic_url', false), + !$this->request->variable('disable_smilies', false) + ); + + // Test if form key is valid if (!check_form_key($this->form_key)) { $error[] = $this->user->lang['FORM_INVALID']; @@ -264,6 +284,14 @@ protected function do_submit_stuff($display_vars, $special_functions = []) return false; } + // Store the chat rules settings to the config_table in the database + $this->config_text->set_array(array( + 'chat_rules_text' => $data['chat_rules_text'], + 'chat_rules_uid' => $data['chat_rules_uid'], + 'chat_rules_bitfield' => $data['chat_rules_bitfield'], + 'chat_rules_options' => $data['chat_rules_options'], + )); + // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $null) { @@ -349,10 +377,50 @@ protected function generate_stuff_for_cfg_template($display_vars) ]); } + // Chat rules functions for ACP + // Include files needed for displaying BBCodes + if (!function_exists('display_custom_bbcodes')) + { + include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); + } + + // Get chat rules data from the config_text table in the database + $data = $this->config_text->get_array(array( + 'chat_rules_text', + 'chat_rules_uid', + 'chat_rules_bitfield', + 'chat_rules_options', + )); + + // Prepare the chat rules text for editing inside the textbox + $ajax_chat_rule_text_edit = generate_text_for_edit($data['chat_rules_text'], $data['chat_rules_uid'], $data['chat_rules_options']); + + // Output data to the template $this->template->assign_vars([ 'S_ERROR' => (sizeof($error)) ? true : false, 'ERROR_MSG' => implode('
', $error), + + 'AJAX_CHAT_RULE_TEXT' => $ajax_chat_rule_text_edit['text'], + + 'S_BBCODE_DISABLE_CHECKED' => !$ajax_chat_rule_text_edit['allow_bbcode'], + 'S_SMILIES_DISABLE_CHECKED' => !$ajax_chat_rule_text_edit['allow_smilies'], + 'S_MAGIC_URL_DISABLE_CHECKED' => !$ajax_chat_rule_text_edit['allow_urls'], + + 'BBCODE_STATUS' => $this->user->lang('BBCODE_IS_ON', 'phpbb_root_path}faq.{$this->php_ext}", 'mode=bbcode') . '">', ''), + 'SMILIES_STATUS' => $this->user->lang('SMILIES_ARE_ON'), + 'IMG_STATUS' => $this->user->lang('IMAGES_ARE_ON'), + 'FLASH_STATUS' => $this->user->lang('FLASH_IS_ON'), + 'URL_STATUS' => $this->user->lang('URL_IS_ON'), + + 'S_BBCODE_ALLOWED' => true, + 'S_SMILIES_ALLOWED' => true, + 'S_BBCODE_IMG' => true, + 'S_BBCODE_FLASH' => true, + 'S_LINKS_ALLOWED' => true, 'U_ACTION' => $this->u_action] ); + + // Assigning custom bbcodes + display_custom_bbcodes(); } } diff --git a/adm/style/ajax_chat.html b/adm/style/ajax_chat.html index 026fa11..701dd00 100644 --- a/adm/style/ajax_chat.html +++ b/adm/style/ajax_chat.html @@ -1,5 +1,13 @@ + +

{L_ACP_AJAX_CHAT}

@@ -17,6 +25,33 @@

{L_WARNING}

+
+ {L_AJAX_CHAT_RULES} + +

{L_RULES_AJAX_CHAT_EXPLAIN}

+ + + +
+
+
+ +
+
+ + + + + + + + + +
+
{L_OPTIONS}{L_COLON} {BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}
+
+
+ diff --git a/adm/style/event/acp_users_prefs_append.html b/adm/style/event/acp_users_prefs_append.html index 79b23c2..263fcfb 100644 --- a/adm/style/event/acp_users_prefs_append.html +++ b/adm/style/event/acp_users_prefs_append.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/composer.json b/composer.json index 83fbc68..71d2606 100644 --- a/composer.json +++ b/composer.json @@ -3,8 +3,8 @@ "type": "phpbb-extension", "description": "Chat for phpBB 3.1", "homepage": "http://www.livemembersonly.com", - "version": "3.0.14-BETA", - "time": "2016-01-30", + "version": "3.0.15-BETA", + "time": "2016-02-21", "license": "GPL-2.0", "authors": [{ "name": "spaceace", diff --git a/config/services.yml b/config/services.yml index 38fa669..73baa09 100644 --- a/config/services.yml +++ b/config/services.yml @@ -9,6 +9,7 @@ services: - '@request' - '@controller.helper' - '@config' + - '@config_text' - '@ext.manager' - '@path_helper' - '@service_container' diff --git a/controller/chat.php b/controller/chat.php index cb6257b..c72c23c 100644 --- a/controller/chat.php +++ b/controller/chat.php @@ -278,7 +278,7 @@ public function index() 'LAST_ID' => $this->last_id, 'LAST_POST' => $last_post, 'TIME' => time(), - 'L_VERSION' => '3.0.14-BETA', + 'L_VERSION' => '3.0.15-BETA', 'STYLE_PATH' => generate_board_url() . '/styles/' . $this->user->style['style_path'], 'EXT_STYLE_PATH' => '' . $this->ext_path_web . 'styles/', 'FILENAME' => $this->helper->route('spaceace_ajaxchat_chat'), diff --git a/event/listener.php b/event/listener.php index 65a5caf..e5fb219 100644 --- a/event/listener.php +++ b/event/listener.php @@ -43,6 +43,9 @@ class listener implements EventSubscriberInterface /** @var \phpbb\config\db */ protected $config; + /** @var \phpbb\config\db_text */ + protected $config_text; + /** @var \phpbb\extension\manager "Extension Manager" */ protected $ext_manager; @@ -129,7 +132,7 @@ class listener implements EventSubscriberInterface * @param string $root_path * @param string $php_ext */ - public function __construct(template $template, user $user, db_driver $db, auth $auth, request $request, helper $helper, db $config, manager $ext_manager, path_helper $path_helper, Container $container, $table_prefix, $root_path, $php_ext) + public function __construct(template $template, user $user, db_driver $db, auth $auth, request $request, helper $helper, db $config, $config_text, manager $ext_manager, path_helper $path_helper, Container $container, $table_prefix, $root_path, $php_ext) { $this->template = $template; $this->user = $user; @@ -138,6 +141,7 @@ public function __construct(template $template, user $user, db_driver $db, auth $this->request = $request; $this->helper = $helper; $this->config = $config; + $this->config_text = $config_text; $this->root_path = $root_path; $this->php_ext = $php_ext; $this->ext_manager = $ext_manager; @@ -226,12 +230,28 @@ public function page_header() $this->template->assign_var('S_AJAX_CHAT_VIEWTOPIC_OVERRIDE', true); } - //Declaring a few UCP switches and basic values + // Get chat rules data from the config_text object + $chat_rules_data = $this->config_text->get_array(array( + 'chat_rules_text', + 'chat_rules_uid', + 'chat_rules_bitfield', + 'chat_rules_options', + )); + + // Prepare chat rules for display + $chat_rules = generate_text_for_display( + $chat_rules_data['chat_rules_text'], + $chat_rules_data['chat_rules_uid'], + $chat_rules_data['chat_rules_bitfield'], + $chat_rules_data['chat_rules_options'] + ); + + // Declaring a few UCP switches and basic values $this->template->assign_vars( array( 'U_CHAT' => $this->helper->route('spaceace_ajaxchat_chat'), 'S_SHOUT' => true, - 'CHAT_RULES' => htmlspecialchars_decode($this->config['rule_ajax_chat']), + 'CHAT_RULES' => $chat_rules, 'SCRIPT_PATH' => $this->config['script_path'], 'COOKIE_NAME' => $this->config['cookie_name'].'_fonthold', 'EXT_PATH' => $this->ext_manager->get_extension_path('spaceace/ajaxchat', true), @@ -491,7 +511,7 @@ public function index() 'LAST_ID' => $this->last_id, 'LAST_POST' => $last_post, 'TIME' => time(), - 'L_VERSION' => '3.0.14-BETA', + 'L_VERSION' => '3.0.15-BETA', 'STYLE_PATH' => generate_board_url() . '/styles/' . $this->user->style['style_path'], 'EXT_STYLE_PATH' => '' . $this->ext_path_web . 'styles/', 'FILENAME' => $this->helper->route('spaceace_ajaxchat_chat'), diff --git a/migrations/install_ajaxchat.php b/migrations/install_ajaxchat.php index 3bb496c..57b7f57 100644 --- a/migrations/install_ajaxchat.php +++ b/migrations/install_ajaxchat.php @@ -24,7 +24,6 @@ public function update_data() // Add configs array('config.add', array('display_ajax_chat', '1')), array('config.add', array('whois_chatting', '1')), - array('config.add', array('rule_ajax_chat', '')), array('config.add', array('location_ajax_chat', '1')), array('config.add', array('location_ajax_chat_override', '0')), array('config.add', array('viewforum_ajax_chat', '1')), @@ -52,6 +51,10 @@ public function update_data() array('config.add', array('prune_keep_ajax_chat', '300')), array('config.add', array('ajax_chat_nav_link', '1')), array('config.add', array('ajax_chat_quick_link', '0')), + array('config_text.add', array('chat_rules_text', '')), + array('config_text.add', array('chat_rules_uid', '')), + array('config_text.add', array('chat_rules_bitfield', '')), + array('config_text.add', array('chat_rules_options', OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS)), // Add chat bbcode part 1 array('custom', array(array($this, 'update_chat_bbcodes'))), // Add the cron diff --git a/styles/Bluespace/template/chat_body.html b/styles/Bluespace/template/chat_body.html index b84e1e1..a8f4219 100644 --- a/styles/Bluespace/template/chat_body.html +++ b/styles/Bluespace/template/chat_body.html @@ -157,7 +157,7 @@
- {L_CHAT_RULE}
{CHAT_RULES} + {L_CHAT_RULE}
{CHAT_RULES}
diff --git a/styles/Deepspace/template/chat_body.html b/styles/Deepspace/template/chat_body.html index b84e1e1..a8f4219 100644 --- a/styles/Deepspace/template/chat_body.html +++ b/styles/Deepspace/template/chat_body.html @@ -157,7 +157,7 @@
- {L_CHAT_RULE}
{CHAT_RULES} + {L_CHAT_RULE}
{CHAT_RULES}
diff --git a/styles/GhostSpace/template/chat_body.html b/styles/GhostSpace/template/chat_body.html index 97ade4a..6daa43a 100644 --- a/styles/GhostSpace/template/chat_body.html +++ b/styles/GhostSpace/template/chat_body.html @@ -102,38 +102,47 @@
- - + + + + + + - + - - - + - + +
+
+ {L_CHAT_RULE}
{CHAT_RULES} +
diff --git a/styles/GhostSpace/theme/ajax_chat.css b/styles/GhostSpace/theme/ajax_chat.css index e49da93..d96e0f9 100644 --- a/styles/GhostSpace/theme/ajax_chat.css +++ b/styles/GhostSpace/theme/ajax_chat.css @@ -128,6 +128,12 @@ div.chat-avatars:hover span { padding: 6px 0 6px 21px; } +.span_chat_rule { + font-weight: bold; + font-size: 1.1em; + color: #FF0000; +} + #chat_smilies { margin-bottom: 5px; } diff --git a/styles/Prospace/template/chat_body.html b/styles/Prospace/template/chat_body.html index b84e1e1..a8f4219 100644 --- a/styles/Prospace/template/chat_body.html +++ b/styles/Prospace/template/chat_body.html @@ -157,7 +157,7 @@
- {L_CHAT_RULE}
{CHAT_RULES} + {L_CHAT_RULE}
{CHAT_RULES}
diff --git a/styles/Subway/template/chat_body.html b/styles/Subway/template/chat_body.html index 760cb86..8be3c1f 100644 --- a/styles/Subway/template/chat_body.html +++ b/styles/Subway/template/chat_body.html @@ -159,7 +159,7 @@
- {L_CHAT_RULE}
{CHAT_RULES} + {L_CHAT_RULE}
{CHAT_RULES}
diff --git a/styles/all/template/chat_body.html b/styles/all/template/chat_body.html index 7be8b97..4decabc 100644 --- a/styles/all/template/chat_body.html +++ b/styles/all/template/chat_body.html @@ -157,7 +157,7 @@
- {L_CHAT_RULE}
{CHAT_RULES} + {L_CHAT_RULE}
{CHAT_RULES}
diff --git a/styles/all/theme/ajax_chat.css b/styles/all/theme/ajax_chat.css index 202ca82..95b9f31 100644 --- a/styles/all/theme/ajax_chat.css +++ b/styles/all/theme/ajax_chat.css @@ -437,3 +437,8 @@ div.chat-avatars:hover span { margin-bottom: 5px; padding: 5px; } + +/* Black additions */ + .fachaticon .nav-link { + content: '\f075'; // fa-comment + } diff --git a/styles/black/template/chat_body.html b/styles/black/template/chat_body.html index 1f2597b..5d28318 100644 --- a/styles/black/template/chat_body.html +++ b/styles/black/template/chat_body.html @@ -157,7 +157,7 @@
- {L_CHAT_RULE}
{CHAT_RULES} + {L_CHAT_RULE}
{CHAT_RULES}
diff --git a/styles/black/template/event/navbar_header_quick_links_after.html b/styles/black/template/event/navbar_header_quick_links_after.html new file mode 100644 index 0000000..d836073 --- /dev/null +++ b/styles/black/template/event/navbar_header_quick_links_after.html @@ -0,0 +1,5 @@ + + +
  • {L_CHAT_EXPLAIN}
  • + + diff --git a/styles/black/template/event/overall_header_navigation_append.html b/styles/black/template/event/overall_header_navigation_append.html new file mode 100644 index 0000000..e69de29 diff --git a/styles/bootlike/template/chat_body.html b/styles/bootlike/template/chat_body.html index 1e30214..4429f4b 100644 --- a/styles/bootlike/template/chat_body.html +++ b/styles/bootlike/template/chat_body.html @@ -139,7 +139,7 @@

    - {L_CHAT_RULE}
    {CHAT_RULES} + {L_CHAT_RULE}
    {CHAT_RULES}
    diff --git a/styles/subsilver2/template/chat_body.html b/styles/subsilver2/template/chat_body.html index 4fb5dca..6b48244 100644 --- a/styles/subsilver2/template/chat_body.html +++ b/styles/subsilver2/template/chat_body.html @@ -134,71 +134,80 @@
    -
    -
    - -
    - - -
    - {L_DELETE} -
    +
    + {L_CHAT_RULE}
    {CHAT_RULES} +
    +
    +
    +
    + +
    + + + - - -
    + {L_DELETE} + -
    - « {chatrow.TIME} » -
    -
    {chatrow.MESSAGE}
    -
    -
    - + {chatrow.USERNAME_FULL} +
    + « {chatrow.TIME} » +
    +
    {chatrow.MESSAGE}
    +
    style="visibility: hidden; position: absolute;"> -
    -
    - -
    - {whoisrow.USER_STATUS} {whoisrow.USERNAME_FULL}  -
    - +
    style="visibility: hidden; position: absolute;"> +
    +
    + +
    + {whoisrow.USER_STATUS} {whoisrow.USERNAME_FULL}  +
    + +
    - -
    {L_DETAILS} diff --git a/styles/subsilver2/theme/ajax_chat.css b/styles/subsilver2/theme/ajax_chat.css index 5c34251..5af032c 100644 --- a/styles/subsilver2/theme/ajax_chat.css +++ b/styles/subsilver2/theme/ajax_chat.css @@ -128,6 +128,12 @@ div.chat-avatars:hover span { padding: 6px 0 6px 21px; } +.span_chat_rule { + font-weight: bold; + font-size: 1.1em; + color: #AA0000; +} + #chat_smilies { margin-bottom: 5px; } diff --git a/styles/we_universal/template/chat_body.html b/styles/we_universal/template/chat_body.html index ae054ba..df21a6c 100644 --- a/styles/we_universal/template/chat_body.html +++ b/styles/we_universal/template/chat_body.html @@ -157,7 +157,7 @@
    - {L_CHAT_RULE}
    {CHAT_RULES} + {L_CHAT_RULE}
    {CHAT_RULES}