adding an ignore-acl parameter to addressbook_bo::read() and addressbook_merge::get_replacements()

This commit is contained in:
Ralf Becker 2016-01-20 14:39:16 +00:00
parent a0338f3398
commit cd1692c4a6
3 changed files with 11 additions and 8 deletions

View File

@ -1055,15 +1055,16 @@ class addressbook_bo extends addressbook_so
* reads contacts matched by key and puts all cols in the data array * reads contacts matched by key and puts all cols in the data array
* *
* @param int|string $contact_id * @param int|string $contact_id
* @param boolean $ignore_acl =false true: no acl check
* @return array|boolean array with contact data, null if not found or false on no view perms * @return array|boolean array with contact data, null if not found or false on no view perms
*/ */
function read($contact_id) function read($contact_id, $ignore_acl=false)
{ {
if (!($data = parent::read($contact_id))) if (!($data = parent::read($contact_id)))
{ {
$data = null; // not found $data = null; // not found
} }
elseif (!$this->check_perms(EGW_ACL_READ,$data)) elseif (!$ignore_acl && !$this->check_perms(EGW_ACL_READ,$data))
{ {
$data = false; // no view perms $data = false; // no view perms
} }

View File

@ -46,17 +46,18 @@ class addressbook_merge extends bo_merge
* *
* @param int $id id of entry * @param int $id id of entry
* @param string &$content=null content to create some replacements only if they are use * @param string &$content=null content to create some replacements only if they are use
* @param boolean $ignore_acl =false true: no acl check
* @return array|boolean * @return array|boolean
*/ */
protected function get_replacements($id,&$content=null) protected function get_replacements($id,&$content=null,$ignore_acl=false)
{ {
if (!($replacements = $this->contact_replacements($id))) if (!($replacements = $this->contact_replacements($id,'',$ignore_acl)))
{ {
return false; return false;
} }
if($content && strpos($content, '$$#') !== 0) if($content && strpos($content, '$$#') !== 0)
{ {
$this->cf_link_to_expand($this->contacts->read($id), $content, $replacements,'addressbook'); $this->cf_link_to_expand($this->contacts->read($id, $ignore_acl), $content, $replacements,'addressbook');
} }
// Links // Links

View File

@ -193,14 +193,15 @@ abstract class bo_merge
* Return replacements for a contact * Return replacements for a contact
* *
* @param int|string|array $contact contact-array or id * @param int|string|array $contact contact-array or id
* @param string $prefix='' prefix like eg. 'user' * @param string $prefix ='' prefix like eg. 'user'
* @param boolean $ignore_acl =false true: no acl check
* @return array * @return array
*/ */
public function contact_replacements($contact,$prefix='') public function contact_replacements($contact,$prefix='',$ignore_acl=false)
{ {
if (!is_array($contact)) if (!is_array($contact))
{ {
$contact = $this->contacts->read($contact); $contact = $this->contacts->read($contact, $ignore_acl);
} }
if (!is_array($contact)) return array(); if (!is_array($contact)) return array();