Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions administrator/components/com_contact/Table/ContactTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
*/
class ContactTable extends Table
{

/**
* Indicates that columns fully support the NULL value in the database
*
* @var boolean
* @since __DEPLOY_VERSION__
*/
protected $_supportNullValue = true;

/**
* Ensure the params and metadata in json encoded in the bind method
*
Expand Down Expand Up @@ -58,7 +67,7 @@ public function __construct(DatabaseDriver $db)
*
* @since 1.6
*/
public function store($updateNulls = false)
public function store($updateNulls = true)
{
// Transform the params field
if (is_array($this->params))
Expand Down Expand Up @@ -91,18 +100,6 @@ public function store($updateNulls = false)
}
}

// Set publish_up to null date if not set
if (!$this->publish_up)
{
$this->publish_up = $this->_db->getNullDate();
}

// Set publish_down to null date if not set
if (!$this->publish_down)
{
$this->publish_down = $this->_db->getNullDate();
}

// Set xreference to empty string if not set
if (!$this->xreference)
{
Expand Down Expand Up @@ -253,9 +250,20 @@ public function check()
$this->metadata = '{}';
}

if (empty($this->modified))
// Set publish_up, publish_down, modified to null if not set
if (!$this->publish_up)
{
$this->publish_up = null;
}

if (!$this->publish_down)
{
$this->publish_down = null;
}

if (!$this->modified)
{
$this->modified = $this->getDbo()->getNullDate();
$this->modified = null;
}

return true;
Expand Down
6 changes: 3 additions & 3 deletions components/com_contact/Model/CategoryModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ protected function getListQuery()
$nowDate = $db->quote(Factory::getDate()->toSql());

if ($this->getState('filter.publish_date'))
{
$query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
{
$query->where('(' . $query->isNullDatetime('a.publish_up') . ' OR a.publish_up <= ' . $db->quote($nowDate) . ')')
->where('(' . $query->isNullDatetime('a.publish_down') . ' OR a.publish_down >= ' . $db->quote($nowDate) . ')');
}

// Filter by search in title
Expand Down
4 changes: 2 additions & 2 deletions components/com_contact/Model/ContactModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ public function getItem($pk = null)
if (is_numeric($published))
{
$query->where('(a.published = ' . (int) $published . ' OR a.published =' . (int) $archived . ')')
->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
->where('(' . $query->isNullDatetime('a.publish_up') . ' OR a.publish_up <= ' . $db->quote($nowDate) . ')')
->where('(' . $query->isNullDatetime('a.publish_down') . ' OR a.publish_down >= ' . $db->quote($nowDate) . ')');
}

$db->setQuery($query);
Expand Down
8 changes: 4 additions & 4 deletions installation/sql/mysql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ CREATE TABLE IF NOT EXISTS `#__contact_details` (
`default_con` tinyint(1) unsigned NOT NULL DEFAULT 0,
`published` tinyint(1) NOT NULL DEFAULT 0,
`checked_out` int(10) unsigned NOT NULL DEFAULT 0,
`checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`checked_out_time` datetime,
`ordering` int(11) NOT NULL DEFAULT 0,
`params` text NOT NULL,
`user_id` int(11) NOT NULL DEFAULT 0,
Expand All @@ -298,15 +298,15 @@ CREATE TABLE IF NOT EXISTS `#__contact_details` (
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`created_by` int(10) unsigned NOT NULL DEFAULT 0,
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified` datetime,
`modified_by` int(10) unsigned NOT NULL DEFAULT 0,
`metakey` text NOT NULL,
`metadesc` text NOT NULL,
`metadata` text NOT NULL,
`featured` tinyint(3) unsigned NOT NULL DEFAULT 0 COMMENT 'Set if contact is featured.',
`xreference` varchar(50) NOT NULL DEFAULT '' COMMENT 'A reference to enable linkages to external data sets.',
`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_up` datetime,
`publish_down` datetime,
`version` int(10) unsigned NOT NULL DEFAULT 1,
`hits` int(10) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
Expand Down
8 changes: 4 additions & 4 deletions installation/sql/postgresql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ CREATE TABLE IF NOT EXISTS "#__contact_details" (
"default_con" smallint NOT NULL DEFAULT 0,
"published" smallint NOT NULL DEFAULT 0,
"checked_out" bigint NOT NULL DEFAULT 0,
"checked_out_time" timestamp without time zone NOT NULL DEFAULT '1970-01-01 00:00:00',
"checked_out_time" timestamp without time zone,
"ordering" bigint NOT NULL DEFAULT 0,
"params" text NOT NULL,
"user_id" bigint NOT NULL DEFAULT 0,
Expand All @@ -303,15 +303,15 @@ CREATE TABLE IF NOT EXISTS "#__contact_details" (
"created" timestamp without time zone NOT NULL DEFAULT '1970-01-01 00:00:00',
"created_by" integer NOT NULL DEFAULT 0,
"created_by_alias" varchar(255) NOT NULL DEFAULT '',
"modified" timestamp without time zone NOT NULL DEFAULT '1970-01-01 00:00:00',
"modified" timestamp without time zone,
"modified_by" integer NOT NULL DEFAULT 0,
"metakey" text NOT NULL,
"metadesc" text NOT NULL,
"metadata" text NOT NULL,
"featured" smallint NOT NULL DEFAULT 0,
"xreference" varchar(50) NOT NULL DEFAULT '',
"publish_up" timestamp without time zone NOT NULL DEFAULT '1970-01-01 00:00:00',
"publish_down" timestamp without time zone NOT NULL DEFAULT '1970-01-01 00:00:00',
"publish_up" timestamp without time zone,
"publish_down" timestamp without time zone,
"version" bigint NOT NULL DEFAULT 1,
"hits" bigint NOT NULL DEFAULT 0,
PRIMARY KEY ("id")
Expand Down