From f3f0344f51b55a784d704a533f97d3a25075df69 Mon Sep 17 00:00:00 2001 From: Lodder Date: Wed, 25 Feb 2015 18:35:00 +0000 Subject: [PATCH 01/25] fixed smiley path for multilingual sites --- mod_shoutbox/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod_shoutbox/helper.php b/mod_shoutbox/helper.php index 172ec7f..4eea056 100644 --- a/mod_shoutbox/helper.php +++ b/mod_shoutbox/helper.php @@ -433,7 +433,7 @@ public function bbcodeFilter($message) // Replace the smileys foreach ($this->smileys as $smile => $url) { - $replace = '' . $smile . ''; + $replace = '' . $smile . ''; $message = str_replace($smile, $replace, $message); } From 82b4280088b8981940186aee1a084aacf711a845 Mon Sep 17 00:00:00 2001 From: Lodder Date: Wed, 25 Feb 2015 19:59:21 +0000 Subject: [PATCH 02/25] added name params + enhanced error reporting --- mod_shoutbox/fields/fade.php | 29 +++++++++-- .../language/en-GB/en-GB.mod_shoutbox.ini | 4 ++ .../language/it-IT/it-IT.mod_shoutbox.ini | 4 ++ .../language/nl-NL/nl_NL.mod_shoutbox.ini | 4 ++ .../language/pl-PL/pl-PL.mod_shoutbox.ini | 4 ++ mod_shoutbox/media/css/mod_shoutbox.css | 11 ++++ mod_shoutbox/media/js/mod_shoutbox.js | 50 ++++++++++--------- mod_shoutbox/mod_shoutbox.php | 3 +- mod_shoutbox/mod_shoutbox.xml | 5 ++ mod_shoutbox/tmpl/default.php | 49 +++++++++++++----- 10 files changed, 123 insertions(+), 40 deletions(-) diff --git a/mod_shoutbox/fields/fade.php b/mod_shoutbox/fields/fade.php index 864b457..bdf20a8 100644 --- a/mod_shoutbox/fields/fade.php +++ b/mod_shoutbox/fields/fade.php @@ -57,17 +57,16 @@ protected function getLabel() $js = ' jQuery(document).ready(function($) { - var select = $("#jform_params_securitytype"); - + var securityType = $("#jform_params_securitytype"); var public = $("#jform_params_recaptcha_public-lbl").parents("' . $parent . '"); var private = $("#jform_params_recaptcha_private-lbl").parents("' . $parent . '"); - if( select.val() == 0 || select.val() == 2 ) { + if( securityType.val() == 0 || securityType.val() == 2 ) { public.hide(); private.hide(); } - select.on("change", function() { + securityType.on("change", function() { var value = this.value; @@ -81,6 +80,28 @@ protected function getLabel() } }); + + + + var nameRequired = $("#jform_params_namerequired"); + var genericName = $("#jform_params_genericname-lbl").parents("' . $parent . '"); + + if( nameRequired.val() == 1 ) { + genericName.hide(); + } + + nameRequired.on("change", function() { + + var value = this.value; + + if( value == 0 ) { + genericName.fadeIn(); + } + else { + genericName.fadeOut(); + } + + }); }); '; diff --git a/mod_shoutbox/language/en-GB/en-GB.mod_shoutbox.ini b/mod_shoutbox/language/en-GB/en-GB.mod_shoutbox.ini index b410d67..b01ba63 100644 --- a/mod_shoutbox/language/en-GB/en-GB.mod_shoutbox.ini +++ b/mod_shoutbox/language/en-GB/en-GB.mod_shoutbox.ini @@ -101,6 +101,10 @@ SHOUT_GREATER_THAN_ZERO="You must delete more than 0 shouts" SHOUT_NOT_INT="You must delete a integer number of shouts" SHOUT_SWEAR_FILE_NOT_FOUND="The swear filter file cannot be found" SHOUT_DATABASE_ERROR="There has been a database error: %s" +SHOUT_NAME_REQUIRED="Name required" +SHOUT_NAME_REQUIRED_DESC="Select whether or not a name is required to submit a post" +SHOUT_GENERIC_NAME="Generic name" +SHOUT_GENERIC_NAME_DESC="Choose a default name that will be used if no name is entered" SHOUT_MASS_DELETE_OPTION="Mass Delete Button" SHOUT_MASS_DELETE_OPTION_DESC="Select whether or not you would like to display the Mass Delete function (only admins can see this)" WARNING_FREICHAT_IS_INSTALLED="Freichat appears to exist on your site. There are known conflicts with JJ Shoutbox and Freichat, therefore you cannot have both extensions installed." diff --git a/mod_shoutbox/language/it-IT/it-IT.mod_shoutbox.ini b/mod_shoutbox/language/it-IT/it-IT.mod_shoutbox.ini index d010c39..d367a93 100644 --- a/mod_shoutbox/language/it-IT/it-IT.mod_shoutbox.ini +++ b/mod_shoutbox/language/it-IT/it-IT.mod_shoutbox.ini @@ -101,6 +101,10 @@ SHOUT_GREATER_THAN_ZERO="È necessario eliminare più di 0 urli" SHOUT_NOT_INT="È necessario eliminare un numero intero di urli" SHOUT_SWEAR_FILE_NOT_FOUND="Il file del filtro parolacce non può essere trovato" SHOUT_DATABASE_ERROR="C'è stato un errore nel database: %s" +SHOUT_NAME_REQUIRED="Name required" +SHOUT_NAME_REQUIRED_DESC="Select whether or not a name is required to submit a post" +SHOUT_GENERIC_NAME="Generic name" +SHOUT_GENERIC_NAME_DESC="Choose a default name that will be used if no name is entered" SHOUT_MASS_DELETE_OPTION="Bottone cancellazione di massa" SHOUT_MASS_DELETE_OPTION_DESC="Selezionare se si desidera visualizzare la funzione di cancellazione di massa (solo gli amministratori possono vedere questo)" WARNING_FREICHAT_IS_INSTALLED="Freichat appears to exist on your site. There are known conflicts with JJ Shoutbox and Freichat, therefore you cannot have both extensions installed." diff --git a/mod_shoutbox/language/nl-NL/nl_NL.mod_shoutbox.ini b/mod_shoutbox/language/nl-NL/nl_NL.mod_shoutbox.ini index b227b3a..b1c4c66 100644 --- a/mod_shoutbox/language/nl-NL/nl_NL.mod_shoutbox.ini +++ b/mod_shoutbox/language/nl-NL/nl_NL.mod_shoutbox.ini @@ -101,6 +101,10 @@ SHOUT_GREATER_THAN_ZERO="Je moet meer dan 0 berichten verwijderen" SHOUT_NOT_INT="Je moet een aantal berichten verwijderen" SHOUT_SWEAR_FILE_NOT_FOUND="Het vloekfilter bestand kan niet worden gevonden" SHOUT_DATABASE_ERROR="Er is een database fout : %s" +SHOUT_NAME_REQUIRED="Name required" +SHOUT_NAME_REQUIRED_DESC="Select whether or not a name is required to submit a post" +SHOUT_GENERIC_NAME="Generic name" +SHOUT_GENERIC_NAME_DESC="Choose a default name that will be used if no name is entered" SHOUT_MASS_DELETE_OPTION="Bulk verwijderingsknop" SHOUT_MASS_DELETE_OPTION_DESC="Selecteer of de Bulk Verwijderingsknop functie ingeschakeld moet worden (alleen administrators kunnen dit zien)" SHOUT_BBCODE_BOLD="B" diff --git a/mod_shoutbox/language/pl-PL/pl-PL.mod_shoutbox.ini b/mod_shoutbox/language/pl-PL/pl-PL.mod_shoutbox.ini index 0a9ba88..adb3667 100644 --- a/mod_shoutbox/language/pl-PL/pl-PL.mod_shoutbox.ini +++ b/mod_shoutbox/language/pl-PL/pl-PL.mod_shoutbox.ini @@ -101,6 +101,10 @@ SHOUT_GREATER_THAN_ZERO="Ilość kasowanych wiadomości musi być większa od ze SHOUT_NOT_INT="Ilość kasowanych wiadomości musi być liczbą całkowitą" SHOUT_SWEAR_FILE_NOT_FOUND="Plik z filtrem przekleństw nie został znaleziony" SHOUT_DATABASE_ERROR="Błąd bazy danych: %s" +SHOUT_NAME_REQUIRED="Name required" +SHOUT_NAME_REQUIRED_DESC="Select whether or not a name is required to submit a post" +SHOUT_GENERIC_NAME="Generic name" +SHOUT_GENERIC_NAME_DESC="Choose a default name that will be used if no name is entered" SHOUT_MASS_DELETE_OPTION="Masowe usuwanie wpisów" SHOUT_MASS_DELETE_OPTION_DESC="Wybierz, czy przycisk masowego usuwania wpisów ma być widoczny (tylko dla administratorów)" WARNING_FREICHAT_IS_INSTALLED="Freichat appears to exist on your site. There are known conflicts with JJ Shoutbox and Freichat, therefore you cannot have both extensions installed." diff --git a/mod_shoutbox/media/css/mod_shoutbox.css b/mod_shoutbox/media/css/mod_shoutbox.css index 1182c21..9119ac5 100644 --- a/mod_shoutbox/media/css/mod_shoutbox.css +++ b/mod_shoutbox/media/css/mod_shoutbox.css @@ -83,6 +83,17 @@ color:red; font-weight:bold; } +#jjshoutbox .jj-shout-error { + display: none; + background: #F00; + color: #FFF; + margin: 7px 0 5px; + padding: 5px; +} +#jjshoutbox .jj-shout-error p { + margin: 0; + font-size: 12px; +} #jjshoutbox .jj_label { width: 70px; display: inline-block; diff --git a/mod_shoutbox/media/js/mod_shoutbox.js b/mod_shoutbox/media/js/mod_shoutbox.js index 3049498..37d164a 100644 --- a/mod_shoutbox/media/js/mod_shoutbox.js +++ b/mod_shoutbox/media/js/mod_shoutbox.js @@ -6,6 +6,7 @@ var JJgetPosts = null; var JJsubmitPost = null; +var showError = null; function addSmiley(smiley, id) { @@ -99,8 +100,7 @@ jQuery(document).ready(function($) { $(this).toggleClass('rotated'); $('#jj_smiley_box').stop(true, false).slideToggle(); }); - - + // SUBMIT POST JJsubmitPost = function(name, title, securityType, security, root) { @@ -108,25 +108,6 @@ jQuery(document).ready(function($) { var textarea = $('#jj_message'), message = textarea.val(); - // If no message body show an error message and stop - if(message == "") - { - $('.jj-shout-error').append('

Please enter a message!

').slideDown().show().delay(6000).queue(function(next){ - $(this).slideUp().hide(); - $('.inner-jj-error').remove(); - next(); - }); - var $elt = $('#shoutbox-submit').attr('disabled', true); - setTimeout(function (){ - $elt.attr('disabled', false); - }, 6000); - textarea.addClass('jj-redBorder').delay(6000).queue(function(next){ - $(this).removeClass('jj-redBorder'); - next(); - }); - return false; - } - // Assemble variables to submit var request = { 'jjshout[name]' : name, @@ -218,10 +199,10 @@ jQuery(document).ready(function($) { success:function(response){ if (response.success) { - $('#jjshoutboxoutput').empty().prepend($('
')); + $('#jjshoutboxoutput').empty().prepend($('
')); // Grab the html output and append it to the shoutbox message - $('.jj-shout-error').after(response.data.html); + $('.jj-shout-new').after(response.data.html); // Get the ID of the last shout after the output has been updated var newLastID = getLastID(); @@ -248,4 +229,27 @@ jQuery(document).ready(function($) { return lastId; } + + // Check if the name or message fields are empty + showError = function(field) + { + var errorBox = $('.jj-shout-error'); + + if( field == '' ) + { + errorMsg = '

Please enter a message

'; + } + else + { + errorMsg = '

Please enter a name

'; + } + + errorBox.html(errorMsg) + .slideDown().delay(5000).slideUp(400, function() { + $(this).empty(); + }); + + return false + } + }); diff --git a/mod_shoutbox/mod_shoutbox.php b/mod_shoutbox/mod_shoutbox.php index 8ed401c..5cd18c5 100644 --- a/mod_shoutbox/mod_shoutbox.php +++ b/mod_shoutbox/mod_shoutbox.php @@ -35,7 +35,8 @@ $headercolor = $params->get('headercolor', '#D0D0D0'); $bbcode = $params->get('bbcode', 1); $sound = $params->get('sound', 1); -$genericName = $params->get('genericname'); +$genericName = $params->get('genericname', 'Anonymous'); +$nameRequired = $params->get('namerequired', 0); $alertLength = $params->get('alertlength', '50'); $warnLength = $params->get('warnlength', '10'); $messageLength = $params->get('messagelength', '200'); diff --git a/mod_shoutbox/mod_shoutbox.xml b/mod_shoutbox/mod_shoutbox.xml index 65fbd39..40bc7e5 100644 --- a/mod_shoutbox/mod_shoutbox.xml +++ b/mod_shoutbox/mod_shoutbox.xml @@ -128,6 +128,11 @@
+ + + + + diff --git a/mod_shoutbox/tmpl/default.php b/mod_shoutbox/tmpl/default.php index a2cde77..be814cc 100644 --- a/mod_shoutbox/tmpl/default.php +++ b/mod_shoutbox/tmpl/default.php @@ -35,7 +35,7 @@
-
+
getShouts($number, $dataerror); ?> @@ -50,6 +50,7 @@
+
From 85debf19a060389a50c393013d64120222f0a59e Mon Sep 17 00:00:00 2001 From: "Charlie.lodder" Date: Mon, 2 Mar 2015 17:34:02 +0000 Subject: [PATCH 16/25] Updated changelog WIP --- changelog.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog.php b/changelog.php index 340fc27..cf35685 100644 --- a/changelog.php +++ b/changelog.php @@ -14,14 +14,16 @@ - -> Removed ! -> Note -WIP (Version 3.0.1) +WIP (Version 3.1.0) + Added option for required name + Added generic name as parameter if none used + Added Gravatar integration + Added Kunena avatar integration ^ Improved error reporting ^ Improved BBCode (now works with highlighted strings) +^ Replaced UI Framework detection with parameter # Fixed smiley path for multilingual sites +# Fixed shout submits not working when assigned to single menu item Version 3.0.0 + Integrated AJAX for submitting and retrieving posts From b1b832f5e361e2873861bd956598074a0cc35f25 Mon Sep 17 00:00:00 2001 From: wilsonge Date: Mon, 2 Mar 2015 20:55:07 +0000 Subject: [PATCH 17/25] Fix undefined variable --- mod_shoutbox/helper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mod_shoutbox/helper.php b/mod_shoutbox/helper.php index f5c7bf9..676d5dd 100644 --- a/mod_shoutbox/helper.php +++ b/mod_shoutbox/helper.php @@ -860,10 +860,11 @@ public function renderPost($shout, $layout = 'default') * * @since 3.0.1 */ - public function getAvatar( $type, $id ) + public function getAvatar($type, $id) { $user = JFactory::getUser($id); $email = $user->email; + $url = ''; if ($type == 'gravatar') { From ae0a277b837f32544c89a64a0089b86469d8b184 Mon Sep 17 00:00:00 2001 From: wilsonge Date: Mon, 2 Mar 2015 21:03:55 +0000 Subject: [PATCH 18/25] Add JomSocial Avatar support --- mod_shoutbox/helper.php | 23 +++++++++++++++++++++-- mod_shoutbox/mod_shoutbox.xml | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/mod_shoutbox/helper.php b/mod_shoutbox/helper.php index 676d5dd..729c8fb 100644 --- a/mod_shoutbox/helper.php +++ b/mod_shoutbox/helper.php @@ -883,7 +883,7 @@ public function getAvatar($type, $id) } $url .= ' />'; } - else if ($type == 'kunena') + elseif ($type == 'kunena') { if (class_exists('KunenaFactory')) { @@ -893,7 +893,26 @@ public function getAvatar($type, $id) $url = $profile->getAvatarImage('kavatar','profile'); } } - else if ($type == 'cb') + elseif ($type == 'jomsocial') + { + // JomSocial Profile Link + $jspath = JPATH_ROOT . '/components/com_community/libraries/core.php'; + + if (JFile::exists($jspath)) + { + include_once $jspath; + $cuser = CFactory::getUser($user->id); + $avatarUrl = $cuser->getThumbAvatar(); + + $url = ''; + } + else + { + JLog::add(JText::_('SHOUT_JOM_SOCIAL_NOT_INSTALLED'), JLog::WARNING, 'mod_shoutbox'); + JFactory::getApplication()->enqueueMessage(JText::_('SHOUT_JOM_SOCIAL_NOT_INSTALLED'), 'error'); + } + } + elseif ($type == 'cb') { // To-Do: Get CB avatar } diff --git a/mod_shoutbox/mod_shoutbox.xml b/mod_shoutbox/mod_shoutbox.xml index 2d32465..9f77dbb 100644 --- a/mod_shoutbox/mod_shoutbox.xml +++ b/mod_shoutbox/mod_shoutbox.xml @@ -81,6 +81,7 @@ + From b42c64a64520487601002ee34f83a040d0cc1be3 Mon Sep 17 00:00:00 2001 From: wilsonge Date: Mon, 2 Mar 2015 21:40:48 +0000 Subject: [PATCH 19/25] [Fix] Multiple instances give multiple posts in AJAX mode --- mod_shoutbox/media/js/mod_shoutbox.js | 48 +++++++++++++-------------- mod_shoutbox/mod_shoutbox.php | 7 ++-- mod_shoutbox/tmpl/default.php | 31 ++++++++--------- 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/mod_shoutbox/media/js/mod_shoutbox.js b/mod_shoutbox/media/js/mod_shoutbox.js index d8d3298..daba66d 100644 --- a/mod_shoutbox/media/js/mod_shoutbox.js +++ b/mod_shoutbox/media/js/mod_shoutbox.js @@ -128,17 +128,17 @@ jQuery(document).ready(function($) { }); // SMILEY SLIDETOGGLE - $('#jj_btn').on('click', function(e) { + $('#jj_btn').on('click', function(e) { e.preventDefault(); $(this).toggleClass('rotated'); $('#jj_smiley_box').stop(true, false).slideToggle(); }); // SUBMIT POST - JJsubmitPost = function(name, title, securityType, security, root, Itemid) + JJsubmitPost = function(name, title, securityType, security, Itemid, instance) { // Assemble some commonly used vars - var textarea = $('#jj_message'), + var textarea = instance.find('#jj_message'), message = textarea.val(); // Assemble variables to submit @@ -153,15 +153,15 @@ jQuery(document).ready(function($) { if (securityType == 1) { - request['recaptcha_challenge_field'] = $('input#recaptcha_challenge_field').val(); - request['recaptcha_response_field'] = $('input#recaptcha_response_field').val(); + request['recaptcha_challenge_field'] = instance.find('input#recaptcha_challenge_field').val(); + request['recaptcha_response_field'] = instance.find('input#recaptcha_response_field').val(); } if (securityType == 2) { - request['jjshout[sum1]'] = $('input[name="jjshout[sum1]"]').val(); - request['jjshout[sum2]'] = $('input[name="jjshout[sum2]"]').val(); - request['jjshout[human]'] = $('input[name="jjshout[human]"]').val(); + request['jjshout[sum1]'] = instance.find('input[name="jjshout[sum1]"]').val(); + request['jjshout[sum2]'] = instance.find('input[name="jjshout[sum2]"]').val(); + request['jjshout[human]'] = instance.find('input[name="jjshout[human]"]').val(); } // AJAX request @@ -176,13 +176,13 @@ jQuery(document).ready(function($) { textarea.val(''); // Empty the name value if there is one - if ($('#shoutbox-name').val()) + if (instance.find('#shoutbox-name').val()) { - $('#shoutbox-name').val(''); + instance.find('#shoutbox-name').val(''); } // Refresh the output - JJgetPosts(title, root, false, Itemid) + JJgetPosts(title, false, Itemid, instance) } }, error:function(ts){ @@ -202,10 +202,10 @@ jQuery(document).ready(function($) { var val1, val2; val1 = getRandomArbitrary(0,9); val2 = getRandomArbitrary(0,9); - $('input[name="jjshout[sum1]"]').val(val1); - $('input[name="jjshout[sum2]"]').val(val2); - $('label[for="math_output"]').text(val1 + ' + ' + val2); - $('input[name="jjshout[human]"]').val(''); + instance.find('input[name="jjshout[sum1]"]').val(val1); + instance.find('input[name="jjshout[sum2]"]').val(val2); + instance.find('label[for="math_output"]').text(val1 + ' + ' + val2); + instance.find('input[name="jjshout[human]"]').val(''); } return false; @@ -213,11 +213,11 @@ jQuery(document).ready(function($) { // GET POSTS - JJgetPosts = function(title, root, sound, Itemid) + JJgetPosts = function(title, sound, Itemid, instance) { // Get the ID of the last shout - var lastID = getLastID(); + var lastID = getLastID(instance); // Assemble variables to submit var request = { @@ -232,10 +232,10 @@ jQuery(document).ready(function($) { success:function(response){ if (response.success) { - $('#jjshoutboxoutput').empty().prepend($('
')); + instance.find('#jjshoutboxoutput').empty().prepend($('
')); // Grab the html output and append it to the shoutbox message - $('.jj-shout-new').after(response.data.html); + instance.find('.jj-shout-new').after(response.data.html); // Get the ID of the last shout after the output has been updated var newLastID = getLastID(); @@ -243,7 +243,7 @@ jQuery(document).ready(function($) { // Play notification sound if enabled if (sound == 1 && newLastID > lastID) { - document.getElementById('jjshoutbox-audio').play(); + instance.find('.jjshoutbox-audio').get(0).play(); } } }, @@ -256,17 +256,17 @@ jQuery(document).ready(function($) { } // Get the last ID of the shoutbox output - function getLastID() + function getLastID(instance) { - var lastId = $('#jjshoutboxoutput').find('.shout-header:first-child').data('shout-id'); + var lastId = instance.find('.shout-header:first-child').data('shout-id'); return lastId; } // Check if the name or message fields are empty - showError = function(field) + showError = function(field, instance) { - var errorBox = $('.jj-shout-error'); + var errorBox = instance.find('.jj-shout-error'); if( field == '' ) { diff --git a/mod_shoutbox/mod_shoutbox.php b/mod_shoutbox/mod_shoutbox.php index 17004a1..3fbfb36 100644 --- a/mod_shoutbox/mod_shoutbox.php +++ b/mod_shoutbox/mod_shoutbox.php @@ -11,9 +11,10 @@ require_once dirname(__FILE__) . '/helper.php'; -$title = $module->title; -$helper = new ModShoutboxHelper($title); -$params = $helper->getParams(); +$title = $module->title; +$uniqueId = $module->id; +$helper = new ModShoutboxHelper($title); +$params = $helper->getParams(); $displayName = $params->get('loginname', 'user'); $smile = $params->get('smile'); diff --git a/mod_shoutbox/tmpl/default.php b/mod_shoutbox/tmpl/default.php index 1565758..675b62b 100644 --- a/mod_shoutbox/tmpl/default.php +++ b/mod_shoutbox/tmpl/default.php @@ -45,9 +45,10 @@ } $doc->addStyleDeclaration($style); +$uniqueIdentifier = 'jjshoutbox' . $uniqueId; ?> -
+
@@ -67,7 +68,7 @@
-