Fixed GUID duplication issue.
This commit is contained in:
parent
eda4d594d6
commit
5f1d17bfb3
@ -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*: 22nd May, 2020
|
||||
+ *Last Build*: 25th May, 2020
|
||||
+ *Version*: 2.11.1
|
||||
+ *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*: **281750**
|
||||
+ *Line count*: **281857**
|
||||
+ *Field count*: **1522**
|
||||
+ *File count*: **1783**
|
||||
+ *Folder count*: **295**
|
||||
|
@ -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*: 22nd May, 2020
|
||||
+ *Last Build*: 25th May, 2020
|
||||
+ *Version*: 2.11.1
|
||||
+ *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*: **281750**
|
||||
+ *Line count*: **281857**
|
||||
+ *Field count*: **1522**
|
||||
+ *File count*: **1783**
|
||||
+ *Folder count*: **295**
|
||||
|
@ -9149,6 +9149,8 @@ class Get
|
||||
// set some placeholder for this plugin
|
||||
$this->placeholders[$this->bbb . 'Plugin_name' . $this->ddd]
|
||||
= $plugin->official_name;
|
||||
$this->placeholders[$this->hhh . 'PLUGIN_NAME' . $this->hhh]
|
||||
= $plugin->official_name;
|
||||
$this->placeholders[$this->bbb . 'Plugin' . $this->ddd]
|
||||
= ucfirst(
|
||||
$plugin->code_name
|
||||
@ -9167,11 +9169,15 @@ class Get
|
||||
);
|
||||
$this->placeholders[$this->bbb . 'plugin.version' . $this->ddd]
|
||||
= $plugin->plugin_version;
|
||||
$this->placeholders[$this->hhh . 'VERSION' . $this->hhh]
|
||||
= $plugin->plugin_version;
|
||||
$this->placeholders[$this->bbb . 'plugin_version' . $this->ddd]
|
||||
= str_replace(
|
||||
'.', '_', $plugin->plugin_version
|
||||
);
|
||||
// set description (TODO) add description field to plugin
|
||||
// set description
|
||||
$this->placeholders[$this->hhh . 'DESCRIPTION' . $this->hhh]
|
||||
= '';
|
||||
if (!isset($plugin->description)
|
||||
|| !ComponentbuilderHelper::checkString(
|
||||
$plugin->description
|
||||
@ -9189,6 +9195,9 @@ class Get
|
||||
$plugin->key, $plugin->lang_prefix . '_DESCRIPTION',
|
||||
$plugin->description
|
||||
);
|
||||
// set description
|
||||
$this->placeholders[$this->hhh . 'DESCRIPTION' . $this->hhh]
|
||||
= $plugin->description;
|
||||
$plugin->description = '<p>' . $plugin->description
|
||||
. '</p>';
|
||||
}
|
||||
@ -9672,6 +9681,15 @@ class Get
|
||||
$this->placeholders[$this->bbb . 'plugin_version'
|
||||
. $this->ddd]
|
||||
);
|
||||
unset(
|
||||
$this->placeholders[$this->hhh . 'VERSION'
|
||||
. $this->hhh]);
|
||||
unset(
|
||||
$this->placeholders[$this->hhh . 'DESCRIPTION'
|
||||
. $this->hhh]);
|
||||
unset(
|
||||
$this->placeholders[$this->hhh . 'PLUGIN_NAME'
|
||||
. $this->hhh]);
|
||||
|
||||
$this->joomlaPlugins[$id] = $plugin;
|
||||
|
||||
|
@ -95,6 +95,13 @@ class Fields extends Structure
|
||||
*/
|
||||
public $dbUniqueKeys = array();
|
||||
|
||||
/**
|
||||
* unique guid swtich
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $dbUniqueGuid = array();
|
||||
|
||||
/**
|
||||
* keys for database field
|
||||
*
|
||||
@ -3850,6 +3857,7 @@ class Fields extends Structure
|
||||
$this->queryBuilder[$view_name_single][$name]['null_switch']
|
||||
= $field['settings']->null_switch;
|
||||
// set index types
|
||||
$_guid = true;
|
||||
if ($field['settings']->indexes == 1
|
||||
&& !in_array(
|
||||
$field['settings']->datatype, $textKeys
|
||||
@ -3857,6 +3865,11 @@ class Fields extends Structure
|
||||
{
|
||||
// build unique keys of this view for db
|
||||
$this->dbUniqueKeys[$view_name_single][] = $name;
|
||||
// prevent guid from being added twice
|
||||
if ('guid' === $name)
|
||||
{
|
||||
$_guid = false;
|
||||
}
|
||||
}
|
||||
elseif (($field['settings']->indexes == 2
|
||||
|| (isset($field['alias'])
|
||||
@ -3868,6 +3881,11 @@ class Fields extends Structure
|
||||
// build keys of this view for db
|
||||
$this->dbKeys[$view_name_single][] = $name;
|
||||
}
|
||||
// special treatment for GUID
|
||||
if ('guid' === $name && $_guid)
|
||||
{
|
||||
$this->dbUniqueGuid[$view_name_single] = true;
|
||||
}
|
||||
}
|
||||
// set list switch
|
||||
$listSwitch = (isset($field['list'])
|
||||
|
@ -17163,11 +17163,26 @@ class Interpretation extends Fields
|
||||
$fields[] = $this->_t(1) . "{";
|
||||
if (isset($this->dbUniqueKeys[$view])
|
||||
&& ComponentbuilderHelper::checkArray($this->dbUniqueKeys[$view]))
|
||||
{
|
||||
// if guid should also be added
|
||||
if (isset($this->dbUniqueGuid[$view]))
|
||||
{
|
||||
$fields[] = $this->_t(2) . "return array('" . implode(
|
||||
"','", $this->dbUniqueKeys[$view]
|
||||
) . "', 'guid');";
|
||||
}
|
||||
else
|
||||
{
|
||||
$fields[] = $this->_t(2) . "return array('" . implode(
|
||||
"','", $this->dbUniqueKeys[$view]
|
||||
) . "');";
|
||||
}
|
||||
}
|
||||
// if only GUID is found
|
||||
elseif (isset($this->dbUniqueGuid[$view]))
|
||||
{
|
||||
$fields[] = $this->_t(2) . "return array('guid');";
|
||||
}
|
||||
else
|
||||
{
|
||||
$fields[] = $this->_t(2) . "return false;";
|
||||
|
@ -2070,6 +2070,49 @@ abstract class ComponentbuilderHelper
|
||||
return $guidv4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the Globally Unique Identifier ( and check if table already has this identifier)
|
||||
*
|
||||
* @param string $guid
|
||||
* @param string $table
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public static function validGUID ($guid, $table = null, $id = 0)
|
||||
{
|
||||
// check if we have a string
|
||||
if (self::validateGUID($guid))
|
||||
{
|
||||
// check if table already has this identifier
|
||||
if (self::checkString($table))
|
||||
{
|
||||
// Get the database object and a new query object.
|
||||
$db = \JFactory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('COUNT(*)')
|
||||
->from('#__componentbuilder_' . (string) $table)
|
||||
->where($db->quoteName('guid') . ' = ' . $db->quote($guid));
|
||||
|
||||
// remove this item from the list
|
||||
if ($id > 0)
|
||||
{
|
||||
$query->where($db->quoteName('id') . ' <> ' . (int) $id);
|
||||
}
|
||||
|
||||
// Set and query the database.
|
||||
$db->setQuery($query);
|
||||
$duplicate = (bool) $db->loadResult();
|
||||
|
||||
if ($duplicate)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the Globally Unique Identifier
|
||||
*
|
||||
@ -2079,7 +2122,7 @@ abstract class ComponentbuilderHelper
|
||||
* @param string $guid
|
||||
* @return bool
|
||||
*/
|
||||
public static function validGUID ($guid)
|
||||
protected static function validateGUID ($guid)
|
||||
{
|
||||
// check if we have a string
|
||||
if (self::checkString($guid))
|
||||
|
@ -1491,7 +1491,7 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin
|
||||
}
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "admin_view", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -972,7 +972,7 @@ class ComponentbuilderModelClass_method extends JModelAdmin
|
||||
$data['name'] = ComponentbuilderHelper::safeClassFunctionName($data['name']);
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "class_method", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -963,7 +963,7 @@ class ComponentbuilderModelClass_property extends JModelAdmin
|
||||
$data['name'] = ComponentbuilderHelper::safeClassFunctionName($data['name']);
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "class_property", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -1125,7 +1125,7 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin
|
||||
}
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "custom_admin_view", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -1148,7 +1148,7 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin
|
||||
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "dynamic_get", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -1144,7 +1144,7 @@ class ComponentbuilderModelField extends JModelAdmin
|
||||
}
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "field", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -1197,7 +1197,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin
|
||||
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "fieldtype", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -1385,7 +1385,7 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin
|
||||
}
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "joomla_component", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -1199,7 +1199,7 @@ class ComponentbuilderModelJoomla_module extends JModelAdmin
|
||||
}
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "joomla_module", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -1162,7 +1162,7 @@ class ComponentbuilderModelJoomla_plugin extends JModelAdmin
|
||||
}
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "joomla_plugin", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -1048,7 +1048,7 @@ class ComponentbuilderModelLibrary extends JModelAdmin
|
||||
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "library", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -1146,7 +1146,7 @@ class ComponentbuilderModelSite_view extends JModelAdmin
|
||||
}
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "site_view", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -852,7 +852,7 @@ class ComponentbuilderModelSnippet extends JModelAdmin
|
||||
}
|
||||
|
||||
// Set the GUID if empty or not valid
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid']))
|
||||
if (isset($data['guid']) && !ComponentbuilderHelper::validGUID($data['guid'], "snippet", $data['id']))
|
||||
{
|
||||
$data['guid'] = (string) ComponentbuilderHelper::GUID();
|
||||
}
|
||||
|
@ -100,7 +100,6 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_joomla_component` (
|
||||
`metadesc` TEXT NOT NULL,
|
||||
`metadata` TEXT NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_system_name` (`system_name`),
|
||||
KEY `idx_name_code` (`name_code`),
|
||||
KEY `idx_add_php_helper_admin` (`add_php_helper_admin`),
|
||||
@ -135,6 +134,7 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_joomla_component` (
|
||||
KEY `idx_update_server_target` (`update_server_target`),
|
||||
KEY `idx_creatuserhelper` (`creatuserhelper`),
|
||||
KEY `idx_adduikit` (`adduikit`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
KEY `idx_createdby` (`created_by`),
|
||||
@ -200,7 +200,6 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_joomla_module` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_system_name` (`system_name`),
|
||||
KEY `idx_add_php_method_uninstall` (`add_php_method_uninstall`),
|
||||
KEY `idx_add_php_postflight_update` (`add_php_postflight_update`),
|
||||
@ -215,6 +214,7 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_joomla_module` (
|
||||
KEY `idx_add_php_preflight_install` (`add_php_preflight_install`),
|
||||
KEY `idx_add_sales_server` (`add_sales_server`),
|
||||
KEY `idx_add_php_preflight_update` (`add_php_preflight_update`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
@ -278,7 +278,6 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_joomla_plugin` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_system_name` (`system_name`),
|
||||
KEY `idx_class_extends` (`class_extends`),
|
||||
KEY `idx_joomla_plugin_group` (`joomla_plugin_group`),
|
||||
@ -295,6 +294,7 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_joomla_plugin` (
|
||||
KEY `idx_add_php_preflight_update` (`add_php_preflight_update`),
|
||||
KEY `idx_add_php_preflight_uninstall` (`add_php_preflight_uninstall`),
|
||||
KEY `idx_add_sales_server` (`add_sales_server`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
@ -410,7 +410,6 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_admin_view` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name_single` (`name_single`),
|
||||
KEY `idx_name_list` (`name_list`),
|
||||
KEY `idx_add_fadein` (`add_fadein`),
|
||||
@ -449,6 +448,7 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_admin_view` (
|
||||
KEY `idx_add_custom_import` (`add_custom_import`),
|
||||
KEY `idx_add_php_getitems` (`add_php_getitems`),
|
||||
KEY `idx_add_php_getitems_after_all` (`add_php_getitems_after_all`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
KEY `idx_createdby` (`created_by`),
|
||||
@ -508,7 +508,6 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_custom_admin_view` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_main_get` (`main_get`),
|
||||
KEY `idx_add_php_jview_display` (`add_php_jview_display`),
|
||||
@ -524,6 +523,7 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_custom_admin_view` (
|
||||
KEY `idx_add_php_ajax` (`add_php_ajax`),
|
||||
KEY `idx_dynamic_get` (`dynamic_get`),
|
||||
KEY `idx_add_custom_button` (`add_custom_button`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
KEY `idx_createdby` (`created_by`),
|
||||
@ -583,7 +583,6 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_site_view` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_main_get` (`main_get`),
|
||||
KEY `idx_add_php_jview_display` (`add_php_jview_display`),
|
||||
@ -600,6 +599,7 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_site_view` (
|
||||
KEY `idx_add_php_ajax` (`add_php_ajax`),
|
||||
KEY `idx_add_custom_button` (`add_custom_button`),
|
||||
KEY `idx_button_position` (`button_position`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
KEY `idx_createdby` (`created_by`),
|
||||
@ -729,7 +729,6 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_dynamic_get` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_main_source` (`main_source`),
|
||||
KEY `idx_gettype` (`gettype`),
|
||||
@ -742,6 +741,7 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_dynamic_get` (
|
||||
KEY `idx_add_php_before_getitems` (`add_php_before_getitems`),
|
||||
KEY `idx_add_php_after_getitems` (`add_php_after_getitems`),
|
||||
KEY `idx_add_php_router_parse` (`add_php_router_parse`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
KEY `idx_createdby` (`created_by`),
|
||||
@ -813,9 +813,9 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_class_property` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_visibility` (`visibility`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_joomla_plugin_group` (`joomla_plugin_group`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
@ -848,9 +848,9 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_class_method` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_visibility` (`visibility`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_joomla_plugin_group` (`joomla_plugin_group`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
@ -910,9 +910,9 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_library` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_how` (`how`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
KEY `idx_createdby` (`created_by`),
|
||||
@ -949,10 +949,10 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_snippet` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_type` (`type`),
|
||||
KEY `idx_library` (`library`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
KEY `idx_createdby` (`created_by`),
|
||||
@ -1029,7 +1029,6 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_field` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_fieldtype` (`fieldtype`),
|
||||
KEY `idx_datatype` (`datatype`),
|
||||
@ -1044,6 +1043,7 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_field` (
|
||||
KEY `idx_add_css_views` (`add_css_views`),
|
||||
KEY `idx_add_javascript_view_footer` (`add_javascript_view_footer`),
|
||||
KEY `idx_add_javascript_views_footer` (`add_javascript_views_footer`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
KEY `idx_createdby` (`created_by`),
|
||||
@ -1082,7 +1082,6 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_fieldtype` (
|
||||
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_guid` (`guid`),
|
||||
KEY `idx_name` (`name`),
|
||||
KEY `idx_null_switch` (`null_switch`),
|
||||
KEY `idx_indexes` (`indexes`),
|
||||
@ -1092,6 +1091,7 @@ CREATE TABLE IF NOT EXISTS `#__componentbuilder_fieldtype` (
|
||||
KEY `idx_datatype` (`datatype`),
|
||||
KEY `idx_has_defaults` (`has_defaults`),
|
||||
KEY `idx_datalenght` (`datalenght`),
|
||||
KEY `idx_guid` (`guid`),
|
||||
KEY `idx_catid` (`catid`),
|
||||
KEY `idx_access` (`access`),
|
||||
KEY `idx_checkout` (`checked_out`),
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="3.2" method="upgrade">
|
||||
<name>COM_COMPONENTBUILDER</name>
|
||||
<creationDate>22nd May, 2020</creationDate>
|
||||
<creationDate>25th May, 2020</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
|
||||
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>
|
||||
|
33
script.php
33
script.php
@ -8973,9 +8973,11 @@ class com_componentbuilderInstallerScript
|
||||
}
|
||||
}
|
||||
}
|
||||
// target version less then 2.11.0
|
||||
if (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && $this->JCBversion[1] < 11)
|
||||
// target version less then or equal to 2.11.1
|
||||
if (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && ($this->JCBversion[1] < 11 || ($this->JCBversion[1] == 11 && $this->JCBversion[2] <= 1)))
|
||||
{
|
||||
// keep track of used
|
||||
$usedGUID = array();
|
||||
/**
|
||||
* Returns a GUIDv4 string
|
||||
*
|
||||
@ -9037,7 +9039,7 @@ class com_componentbuilderInstallerScript
|
||||
* @param string $guid
|
||||
* @return bool
|
||||
*/
|
||||
function validGUID ($guid)
|
||||
function validateGUID ($guid)
|
||||
{
|
||||
// check if we have a string
|
||||
if (ComponentbuilderHelper::checkString($guid))
|
||||
@ -9047,6 +9049,23 @@ class com_componentbuilderInstallerScript
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the Globally Unique Identifier
|
||||
*
|
||||
* @param string $guid
|
||||
* @return bool
|
||||
*/
|
||||
function validGUID ($guid, &$usedGUID)
|
||||
{
|
||||
// check if we have a string
|
||||
if (validateGUID($guid) && !isset($usedGUID[$guid]))
|
||||
{
|
||||
$usedGUID[$guid] = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// we must update all GUID's for future use :)
|
||||
$guid_tables = array(
|
||||
'joomla_component',
|
||||
@ -9077,10 +9096,14 @@ class com_componentbuilderInstallerScript
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
// keep track of used
|
||||
$usedGUID = array();
|
||||
// get the rows
|
||||
$rows = $db->loadObjectList();
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
if (!validGUID($row->guid))
|
||||
// load value not to use it again
|
||||
if (!validGUID($row->guid, $usedGUID))
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
@ -9100,8 +9123,6 @@ class com_componentbuilderInstallerScript
|
||||
}
|
||||
}
|
||||
}
|
||||
// set a notice that this was done
|
||||
$app->enqueueMessage('<p>Globally Unique Identifier <b>GUID</b> was added to <b>various tables</b> in JCB, thanks to <strong><a href="https://vdm.bz/get-jcb-pro-membership" target="_blank">PRO members</a></strong> contribution!</p>', 'Notice');
|
||||
}
|
||||
// check if this install has the libraries in the helper folder, if so remove it
|
||||
$vendorPath = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/vendor';
|
||||
|
@ -2067,6 +2067,49 @@ abstract class ComponentbuilderHelper
|
||||
return $guidv4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the Globally Unique Identifier ( and check if table already has this identifier)
|
||||
*
|
||||
* @param string $guid
|
||||
* @param string $table
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public static function validGUID ($guid, $table = null, $id = 0)
|
||||
{
|
||||
// check if we have a string
|
||||
if (self::validateGUID($guid))
|
||||
{
|
||||
// check if table already has this identifier
|
||||
if (self::checkString($table))
|
||||
{
|
||||
// Get the database object and a new query object.
|
||||
$db = \JFactory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$query->select('COUNT(*)')
|
||||
->from('#__componentbuilder_' . (string) $table)
|
||||
->where($db->quoteName('guid') . ' = ' . $db->quote($guid));
|
||||
|
||||
// remove this item from the list
|
||||
if ($id > 0)
|
||||
{
|
||||
$query->where($db->quoteName('id') . ' <> ' . (int) $id);
|
||||
}
|
||||
|
||||
// Set and query the database.
|
||||
$db->setQuery($query);
|
||||
$duplicate = (bool) $db->loadResult();
|
||||
|
||||
if ($duplicate)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the Globally Unique Identifier
|
||||
*
|
||||
@ -2076,7 +2119,7 @@ abstract class ComponentbuilderHelper
|
||||
* @param string $guid
|
||||
* @return bool
|
||||
*/
|
||||
public static function validGUID ($guid)
|
||||
protected static function validateGUID ($guid)
|
||||
{
|
||||
// check if we have a string
|
||||
if (self::checkString($guid))
|
||||
|
Loading…
Reference in New Issue
Block a user