]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
deletion of a collection.
authorBanana <mail@bananas-playground.net>
Tue, 5 Jan 2021 10:10:29 +0000 (11:10 +0100)
committerBanana <mail@bananas-playground.net>
Tue, 5 Jan 2021 10:10:29 +0000 (11:10 +0100)
TODO
documentation/setup/install.txt
webclient/lib/managecollections.class.php

diff --git a/TODO b/TODO
index 9faa7d65e75191a03071d79abf3feff815eeda1a..e6d856d83d4372c424003b0b770031c9cf5755d5 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,13 +1,13 @@
-* sort by filter for collection display
 * Collection fields: final remove from entry table
        Add waring about it!
-* Mass edit of entries
-* delete of a collection
-* Better error handling and display while adding / update and delete
-* rights example setup and also check if it maches the menu and actions
+* rights example setup and also check if it matches the menu and actions
        + admin
        + Management
        + User (only its data)
+* sort by filter for collection display
+* Mass edit of entries
+* Better error handling and display while adding / update and delete
+
 * responsive and breakpoints
 * stats overview page. amount of entries. file and db storage.
 * Export of an entry, collection or everything. Stored on disk.
index 55b3e9fef2f80b4b86356762e919d7e2c75f2477..bd9e09a055680a4771c85bafc5a37fe0fce7db7b 100644 (file)
@@ -32,5 +32,6 @@ Open your browser and visit your newly created bibliotheca installation.
 Default admin user pw: test
 
 7. First steps
+Login with default admin account and change the password!
 Create your own user.
 Create your first collection.
index 91d09281e07682ecc9d29b19bc6d617ff4170821..5e52fa007536e8bfd6bd268ba87e4a212aca3830 100644 (file)
@@ -368,27 +368,49 @@ class ManageCollections {
 
        /**
         * Delete collection identified by given id
+        * This removes everything and drops tables!
         *
-        * @param string $id  Number
+        * @param string $id Number
         * @return bool
         */
        public function deleteCollection($id) {
                $ret = false;
 
-               // @todo Implement list deletion
-               // what to do with the entries?
-               exit('No implemented yet.');
-
                if(!empty($id) && Summoner::validate($id, 'digit')) {
                        $queryStr = "DELETE FROM `".DB_PREFIX."_collection`
                                                        WHERE `id` = '".$this->_DB->real_escape_string($id)."'";
                        if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
-                       $query = $this->_DB->query($queryStr);
-                       if($query !== false) {
 
-                               var_dump("Implement list deletion");
+                       $queryStrTool = "DELETE FROM `".DB_PREFIX."_tool2collection`
+                                                       WHERE `fk_collection_id` = '".$this->_DB->real_escape_string($id)."'";
+                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrTool,true));
+
+                       $queryStre2l = "DROP TABLE `bibliotheca`.`bib_collection_entry2lookup_".$this->_DB->real_escape_string($id)."`";
+                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStre2l,true));
+
+                       $queryStrEntry = "DROP TABLE `bibliotheca`.`bib_collection_entry_".$this->_DB->real_escape_string($id)."`";
+                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrEntry,true));
+
+                       $queryStrFields = "DROP TABLE `bibliotheca`.`bib_collection_fields_".$this->_DB->real_escape_string($id)."`";
+                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrFields,true));
+
+
+                       try {
+                               $this->_DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
+
+                               $this->_DB->query($queryStr);
+                               $this->_DB->query($queryStrTool);
+                               $this->_DB->query($queryStre2l);
+                               $this->_DB->query($queryStrEntry);
+                               $this->_DB->query($queryStrFields);
+
+                               $this->_DB->commit();
                                $ret = true;
                        }
+                       catch (Exception $e) {
+                               $this->_DB->rollback();
+                               error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+                       }
                }
 
                return $ret;