Skip to content

Commit

Permalink
Merge branch 'staging' of https://github.com/joomla/joomla-cms into b…
Browse files Browse the repository at this point in the history
…atchoptimizations
  • Loading branch information
Hackwar committed Dec 8, 2014
2 parents 4696989 + 98b2073 commit 1ee8ee6
Show file tree
Hide file tree
Showing 20 changed files with 414 additions and 5 deletions.
@@ -0,0 +1,2 @@
INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES
(452, 'plg_captcha_nocaptcha', 'plugin', 'nocaptcha', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"light"}', '', '', 0, '0000-00-00 00:00:00', 0, 0);
@@ -0,0 +1,2 @@
INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES
(452, 'plg_captcha_nocaptcha', 'plugin', 'nocaptcha', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"light"}', '', '', 0, '1970-01-01 00:00:00', 0, 0);
@@ -0,0 +1,6 @@
SET IDENTITY_INSERT [#__extensions] ON;

INSERT [#__extensions] ([extension_id], [name], [type], [element], [folder], [client_id], [enabled], [access], [protected], [manifest_cache], [params], [custom_data], [system_data], [checked_out], [checked_out_time], [ordering], [state])
SELECT 452, 'plg_captcha_nocaptcha', 'plugin', 'nocaptcha', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"light"}', '', '', 0, '1900-01-01 00:00:00', 0, 0;

SET IDENTITY_INSERT [#__extensions] OFF;
Expand Up @@ -125,6 +125,15 @@ protected function addToolbar()
$bar->appendButton('Custom', $dhtml, 'batch');
}

if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete'))
{
JToolbarHelper::deleteList('', 'articles.delete', 'JTOOLBAR_EMPTY_TRASH');
}
elseif ($canDo->get('core.edit.state'))
{
JToolbarHelper::trash('articles.trash');
}

if ($user->authorise('core.admin', 'com_content') || $user->authorise('core.options', 'com_content'))
{
JToolbarHelper::preferences('com_content');
Expand Down
4 changes: 3 additions & 1 deletion administrator/components/com_installer/models/install.php
Expand Up @@ -158,20 +158,22 @@ public function install()
// There was an error installing the package.
$msg = JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
$result = false;
$msgType = 'error';
}
else
{
// Package installed sucessfully.
$msg = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
$result = true;
$msgType = 'message';
}

// This event allows a custom a post-flight:
$dispatcher->trigger('onInstallerAfterInstaller', array($this, &$package, $installer, &$result, &$msg));

// Set some model state values.
$app = JFactory::getApplication();
$app->enqueueMessage($msg);
$app->enqueueMessage($msg, $msgType);
$this->setState('name', $installer->get('name'));
$this->setState('result', $result);
$app->setUserState('com_installer.message', $installer->message);
Expand Down
23 changes: 23 additions & 0 deletions administrator/language/en-GB/en-GB.plg_captcha_nocaptcha.ini
@@ -0,0 +1,23 @@
; Joomla! Project
; Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

PLG_CAPTCHA_NOCAPTCHA_XML_DESCRIPTION="This CAPTCHA plugin uses the reCAPTCHA service to prevent spammers. To get a site and secret key for your domain, go to <a href="_QQ_"http://www.google.com/recaptcha"_QQ_" target="_QQ_"_blank"_QQ_">http://www.google.com/recaptcha</a>. To use this for new account registration, go to Options in the User Manager and select Captcha - NoCAPTCHA as the Captcha."
PLG_CAPTCHA_NOCAPTCHA="Captcha - NoCAPTCHA"

; Params
PLG_NOCAPTCHA_PUBLIC_KEY_LABEL="Site key"
PLG_NOCAPTCHA_PUBLIC_KEY_DESC="Used in the JavaScript code that is served to your users. See the plugin description for instructions on getting a site key."
PLG_NOCAPTCHA_PRIVATE_KEY_LABEL="Secret key"
PLG_NOCAPTCHA_PRIVATE_KEY_DESC="Used in the communication between your server and the reCAPTCHA server. Be sure to keep it a secret. See the plugin description for instructions on getting a secret key."
PLG_NOCAPTCHA_THEME_LABEL="Theme"
PLG_NOCAPTCHA_THEME_DESC="Defines which theme to use for NoCAPTCHA."
PLG_NOCAPTCHA_THEME_LIGHT="Light"
PLG_NOCAPTCHA_THEME_DARK="Dark"

; Error messages
PLG_NOCAPTCHA_ERROR_NO_PRIVATE_KEY="The NoCAPTCHA plugin needs a secret key to be set in its parameters. Please contact a site administrator."
PLG_NOCAPTCHA_ERROR_NO_PUBLIC_KEY="The NoCAPTCHA plugin needs a site key to be set in its parameters. Please contact a site administrator."
PLG_NOCAPTCHA_ERROR_NOT_SET="Please complete the security question."
PLG_NOCAPTCHA_ERROR_NO_IP="For security reasons, you must pass the remote ip address to NoCAPTCHA"
@@ -0,0 +1,7 @@
; Joomla! Project
; Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8

PLG_CAPTCHA_NOCAPTCHA_XML_DESCRIPTION="This CAPTCHA plugin uses the reCAPTCHA service to prevent spammers. To get a site and secret key for your domain, go to <a href="_QQ_"http://www.google.com/recaptcha"_QQ_" target="_QQ_"_blank"_QQ_">http://www.google.com/recaptcha</a>. To use this for new account registration, go to Options in the User Manager and select Captcha - NoCAPTCHA as the Captcha."
PLG_CAPTCHA_NOCAPTCHA="Captcha - NoCAPTCHA"
2 changes: 2 additions & 0 deletions administrator/language/en-GB/install.xml
Expand Up @@ -113,6 +113,8 @@
<filename>en-GB.plg_authentication_joomla.sys.ini</filename>
<filename>en-GB.plg_authentication_ldap.ini</filename>
<filename>en-GB.plg_authentication_ldap.sys.ini</filename>
<filename>en-GB.plg_captcha_nocaptcha.ini</filename>
<filename>en-GB.plg_captcha_nocaptcha.sys.ini</filename>
<filename>en-GB.plg_captcha_recaptcha.ini</filename>
<filename>en-GB.plg_captcha_recaptcha.sys.ini</filename>
<filename>en-GB.plg_content_emailcloak.ini</filename>
Expand Down
3 changes: 3 additions & 0 deletions administrator/templates/isis/css/template-rtl.css
Expand Up @@ -7964,6 +7964,9 @@ input.input-large-text {
overflow: hidden;
position: relative;
}
.editor textarea.mce_editable {
box-sizing: border-box;
}
a.grid_false {
display: inline-block;
height: 16px;
Expand Down
3 changes: 3 additions & 0 deletions administrator/templates/isis/css/template.css
Expand Up @@ -7964,6 +7964,9 @@ input.input-large-text {
overflow: hidden;
position: relative;
}
.editor textarea.mce_editable {
box-sizing: border-box;
}
a.grid_false {
display: inline-block;
height: 16px;
Expand Down
3 changes: 3 additions & 0 deletions administrator/templates/isis/less/template.less
Expand Up @@ -1038,6 +1038,9 @@ input.input-large-text {
overflow: hidden;
position: relative
}
.editor textarea.mce_editable {
box-sizing: border-box;
}

/* For grid.boolean */
a.grid_false {
Expand Down
1 change: 1 addition & 0 deletions build/phpcs/Joomla/ruleset.xml
Expand Up @@ -23,6 +23,7 @@
<exclude-pattern type="relative">configuration.php</exclude-pattern>
<exclude-pattern type="relative">libraries/ClassLoader.php</exclude-pattern>
<exclude-pattern type="relative">libraries/composer_autoload.php</exclude-pattern>
<exclude-pattern type="relative">plugins/captcha/nocaptcha/recaptchalib.php</exclude-pattern>

<!-- Include all sniffs in an external standard directory -->

Expand Down
1 change: 1 addition & 0 deletions installation/sql/mysql/joomla.sql
Expand Up @@ -610,6 +610,7 @@ INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`
(449, 'plg_authentication_cookie', 'plugin', 'cookie', 'authentication', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(450, 'plg_twofactorauth_yubikey', 'plugin', 'yubikey', 'twofactorauth', 0, 0, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(451, 'plg_search_tags', 'plugin', 'tags', 'search', 0, 1, 1, 0, '', '{"search_limit":"50","show_tagged_items":"1"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(452, 'plg_captcha_nocaptcha', 'plugin', 'nocaptcha', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"light"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(503, 'beez3', 'template', 'beez3', '', 0, 1, 1, 0, '', '{"wrapperSmall":"53","wrapperLarge":"72","sitetitle":"","sitedescription":"","navposition":"center","templatecolor":"nature"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(504, 'hathor', 'template', 'hathor', '', 1, 1, 1, 0, '', '{"showSiteName":"0","colourChoice":"0","boldText":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
(506, 'protostar', 'template', 'protostar', '', 0, 1, 1, 0, '', '{"templateColor":"","logoFile":"","googleFont":"1","googleFontName":"Open+Sans","fluidContainer":"0"}', '', '', 0, '0000-00-00 00:00:00', 0, 0),
Expand Down
3 changes: 2 additions & 1 deletion installation/sql/postgresql/joomla.sql
Expand Up @@ -609,7 +609,8 @@ INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder"
(448, 'plg_twofactorauth_totp', 'plugin', 'totp', 'twofactorauth', 0, 0, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0),
(449, 'plg_authentication_cookie', 'plugin', 'cookie', 'authentication', 0, 1, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0),
(450, 'plg_twofactorauth_yubikey', 'plugin', 'yubikey', 'twofactorauth', 0, 0, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0),
(451, 'plg_search_tags', 'plugin', 'tags', 'search', 0, 1, 1, 0, '', '{"search_limit":"50","show_tagged_items":"1"}', '', '', 0, '1970-01-01 00:00:00', 0, 0);
(451, 'plg_search_tags', 'plugin', 'tags', 'search', 0, 1, 1, 0, '', '{"search_limit":"50","show_tagged_items":"1"}', '', '', 0, '1970-01-01 00:00:00', 0, 0),
(452, 'plg_captcha_nocaptcha', 'plugin', 'nocaptcha', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"light"}', '', '', 0, '1970-01-01 00:00:00', 0, 0);

-- Templates
INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES
Expand Down
4 changes: 3 additions & 1 deletion installation/sql/sqlazure/joomla.sql
Expand Up @@ -1011,7 +1011,9 @@ SELECT 449, 'plg_authentication_cookie', 'plugin', 'cookie', 'authentication', 0
UNION ALL
SELECT 450, 'plg_twofactorauth_yubikey', 'plugin', 'yubikey', 'twofactorauth', 0, 0, 1, 0, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0
UNION ALL
SELECT 451, 'plg_search_tags', 'plugin', 'tags', 'search', 0, 1, 1, 0, '', '{"search_limit":"50","show_tagged_items":"1"}', '', '', 0, '1900-01-01 00:00:00', 0, 0;
SELECT 451, 'plg_search_tags', 'plugin', 'tags', 'search', 0, 1, 1, 0, '', '{"search_limit":"50","show_tagged_items":"1"}', '', '', 0, '1900-01-01 00:00:00', 0, 0
UNION ALL
SELECT 452, 'plg_captcha_nocaptcha', 'plugin', 'nocaptcha', 'captcha', 0, 0, 1, 0, '', '{"public_key":"","private_key":"","theme":"light"}', '', '', 0, '1900-01-01 00:00:00', 0, 0;


INSERT [#__extensions] ([extension_id], [name], [type], [element], [folder], [client_id], [enabled], [access], [protected], [manifest_cache], [params], [custom_data], [system_data], [checked_out], [checked_out_time], [ordering], [state])
Expand Down
1 change: 1 addition & 0 deletions plugins/captcha/nocaptcha/index.html
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
141 changes: 141 additions & 0 deletions plugins/captcha/nocaptcha/nocaptcha.php
@@ -0,0 +1,141 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Captcha
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

/**
* NoCaptcha Plugin.
* Based on the official recaptcha library( https://developers.google.com/recaptcha/docs/php )
*
* @since 3.4
*/
class PlgCaptchaNocaptcha extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.4
*/
protected $autoloadLanguage = true;

/**
* Initialise the captcha
*
* @param string $id The id of the field.
*
* @return boolean True on success, false otherwise
*
* @since 3.4
*/
public function onInit($id = 'dynamic_recaptcha_1')
{
$document = JFactory::getDocument();
$app = JFactory::getApplication();

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

$public_key = $this->params->get('public_key', '');
$theme = $this->params->get('theme', 'light');

if ($public_key == null || $public_key == '')
{
throw new Exception(JText::_('PLG_NOCAPTCHA_ERROR_NO_PUBLIC_KEY'));
}

$file = $app->isSSLConnection() ? 'https' : 'http';
$file .= '://www.google.com/recaptcha/api.js?hl=' . JFactory::getLanguage()
->getTag() . '&onload=onloadCallback&render=explicit';

JHtml::_('script', $file, true, true);

$document->addScriptDeclaration('var onloadCallback = function() {'
. 'grecaptcha.render("' . $id . '", {sitekey: "' . $public_key . '", theme: "' . $theme . '"});'
. '}'
);

return true;
}

/**
* Gets the challenge HTML
*
* @param string $name The name of the field.
* @param string $id The id of the field.
* @param string $class The class of the field. This should be passed as
* e.g. 'class="required"'.
*
* @return string The HTML to be embedded in the form.
*
* @since 3.4
*/
public function onDisplay($name, $id = 'dynamic_recaptcha_1', $class = '')
{
return '<div id="' . $id . '" ' . $class . '></div>';
}

/**
* Calls an HTTP POST function to verify if the user's guess was correct
*
* @param string $code Answer provided by user.
*
* @return True if the answer is correct, false otherwise
*
* @since 3.4
*/
public function onCheckAnswer($code)
{
$input = JFactory::getApplication()->input;
$privatekey = $this->params->get('private_key');
$remoteip = $input->server->get('REMOTE_ADDR', '', 'string');
$response = $input->get('g-recaptcha-response', '', 'string');

// Check for Private Key
if (empty($privatekey))
{
$this->_subject->setError(JText::_('PLG_NOCAPTCHA_ERROR_NO_PRIVATE_KEY'));

return false;
}

// Check for IP
if (empty($remoteip))
{
$this->_subject->setError(JText::_('PLG_NOCAPTCHA_ERROR_NO_IP'));

return false;
}

// Discard spam submissions
if ($response == null || strlen($response) == 0)
{
$this->_subject->setError(JText::_('PLG_NOCAPTCHA_ERROR_EMPTY_SOLUTION'));

return false;
}

require_once 'recaptchalib.php';

$reCaptcha = new JReCaptcha($privatekey);
$response = $reCaptcha->verifyResponse($remoteip, $response);

if ( !isset($response->success) || !$response->success)
{
// @todo use exceptions here
foreach ($response->errorCodes as $error)
{
$this->_subject->setError($error);
}

return false;
}

return true;
}
}
55 changes: 55 additions & 0 deletions plugins/captcha/nocaptcha/nocaptcha.xml
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="captcha">
<name>plg_captcha_nocaptcha</name>
<version>3.0.0</version>
<creationDate>December 2014</creationDate>
<author>Joomla! Project</author>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<copyright>Copyright (C) 2005 - 2014 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<description>PLG_CAPTCHA_NOCAPTCHA_XML_DESCRIPTION</description>
<files>
<filename
plugin="nocaptcha">nocaptcha.php</filename>
</files>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="public_key"
type="text"
default=""
label="PLG_NOCAPTCHA_PUBLIC_KEY_LABEL"
description="PLG_NOCAPTCHA_PUBLIC_KEY_DESC"
required="true"
filter="string"
size="50" />

<field
name="private_key"
type="text"
default=""
label="PLG_NOCAPTCHA_PRIVATE_KEY_LABEL"
description="PLG_NOCAPTCHA_PRIVATE_KEY_DESC"
required="true"
filter="string"
size="50" />

<field
name="theme"
type="list"
default="dark"
label="PLG_NOCAPTCHA_THEME_LABEL"
description="PLG_NOCAPTCHA_THEME_DESC"
required="true"
filter="">
<option
value="light">PLG_NOCAPTCHA_THEME_LIGHT</option>
<option
value="dark">PLG_NOCAPTCHA_THEME_DARK</option>
</field>
</fieldset>
</fields>
</config>
</extension>

0 comments on commit 1ee8ee6

Please sign in to comment.