Skip to content

Commit

Permalink
Merge pull request #153 from JoomJunk/development
Browse files Browse the repository at this point in the history
Update to v4.0.0
  • Loading branch information
C-Lodder committed Apr 15, 2015
2 parents eb153da + 991034f commit d829838
Show file tree
Hide file tree
Showing 17 changed files with 283 additions and 216 deletions.
8 changes: 8 additions & 0 deletions changelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
- -> Removed
! -> Note

Version 4.0.0
+ Added Norwegian language pack (Thanks Johan)
+ Added Community Builder avatar integration
+ Added Popover for BBCode Link example
+ Added option to submit using the Enter key
$ Button and permissions message now language strings
- Removed support for Joomla 2.5

Version 3.1.2
* Fix XSS vunerability where script tags could be placed in the message body

Expand Down
39 changes: 6 additions & 33 deletions mod_shoutbox/fields/fade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,14 @@ protected function getLabel()
$app = JFactory::getApplication();

// Import jQuery
if (version_compare(JVERSION, '3.0.0', 'ge'))
{
JHtml::_('jquery.framework');
}
else
{
if (!$app->get('jquery'))
{
$app->set('jquery', true);
$doc->addScript('//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js');
JHtml::_('script', 'mod_shoutbox/jquery-conflict.js', false, true);
}
}

if (version_compare(JVERSION, '3.0.0', 'ge'))
{
$parent = '.control-group';
}
else
{
$parent = 'li';
}


JHtml::_('jquery.framework');

$js = '
jQuery(document).ready(function($) {
var securityType = $("#jform_params_securitytype");
var public = $("#jform_params_recaptcha_public-lbl").parents("' . $parent . '");
var private = $("#jform_params_recaptcha_private-lbl").parents("' . $parent . '");
var public = $("#jform_params_recaptcha_public-lbl").parents(".control-group");
var private = $("#jform_params_recaptcha_private-lbl").parents(".control-group");
if( securityType.val() == 0 || securityType.val() == 2 ) {
public.hide();
Expand All @@ -84,7 +62,7 @@ protected function getLabel()
var nameRequired = $("#jform_params_namerequired");
var genericName = $("#jform_params_genericname-lbl").parents("' . $parent . '");
var genericName = $("#jform_params_genericname-lbl").parents(".control-group");
if( nameRequired.val() == 1 ) {
genericName.hide();
Expand All @@ -108,12 +86,7 @@ protected function getLabel()

$doc->addScriptDeclaration($js);

if (version_compare(JVERSION, '3.0.0', 'ge'))
{
return '<hr>';
}

return '';
return '<hr>';
}

/**
Expand Down
139 changes: 61 additions & 78 deletions mod_shoutbox/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,8 @@ class ModShoutboxHelper
*/
public static function submitAjax()
{
if (!get_magic_quotes_gpc())
{
$app = JFactory::getApplication();
$post = $app->input->post->get('jjshout', array(), 'array');
}
else
{
$post = JRequest::getVar('jjshout', array(), 'post', 'array');
}
$app = JFactory::getApplication();
$post = $app->input->post->get('jjshout', array(), 'array');

// Retrieve relevant parameters
if (!isset($post['title']))
Expand Down Expand Up @@ -111,15 +104,8 @@ public static function submitAjax()
*/
public static function getPostsAjax()
{
if (!get_magic_quotes_gpc())
{
$app = JFactory::getApplication();
$post = $app->input->post->get('jjshout', array(), 'array');
}
else
{
$post = JRequest::getVar('jjshout', array(), 'post', 'array');
}
$app = JFactory::getApplication();
$post = $app->input->post->get('jjshout', array(), 'array');

// Retrieve required parameter
if (!isset($post['title']))
Expand Down Expand Up @@ -225,20 +211,12 @@ private function getShoutData($number)
->order($db->quoteName('id') . ' DESC');
$db->setQuery($query, 0, $number);

if (!JError::$legacy)
{
// If we have an exception then we'll let it propagate up the chain
$rows = $db->loadObjectList();
}
else
{
$rows = $db->loadObjectList();
$rows = $db->loadObjectList();

// If we have an error with JError then we'll create an exception ourselves
if ($db->getErrorNum())
{
throw new RuntimeException($db->getErrorMsg(), $db->getErrorNum());
}
// If we have an error then we'll create an exception
if ($db->getErrorNum())
{
throw new RuntimeException($db->getErrorMsg(), $db->getErrorNum());
}

// Ensure the date formatting
Expand Down Expand Up @@ -270,20 +248,12 @@ public function getAShout($id)
->where($db->quoteName('id') . ' = ' . $id);
$db->setQuery($query);

if (!JError::$legacy)
{
// If we have an exception then we'll let it propagate up the chain
$row = $db->loadObject();
}
else
{
$row = $db->loadObject();
$row = $db->loadObject();

// If we have an error with JError then we'll create an exception ourselves
if ($db->getErrorNum())
{
throw new RuntimeException($db->getErrorMsg(), $db->getErrorNum());
}
// If we have an error then we'll create an exception
if ($db->getErrorNum())
{
throw new RuntimeException($db->getErrorMsg(), $db->getErrorNum());
}

// Format the when correctly
Expand Down Expand Up @@ -389,9 +359,9 @@ public function postFiltering($shout, $user, $swearCounter, $swearNumber, $displ
$ip = $_SERVER['REMOTE_ADDR'];

// Sanity check on the contents of the user fields
$filter = JFilterInput::getInstance();
$name = $filter->clean($name, 'string');
$message = $filter->clean($message, 'string');
$filter = JFilterInput::getInstance();
$name = $filter->clean($name, 'string');
$message = $filter->clean($message, 'string');

if ($swearCounter == 0 || $swearCounter == 1 && (($nameSwears + $messageSwears) <= $swearNumber))
{
Expand Down Expand Up @@ -610,27 +580,16 @@ public function addShout($name, $message, $ip)
->columns($db->quoteName($columns))
->values(implode(',', $values));


$db->setQuery($query);

if (version_compare(JVERSION, '3.0.0', 'ge'))
try
{
try
{
$db->execute();
}
catch (Exception $e)
{
JLog::add(JText::sprintf('SHOUT_DATABASE_ERROR', $e), JLog::CRITICAL, 'mod_shoutbox');
}
$db->execute();
}
else
catch (Exception $e)
{
$db->query();

if ($db->getErrorNum())
{
JLog::add(JText::sprintf('SHOUT_DATABASE_ERROR', $db->getErrorMsg()), JLog::CRITICAL, 'mod_shoutbox');
}
JLog::add(JText::sprintf('SHOUT_DATABASE_ERROR', $e), JLog::CRITICAL, 'mod_shoutbox');
}

return $db->insertid();
Expand All @@ -650,18 +609,11 @@ public function deletepost($id)
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->delete()
->from($db->quoteName('#__shoutbox'))
->where($db->quoteName('id') . ' = ' . (int) $id);
->from($db->quoteName('#__shoutbox'))
->where($db->quoteName('id') . ' = ' . (int) $id);
$db->setQuery($query);

if (version_compare(JVERSION, '3.0.0', 'ge'))
{
$db->execute();
}
else
{
$db->query();
}
$db->execute();
}

/**
Expand All @@ -678,9 +630,10 @@ public function deleteall($delete)
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('*')
->from($db->quoteName('#__shoutbox'))
->order($db->quoteName('id') . ' DESC');
->from($db->quoteName('#__shoutbox'))
->order($db->quoteName('id') . ' DESC');
$db->setQuery($query, 0, $delete);

$rows = $db->loadObjectList();

foreach ($rows as $row)
Expand Down Expand Up @@ -918,8 +871,38 @@ public function getAvatar($type, $id)
}
}
elseif ($type == 'cb')
{
// To-Do: Get CB avatar
{
// Use a database query as the CB framework is horrible
$db = JFactory::getDbo();

$query = $db->getQuery(true);

$query->select($db->quoteName('avatar'))
->from($db->quoteName('#__comprofiler'))
->where($db->quoteName('user_id') . ' = '. $db->quote($user->id));

$db->setQuery($query);

try
{
$result = $db->loadResult();
}
catch (Exception $e)
{
// If there is an error in the database request show the default avatar
$result = false;
}

if ($result)
{
$avatar = JUri::root() . 'images/comprofiler/tn' . $result;
}
else
{
$avatar = JUri::root() . 'components/com_comprofiler/plugin/templates/default/images/avatar/tnnophoto_n.png';
}

$url = '<img src="' . $avatar . '" height="30" width="30">';
}

return $url;
Expand Down Expand Up @@ -1058,4 +1041,4 @@ private function createErrorMsg($message, $e)

return $shouts;
}
}
}
8 changes: 4 additions & 4 deletions mod_shoutbox/language/en-GB/en-GB.mod_shoutbox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ SHOUT_DATE_SPACE_OPTION_TWO="Sat 31 Jan"
SHOUT_DATE_AMERICAN_BACKSLASH="01/31/2015"
SHOUT_DATE_REVERSED="2015/01/31"
SHOUT_DONT_SHOW="Don't Show"
SHOUT_SUBMITTEXT="Submit button text"
SHOUT_SUBMITTEXTDESC="Type in the text that you like to be shown on the submit button"
SHOUT_NONMEMBER="No permissions message"
SHOUT_NONMEMBERDESC="The message that will be displayed to those who do not have permissions to use the shoutbox"
SHOUT_SUBMITTEXT="Submit"
SHOUT_NONMEMBER="The shoutbox is unavailable to non-members"
SHOUT_AUTO_REFRESH="Auto refresh (seconds)"
SHOUT_AUTO_REFRESH_DESC="Select how many seconds it takes for the auto refresh to retrieve new shouts"
SHOUT_NAME="Name"
Expand Down Expand Up @@ -68,6 +66,8 @@ SHOUT_SOUNDLABEL="Sound Notifications"
SHOUT_SOUNDDESC="Select whether or not you would like a sound notification when there's a new shout"
SHOUT_BBCODELABEL="BBCode"
SHOUT_BBCODEDESC="Select whether you would like to enable BBCode"
SHOUT_ENTERTOSUBMIT="Enter to submit"
SHOUT_ENTERTOSUBMITDESC="Set to On if you would like to submit your shouts by pressing the Enter key"
SHOUT_FRAMEWORK="UI Framework Integration"
SHOUT_FRAMEWORK_DESC="Select whether you wish to integrate the shoutbox styling with UIKit or Bootstrap"
SHOUT_BOOTSTRAP="Bootstrap"
Expand Down
8 changes: 4 additions & 4 deletions mod_shoutbox/language/it-IT/it-IT.mod_shoutbox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ SHOUT_DATE_SPACE_OPTION_TWO="Sab 31 Gen"
SHOUT_DATE_AMERICAN_BACKSLASH="01/31/2015"
SHOUT_DATE_REVERSED="2015/01/31"
SHOUT_DONT_SHOW="Non visualizzare"
SHOUT_SUBMITTEXT="Testo Bottone Invia"
SHOUT_SUBMITTEXTDESC="Digitare il testo che si desidera venga visualizzato sul pulsante di invio"
SHOUT_NONMEMBER="Nessun messaggio permesso"
SHOUT_NONMEMBERDESC="Il messaggio che verrà visualizzato a coloro che non dispongono delle autorizzazioni per utilizzare la shoutbox"
SHOUT_SUBMITTEXT="Submit"
SHOUT_NONMEMBER="The shoutbox is unavailable to non-members"
SHOUT_AUTO_REFRESH="Auto refresh (seconds)"
SHOUT_AUTO_REFRESH_DESC="Select how many seconds it takes for the auto refresh to retrieve new shouts"
SHOUT_NAME="Nome"
Expand Down Expand Up @@ -68,6 +66,8 @@ SHOUT_SOUNDLABEL="Sound Notifications"
SHOUT_SOUNDDESC="Select whether or not you would like a sound notification when there's a new shout"
SHOUT_BBCODELABEL="BBCode"
SHOUT_BBCODEDESC="Select whether you would like to enable BBCode"
SHOUT_ENTERTOSUBMIT="Enter to submit"
SHOUT_ENTERTOSUBMITDESC="Set to On if you would like to submit your shouts by pressing the Enter key"
SHOUT_FRAMEWORK="UI Framework Integration"
SHOUT_FRAMEWORK_DESC="Select whether you wish to integrate the shoutbox styling with UIKit or Bootstrap"
SHOUT_BOOTSTRAP="Bootstrap"
Expand Down
Loading

0 comments on commit d829838

Please sign in to comment.