From 154038605de655aa54df7fecdf501a5acf5b98ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Mon, 16 Sep 2019 17:03:37 +0530
Subject: [PATCH 01/15] feat : Task #150647 tjucm plugin
---
.../administrator/controllers/types.php | 8 +
.../com_tjucm/administrator/models/type.php | 8 +
.../plugins/actionlog/tjfield/index.html | 1 +
.../plugins/actionlog/tjfield/tjfield.php | 249 ++++++++++++++
.../plugins/actionlog/tjfield/tjfield.xml | 58 ++++
.../actionlog/tjfield/tjfield_Kishori.php | 126 +++++++
.../plugins/actionlog/tjucm/index.html | 1 +
.../en-GB/en-GB.plg_actionlog_tjucm.ini | 26 ++
.../en-GB/en-GB.plg_actionlog_tjucm.sys.ini | 8 +
.../plugins/actionlog/tjucm/tjucm.php | 322 ++++++++++++++++++
.../plugins/actionlog/tjucm/tjucm.xml | 53 +++
11 files changed, 860 insertions(+)
create mode 100644 src/components/com_tjucm/plugins/actionlog/tjfield/index.html
create mode 100644 src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.php
create mode 100644 src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.xml
create mode 100644 src/components/com_tjucm/plugins/actionlog/tjfield/tjfield_Kishori.php
create mode 100644 src/components/com_tjucm/plugins/actionlog/tjucm/index.html
create mode 100644 src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
create mode 100644 src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.sys.ini
create mode 100644 src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
create mode 100644 src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.xml
diff --git a/src/components/com_tjucm/administrator/controllers/types.php b/src/components/com_tjucm/administrator/controllers/types.php
index 8fb4ed69..1367f4f1 100644
--- a/src/components/com_tjucm/administrator/controllers/types.php
+++ b/src/components/com_tjucm/administrator/controllers/types.php
@@ -135,6 +135,10 @@ public function export()
$exportData = array();
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('actionlog', 'tjucm');
+ $dispatcher->trigger('tjUcmOnAfterTypeExport', array($cids));
+
foreach ($cids as $cid)
{
$ucmTypeTable = Table::getInstance('Type', 'TjucmTable');
@@ -369,6 +373,10 @@ public function import()
}
}
}
+
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('actionlog', 'tjucm');
+ $dispatcher->trigger('tjUcmOnAfterTypeImport', array($ucmTypeId));
}
}
diff --git a/src/components/com_tjucm/administrator/models/type.php b/src/components/com_tjucm/administrator/models/type.php
index 782c53a2..9e7bd02a 100644
--- a/src/components/com_tjucm/administrator/models/type.php
+++ b/src/components/com_tjucm/administrator/models/type.php
@@ -51,6 +51,9 @@ public function __construct($config = array())
JLoader::import('components.com_tjucm.classes.funlist', JPATH_ADMINISTRATOR);
$this->common = new TjucmFunList;
+ $config['event_after_delete'] = 'tjUcmOnAfterTypeDelete';
+ $config['event_change_state'] = 'tjUcmOnAfterTypeChangeState';
+
parent::__construct($config);
}
@@ -381,6 +384,11 @@ public function save($data)
if (parent::save($data))
{
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('actionlog', 'tjucm');
+ $isNew = ($data['id'] != 0) ? false : true;
+ $dispatcher->trigger('tjUcmOnAfterTypeSave', array($data, $isNew));
+
return true;
}
diff --git a/src/components/com_tjucm/plugins/actionlog/tjfield/index.html b/src/components/com_tjucm/plugins/actionlog/tjfield/index.html
new file mode 100644
index 00000000..2efb97f3
--- /dev/null
+++ b/src/components/com_tjucm/plugins/actionlog/tjfield/index.html
@@ -0,0 +1 @@
+
diff --git a/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.php b/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.php
new file mode 100644
index 00000000..b4cbab21
--- /dev/null
+++ b/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.php
@@ -0,0 +1,249 @@
+
+ * @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\Plugin\CMSPlugin;
+use Joomla\CMS\Factory;
+use Joomla\CMS\MVC\Model\BaseDatabaseModel;
+use Joomla\CMS\Table\Table;
+
+/**
+ * JGive Actions Logging Plugin.
+ *
+ * @since __DEPLOY_VERSION__
+ */
+class PlgActionlogTjfield 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');
+
+ /* @var ActionlogsModelActionlog $model */
+ $model = BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel');
+ $model->addLog($messages, $messageLanguageKey, $context, $userId);
+ }
+
+ /**
+ * On saving/updateting field group data logging method
+ *
+ * Method is called after field group data is stored in the database.
+ * This method logs who created/edited any field group data
+ *
+ * @param Array $fieldGroup Holds the Field Group data
+ * @param Boolean $isNew True if a new report is stored.
+ *
+ * @return void
+ *
+ * @since __DEPLOY_VERSION__
+ */
+ public function tjfieldOnAfterFieldGroupSave($fieldGroup,$isNew)
+ {
+ if ($isNew)
+ {
+ if (!$this->params->get('logActionForFieldGroupSave', 1))
+ {
+ return;
+ }
+ }
+ else
+ {
+ if (!$this->params->get('logActionForFieldGroupUpdate', 1))
+ {
+ return;
+ }
+ }
+
+ $context = JFactory::getApplication()->input->get('option');
+
+ $user = JFactory::getUser();
+
+ if ($isNew)
+ {
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_GROUP_CREATED';
+ $action = 'add';
+ }
+ else
+ {
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_GROUP_UPDATED';
+ $action = 'update';
+ }
+
+ $message = array(
+ 'action' => $action,
+ 'id' => $fieldGroup['fieldGroupId'],
+ 'title' => ucfirst($fieldGroup['title']),
+ 'itemlink' => 'index.php?option=com_tjfields&&view=group&layout=edit&id=' . $fieldGroup['fieldGroupId'] . '&client=' . $fieldGroup['client'],
+ 'userid' => $user->id,
+ 'username' => $user->username,
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ }
+
+ /**
+ * On saving field group data logging method
+ *
+ * Method is called after field group data is stored in the database.
+ * This method logs who created/edited any field group data
+ *
+ * @param Array $pk Holds the Field Group data
+ * @param Boolean $value True if a new report is stored.
+ *
+ * @return void
+ *
+ * @since __DEPLOY_VERSION__
+ */
+ public function tjfieldOnAfterFieldGroupChangeState($pk, $value)
+ {
+ if (!$this->params->get('logActionForFieldGroupStateChange', 1))
+ {
+ return;
+ }
+
+ $context = JFactory::getApplication()->input->get('option');
+
+ $user = JFactory::getUser();
+
+ switch ($value)
+ {
+ case 0:
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_GROUP_UNPUBLISHED';
+ $action = 'unpublish';
+ break;
+ case 1:
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_GROUP_PUBLISHED';
+ $action = 'publish';
+ break;
+ default:
+ $messageLanguageKey = '';
+ $action = '';
+ break;
+ }
+
+ $tjfieldsTablegroup = Table::getInstance('group', 'TjfieldsTable', array());
+ $tjfieldsTablegroup->load(array('id' => $pk));
+
+ $message = array(
+ 'action' => $action,
+ 'id' => $tjfieldsTablegroup->id,
+ 'title' => ucfirst($tjfieldsTablegroup->title),
+ 'itemlink' => 'index.php?option=com_tjfields&&view=group&layout=edit&id=' . $tjfieldsTablegroup->id . '&client=' . $tjfieldsTablegroup->client,
+ 'userid' => $user->id,
+ 'username' => $user->username,
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $userId);
+ }
+
+
+
+
+
+
+
+
+
+ /**
+ * On saving field data logging method
+ *
+ * Method is called after field data is stored in the database.
+ * This method logs who created/edited any field group data
+ *
+ * @param Array $field Holds the Field data
+ * @param Boolean $isNew True if a new report is stored.
+ *
+ * @return void
+ *
+ * @since __DEPLOY_VERSION__
+ */
+ public function tjfieldOnAfterFieldSave($field, $fieldGroupID, $typeID, $isNew)
+ {
+ if (!$this->params->get('logActionForFieldSave', 1))
+ {
+ return;
+ }
+
+ $context = JFactory::getApplication()->input->get('option');
+
+ $user = JFactory::getUser();
+ $tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
+ $tjucmTableType->load(array('id' => $typeID));
+
+ if ($isNew)
+ {
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_CREATED';
+ $action = 'add';
+ }
+ else
+ {
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_UPDATED';
+ $action = 'update';
+ }
+
+ // User X has created field PQR under type ABC
+ $message = array(
+ 'action' => $action,
+ 'id' => $field->id,
+ 'title' => ucfirst($field->title),
+ 'type' => $tjucmTableType->title,
+ 'itemlink' => 'index.php?option=com_tjfield&task=field.edit&id=' . $field->id,
+ 'userid' => $user->id,
+ 'username' => $user->username,
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+
+ }
+}
diff --git a/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.xml b/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.xml
new file mode 100644
index 00000000..36da6c54
--- /dev/null
+++ b/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.xml
@@ -0,0 +1,58 @@
+
+
+ PLG_ACTIONLOG_TJFIELD
+ Techjoomla
+ 14th Septmber 2019
+ Copyright (C) 2012 - 2019 Techjoomla. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ extensions@techjoomla.com
+ https://techjoomla.com
+ 1.0.0
+ PLG_ACTIONLOG_TJFIELD_XML_DESCRIPTION
+
+ tjfield.php
+ index.html
+
+
+ en-GB/en-GB.plg_actionlog_tjfield.ini
+ en-GB/en-GB.plg_actionlog_tjfield.sys.ini
+
+
+
+
+
+
+
diff --git a/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield_Kishori.php b/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield_Kishori.php
new file mode 100644
index 00000000..6d40b899
--- /dev/null
+++ b/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield_Kishori.php
@@ -0,0 +1,126 @@
+
+ * @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\Plugin\CMSPlugin;
+use Joomla\CMS\Factory;
+use Joomla\CMS\MVC\Model\BaseDatabaseModel;
+
+/**
+ * JGive Actions Logging Plugin.
+ *
+ * @since __DEPLOY_VERSION__
+ */
+class PlgActionlogTjfield 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');
+
+ /* @var ActionlogsModelActionlog $model */
+ $model = BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel');
+ $model->addLog($messages, $messageLanguageKey, $context, $userId);
+ }
+
+ /**
+ * On saving field data logging method
+ *
+ * Method is called after field data is stored in the database.
+ * This method logs who created/edited any field group data
+ *
+ * @param Array $field Holds the Field data
+ * @param Boolean $isNew True if a new report is stored.
+ *
+ * @return void
+ *
+ * @since __DEPLOY_VERSION__
+ */
+ public function tjfieldOnAfterFieldSave($field, $fieldGroupID, $typeID, $isNew)
+ {
+ if (!$this->params->get('logActionForFieldSave', 1))
+ {
+ return;
+ }
+
+ $context = JFactory::getApplication()->input->get('option');
+
+ $user = JFactory::getUser();
+ $tjucmTableType = Table::getInstance('type', 'TjucmTablet', array());
+ $tjucmTableType->load(array('id' => $typeID));
+
+ if ($isNew)
+ {
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_CREATED';
+ $action = 'add';
+ }
+ else
+ {
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_UPDATED';
+ $action = 'update';
+ }
+
+ // User X has created field PQR under type ABC
+ $message = array(
+ 'action' => $action,
+ 'id' => $field->id,
+ 'title' => ucfirst($field->title),
+ 'type' => $tjucmTableType->title,
+ 'itemlink' => 'index.php?option=com_tjfield&task=field.edit&id=' . $field->id,
+ 'userid' => $user->id,
+ 'username' => $user->username,
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+
+ }
+}
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/index.html b/src/components/com_tjucm/plugins/actionlog/tjucm/index.html
new file mode 100644
index 00000000..2efb97f3
--- /dev/null
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/index.html
@@ -0,0 +1 @@
+
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini b/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
new file mode 100644
index 00000000..09c4ab26
--- /dev/null
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
@@ -0,0 +1,26 @@
+; @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_TYPE_ADDED="User {username} added a new UCM type {title} of client \"{identifier}\" "
+PLG_ACTIONLOG_TJUCM_TYPE_UPDATED="User {username} updated the UCM type {title} of client \"{identifier}\" "
+PLG_ACTIONLOG_TJUCM_TYPE_DELETED="User {username} deleted the UCM type \"{title}\" of client \"{identifier}\" "
+PLG_ACTIONLOGS_TJUCM_TYPE_UNPUBLISHED="User {username} unpublished the UCM type {title} of client \"{identifier}\" "
+PLG_ACTIONLOGS_TJUCM_TYPE_PUBLISHED="User {username} published the UCM type {title} of client \"{identifier}\" "
+PLG_ACTIONLOGS_TJUCM_TYPE_ARCHIVED="User {username} archived the UCM type {title} of client \"{identifier}\" "
+PLG_ACTIONLOGS_TJUCM_TYPE_TRASHED="User {username} trashed the UCM type {title} of client \"{identifier}\" "
+PLG_ACTIONLOG_TJUCM_TYPE_EXPORTED="User {username} exported the UCM type {title} of client \"{identifier}\" "
+PLG_ACTIONLOG_TJUCM_TYPE_IMPORTED="User {username} imported the UCM type {title} of client \"{identifier}\" "
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.sys.ini b/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.sys.ini
new file mode 100644
index 00000000..5511d868
--- /dev/null
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.sys.ini
@@ -0,0 +1,8 @@
+; @package Jgive
+; @subpackage Actionlog.jgive
+; @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_JGIVE="Action Log - JGive"
+PLG_ACTIONLOG_JGIVE_XML_DESCRIPTION="Record the actions of users on the site for extension JGive so they can be reviewed if required."
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
new file mode 100644
index 00000000..5494472d
--- /dev/null
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -0,0 +1,322 @@
+
+ * @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\Plugin\CMSPlugin;
+use Joomla\CMS\Factory;
+use Joomla\CMS\MVC\Model\BaseDatabaseModel;
+use Joomla\CMS\Table\Table;
+
+/**
+ * JGive 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');
+
+ /* @var ActionlogsModelActionlog $model */
+ $model = BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel');
+ $model->addLog($messages, $messageLanguageKey, $context, $userId);
+ }
+
+ /**
+ * On saving UCM type data - logging method
+ *
+ * Method is called after user data is stored in the database.
+ * This method logs who created/edited any data of UCM type
+ *
+ * @param Object $type Holds the report data
+ * @param Boolean $isNew True if a new report 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['id'],
+ 'title' => $type['title'],
+ 'identifier' => $type['unique_identifier'],
+ 'itemlink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $type['id'],
+ 'userid' => $user->id,
+ 'username' => $user->username,
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ }
+
+ /**
+ * On deleting UCM type data - logging method
+ *
+ * Method is called after user data is stored in the database.
+ * This method logs who created/edited UCM type ,user's data
+ *
+ * @param string $context com_jticketing.
+ * @param Object $type 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' => $user->username,
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ }
+
+ /**
+ * On deleting UCM type data - logging method
+ *
+ * Method is called after user data is stored in the database.
+ * This method logs who created/edited UCM type ,user's data
+ *
+ * @param Object $pks Holds the UCM type data.
+ *
+ * @return void
+ *
+ * @since __DEPLOY__VERSION__
+ */
+ public function tjUcmOnAfterTypeImport($pks)
+ {
+ if (!$this->params->get('logActionForTypeImport', 1) || !$pks)
+ {
+ return;
+ }
+
+ $context = Factory::getApplication()->input->get('option');
+ $user = Factory::getUser();
+
+ $tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
+ $tjucmTableType->load(array('id' => $pk));
+
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_TYPE_IMPORTED';
+ $message = array(
+ 'action' => 'import',
+ 'id' => $tjucmTableType->id,
+ 'title' => $tjucmTableType->title,
+ 'identifier' => $tjucmTableType->unique_identifier,
+ 'itemlink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $tjucmTableType->id,
+ 'userid' => $user->id,
+ 'username' => $user->username,
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ }
+
+ /**
+ * On deleting UCM type data - logging method
+ *
+ * Method is called after user data is stored in the database.
+ * This method logs who created/edited UCM type ,user's data
+ *
+ * @param Object $pks Holds the UCM type data.
+ *
+ * @return void
+ *
+ * @since __DEPLOY__VERSION__
+ */
+ public function tjUcmOnAfterTypeExport($pks)
+ {
+ if (!$this->params->get('logActionForTypeExport', 1))
+ {
+ return;
+ }
+
+ $context = Factory::getApplication()->input->get('option');
+ $jUser = Factory::getUser();
+ $userId = $jUser->id;
+ $userName = $jUser->username;
+
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_TYPE_EXPORTED';
+
+ $tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
+
+ 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 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_jgive
+ * @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;
+ }
+
+ $tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
+
+ $context = Factory::getApplication()->input->get('option');
+ $jUser = Factory::getUser();
+ $userId = $jUser->id;
+ $userName = $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);
+ }
+ }
+}
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.xml b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.xml
new file mode 100644
index 00000000..ac64ca75
--- /dev/null
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.xml
@@ -0,0 +1,53 @@
+
+
+ PLG_ACTIONLOG_TJUCM
+ Techjoomla
+ 14th sept 2019
+ Copyright (C) 2009 - 2019 Techjoomla. All rights reserved.
+ http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
+ extensions@techjoomla.com
+ https://techjoomla.com
+ 2.2.3
+ 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
+
+
+
+
+
+
+
From 4430f7cd96b219c990ab1016ba6e651dbe550c1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Mon, 16 Sep 2019 17:14:56 +0530
Subject: [PATCH 02/15] feat : Task #150647 tjucm plugin
---
.../plugins/actionlog/tjfield/index.html | 1 -
.../plugins/actionlog/tjfield/tjfield.php | 249 ------------------
.../plugins/actionlog/tjfield/tjfield.xml | 58 ----
.../actionlog/tjfield/tjfield_Kishori.php | 126 ---------
4 files changed, 434 deletions(-)
delete mode 100644 src/components/com_tjucm/plugins/actionlog/tjfield/index.html
delete mode 100644 src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.php
delete mode 100644 src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.xml
delete mode 100644 src/components/com_tjucm/plugins/actionlog/tjfield/tjfield_Kishori.php
diff --git a/src/components/com_tjucm/plugins/actionlog/tjfield/index.html b/src/components/com_tjucm/plugins/actionlog/tjfield/index.html
deleted file mode 100644
index 2efb97f3..00000000
--- a/src/components/com_tjucm/plugins/actionlog/tjfield/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.php b/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.php
deleted file mode 100644
index b4cbab21..00000000
--- a/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.php
+++ /dev/null
@@ -1,249 +0,0 @@
-
- * @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\Plugin\CMSPlugin;
-use Joomla\CMS\Factory;
-use Joomla\CMS\MVC\Model\BaseDatabaseModel;
-use Joomla\CMS\Table\Table;
-
-/**
- * JGive Actions Logging Plugin.
- *
- * @since __DEPLOY_VERSION__
- */
-class PlgActionlogTjfield 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');
-
- /* @var ActionlogsModelActionlog $model */
- $model = BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel');
- $model->addLog($messages, $messageLanguageKey, $context, $userId);
- }
-
- /**
- * On saving/updateting field group data logging method
- *
- * Method is called after field group data is stored in the database.
- * This method logs who created/edited any field group data
- *
- * @param Array $fieldGroup Holds the Field Group data
- * @param Boolean $isNew True if a new report is stored.
- *
- * @return void
- *
- * @since __DEPLOY_VERSION__
- */
- public function tjfieldOnAfterFieldGroupSave($fieldGroup,$isNew)
- {
- if ($isNew)
- {
- if (!$this->params->get('logActionForFieldGroupSave', 1))
- {
- return;
- }
- }
- else
- {
- if (!$this->params->get('logActionForFieldGroupUpdate', 1))
- {
- return;
- }
- }
-
- $context = JFactory::getApplication()->input->get('option');
-
- $user = JFactory::getUser();
-
- if ($isNew)
- {
- $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_GROUP_CREATED';
- $action = 'add';
- }
- else
- {
- $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_GROUP_UPDATED';
- $action = 'update';
- }
-
- $message = array(
- 'action' => $action,
- 'id' => $fieldGroup['fieldGroupId'],
- 'title' => ucfirst($fieldGroup['title']),
- 'itemlink' => 'index.php?option=com_tjfields&&view=group&layout=edit&id=' . $fieldGroup['fieldGroupId'] . '&client=' . $fieldGroup['client'],
- 'userid' => $user->id,
- 'username' => $user->username,
- 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
- );
-
- $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
- }
-
- /**
- * On saving field group data logging method
- *
- * Method is called after field group data is stored in the database.
- * This method logs who created/edited any field group data
- *
- * @param Array $pk Holds the Field Group data
- * @param Boolean $value True if a new report is stored.
- *
- * @return void
- *
- * @since __DEPLOY_VERSION__
- */
- public function tjfieldOnAfterFieldGroupChangeState($pk, $value)
- {
- if (!$this->params->get('logActionForFieldGroupStateChange', 1))
- {
- return;
- }
-
- $context = JFactory::getApplication()->input->get('option');
-
- $user = JFactory::getUser();
-
- switch ($value)
- {
- case 0:
- $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_GROUP_UNPUBLISHED';
- $action = 'unpublish';
- break;
- case 1:
- $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_GROUP_PUBLISHED';
- $action = 'publish';
- break;
- default:
- $messageLanguageKey = '';
- $action = '';
- break;
- }
-
- $tjfieldsTablegroup = Table::getInstance('group', 'TjfieldsTable', array());
- $tjfieldsTablegroup->load(array('id' => $pk));
-
- $message = array(
- 'action' => $action,
- 'id' => $tjfieldsTablegroup->id,
- 'title' => ucfirst($tjfieldsTablegroup->title),
- 'itemlink' => 'index.php?option=com_tjfields&&view=group&layout=edit&id=' . $tjfieldsTablegroup->id . '&client=' . $tjfieldsTablegroup->client,
- 'userid' => $user->id,
- 'username' => $user->username,
- 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
- );
-
- $this->addLog(array($message), $messageLanguageKey, $context, $userId);
- }
-
-
-
-
-
-
-
-
-
- /**
- * On saving field data logging method
- *
- * Method is called after field data is stored in the database.
- * This method logs who created/edited any field group data
- *
- * @param Array $field Holds the Field data
- * @param Boolean $isNew True if a new report is stored.
- *
- * @return void
- *
- * @since __DEPLOY_VERSION__
- */
- public function tjfieldOnAfterFieldSave($field, $fieldGroupID, $typeID, $isNew)
- {
- if (!$this->params->get('logActionForFieldSave', 1))
- {
- return;
- }
-
- $context = JFactory::getApplication()->input->get('option');
-
- $user = JFactory::getUser();
- $tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
- $tjucmTableType->load(array('id' => $typeID));
-
- if ($isNew)
- {
- $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_CREATED';
- $action = 'add';
- }
- else
- {
- $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_UPDATED';
- $action = 'update';
- }
-
- // User X has created field PQR under type ABC
- $message = array(
- 'action' => $action,
- 'id' => $field->id,
- 'title' => ucfirst($field->title),
- 'type' => $tjucmTableType->title,
- 'itemlink' => 'index.php?option=com_tjfield&task=field.edit&id=' . $field->id,
- 'userid' => $user->id,
- 'username' => $user->username,
- 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
- );
-
- $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
-
- }
-}
diff --git a/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.xml b/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.xml
deleted file mode 100644
index 36da6c54..00000000
--- a/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- PLG_ACTIONLOG_TJFIELD
- Techjoomla
- 14th Septmber 2019
- Copyright (C) 2012 - 2019 Techjoomla. All rights reserved.
- http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
- extensions@techjoomla.com
- https://techjoomla.com
- 1.0.0
- PLG_ACTIONLOG_TJFIELD_XML_DESCRIPTION
-
- tjfield.php
- index.html
-
-
- en-GB/en-GB.plg_actionlog_tjfield.ini
- en-GB/en-GB.plg_actionlog_tjfield.sys.ini
-
-
-
-
-
-
-
diff --git a/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield_Kishori.php b/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield_Kishori.php
deleted file mode 100644
index 6d40b899..00000000
--- a/src/components/com_tjucm/plugins/actionlog/tjfield/tjfield_Kishori.php
+++ /dev/null
@@ -1,126 +0,0 @@
-
- * @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\Plugin\CMSPlugin;
-use Joomla\CMS\Factory;
-use Joomla\CMS\MVC\Model\BaseDatabaseModel;
-
-/**
- * JGive Actions Logging Plugin.
- *
- * @since __DEPLOY_VERSION__
- */
-class PlgActionlogTjfield 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');
-
- /* @var ActionlogsModelActionlog $model */
- $model = BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel');
- $model->addLog($messages, $messageLanguageKey, $context, $userId);
- }
-
- /**
- * On saving field data logging method
- *
- * Method is called after field data is stored in the database.
- * This method logs who created/edited any field group data
- *
- * @param Array $field Holds the Field data
- * @param Boolean $isNew True if a new report is stored.
- *
- * @return void
- *
- * @since __DEPLOY_VERSION__
- */
- public function tjfieldOnAfterFieldSave($field, $fieldGroupID, $typeID, $isNew)
- {
- if (!$this->params->get('logActionForFieldSave', 1))
- {
- return;
- }
-
- $context = JFactory::getApplication()->input->get('option');
-
- $user = JFactory::getUser();
- $tjucmTableType = Table::getInstance('type', 'TjucmTablet', array());
- $tjucmTableType->load(array('id' => $typeID));
-
- if ($isNew)
- {
- $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_CREATED';
- $action = 'add';
- }
- else
- {
- $messageLanguageKey = 'PLG_ACTIONLOG_TJFIELD_FIELD_UPDATED';
- $action = 'update';
- }
-
- // User X has created field PQR under type ABC
- $message = array(
- 'action' => $action,
- 'id' => $field->id,
- 'title' => ucfirst($field->title),
- 'type' => $tjucmTableType->title,
- 'itemlink' => 'index.php?option=com_tjfield&task=field.edit&id=' . $field->id,
- 'userid' => $user->id,
- 'username' => $user->username,
- 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
- );
-
- $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
-
- }
-}
From 4fa7d1a9e07cc5f76b5082871bedc7be8f09b585 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Mon, 16 Sep 2019 18:21:07 +0530
Subject: [PATCH 03/15] feat : Task #150647 tjucm plugin
---
src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index 5494472d..ffe750ae 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -132,7 +132,7 @@ public function tjUcmOnAfterTypeSave($type, $isNew)
* This method logs who created/edited UCM type ,user's data
*
* @param string $context com_jticketing.
- * @param Object $type Holds the coupon data.
+ * @param Object $table Holds the coupon data.
*
* @return void
*
@@ -185,7 +185,7 @@ public function tjUcmOnAfterTypeImport($pks)
$user = Factory::getUser();
$tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
- $tjucmTableType->load(array('id' => $pk));
+ $tjucmTableType->load(array('id' => $pks));
$messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_TYPE_IMPORTED';
$message = array(
From 13259e026fc12ad8f80ecc35609fe64d23e69167 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Mon, 16 Sep 2019 18:25:31 +0530
Subject: [PATCH 04/15] feat : Task #150647 tjucm plugin
---
src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index ffe750ae..b5e4fac9 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -235,7 +235,7 @@ public function tjUcmOnAfterTypeExport($pks)
$tjucmTableType->load(array('id' => $pk));
$message = array(
- 'action' => $action,
+ /*'action' => $action,*/
'id' => $tjucmTableType->id,
'title' => $tjucmTableType->title,
'identifier' => $tjucmTableType->unique_identifier,
From a32dd70307d4d2a0f7af494b000f0cc5fe2b60e9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Wed, 18 Sep 2019 12:28:01 +0530
Subject: [PATCH 05/15] Task #150647 feat : tjucm actionlog plugin
---
src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index b5e4fac9..ffe750ae 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -235,7 +235,7 @@ public function tjUcmOnAfterTypeExport($pks)
$tjucmTableType->load(array('id' => $pk));
$message = array(
- /*'action' => $action,*/
+ 'action' => $action,
'id' => $tjucmTableType->id,
'title' => $tjucmTableType->title,
'identifier' => $tjucmTableType->unique_identifier,
From ca5df2e88aec632a04a864f43dd051ce078a29c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Wed, 18 Sep 2019 12:35:51 +0530
Subject: [PATCH 06/15] Task #150647 feat : tjucm actionlog plugin
---
src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index ffe750ae..8214628b 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -67,7 +67,7 @@ protected function addLog($messages, $messageLanguageKey, $context, $userId = nu
{
JLoader::register('ActionlogsModelActionlog', JPATH_ADMINISTRATOR . '/components/com_actionlogs/models/actionlog.php');
- /* @var ActionlogsModelActionlog $model */
+ // ActionlogsModelActionlog
$model = BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel');
$model->addLog($messages, $messageLanguageKey, $context, $userId);
}
@@ -185,6 +185,7 @@ public function tjUcmOnAfterTypeImport($pks)
$user = Factory::getUser();
$tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
+
$tjucmTableType->load(array('id' => $pks));
$messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_TYPE_IMPORTED';
@@ -235,7 +236,6 @@ public function tjUcmOnAfterTypeExport($pks)
$tjucmTableType->load(array('id' => $pk));
$message = array(
- 'action' => $action,
'id' => $tjucmTableType->id,
'title' => $tjucmTableType->title,
'identifier' => $tjucmTableType->unique_identifier,
From 3de0c57a721e4b3f39ff79ea53f20f6e9580b7d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Wed, 18 Sep 2019 12:50:48 +0530
Subject: [PATCH 07/15] Task #150647 feat : tjucm actionlog plugin
---
src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index 8214628b..740ee047 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -67,7 +67,6 @@ protected function addLog($messages, $messageLanguageKey, $context, $userId = nu
{
JLoader::register('ActionlogsModelActionlog', JPATH_ADMINISTRATOR . '/components/com_actionlogs/models/actionlog.php');
- // ActionlogsModelActionlog
$model = BaseDatabaseModel::getInstance('Actionlog', 'ActionlogsModel');
$model->addLog($messages, $messageLanguageKey, $context, $userId);
}
From c7a85442189edafe0d15a4ed72dedd3a9224de00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Wed, 18 Sep 2019 14:18:06 +0530
Subject: [PATCH 08/15] Task techjoomla#196 feat : tjucm actionlog plugin
---
.../plugins/actionlog/tjucm/tjucm.php | 43 +++++++++++--------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index 740ee047..358f6f34 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -163,8 +163,7 @@ public function tjUcmOnAfterTypeDelete($context, $table)
/**
* On deleting UCM type data - logging method
- *
- * Method is called after user data is stored in the database.
+ * Method is called after user data is stored in the database
* This method logs who created/edited UCM type ,user's data
*
* @param Object $pks Holds the UCM type data.
@@ -188,7 +187,10 @@ public function tjUcmOnAfterTypeImport($pks)
$tjucmTableType->load(array('id' => $pks));
$messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_TYPE_IMPORTED';
- $message = array(
+
+ if ($tjucmTableType != null)
+ {
+ $message = array(
'action' => 'import',
'id' => $tjucmTableType->id,
'title' => $tjucmTableType->title,
@@ -198,8 +200,8 @@ public function tjUcmOnAfterTypeImport($pks)
'username' => $user->username,
'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
);
-
- $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ }
}
/**
@@ -230,21 +232,24 @@ public function tjUcmOnAfterTypeExport($pks)
$tjucmTableType = Table::getInstance('type', 'TjucmTable', array());
- foreach ($pks as $pk)
+ if ($tjucmTableType != null)
{
- $tjucmTableType->load(array('id' => $pk));
-
- $message = array(
- '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);
+ foreach ($pks as $pk)
+ {
+ $tjucmTableType->load(array('id' => $pk));
+
+ $message = array(
+ '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);
+ }
}
}
From c54ed527557678b8c8305f064fa59b7f5ea4249f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Thu, 19 Sep 2019 15:33:28 +0530
Subject: [PATCH 09/15] Task #196 feat : tjucm actionlog plugin
---
.../en-GB/en-GB.plg_actionlog_tjucm.ini | 16 +++++++--------
.../plugins/actionlog/tjucm/tjucm.php | 20 +++++++++----------
2 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini b/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
index 09c4ab26..3d2f45ef 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
@@ -15,12 +15,12 @@ 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_TYPE_ADDED="User {username} added a new UCM type {title} of client \"{identifier}\" "
-PLG_ACTIONLOG_TJUCM_TYPE_UPDATED="User {username} updated the UCM type {title} of client \"{identifier}\" "
-PLG_ACTIONLOG_TJUCM_TYPE_DELETED="User {username} deleted the UCM type \"{title}\" of client \"{identifier}\" "
-PLG_ACTIONLOGS_TJUCM_TYPE_UNPUBLISHED="User {username} unpublished the UCM type {title} of client \"{identifier}\" "
-PLG_ACTIONLOGS_TJUCM_TYPE_PUBLISHED="User {username} published the UCM type {title} of client \"{identifier}\" "
+PLG_ACTIONLOG_TJUCM_TYPE_ADDED="User {username} added a new UCM type \"{title}\" "
+PLG_ACTIONLOG_TJUCM_TYPE_UPDATED="User {username} updated the UCM type {title} "
+PLG_ACTIONLOG_TJUCM_TYPE_DELETED="User {username} deleted the UCM type \"{title}\" "
+PLG_ACTIONLOGS_TJUCM_TYPE_UNPUBLISHED="User {username} unpublished the UCM type {title} "
+PLG_ACTIONLOGS_TJUCM_TYPE_PUBLISHED="User {username} published the UCM type {title} "
PLG_ACTIONLOGS_TJUCM_TYPE_ARCHIVED="User {username} archived the UCM type {title} of client \"{identifier}\" "
-PLG_ACTIONLOGS_TJUCM_TYPE_TRASHED="User {username} trashed the UCM type {title} of client \"{identifier}\" "
-PLG_ACTIONLOG_TJUCM_TYPE_EXPORTED="User {username} exported the UCM type {title} of client \"{identifier}\" "
-PLG_ACTIONLOG_TJUCM_TYPE_IMPORTED="User {username} imported the UCM type {title} of client \"{identifier}\" "
+PLG_ACTIONLOGS_TJUCM_TYPE_TRASHED="User {username} trashed the UCM type {title} "
+PLG_ACTIONLOG_TJUCM_TYPE_EXPORTED="User {username} exported the UCM type {title} "
+PLG_ACTIONLOG_TJUCM_TYPE_IMPORTED="User {username} imported the UCM type {title} "
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index 358f6f34..f6cb9a1d 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -74,11 +74,11 @@ protected function addLog($messages, $messageLanguageKey, $context, $userId = nu
/**
* On saving UCM type data - logging method
*
- * Method is called after user data is stored in the database.
+ * 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 Object $type Holds the report data
- * @param Boolean $isNew True if a new report is stored.
+ * @param Array $type Holds the ucm type data
+ * @param Boolean $isNew True if a new type is stored.
*
* @return void
*
@@ -114,8 +114,6 @@ public function tjUcmOnAfterTypeSave($type, $isNew)
'action' => $action,
'id' => $type['id'],
'title' => $type['title'],
- 'identifier' => $type['unique_identifier'],
- 'itemlink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $type['id'],
'userid' => $user->id,
'username' => $user->username,
'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
@@ -130,7 +128,7 @@ public function tjUcmOnAfterTypeSave($type, $isNew)
* Method is called after user data is stored in the database.
* This method logs who created/edited UCM type ,user's data
*
- * @param string $context com_jticketing.
+ * @param String $context com_tjucm
* @param Object $table Holds the coupon data.
*
* @return void
@@ -166,7 +164,7 @@ public function tjUcmOnAfterTypeDelete($context, $table)
* Method is called after user data is stored in the database
* This method logs who created/edited UCM type ,user's data
*
- * @param Object $pks Holds the UCM type data.
+ * @param Int $pks Holds the UCM type data.
*
* @return void
*
@@ -210,7 +208,7 @@ public function tjUcmOnAfterTypeImport($pks)
* Method is called after user data is stored in the database.
* This method logs who created/edited UCM type ,user's data
*
- * @param Object $pks Holds the UCM type data.
+ * @param Array $pks Holds the UCM type data.
*
* @return void
*
@@ -259,9 +257,9 @@ public function tjUcmOnAfterTypeExport($pks)
* Method is called after user data is stored in the database.
* This method logs who changed state of UCM type
*
- * @param String $context com_jgive
- * @param array $pks Holds array of primary key.
- * @param int $value Switch case value.
+ * @param String $context com_tjucm
+ * @param Array $pks Holds array of primary key.
+ * @param Int $value Switch case value.
*
* @return void
*
From c3095dbe36273b81d9bea0077521e81dafe4af7d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Thu, 19 Sep 2019 18:14:06 +0530
Subject: [PATCH 10/15] Task #196 feat : tjucm actionlog plugin
---
src/components/com_tjucm/administrator/models/type.php | 2 ++
.../tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini | 4 ++--
src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/components/com_tjucm/administrator/models/type.php b/src/components/com_tjucm/administrator/models/type.php
index 9e7bd02a..55837c5a 100644
--- a/src/components/com_tjucm/administrator/models/type.php
+++ b/src/components/com_tjucm/administrator/models/type.php
@@ -384,6 +384,8 @@ public function save($data)
if (parent::save($data))
{
+ $id = (int) $this->getState($this->getName() . '.id');
+ $data['typeId'] = $id;
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('actionlog', 'tjucm');
$isNew = ($data['id'] != 0) ? false : true;
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini b/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
index 3d2f45ef..ba77dbd2 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
@@ -15,8 +15,8 @@ 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_TYPE_ADDED="User {username} added a new UCM type \"{title}\" "
-PLG_ACTIONLOG_TJUCM_TYPE_UPDATED="User {username} updated the UCM type {title} "
+PLG_ACTIONLOG_TJUCM_TYPE_ADDED="User {username} added a new UCM type {title} "
+PLG_ACTIONLOG_TJUCM_TYPE_UPDATED="User {username} updated the UCM type {title} "
PLG_ACTIONLOG_TJUCM_TYPE_DELETED="User {username} deleted the UCM type \"{title}\" "
PLG_ACTIONLOGS_TJUCM_TYPE_UNPUBLISHED="User {username} unpublished the UCM type {title} "
PLG_ACTIONLOGS_TJUCM_TYPE_PUBLISHED="User {username} published the UCM type {title} "
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index f6cb9a1d..7e9c6e78 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -112,11 +112,12 @@ public function tjUcmOnAfterTypeSave($type, $isNew)
$message = array(
'action' => $action,
- 'id' => $type['id'],
+ 'id' => $type['typeId'],
'title' => $type['title'],
'userid' => $user->id,
'username' => $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);
From 879ea57e4c11edaa0bbd638dbc780c6e7c8be92a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Thu, 19 Sep 2019 18:47:54 +0530
Subject: [PATCH 11/15] Task #196 feat : tjucm actionlog plugin
---
.../com_tjucm/plugins/actionlog/tjucm/tjucm.php | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index 7e9c6e78..07426525 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -189,12 +189,15 @@ public function tjUcmOnAfterTypeImport($pks)
if ($tjucmTableType != null)
{
+ $ucmid = $tjucmTableType->id;
+ $title = $tjucmTableType->title;
+ $unique_identifier = $tjucmTableType->unique_identifier;
$message = array(
'action' => 'import',
- 'id' => $tjucmTableType->id,
- 'title' => $tjucmTableType->title,
- 'identifier' => $tjucmTableType->unique_identifier,
- 'itemlink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $tjucmTableType->id,
+ 'id' => $ucmid,
+ 'title' => $title,
+ 'identifier' => $unique_identifier,
+ 'itemlink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $ucmid,
'userid' => $user->id,
'username' => $user->username,
'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
From 4719fa1e79a45f3f4852d26c571e7d684f0d949c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Thu, 19 Sep 2019 18:57:23 +0530
Subject: [PATCH 12/15] Task #196 feat : tjucm actionlog plugin
---
src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index 07426525..8df212d2 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -189,15 +189,15 @@ public function tjUcmOnAfterTypeImport($pks)
if ($tjucmTableType != null)
{
- $ucmid = $tjucmTableType->id;
+ $ucmId = $tjucmTableType->id;
$title = $tjucmTableType->title;
$unique_identifier = $tjucmTableType->unique_identifier;
$message = array(
'action' => 'import',
- 'id' => $ucmid,
+ 'id' => $ucmId,
'title' => $title,
'identifier' => $unique_identifier,
- 'itemlink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $ucmid,
+ 'itemlink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $ucmId,
'userid' => $user->id,
'username' => $user->username,
'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
From d32ae50f3bf64198330731f1a465bf9c37407601 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Thu, 19 Sep 2019 19:38:35 +0530
Subject: [PATCH 13/15] Task #196 feat : tjucm actionlog plugin
---
.../com_tjucm/plugins/actionlog/tjucm/tjucm.php | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index 8df212d2..7e9c6e78 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -189,15 +189,12 @@ public function tjUcmOnAfterTypeImport($pks)
if ($tjucmTableType != null)
{
- $ucmId = $tjucmTableType->id;
- $title = $tjucmTableType->title;
- $unique_identifier = $tjucmTableType->unique_identifier;
$message = array(
'action' => 'import',
- 'id' => $ucmId,
- 'title' => $title,
- 'identifier' => $unique_identifier,
- 'itemlink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $ucmId,
+ 'id' => $tjucmTableType->id,
+ 'title' => $tjucmTableType->title,
+ 'identifier' => $tjucmTableType->unique_identifier,
+ 'itemlink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $tjucmTableType->id,
'userid' => $user->id,
'username' => $user->username,
'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
From 5bbafe9d6bd620089d530cd4897a4e0467c8f26f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Fri, 11 Oct 2019 17:35:34 +0530
Subject: [PATCH 14/15] Task #150647 feat : tjucm actionlog plugin
---
.../en-GB/en-GB.plg_actionlog_tjucm.ini | 8 ++-
.../plugins/actionlog/tjucm/tjucm.php | 71 ++++++++++++++++++-
.../plugins/actionlog/tjucm/tjucm.xml | 8 +++
.../site/controllers/itemform.json.php | 4 ++
.../com_tjucm/site/models/itemform.php | 8 +++
5 files changed, 95 insertions(+), 4 deletions(-)
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini b/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
index ba77dbd2..28882046 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini
@@ -6,14 +6,15 @@
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_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_TYPE_ADDED="User {username} added a new UCM type {title} "
PLG_ACTIONLOG_TJUCM_TYPE_UPDATED="User {username} updated the UCM type {title} "
@@ -24,3 +25,6 @@ PLG_ACTIONLOGS_TJUCM_TYPE_ARCHIVED="User {username}{username} trashed the UCM type {title} "
PLG_ACTIONLOG_TJUCM_TYPE_EXPORTED="User {username} exported the UCM type {title} "
PLG_ACTIONLOG_TJUCM_TYPE_IMPORTED="User {username} imported the UCM type {title} "
+
+PLG_ACTIONLOG_TJUCM_ITEM_DELETED="User {username} has deleted item \"{id}\" "
+PLG_ACTIONLOG_TJUCM_ITEM_ADDED="User {username} has added item \"{id}\" "
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
index 7e9c6e78..ff1ff88c 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.php
@@ -126,8 +126,7 @@ public function tjUcmOnAfterTypeSave($type, $isNew)
/**
* On deleting UCM type data - logging method
*
- * Method is called after user data is stored in the database.
- * This method logs who created/edited UCM type ,user's data
+ * Method is called after ucm type is deleted in the database.
*
* @param String $context com_tjucm
* @param Object $table Holds the coupon data.
@@ -322,4 +321,72 @@ public function tjUcmOnAfterTypeChangeState($context, $pks, $value)
$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
+ *
+ * @return void
+ *
+ * @since __DEPLOY__VERSION__
+ */
+ public function tjucmOnAfterSaveItem($item)
+ {
+ if (!$this->params->get('tjucmOnAfterSaveItem', 1))
+ {
+ return;
+ }
+
+ $context = Factory::getApplication()->input->get('option');
+ $user = Factory::getUser();
+
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_ITEM_ADDED';
+ $message = array(
+ 'action' => 'add',
+ 'id' => $item,
+ 'userid' => $user->id,
+ 'username' => $user->username,
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $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.
+ *
+ * @return void
+ *
+ * @since __DEPLOY__VERSION__
+ */
+ public function TjUcmOnAfterItemDelete($item)
+ {
+ if (!$this->params->get('TjUcmOnAfterItemDelete', 1))
+ {
+ return;
+ }
+
+ $context = Factory::getApplication()->input->get('option');
+ $user = Factory::getUser();
+
+ $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_ITEM_DELETED';
+ $message = array(
+ 'action' => 'delete',
+ 'id' => $item->content_id,
+ 'userid' => $user->id,
+ 'username' => $user->username,
+ 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id,
+ );
+
+ $this->addLog(array($message), $messageLanguageKey, $context, $user->id);
+ }
+
}
diff --git a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.xml b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.xml
index ac64ca75..eb173073 100644
--- a/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.xml
+++ b/src/components/com_tjucm/plugins/actionlog/tjucm/tjucm.xml
@@ -46,6 +46,14 @@
+
+
+
+
+
+
+
+
diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php
index 25401ab7..64412b6a 100644
--- a/src/components/com_tjucm/site/controllers/itemform.json.php
+++ b/src/components/com_tjucm/site/controllers/itemform.json.php
@@ -168,6 +168,10 @@ public function save($key = null, $urlVar = null)
{
$result['id'] = $model->getState($model->getName() . '.id');
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('actionlog', 'tjucm');
+ $dispatcher->trigger('tjucmOnAfterSaveItem', array($result['id']));
+
echo new JResponseJson($result, Text::_('COM_TJUCM_ITEM_SAVED_SUCCESSFULLY'));
}
else
diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php
index 985cf079..f1dfe434 100644
--- a/src/components/com_tjucm/site/models/itemform.php
+++ b/src/components/com_tjucm/site/models/itemform.php
@@ -1018,6 +1018,14 @@ public function delete($contentId)
if ($table->delete($id) === true)
{
+ JLoader::import('components.com_tjfields.tables.fieldsvalue', JPATH_ADMINISTRATOR);
+ $itemTable = JTable::getInstance('FieldsValue', 'TjfieldsTable', array('dbo', $db));
+ $itemTable->load(array('content_id' => $contentId));
+
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('actionlog', 'tjucm');
+ $dispatcher->trigger('TjUcmOnAfterItemDelete', array($itemTable));
+
$this->deleteExtraFieldsData($id, $table->client);
return $id;
From 0745c6cdf7df7aa7574c8b6507d82788917036bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CRajnish?= <“rajnish_d@techjoomla.com”>
Date: Wed, 16 Oct 2019 18:34:42 +0530
Subject: [PATCH 15/15] Task #150647
---
.../com_tjucm/site/controllers/itemform.json.php | 4 ++--
src/components/com_tjucm/site/models/item.php | 13 +++++++++++--
.../com_tjucm/site/models/itemform.php | 16 ++++++++++++++--
src/components/com_tjucm/site/models/items.php | 6 +++---
4 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php
index 64412b6a..37da5085 100644
--- a/src/components/com_tjucm/site/controllers/itemform.json.php
+++ b/src/components/com_tjucm/site/controllers/itemform.json.php
@@ -168,9 +168,9 @@ public function save($key = null, $urlVar = null)
{
$result['id'] = $model->getState($model->getName() . '.id');
- $dispatcher = JDispatcher::getInstance();
+ /*$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('actionlog', 'tjucm');
- $dispatcher->trigger('tjucmOnAfterSaveItem', array($result['id']));
+ $dispatcher->trigger('tjucmOnAfterSaveItem', array($result['id']));*/
echo new JResponseJson($result, Text::_('COM_TJUCM_ITEM_SAVED_SUCCESSFULLY'));
}
diff --git a/src/components/com_tjucm/site/models/item.php b/src/components/com_tjucm/site/models/item.php
index 02e31596..5fc3cb0a 100644
--- a/src/components/com_tjucm/site/models/item.php
+++ b/src/components/com_tjucm/site/models/item.php
@@ -109,7 +109,7 @@ protected function populateState()
* @param integer $pk The id of the item.
*
* @return object|boolean|JException Menu item data object on success, boolean false or JException instance on error
- *
+ *
* @since _DEPLOY_VERSION_
*/
public function getItem($pk = null)
@@ -359,7 +359,16 @@ public function publish(&$id, $state = 1)
$table->draft = $state == 1 ? 0 : 1;
$table->state = $state;
- return $table->store();
+ if ($table->store())
+ {
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('actionlog', 'tjucm');
+ $dispatcher->trigger('tjUcmOnAfterItemChangeState', array($id,$state));
+
+ return true;
+ }
+
+ return false;
}
/**
diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php
index f1dfe434..ea00867e 100644
--- a/src/components/com_tjucm/site/models/itemform.php
+++ b/src/components/com_tjucm/site/models/itemform.php
@@ -646,7 +646,19 @@ public function save($data)
}
}
- return parent::save($data);
+ if (parent::save($data))
+ {
+ $id = (int) $this->getState($this->getName() . '.id');
+ $data['itemId'] = $id;
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('actionlog', 'tjucm');
+ $isNew = ($data['id'] != 0) ? false : true;
+ $dispatcher->trigger('tjucmOnAfterSaveItem', array($data, $isNew));
+
+ return true;
+ }
+
+ return false;
}
/**
@@ -1024,7 +1036,7 @@ public function delete($contentId)
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('actionlog', 'tjucm');
- $dispatcher->trigger('TjUcmOnAfterItemDelete', array($itemTable));
+ $dispatcher->trigger('tjUcmOnAfterItemDelete', array($itemTable));
$this->deleteExtraFieldsData($id, $table->client);
diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php
index 62a62ecf..da7e4166 100644
--- a/src/components/com_tjucm/site/models/items.php
+++ b/src/components/com_tjucm/site/models/items.php
@@ -93,7 +93,7 @@ protected function populateState($ordering = "a.id", $direction = "DESC")
foreach ($fields as $field)
{
$filterValue = $app->getUserStateFromRequest($this->context . '.' . $field->name, $field->name, '', 'STRING');
- $this->setState('filter.field.' . $field->name, $filterValue);
+ $this->setState('filter.field.' . $field->name, $filterValue);
}
if (empty($ucmType))
@@ -272,7 +272,7 @@ protected function getListQuery()
else
{
// If no search results found then do not return any record
- $query->where($db->quoteName('a.id') . '=0');
+ $query->where($db->quoteName('a.id') . '=0');
}
}
@@ -363,7 +363,7 @@ private function filterContent()
$query->where($db->quoteName('fv'.$filterFieldsCount.'.value') . ' LIKE ' . $db->q('%' . $search . '%'));
$filterApplied = 1;
- }
+ }
// For filterable fields
JLoader::import('components.com_tjfields.models.fields', JPATH_ADMINISTRATOR);