From: Banana Date: Tue, 5 Jan 2021 10:10:29 +0000 (+0100) Subject: deletion of a collection. X-Git-Tag: 1.0~3 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=81a9a66fee1cb49b0df6b8822d7b788acceb5e7f;p=bibliotheca-php.git deletion of a collection. --- diff --git a/TODO b/TODO index 9faa7d6..e6d856d 100644 --- 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. diff --git a/documentation/setup/install.txt b/documentation/setup/install.txt index 55b3e9f..bd9e09a 100644 --- a/documentation/setup/install.txt +++ b/documentation/setup/install.txt @@ -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. diff --git a/webclient/lib/managecollections.class.php b/webclient/lib/managecollections.class.php index 91d0928..5e52fa0 100644 --- a/webclient/lib/managecollections.class.php +++ b/webclient/lib/managecollections.class.php @@ -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;