Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin compatible to j4 #422

Open
wants to merge 1 commit into
base: j4x
Choose a base branch
from
Open
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
15 changes: 9 additions & 6 deletions src/plugins/actionlog/tjucm/tjucm.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@

// No direct access.
defined('_JEXEC') or die();
use Joomla\CMS\Application\CMSApplication;
use Joomla\Data\DataObject;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Router\Route;

JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php');

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Table\Table;

/**
Expand All @@ -29,15 +32,15 @@ class PlgActionlogTjUcm extends CMSPlugin
/**
* Application object.
*
* @var JApplicationCms
* @var CMSApplication
* @since __DEPLOY__VERSION__
*/
protected $app;

/**
* Database object.
*
* @var JDatabaseDriver
* @var DataObjectbaseDriver
* @since __DEPLOY__VERSION__
*/
protected $db;
Expand Down Expand Up @@ -317,7 +320,7 @@ public function tjucmOnBeforeSaveItemData($recordId, $client, $data)
$clusterField = str_replace(".", "_", $client) . '_clusterclusterid';

JLoader::import('components.com_cluster.models.clusteruser', JPATH_ADMINISTRATOR);
$clusterUserModel = JModelLegacy::getInstance('ClusterUser', 'ClusterModel');
$clusterUserModel = BaseDatabaseModel::getInstance('ClusterUser', 'ClusterModel');
$usersClusters = $clusterUserModel->getUsersClusters($user->id);

if ($data[$clusterField])
Expand Down Expand Up @@ -370,7 +373,7 @@ public function tjucmOnBeforeSaveItemData($recordId, $client, $data)
$tjUcmFrontendHelper = new TjucmHelpersTjucm;
$link = 'index.php?option=com_tjucm&view=item&client=' . $client . '&id=' . $recordId;
$itemId = $tjUcmFrontendHelper->getItemId($link);
$link = JRoute::_($link . '&Itemid=' . $itemId, false);
$link = Route::_($link . '&Itemid=' . $itemId, false);

$message = array(
'action' => 'add',
Expand Down Expand Up @@ -428,7 +431,7 @@ public function tjUcmOnBeforeDeleteItem($item, $client)
$tjucmTableItem->load($item);

JLoader::import('components.com_cluster.models.clusteruser', JPATH_ADMINISTRATOR);
$clusterUserModel = JModelLegacy::getInstance('ClusterUser', 'ClusterModel');
$clusterUserModel = BaseDatabaseModel::getInstance('ClusterUser', 'ClusterModel');
$usersClusters = $clusterUserModel->getUsersClusters($user->id);

$deletingRecordOfOtherCluster = true;
Expand Down
16 changes: 9 additions & 7 deletions src/plugins/api/tjucm/tjucm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
*/

defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Table\Table;
jimport('joomla.plugin.plugin');
jimport('joomla.application.component.model');

$lang = JFactory::getLanguage();
$lang = Factory::getLanguage();
$lang->load('com_tjucm', JPATH_ADMINISTRATOR);

/**
Expand Down Expand Up @@ -46,13 +48,13 @@ public function __construct($subject, $config = array())
}

// Load component models
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/models');
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models');
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_tjucm/models');
BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/models');
BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models');
BaseDatabaseModel::addIncludePath(JPATH_SITE . '/components/com_tjucm/models');

// Load component tables
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/tables');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/tables');
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/tables');
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/tables');

ApiResource::addIncludePath(dirname(__FILE__) . '/tjucm');
}
Expand Down
19 changes: 11 additions & 8 deletions src/plugins/api/tjucm/tjucm/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*/

defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Language\Text;
jimport('joomla.plugin.plugin');

/**
Expand All @@ -29,9 +32,9 @@ class TjucmApiResourceItem extends ApiResource
*/
public function get()
{
$jInput = JFactory::getApplication()->input;
$jInput = Factory::getApplication()->input;
$id = $jInput->get('id');
$tjUcmModelItem = JModelLegacy::getInstance('Item', 'TjucmModel');
$tjUcmModelItem = BaseDatabaseModel::getInstance('Item', 'TjucmModel');

// Setting Client ID
$item = $tjUcmModelItem->getItem($id);
Expand All @@ -48,11 +51,11 @@ public function get()
*/
public function post()
{
$jInput = JFactory::getApplication()->input;
$jInput = Factory::getApplication()->input;
$client = $jInput->get('client');

// Getting the request Body Data
$jinput = JFactory::getApplication()->input->json;
$jinput = Factory::getApplication()->input->json;

// Setting Item details
$data = array();
Expand All @@ -65,7 +68,7 @@ public function post()
$extra_jform_data = array();

// Addding Extra item field values
$tjFieldsModelFields = JModelLegacy::getInstance('Fields', 'TjfieldsModel');
$tjFieldsModelFields = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel');
$tjFieldsModelFields->setState("filter.client", $client);

// Variable to store Fields of FieldGroup
Expand All @@ -87,7 +90,7 @@ public function post()
$extra_jform_data[$fieldsAssoc[(int) $field["id"]]] = $field["value"];
}

$tjUcmModelItemForm = JModelLegacy::getInstance('ItemForm', 'TjucmModel');
$tjUcmModelItemForm = BaseDatabaseModel::getInstance('ItemForm', 'TjucmModel');

// Setting Client ID
$tjUcmModelItemForm->setClient($client);
Expand All @@ -99,13 +102,13 @@ public function post()
if ($itemId)
{
$return_arr['success'] = true;
$return_arr['message'] = JText::_("COM_TJUCM_ITEM_ADDED");
$return_arr['message'] = Text::_("COM_TJUCM_ITEM_ADDED");
$return_arr['id'] = $itemId;
}
else
{
$return_arr['success'] = false;
$return_arr['message'] = JText::_("COM_TJUCM_ITEM_NOT_ADDED");
$return_arr['message'] = Text::_("COM_TJUCM_ITEM_NOT_ADDED");
}

$this->plugin->setResponse($return_arr);
Expand Down
22 changes: 13 additions & 9 deletions src/plugins/api/tjucm/tjucm/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
*/

defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Language\Text;
jimport('joomla.plugin.plugin');

/**
Expand All @@ -29,26 +33,26 @@ class TjucmApiResourceType extends ApiResource
*/
public function get()
{
$jInput = JFactory::getApplication()->input;
$jInput = Factory::getApplication()->input;
$client = $jInput->get('client');
$table = JTable::getInstance('Type', 'TjucmTable');
$table = Table::getInstance('Type', 'TjucmTable');
$table->load(["unique_identifier" => $client]);

$tjUcmModelType = JModelLegacy::getInstance('Type', 'TjucmModel');
$tjUcmModelType = BaseDatabaseModel::getInstance('Type', 'TjucmModel');
$tjUcmModelType->setState("filter.client", $client);

// Variable to store UCM Type
$ucmType = $tjUcmModelType->getItem($table->id);

// Variable to store creator name and id
$created_by = JFactory::getUser($ucmType->created_by);
$created_by = Factory::getUser($ucmType->created_by);
$ucmType->created_by = array("id" => $created_by->id, "name" => $created_by->name);

// Variable to store modifier name and id
$modified_by = JFactory::getUser($ucmType->modified_by);
$modified_by = Factory::getUser($ucmType->modified_by);
$ucmType->modified_by = array("id" => $modified_by->id, "name" => $modified_by->name);

$tjFieldsModelGroups = JModelLegacy::getInstance('Groups', 'TjfieldsModel', array('ignore_request' => true));
$tjFieldsModelGroups = BaseDatabaseModel::getInstance('Groups', 'TjfieldsModel', array('ignore_request' => true));
$tjFieldsModelGroups->setState('list.ordering', 'a.ordering');
$tjFieldsModelGroups->setState('list.direction', 'asc');

Expand All @@ -58,7 +62,7 @@ public function get()
// Getting fields of fieldgroups
foreach ($fieldgroups as $groupKey => $groupValue)
{
$tjFieldsModelFields = JModelLegacy::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true));
$tjFieldsModelFields = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true));
$tjFieldsModelFields->setState("filter.group_id", $fieldgroups[$groupKey]->id);
$tjFieldsModelFields->setState('list.ordering', 'a.ordering');
$tjFieldsModelFields->setState('list.direction', 'asc');
Expand All @@ -69,7 +73,7 @@ public function get()
// Getting options of field
foreach ($fields as $fieldKey => $fieldValue)
{
$tjFieldsModelOptions = JModelLegacy::getInstance('Options', 'TjfieldsModel');
$tjFieldsModelOptions = BaseDatabaseModel::getInstance('Options', 'TjfieldsModel');
$tjFieldsModelOptions->setState("filter.field_id", $fields[$fieldKey]->id);

// Variable to store Options of Field
Expand All @@ -93,7 +97,7 @@ public function get()
if (empty($ucmType))
{
$return_arr['success'] = false;
$return_arr['message'] = JText::_("COM_TJUCM_NO_TYPE");
$return_arr['message'] = Text::_("COM_TJUCM_NO_TYPE");
}
else
{
Expand Down