diff --git a/src/com_tjvendors/admin/controllers/vendors.php b/src/com_tjvendors/admin/controllers/vendors.php index 6e4d32a2..14362b0b 100755 --- a/src/com_tjvendors/admin/controllers/vendors.php +++ b/src/com_tjvendors/admin/controllers/vendors.php @@ -11,6 +11,8 @@ // No direct access. defined('_JEXEC') or die; +use Joomla\CMS\Session\Session; + jimport('joomla.application.component.controlleradmin'); /** @@ -45,6 +47,9 @@ public function getModel($name = 'vendor', $prefix = 'TjvendorsModel', $config = */ public function delete() { + // Check for request forgeries + Session::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + $input = JFactory::getApplication()->input; $client = $input->get('client', '', 'STRING'); $cid = JFactory::getApplication()->input->get('cid', array(), 'array'); diff --git a/src/com_tjvendors/admin/helpers/tjvendors.php b/src/com_tjvendors/admin/helpers/tjvendors.php index f1dc03c0..bfac1e8b 100644 --- a/src/com_tjvendors/admin/helpers/tjvendors.php +++ b/src/com_tjvendors/admin/helpers/tjvendors.php @@ -10,6 +10,8 @@ // No direct access defined('_JEXEC') or die; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Factory; /** * Tjvendors helper. @@ -278,18 +280,20 @@ public static function getClients($vendor_id) /** * Get get unique Currency * - * @param string $currency integer + * @param string $currency integer * - * @param string $vendor_id integer + * @param string $vendor_id integer + * + * @param string $client integer * - * @param string $client integer + * @param integer $id tjvendors_fee * * @return boolean */ - public static function checkUniqueCurrency($currency, $vendor_id, $client) + public static function checkUniqueCurrency($currency, $vendor_id, $client, $id) { - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true); $query->select($db->quoteName('currency')); $query->from($db->quoteName('#__tjvendors_fee')); @@ -304,6 +308,12 @@ public static function checkUniqueCurrency($currency, $vendor_id, $client) $query->where($db->quoteName('client') . ' = ' . $db->quote($client)); } + // If site admin wants to edit the commission + if ($id) + { + $query->where($db->quoteName('id') . ' = ' . (int) $id); + } + $db->setQuery($query); try @@ -312,19 +322,30 @@ public static function checkUniqueCurrency($currency, $vendor_id, $client) } catch (Exception $e) { - JFactory::getApplication()->enqueueMessage(JText::_('COM_TJVENDORS_DB_EXCEPTION_WARNING_MESSAGE'), 'error'); + Factory::getApplication()->enqueueMessage(Text::_('COM_TJVENDORS_DB_EXCEPTION_WARNING_MESSAGE'), 'error'); } - foreach ($currencies as $i) + if (!empty($currencies)) { - if ($currency == $i['currency']) + // If site admin want to edit the commission with same id, currency, client and same vendor id + if ($id && count($currencies) == 1) { - return false; - break; + return true; } else { - continue; + foreach ($currencies as $i) + { + if ($currency == $i['currency']) + { + return false; + break; + } + else + { + continue; + } + } } } diff --git a/src/com_tjvendors/admin/models/forms/payout.xml b/src/com_tjvendors/admin/models/forms/payout.xml index 067c4d3f..f4572cb8 100644 --- a/src/com_tjvendors/admin/models/forms/payout.xml +++ b/src/com_tjvendors/admin/models/forms/payout.xml @@ -8,8 +8,8 @@ - - + + diff --git a/src/com_tjvendors/admin/models/forms/vendorfee.xml b/src/com_tjvendors/admin/models/forms/vendorfee.xml index b9a41a56..ccdac2da 100644 --- a/src/com_tjvendors/admin/models/forms/vendorfee.xml +++ b/src/com_tjvendors/admin/models/forms/vendorfee.xml @@ -1,12 +1,61 @@
- - - - - - - + + + + + + + + + + +
diff --git a/src/com_tjvendors/admin/models/vendorfee.php b/src/com_tjvendors/admin/models/vendorfee.php index eb7d7cab..96aa1ab7 100644 --- a/src/com_tjvendors/admin/models/vendorfee.php +++ b/src/com_tjvendors/admin/models/vendorfee.php @@ -10,6 +10,8 @@ // No direct access. defined('_JEXEC') or die; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Factory; jimport('joomla.application.component.modeladmin'); @@ -122,7 +124,6 @@ protected function loadFormData() $this->item = $this->getItem(); } - $this->item->currency_unchange = $this->item->currency; $data = $this->item; } @@ -134,20 +135,32 @@ protected function loadFormData() * * @param Array $data Data * - * @return id + * @return boolean true or false */ public function save($data) { - $isNew = (empty($data['id']))? true : false; - $app = JFactory::getApplication(); - $table = $this->getTable(); - $db = JFactory::getDbo(); + $app = Factory::getApplication(); + $isNew = (empty($data['id']))? true : false; + + if ($isNew && empty($data['currency'])) + { + $this->setError(Text::_('COM_TJVENDORS_VENDORFEE_INVALID_CURRENCY')); + + return false; + } + $input = $app->input; $data['vendor_id'] = $input->get('vendor_id', '', 'INTEGER'); - $uniqueCurrency = TjvendorsHelper::checkUniqueCurrency($data['currency'], $data['vendor_id'], $data['client']); + $uniqueCurrency = TjvendorsHelper::checkUniqueCurrency($data['currency'], $data['vendor_id'], $data['client'], $data['id']); - if (!empty($uniqueCurrency)) + if ($uniqueCurrency) { + // While editing the fees don't allow to edit currency + if ($data['id']) + { + unset($data['currency']); + } + if (parent::save($data)) { if (empty($data['id'])) @@ -164,7 +177,7 @@ public function save($data) } else { - $app->enqueueMessage(JText::_('COM_TJVENDORS_VENDORFEE_DUPLICATE_CURRENCY'), 'error'); + $this->setError(Text::_('COM_TJVENDORS_VENDORFEE_DUPLICATE_CURRENCY')); } return false; diff --git a/src/com_tjvendors/admin/tables/vendor.php b/src/com_tjvendors/admin/tables/vendor.php index 54ec97f9..cefa35fb 100644 --- a/src/com_tjvendors/admin/tables/vendor.php +++ b/src/com_tjvendors/admin/tables/vendor.php @@ -219,6 +219,10 @@ public function check() } $filename = JFile::stripExt($singleFile['name']); + + // Strip unwanted characters + $filename = JFile::makeSafe($filename); + $extension = JFile::getExt($singleFile['name']); $fileType = $singleFile['type']; $filename = md5(time()) . $filename; diff --git a/src/com_tjvendors/admin/views/vendorfee/tmpl/edit.php b/src/com_tjvendors/admin/views/vendorfee/tmpl/edit.php index 5812d973..d0f0a70c 100644 --- a/src/com_tjvendors/admin/views/vendorfee/tmpl/edit.php +++ b/src/com_tjvendors/admin/views/vendorfee/tmpl/edit.php @@ -30,15 +30,16 @@
form->renderField('vendor_title'); + if($this->item->vendor_id == 0) { - echo $this->form->renderField('vendor_title'); echo $this->form->renderField('currency'); } else { - echo $this->form->renderField('vendor_title'); - echo $this->form->renderField('currency_unchange'); + $this->form->setFieldAttribute('currency', 'readonly', 'true'); + echo $this->form->renderField('currency'); ?> COM_TJVENDORS - 22nd Oct 2019 - Copyright (C) 2016 - 2019 Techjoomla. All rights reserved. + 20th Jan 2020 + Copyright (C) 2016 - 2020 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL Techjoomla extensions@techjoomla.com https://techjoomla.com - 1.3.4 + 1.3.5 COM_TJVENDORS_PRODUCT_DESC diff --git a/src/plugins/actionlog/tjvendors/tjvendors.xml b/src/plugins/actionlog/tjvendors/tjvendors.xml index 13f97f63..ae87bad0 100644 --- a/src/plugins/actionlog/tjvendors/tjvendors.xml +++ b/src/plugins/actionlog/tjvendors/tjvendors.xml @@ -2,12 +2,12 @@ plg_actionlog_tjvendors Techjoomla - 22nd Oct 2019 - Copyright (C) 2016 - 2019 Techjoomla. All rights reserved. + 20th Jan 2020 + Copyright (C) 2016 - 2020 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL extensions@techjoomla.com https://techjoomla.com - 1.3.4 + 1.3.5 PLG_ACTIONLOG_TJVENDORS_XML_DESCRIPTION tjvendors.php diff --git a/src/plugins/privacy/tjvendors/tjvendors.xml b/src/plugins/privacy/tjvendors/tjvendors.xml index b67a05c3..9a2d76f4 100644 --- a/src/plugins/privacy/tjvendors/tjvendors.xml +++ b/src/plugins/privacy/tjvendors/tjvendors.xml @@ -1,12 +1,12 @@ plg_privacy_tjvendors - 1.3.4 - 22nd Oct 2019 + 1.3.5 + 20th Jan 2020 Techjoomla extensions@techjoomla.com https://techjoomla.com - Copyright (C) 2016 - 2019 Techjoomla. All rights reserved. + Copyright (C) 2016 - 2020 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL PLG_PRIVACY_TJVENDORS_XML_DESCRIPTION