commit
7ae6726241
|
@ -697,6 +697,7 @@ class CSV extends Importer {
|
||||||
remove_action( 'post_updated', 'wp_save_post_revision' );
|
remove_action( 'post_updated', 'wp_save_post_revision' );
|
||||||
$collections = $this->get_collections();
|
$collections = $this->get_collections();
|
||||||
$collection_definition = isset($collections[$collection_index]) ? $collections[$collection_index] : false;
|
$collection_definition = isset($collections[$collection_index]) ? $collections[$collection_index] : false;
|
||||||
|
|
||||||
if ( !$collection_definition || !is_array($collection_definition) || !isset($collection_definition['id']) || !isset($collection_definition['mapping']) ) {
|
if ( !$collection_definition || !is_array($collection_definition) || !isset($collection_definition['id']) || !isset($collection_definition['mapping']) ) {
|
||||||
$this->add_error_log('Collection misconfigured');
|
$this->add_error_log('Collection misconfigured');
|
||||||
return false;
|
return false;
|
||||||
|
@ -712,7 +713,7 @@ class CSV extends Importer {
|
||||||
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
||||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||||
|
$special_columns = false;
|
||||||
|
|
||||||
$itemMetadataArray = [];
|
$itemMetadataArray = [];
|
||||||
|
|
||||||
|
@ -731,7 +732,7 @@ class CSV extends Importer {
|
||||||
$item = new Entities\Item();
|
$item = new Entities\Item();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( is_numeric($this->get_transient('item_id')) ) {
|
if ( is_numeric($this->get_transient('item_id')) ) {
|
||||||
if ( $item instanceof Entities\Item && $item->get_id() == $this->get_transient('item_id') ) {
|
if ( $item instanceof Entities\Item && $item->get_id() == $this->get_transient('item_id') ) {
|
||||||
if ( ! $item->can_edit() ) {
|
if ( ! $item->can_edit() ) {
|
||||||
$this->add_error_log("You don't have permission to edit item:" . $item->get_id() );
|
$this->add_error_log("You don't have permission to edit item:" . $item->get_id() );
|
||||||
|
@ -748,12 +749,12 @@ class CSV extends Importer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $this->get_transient('item_id') && $item instanceof Entities\Item && is_numeric($item->get_id()) && $item->get_id() > 0 && $this->get_transient('item_action') == 'ignore' ){
|
if ( $this->get_transient('item_id') && $item instanceof Entities\Item && is_numeric($item->get_id()) && $item->get_id() > 0 && $this->get_transient('item_action') == 'ignore' ){
|
||||||
$this->add_log('Ignoring repeated Item');
|
$this->add_log('Ignoring repeated Item');
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( is_array( $processed_item ) ) {
|
if ( is_array( $processed_item ) ) {
|
||||||
foreach ( $processed_item as $metadatum_source => $values ) {
|
foreach ( $processed_item as $metadatum_source => $values ) {
|
||||||
|
|
||||||
if ($metadatum_source == 'special_document' ||
|
if ($metadatum_source == 'special_document' ||
|
||||||
|
@ -820,7 +821,17 @@ class CSV extends Importer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (!empty( $itemMetadataArray ) || $special_columns) && $collection instanceof Entities\Collection ) {
|
if ( !( $collection instanceof Entities\Collection ) ) {
|
||||||
|
$this->add_error_log( 'Collection not set');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( empty( $itemMetadataArray ) && !$special_columns ) ) {
|
||||||
|
$this->add_log( 'Found one empty value' );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$item->set_collection( $collection );
|
$item->set_collection( $collection );
|
||||||
if ( !$updating_item ) {
|
if ( !$updating_item ) {
|
||||||
if( $item->validate() ) {
|
if( $item->validate() ) {
|
||||||
|
@ -833,8 +844,10 @@ class CSV extends Importer {
|
||||||
} else {
|
} else {
|
||||||
$insertedItem = $item;
|
$insertedItem = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$wpdb->query( 'SET autocommit = 0;' );
|
$wpdb->query( 'SET autocommit = 0;' );
|
||||||
|
|
||||||
foreach ( $itemMetadataArray as $itemMetadata ) {
|
foreach ( $itemMetadataArray as $itemMetadata ) {
|
||||||
if($itemMetadata instanceof Entities\Item_Metadata_Entity ) {
|
if($itemMetadata instanceof Entities\Item_Metadata_Entity ) {
|
||||||
$itemMetadata->set_item( $insertedItem ); // *I told you
|
$itemMetadata->set_item( $insertedItem ); // *I told you
|
||||||
|
@ -881,7 +894,7 @@ class CSV extends Importer {
|
||||||
$insertedItem->set_status('publish' );
|
$insertedItem->set_status('publish' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if($insertedItem->validate()) {
|
if ( $insertedItem->validate() ) {
|
||||||
$insertedItem = $Tainacan_Items->update( $insertedItem );
|
$insertedItem = $Tainacan_Items->update( $insertedItem );
|
||||||
$this->after_inserted_item( $insertedItem, $collection_index );
|
$this->after_inserted_item( $insertedItem, $collection_index );
|
||||||
} else {
|
} else {
|
||||||
|
@ -891,10 +904,6 @@ class CSV extends Importer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $insertedItem;
|
return $insertedItem;
|
||||||
} else {
|
|
||||||
$this->add_error_log( 'Collection not set');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function is_assoc(array $arr) {
|
private function is_assoc(array $arr) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ Tags: museums, archives, GLAM, collections, repository
|
||||||
Requires at least: 5.9
|
Requires at least: 5.9
|
||||||
Tested up to: 6.5
|
Tested up to: 6.5
|
||||||
Requires PHP: 7.0
|
Requires PHP: 7.0
|
||||||
Stable tag: 0.21.6
|
Stable tag: 0.21.7
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
|
|
@ -5,17 +5,17 @@ Plugin URI: https://tainacan.org/
|
||||||
Description: Open source, powerful and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional repository platform.
|
Description: Open source, powerful and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional repository platform.
|
||||||
Author: Tainacan.org
|
Author: Tainacan.org
|
||||||
Author URI: https://tainacan.org/
|
Author URI: https://tainacan.org/
|
||||||
Version: 0.21.6
|
Version: 0.21.7
|
||||||
Requires at least: 5.9
|
Requires at least: 5.9
|
||||||
Tested up to: 6.5
|
Tested up to: 6.5
|
||||||
Requires PHP: 7.0
|
Requires PHP: 7.0
|
||||||
Stable tag: 0.21.6
|
Stable tag: 0.21.7
|
||||||
Text Domain: tainacan
|
Text Domain: tainacan
|
||||||
License: GPLv2 or later
|
License: GPLv2 or later
|
||||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const TAINACAN_VERSION = '0.21.6';
|
const TAINACAN_VERSION = '0.21.7';
|
||||||
|
|
||||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||||
$TAINACAN_BASE_URL = plugins_url('', __FILE__);
|
$TAINACAN_BASE_URL = plugins_url('', __FILE__);
|
||||||
|
|
Loading…
Reference in New Issue