]> 91.132.146.200 Git - insipid.git/commitdiff
documentation for simple import and export
authorBanana <mail@bananas-playground.net>
Tue, 11 Feb 2020 16:00:04 +0000 (17:00 +0100)
committerBanana <mail@bananas-playground.net>
Tue, 11 Feb 2020 16:00:04 +0000 (17:00 +0100)
ChangeLog
documentation/update.txt
documentation/xml-export-and-import.txt [new file with mode: 0644]
webroot/job/email-import.php
webroot/lib/management.class.php

index 421a4ea749903a891c2606aeba9b5ffce41c81a2..2bc85d3f3c05e92494b6ece95d72121600fab695 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@ version x.x - Seven Portals (tba)
 
     + Now including update instructions
     + DB export only insipid tables and not the whole DB itself.
+    + Simple xml export and import
     + #2 Protection if the email-import.php file if it needs to be
         in a web accessible folder
     + Fixed the search for words. See update instructions how to correct your data
index 7f328a5f403c82328a1263085844a48bf78c9b90..773672d4a193b7bb2c0abf80b4281b846ab4e158 100644 (file)
@@ -8,4 +8,6 @@ To validate you can now search for single words case-insensitive.
 
 + Update config file with tow new settings. See config.default for more info
 define('EMAIL_JOB_PROTECT', false);
-define('EMAIL_JOB_PROTECT_SECRET', 'SOME_SECRET_STRING');
\ No newline at end of file
+define('EMAIL_JOB_PROTECT_SECRET', 'SOME_SECRET_STRING');
+
++ All Files in webroot/asset/js/ EXCEPT the new editlink.js can be removed
\ No newline at end of file
diff --git a/documentation/xml-export-and-import.txt b/documentation/xml-export-and-import.txt
new file mode 100644 (file)
index 0000000..60c0b64
--- /dev/null
@@ -0,0 +1,10 @@
+Any link can be exported as a xml file from the link info view.
+Login is required to trigger this function.
+The result can be used to import it again at the stats view.
+
+It exports all the link information, image and its tags and categories.
+
+The import can overwrite existing links and import non existing ones.
+
+A import xml file can contain multiple exports. Make sure the root is
+still there.
\ No newline at end of file
index 4815cfcc0f0ae94f91ed01d093a4ee76a3b7016b..f7db1b631639b10e7d557d0555f3fc33ca1a96a8 100644 (file)
@@ -208,13 +208,14 @@ if(!empty($emails)) {
 
                                if(DEBUG === true) var_dump($newdata);
 
-                $DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
-
                 $linkObj = new Link($DB);
                 $linkID = false;
 
                                # check for duplicate
                 $existing = $linkObj->load($newdata['hash']);
+
+                               $DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
+
                 if(!empty($existing) && isset($existing['id'])) {
                     $linkID = $existing['id'];
                     error_log('INFO Updating existing link with tag or category '.$newdata['link']);
index 697da4ce0b6e905e691ac4129c2dffdf016407a7..08ce708075caa196bf3c30f305d96900f41b55bc 100644 (file)
@@ -718,7 +718,6 @@ class Management {
                return $ret;
        }
 
-
        /**
         * process the given xml file. Based on the export file
         * options are overwrite => true|false
@@ -748,6 +747,8 @@ class Management {
                if(!empty($links)) {
                        $_amount = count($links);
                        foreach($links as $linkToImport) {
+                               $do = false;
+
                                if($this->_linkExistsById($linkToImport['id'])) {
                                        if(isset($options['overwrite']) && $options['overwrite'] === true) {
                                                $linkObj = new Link($this->DB);
@@ -757,8 +758,55 @@ class Management {
                                        $_existing++;
                                }
                                else {
+                                       $linkObj = new Link($this->DB);
+
+                                       $this->DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
+                                       try{
+                                               $do = $linkObj->create(array(
+                                                       'hash' => $linkToImport['hash'],
+                                                       'link' => $linkToImport['link'],
+                                                       'status' => $linkToImport['private'],
+                                                       'description' => $linkToImport['description'],
+                                                       'title' => $linkToImport['title'],
+                                                       'search' => '',
+                                                       'image' => $linkToImport['image']
+                                               ), true);
+                                       } catch (Exception $e) {
+                                               continue;
+                                       }
+
+                                       if(!empty($do)) {
+
+                                               $linkToImport['catArr'] = Summoner::prepareTagOrCategoryStr($linkToImport['category']);
+                                               $linkToImport['tagArr'] = Summoner::prepareTagOrCategoryStr($linkToImport['tag']);
+
+                                               if(!empty($linkToImport['catArr'])) {
+                                                       foreach($linkToImport['catArr'] as $c) {
+                                                               $catObj = new Category($this->DB);
+                                                               $catObj->initbystring($c);
+                                                               $catObj->setRelation($do);
+
+                                                               unset($catObj);
+                                                       }
+                                               }
+                                               if(!empty($linkToImport['tagArr'])) {
+                                                       foreach($linkToImport['tagArr'] as $t) {
+                                                               $tagObj = new Tag($this->DB);
+                                                               $tagObj->initbystring($t);
+                                                               $tagObj->setRelation($do);
+
+                                                               unset($tagObj);
+                                                       }
+                                               }
+
+                                               $this->DB->commit();
+
+                                               $this->updateSearchIndex();
+                                       }
+                                       else {
+                                               $this->DB->rollback();
+                                       }
                                        $_new++;
-                                       var_dump('new one');
                                }
                        }
                        if(isset($options['overwrite']) && $options['overwrite'] === true) {
@@ -771,7 +819,6 @@ class Management {
                                'status' => 'success',
                                'message' => $_msg
                        );
-
                }
 
                return $ret;