- draft, "draft", 'class="input-medium"
- size="1" onchange="this.form.submit();"', "value", "text", $this->state->get('filter.draft')
- );
- ?>
-
-
- pagination->getLimitBox(); ?>
+ draft, "draft", 'class="input-medium"
+ size="1" onchange="this.form.submit();"', "value", "text", $this->state->get('filter.draft')
+ );
+ ?>
enabled)
{
JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR);
@@ -55,14 +53,54 @@
if ($fieldTable->id)
{
- JFormHelper::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models/fields/');
- $cluster = JFormHelper::loadFieldType('cluster', false);
- $this->clusterList = $cluster->getOptionsExternally();
+ JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR);
+ JLoader::import("/components/com_cluster/includes/cluster", JPATH_ADMINISTRATOR);
+ $clustersModel = ClusterFactory::model('Clusters', array('ignore_request' => true));
+ $clusters = $clustersModel->getItems();
+
+ // Get list of clusters with data in UCM type
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true);
+ $query->select($db->quoteName('cluster_id'));
+ $query->from($db->quoteName('#__tj_ucm_data'));
+ $query->where($db->quoteName('client') . '=' . $db->quote($this->client));
+ $query->group($db->quoteName('cluster_id'));
+ $db->setQuery($query);
+ $clustersWithData = $db->loadColumn();
+
+ $usersClusters = array();
+
+ $clusterObj = new stdclass;
+ $clusterObj->text = JText::_("COM_TJFIELDS_OWNERSHIP_CLUSTER");
+ $clusterObj->value = "";
+
+ $usersClusters[] = $clusterObj;
+
+ if (!empty($clusters))
+ {
+ foreach ($clusters as $clusterList)
+ {
+ if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewitem.' . $this->ucmTypeId, $clusterList->id) || RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewallitem.' . $this->ucmTypeId))
+ {
+ if (!empty($clusterList->id))
+ {
+ if (in_array($clusterList->id, $clustersWithData))
+ {
+ $clusterObj = new stdclass;
+ $clusterObj->text = $clusterList->name;
+ $clusterObj->value = $clusterList->id;
+
+ $usersClusters[] = $clusterObj;
+ }
+ }
+ }
+ }
+ }
?>
clusterList, "cluster", 'class="input-medium"
+ 'select.genericlist', $usersClusters, "cluster", 'class="input-medium"
size="1" onchange="this.form.submit();"', "value", "text",
$this->state->get($this->client . '.filter.cluster_id', '', 'INT')
);
diff --git a/src/components/com_tjucm/site/views/items/view.html.php b/src/components/com_tjucm/site/views/items/view.html.php
index 9d79de02..44424768 100644
--- a/src/components/com_tjucm/site/views/items/view.html.php
+++ b/src/components/com_tjucm/site/views/items/view.html.php
@@ -38,15 +38,7 @@ class TjucmViewItems extends JViewLegacy
protected $canCreate;
- protected $canView;
-
- protected $canEdit;
-
- protected $canChange;
-
- protected $canEditOwn;
-
- protected $canDelete;
+ protected $canImport;
protected $menuparams;
@@ -76,6 +68,16 @@ public function display($tpl = null)
$app = JFactory::getApplication();
$user = JFactory::getUser();
+ if (!$user->id)
+ {
+ $msg = JText::_('COM_TJUCM_LOGIN_MSG');
+
+ // Get current url.
+ $current = JUri::getInstance()->toString();
+ $url = base64_encode($current);
+ JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $url, false), $msg);
+ }
+
// Check the view access to the items.
if (!$user->id)
{
@@ -94,17 +96,10 @@ public function display($tpl = null)
$model = $this->getModel("Items");
$this->ucmTypeId = $id = $model->getState('ucmType.id');
$this->client = $model->getState('ucm.client');
- $this->canCreate = $user->authorise('core.type.createitem', 'com_tjucm.type.' . $this->ucmTypeId);
- $this->canImport = $user->authorise('core.type.importitem', 'com_tjucm.type.' . $this->ucmTypeId);
- $this->canView = $user->authorise('core.type.viewitem', 'com_tjucm.type.' . $this->ucmTypeId);
- $this->canEdit = $user->authorise('core.type.edititem', 'com_tjucm.type.' . $this->ucmTypeId);
- $this->canChange = $user->authorise('core.type.edititemstate', 'com_tjucm.type.' . $this->ucmTypeId);
- $this->canEditOwn = $user->authorise('core.type.editownitem', 'com_tjucm.type.' . $this->ucmTypeId);
- $this->canDelete = $user->authorise('core.type.deleteitem', 'com_tjucm.type.' . $this->ucmTypeId);
- $this->canDeleteOwn = $user->authorise('core.type.deleteownitem', 'com_tjucm.type.' . $this->ucmTypeId);
+ $this->canCreate = TjucmAccess::canCreate($this->ucmTypeId);
+ $this->canImport = TjucmAccess::canImport($this->ucmTypeId);
$this->draft = array("" => JText::_('COM_TJUCM_DATA_STATUS_SELECT_OPTION'),
"0" => JText::_("COM_TJUCM_DATA_STATUS_SAVE"), "1" => JText::_('COM_TJUCM_DATA_STATUS_DRAFT'));
-
// If did not get the client from url then get if from menu param
if (empty($this->client))
{
@@ -124,23 +119,18 @@ public function display($tpl = null)
$ucmTypeTable = JTable::getInstance('Type', 'TjucmTable', array('dbo', JFactory::getDbo()));
$ucmTypeTable->load(array('alias' => $this->ucm_type));
$this->client = $ucmTypeTable->unique_identifier;
+ $this->title = $ucmTypeTable->title;
}
}
}
// To get title of list as per the ucm type
- if (empty($this->title))
+ if (!isset($this->title))
{
- // Get the active item
- $menuItem = $app->getMenu()->getActive();
-
- // Get the params
- $this->menuparams = $menuItem->params;
-
- if (!empty($this->menuparams))
- {
- $this->title = $this->menuparams->get('ucm_type');
- }
+ JLoader::import('components.com_tjfields.tables.type', JPATH_ADMINISTRATOR);
+ $ucmTypeTable = JTable::getInstance('Type', 'TjucmTable', array('dbo', JFactory::getDbo()));
+ $ucmTypeTable->load(array('unique_identifier' => $this->client));
+ $this->title = $ucmTypeTable->title;
}
// If there are no fields column to show in list view then dont allow to show data
@@ -178,11 +168,6 @@ public function display($tpl = null)
}
}
- if ($this->created_by == $userId)
- {
- $this->canView = true;
- }
-
// Check for errors.
if (count($errors = $this->get('Errors')))
{
diff --git a/src/components/com_tjucm/tjucm.xml b/src/components/com_tjucm/tjucm.xml
index 5073f11b..84b8bb21 100644
--- a/src/components/com_tjucm/tjucm.xml
+++ b/src/components/com_tjucm/tjucm.xml
@@ -41,6 +41,7 @@
js
css
+ gif
en-GB/en-GB.com_tjucm.ini
diff --git a/src/pkg_tjucm.xml b/src/pkg_tjucm.xml
index b5d8c468..3073b049 100644
--- a/src/pkg_tjucm.xml
+++ b/src/pkg_tjucm.xml
@@ -11,8 +11,9 @@
1.2.3
Techjoomla Team
script.pkg_tjucm.php
-
- com_tjucm.zip
- com_tjfields.zip
+
+ components/com_tjucm.zip
+ components/com_tjfields.zip
+ plugins/actionlog/tjucm.zip
diff --git a/src/plugins/actionlog/tjucm/index.html b/src/plugins/actionlog/tjucm/index.html
new file mode 100644
index 00000000..2efb97f3
--- /dev/null
+++ b/src/plugins/actionlog/tjucm/index.html
@@ -0,0 +1 @@
+
diff --git a/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini b/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
new file mode 100644
index 00000000..a4f8ceff
--- /dev/null
+++ b/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
@@ -0,0 +1,39 @@
+; @package TJUCM
+; @subpackage Actionlog.TJUCM
+; @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
+; @license GNU General Public License version 2 or later
+; Note: All ini files need to be saved as UTF-8
+
+PLG_ACTIONLOG_TJUCM="Action Log - TJUCM"
+PLG_ACTIONLOG_TJUCM_XML_DESCRIPTION="Record the actions of users on the site for extension TJUCM so they can be reviewed if required."
+PLG_ACTIONLOG_TJUCM_LOG_ACTION_TYPE_SAVE="Log action for type creation?"
+PLG_ACTIONLOG_TJUCM_LOG_ACTION_TYPE_DELETE="Log action for type delete?"
+PLG_ACTIONLOG_TJUCM_LOG_ACTION_TYPE_UPDATE="Log action for type update?"
+PLG_ACTIONLOG_TJUCM_LOG_ACTION_TYPE_STATE_CHANGE="Log action for type state change?"
+PLG_ACTIONLOG_TJUCM_LOG_ACTION_TYPE_IMPORT="Log action for type import?"
+PLG_ACTIONLOG_TJUCM_LOG_ACTION_TYPE_EXPORT="Log action for type Export?"
+PLG_ACTIONLOG_TJUCM_LOG_ACTION_TYPE_TRASH="Log action for type Trash?"
+PLG_ACTIONLOG_TJUCM_LOG_ACTION_ITEM_DELETE="Log action for item delete?"
+PLG_ACTIONLOG_TJUCM_LOG_ACTION_ITEM_SAVE="Log action for item creation?"
+PLG_ACTIONLOG_TJUCM_LOG_ACTION_ITEM_DATA_SAVE="Log action for item data add/update?"
+
+PLG_ACTIONLOG_TJUCM_TYPE_ADDED="{username} added a new UCM type {title} "
+PLG_ACTIONLOG_TJUCM_TYPE_UPDATED="{username} updated the UCM type {title} "
+PLG_ACTIONLOG_TJUCM_TYPE_DELETED="{username} deleted the UCM type \"{title}\""
+PLG_ACTIONLOGS_TJUCM_TYPE_UNPUBLISHED="{username} unpublished the UCM type {title} "
+PLG_ACTIONLOGS_TJUCM_TYPE_PUBLISHED="{username} published the UCM type {title} "
+PLG_ACTIONLOGS_TJUCM_TYPE_ARCHIVED="{username} archived the UCM type {title} of client \"{identifier}\""
+PLG_ACTIONLOGS_TJUCM_TYPE_TRASHED="{username} trashed the UCM type {title}"
+PLG_ACTIONLOG_TJUCM_TYPE_EXPORTED="{username} exported the UCM type {title}"
+PLG_ACTIONLOG_TJUCM_TYPE_IMPORTED="{username} imported the UCM type {title}"
+
+PLG_ACTIONLOG_TJUCM_ITEM_DELETED="{username} has deleted a record from {title}"
+PLG_ACTIONLOG_TJUCM_ITEM_ADDED="{username} has added a record in {title}"
+PLG_ACTIONLOG_TJUCM_ITEM_DATA_ADDED="{username} has added a record in {title}"
+PLG_ACTIONLOG_TJUCM_ITEM_DATA_EDIT="{username} has updated a record in {title}"
+PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_EDIT="{username} from {cluster_title} has updated a record in {title}"
+PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_ADDED="{username} from {cluster_title} has added a record in {title}"
+PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DELETED="{username} from {cluster_title} has deleted a record from {title}"
+PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DATA_EDIT="{username} from {cluster_title} has updated a record in {title} for {owner_cluster_title}"
+PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DATA_ADDED="{username} from {cluster_title} has added a record in {title} for {owner_cluster_title}"
+PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DELETED="{username} from {cluster_title} has deleted a record from {title} for {owner_cluster_title}"
diff --git a/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.sys.ini b/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.sys.ini
new file mode 100644
index 00000000..faa6bead
--- /dev/null
+++ b/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.sys.ini
@@ -0,0 +1,8 @@
+; @package TJUCM
+; @subpackage Actionlog.TJUCM
+; @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
+; @license GNU General Public License version 2 or later
+; Note: All ini files need to be saved as UTF-8
+
+PLG_ACTIONLOG_TJUCM="Action Log - TJUCM"
+PLG_ACTIONLOG_TJUCM_XML_DESCRIPTION="Record the actions of users on the site for extension TJUCM so they can be reviewed if required."
\ No newline at end of file
diff --git a/src/plugins/actionlog/tjucm/tjucm.php b/src/plugins/actionlog/tjucm/tjucm.php
new file mode 100644
index 00000000..cd422570
--- /dev/null
+++ b/src/plugins/actionlog/tjucm/tjucm.php
@@ -0,0 +1,495 @@
+
+ * @copyright Copyright (c) 2009-2019 Techjoomla. All rights reserved.
+ * @license GNU General Public License version 2 or later.
+ */
+
+// No direct access.
+defined('_JEXEC') or die();
+
+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;
+
+/**
+ * UCM Actions Logging Plugin.
+ *
+ * @since __DEPLOY__VERSION__
+ */
+class PlgActionlogTjUcm extends CMSPlugin
+{
+ /**
+ * Application object.
+ *
+ * @var JApplicationCms
+ * @since __DEPLOY__VERSION__
+ */
+ protected $app;
+
+ /**
+ * Database object.
+ *
+ * @var JDatabaseDriver
+ * @since __DEPLOY__VERSION__
+ */
+ protected $db;
+
+ /**
+ * Load plugin language file automatically so that it can be used inside component
+ *
+ * @var boolean
+ * @since __DEPLOY__VERSION__
+ */
+ protected $autoloadLanguage = true;
+
+ /**
+ * Proxy for ActionlogsModelUserlog addLog method
+ *
+ * This method adds a record to #__action_logs contains (message_language_key, message, date, context, user)
+ *
+ * @param array $messages The contents of the messages to be logged
+ * @param string $messageLanguageKey The language key of the message
+ * @param string $context The context of the content passed to the plugin
+ * @param int $userId ID of user perform the action, usually ID of current logged in user
+ *
+ * @return void
+ *
+ * @since __DEPLOY__VERSION__
+ */
+ protected function addLog($messages, $messageLanguageKey, $context, $userId = null)
+ {
+ JLoader::register('ActionlogsModelActionlog', JPATH_ADMINISTRATOR . '/components/com_actionlogs/models/actionlog.php');
+
+ $model = BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel');
+ $model->addLog($messages, $messageLanguageKey, $context, $userId);
+ }
+
+ /**
+ * On saving UCM type data - logging method
+ *
+ * Method is called when ucm type is to be stored in the database.
+ * This method logs who created/edited any data of UCM type
+ *
+ * @param Array $type Holds the ucm type data
+ * @param Boolean $isNew True if a new type is stored.
+ *
+ * @return void
+ *
+ * @since __DEPLOY__VERSION__
+ */
+ public function tjUcmOnAfterTypeSave($type, $isNew)
+ {
+ if ($isNew)
+ {
+ if (!$this->params->get('logActionForTypeSave', 1))
+ {
+ return;
+ }
+
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_TYPE_ADDED';
+ $action = 'add';
+ }
+ else
+ {
+ if (!$this->params->get('logActionForTypeUpdate', 1))
+ {
+ return;
+ }
+
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_TYPE_UPDATED';
+ $action = 'update';
+ }
+
+ $context = Factory::getApplication()->input->get('option');
+ $user = Factory::getUser();
+
+ $message = array(
+ 'action' => $action,
+ 'id' => $type['typeId'],
+ 'title' => $type['title'],
+ 'userid' => $user->id,
+ 'username' => ucfirst($user->username),
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ 'typelink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $type['typeId'],
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ }
+
+ /**
+ * On deleting UCM type data - logging method
+ *
+ * Method is called after ucm type is deleted in the database.
+ *
+ * @param String $context com_tjucm
+ * @param Object $table Holds the coupon data.
+ *
+ * @return void
+ *
+ * @since __DEPLOY__VERSION__
+ */
+ public function tjUcmOnAfterTypeDelete($context, $table)
+ {
+ if (!$this->params->get('logActionForTypeDelete', 1))
+ {
+ return;
+ }
+
+ $context = Factory::getApplication()->input->get('option');
+ $user = Factory::getUser();
+
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_TYPE_DELETED';
+ $message = array(
+ 'action' => 'delete',
+ 'id' => $table->id,
+ 'title' => $table->title,
+ 'identifier' => $table->unique_identifier,
+ 'userid' => $user->id,
+ 'username' => ucfirst($user->username),
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ }
+
+ /**
+ * On changing state of UCM Type - logging method
+ *
+ * Method is called after user data is stored in the database.
+ * This method logs who changed state of UCM type
+ *
+ * @param String $context com_tjucm
+ * @param Array $pks Holds array of primary key.
+ * @param Int $value Switch case value.
+ *
+ * @return void
+ *
+ * @since __DEPLOY__VERSION__
+ */
+ public function tjUcmOnAfterTypeChangeState($context, $pks, $value)
+ {
+ if (!$this->params->get('logActionForTypeStateChange', 1))
+ {
+ return;
+ }
+
+ JLoader::import('components.com_tjucm.tables.type', JPATH_ADMINISTRATOR);
+ $tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
+
+ $context = Factory::getApplication()->input->get('option');
+ $jUser = Factory::getUser();
+ $userId = $jUser->id;
+ $userName = ucfirst($jUser->username);
+
+ switch ($value)
+ {
+ case 0:
+ $messageLanguageKey = 'PLG_ACTIONLOGS_TJUCM_TYPE_UNPUBLISHED';
+ $action = 'unpublish';
+ break;
+ case 1:
+ $messageLanguageKey = 'PLG_ACTIONLOGS_TJUCM_TYPE_PUBLISHED';
+ $action = 'publish';
+ break;
+ case 2:
+ $messageLanguageKey = 'PLG_ACTIONLOGS_TJUCM_TYPE_ARCHIVED';
+ $action = 'archive';
+ break;
+ case -2:
+ $messageLanguageKey = 'PLG_ACTIONLOGS_TJUCM_TYPE_TRASHED';
+ $action = 'trash';
+ break;
+ default:
+ $messageLanguageKey = '';
+ $action = '';
+ break;
+ }
+
+ foreach ($pks as $pk)
+ {
+ $tjucmTableType->load(array('id' => $pk));
+
+ $message = array(
+ 'action' => $action,
+ 'id' => $tjucmTableType->id,
+ 'title' => $tjucmTableType->title,
+ 'identifier' => $tjucmTableType->unique_identifier,
+ 'itemlink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $tjucmTableType->id,
+ 'userid' => $userId,
+ 'username' => $userName,
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $userId,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $userId);
+ }
+ }
+
+ /**
+ * On saving UCM item data - logging method
+ *
+ * Method is called when ucm item is to be stored in the database.
+ * This method logs who created/edited any data of UCM item
+ *
+ * @param Integer $item Holds the ucm item id
+ *
+ * @param Integer $isNew Flag to mark new records
+ *
+ * @return void
+ *
+ * @since __DEPLOY__VERSION__
+ */
+ public function tjucmOnAfterSaveItem($item, $isNew)
+ {
+ if (!$this->params->get('tjucmOnAfterSaveItem', 1))
+ {
+ return;
+ }
+
+ JLoader::import('components.com_tjucm.tables.type', JPATH_ADMINISTRATOR);
+ $tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
+ $tjucmTableType->load(array('unique_identifier' => $item['client']));
+
+ $context = Factory::getApplication()->input->get('option');
+ $user = Factory::getUser();
+
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_ITEM_ADDED';
+ $message = array(
+ 'action' => 'add',
+ 'id' => $item['id'],
+ 'title' => $tjucmTableType->title,
+ 'userid' => $user->id,
+ 'username' => ucfirst($user->username),
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ }
+
+ /**
+ * On saving UCM item data - logging method
+ *
+ * Method is called when ucm item is to be stored in the database.
+ * This method logs who created/edited any data of UCM item
+ *
+ * @param Integer $recordId Holds the ucm item id
+ *
+ * @param Integer $client UCM client
+ *
+ * @param Integer $data fields value
+ *
+ * @return void
+ *
+ * @since __DEPLOY__VERSION__
+ */
+ public function tjucmOnBeforeSaveItemData($recordId, $client, $data)
+ {
+ if (!$this->params->get('tjucmOnAfterSaveItemData', 1) || empty($recordId))
+ {
+ return;
+ }
+
+ $context = Factory::getApplication()->input->get('option');
+ $user = Factory::getUser();
+
+ JLoader::import('components.com_tjucm.tables.type', JPATH_ADMINISTRATOR);
+ $tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
+ $tjucmTableType->load(array('unique_identifier' => $client));
+
+ JLoader::import('components.com_tjfields.tables.fieldsvalue', JPATH_ADMINISTRATOR);
+ $fieldValue = Table::getInstance('FieldsValue', 'TjfieldsTable', array());
+ $fieldValue->load(array('content_id' => $recordId, 'client' => $client));
+
+ $clusterId = "";
+ $clusterTitle = "";
+ $ownerClusterId = "";
+ $ownerClusterTitle = "";
+
+ if (ComponentHelper::getComponent('com_cluster', true)->enabled)
+ {
+ $clusterField = str_replace(".", "_", $client) . '_clusterclusterid';
+
+ JLoader::import('components.com_cluster.models.clusteruser', JPATH_ADMINISTRATOR);
+ $clusterUserModel = JModelLegacy::getInstance('ClusterUser', 'ClusterModel');
+ $usersClusters = $clusterUserModel->getUsersClusters($user->id);
+
+ if ($data[$clusterField])
+ {
+ $editingRecordOfOtherCluster = true;
+
+ // Check if user belongs to the cluster who has created the record or not
+ foreach ($usersClusters as $usersCluster)
+ {
+ if ($usersCluster->cluster_id == $data[$clusterField])
+ {
+ // If user is not part of cluster who owns the record then he is editing record on behalf or other cluster
+ $editingRecordOfOtherCluster = false;
+
+ break;
+ }
+ }
+
+ JLoader::import('components.com_cluster.tables.clusters', JPATH_ADMINISTRATOR);
+ $clusterTable = Table::getInstance('Clusters', 'ClusterTable', array());
+
+ if ($editingRecordOfOtherCluster)
+ {
+ $clusterTable->load($usersClusters[0]->cluster_id);
+ $clusterId = $usersClusters[0]->cluster_id;
+ $clusterTitle = $clusterTable->name;
+
+ $clusterTable->load($data[$clusterField]);
+ $ownerClusterId = $data[$clusterField];
+ $ownerClusterTitle = $clusterTable->name;
+
+ $messageLanguageKey = ($fieldValue->id) ? 'PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DATA_EDIT' : 'PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DATA_ADDED';
+ }
+ else
+ {
+ $clusterTable->load($data[$clusterField]);
+ $clusterId = $tjucmTableItem->cluster_id;
+ $clusterTitle = $clusterTable->name;
+
+ $messageLanguageKey = ($fieldValue->id) ? 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_EDIT' : 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_ADDED';
+ }
+ }
+ }
+ else
+ {
+ $messageLanguageKey = ($fieldValue->id) ? 'PLG_ACTIONLOG_TJUCM_ITEM_DATA_EDIT' : 'PLG_ACTIONLOG_TJUCM_ITEM_DATA_ADDED';
+ }
+
+ JLoader::import('components.com_tjucm.helpers.tjucm', JPATH_SITE);
+ $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);
+
+ $message = array(
+ 'action' => 'add',
+ 'id' => $recordId,
+ 'title' => $tjucmTableType->title,
+ 'cluster_id' => $clusterId,
+ 'cluster_title' => $clusterTitle,
+ 'owner_cluster_id' => $ownerClusterId,
+ 'owner_cluster_title' => $ownerClusterTitle,
+ 'userid' => $user->id,
+ 'username' => ucfirst($user->name),
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ 'item_link' => $link,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ }
+
+ /**
+ * On deleting UCM item data - logging method
+ *
+ * Method is called after ucm item is deleted in the database.
+ *
+ * @param Object $item Holds the item obj.
+ *
+ * @param Object $client UCM type
+ *
+ * @return void
+ *
+ * @since __DEPLOY__VERSION__
+ */
+ public function tjUcmOnBeforeDeleteItem($item, $client)
+ {
+ if (!$this->params->get('TjUcmOnAfterItemDelete', 1))
+ {
+ return;
+ }
+
+ JLoader::import('components.com_tjucm.tables.type', JPATH_ADMINISTRATOR);
+ $tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
+ $tjucmTableType->load(array('unique_identifier' => $client));
+
+ $context = Factory::getApplication()->input->get('option');
+ $user = Factory::getUser();
+
+ $clusterId = "";
+ $clusterTitle = "";
+ $ownerClusterId = "";
+ $ownerClusterTitle = "";
+
+ if (ComponentHelper::getComponent('com_cluster', true)->enabled)
+ {
+ JLoader::import('components.com_tjucm.tables.item', JPATH_ADMINISTRATOR);
+ $tjucmTableItem = Table::getInstance('Item', 'TjucmTable', array());
+ $tjucmTableItem->load($item);
+
+ JLoader::import('components.com_cluster.models.clusteruser', JPATH_ADMINISTRATOR);
+ $clusterUserModel = JModelLegacy::getInstance('ClusterUser', 'ClusterModel');
+ $usersClusters = $clusterUserModel->getUsersClusters($user->id);
+
+ $deletingRecordOfOtherCluster = true;
+
+ // Check if user belongs to the cluster who has created the record or not
+ foreach ($usersClusters as $usersCluster)
+ {
+ if ($usersCluster->cluster_id == $tjucmTableItem->cluster_id)
+ {
+ // If user is not part of cluster who owns the record then he is editing record on behalf or other cluster
+ $deletingRecordOfOtherCluster = false;
+
+ break;
+ }
+ }
+
+ if ($tjucmTableItem->cluster_id)
+ {
+ JLoader::import('components.com_cluster.tables.clusters', JPATH_ADMINISTRATOR);
+ $clusterTable = Table::getInstance('Clusters', 'ClusterTable', array());
+
+ if ($deletingRecordOfOtherCluster)
+ {
+ $clusterTable->load($usersClusters[0]->cluster_id);
+ $clusterId = $usersClusters[0]->cluster_id;
+ $clusterTitle = $clusterTable->name;
+
+ $clusterTable->load($tjucmTableItem->cluster_id);
+ $ownerClusterId = $tjucmTableItem->cluster_id;
+ $ownerClusterTitle = $clusterTable->name;
+
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DELETED';
+ }
+ else
+ {
+ $clusterTable->load($tjucmTableItem->cluster_id);
+ $clusterId = $tjucmTableItem->cluster_id;
+ $clusterTitle = $clusterTable->name;
+
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DELETED';
+ }
+ }
+ }
+ else
+ {
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_ITEM_DELETED';
+ }
+
+ $message = array(
+ 'action' => 'delete',
+ 'id' => $item,
+ 'title' => $tjucmTableType->title,
+ 'cluster_id' => $clusterId,
+ 'cluster_title' => $clusterTitle,
+ 'owner_cluster_id' => $ownerClusterId,
+ 'owner_cluster_title' => $ownerClusterTitle,
+ 'userid' => $user->id,
+ 'username' => ucfirst($user->name),
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ }
+}
diff --git a/src/plugins/actionlog/tjucm/tjucm.xml b/src/plugins/actionlog/tjucm/tjucm.xml
new file mode 100644
index 00000000..34c13553
--- /dev/null
+++ b/src/plugins/actionlog/tjucm/tjucm.xml
@@ -0,0 +1,54 @@
+
+
+ plg_actionlog_tjucm
+ Techjoomla
+ 19th March 2020
+ Copyright (C) 2009 - 2020 Techjoomla. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ extensions@techjoomla.com
+ https://techjoomla.com
+ 1.2.4
+ PLG_ACTIONLOG_TJUCM_XML_DESCRIPTION
+
+ tjucm.php
+ index.html
+
+
+ en-GB/en-GB.plg_actionlog_tjucm.ini
+ en-GB/en-GB.plg_actionlog_tjucm.sys.ini
+
+
+
+
+
+
+
diff --git a/src/components/com_tjucm/plugins/api/tjucm/tjucm.php b/src/plugins/api/tjucm/tjucm.php
similarity index 100%
rename from src/components/com_tjucm/plugins/api/tjucm/tjucm.php
rename to src/plugins/api/tjucm/tjucm.php
diff --git a/src/components/com_tjucm/plugins/api/tjucm/tjucm.xml b/src/plugins/api/tjucm/tjucm.xml
similarity index 100%
rename from src/components/com_tjucm/plugins/api/tjucm/tjucm.xml
rename to src/plugins/api/tjucm/tjucm.xml
diff --git a/src/components/com_tjucm/plugins/api/tjucm/tjucm/item.php b/src/plugins/api/tjucm/tjucm/item.php
similarity index 100%
rename from src/components/com_tjucm/plugins/api/tjucm/tjucm/item.php
rename to src/plugins/api/tjucm/tjucm/item.php
diff --git a/src/components/com_tjucm/plugins/api/tjucm/tjucm/type.php b/src/plugins/api/tjucm/tjucm/type.php
similarity index 100%
rename from src/components/com_tjucm/plugins/api/tjucm/tjucm/type.php
rename to src/plugins/api/tjucm/tjucm/type.php