Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 173 additions & 0 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -6076,4 +6076,177 @@ private function cleanJoomlaCache()
$model->setState('client_id', 1);
$model->clean();
}

/**
* Called after any type of action
*
* @param string $action Which action is happening (install|uninstall|discover_install|update)
* @param Installer $installer The class calling this method
*
* @return boolean True on success
*
* @since __DEPLOY_VERSION__
*/
public function postflight($action, $installer)
{
if ($action !== 'update')
{
return true;
}

if (empty($this->fromVersion) || version_compare($this->fromVersion, '4.0.0', 'ge'))
{
return true;
}

$db = Factory::getDbo();
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_menus/Table/');

$tableItem = new \Joomla\Component\Menus\Administrator\Table\MenuTable($db);

// Check for the Contact parent Id Menu Item
$keys = [
'menutype' => 'main',
'type' => 'component',
'title' => 'com_contact',
'parent_id' => 1,
'client_id' => 1,
];

$contactMenuitem = $tableItem->load($keys);

if (!$contactMenuitem)
{
return false;
}

$parentId = $tableItem->id;
$componentId = ExtensionHelper::getExtensionRecord('com_fields')->extension_id;

// Add Contact Fields Menu Items.
$menuItems = [
[
'menutype' => 'main',
'title' => '-',
'alias' => microtime(true),
'note' => '',
'path' => '',
'link' => '#',
'type' => 'separator',
'published' => 1,
'parent_id' => $parentId,
'level' => 2,
'component_id' => $componentId,
'checked_out' => 0,
'checked_out_time' => null,
'browserNav' => 0,
'access' => 0,
'img' => '',
'template_style_id' => 0,
'params' => '{}',
'home' => 0,
'language' => '*',
'client_id' => 1,
'publish_up' => null,
'publish_down' => null,
],
[
'menutype' => 'main',
'title' => 'mod_menu_fields',
'alias' => 'Contact Custom Fields',
'note' => '',
'path' => 'contact/Custom Fields',
'link' => 'index.php?option=com_fields&context=com_contact.contact',
'type' => 'component',
'published' => 1,
'parent_id' => $parentId,
'level' => 2,
'component_id' => $componentId,
'checked_out' => 0,
'checked_out_time' => null,
'browserNav' => 0,
'access' => 0,
'img' => '',
'template_style_id' => 0,
'params' => '{}',
'home' => 0,
'language' => '*',
'client_id' => 1,
'publish_up' => null,
'publish_down' => null,
],
[
'menutype' => 'main',
'title' => 'mod_menu_fields_group',
'alias' => 'Contact Custom Fields Group',
'note' => '',
'path' => 'contact/Custom Fields Group',
'link' => 'index.php?option=com_fields&view=groups&context=com_contact.contact',
'type' => 'component',
'published' => 1,
'parent_id' => $parentId,
'level' => 2,
'component_id' => $componentId,
'checked_out' => 0,
'checked_out_time' => null,
'browserNav' => 0,
'access' => 0,
'img' => '',
'template_style_id' => 0,
'params' => '{}',
'home' => 0,
'language' => '*',
'client_id' => 1,
'publish_up' => null,
'publish_down' => null,
]
];

foreach ($menuItems as $menuItem)
{
// Check an existing record
$keys = [
'menutype' => $menuItem['menutype'],
'type' => $menuItem['type'],
'title' => $menuItem['title'],
'parent_id' => $menuItem['parent_id'],
'client_id' => $menuItem['client_id'],
];

if ($tableItem->load($keys))
{
continue;
}

$newTableItem = new \Joomla\Component\Menus\Administrator\Table\MenuTable($db);

// Bind the data.
if (!$newTableItem->bind($menuItem))
{
return false;
}

$newTableItem->setLocation($menuItem['parent_id'], 'last-child');

// Check the data.
if (!$newTableItem->check())
{
return false;
}

// Store the data.
if (!$newTableItem->store())
{
return false;
}

// Rebuild the tree path.
if (!$newTableItem->rebuildPath($newTableItem->id))
{
return false;
}
}

return true;
}
}
27 changes: 0 additions & 27 deletions administrator/components/com_contact/Helper/ContactHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Language\Text;

/**
* Contact component helper.
Expand All @@ -22,29 +20,4 @@
*/
class ContactHelper extends ContentHelper
{
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
if (ComponentHelper::isEnabled('com_fields') && ComponentHelper::getParams('com_contact')->get('custom_fields_enable', '1'))
{
\JHtmlSidebar::addEntry(
Text::_('JGLOBAL_FIELDS'),
'index.php?option=com_fields&context=com_contact.contact',
$vName == 'fields.fields'
);
\JHtmlSidebar::addEntry(
Text::_('JGLOBAL_FIELD_GROUPS'),
'index.php?option=com_fields&view=groups&context=com_contact.contact',
$vName == 'fields.groups'
);
}
}
}
Loading