Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2020-09-02 09:01:18 +02:00
commit ce2e6c61d2
9 changed files with 92 additions and 20 deletions

View File

@ -138,6 +138,18 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
}
$this->addField(Zend_Search_Lucene_Field::Text('category', implode(' ', $names), 'utf-8'));
}
if($acllist = $document->getReadAccessList(1, 1, 1)) {
$allu = [];
foreach($acllist['users'] as $u)
$allu[] = $u->getLogin();
$this->addField(Zend_Search_Lucene_Field::Text('users', implode(' ', $allu), 'utf-8'));
/*
$allg = [];
foreach($acllist['groups'] as $g)
$allg[] = $g->getName();
$this->addField(Zend_Search_Lucene_Field::Text('groups', implode(' ', $allg), 'utf-8'));
*/
}
if($attributes = $document->getAttributes()) {
foreach($attributes as $attribute) {
$attrdef = $attribute->getAttributeDefinition();

View File

@ -59,7 +59,7 @@ class SeedDMS_Lucene_Search {
* @param object $index lucene 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 {
@ -78,6 +78,13 @@ class SeedDMS_Lucene_Search {
$querystr .= implode('" || category:"', $categories);
$querystr .= '")';
}
if($users) {
if($querystr)
$querystr .= ' && ';
$querystr .= '(users:"';
$querystr .= implode('" || users:"', $users);
$querystr .= '")';
}
try {
$query = Zend_Search_Lucene_Search_QueryParser::parse($querystr);
try {

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email>
<active>yes</active>
</lead>
<date>2018-04-11</date>
<time>10:58:13</time>
<date>2020-09-02</date>
<time>08:55:43</time>
<version>
<release>1.1.13</release>
<api>1.1.13</api>
<release>1.1.14</release>
<api>1.1.14</api>
</version>
<stability>
<release>stable</release>
@ -23,7 +23,7 @@
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
IndexedDocument() remembers cmd and mimetype
Index users with at least read access on the document
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">
@ -299,5 +299,21 @@ allow conversion commands for mimetypes with wildcards
execWithTimeout() reads data from stderr and saves it into error msg
</notes>
</release>
<release>
<date>2018-04-11</date>
<time>10:58:13</time>
<version>
<release>1.1.13</release>
<api>1.1.13</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
IndexedDocument() remembers cmd and mimetype
</notes>
</release>
</changelog>
</package>

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>

View File

@ -128,7 +128,7 @@ if(isset($_GET["fullsearch"]) && $_GET["fullsearch"] && $settings->_enableFullSe
$startTime = getTime();
$index = $indexconf['Indexer']::open($settings->_luceneDir);
$lucenesearch = new $indexconf['Search']($index);
$hits = $lucenesearch->search($query, $owner ? $owner->getLogin() : '', '', $categorynames);
$hits = $lucenesearch->search($query, $owner ? $owner->getLogin() : '', '', $categorynames, array(), $user->isAdmin() ? [] : [$user->getLogin()]);
if($hits === false) {
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('splash_invalid_searchterm')));
$totalPages = 0;

View File

@ -282,7 +282,7 @@ $(document).ready( function() {
?>
<tr>
<td></td><td><button type="submit" class="btn"><i class="fa fa-search"></i> <?php printMLText("search"); ?></button></td>
<td></td><td><button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> <?php printMLText("search"); ?></button></td>
</tr>
</table>
@ -541,7 +541,7 @@ $(document).ready( function() {
</td>
</tr>
<tr>
<td></td><td><button type="submit" class="btn"><i class="fa fa-search"></i> <?php printMLText("search"); ?></button></td>
<td></td><td><button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> <?php printMLText("search"); ?></button></td>
</tr>
</table>