From: Banana Date: Fri, 8 Jan 2021 10:30:39 +0000 (+0100) Subject: collection management can update the entries with the rights of the collection X-Git-Tag: 1.1~30 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=45993d7ee598890b0c428820114536868c2c46a5;p=bibliotheca-php.git collection management can update the entries with the rights of the collection --- diff --git a/CHANGELOG b/CHANGELOG index c6c3032..0bc865f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,11 +3,12 @@ * Missing changelog file * api has its own log file now. * User profile for editing own settings. + * Collection management has the option to update entry rights with the collection ones. 1.0 - Castle 20210106 * First usable version * Using as a collection management software will work - * Rights management needs tweeking, so use the admin account for a start + * Rights management needs tweaking, so use the admin account for a start * Documentation covers the basics * Use it and give feedback. * Also, make backups. diff --git a/webclient/lib/managecollections.class.php b/webclient/lib/managecollections.class.php index a31328e..fc6b86e 100644 --- a/webclient/lib/managecollections.class.php +++ b/webclient/lib/managecollections.class.php @@ -329,6 +329,9 @@ class ManageCollections { try { $this->_DB->query($queryStr); $this->_updateToolRelation($data['id'],$data['tool']); + if($data['doRightsForEntries'] === true) { + $this->_updateEntryRights($data['id'], $data['owner'], $data['group'], $data['rights']); + } $ret = true; } catch (Exception $e) { @@ -536,11 +539,37 @@ class ManageCollections { } $this->_DB->commit(); $ret = true; - } catch (Exception $e) { + } + catch (Exception $e) { $this->_DB->rollback(); error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage()); } return $ret; } + + private function _updateEntryRights($collectionId, $owner=false, $group=false, $rights=false) { + if(!empty($collectionId)) { + $queryStr = "UPDATE `".DB_PREFIX."_collection_entry_".$collectionId."` SET"; + + if(Summoner::validate($owner, "digit")) { + $queryStr .= " `owner` = '".$this->_DB->real_escape_string($owner)."',"; + } + if(Summoner::validate($group, "digit")) { + $queryStr .= " `group` = '".$this->_DB->real_escape_string($group)."',"; + } + if(Summoner::validate($rights, "rights")) { + $queryStr .= " `rights` = '".$this->_DB->real_escape_string($rights)."',"; + } + $queryStr = trim($queryStr, ","); + + if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true)); + try { + $this->_DB->query($queryStr); + } + catch (Exception $e) { + error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage()); + } + } + } } diff --git a/webclient/view/default/managecolletions/managecolletions.html b/webclient/view/default/managecolletions/managecolletions.html index 486957f..a127e55 100644 --- a/webclient/view/default/managecolletions/managecolletions.html +++ b/webclient/view/default/managecolletions/managecolletions.html @@ -19,6 +19,36 @@ value=""> +
+ +
+ + The field is used in the global search. + Altering the default search field results in + a DB reindex. This could take some time, depending on the amount of data. +
+
+
+ +
+ +
+
+
@@ -83,46 +113,26 @@
+
- -
- +
Update entry with collection rights
+
+
-
Delete
-
- -
- - The field is used in the global search. - Altering the default search field results in - a DB reindex. This could take some time, depending on the amount of data. -
-