Removed the fallback for empty description on title field.Improved the createUser method to allow custom methodd registerUser to create a user. Fixed the empty not_required field issue.

This commit is contained in:
Llewellyn van der Merwe 2020-07-18 21:36:05 +02:00
parent 3a5681ce43
commit 27de9a83a5
Signed by untrusted user: Llewellyn
GPG Key ID: EFC0C720A240551C
24 changed files with 54 additions and 52 deletions

View File

@ -144,11 +144,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 13th July, 2020
+ *Last Build*: 16th July, 2020
+ *Version*: 2.11.2
+ *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **282699**
+ *Line count*: **282693**
+ *Field count*: **1525**
+ *File count*: **1785**
+ *Folder count*: **295**

View File

@ -144,11 +144,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 13th July, 2020
+ *Last Build*: 16th July, 2020
+ *Version*: 2.11.2
+ *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **282699**
+ *Line count*: **282693**
+ *Field count*: **1525**
+ *File count*: **1785**
+ *Folder count*: **295**

View File

@ -4141,10 +4141,6 @@ class Fields extends Structure
{
$xmlValue = 'JGLOBAL_TITLE';
}
elseif ($property['name'] === 'description')
{
$xmlValue = 'JFIELD_TITLE_DESC';
}
}
// only load value if found or is mandatory
if (ComponentbuilderHelper::checkString($xmlValue)

View File

@ -1853,7 +1853,7 @@ class Interpretation extends Fields
$method[] = $this->_t(1) . " * @param array \$credentials Array('name' => string, 'username' => string, 'email' => string, 'password' => string, 'password2' => string)";
$method[] = $this->_t(1) . " * @param int \$autologin";
$method[] = $this->_t(1) . " * @param array \$params Array('useractivation' => int, 'sendpassword' => int, 'allowUserRegistration' => int)";
$method[] = $this->_t(1) . " * @param array \$mode 1 = Site Registrations; 0 = Admin Registration";
$method[] = $this->_t(1) . " * @param array \$mode 1 = Site Registrations; 0 = Admin Registration; 2 = Custom Helper Method Called registerUser";
$method[] = $this->_t(1) . " *";
$method[] = $this->_t(1) . " * @return int|Error User ID on success, or an error.";
$method[] = $this->_t(1) . " */";
@ -1864,6 +1864,23 @@ class Interpretation extends Fields
$method[] = $this->_t(2) . "), \$mode = 1";
$method[] = $this->_t(1) . ")";
$method[] = $this->_t(1) . "{";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Override mode";
$method[] = $this->_t(2) . "if (\$mode == 2 && method_exists(__CLASS__, 'registerUser'))";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Update params";
$method[] = $this->_t(3) . "\$params['autologin'] = \$autologin;";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Now Register User";
$method[] = $this->_t(3) . "return self::registerUser(\$credentials, \$params);";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "elseif (\$mode == 2)";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Fallback to Site Registrations";
$method[] = $this->_t(3) . "\$mode = 1;";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " load the user component language files if there is an error.";
$method[] = $this->_t(2) . "\$lang = JFactory::getLanguage();";
@ -1882,7 +1899,7 @@ class Interpretation extends Fields
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Load the user site-registration model";
$method[] = $this->_t(3)
. "\$model = self::getModel('registration', JPATH_ROOT. '/components/com_users', 'Users');";
. "\$model = self::getModel('registration', \$base_dir . '/components/' . \$extension, 'Users');";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "else //" . $this->setLine(__LINE__)
. " 0 = Admin Registration";
@ -1890,7 +1907,7 @@ class Interpretation extends Fields
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Load the backend-user model";
$method[] = $this->_t(3)
. "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/com_users', 'Users');";
. "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/' . \$extension, 'Users');";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Check if we have params/config";
@ -1904,7 +1921,7 @@ class Interpretation extends Fields
$method[] = $this->_t(4) . "//" . $this->setLine(__LINE__)
. " If you know of a better path, let me know";
$method[] = $this->_t(4)
."\$params[\$param] = self::setParams('com_users', \$param, \$set);";
."\$params[\$param] = self::setParams(\$extension, \$param, \$set);";
$method[] = $this->_t(3) . "}";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
@ -1938,7 +1955,7 @@ class Interpretation extends Fields
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Check if password was set";
$method[] = $this->_t(2)
. "if (\$mode = 1 && (!isset(\$credentials['password']) || !isset(\$credentials['password2']) || !self::checkString(\$credentials['password']) || !self::checkString(\$credentials['password2'])))";
. "if (\$mode == 1 && (!isset(\$credentials['password']) || !isset(\$credentials['password2']) || !self::checkString(\$credentials['password']) || !self::checkString(\$credentials['password2'])))";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Set random password when empty password was submitted,";
@ -1953,11 +1970,13 @@ class Interpretation extends Fields
$method[] = $this->_t(2)
. "if (isset(\$credentials['password']) && isset(\$credentials['password2']) && self::checkString(\$credentials['password']) && self::checkString(\$credentials['password2']))";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "if (\$mode = 1)";
$method[] = $this->_t(3) . "if (\$mode == 1) //". $this->setLine(__LINE__)
. " 1 = Site-registration mode";
$method[] = $this->_t(3) . "{";
$method[] = $this->_t(4) . "\$data['password1'] = \$credentials['password'];";
$method[] = $this->_t(3) . "}";
$method[] = $this->_t(3) . "else";
$method[] = $this->_t(3) . "else //" . $this->setLine(__LINE__)
. " 0 = Admin-registration mode";
$method[] = $this->_t(3) . "{";
$method[] = $this->_t(4) . "\$data['password'] = \$credentials['password'];";
$method[] = $this->_t(3) . "}";
@ -1973,16 +1992,14 @@ class Interpretation extends Fields
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Create the new user";
$method[] = $this->_t(2) . "if (\$mode = 1)";
$method[] = $this->_t(2) . "if (\$mode == 1) //". $this->setLine(__LINE__)
. " 1 = Site-registration mode";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Site-registration mode";
$method[] = $this->_t(3) . "\$userId = \$model->register(\$data);";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "else";
$method[] = $this->_t(2) . "else //" . $this->setLine(__LINE__)
. " 0 = Admin-registration mode";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3) . "//" . $this->setLine(__LINE__)
. " Admin-registration mode";
$method[] = $this->_t(3) . "\$model->save(\$data);";
$method[] = $this->_t(3) . "\$userId = \$model->getState('user.id', 0);";
$method[] = $this->_t(2) . "}";
@ -1999,7 +2016,7 @@ class Interpretation extends Fields
$method[] = $this->_t(4) . "//" . $this->setLine(__LINE__)
. " If you know of a better path, let me know";
$method[] = $this->_t(4)
."self::setParams('com_users', \$param, \$set);";
."self::setParams(\$extension, \$param, \$set);";
$method[] = $this->_t(3) . "}";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
@ -2086,17 +2103,12 @@ class Interpretation extends Fields
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "// set username";
$method[] = $this->_t(2)
. "if (isset(\$new['username']) && self::checkString(\$new['username']))";
. "if (!isset(\$new['username']) || !self::checkString(\$new['username']))";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3)
. "\$new['username'] = self::safeString(\$new['username']);";
. "\$new['username'] = \$new['email'];";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "else";
$method[] = $this->_t(2) . "{";
$method[] = $this->_t(3)
. "\$new['username'] = self::safeString(\$new['name']);";
$method[] = $this->_t(2) . "}";
$method[] = $this->_t(2) . "// linup update user data";
$method[] = $this->_t(2) . "// lineup update user data";
$method[] = $this->_t(2) . "\$data = array(";
$method[] = $this->_t(3) . "'id' => \$new['id'],";
$method[] = $this->_t(3) . "'username' => \$new['username'],";
@ -16756,7 +16768,7 @@ class Interpretation extends Fields
$fix .= PHP_EOL . $this->_t(1) . "{";
$fix .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__)
. " check if the not_required field is set";
$fix .= PHP_EOL . $this->_t(2) . "if (" . $Component
$fix .= PHP_EOL . $this->_t(2) . "if (isset(\$data['not_required']) && " . $Component
. "Helper::checkString(\$data['not_required']))";
$fix .= PHP_EOL . $this->_t(2) . "{";
$fix .= PHP_EOL . $this->_t(3)

View File

@ -984,7 +984,7 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -526,7 +526,7 @@ class ComponentbuilderModelClass_method extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -517,7 +517,7 @@ class ComponentbuilderModelClass_property extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -519,7 +519,7 @@ class ComponentbuilderModelCustom_code extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -710,7 +710,7 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -603,7 +603,7 @@ class ComponentbuilderModelField extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -728,7 +728,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -90,7 +90,6 @@
type="component"
name="component"
label="COM_COMPONENTBUILDER_CUSTOM_CODE_COMPONENT_LABEL"
description="JFIELD_TITLE_DESC"
class="list_class"
multiple="false"
default="0"

View File

@ -90,7 +90,6 @@
type="joomlamodules"
name="joomla_module"
label="COM_COMPONENTBUILDER_JOOMLA_MODULE_FILES_FOLDERS_URLS_JOOMLA_MODULE_LABEL"
description="JFIELD_TITLE_DESC"
class="list_class span12"
multiple="false"
default="0"

View File

@ -90,7 +90,6 @@
type="joomlamodules"
name="joomla_module"
label="COM_COMPONENTBUILDER_JOOMLA_MODULE_UPDATES_JOOMLA_MODULE_LABEL"
description="JFIELD_TITLE_DESC"
class="list_class span12"
multiple="false"
default="0"

View File

@ -90,7 +90,6 @@
type="joomlaplugins"
name="joomla_plugin"
label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_FILES_FOLDERS_URLS_JOOMLA_PLUGIN_LABEL"
description="JFIELD_TITLE_DESC"
class="list_class span12"
multiple="false"
default="0"

View File

@ -90,7 +90,6 @@
type="joomlaplugins"
name="joomla_plugin"
label="COM_COMPONENTBUILDER_JOOMLA_PLUGIN_UPDATES_JOOMLA_PLUGIN_LABEL"
description="JFIELD_TITLE_DESC"
class="list_class span12"
multiple="false"
default="0"

View File

@ -92,7 +92,6 @@
label="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_SOURCE_LABEL"
rows="4"
cols="5"
description="JFIELD_TITLE_DESC"
message="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_SOURCE_MESSAGE"
class="text_area span12"
filter="safehtml"
@ -150,7 +149,7 @@
cols="20"
message="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_TRANSLATION_MESSAGE"
class="text_area translation_text_area"
filter="SAFEHTML"
filter="RAW"
hint="COM_COMPONENTBUILDER_LANGUAGE_TRANSLATION_TRANSLATION_HINT"
/>
<!-- Language Field. Type: Lang. (custom) -->

View File

@ -415,7 +415,7 @@ class ComponentbuilderModelHelp_document extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -878,7 +878,7 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -698,7 +698,7 @@ class ComponentbuilderModelJoomla_module extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -663,7 +663,7 @@ class ComponentbuilderModelJoomla_plugin extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -542,7 +542,7 @@ class ComponentbuilderModelLibrary extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -557,7 +557,7 @@ class ComponentbuilderModelServer extends JModelAdmin
public function validate($form, $data, $group = null)
{
// check if the not_required field is set
if (ComponentbuilderHelper::checkString($data['not_required']))
if (isset($data['not_required']) && ComponentbuilderHelper::checkString($data['not_required']))
{
$requiredFields = (array) explode(',',(string) $data['not_required']);
$requiredFields = array_unique($requiredFields);

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>13th July, 2020</creationDate>
<creationDate>16th July, 2020</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>