return $deleteClause;
}
- $user = CRM_Core_Session::getLoggedInContactID();
- if ($contactID == NULL) {
- $contactID = $user ? $user : 0;
- }
-
- // Check if contact has permissions on self
- if ($user && $contactID == $user) {
- if (CRM_Core_Permission::check('edit my contact') ||
- ($type == self::VIEW && CRM_Core_Permission::check('view my contact'))
- ) {
- return ' ( 1 ) ';
- }
+ if (!$contactID) {
+ $contactID = CRM_Core_Session::getLoggedInContactID();
}
+ $contactID = (int) $contactID;
- return implode(' AND ',
+ $where = implode(' AND ',
array(
CRM_ACL_BAO_ACL::whereClause($type,
$tables,
$deleteClause,
)
);
+
+ // Add permission on self
+ if ($contactID && (CRM_Core_Permission::check('edit my contact') ||
+ $type == self::VIEW && CRM_Core_Permission::check('view my contact'))
+ ) {
+ $where = "contact_a.id = $contactID OR ($where)";
+ }
+ return $where;
}
/**