Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Php8.1test Issues #361

Open
wants to merge 11 commits into
base: j4x
Choose a base branch
from
115 changes: 115 additions & 0 deletions administrator/houseKeeping/1.4.6/tjVendorsColumn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php
/**
* @package TJ-Fields
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2021 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
*/

// No direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Table\Table;

/**
* Migration file for TJ-Fields
*
* @since 1.4.6
*/
class TjHouseKeepingTjVendorsColumn extends TjModelHouseKeeping
{
public $title = "Country, Region, and City table fix for com_tjvendors";

public $description = "Add com_tjvendors column in Country, Region, and City table";

/**
* Add com_tjvendors column in Country, Region, and City table if not exists
*
* @return void
*
* @since 1.0
*/
public function migrate()
{
$result = array();

try
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "SHOW COLUMNS FROM `#__tj_city`";
$db->setQuery($query);
$columns = $db->loadAssoclist();

$columns = array_column($columns, "Field");

if (!in_array('com_tjvendors', $columns))
{
$query = "ALTER TABLE `#__tj_city` ADD COLUMN `com_tjvendors` tinyint(1) NOT NULL DEFAULT '1'";
$db->setQuery($query);

if (!$db->execute())
{
$result['status'] = false;
$result['message'] = $db->getErrorMsg();

return $result;
}
}

$query = $db->getQuery(true);
$query = "SHOW COLUMNS FROM `#__tj_region`";
$db->setQuery($query);
$columns = $db->loadobjectlist();

$columns = array_column($columns, "Field");

if (!in_array('com_tjvendors', $columns))
{
$query = "ALTER TABLE `#__tj_region` ADD COLUMN `com_tjvendors` tinyint(1) NOT NULL DEFAULT '1'";
$db->setQuery($query);

if (!$db->execute())
{
$result['status'] = false;
$result['message'] = $db->getErrorMsg();

return $result;
}
}

$query = $db->getQuery(true);
$query = "SHOW COLUMNS FROM `#__tj_country`";
$db->setQuery($query);
$columns = $db->loadobjectlist();

$columns = array_column($columns, "Field");

if (!in_array('com_tjvendors', $columns))
{
$query = "ALTER TABLE `#__tj_country` ADD COLUMN `com_tjvendors` tinyint(1) NOT NULL DEFAULT '1'";
$db->setQuery($query);

if (!$db->execute())
{
$result['status'] = false;
$result['message'] = $db->getErrorMsg();

return $result;
}
}

$result['status'] = true;
$result['message'] = "Migration successful";
}
catch (Exception $e)
{
$result['err_code'] = '';
$result['status'] = false;
$result['message'] = $e->getMessage();
}

return $result;
}
}
10 changes: 8 additions & 2 deletions site/helpers/tjfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function FetchDatavalue($data)
$query->join('INNER', $db->qn('#__tjfields_fields', 'f') . ' ON (' .
$db->qn('f.id') . ' = ' . $db->qn('fv.field_id') . ')');

$query->where('fv.content_id=' . $content_id);
$query->where('fv.content_id=' . (int) $content_id);
$query->where('fv.client="' . $client . '" ' . $query_user_string);
$query->where('f.state=' . $db->quote("1"));
$db->setQuery($query);
Expand All @@ -75,6 +75,12 @@ public function FetchDatavalue($data)
{
$fieldParams = json_decode($data->params);
$multipleValueField = (isset($fieldParams->multiple) && !empty($fieldParams->multiple)) ? 1 : 0;

// Initialize $fieldDataValue[$data->field_id] if needed
if (!isset($fieldDataValue[$data->field_id]))
{
$fieldDataValue[$data->field_id] = new stdclass;
}

if ($data->type == "radio" || $data->type == "single_select")
{
Expand All @@ -89,7 +95,7 @@ public function FetchDatavalue($data)
}
else
{
$fieldDataValue[$data->field_id] = new stdclass;

$fieldDataValue[$data->field_id]->value = $data->value;
$fieldDataValue[$data->field_id]->field_id = $data->field_id;
}
Expand Down