From 89795a7c31eedc68a40c08b0f86541585dfcd5dd Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 2 Sep 2020 08:59:24 +0200 Subject: [PATCH] index users with read access on a document, start version 1.1.12 --- .../SQLiteFTS/IndexedDocument.php | 12 ++++++++ SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php | 9 +++--- SeedDMS_SQLiteFTS/SQLiteFTS/Search.php | 10 ++++++- SeedDMS_SQLiteFTS/package.xml | 28 +++++++++++++++---- 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php b/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php index 5e9fb08a1..237cf8576 100644 --- a/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php +++ b/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php @@ -150,6 +150,18 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document { if($comment = $document->getComment()) { $this->addField('comment', $comment); } + if($acllist = $document->getReadAccessList(1, 1, 1)) { + $allu = []; + foreach($acllist['users'] as $u) + $allu[] = $u->getLogin(); + $this->addField('users', implode(' ', $allu)); + /* + $allg = []; + foreach($acllist['groups'] as $g) + $allg[] = $g->getName(); + $this->addField('groups', implode(' ', $allg)); + */ + } if($version && !$nocontent) { $path = $dms->contentDir . $version->getPath(); if(file_exists($path)) { diff --git a/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php b/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php index 7cac5d7e9..f4791f5f2 100644 --- a/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php +++ b/SeedDMS_SQLiteFTS/SQLiteFTS/Indexer.php @@ -63,9 +63,9 @@ class SeedDMS_SQLiteFTS_Indexer { */ $version = SQLite3::version(); if($version['versionNumber'] >= 3008000) - $sql = 'CREATE VIRTUAL TABLE docs USING fts4(title, comment, keywords, category, mimetype, origfilename, owner, content, created, notindexed=created, matchinfo=fts3)'; + $sql = 'CREATE VIRTUAL TABLE docs USING fts4(title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, notindexed=created, matchinfo=fts3)'; else - $sql = 'CREATE VIRTUAL TABLE docs USING fts4(title, comment, keywords, category, mimetype, origfilename, owner, content, created, matchinfo=fts3)'; + $sql = 'CREATE VIRTUAL TABLE docs USING fts4(title, comment, keywords, category, mimetype, origfilename, owner, content, created, users, matchinfo=fts3)'; $res = $index->_conn->exec($sql); if($res === false) { return null; @@ -96,7 +96,7 @@ class SeedDMS_SQLiteFTS_Indexer { if(!$this->_conn) return false; - $sql = "INSERT INTO docs (docid, title, comment, keywords, category, owner, content, mimetype, origfilename, created) VALUES(".$doc->getFieldValue('document_id').", ".$this->_conn->quote($doc->getFieldValue('title')).", ".$this->_conn->quote($doc->getFieldValue('comment')).", ".$this->_conn->quote($doc->getFieldValue('keywords')).", ".$this->_conn->quote($doc->getFieldValue('category')).", ".$this->_conn->quote($doc->getFieldValue('owner')).", ".$this->_conn->quote($doc->getFieldValue('content')).", ".$this->_conn->quote($doc->getFieldValue('mimetype')).", ".$this->_conn->quote($doc->getFieldValue('origfilename')).", ".$doc->getFieldValue('created')/*time()*/.")"; + $sql = "INSERT INTO docs (docid, title, comment, keywords, category, owner, content, mimetype, origfilename, created, users) VALUES(".$doc->getFieldValue('document_id').", ".$this->_conn->quote($doc->getFieldValue('title')).", ".$this->_conn->quote($doc->getFieldValue('comment')).", ".$this->_conn->quote($doc->getFieldValue('keywords')).", ".$this->_conn->quote($doc->getFieldValue('category')).", ".$this->_conn->quote($doc->getFieldValue('owner')).", ".$this->_conn->quote($doc->getFieldValue('content')).", ".$this->_conn->quote($doc->getFieldValue('mimetype')).", ".$this->_conn->quote($doc->getFieldValue('origfilename')).", ".$doc->getFieldValue('created').", ".$this->_conn->quote($doc->getFieldValue('users'))/*time()*/.")"; $res = $this->_conn->exec($sql); if($res === false) { return false; @@ -189,7 +189,7 @@ class SeedDMS_SQLiteFTS_Indexer { if(!$this->_conn) return false; - $sql = "SELECT title, comment, owner, keywords, category, mimetype, origfilename, created FROM docs WHERE docid=".(int) $id; + $sql = "SELECT title, comment, owner, keywords, category, mimetype, origfilename, created, users FROM docs WHERE docid=".(int) $id; $res = $this->_conn->query($sql); $doc = false; if($res) { @@ -203,6 +203,7 @@ class SeedDMS_SQLiteFTS_Indexer { $doc->addField('origfilename', $rec['origfilename']); $doc->addField('owner', $rec['owner']); $doc->addField('created', $rec['created']); + $doc->addField('users', $rec['users']); } return $doc; } /* }}} */ diff --git a/SeedDMS_SQLiteFTS/SQLiteFTS/Search.php b/SeedDMS_SQLiteFTS/SQLiteFTS/Search.php index 18b20fdaf..511783539 100644 --- a/SeedDMS_SQLiteFTS/SQLiteFTS/Search.php +++ b/SeedDMS_SQLiteFTS/SQLiteFTS/Search.php @@ -59,7 +59,7 @@ class SeedDMS_SQliteFTS_Search { * @param object $index SQlite FTS index * @return object instance of SeedDMS_Lucene_Search */ - function search($term, $owner, $status='', $categories=array(), $fields=array()) { /* {{{ */ + function search($term, $owner, $status='', $categories=array(), $fields=array(), $users=array()) { /* {{{ */ $querystr = ''; if($fields) { } else { @@ -81,6 +81,14 @@ class SeedDMS_SQliteFTS_Search { $querystr .= implode(' OR category:', $categories); $querystr .= ''; } + if($users) { + if($querystr) + $querystr .= ' '; + //$querystr .= ' AND '; + $querystr .= 'users:'; + $querystr .= implode(' OR users:', $users); + $querystr .= ''; + } try { $hits = $this->index->find($querystr); $recs = array(); diff --git a/SeedDMS_SQLiteFTS/package.xml b/SeedDMS_SQLiteFTS/package.xml index fdac846ba..c5fc5eacc 100644 --- a/SeedDMS_SQLiteFTS/package.xml +++ b/SeedDMS_SQLiteFTS/package.xml @@ -11,11 +11,11 @@ uwe@steinmann.cx yes - 2019-11-28 - + 2020-09-02 + - 1.0.11 - 1.0.11 + 1.0.12 + 1.0.12 stable @@ -23,8 +23,7 @@ GPL License -Set 'created' in index to creation date of indexed content (was set to current -timestamp) +Index users with at least read access on a document @@ -243,5 +242,22 @@ execWithTimeout() reads data from stderr and saves it into error msg IndexedDocument() remembers cmd and mimetype + + 2019-11-28 + + + 1.0.11 + 1.0.11 + + + stable + stable + + GPL License + +Set 'created' in index to creation date of indexed content (was set to current +timestamp) + +