本文整理匯總了PHP中CRM_Campaign_BAO_Survey::getSurveyProfileId方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Campaign_BAO_Survey::getSurveyProfileId方法的具體用法?PHP CRM_Campaign_BAO_Survey::getSurveyProfileId怎麽用?PHP CRM_Campaign_BAO_Survey::getSurveyProfileId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Campaign_BAO_Survey
的用法示例。
在下文中一共展示了CRM_Campaign_BAO_Survey::getSurveyProfileId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: filterVoterIds
public function filterVoterIds()
{
//do the cleanup later on.
if (!is_array($this->_contactIds)) {
return;
}
$profileId = CRM_Campaign_BAO_Survey::getSurveyProfileId($this->_surveyId);
if ($profileId) {
$profileType = CRM_Core_BAO_UFField::getProfileType($profileId);
if (in_array($profileType, CRM_Contact_BAO_ContactType::basicTypes())) {
$voterIdCount = count($this->_contactIds);
//create temporary table to store voter ids.
$tempTableName = CRM_Core_DAO::createTempTableName('civicrm_survey_respondent');
CRM_Core_DAO::executeQuery("DROP TEMPORARY TABLE IF EXISTS {$tempTableName}");
$query = "\n CREATE TEMPORARY TABLE {$tempTableName} (\n id int unsigned NOT NULL AUTO_INCREMENT,\n survey_contact_id int unsigned NOT NULL,\n PRIMARY KEY ( id )\n);\n";
CRM_Core_DAO::executeQuery($query);
$batch = 100;
$insertedCount = 0;
do {
$processIds = $this->_contactIds;
$insertIds = array_splice($processIds, $insertedCount, $batch);
if (!empty($insertIds)) {
$insertSQL = "INSERT IGNORE INTO {$tempTableName}( survey_contact_id )\n VALUES (" . implode('),(', $insertIds) . ');';
CRM_Core_DAO::executeQuery($insertSQL);
}
$insertedCount += $batch;
} while ($insertedCount < $voterIdCount);
$query = "\n SELECT contact.id as id\n FROM civicrm_contact contact\nINNER JOIN {$tempTableName} ON ( {$tempTableName}.survey_contact_id = contact.id )\n WHERE contact.contact_type != %1";
$removeContact = CRM_Core_DAO::executeQuery($query, array(1 => array($profileType, 'String')));
while ($removeContact->fetch()) {
unset($this->_contactIds[$removeContact->id]);
}
}
}
}