index users with read access on a document, start version 1.1.12

This commit is contained in:
Uwe Steinmann 2020-09-02 08:59:24 +02:00
parent a29c0f35aa
commit 89795a7c31
4 changed files with 48 additions and 11 deletions

View File

@ -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)) {

View File

@ -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;
} /* }}} */

View File

@ -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();

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email>
<active>yes</active>
</lead>
<date>2019-11-28</date>
<time>11:00:40</time>
<date>2020-09-02</date>
<time>08:57:44</time>
<version>
<release>1.0.11</release>
<api>1.0.11</api>
<release>1.0.12</release>
<api>1.0.12</api>
</version>
<stability>
<release>stable</release>
@ -23,8 +23,7 @@
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
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
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">
@ -243,5 +242,22 @@ execWithTimeout() reads data from stderr and saves it into error msg
IndexedDocument() remembers cmd and mimetype
</notes>
</release>
<release>
<date>2019-11-28</date>
<time>11:00:40</time>
<version>
<release>1.0.11</release>
<api>1.0.11</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
Set 'created' in index to creation date of indexed content (was set to current
timestamp)
</notes>
</release>
</changelog>
</package>