Skip to content

Commit

Permalink
Merge pull request #200 from techjoomla/release-1.2.1
Browse files Browse the repository at this point in the history
Release 1.2.1
  • Loading branch information
ankush-maherwal authored Oct 4, 2019
2 parents ce0f9f6 + 54295f5 commit 572566f
Show file tree
Hide file tree
Showing 32 changed files with 2,919 additions and 624 deletions.
1,079 changes: 1,079 additions & 0 deletions src/components/com_tjucm/administrator/assets/js/itemform.js

Large diffs are not rendered by default.

This file was deleted.

13 changes: 6 additions & 7 deletions src/components/com_tjucm/administrator/controllers/types.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,23 +310,21 @@ public function import()
{
foreach ($fields as $field)
{
$input->post->set('tjfields', '');
$fieldOptions = array();
$options = $field->options;

// Format options data
if (!empty($options))
{
$optionCount = 0;

foreach ($options as &$option)
{
$option = (array) $option;
$option['optionname'] = $option['options'];
$option['optionvalue'] = $option['value'];
$fieldOptions['fieldoption'.$optionCount] = array("name" => $option->options, "value" => $option->value);
$optionCount++;
}

$input->post->set('tjfields', $options);
}

unset($field->options);
$field = (array) $field;

// Cleaning Field data
Expand All @@ -340,6 +338,7 @@ public function import()
$field['params'] = (array) json_decode($field['params']);
$tmpName = str_replace('.', '_', $ucmTypeData['unique_identifier']) . '_';
$field['name'] = str_replace($tmpName, '', $field['name']);
$field['fieldoption'] = $fieldOptions;

// Special case - Do not insert field with name 'contentid' as this will be added when ucm type for ucmsubform is created
if ($field['name'] == 'contentid')
Expand Down
4 changes: 3 additions & 1 deletion src/components/com_tjucm/administrator/models/forms/type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field name="allowed_count" type="number" label="COM_TJUCM_FORM_LBL_TYPE_ALLOWED_COUNT" description="COM_TJUCM_FORM_DESC_TYPE_ALLOWED_COUNT" hint="COM_TJUCM_FORM_LBL_TYPE_ALLOWED_COUNT" showon="is_subform:0"/>
<field name="allowed_count" type="number" label="COM_TJUCM_FORM_LBL_TYPE_ALLOWED_COUNT" description="COM_TJUCM_FORM_DESC_TYPE_ALLOWED_COUNT" hint="COM_TJUCM_FORM_LBL_TYPE_ALLOWED_COUNT" default="0" showon="is_subform:0"/>
<field name="allow_auto_save" type="radio" class="btn-group" default="1" label="COM_TJUCM_FORM_LBL_TYPE_ALLOW_AUTO_SAVE" description="COM_TJUCM_FORM_DESC_TYPE_ALLOW_AUTO_SAVE" hint="COM_TJUCM_FORM_LBL_TYPE_ALLOW_AUTO_SAVE" showon="is_subform:0">
<option value="0">JNO</option>
<option value="1">JYES</option>
Expand All @@ -39,6 +39,8 @@
<field name="modified_date" type="timecreated" label="COM_TJUCM_FORM_LBL_TYPE_MODIFIED_DATE" description="COM_TJUCM_FORM_DESC_TYPE_MODIFIED_DATE" hidden="true" hint="COM_TJUCM_FORM_LBL_TYPE_MODIFIED_DATE" />
<field name="version_note" type="text" label="JGLOBAL_FIELD_VERSION_NOTE_LABEL" description="JGLOBAL_FIELD_VERSION_NOTE_DESC" class="inputbox" size="45" labelclass="control-label" />
<field name="layout" type="componentlayout" label="COM_TJUCM_FORM_LBL_TYPE_LAYOUT" description="COM_TJUCM_FORM_DESC_TYPE_LAYOUT" useglobal="true" extension="com_tjucm" view="itemform"/>
<field name="details_layout" type="componentlayout" label="COM_TJUCM_DETAILS_LBL_TYPE_LAYOUT" description="COM_TJUCM_DETAILS_DESC_TYPE_LAYOUT" useglobal="true" extension="com_tjucm" view="item"/>
<field name="list_layout" type="componentlayout" label="COM_TJUCM_LIST_LBL_TYPE_LAYOUT" description="COM_TJUCM_LIST_DESC_TYPE_LAYOUT" useglobal="true" extension="com_tjucm" view="items"/>
</fieldset>
<fieldset name="accesscontrol">
<field name="asset_id" type="hidden" filter="unset" />
Expand Down
90 changes: 90 additions & 0 deletions src/components/com_tjucm/administrator/models/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ public function save($data)
$params['publish_items'] = $data['publish_items'];
$params['allowed_count'] = $data['allowed_count'];
$params['layout'] = $data['layout'];
$params['details_layout'] = $data['details_layout'];
$params['list_layout'] = $data['list_layout'];

// If UCM type is a subform then need to add content_id as hidden field in the form - For flat subform storage
JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR);
Expand Down Expand Up @@ -460,4 +462,92 @@ public function getTypeId($client)

return $table->id;
}

/**
* Method to delete one or more records.
*
* @param array &$pks An array of record primary keys.
*
* @return boolean True if successful, false if an error occurs.
*
* @since 1.2.1
*/
public function delete(&$pks)
{
$pks = (array) $pks;

if (empty($pks))
{
return false;
}

// Load the required files in the delete operation
JLoader::import('components.com_tjfields.models.groups', JPATH_ADMINISTRATOR);
JLoader::import('components.com_tjfields.models.group', JPATH_ADMINISTRATOR);
JLoader::import('components.com_tjucm.models.items', JPATH_SITE);
JLoader::import('components.com_tjucm.models.itemform', JPATH_SITE);

// Delete related field groups and fields and items data related to the UCM Type
foreach ($pks as $pk)
{
if (empty($pk))
{
continue;
}

// Get ucm data
$table = $this->getTable();
$table->load(array('id' => $pk));

// Get all field groups in the UCM type
$fieldGroupsModel = JModelLegacy::getInstance('Groups', 'TjfieldsModel', array('ignore_request' => true));
$fieldGroupsModel->setState("filter.client", $table->unique_identifier);
$fieldGroups = $fieldGroupsModel->getItems();

if (!empty($fieldGroups))
{
$tjFieldsGroupModel = JModelLegacy::getInstance('group', 'TjfieldsModel', array('ignore_request' => true));

foreach ($fieldGroups as $fieldGroup)
{
// Delete field groups in UCM type
$status = $tjFieldsGroupModel->delete($fieldGroup->id);

if ($status === false)
{
return false;
}
}
}

// Get all field records related to the UCM type
$itemsModel = JModelLegacy::getInstance('Items', 'TjucmModel', array('ignore_request' => true));
$itemsModel->setState("ucm.client", $table->unique_identifier);
$items = $itemsModel->getItems();

// Delete records related to the UCM type
if (!empty($items))
{
$itemFormModel = JModelLegacy::getInstance('ItemForm', 'TjucmModel', array('ignore_request' => true));

foreach ($items as $item)
{
$status = $itemFormModel->delete($item->id);

if ($status === false)
{
return false;
}
}
}

// Delete UCM type
if (!parent::delete($pk))
{
return false;
}
}

return true;
}
}
Loading

0 comments on commit 572566f

Please sign in to comment.