Resolved gh-323 so we can load fields only in the linked or admin list views or in both. Added the option to also add permission to access fields. Improved the checkArray method to return arry count value. Fixed issue in field permissions when the value is and array, field type can not be made hidden, but should instead just be removed. Fixed an issue in the code search methods to insure all areas are looked at, and search and export.

This commit is contained in:
2018-10-29 18:38:00 +02:00
parent 1e5fda0327
commit 6c4bab5ea9
58 changed files with 556 additions and 355 deletions

View File

@ -2713,7 +2713,7 @@ class Get
return $field['type_name'];
}
// check that we have the poperties
if (ComponentbuilderHelper::checkArray($field['settings']->properties))
if (isset($field['settings']) && ComponentbuilderHelper::checkObject($field['settings']) && isset($field['settings']->properties) && ComponentbuilderHelper::checkArray($field['settings']->properties))
{
// search for own custom fields
if (strpos($field['settings']->type_name, '@') !== false)
@ -4316,139 +4316,155 @@ class Get
$counter = 'a';
// Create a new query object.
$query = $this->db->getQuery(true);
// switch to onlu trigger the run of the query if we have tables to query
$runQuery = false;
foreach ($tables as $table)
{
if ($counter === 'a')
if (isset($table['table']))
{
// the main table fields
if (strpos($table['sourcemap'], PHP_EOL) !== false)
if ($counter === 'a')
{
$fields = explode(PHP_EOL, $table['sourcemap']);
if (ComponentbuilderHelper::checkArray($fields))
// the main table fields
if (strpos($table['sourcemap'], PHP_EOL) !== false)
{
// reset array buckets
$sourceArray = array();
$targetArray = array();
foreach ($fields as $field)
$fields = explode(PHP_EOL, $table['sourcemap']);
if (ComponentbuilderHelper::checkArray($fields))
{
if (strpos($field, "=>") !== false)
// reset array buckets
$sourceArray = array();
$targetArray = array();
foreach ($fields as $field)
{
list($source, $target) = explode("=>", $field);
$sourceArray[] = $counter . '.' . trim($source);
$targetArray[] = trim($target);
if (strpos($field, "=>") !== false)
{
list($source, $target) = explode("=>", $field);
$sourceArray[] = $counter . '.' . trim($source);
$targetArray[] = trim($target);
}
}
}
if (ComponentbuilderHelper::checkArray($sourceArray) && ComponentbuilderHelper::checkArray($targetArray))
{
// add to query
$query->select($this->db->quoteName($sourceArray, $targetArray));
$query->from('#__' . $table['table'] . ' AS a');
}
// we may need to filter the selection
if (isset($this->sqlTweak[$view_id]['where']))
{
// add to query the where filter
$query->where('a.id IN (' . $this->sqlTweak[$view_id]['where'] . ')');
}
}
}
}
else
{
// the other tables
if (strpos($table['sourcemap'], PHP_EOL) !== false)
{
$fields = explode(PHP_EOL, $table['sourcemap']);
if (ComponentbuilderHelper::checkArray($fields))
{
// reset array buckets
$sourceArray = array();
$targetArray = array();
foreach ($fields as $field)
{
if (strpos($field, "=>") !== false)
if (ComponentbuilderHelper::checkArray($sourceArray) && ComponentbuilderHelper::checkArray($targetArray))
{
list($source, $target) = explode("=>", $field);
$sourceArray[] = $counter . '.' . trim($source);
$targetArray[] = trim($target);
}
if (strpos($field, "==") !== false)
{
list($aKey, $bKey) = explode("==", $field);
// add to query
$query->join('LEFT', $this->db->quoteName('#__' . $table['table'], $counter) . ' ON (' . $this->db->quoteName('a.' . trim($aKey)) . ' = ' . $this->db->quoteName($counter . '.' . trim($bKey)) . ')');
$query->select($this->db->quoteName($sourceArray, $targetArray));
$query->from('#__' . $table['table'] . ' AS a');
$runQuery = true;
}
// we may need to filter the selection
if (isset($this->sqlTweak[$view_id]['where']))
{
// add to query the where filter
$query->where('a.id IN (' . $this->sqlTweak[$view_id]['where'] . ')');
}
}
if (ComponentbuilderHelper::checkArray($sourceArray) && ComponentbuilderHelper::checkArray($targetArray))
{
// add to query
$query->select($this->db->quoteName($sourceArray, $targetArray));
}
}
}
}
$counter++;
}
// now get the data
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the data
$data = $this->db->loadObjectList();
// start building the MySql dump
$dump = "--";
$dump .= PHP_EOL . "-- Dumping data for table `#__" . $this->bbb . "component" . $this->ddd . "_" . $view . "`";
$dump .= PHP_EOL . "--";
$dump .= PHP_EOL . PHP_EOL . "INSERT INTO `#__" . $this->bbb . "component" . $this->ddd . "_" . $view . "` (";
foreach ($data as $line)
{
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
{
if ($comaSet == 0)
{
$dump .= $this->db->quoteName($fieldName);
}
else
{
$dump .= ", " . $this->db->quoteName($fieldName);
}
$comaSet++;
}
break;
}
$dump .= ") VALUES";
$coma = 0;
foreach ($data as $line)
{
if ($coma == 0)
{
$dump .= PHP_EOL . "(";
}
else
{
$dump .= "," . PHP_EOL . "(";
}
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
{
if ($comaSet == 0)
// the other tables
if (strpos($table['sourcemap'], PHP_EOL) !== false)
{
$dump .= $this->mysql_escape($fieldValue);
$fields = explode(PHP_EOL, $table['sourcemap']);
if (ComponentbuilderHelper::checkArray($fields))
{
// reset array buckets
$sourceArray = array();
$targetArray = array();
foreach ($fields as $field)
{
if (strpos($field, "=>") !== false)
{
list($source, $target) = explode("=>", $field);
$sourceArray[] = $counter . '.' . trim($source);
$targetArray[] = trim($target);
}
if (strpos($field, "==") !== false)
{
list($aKey, $bKey) = explode("==", $field);
// add to query
$query->join('LEFT', $this->db->quoteName('#__' . $table['table'], $counter) . ' ON (' . $this->db->quoteName('a.' . trim($aKey)) . ' = ' . $this->db->quoteName($counter . '.' . trim($bKey)) . ')');
}
}
if (ComponentbuilderHelper::checkArray($sourceArray) && ComponentbuilderHelper::checkArray($targetArray))
{
// add to query
$query->select($this->db->quoteName($sourceArray, $targetArray));
}
}
}
}
$counter++;
}
else
{
// see where
// var_dump($view);
// jexit();
}
}
// check if we should run query
if ($runQuery)
{
// now get the data
$this->db->setQuery($query);
$this->db->execute();
if ($this->db->getNumRows())
{
// get the data
$data = $this->db->loadObjectList();
// start building the MySql dump
$dump = "--";
$dump .= PHP_EOL . "-- Dumping data for table `#__" . $this->bbb . "component" . $this->ddd . "_" . $view . "`";
$dump .= PHP_EOL . "--";
$dump .= PHP_EOL . PHP_EOL . "INSERT INTO `#__" . $this->bbb . "component" . $this->ddd . "_" . $view . "` (";
foreach ($data as $line)
{
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
{
if ($comaSet == 0)
{
$dump .= $this->db->quoteName($fieldName);
}
else
{
$dump .= ", " . $this->db->quoteName($fieldName);
}
$comaSet++;
}
break;
}
$dump .= ") VALUES";
$coma = 0;
foreach ($data as $line)
{
if ($coma == 0)
{
$dump .= PHP_EOL . "(";
}
else
{
$dump .= ", " . $this->mysql_escape($fieldValue);
$dump .= "," . PHP_EOL . "(";
}
$comaSet++;
$comaSet = 0;
foreach ($line as $fieldName => $fieldValue)
{
if ($comaSet == 0)
{
$dump .= $this->mysql_escape($fieldValue);
}
else
{
$dump .= ", " . $this->mysql_escape($fieldValue);
}
$comaSet++;
}
$dump .= ")";
$coma++;
}
$dump .= ")";
$coma++;
$dump .= ";";
// return build dump query
return $dump;
}
$dump .= ";";
// return build dump query
return $dump;
}
}
return false;

View File

@ -2107,6 +2107,8 @@ class Fields extends Structure
// setup a default field
if (ComponentbuilderHelper::checkArray($field['settings']->properties))
{
// we need a deeper php code search tracker
$phpTracker = array();
foreach ($field['settings']->properties as $property)
{
// reset
@ -2155,6 +2157,8 @@ class Fields extends Structure
$this->setDynamicValues(ComponentbuilderHelper::openValidBase64(
ComponentbuilderHelper::getBetween($field['settings']->xml, $property['name'] . '="', '"')
));
// load tracker
$phpTracker['type_' . $phpKey] = $phpKey;
}
elseif ($property['name'] === 'prime_php' && $setCustom)
{
@ -2338,6 +2342,24 @@ class Fields extends Structure
$fieldAttributes['default'] = $xmlValue;
}
}
// check if all php is loaded using the tracker
if (ComponentbuilderHelper::checkArray($phpTracker))
{
// litle search validation
$confirmation = '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB';
foreach ($phpTracker as $searchKey => $phpKey)
{
// we must search for more code in the xml just incase
foreach(range(2, 30) as $phpLine)
{
$get_ = $searchKey . '_' . $phpLine;
if (!isset($fieldAttributes['custom'][$phpKey][$phpLine]) && ($value = ComponentbuilderHelper::getValueFromXMLstring($field['settings']->xml, $get_, $confirmation)) !== $confirmation)
{
$fieldAttributes['custom'][$phpKey][$phpLine] = $this->setDynamicValues(ComponentbuilderHelper::openValidBase64($value));
}
}
}
}
// do some nice twigs beyond the default
if (isset($fieldAttributes['name']))
{
@ -2460,7 +2482,7 @@ class Fields extends Structure
}
}
// set list switch
$listSwitch = (isset($field['list']) && $field['list'] == 1);
$listSwitch = (isset($field['list']) && ($field['list'] == 1 || $field['list'] == 3 || $field['list'] == 4 ));
// set list join
$listJoin = (isset($this->listJoinBuilder[$view_name_list][(int) $field['field']]));
// add history to this view
@ -2523,7 +2545,8 @@ class Fields extends Structure
'sort' => (isset($field['sort']) && $field['sort']) ? true : false,
'custom' => $custom,
'multiple' => $multiple,
'options' => $options);
'options' => $options,
'target' => (int) $field['list']);
}
// build custom builder list
if ($listSwitch || $listJoin)

View File

@ -4554,6 +4554,9 @@ class Interpretation extends Fields
public function setMethodItemSave(&$view)
{
$script = '';
// get component name
$Component = $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh];
$component = $this->fileContentStatic[$this->hhh . 'component' . $this->hhh];
// check if there was script added before modeling of data
$script .= $this->getCustomScriptBuilder('php_before_save', $view, PHP_EOL . PHP_EOL);
// turn array into JSON string
@ -4568,7 +4571,22 @@ class Interpretation extends Fields
$script .= PHP_EOL . $this->_t(3) . "\$" . $jsonItem . "->loadArray(\$data['" . $jsonItem . "']);";
$script .= PHP_EOL . $this->_t(3) . "\$data['" . $jsonItem . "'] = (string) \$" . $jsonItem . ";";
$script .= PHP_EOL . $this->_t(2) . "}";
$script .= PHP_EOL . $this->_t(2) . "elseif (!isset(\$data['" . $jsonItem . "']))";
if (isset($this->permissionFields[$view]) && isset($this->permissionFields[$view][$jsonItem]) && ComponentbuilderHelper::checkArray($this->permissionFields[$view][$jsonItem]))
{
$script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Also check permission since the value may be removed due to permissions";
$script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Then we do not want to clear it out, but simple ignore the empty " . $jsonItem;
$script .= PHP_EOL . $this->_t(2) . "elseif (!isset(\$data['" . $jsonItem . "'])";
// only add permission that are available
foreach ($this->permissionFields[$view][$jsonItem] as $permission_option => $fieldType)
{
$script .= PHP_EOL . $this->_t(3) . "&& JFactory::getUser()->authorise('" . $view . "." . $permission_option . "." . $jsonItem . "', 'com_" . $component . "')";
}
$script .= ")";
}
else
{
$script .= PHP_EOL . $this->_t(2) . "elseif (!isset(\$data['" . $jsonItem . "']))";
}
$script .= PHP_EOL . $this->_t(2) . "{";
$script .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set the empty " . $jsonItem . " to data";
$script .= PHP_EOL . $this->_t(3) . "\$data['" . $jsonItem . "'] = '';";
@ -4600,7 +4618,6 @@ class Interpretation extends Fields
}
}
// turn string into encrypted string
$Component = $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh];
foreach ($this->cryptionTypes as $cryptionType)
{
if (isset($this->{$cryptionType . 'EncryptionBuilder'}[$view]) && ComponentbuilderHelper::checkArray($this->{$cryptionType . 'EncryptionBuilder'}[$view]))
@ -6759,25 +6776,29 @@ class Interpretation extends Fields
// start adding the dynamic
foreach ($this->listBuilder[$viewName_list] as $item)
{
// set some defaults
$customAdminViewButtons = '';
// set the item default class
$itemClass = 'hidden-phone';
// set the item row
$itemRow = $this->getListItemBuilder($item, $viewName_single, $viewName_list, $itemClass, $doNotEscape, $coreLoad, $core);
// check if buttons was aready added
if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :)
// check if target is admin list
if (1 == $item['target'] || 3 == $item['target'])
{
// get custom admin view buttons
$customAdminViewButtons = $this->getCustomAdminViewButtons($viewName_list);
// make sure the custom admin view buttons are only added once
$firstTimeBeingAdded = false;
// set some defaults
$customAdminViewButtons = '';
// set the item default class
$itemClass = 'hidden-phone';
// set the item row
$itemRow = $this->getListItemBuilder($item, $viewName_single, $viewName_list, $itemClass, $doNotEscape, $coreLoad, $core);
// check if buttons was aready added
if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :)
{
// get custom admin view buttons
$customAdminViewButtons = $this->getCustomAdminViewButtons($viewName_list);
// make sure the custom admin view buttons are only added once
$firstTimeBeingAdded = false;
}
// add row to body
$body .= PHP_EOL . $this->_t(2) . "<td class=\"" . $this->getListFieldClass($item['code'], $viewName_list, $itemClass) . "\">";
$body .= $itemRow;
$body .= $customAdminViewButtons;
$body .= PHP_EOL . $this->_t(2) . "</td>";
}
// add row to body
$body .= PHP_EOL . $this->_t(2) . "<td class=\"" . $this->getListFieldClass($item['code'], $viewName_list, $itemClass) . "\">";
$body .= $itemRow;
$body .= $customAdminViewButtons;
$body .= PHP_EOL . $this->_t(2) . "</td>";
}
// add the defaults
if (!isset($this->fieldsNames[$viewName_single]['published']))
@ -7253,30 +7274,34 @@ class Interpretation extends Fields
// build the dynamic fields
foreach ($this->listBuilder[$viewName_list] as $item)
{
// check if we have an over-ride
if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']]))
// check if target is admin list
if (1 == $item['target'] || 3 == $item['target'])
{
$item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']];
// check if we have an over-ride
if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']]))
{
$item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']];
}
// set the custom code
if (ComponentbuilderHelper::checkArray($item['custom']))
{
$item['code'] = $item['code'] . '_' . $item['custom']['text'];
}
$class = 'nowrap hidden-phone';
if ($item['link'])
{
$class = 'nowrap';
}
$title = "<?php echo JText:" . ":_('" . $item['lang'] . "'); ?>";
if ($item['sort'])
{
$title = "<?php echo JHtml::_('grid.sort', '" . $item['lang'] . "', '" . $item['code'] . "', \$this->listDirn, \$this->listOrder); ?>";
}
$head .= PHP_EOL . $this->_t(1) . '<th class="' . $class . '" >';
$head .= PHP_EOL . $this->_t(3) . $title;
$head .= PHP_EOL . $this->_t(1) . "</th>";
$this->listColnrBuilder[$viewName_list] ++;
}
// set the custom code
if (ComponentbuilderHelper::checkArray($item['custom']))
{
$item['code'] = $item['code'] . '_' . $item['custom']['text'];
}
$class = 'nowrap hidden-phone';
if ($item['link'])
{
$class = 'nowrap';
}
$title = "<?php echo JText:" . ":_('" . $item['lang'] . "'); ?>";
if ($item['sort'])
{
$title = "<?php echo JHtml::_('grid.sort', '" . $item['lang'] . "', '" . $item['code'] . "', \$this->listDirn, \$this->listOrder); ?>";
}
$head .= PHP_EOL . $this->_t(1) . '<th class="' . $class . '" >';
$head .= PHP_EOL . $this->_t(3) . $title;
$head .= PHP_EOL . $this->_t(1) . "</th>";
$this->listColnrBuilder[$viewName_list] ++;
}
// set default
if (!isset($this->fieldsNames[$viewName_single]['published']))
@ -8212,27 +8237,31 @@ class Interpretation extends Fields
// start adding the dynamic
foreach ($this->listBuilder[$viewName_list] as $item)
{
// set the ref
$ref = '<?php echo $ref; ?>';
// set some defaults
$customAdminViewButtons = '';
// set the item row
$itemRow = $this->getListItemBuilder($item, $viewName_single, $viewName_list, $itemClass, $doNotEscape, $coreLoad, $core, false, $ref, '$displayData->escape', '$user', $refview);
// check if buttons was aready added
if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :)
// check if target is linked list view
if (1 == $item['target'] || 4 == $item['target'])
{
// get custom admin view buttons
$customAdminViewButtons = $this->getCustomAdminViewButtons($viewName_list, $ref);
// make sure the custom admin view buttons are only added once
$firstTimeBeingAdded = false;
// set the ref
$ref = '<?php echo $ref; ?>';
// set some defaults
$customAdminViewButtons = '';
// set the item row
$itemRow = $this->getListItemBuilder($item, $viewName_single, $viewName_list, $itemClass, $doNotEscape, $coreLoad, $core, false, $ref, '$displayData->escape', '$user', $refview);
// check if buttons was aready added
if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :)
{
// get custom admin view buttons
$customAdminViewButtons = $this->getCustomAdminViewButtons($viewName_list, $ref);
// make sure the custom admin view buttons are only added once
$firstTimeBeingAdded = false;
}
// add row to body
$body .= PHP_EOL . $this->_t(2) . "<td>";
$body .= $itemRow;
$body .= $customAdminViewButtons;
$body .= PHP_EOL . $this->_t(2) . "</td>";
// increment counter
$counter++;
}
// add row to body
$body .= PHP_EOL . $this->_t(2) . "<td>";
$body .= $itemRow;
$body .= $customAdminViewButtons;
$body .= PHP_EOL . $this->_t(2) . "</td>";
// increment counter
$counter++;
}
$counter = $counter + 2;
$data_value = (3 == $this->footableVersion) ? 'data-sort-value' : 'data-value';
@ -8397,31 +8426,35 @@ class Interpretation extends Fields
// build the dynamic fields
foreach ($this->listBuilder[$viewName_list] as $item)
{
// check if we have an over-ride
if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']]))
// check if target is linked list view
if (1 == $item['target'] || 4 == $item['target'])
{
$item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']];
}
$setin = (2 == $this->footableVersion) ? ' data-hide="phone"' : ' data-breakpoints="xs sm"';
if ($controller > 3)
{
$setin = (2 == $this->footableVersion) ? ' data-hide="phone,tablet"' : ' data-breakpoints="xs sm md"';
}
// check if we have an over-ride
if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']]))
{
$item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']];
}
$setin = (2 == $this->footableVersion) ? ' data-hide="phone"' : ' data-breakpoints="xs sm"';
if ($controller > 3)
{
$setin = (2 == $this->footableVersion) ? ' data-hide="phone,tablet"' : ' data-breakpoints="xs sm md"';
}
if ($controller > 6)
{
$setin = (2 == $this->footableVersion) ? ' data-hide="all"' : ' data-breakpoints="all"';
}
if ($controller > 6)
{
$setin = (2 == $this->footableVersion) ? ' data-hide="all"' : ' data-breakpoints="all"';
}
if ($item['link'] && $firstLink)
{
$setin = (2 == $this->footableVersion) ? ' data-toggle="true"' : '';
$firstLink = false;
if ($item['link'] && $firstLink)
{
$setin = (2 == $this->footableVersion) ? ' data-toggle="true"' : '';
$firstLink = false;
}
$head .= PHP_EOL . $this->_t(2) . "<th" . $setin . $htmlFix . ">";
$head .= PHP_EOL . $this->_t(3) . "<?php echo JText:" . ":_('" . $item['lang'] . "'); ?>";
$head .= PHP_EOL . $this->_t(2) . "</th>";
$controller++;
}
$head .= PHP_EOL . $this->_t(2) . "<th" . $setin . $htmlFix . ">";
$head .= PHP_EOL . $this->_t(3) . "<?php echo JText:" . ":_('" . $item['lang'] . "'); ?>";
$head .= PHP_EOL . $this->_t(2) . "</th>";
$controller++;
}
// set some V3 attr
$data_hide = (2 == $this->footableVersion) ? 'data-hide="phone,tablet"' : 'data-breakpoints="xs sm md"';
@ -11284,6 +11317,19 @@ class Interpretation extends Fields
$allow[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " Disable fields while saving.";
$allow[] = $this->_t(3) . "\$form->setFieldAttribute('created', 'filter', 'unset');";
$allow[] = $this->_t(2) . "}";
// check if the item has access permissions.
if ($coreLoad && isset($core['core.edit.access']) && isset($this->permissionBuilder[$core['core.edit.access']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder[$core['core.edit.access']]) && in_array($viewName_single, $this->permissionBuilder[$core['core.edit.access']]))
{
$allow[] = $this->_t(2) . "//" . $this->setLine(__LINE__) . " Modify the form based on Edit Access 'access' controls.";
$allow[] = $this->_t(2) . "if (\$id != 0 && (!\$user->authorise('" . $core['core.edit.access'] . "', 'com_" . $component . "." . $viewName_single . ".' . (int) \$id))";
$allow[] = $this->_t(3) . "|| (\$id == 0 && !\$user->authorise('" . $core['core.edit.access'] . "', 'com_" . $component . "')))";
$allow[] = $this->_t(2) . "{";
$allow[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " Disable fields for display.";
$allow[] = $this->_t(3) . "\$form->setFieldAttribute('access', 'disabled', 'true');";
$allow[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " Disable fields while saving.";
$allow[] = $this->_t(3) . "\$form->setFieldAttribute('access', 'filter', 'unset');";
$allow[] = $this->_t(2) . "}";
}
// handel the fields permissions
if (isset($this->permissionFields[$viewName_single]) && ComponentbuilderHelper::checkArray($this->permissionFields[$viewName_single]))
{
@ -11382,12 +11428,21 @@ class Interpretation extends Fields
$allow[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " Make the field hidded.";
$allow[] = $this->_t(3) . "\$form->setFieldAttribute('" . $fieldName . "', 'type', 'hidden');";
$allow[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " If there is no value continue.";
$allow[] = $this->_t(3) . "if (!\$form->getValue('" . $fieldName . "'))";
$allow[] = $this->_t(3) . "if (!(\$val = \$form->getValue('" . $fieldName . "')))";
$allow[] = $this->_t(3) . "{";
$allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Disable fields while saving.";
$allow[] = $this->_t(4) . "\$form->setFieldAttribute('" . $fieldName . "', 'filter', 'unset');";
$allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Disable fields while saving.";
$allow[] = $this->_t(4) . "\$form->setFieldAttribute('" . $fieldName . "', 'required', 'false');";
$allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Make sure";
$allow[] = $this->_t(4) . "\$form->setValue('" . $fieldName . "', null, '');";
$allow[] = $this->_t(3) . "}";
$allow[] = $this->_t(3) . "elseif (" . ucfirst($component) . "Helper::checkArray(\$val))";
$allow[] = $this->_t(3) . "{";
$allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " We have to unset then (TODO)";
$allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Hiddend field can not handel array value";
$allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Even if we conver to json we get an error";
$allow[] = $this->_t(4) . "\$form->removeField('" . $fieldName . "');";
$allow[] = $this->_t(3) . "}";
$allow[] = $this->_t(2) . "}";
}
@ -12336,6 +12391,8 @@ class Interpretation extends Fields
// JSON_ARRAY_ENCODE
$decode = 'json_decode';
$suffix_decode = ', true';
// fallback on json
$item['method'] = 1;
break;
}
@ -12486,7 +12543,7 @@ class Interpretation extends Fields
{
if (!$export)
{
// For thos we have not cached yet.
// For those we have not cached yet.
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " convert " . $item['name'];
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$item->" . $item['name'] . " = " . $Component . "Helper::jsonToString(\$item->" . $item['name'] . ");";
}
@ -15469,7 +15526,7 @@ function vdm_dkim() {
// set the permission for this field
$fieldView['action'] = 'view.' . $permission_option . '.' . $fieldName;
$fieldView['implementation'] = '3';
// check if persmissions was laready set
// check if persmissions was already set
if (isset($view['settings']->permissions) && ComponentbuilderHelper::checkArray($view['settings']->permissions))
{
array_push($view['settings']->permissions, $fieldView);
@ -15600,6 +15657,7 @@ function vdm_dkim() {
$view['settings']->permissions[] = $versionView;
}
}
// add batch permissions
if ($type === 'admin')
{
// set batch control
@ -15615,6 +15673,7 @@ function vdm_dkim() {
$view['settings']->permissions[] = $batchView;
}
}
// load the permissions
foreach ($view['settings']->permissions as $permission)
{
// set acction name
@ -15639,6 +15698,12 @@ function vdm_dkim() {
array_shift($actionNameBuilder);
$nameBuilder = trim(implode('___', $actionNameBuilder));
$customName = trim(implode(' ', $actionNameBuilder));
// check if we have access set for this view (if not skip)
if ($nameBuilder === 'edit___access' && $type === 'admin' && (!isset($view['access']) || $view['access'] != 1))
{
continue;
}
// build the names
if ($type === 'admin')
{
$W_NameList = ComponentbuilderHelper::safeString($view['settings']->name_list, 'W');
@ -15666,6 +15731,12 @@ function vdm_dkim() {
// set edit description
$permission['description'] = ' Allows the users in this group to edit ' . $w_NameList . ' created by them';
break;
case 'edit___access':
// set edit title
$permission['title'] = $W_NameList . ' Edit Access';
// set edit description
$permission['description'] = ' Allows the users in this group to change the access of the ' . $w_NameList;
break;
case 'edit___state':
// set edit title
$permission['title'] = $W_NameList . ' Edit State';

View File

@ -686,6 +686,8 @@ abstract class ComponentbuilderHelper
'description' => $result->description);
// number pointer
$nr = 0;
// php tracker (we must try to load alteast 17 rows
$phpTracker = array();
// value to check since there are false and null values even 0 in the values returned
$confirmation = '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB';
// set the headers
@ -701,6 +703,9 @@ abstract class ComponentbuilderHelper
if (strpos($property['name'], 'type_php') !== false)
{
$addPHP = true;
// set the line number
$phpLine = (int) preg_replace('/[^0-9]/', '', $property['name']);
// set the key
$phpKey = trim(preg_replace('/[0-9]+/', '', $property['name']), '_');
// start array if not already set
if (!isset($field['php'][$phpKey]))
@ -708,6 +713,8 @@ abstract class ComponentbuilderHelper
$field['php'][$phpKey] = array();
$field['php'][$phpKey]['value'] = array();
$field['php'][$phpKey]['desc'] = $property['description'];
// start tracker
$phpTracker[$phpKey] = 1;
}
}
// was the settings for the property passed
@ -718,7 +725,8 @@ abstract class ComponentbuilderHelper
// add the json values
if ($addPHP)
{
$field['php'][$phpKey]['value'][] = $settings[$property['name']];
$field['php'][$phpKey]['value'][$phpLine] = $settings[$property['name']];
$phpTracker[$phpKey]++;
}
else
{
@ -732,7 +740,8 @@ abstract class ComponentbuilderHelper
// add the json values
if ($addPHP)
{
$field['php'][$phpKey]['value'][] = ($confirmation !== $value) ? $value : $example;
$field['php'][$phpKey]['value'][$phpLine] = ($confirmation !== $value) ? $value : $example;
$phpTracker[$phpKey]++;
}
else
{
@ -747,6 +756,25 @@ abstract class ComponentbuilderHelper
// increment the number
$nr++;
}
// check if all php is loaded using the tracker
if (self::checkString($xml) && isset($phpTracker) && self::checkArray($phpTracker))
{
foreach ($phpTracker as $phpKey => $start)
{
if ($start < 30)
{
// we must search for more code in the xml just incase
foreach(range(2, 30) as $t_nr)
{
$get_ = $phpKey . '_' . $t_nr;
if (!isset($field['php'][$phpKey]['value'][$t_nr]) && ($value = self::getValueFromXMLstring($xml, $get_, $confirmation)) !== $confirmation)
{
$field['php'][$phpKey]['value'][$t_nr] = $value;
}
}
}
}
}
$field['values'] .= PHP_EOL . "/>";
$field['values_description'] .= '</tbody></table>';
// return found field options
@ -5192,11 +5220,11 @@ abstract class ComponentbuilderHelper
*
* @input array The array to check
*
* @returns bool true on success
* @returns bool/int number of items in array on success
**/
public static function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && count((array)$array) > 0)
if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
@ -5210,7 +5238,7 @@ abstract class ComponentbuilderHelper
}
return self::checkArray($array, false);
}
return true;
return $nr;
}
return false;
}