From 50802e16255aa3466f51b5126a2bd2e598489c8b Mon Sep 17 00:00:00 2001 From: MeghaBiranje <58220237+MeghaBiranje@users.noreply.github.com> Date: Fri, 19 Jun 2020 15:04:14 +0530 Subject: [PATCH 1/4] Bug #162401 Fix: Warning on com_tjcertificate edit template view (#18) --- .../com_tjcertificate/administrator/models/template.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjcertificate/administrator/models/template.php b/src/components/com_tjcertificate/administrator/models/template.php index 26233d0b..5a99a472 100644 --- a/src/components/com_tjcertificate/administrator/models/template.php +++ b/src/components/com_tjcertificate/administrator/models/template.php @@ -184,14 +184,15 @@ protected function populateState() /** * Method to validate the form data. * - * @param \JForm $form The form to validate against. + * @param JForm $form The form to validate against. * @param Array $data The data to validate. + * @param string $group The name of the field group to validate. * * @return array|boolean Array of filtered data if valid, false otherwise. * * @since 12.2 */ - public function validate($form, $data) + public function validate($form, $data, $group = null) { $return = true; $return = parent::validate($form, $data); From 2652d87368d310adffbd27b490530fbc3a5a6195 Mon Sep 17 00:00:00 2001 From: poonam_b Date: Tue, 11 Aug 2020 10:54:09 +0530 Subject: [PATCH 2/4] Task #163911: Added cols client issued to and client issued to name --- .../administrator/libraries/certificate.php | 81 +++++++++++++++++-- .../administrator/models/certificates.php | 8 ++ .../administrator/sql/install.mysql.utf8.sql | 2 + .../administrator/sql/updates/mysql/1.0.1.sql | 2 + 4 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 src/components/com_tjcertificate/administrator/sql/updates/mysql/1.0.1.sql diff --git a/src/components/com_tjcertificate/administrator/libraries/certificate.php b/src/components/com_tjcertificate/administrator/libraries/certificate.php index d4fb1474..c2d2e9b2 100644 --- a/src/components/com_tjcertificate/administrator/libraries/certificate.php +++ b/src/components/com_tjcertificate/administrator/libraries/certificate.php @@ -41,6 +41,10 @@ class TjCertificateCertificate extends CMSObject private $client_id = 0; + private $client_issued_to = 0; + + private $client_issued_to_name = ""; + private $user_id = 0; public $state = 1; @@ -148,6 +152,58 @@ public function getClientId() return $this->client_id; } + /** + * Set client issued to + * + * @param integer $value Value to set client issued to. + * + * @return void. + * + * @since __DEPLOY_VERSION__ + */ + public function setClientIssuedTo($value = 0) + { + $this->client_issued_to = $value; + } + + /** + * Get client issued to + * + * @return string Client issued to. + * + * @since __DEPLOY_VERSION__ + */ + public function getClientIssuedTo() + { + return $this->client_issued_to; + } + + /** + * Set client issued to name + * + * @param string $value Value to set client issued to name. + * + * @return void. + * + * @since __DEPLOY_VERSION__ + */ + public function setClientIssuedToName($value = "") + { + $this->client_issued_to_name = $value; + } + + /** + * Get client issued to name + * + * @return string Client issued to name. + * + * @since __DEPLOY_VERSION__ + */ + public function getClientIssuedToName() + { + return $this->client_issued_to_name; + } + /** * Set User Id * @@ -432,21 +488,23 @@ public function bind(&$array) /** * Method to get issued certificate list * - * @param string $client Client e.g. com_tjlms.course + * @param string $client Client e.g. com_tjlms.course * - * @param integer $clientId Specific client id + * @param integer $clientId Specific client id * - * @param integer $userId User Id + * @param integer $userId User Id * - * @param boolean $expired Get expired certificates + * @param boolean $expired Get expired certificates + * + * @param boolean $clientIssuedTo Client issued to * * @return boolean|array Issued certificate array * * @since 1.0 */ - public static function getIssued($client, $clientId, $userId, $expired = false) + public static function getIssued($client, $clientId, $userId = 0, $expired = false, $clientIssuedTo = 0) { - if (empty($client) || empty($clientId) || empty($userId)) + if (empty($client) || empty($clientId)) { return false; } @@ -455,7 +513,16 @@ public static function getIssued($client, $clientId, $userId, $expired = false) $model->setState('filter.client', $client); $model->setState('filter.client_id', $clientId); - $model->setState('filter.user_id', $userId); + + if (!empty($userId)) + { + $model->setState('filter.user_id', $userId); + } + + if ($clientIssuedTo) + { + $model->setState('filter.client_issued_to', $clientIssuedTo); + } if ($expired) { diff --git a/src/components/com_tjcertificate/administrator/models/certificates.php b/src/components/com_tjcertificate/administrator/models/certificates.php index 96a099d1..6039421a 100644 --- a/src/components/com_tjcertificate/administrator/models/certificates.php +++ b/src/components/com_tjcertificate/administrator/models/certificates.php @@ -137,6 +137,14 @@ protected function getListQuery() $query->where($db->quoteName('ci.user_id') . ' = ' . (int) $userId); } + // Filter by client issued to + $clientIssuedTo = $this->getState('filter.client_issued_to'); + + if (!empty($clientIssuedTo)) + { + $query->where($db->quoteName('ci.client_issued_to') . ' = ' . (int) $clientIssuedTo); + } + // Filter by search in title. $search = $this->getState('filter.search'); diff --git a/src/components/com_tjcertificate/administrator/sql/install.mysql.utf8.sql b/src/components/com_tjcertificate/administrator/sql/install.mysql.utf8.sql index 28345089..d5b51fee 100644 --- a/src/components/com_tjcertificate/administrator/sql/install.mysql.utf8.sql +++ b/src/components/com_tjcertificate/administrator/sql/install.mysql.utf8.sql @@ -26,6 +26,8 @@ CREATE TABLE IF NOT EXISTS `#__tj_certificate_issue` ( `generated_body` text NOT NULL, `client` varchar(100) NOT NULL, `client_id` int(11) NOT NULL, + `client_issued_to` int(11) NOT NULL, + `client_issued_to_name` varchar(400) COLLATE utf8mb4_unicode_ci NOT NULL, `user_id` int(11) NOT NULL, `comment` text NULL, `state` tinyint(3) NOT NULL, diff --git a/src/components/com_tjcertificate/administrator/sql/updates/mysql/1.0.1.sql b/src/components/com_tjcertificate/administrator/sql/updates/mysql/1.0.1.sql new file mode 100644 index 00000000..6e41e6d6 --- /dev/null +++ b/src/components/com_tjcertificate/administrator/sql/updates/mysql/1.0.1.sql @@ -0,0 +1,2 @@ +ALTER TABLE `#__tj_certificate_issue` ADD `client_issued_to` int(11) NOT NULL AFTER `user_id`; +ALTER TABLE `#__tj_certificate_issue` ADD `client_issued_to_name` varchar(400) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `client_issued_to`; From 0f48aacd8855cb2e7d363b01047fa6c9fded1a05 Mon Sep 17 00:00:00 2001 From: poonam_b Date: Mon, 17 Aug 2020 15:13:27 +0530 Subject: [PATCH 3/4] Task #163911: Added cols client issued to and client issued to name --- .../administrator/libraries/certificate.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/com_tjcertificate/administrator/libraries/certificate.php b/src/components/com_tjcertificate/administrator/libraries/certificate.php index c2d2e9b2..3fae0adf 100644 --- a/src/components/com_tjcertificate/administrator/libraries/certificate.php +++ b/src/components/com_tjcertificate/administrator/libraries/certificate.php @@ -509,6 +509,11 @@ public static function getIssued($client, $clientId, $userId = 0, $expired = fal return false; } + if (empty($userId) && empty($clientIssuedTo)) + { + return false; + } + $model = TJCERT::model('Certificates', array('ignore_request' => true)); $model->setState('filter.client', $client); From c3edf9bdcee6aca1aba9f237949a61eb973a2123 Mon Sep 17 00:00:00 2001 From: poonam_b Date: Wed, 9 Sep 2020 20:14:26 +0530 Subject: [PATCH 4/4] Task #163911: Added cols client issued to and client issued to name --- src/components/com_tjcertificate/tjcertificate.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjcertificate/tjcertificate.xml b/src/components/com_tjcertificate/tjcertificate.xml index 583bbee1..606eb45f 100644 --- a/src/components/com_tjcertificate/tjcertificate.xml +++ b/src/components/com_tjcertificate/tjcertificate.xml @@ -8,7 +8,7 @@ extensions@techjoomla.com http://techjoomla.com - 1.0.0 + 1.0.1