Author: david
Date: Fri Oct 23 18:05:14 2009
New Revision: 3818
Log:
Fix lucene search query terms for filtering draft descriptions. Fixes issue
#1093.
Modified:
trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
trunk/plugins/qbAclPlugin/lib/QubitAcl.class.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
Fri Oct 23 15:13:22 2009 (r3817)
+++ trunk/apps/qubit/modules/informationobject/actions/listAction.class.php
Fri Oct 23 18:05:14 2009 (r3818)
@@ -80,6 +80,8 @@
{
$query = $request->query;
}
+
+ $deniedRepositories = array();
$repositoryAccess = QubitAcl::getRepositoryAccess(QubitAclAction::READ_ID);
if (1 == count($repositoryAccess))
{
@@ -130,33 +132,45 @@
}
else
{
- $subquery = new Zend_Search_Lucene_Search_Query_MultiTerm();
- while ($repo = array_shift($repositoryViewDrafts))
+ // Get last rule in list, it will be the global rule with the opposite
+ // access of the preceeding rules (e.g. if last rule is "DENY ALL" then
+ // preceeding rules will be "ALLOW" rules)
+ $globalRule = array_pop($repositoryViewDrafts);
+
+ // If global rule is GRANT, then listed repos are exceptions so remove
+ // from results
+ if (QubitAcl::GRANT == $globalRule['access'])
{
- // Don't bother excluding repos (again) that have no read access at all
- if (in_array($repo['id'], $deniedRepositories))
+ while ($repo = array_shift($repositoryViewDrafts))
{
- continue;
- }
+ // Don't bother excluding repos (again) that have no read access at
all
+ if (in_array($repo['id'], $deniedRepositories))
+ {
+ continue;
+ }
- if ('*' != $repo['id'])
- {
+ $subquery = new Zend_Search_Lucene_Search_Query_MultiTerm();
$subquery->addTerm(new Zend_Search_Lucene_Index_Term($repo['id'],
'repositoryid'), true);
$subquery->addTerm(new
Zend_Search_Lucene_Index_Term(QubitTerm::PUBLICATION_STATUS_DRAFT_ID,
'publicationStatusId'), true);
+
+ // Filter rule should look like: "-(+id:356 +status:draft) -(+id:357
+status:draft)"
+ $query->addSubquery($subquery, false /* prohibited */);
}
- else
+ }
+
+ // If global rule is DENY, then only show the listed repo drafts
+ else
+ {
+ $subquery = new Zend_Search_Lucene_Search_Query_MultiTerm();
+
+ while ($repo = array_shift($repositoryViewDrafts))
{
- if (QubitAcl::DENY == $repo['access'])
- {
- // Require repos to be specifically allowed (all others prohibited)
- $query->addSubquery($subquery, true /* required */);
- }
- else
- {
- // Prohibit specified repos (all others allowed)
- $query->addSubquery($subquery, false /* prohibited */);
- }
+ $subquery->addTerm(new Zend_Search_Lucene_Index_Term($repo['id'],
'repositoryid'), null);
}
+ $subquery->addTerm(new
Zend_Search_Lucene_Index_Term(QubitTerm::PUBLICATION_STATUS_PUBLISHED_ID,
'publicationStatusId'), null);
+
+ // Filter rule should look like "+(id:(356 357 358) status:published)"
+ $query->addSubquery($subquery, true /* required */);
}
}
Modified: trunk/plugins/qbAclPlugin/lib/QubitAcl.class.php
==============================================================================
--- trunk/plugins/qbAclPlugin/lib/QubitAcl.class.php Fri Oct 23 15:13:22
2009 (r3817)
+++ trunk/plugins/qbAclPlugin/lib/QubitAcl.class.php Fri Oct 23 18:05:14
2009 (r3818)
@@ -416,7 +416,7 @@
{
if ('*' != $val['id'] && $globalPermission == $val['access'])
{
- unset($repositoryAccess[$i]);
+ array_splice($repositoryAccess, $i, 1);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---