当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contact_BAO_Contact_Permission::cacheClause方法代码示例

本文整理汇总了PHP中CRM_Contact_BAO_Contact_Permission::cacheClause方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact_Permission::cacheClause方法的具体用法?PHP CRM_Contact_BAO_Contact_Permission::cacheClause怎么用?PHP CRM_Contact_BAO_Contact_Permission::cacheClause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Contact_BAO_Contact_Permission的用法示例。


在下文中一共展示了CRM_Contact_BAO_Contact_Permission::cacheClause方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getContactList

 static function getContactList(&$config)
 {
     require_once 'CRM/Core/BAO/Preferences.php';
     $name = CRM_Utils_Type::escape($_GET['s'], 'String');
     $limit = '10';
     $list = array_keys(CRM_Core_BAO_Preferences::valueOptions('contact_autocomplete_options'), '1');
     $select = array('sort_name');
     $where = '';
     $from = array();
     foreach ($list as $value) {
         $suffix = substr($value, 0, 2) . substr($value, -1);
         switch ($value) {
             case 'street_address':
             case 'city':
                 $selectText = $value;
                 $value = "address";
                 $suffix = 'sts';
             case 'phone':
             case 'email':
                 $select[] = $value == 'address' ? $selectText : $value;
                 $from[$value] = "LEFT JOIN civicrm_{$value} {$suffix} ON ( cc.id = {$suffix}.contact_id AND {$suffix}.is_primary = 1 ) ";
                 break;
             case 'country':
             case 'state_province':
                 $select[] = "{$suffix}.name";
                 if (!in_array('address', $from)) {
                     $from['address'] = 'LEFT JOIN civicrm_address sts ON ( cc.id = sts.contact_id AND sts.is_primary = 1) ';
                 }
                 $from[$value] = " LEFT JOIN civicrm_{$value} {$suffix} ON ( sts.{$value}_id = {$suffix}.id  ) ";
                 break;
         }
     }
     $select = implode(', ', $select);
     $from = implode(' ', $from);
     if (CRM_Utils_Array::value('limit', $_GET)) {
         $limit = CRM_Utils_Type::escape($_GET['limit'], 'Positive');
     }
     // add acl clause here
     require_once 'CRM/Contact/BAO/Contact/Permission.php';
     list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('cc');
     if ($aclWhere) {
         $where .= " AND {$aclWhere} ";
     }
     $query = "\nSELECT DISTINCT(cc.id) as id, CONCAT_WS( ' :: ', {$select} ) as data\nFROM civicrm_contact cc {$from}\n{$aclFrom}\nWHERE sort_name LIKE '%{$name}%' {$where} \nORDER BY sort_name\nLIMIT 0, {$limit}\n";
     // send query to hook to be modified if needed
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::contactListQuery($query, $name, CRM_Utils_Array::value('context', $_GET), CRM_Utils_Array::value('id', $_GET));
     $dao = CRM_Core_DAO::executeQuery($query);
     $contactList = null;
     while ($dao->fetch()) {
         echo $contactList = "{$dao->data}|{$dao->id}\n";
     }
     exit;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:54,代码来源:AJAX.php

示例2: buildACLClause

 function buildACLClause($tableAlias = 'contact')
 {
     list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
 }
开发者ID:eileenmcnaughton,项目名称:au.org.greens.customsearches,代码行数:4,代码来源:agSpam.php

示例3: getContactPhone

 public static function getContactPhone()
 {
     $queryString = NULL;
     //check for mobile type
     $phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name');
     $mobileType = CRM_Utils_Array::value('Mobile', $phoneTypes);
     $name = CRM_Utils_Array::value('name', $_GET);
     if ($name) {
         $name = CRM_Utils_Type::escape($name, 'String');
         $queryString = " ( cc.sort_name LIKE '%{$name}%' OR cp.phone LIKE '%{$name}%' ) ";
     } else {
         $cid = CRM_Utils_Array::value('cid', $_GET);
         if ($cid) {
             //check cid for integer
             $contIDS = explode(',', $cid);
             foreach ($contIDS as $contID) {
                 CRM_Utils_Type::escape($contID, 'Integer');
             }
             $queryString = " cc.id IN ( {$cid} )";
         }
     }
     if ($queryString) {
         $offset = CRM_Utils_Array::value('offset', $_GET, 0);
         $rowCount = CRM_Utils_Array::value('rowcount', $_GET, 20);
         $offset = CRM_Utils_Type::escape($offset, 'Int');
         $rowCount = CRM_Utils_Type::escape($rowCount, 'Int');
         // add acl clause here
         list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('cc');
         if ($aclWhere) {
             $aclWhere = " AND {$aclWhere}";
         }
         $query = "\nSELECT sort_name name, cp.phone, cc.id\nFROM   civicrm_phone cp INNER JOIN civicrm_contact cc ON cc.id = cp.contact_id\n       {$aclFrom}\nWHERE  cc.is_deceased = 0 AND cc.do_not_sms = 0 AND cp.phone_type_id = {$mobileType} AND {$queryString}\n       {$aclWhere}\nLIMIT {$offset}, {$rowCount}\n";
         // send query to hook to be modified if needed
         CRM_Utils_Hook::contactListQuery($query, $name, CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject), CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject));
         $dao = CRM_Core_DAO::executeQuery($query);
         while ($dao->fetch()) {
             $result[] = array('text' => '"' . $dao->name . '" (' . $dao->phone . ')', 'id' => CRM_Utils_Array::value('id', $_GET) ? "{$dao->id}::{$dao->phone}" : '"' . $dao->name . '" <' . $dao->phone . '>');
         }
     }
     if ($result) {
         CRM_Utils_JSON::output($result);
     }
     CRM_Utils_System::civiExit();
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:44,代码来源:AJAX.php

示例4: civicrm_api3_contact_getquick

/**
 * Old Contact quick search api.
 *
 * @deprecated
 *
 * @param array $params
 *
 * @return array
 * @throws \API_Exception
 */
function civicrm_api3_contact_getquick($params)
{
    $name = CRM_Utils_Type::escape(CRM_Utils_Array::value('name', $params), 'String');
    $table_name = CRM_Utils_String::munge($params['table_name']);
    // get the autocomplete options from settings
    $acpref = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options'));
    // get the option values for contact autocomplete
    $acOptions = CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, FALSE, NULL, 'name');
    $list = array();
    foreach ($acpref as $value) {
        if ($value && !empty($acOptions[$value])) {
            $list[$value] = $acOptions[$value];
        }
    }
    // If we are doing quicksearch by a field other than name, make sure that field is added to results
    if (!empty($params['field_name'])) {
        $field_name = CRM_Utils_String::munge($params['field_name']);
        // Unique name contact_id = id
        if ($field_name == 'contact_id') {
            $field_name = 'id';
        }
        // phone_numeric should be phone
        $searchField = str_replace('_numeric', '', $field_name);
        if (!in_array($searchField, $list)) {
            $list[] = $searchField;
        }
    } else {
        // Set field name to first name for exact match checking.
        $field_name = 'sort_name';
    }
    $select = $actualSelectElements = array('sort_name');
    $where = '';
    $from = array();
    foreach ($list as $value) {
        $suffix = substr($value, 0, 2) . substr($value, -1);
        switch ($value) {
            case 'street_address':
            case 'city':
            case 'postal_code':
                $selectText = $value;
                $value = "address";
                $suffix = 'sts';
            case 'phone':
            case 'email':
                $actualSelectElements[] = $select[] = $value == 'address' ? $selectText : $value;
                if ($value == 'phone') {
                    $actualSelectElements[] = $select[] = 'phone_ext';
                }
                $from[$value] = "LEFT JOIN civicrm_{$value} {$suffix} ON ( cc.id = {$suffix}.contact_id AND {$suffix}.is_primary = 1 ) ";
                break;
            case 'country':
            case 'state_province':
                $select[] = "{$suffix}.name as {$value}";
                $actualSelectElements[] = "{$suffix}.name";
                if (!in_array('address', $from)) {
                    $from['address'] = 'LEFT JOIN civicrm_address sts ON ( cc.id = sts.contact_id AND sts.is_primary = 1) ';
                }
                $from[$value] = " LEFT JOIN civicrm_{$value} {$suffix} ON ( sts.{$value}_id = {$suffix}.id  ) ";
                break;
            default:
                if ($value != 'id') {
                    $suffix = 'cc';
                    if (!empty($params['field_name']) && $params['field_name'] == 'value') {
                        $suffix = CRM_Utils_String::munge(CRM_Utils_Array::value('table_name', $params, 'cc'));
                    }
                    $actualSelectElements[] = $select[] = $suffix . '.' . $value;
                }
                break;
        }
    }
    $config = CRM_Core_Config::singleton();
    $as = $select;
    $select = implode(', ', $select);
    if (!empty($select)) {
        $select = ", {$select}";
    }
    $actualSelectElements = implode(', ', $actualSelectElements);
    $selectAliases = $from;
    unset($selectAliases['address']);
    $selectAliases = implode(', ', array_keys($selectAliases));
    if (!empty($selectAliases)) {
        $selectAliases = ", {$selectAliases}";
    }
    $from = implode(' ', $from);
    $limit = (int) CRM_Utils_Array::value('limit', $params);
    $limit = $limit > 0 ? $limit : Civi::settings()->get('search_autocomplete_count');
    // add acl clause here
    list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('cc');
    if ($aclWhere) {
        $where .= " AND {$aclWhere} ";
//.........这里部分代码省略.........
开发者ID:nielosz,项目名称:civicrm-core,代码行数:101,代码来源:Contact.php

示例5: thresholdQuery

 /**
  * Return the SQL query for getting only the interesting results out of the dedupe table.
  *
  * @$checkPermission boolean $params a flag to indicate if permission should be considered.
  * default is to always check permissioning but public pages for example might not want
  * permission to be checked for anonymous users. Refer CRM-6211. We might be beaking
  * Multi-Site dedupe for public pages.
  *
  * @param bool $checkPermission
  *
  * @return string
  */
 public function thresholdQuery($checkPermission = TRUE)
 {
     $this->_aclFrom = '';
     // CRM-6603: anonymous dupechecks side-step ACLs
     $this->_aclWhere = ' AND is_deleted = 0 ';
     if ($this->params && !$this->noRules) {
         if ($checkPermission) {
             list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('civicrm_contact');
             $this->_aclWhere = $this->_aclWhere ? "AND {$this->_aclWhere}" : '';
         }
         $query = "SELECT dedupe.id1 as id\n                FROM dedupe JOIN civicrm_contact ON dedupe.id1 = civicrm_contact.id {$this->_aclFrom}\n                WHERE contact_type = '{$this->contact_type}' {$this->_aclWhere}\n                AND weight >= {$this->threshold}";
     } else {
         $this->_aclWhere = ' AND c1.is_deleted = 0 AND c2.is_deleted = 0';
         if ($checkPermission) {
             list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause(array('c1', 'c2'));
             $this->_aclWhere = $this->_aclWhere ? "AND {$this->_aclWhere}" : '';
         }
         $query = "SELECT dedupe.id1, dedupe.id2, dedupe.weight\n                FROM dedupe JOIN civicrm_contact c1 ON dedupe.id1 = c1.id\n                            JOIN civicrm_contact c2 ON dedupe.id2 = c2.id {$this->_aclFrom}\n                       LEFT JOIN civicrm_dedupe_exception exc ON dedupe.id1 = exc.contact_id1 AND dedupe.id2 = exc.contact_id2\n                WHERE c1.contact_type = '{$this->contact_type}' AND\n                      c2.contact_type = '{$this->contact_type}' {$this->_aclWhere}\n                      AND weight >= {$this->threshold} AND exc.contact_id1 IS NULL";
     }
     CRM_Utils_Hook::dupeQuery($this, 'threshold', $query);
     return $query;
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:34,代码来源:RuleGroup.php

示例6: buildACLClause

 /**
  * We are over-riding this because the current choice is NO acls or automatically adding contact.is_deleted
  * which is a pain when left joining form another table
  * @see CRM_Report_Form::buildACLClause($tableAlias)
  *
  * @param string $tableAlias
  *
  */
 function buildACLClause($tableAlias = 'contact_a') {
   list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
   if ($this->_skipACLContactDeletedClause && CRM_Core_Permission::check('access deleted contacts')) {
     if (trim($this->_aclWhere) == "{$tableAlias}.is_deleted = 0") {
       $this->_aclWhere = NULL;
     }
     else {
       $this->_aclWhere = str_replace("AND {$tableAlias}.is_deleted = 0", '', $this->_aclWhere);
     }
   }
 }
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:19,代码来源:ExtendedReport.php

示例7: getContactEmail

 /**
  *  Function to get email address of a contact
  */
 static function getContactEmail()
 {
     if (CRM_Utils_Array::value('contact_id', $_POST)) {
         $contactID = CRM_Utils_Type::escape($_POST['contact_id'], 'Positive');
         require_once 'CRM/Contact/BAO/Contact/Location.php';
         list($displayName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
         if ($userEmail) {
             echo $userEmail;
         }
     } else {
         $noemail = CRM_Utils_Array::value('noemail', $_GET);
         if ($name = CRM_Utils_Array::value('name', $_GET)) {
             $name = CRM_Utils_Type::escape($name, 'String');
             if ($noemail) {
                 $queryString = " cc.sort_name LIKE '%{$name}%'";
             } else {
                 $queryString = " ( cc.sort_name LIKE '%{$name}%' OR ce.email LIKE '%{$name}%' ) ";
             }
         } else {
             $cid = CRM_Utils_Array::value('cid', $_GET);
             $queryString = " cc.id IN ( {$cid} )";
         }
         // add acl clause here
         require_once 'CRM/Contact/BAO/Contact/Permission.php';
         list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('cc');
         if ($aclWhere) {
             $aclWhere = " AND {$aclWhere}";
         }
         if ($noemail) {
             $query = "\nSELECT sort_name name, cc.id\nFROM civicrm_contact cc \n     {$aclFrom}\nWHERE {$queryString}\n      {$aclWhere}\n";
             $dao = CRM_Core_DAO::executeQuery($query);
             while ($dao->fetch()) {
                 $result[] = array('name' => $dao->name, 'id' => $dao->id);
             }
         } else {
             $query = "\nSELECT sort_name name, ce.email, cc.id\nFROM   civicrm_email ce INNER JOIN civicrm_contact cc ON cc.id = ce.contact_id\n       {$aclFrom}\nWHERE  ce.on_hold = 0 AND cc.is_deceased = 0 AND cc.do_not_email = 0 AND {$queryString}\n       {$aclWhere}\n";
             $dao = CRM_Core_DAO::executeQuery($query);
             while ($dao->fetch()) {
                 $result[] = array('name' => '"' . $dao->name . '" &lt;' . $dao->email . '&gt;', 'id' => CRM_Utils_Array::value('id', $_GET) ? "{$dao->id}::{$dao->email}" : '"' . $dao->name . '" <' . $dao->email . '>');
             }
         }
         if ($result) {
             echo json_encode($result);
         }
     }
     exit;
 }
开发者ID:bhirsch,项目名称:civicrm,代码行数:50,代码来源:AJAX.php

示例8: buildACLClause

 function buildACLClause($tableAlias = 'contact_a')
 {
     require_once 'CRM/Contact/BAO/Contact/Permission.php';
     list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:5,代码来源:Form.php

示例9: thresholdQuery

 /**
  * Return the SQL query for getting only the interesting results out of the dedupe table.
  */
 function thresholdQuery()
 {
     require_once 'CRM/Contact/BAO/Contact/Permission.php';
     if ($this->params && !$this->noRules) {
         list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('civicrm_contact');
         $this->_aclWhere = $this->_aclWhere ? "AND {$this->_aclWhere}" : '';
         $query = "SELECT dedupe.id\n                FROM dedupe JOIN civicrm_contact USING (id) {$this->_aclFrom}\n                WHERE contact_type = '{$this->contact_type}' {$this->_aclWhere}\n                GROUP BY dedupe.id HAVING SUM(weight) >= {$this->threshold}\n                ORDER BY SUM(weight) desc";
     } else {
         list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause(array('c1', 'c2'));
         $this->_aclWhere = $this->_aclWhere ? "AND {$this->_aclWhere}" : '';
         $query = "SELECT dedupe.id1, dedupe.id2, SUM(weight) as weight\n                FROM dedupe JOIN civicrm_contact c1 ON dedupe.id1 = c1.id \n                            JOIN civicrm_contact c2 ON dedupe.id2 = c2.id {$this->_aclFrom}\n                WHERE c1.contact_type = '{$this->contact_type}' AND \n                      c2.contact_type = '{$this->contact_type}' {$this->_aclWhere}\n                GROUP BY dedupe.id1, dedupe.id2 HAVING SUM(weight) >= {$this->threshold}\n                ORDER BY SUM(weight) desc";
     }
     return $query;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:17,代码来源:RuleGroup.php

示例10: civicrm_api3_contact_getquick

function civicrm_api3_contact_getquick($params)
{
    civicrm_api3_verify_mandatory($params, NULL, array('name'));
    $name = CRM_Utils_Array::value('name', $params);
    // get the autocomplete options from settings
    require_once 'CRM/Core/BAO/Setting.php';
    $acpref = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options'));
    // get the option values for contact autocomplete
    $acOptions = CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, FALSE, NULL, 'name');
    $list = array();
    foreach ($acpref as $value) {
        if ($value && CRM_Utils_Array::value($value, $acOptions)) {
            $list[$value] = $acOptions[$value];
        }
    }
    $select = $actualSelectElements = array('sort_name');
    $where = '';
    $from = array();
    foreach ($list as $value) {
        $suffix = substr($value, 0, 2) . substr($value, -1);
        switch ($value) {
            case 'street_address':
            case 'city':
                $selectText = $value;
                $value = "address";
                $suffix = 'sts';
            case 'phone':
            case 'email':
                $actualSelectElements[] = $select[] = $value == 'address' ? $selectText : $value;
                $from[$value] = "LEFT JOIN civicrm_{$value} {$suffix} ON ( cc.id = {$suffix}.contact_id AND {$suffix}.is_primary = 1 ) ";
                break;
            case 'country':
            case 'state_province':
                $select[] = "{$suffix}.name as {$value}";
                $actualSelectElements[] = "{$suffix}.name";
                if (!in_array('address', $from)) {
                    $from['address'] = 'LEFT JOIN civicrm_address sts ON ( cc.id = sts.contact_id AND sts.is_primary = 1) ';
                }
                $from[$value] = " LEFT JOIN civicrm_{$value} {$suffix} ON ( sts.{$value}_id = {$suffix}.id  ) ";
                break;
        }
    }
    $config = CRM_Core_Config::singleton();
    $as = $select;
    $select = implode(', ', $select);
    if (!empty($select)) {
        $select = ", {$select}";
    }
    $actualSelectElements = implode(', ', $actualSelectElements);
    $selectAliases = $from;
    unset($selectAliases['address']);
    $selectAliases = implode(', ', array_keys($selectAliases));
    if (!empty($selectAliases)) {
        $selectAliases = ", {$selectAliases}";
    }
    $from = implode(' ', $from);
    $limit = CRM_Utils_Array::value('limit', $params, 10);
    // add acl clause here
    require_once 'CRM/Contact/BAO/Contact/Permission.php';
    list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause('cc');
    if ($aclWhere) {
        $where .= " AND {$aclWhere} ";
    }
    if (CRM_Utils_Array::value('org', $params)) {
        $where .= " AND contact_type = \"Organization\"";
        //set default for current_employer
        if ($orgId = CRM_Utils_Array::value('id', $params)) {
            $where .= " AND cc.id = {$orgId}";
        }
        // CRM-7157, hack: get current employer details when
        // employee_id is present.
        $currEmpDetails = array();
        if (CRM_Utils_Array::value('employee_id', $params)) {
            if ($currentEmployer = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', CRM_Utils_Array::value('employee_id', $params), 'employer_id')) {
                if ($config->includeWildCardInName) {
                    $strSearch = "%{$name}%";
                } else {
                    $strSearch = "{$name}%";
                }
                // get current employer details
                $dao = CRM_Core_DAO::executeQuery("SELECT cc.id as id, CONCAT_WS( ' :: ', {$actualSelectElements} ) as data, sort_name\n                    FROM civicrm_contact cc {$from} WHERE cc.contact_type = \"Organization\" AND cc.id = {$currentEmployer} AND cc.sort_name LIKE '{$strSearch}'");
                if ($dao->fetch()) {
                    $currEmpDetails = array('id' => $dao->id, 'data' => $dao->data);
                }
            }
        }
    }
    if (CRM_Utils_Array::value('cid', $params)) {
        $where .= " AND cc.id <> {$params['cid']}";
    }
    //contact's based of relationhip type
    $relType = NULL;
    if (CRM_Utils_Array::value('rel', $params)) {
        $relation = explode('_', CRM_Utils_Array::value('rel', $params));
        $relType = CRM_Utils_Type::escape($relation[0], 'Integer');
        $rel = CRM_Utils_Type::escape($relation[2], 'String');
    }
    if ($config->includeWildCardInName) {
        $strSearch = "%{$name}%";
    } else {
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Contact.php


注:本文中的CRM_Contact_BAO_Contact_Permission::cacheClause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。