diff --git a/include/class.queue.php b/include/class.queue.php index dfa3846425c8d86c867d491f52c2b75be4fafb1e..760042a731c52547f726afef0f5ee943e837cff3 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -937,10 +937,14 @@ class CustomQueue extends VerySimpleModel { return $agent && $this->isPrivate() && $this->checkOwnership($agent); } + function isSaved() { + return true; + } + function ignoreVisibilityConstraints(Staff $agent) { - // For saved searches (not queues), some staff can have a permission to + // For searches (not queues), some staff can have a permission to // see all records - return (!$this->isASubQueue() + return ($this->isASearch() && $this->isOwner($agent) && $agent->canSearchEverything()); } @@ -994,6 +998,10 @@ class CustomQueue extends VerySimpleModel { return $this->hasFlag(self::FLAG_QUEUE); } + function isASearch() { + return !$this->isAQueue() || !$this->isSaved(); + } + function isPrivate() { return !$this->isAQueue() && !$this->isPublic() && $this->staff_id; diff --git a/include/class.search.php b/include/class.search.php index be17902260dd53b308ffdd3a47ad30156ac7d811..e4c6111b5fe313438577394dcbae5cebf271ec3a 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -912,6 +912,10 @@ extends SavedSearch { return false; } + function isOwner(Staff $staff) { + return $this->ht['staff_id'] == $staff->getId(); + } + function checkAccess($staff) { return true; } @@ -921,6 +925,7 @@ extends SavedSearch { } function load($key) { + global $thisstaff; if (strpos($key, 'adhoc') === 0) list(, $key) = explode(',', $key, 2); @@ -933,6 +938,7 @@ extends SavedSearch { $queue = new AdhocSearch(array( 'id' => "adhoc,$key", 'root' => 'T', + 'staff_id' => $thisstaff->getId(), 'title' => __('Advanced Search'), )); $queue->config = $config;