diff --git a/src/classes/api/endpoints/class-tainacan-rest-background-processes-controller.php b/src/classes/api/endpoints/class-tainacan-rest-background-processes-controller.php index ffb435a58..2074195d1 100644 --- a/src/classes/api/endpoints/class-tainacan-rest-background-processes-controller.php +++ b/src/classes/api/endpoints/class-tainacan-rest-background-processes-controller.php @@ -249,8 +249,9 @@ class REST_Background_Processes_Controller extends REST_Controller { } public function prepare_item_for_response($item, $request) { - $item->log = $this->get_log_url($item->ID, $item->action); - $item->error_log = $this->get_log_url($item->ID, $item->action, 'error'); + $key_log = $item->bg_uuid ?? $item->ID; + $item->log = $this->get_log_url($key_log, $item->action); + $item->error_log = $this->get_log_url($key_log, $item->action, 'error'); $nonce = wp_create_nonce( 'wp_rest' ); $item->output = str_replace("&_wpnonce=[nonce]", "&_wpnonce=$nonce", $item->output); return $item; diff --git a/src/classes/api/endpoints/class-tainacan-rest-exporters-controller.php b/src/classes/api/endpoints/class-tainacan-rest-exporters-controller.php index 6cae2e0b1..e9ff9e251 100644 --- a/src/classes/api/endpoints/class-tainacan-rest-exporters-controller.php +++ b/src/classes/api/endpoints/class-tainacan-rest-exporters-controller.php @@ -111,7 +111,7 @@ class REST_Exporters_Controller extends REST_Controller { * @throws \Exception */ public function export_permissions_check($request) { - return true; + return current_user_can('manage_tainacan'); } public function get_registered_exporters() { diff --git a/src/classes/api/endpoints/class-tainacan-rest-importers-controller.php b/src/classes/api/endpoints/class-tainacan-rest-importers-controller.php index e45f1b654..5f58e2a7e 100644 --- a/src/classes/api/endpoints/class-tainacan-rest-importers-controller.php +++ b/src/classes/api/endpoints/class-tainacan-rest-importers-controller.php @@ -137,7 +137,7 @@ class REST_Importers_Controller extends REST_Controller { */ public function import_permissions_check($request){ // TODO - return true; + return current_user_can('manage_tainacan'); } /** diff --git a/src/classes/class-tainacan-background-process.php b/src/classes/class-tainacan-background-process.php index 2a5d1c8a9..1f932839d 100644 --- a/src/classes/class-tainacan-background-process.php +++ b/src/classes/class-tainacan-background-process.php @@ -114,7 +114,8 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process { 'action' => $this->action, 'name' => $this->get_name(), 'queued_on' => date('Y-m-d H:i:s'), - 'status' => 'waiting' + 'status' => 'waiting', + 'bg_uuid' => uniqid(), ] ); $this->ID = $wpdb->insert_id; @@ -263,6 +264,7 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process { $batch->key = $query->ID; $batch->data = maybe_unserialize( $query->data ); $batch->status = $query->status; + $batch->bg_uuid = $query->bg_uuid; if ($batch->status != 'running') { $this->open($batch->key); @@ -271,6 +273,33 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process { return $batch; } + + /** + * Get batch by key ID + * + * @return stdClass Return the batch + */ + protected function get_batch_by_key($key) { + global $wpdb; + + $table = $this->table; + + $query = $wpdb->get_row( $wpdb->prepare( " + SELECT * + FROM {$table} + WHERE action = %s + AND ID = %s + LIMIT 1 + ", $this->action, $key ) ); + + $batch = new \stdClass(); + $batch->key = $query->ID; + $batch->data = maybe_unserialize( $query->data ); + $batch->status = $query->status; + $batch->bg_uuid = $query->bg_uuid; + return $batch; + } + /** * Handle * @@ -428,10 +457,14 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process { } protected function write_log($key, $log) { - $this->write_log_to_file($key, $log); + $batch = $this->get_batch_by_key($key); + $key_log = $batch->bg_uuid ?? $key; + $this->write_log_to_file($key_log, $log); } protected function write_error_log($key, $log) { - $this->write_log_to_file($key, $log, 'error'); + $batch = $this->get_batch_by_key($key); + $key_log = $batch->bg_uuid ?? $key; + $this->write_log_to_file($key_log, $log, 'error'); } private function recursive_stingify_log_array(array $log, $break = true) { diff --git a/src/classes/exporter/class-tainacan-exporter.php b/src/classes/exporter/class-tainacan-exporter.php index 91846aab3..62dd95cd6 100644 --- a/src/classes/exporter/class-tainacan-exporter.php +++ b/src/classes/exporter/class-tainacan-exporter.php @@ -695,7 +695,6 @@ abstract class Exporter { $upload_dir_info = wp_upload_dir(); $prefix = $this->get_id(); $upload_dir = trailingslashit( $upload_dir_info['basedir'] ); - // $upload_url = trailingslashit( $upload_dir_info['baseurl'] ); $exporter_folder = 'tainacan/exporter'; $file_suffix = "{$exporter_folder}/{$prefix}_{$key}"; diff --git a/src/migrations.php b/src/migrations.php index 424dff8fb..161362a44 100644 --- a/src/migrations.php +++ b/src/migrations.php @@ -509,6 +509,20 @@ class Migrations { ); } + + static function alter_table_tnc_bg_process_add_uuid() { + global $wpdb; + // update default order by "creation_date" to "date" + $table_name = $wpdb->prefix . 'tnc_bg_process'; + $column_exists = $wpdb->get_results( "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '$table_name' AND column_name = 'bg_uuid'" ); + + if(empty($column_exists)) { + $wpdb->query(" + ALTER TABLE $table_name + ADD bg_uuid text NULL + "); + } + } } diff --git a/src/readme.txt b/src/readme.txt index 4f50e8a45..b8730873e 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -1,21 +1,21 @@ === Tainacan === -Contributors: andrebenedito, daltonmartins, fabianobn, jacsonp, leogermani, weryques, wetah, eduardohumberto, ravipassos, jessicafpx, marinagiolo, omarceloavila, vnmedeiros, tainacan, r-guimaraes, suelanesilva, ccaio, alanargomes, ateneagarcia123, rodrigo0freire, clarandreozzi -Tags: museums, libraries, archives, GLAM, collections, repository +Contributors: andrebenedito, daltonmartins, fabianobn, jacsonp, leogermani, weryques, wetah, eduardohumberto, ravipassos, jessicafpx, marinagiolo, omarceloavila, vnmedeiros, tainacan, suelanesilva, ccaio, alanargomes, ateneagarcia123, rodrigo0freire, clarandreozzi +Tags: museums, archives, GLAM, collections, repository Requires at least: 5.9 Tested up to: 6.4 Requires PHP: 7.0 -Stable tag: 0.20.7 +Stable tag: 0.20.8 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html -Tainacan is an open-source, powerful and flexible digital repository platform for WordPress. With all the tools of a professional repository platform, you can manage and publish your digital collections as easily as posting to your blog. It is versatile and can be used to create a digital collection, a digital library or a digital repository for your institutional or personal collection. +Tainacan is an open-source, powerful and flexible digital repository platform for WordPress. == Description == [Tainacan](https://tainacan.org/) is an [open-source](https://github.com/tainacan/tainacan), powerful and flexible digital repository platform for WordPress. Manage and publish your digital collections just as easily as you post to your blog, having all the tools of a professional repository platform. It can be used for the creation of a digital collection, a digital library or a digital repository for your institutional or personal collection. -Tainacan aims to facilitate the activities of organizing, documenting, disseminating and displaying digital objects based on simple and accessible principles of digital curation. The plugin integrates with the WordPress block engine, making it easy to reuse objects for different and varied uses. +Tainacan aims to facilitate the activities of organizing, documenting, disseminating and displaying digital objects based on simple and accessible principles of digital curation. The plugin integrates with the WordPress block engine, making it easy to reuse objects for different and varied uses. You can manage and publish your digital collections as easily as posting to your blog. It is versatile and can be used to create a digital collection, a digital library or a digital repository for your institutional or personal collection. diff --git a/src/tainacan.php b/src/tainacan.php index 87b9b204e..6a760fd9c 100644 --- a/src/tainacan.php +++ b/src/tainacan.php @@ -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. Author: Tainacan.org Author URI: https://tainacan.org/ -Version: 0.20.7 +Version: 0.20.8 Requires at least: 5.9 Tested up to: 6.4 Requires PHP: 7.0 -Stable tag: 0.20.7 +Stable tag: 0.20.8 Text Domain: tainacan License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html */ -const TAINACAN_VERSION = '0.20.7'; +const TAINACAN_VERSION = '0.20.8'; defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); $TAINACAN_BASE_URL = plugins_url('', __FILE__); diff --git a/src/views/admin/components/navigation/primary-menu.vue b/src/views/admin/components/navigation/primary-menu.vue index 94ef1516c..1914c7647 100644 --- a/src/views/admin/components/navigation/primary-menu.vue +++ b/src/views/admin/components/navigation/primary-menu.vue @@ -103,7 +103,7 @@ {{ $i18n.get('capabilities') }} -
  • +
  • {{ $i18n.get('importers') }}
  • -
  • +