Пример #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)";
    }
}
Пример #2
0
/**
 * get organization of domain group
 */
function _multisite_get_domain_organization($permission = True)
{
    $groupID = _multisite_get_domain_group($permission);
    if (empty($groupID)) {
        return FALSE;
    }
    return civicrm_api('group_organization', 'getvalue', array('version' => 3, 'group_id' => $groupID, 'return' => 'organization_id'));
}