Skip to content
Permalink
Browse files

Use JCckTableContent instead of JTableContent

  • Loading branch information
sebastienheraud committed Nov 15, 2019
1 parent 0f83305 commit 77d89d27ce6bd12cfeb8fc0a5780b2d63234211c
Showing with 33 additions and 19 deletions.
  1. +19 −0 libraries/cms/cck/table/content.php
  2. +14 −19 plugins/cck_storage_location/joomla_article/joomla_article.php
@@ -0,0 +1,19 @@
<?php
/**
* @version SEBLOD 3.x Core ~ $Id: batch.php sebastienheraud $
* @package SEBLOD (App Builder & CCK) // SEBLOD nano (Form Builder)
* @url https://www.seblod.com
* @editor Octopoos - www.octopoos.com
* @copyright Copyright (C) 2009 - 2018 SEBLOD. All Rights Reserved.
* @license GNU General Public License version 2 or later; see _LICENSE.php
**/
defined( '_JEXEC' ) or die;
JLoader::register( 'JTableContent', JPATH_PLATFORM.'/joomla/database/table/content.php' );
// JCckTableContent
class JCckTableContent extends JTableContent
{
}
?>
@@ -12,15 +12,13 @@
use Joomla\Utilities\ArrayHelper;
JLoader::register( 'JTableContent', JPATH_PLATFORM.'/joomla/database/table/content.php' );
// Plugin
class plgCCK_Storage_LocationJoomla_Article extends JCckPluginLocation
{
protected static $type = 'joomla_article';
protected static $type_alias = 'Article';
protected static $table = '#__content';
protected static $table_object = array( 'Content', 'JTable' );
protected static $table_object = array( 'Content', 'JCckTable' );
protected static $key = 'id';
protected static $access = 'access';
@@ -350,8 +348,9 @@ protected function _core( $data, &$config = array(), $pk = 0 )
// Init
$app = JFactory::getApplication();
$table = self::_getTable( $pk );
$isNew = ( $pk > 0 ) ? false : true;
$rules = '{}';
$table = self::_getTable( $pk );
if ( isset( $table->tags ) ) {
unset( $table->tags );
@@ -373,6 +372,15 @@ protected function _core( $data, &$config = array(), $pk = 0 )
// Prepare
if ( is_array( $data ) ) {
if ( isset( $data['rules'] ) && $data['rules'] ) {
if ( !is_array( $data['rules'] ) ) {
$data['rules'] = json_decode( $data['rules'] );
}
$rules = new JAccessRules( JCckDevHelper::getRules( $data['rules'] ) );
unset( $data['rules'] );
}
if ( $config['task'] == 'save2copy' ) {
$empty = array( self::$key, 'alias', 'created', 'created_by', 'hits', 'modified', 'modified_by', 'version' );
foreach ( $empty as $k ) {
@@ -381,20 +389,7 @@ protected function _core( $data, &$config = array(), $pk = 0 )
}
$table->bind( $data );
}
if ( $isNew && !isset( $data['rules'] ) ) {
$data['rules'] = array(
'core.delete'=>array(),
'core.edit'=>array(),
'core.edit.state'=>array()
);
}
if ( isset( $data['rules'] ) && $data['rules'] ) {
if ( !is_array( $data['rules'] ) ) {
$data['rules'] = json_decode( $data['rules'] );
}
$rules = new JAccessRules( JCckDevHelper::getRules( $data['rules'] ) );
$table->setRules( $rules );
}
$table->setRules( $rules );
$table->check();
self::_completeTable( $table, $data, $config );
@@ -463,7 +458,7 @@ protected function _core( $data, &$config = array(), $pk = 0 )
// _getTable
protected static function _getTable( $pk = 0, $join = false )
{
$table = JTable::getInstance( 'Content' );
$table = JTable::getInstance( 'Content', 'JCckTable' );
if ( $pk > 0 ) {
$table->load( $pk );

0 comments on commit 77d89d2

Please sign in to comment.
You can’t perform that action at this time.