mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2024-06-03 15:00:48 +00:00
Merge pull request #9 from richard67/4.0-dev-joomdonation-4.0-compatible-mod-1
Real null values for datetimes and checked out user for weblinks 4.0
This commit is contained in:
commit
c1f3652257
|
@ -114,11 +114,11 @@ class Com_WeblinksInstallerScript
|
||||||
$category->metadesc = '';
|
$category->metadesc = '';
|
||||||
$category->metakey = '';
|
$category->metakey = '';
|
||||||
$category->language = '*';
|
$category->language = '*';
|
||||||
$category->checked_out_time = Factory::getDbo()->getNullDate();
|
$category->checked_out_time = null;
|
||||||
$category->version = 1;
|
$category->version = 1;
|
||||||
$category->hits = 0;
|
$category->hits = 0;
|
||||||
$category->modified_user_id = 0;
|
$category->modified_user_id = 0;
|
||||||
$category->checked_out = 0;
|
$category->checked_out = null;
|
||||||
|
|
||||||
// Set the location in the tree
|
// Set the location in the tree
|
||||||
$category->setLocation(1, 'last-child');
|
$category->setLocation(1, 'last-child');
|
||||||
|
|
|
@ -19,24 +19,24 @@ CREATE TABLE IF NOT EXISTS `#__weblinks` (
|
||||||
`description` text NOT NULL,
|
`description` text NOT NULL,
|
||||||
`hits` int NOT NULL DEFAULT 0,
|
`hits` int NOT NULL DEFAULT 0,
|
||||||
`state` tinyint NOT NULL DEFAULT 0,
|
`state` tinyint NOT NULL DEFAULT 0,
|
||||||
`checked_out` int NOT NULL DEFAULT 0,
|
`checked_out` int unsigned,
|
||||||
`checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`checked_out_time` datetime,
|
||||||
`ordering` int NOT NULL DEFAULT 0,
|
`ordering` int NOT NULL DEFAULT 0,
|
||||||
`access` int NOT NULL DEFAULT 1,
|
`access` int NOT NULL DEFAULT 1,
|
||||||
`params` text NOT NULL,
|
`params` text NOT NULL,
|
||||||
`language` char(7) NOT NULL DEFAULT '',
|
`language` char(7) NOT NULL DEFAULT '',
|
||||||
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`created` datetime NOT NULL,
|
||||||
`created_by` int unsigned NOT NULL DEFAULT 0,
|
`created_by` int unsigned NOT NULL DEFAULT 0,
|
||||||
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
|
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
|
||||||
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`modified` datetime NOT NULL,
|
||||||
`modified_by` int unsigned NOT NULL DEFAULT 0,
|
`modified_by` int unsigned NOT NULL DEFAULT 0,
|
||||||
`metakey` text NOT NULL,
|
`metakey` text NOT NULL,
|
||||||
`metadesc` text NOT NULL,
|
`metadesc` text NOT NULL,
|
||||||
`metadata` text NOT NULL,
|
`metadata` text NOT NULL,
|
||||||
`featured` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Set if link is featured.',
|
`featured` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Set if link is featured.',
|
||||||
`xreference` varchar(50) NOT NULL COMMENT 'A reference to enable linkages to external data sets.',
|
`xreference` varchar(50) NOT NULL COMMENT 'A reference to enable linkages to external data sets.',
|
||||||
`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`publish_up` datetime,
|
||||||
`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`publish_down` datetime,
|
||||||
`version` int unsigned NOT NULL DEFAULT 1,
|
`version` int unsigned NOT NULL DEFAULT 1,
|
||||||
`images` text NOT NULL,
|
`images` text NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
|
|
|
@ -17,24 +17,24 @@ CREATE TABLE "#__weblinks" (
|
||||||
"description" text NOT NULL,
|
"description" text NOT NULL,
|
||||||
"hits" bigint DEFAULT 0 NOT NULL,
|
"hits" bigint DEFAULT 0 NOT NULL,
|
||||||
"state" smallint DEFAULT 0 NOT NULL,
|
"state" smallint DEFAULT 0 NOT NULL,
|
||||||
"checked_out" bigint DEFAULT 0 NOT NULL,
|
"checked_out" integer,
|
||||||
"checked_out_time" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
|
"checked_out_time" timestamp without time zone,
|
||||||
"ordering" bigint DEFAULT 0 NOT NULL,
|
"ordering" bigint DEFAULT 0 NOT NULL,
|
||||||
"access" bigint DEFAULT 1 NOT NULL,
|
"access" bigint DEFAULT 1 NOT NULL,
|
||||||
"params" text NOT NULL,
|
"params" text NOT NULL,
|
||||||
"language" varchar(7) DEFAULT '' NOT NULL,
|
"language" varchar(7) DEFAULT '' NOT NULL,
|
||||||
"created" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
|
"created" timestamp without time zone NOT NULL,
|
||||||
"created_by" integer DEFAULT 0 NOT NULL,
|
"created_by" integer DEFAULT 0 NOT NULL,
|
||||||
"created_by_alias" varchar(255) DEFAULT '' NOT NULL,
|
"created_by_alias" varchar(255) DEFAULT '' NOT NULL,
|
||||||
"modified" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
|
"modified" timestamp without time zone NOT NULL,
|
||||||
"modified_by" integer DEFAULT 0 NOT NULL,
|
"modified_by" integer DEFAULT 0 NOT NULL,
|
||||||
"metakey" text NOT NULL,
|
"metakey" text NOT NULL,
|
||||||
"metadesc" text NOT NULL,
|
"metadesc" text NOT NULL,
|
||||||
"metadata" text NOT NULL,
|
"metadata" text NOT NULL,
|
||||||
"featured" smallint DEFAULT 0 NOT NULL,
|
"featured" smallint DEFAULT 0 NOT NULL,
|
||||||
"xreference" varchar(50) NOT NULL,
|
"xreference" varchar(50) NOT NULL,
|
||||||
"publish_up" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
|
"publish_up" timestamp without time zone,
|
||||||
"publish_down" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
|
"publish_down" timestamp without time zone,
|
||||||
"version" bigint DEFAULT 1 NOT NULL,
|
"version" bigint DEFAULT 1 NOT NULL,
|
||||||
"images" text NOT NULL,
|
"images" text NOT NULL,
|
||||||
PRIMARY KEY ("id")
|
PRIMARY KEY ("id")
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
ALTER TABLE `#__weblinks` MODIFY `created` datetime NOT NULL;
|
||||||
|
ALTER TABLE `#__weblinks` MODIFY `modified` datetime NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE `#__weblinks` MODIFY `publish_up` datetime NULL DEFAULT NULL;
|
||||||
|
ALTER TABLE `#__weblinks` MODIFY `publish_down` datetime NULL DEFAULT NULL;
|
||||||
|
ALTER TABLE `#__weblinks` MODIFY `checked_out_time` datetime NULL DEFAULT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE `#__weblinks` MODIFY `checked_out` int unsigned;
|
||||||
|
|
||||||
|
UPDATE `#__weblinks` SET `modified` = `created` WHERE `modified` = '0000-00-00 00:00:00';
|
||||||
|
|
||||||
|
UPDATE `#__weblinks` SET `publish_up` = NULL WHERE `publish_up` = '0000-00-00 00:00:00';
|
||||||
|
UPDATE `#__weblinks` SET `publish_down` = NULL WHERE `publish_down` = '0000-00-00 00:00:00';
|
||||||
|
UPDATE `#__weblinks` SET `checked_out_time` = NULL WHERE `checked_out_time` = '0000-00-00 00:00:00';
|
||||||
|
|
||||||
|
UPDATE `#__weblinks` SET `checked_out` = null WHERE `checked_out` = 0;
|
||||||
|
|
||||||
|
UPDATE `#__categories` SET `modified_time` = `created_time` WHERE `modified_time` = '0000-00-00 00:00:00' AND `extension` = 'com_weblinks';
|
||||||
|
|
||||||
|
UPDATE `#__categories` SET `checked_out_time` = NULL WHERE `checked_out_time` = '0000-00-00 00:00:00' AND `extension` = 'com_weblinks';
|
||||||
|
|
||||||
|
UPDATE `#__ucm_content` SET `core_modified_time` = `core_created_time`
|
||||||
|
WHERE `core_type_alias` IN ('com_weblinks.weblink', 'com_weblinks.category')
|
||||||
|
AND `core_modified_time` = '0000-00-00 00:00:00';
|
||||||
|
|
||||||
|
UPDATE `#__ucm_content` SET `core_publish_up` = NULL
|
||||||
|
WHERE `core_type_alias` = 'com_weblinks.weblink'
|
||||||
|
AND `core_publish_up` = '0000-00-00 00:00:00';
|
||||||
|
UPDATE `#__ucm_content` SET `core_publish_down` = NULL
|
||||||
|
WHERE `core_type_alias` = 'com_weblinks.weblink'
|
||||||
|
AND `core_publish_down` = '0000-00-00 00:00:00';
|
||||||
|
|
||||||
|
UPDATE `#__ucm_content` SET `core_checked_out_time` = NULL
|
||||||
|
WHERE `core_type_alias` IN ('com_weblinks.weblink', 'com_weblinks.category')
|
||||||
|
AND `core_checked_out_time` = '0000-00-00 00:00:00';
|
|
@ -0,0 +1,42 @@
|
||||||
|
ALTER TABLE "#__weblinks" ALTER COLUMN "created" DROP DEFAULT;
|
||||||
|
|
||||||
|
ALTER TABLE "#__weblinks" ALTER COLUMN "modified" DROP DEFAULT;
|
||||||
|
|
||||||
|
ALTER TABLE "#__weblinks" ALTER COLUMN "publish_up" DROP NOT NULL;
|
||||||
|
ALTER TABLE "#__weblinks" ALTER COLUMN "publish_up" DROP DEFAULT;
|
||||||
|
|
||||||
|
ALTER TABLE "#__weblinks" ALTER COLUMN "publish_down" DROP NOT NULL;
|
||||||
|
ALTER TABLE "#__weblinks" ALTER COLUMN "publish_down" DROP DEFAULT;
|
||||||
|
|
||||||
|
ALTER TABLE "#__weblinks" ALTER COLUMN "checked_out_time" DROP NOT NULL;
|
||||||
|
ALTER TABLE "#__weblinks" ALTER COLUMN "checked_out_time" DROP DEFAULT;
|
||||||
|
|
||||||
|
ALTER TABLE "#__weblinks" ALTER COLUMN "checked_out" DROP NOT NULL;
|
||||||
|
ALTER TABLE "#__weblinks" ALTER COLUMN "checked_out" DROP DEFAULT;
|
||||||
|
|
||||||
|
UPDATE "#__weblinks" SET "modified" = "created" WHERE "modified" = '1970-01-01 00:00:00';
|
||||||
|
|
||||||
|
UPDATE "#__weblinks" SET "publish_up" = NULL WHERE "publish_up" = '1970-01-01 00:00:00';
|
||||||
|
UPDATE "#__weblinks" SET "publish_down" = NULL WHERE "publish_down" = '1970-01-01 00:00:00';
|
||||||
|
UPDATE "#__weblinks" SET "checked_out_time" = NULL WHERE "checked_out_time" = '1970-01-01 00:00:00';
|
||||||
|
|
||||||
|
UPDATE "#__weblinks" SET "checked_out" = null WHERE "checked_out" = 0;
|
||||||
|
|
||||||
|
UPDATE "#__categories" SET "modified_time" = "created_time" WHERE "modified_time" = '1970-01-01 00:00:00' AND "extension" = 'com_weblinks';
|
||||||
|
|
||||||
|
UPDATE "#__categories" SET "checked_out_time" = NULL WHERE "checked_out_time" = '1970-01-01 00:00:00' AND "extension" = 'com_weblinks';
|
||||||
|
|
||||||
|
UPDATE "#__ucm_content" SET "core_modified_time" = "core_created_time"
|
||||||
|
WHERE "core_type_alias" IN ('com_weblinks.weblink', 'com_weblinks.category')
|
||||||
|
AND "core_modified_time" = '1970-01-01 00:00:00';
|
||||||
|
|
||||||
|
UPDATE "#__ucm_content" SET "core_publish_up" = NULL
|
||||||
|
WHERE "core_type_alias" = 'com_weblinks.weblink'
|
||||||
|
AND "core_publish_up" = '1970-01-01 00:00:00';
|
||||||
|
UPDATE "#__ucm_content" SET "core_publish_down" = NULL
|
||||||
|
WHERE "core_type_alias" = 'com_weblinks.weblink'
|
||||||
|
AND "core_publish_down" = '1970-01-01 00:00:00';
|
||||||
|
|
||||||
|
UPDATE "#__ucm_content" SET "core_checked_out_time" = NULL
|
||||||
|
WHERE "core_type_alias" IN ('com_weblinks.weblink', 'com_weblinks.category')
|
||||||
|
AND "core_checked_out_time" = '1970-01-01 00:00:00';
|
|
@ -32,6 +32,14 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
||||||
{
|
{
|
||||||
use TaggableTableTrait;
|
use TaggableTableTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Ensure the params and metadata in json encoded in the bind method
|
||||||
*
|
*
|
||||||
|
@ -66,9 +74,9 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
||||||
*
|
*
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
public function store($updateNulls = false)
|
public function store($updateNulls = true)
|
||||||
{
|
{
|
||||||
$date = Factory::getDate();
|
$date = Factory::getDate()->toSql();
|
||||||
$user = Factory::getApplication()->getIdentity();
|
$user = Factory::getApplication()->getIdentity();
|
||||||
|
|
||||||
$this->modified = $date->toSql();
|
$this->modified = $date->toSql();
|
||||||
|
@ -77,6 +85,7 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
||||||
{
|
{
|
||||||
// Existing item
|
// Existing item
|
||||||
$this->modified_by = $user->id;
|
$this->modified_by = $user->id;
|
||||||
|
$this->modified = $date;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -84,7 +93,7 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
||||||
// so we don't touch either of these if they are set.
|
// so we don't touch either of these if they are set.
|
||||||
if (!(int) $this->created)
|
if (!(int) $this->created)
|
||||||
{
|
{
|
||||||
$this->created = $date->toSql();
|
$this->created = $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->created_by))
|
if (empty($this->created_by))
|
||||||
|
@ -92,22 +101,32 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
||||||
$this->created_by = $user->id;
|
$this->created_by = $user->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(int) $this->modified)
|
||||||
|
{
|
||||||
|
$this->modified = $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($this->modified_by))
|
||||||
|
{
|
||||||
|
$this->modified_by = $user->id;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($this->hits))
|
if (empty($this->hits))
|
||||||
{
|
{
|
||||||
$this->hits = 0;
|
$this->hits = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set publish_up to null date if not set
|
// Set publish_up to null if not set
|
||||||
if (!$this->publish_up)
|
if (!$this->publish_up)
|
||||||
{
|
{
|
||||||
$this->publish_up = $this->getDbo()->getNullDate();
|
$this->publish_up = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set publish_down to null date if not set
|
// Set publish_down to null if not set
|
||||||
if (!$this->publish_down)
|
if (!$this->publish_down)
|
||||||
{
|
{
|
||||||
$this->publish_down = $this->getDbo()->getNullDate();
|
$this->publish_down = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the alias is unique
|
// Verify that the alias is unique
|
||||||
|
@ -187,7 +206,7 @@ class WeblinkTable extends Table implements VersionableTableInterface, TaggableT
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the publish down date is not earlier than publish up.
|
// Check the publish down date is not earlier than publish up.
|
||||||
if ($this->publish_down > $db->getNullDate() && $this->publish_down < $this->publish_up)
|
if ((int) $this->publish_down > 0 && $this->publish_down < $this->publish_up)
|
||||||
{
|
{
|
||||||
$this->setError(Text::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
|
$this->setError(Text::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ class HtmlView extends BaseHtmlView
|
||||||
|
|
||||||
$user = $app->getIdentity();
|
$user = $app->getIdentity();
|
||||||
$isNew = ($this->item->id == 0);
|
$isNew = ($this->item->id == 0);
|
||||||
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
|
$checkedOut = $this->item->checked_out && $this->item->checked_out !== $user->get('id');
|
||||||
|
|
||||||
// Since we don't track these assets at the item level, use the category id.
|
// Since we don't track these assets at the item level, use the category id.
|
||||||
$canDo = ContentHelper::getActions('com_weblinks', 'category', $this->item->catid);
|
$canDo = ContentHelper::getActions('com_weblinks', 'category', $this->item->catid);
|
||||||
|
|
|
@ -95,7 +95,7 @@ if ($saveOrder && !empty($this->items))
|
||||||
<?php $item->cat_link = Route::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]=' . $item->catid); ?>
|
<?php $item->cat_link = Route::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]=' . $item->catid); ?>
|
||||||
<?php $canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $item->catid); ?>
|
<?php $canCreate = $user->authorise('core.create', 'com_weblinks.category.' . $item->catid); ?>
|
||||||
<?php $canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $item->catid); ?>
|
<?php $canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $item->catid); ?>
|
||||||
<?php $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; ?>
|
<?php $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || !$item->checked_out; ?>
|
||||||
<?php $canEditOwn = $user->authorise('core.edit.own', 'com_weblinks.category.' . $item->catid) && $item->created_by == $user->id; ?>
|
<?php $canEditOwn = $user->authorise('core.edit.own', 'com_weblinks.category.' . $item->catid) && $item->created_by == $user->id; ?>
|
||||||
<?php $canChange = $user->authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin; ?>
|
<?php $canChange = $user->authorise('core.edit.state', 'com_weblinks.category.' . $item->catid) && $canCheckin; ?>
|
||||||
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->catid; ?>">
|
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->catid; ?>">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user