Ejemplo n.º 1
0
/**
 *
 * @param string $type
 * @param array $tables tables to be included in query
 * @param array $whereTables tables required for where portion of query
 * @param integer $contactID contact for whom where clause is being composed
 * @param string $where Where clause The completed clause will look like
 *   (multisiteGroupTable.group_id IN ("1,2,3,4,5") AND multisiteGroupTable.status IN ('Added') AND contact_a.is_deleted = 0)
 *   where the child groups are groups the contact is potentially a member of
 *
 */
function multisite_civicrm_aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where)
{
    if (!$contactID) {
        return;
    }
    if (!_multisite_add_permissions($type)) {
        return;
    }
    $groupID = _multisite_get_domain_group();
    if (!$groupID) {
        return;
    }
    $childOrgs = _multisite_get_all_child_groups($groupID);
    if (!empty($childOrgs)) {
        $groupTable = 'civicrm_group_contact';
        $tables[$groupTable] = $whereTables[$groupTable] = "LEFT JOIN {$groupTable} multisiteGroupTable ON contact_a.id = multisiteGroupTable.contact_id";
        $where = "(multisiteGroupTable.group_id IN (" . implode(',', $childOrgs) . ") AND multisiteGroupTable.status IN ('Added') AND contact_a.is_deleted = 0)";
    }
}
Ejemplo n.º 2
0
/**
 *
 * @param string $type
 * @param array $tables tables to be included in query
 * @param array $whereTables tables required for where portion of query
 * @param integer $contactID contact for whom where clause is being composed
 * @param string $where Where clause The completed clause will look like
 *   (multisiteGroupTable.group_id IN ("1,2,3,4,5") AND multisiteGroupTable.status IN ('Added') AND contact_a.is_deleted = 0)
 *   where the child groups are groups the contact is potentially a member of
 *
 */
function multisite_civicrm_aclWhereClause($type, &$tables, &$whereTables, &$contactID, &$where)
{
    if (!$contactID) {
        return;
    }
    if (!_multisite_add_permissions($type)) {
        return;
    }
    $groupID = _multisite_get_domain_group();
    if (!$groupID) {
        return;
    }
    $childOrgs = _multisite_get_all_child_groups($groupID);
    if (!empty($childOrgs)) {
        $groupTable = 'civicrm_group_contact';
        $groupTableAlias = 'multisiteGroupTable';
        $tables[$groupTableAlias] = $whereTables[$groupTableAlias] = "\n      LEFT JOIN {$groupTable} {$groupTableAlias} ON contact_a.id = {$groupTableAlias}.contact_id\n    ";
        $deletedContactClause = CRM_Core_Permission::check('access deleted contacts') ? '' : 'AND contact_a.is_deleted = 0';
        $where = "(multisiteGroupTable.group_id IN (" . implode(',', $childOrgs) . ") AND {$groupTableAlias}.status IN ('Added') {$deletedContactClause})";
    }
}