本文整理汇总了PHP中CRM_Campaign_BAO_Survey::getSurveyActivityType方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Campaign_BAO_Survey::getSurveyActivityType方法的具体用法?PHP CRM_Campaign_BAO_Survey::getSurveyActivityType怎么用?PHP CRM_Campaign_BAO_Survey::getSurveyActivityType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Campaign_BAO_Survey
的用法示例。
在下文中一共展示了CRM_Campaign_BAO_Survey::getSurveyActivityType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
if ($this->_search) {
return;
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey');
$this->add('text', 'survey_title', ts('Title'), $attributes['title']);
//activity Type id
$surveyTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
$this->add('select', 'activity_type_id', ts('Activity Type'), array('' => ts('- select -')) + $surveyTypes);
$this->set('surveyTypes', $surveyTypes);
$this->assign('surveyTypes', json_encode($surveyTypes));
//campaigns
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$this->add('select', 'survey_campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns);
$this->set('surveyCampaigns', $campaigns);
$this->assign('surveyCampaigns', json_encode($campaigns));
//build the array of all search params.
$this->_searchParams = array();
foreach ($this->_elements as $element) {
$name = $element->_attributes['name'];
$label = $element->_label;
if ($name == 'qfKey') {
continue;
}
$this->_searchParams[$name] = $label ? $label : $name;
}
$this->set('searchParams', $this->_searchParams);
$this->assign('searchParams', json_encode($this->_searchParams));
}
示例2: browse
function browse()
{
require_once 'CRM/Core/Permission.php';
$surveys = CRM_Campaign_BAO_Survey::getSurvey(true);
if (!empty($surveys)) {
require_once 'CRM/Campaign/BAO/Campaign.php';
$surveyType = CRM_Campaign_BAO_Survey::getSurveyActivityType();
$campaigns = CRM_Campaign_BAO_Campaign::getAllCampaign();
$activityTypes = CRM_Core_OptionGroup::values('activity_type', false, false, false, false, 'name');
foreach ($surveys as $sid => $survey) {
$surveys[$sid]['campaign_id'] = $campaigns[$survey['campaign_id']];
$surveys[$sid]['activity_type_id'] = $surveyType[$survey['activity_type_id']];
$surveys[$sid]['release_frequency'] = $survey['release_frequency_interval'] . ' ' . $survey['release_frequency_unit'];
$action = array_sum(array_keys($this->actionLinks()));
if ($survey['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$surveys[$sid]['action'] = CRM_Core_Action::formLink($this->actionLinks(), $action, array('id' => $sid));
}
}
$this->assign('surveys', $surveys);
$this->assign('addSurveyUrl', CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add'));
}
示例3: releaseRespondent
public function releaseRespondent()
{
require_once 'CRM/Core/PseudoConstant.php';
require_once 'CRM/Campaign/BAO/Survey.php';
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$reserveStatusId = array_search('Scheduled', $activityStatus);
$surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
$surveyActivityTypesIds = array_keys($surveyActivityTypes);
//retrieve all survey activities related to reserve action.
$releasedCount = 0;
if ($reserveStatusId && !empty($surveyActivityTypesIds)) {
$query = '
SELECT activity.id as id,
activity.activity_date_time as activity_date_time,
survey.id as surveyId,
survey.release_frequency as release_frequency
FROM civicrm_activity activity
INNER JOIN civicrm_survey survey ON ( survey.id = activity.source_record_id )
WHERE activity.is_deleted = 0
AND activity.status_id = %1
AND activity.activity_type_id IN ( ' . implode(', ', $surveyActivityTypesIds) . ' )';
$activity = CRM_Core_DAO::executeQuery($query, array(1 => array($reserveStatusId, 'Positive')));
$releasedIds = array();
while ($activity->fetch()) {
if (!$activity->release_frequency) {
continue;
}
$reservedSeconds = CRM_Utils_Date::unixTime($activity->activity_date_time);
$releasedSeconds = $activity->release_frequency * 24 * 3600;
$totalReservedSeconds = $reservedSeconds + $releasedSeconds;
if ($totalReservedSeconds < time()) {
$releasedIds[$activity->id] = $activity->id;
}
}
//released respondent.
if (!empty($releasedIds)) {
$query = '
UPDATE civicrm_activity
SET is_deleted = 1
WHERE id IN ( ' . implode(', ', $releasedIds) . ' )';
CRM_Core_DAO::executeQuery($query);
$releasedCount = count($releasedIds);
}
}
echo "<br /><br />Number of respondents released = {$releasedCount}";
}
示例4: browse
public function browse()
{
$surveys = CRM_Campaign_BAO_Survey::getSurveySummary();
if (!empty($surveys)) {
$surveyType = CRM_Campaign_BAO_Survey::getSurveyActivityType();
$campaigns = CRM_Campaign_BAO_Campaign::getAllCampaign();
$activityTypes = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, FALSE, 'name');
foreach ($surveys as $sid => $survey) {
$surveys[$sid]['campaign_id'] = $campaigns[$survey['campaign_id']];
$surveys[$sid]['activity_type_id'] = $surveyType[$survey['activity_type_id']];
$surveys[$sid]['release_frequency'] = $survey['release_frequency_interval'] . ' ' . $survey['release_frequency_unit'];
$action = array_sum(array_keys($this->actionLinks()));
if ($survey['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$surveys[$sid]['action'] = CRM_Core_Action::formLink($this->actionLinks(), $action, array('id' => $sid), ts('more'), FALSE, 'survey.selector.row', 'Survey', $sid);
}
}
$this->assign('surveys', $surveys);
$this->assign('addSurveyUrl', CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add'));
}
示例5: getPetitionSummary
/**
* @param array $params
*
* @return array
*/
public static function getPetitionSummary($params = array())
{
$config = CRM_Core_Config::singleton();
$petitionsData = array();
//get the petitions.
$petitions = CRM_Campaign_BAO_Petition::getPetitionSummary($params);
if (!empty($petitions)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$petitionType = CRM_Campaign_BAO_Survey::getSurveyActivityType('label', TRUE);
foreach ($petitions as $pid => $petition) {
$petitionsData[$pid] = $petition;
$camapignId = CRM_Utils_Array::value('campaign_id', $petition);
$petitionsData[$pid]['campaign'] = CRM_Utils_Array::value($camapignId, $campaigns);
$petitionsData[$pid]['activity_type'] = $petitionType[$petition['activity_type_id']];
$action = array_sum(array_keys(self::petitionActionLinks()));
if ($petition['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$isActive = ts('No');
if ($petitionsData[$pid]['is_active']) {
$isActive = ts('Yes');
}
$petitionsData[$pid]['isActive'] = $isActive;
$isDefault = NULL;
if ($petitionsData[$pid]['is_default']) {
$isDefault = '<img src="' . $config->resourceBase . 'i/check.gif" alt="' . ts('Default') . '" />';
}
$petitionsData[$pid]['is_default'] = $isDefault;
$petitionsData[$pid]['action'] = CRM_Core_Action::formLink(self::petitionActionLinks(), $action, array('id' => $pid), ts('more'), FALSE, 'petition.dashboard.row', 'Petition', $pid);
}
}
return $petitionsData;
}
示例6: buildQuickForm
/**
* Function to actually build the form
*
* @param null
*
* @return void
* @access public
*/
public function buildQuickForm()
{
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
$this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'title'), TRUE);
$surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
// Activity Type id
$this->addSelect('activity_type_id', array(), TRUE);
// Campaign id
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value('campaign_id', $this->_values));
$this->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns);
// script / instructions
$this->addWysiwyg('instructions', ts('Instructions for interviewers'), array('rows' => 5, 'cols' => 40));
// release frequency
$this->add('text', 'release_frequency', ts('Release frequency'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency'));
$this->addRule('release_frequency', ts('Release Frequency interval should be a positive number.'), 'positiveInteger');
// max reserved contacts at a time
$this->add('text', 'default_number_of_contacts', ts('Maximum reserved at one time'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'default_number_of_contacts'));
$this->addRule('default_number_of_contacts', ts('Maximum reserved at one time should be a positive number'), 'positiveInteger');
// total reserved per interviewer
$this->add('text', 'max_number_of_contacts', ts('Total reserved per interviewer'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'max_number_of_contacts'));
$this->addRule('max_number_of_contacts', ts('Total reserved contacts should be a positive number'), 'positiveInteger');
// is active ?
$this->add('checkbox', 'is_active', ts('Active?'));
// is default ?
$this->add('checkbox', 'is_default', ts('Default?'));
parent::buildQuickForm();
}
示例7: buildQuickForm
/**
* Function to actually build the form
*
* @param null
*
* @return void
* @access public
*/
public function buildQuickForm()
{
if ($this->_action & CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
require_once 'CRM/Event/PseudoConstant.php';
require_once 'CRM/Core/BAO/UFGroup.php';
require_once 'CRM/Core/BAO/CustomField.php';
$this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'title'), true);
$surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
// Activity Type id
$this->add('select', 'activity_type_id', ts('Activity Type'), array('' => ts('- select -')) + $surveyActivityTypes, true);
// Campaign id
require_once 'CRM/Campaign/BAO/Campaign.php';
$campaigns = CRM_Campaign_BAO_Campaign::getAllCampaign();
$this->add('select', 'campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns);
$customProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Activity'));
// custom group id
$this->add('select', 'profile_id', ts('Profile'), array('' => ts('- select -')) + $customProfiles);
$optionGroups = CRM_Campaign_BAO_Survey::getResultSets();
if (empty($optionGroups)) {
$optionTypes = array('1' => ts('Create new response set'));
} else {
$optionTypes = array('1' => ts('Create a new response set'), '2' => ts('Use existing response set'));
$this->add('select', 'option_group_id', ts('Select Response Set'), array('' => ts('- select -')) + $optionGroups, false, array('onChange' => 'loadOptionGroup( )'));
}
$element =& $this->addRadio('option_type', ts('Survey Responses'), $optionTypes, array('onclick' => "showOptionSelect();"), '<br/>', true);
if (empty($optionGroups) || !CRM_Utils_Array::value('result_id', $this->_values)) {
$this->setdefaults(array('option_type' => 1));
} else {
if (CRM_Utils_Array::value('result_id', $this->_values)) {
$this->setdefaults(array('option_type' => 2, 'option_group_id' => $this->_values['result_id']));
}
}
// form fields of Custom Option rows
$defaultOption = array();
$_showHide = new CRM_Core_ShowHideBlocks('', '');
$optionAttributes =& CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue');
$optionAttributes['label']['size'] = $optionAttributes['value']['size'] = 25;
for ($i = 1; $i <= self::NUM_OPTION; $i++) {
//the show hide blocks
$showBlocks = 'optionField_' . $i;
if ($i > 2) {
$_showHide->addHide($showBlocks);
if ($i == self::NUM_OPTION) {
$_showHide->addHide('additionalOption');
}
} else {
$_showHide->addShow($showBlocks);
}
$this->add('text', 'option_label[' . $i . ']', ts('Label'), $optionAttributes['label']);
// value
$this->add('text', 'option_value[' . $i . ']', ts('Value'), $optionAttributes['value']);
// weight
$this->add('text', "option_weight[{$i}]", ts('Order'), $optionAttributes['weight']);
$this->add('text', 'option_interval[' . $i . ']', ts('Recontact Interval'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency'));
$defaultOption[$i] = $this->createElement('radio', null, null, null, $i);
}
//default option selection
$this->addGroup($defaultOption, 'default_option');
$_showHide->addToTemplate();
// script / instructions
$this->add('textarea', 'instructions', ts('Instructions for interviewers'), array('rows' => 5, 'cols' => 40));
// release frequency
$this->add('text', 'release_frequency', ts('Release frequency'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency'));
$this->addRule('release_frequency', ts('Release Frequency interval should be a positive number.'), 'positiveInteger');
// max reserved contacts at a time
$this->add('text', 'default_number_of_contacts', ts('Maximum reserved at one time'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'default_number_of_contacts'));
$this->addRule('default_number_of_contacts', ts('Maximum reserved at one time should be a positive number'), 'positiveInteger');
// total reserved per interviewer
$this->add('text', 'max_number_of_contacts', ts('Total reserved per interviewer'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'max_number_of_contacts'));
$this->addRule('max_number_of_contacts', ts('Total reserved contacts should be a positive number'), 'positiveInteger');
// is active ?
$this->add('checkbox', 'is_active', ts('Active?'));
// is default ?
$this->add('checkbox', 'is_default', ts('Default?'));
// add buttons
if ($this->_context == 'dialog') {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'), 'js' => array('onclick' => "cj('#survey-dialog').dialog('close'); return false;"))));
} else {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
// add a form rule to check default value
$this->addFormRule(array('CRM_Campaign_Form_Survey', 'formRule'), $this);
}
示例8: where
public function where()
{
$clauses = array();
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('filters', $table)) {
foreach ($table['filters'] as $fieldName => $field) {
$clause = NULL;
if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
$relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
$from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
$to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
$clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
} else {
$op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
if ($op) {
$clause = $this->whereClause($field, $op, CRM_Utils_Array::value("{$fieldName}_value", $this->_params), CRM_Utils_Array::value("{$fieldName}_min", $this->_params), CRM_Utils_Array::value("{$fieldName}_max", $this->_params));
}
}
if (!empty($clause)) {
$clauses[] = $clause;
}
}
}
}
//apply survey activity types filter.
$surveyActivityTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
if (!empty($surveyActivityTypes)) {
$clauses[] = "( {$this->_aliases['civicrm_activity']}.activity_type_id IN ( " . implode(' , ', array_keys($surveyActivityTypes)) . ' ) )';
}
// always filter out deleted activities (so contacts that have been released
// don't show up in the report).
$clauses[] = "( {$this->_aliases['civicrm_activity']}.is_deleted = 0 )";
if (empty($clauses)) {
$this->_where = "WHERE ( 1 ) ";
} else {
$this->_where = "WHERE " . implode(' AND ', $clauses);
}
if ($this->_aclWhere) {
$this->_where .= " AND {$this->_aclWhere} ";
}
}
示例9: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
$this->_interviewToRelease = $this->get('interviewToRelease');
if ($this->_interviewToRelease) {
//user came from interview form.
foreach (array('surveyId', 'contactIds', 'interviewerId') as $fld) {
$this->{"_{$fld}"} = $this->get($fld);
}
if (!empty($this->_contactIds)) {
$this->assign('totalSelectedContacts', count($this->_contactIds));
}
} else {
parent::preProcess();
//get the survey id from user submitted values.
$this->_surveyId = CRM_Utils_Array::value('campaign_survey_id', $this->get('formValues'));
$this->_interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->get('formValues'));
}
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$surveyActType = CRM_Campaign_BAO_Survey::getSurveyActivityType();
if (!$this->_surveyId) {
CRM_Core_Error::statusBounce(ts("Please search with 'Survey', to apply this action."));
}
if (!$this->_interviewerId) {
CRM_Core_Error::statusBounce(ts('Missing Interviewer contact.'));
}
if (!is_array($this->_contactIds) || empty($this->_contactIds)) {
CRM_Core_Error::statusBounce(ts('Could not find respondents to release.'));
}
$surveyDetails = array();
$params = array('id' => $this->_surveyId);
$this->_surveyDetails = CRM_Campaign_BAO_Survey::retrieve($params, $surveyDetails);
require_once 'CRM/Core/PseudoConstant.php';
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$statusIds = array();
foreach (array('Scheduled') as $name) {
if ($statusId = array_search($name, $activityStatus)) {
$statusIds[] = $statusId;
}
}
//fetch the target survey activities.
$this->_surveyActivities = CRM_Campaign_BAO_Survey::voterActivityDetails($this->_surveyId, $this->_contactIds, $this->_interviewerId, $statusIds);
if (count($this->_surveyActivities) < 1) {
CRM_Core_Error::statusBounce(ts('We could not found respondent for this survey to release.'));
}
$this->assign('surveyTitle', $surveyDetails['title']);
//append breadcrumb to survey dashboard.
require_once 'CRM/Campaign/BAO/Campaign.php';
if (CRM_Campaign_BAO_Campaign::accessCampaignDashboard()) {
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url)));
}
//set the title.
CRM_Utils_System::setTitle(ts('Release Respondents'));
}
示例10: browseSurvey
function browseSurvey()
{
$surveysData = array();
//get the survey.
$surveys = CRM_Campaign_BAO_Survey::getSurvey(true);
if (!empty($surveys)) {
$campaigns = CRM_Campaign_BAO_Campaign::getAllCampaign();
$surveyType = CRM_Campaign_BAO_Survey::getSurveyActivityType();
foreach ($surveys as $sid => $survey) {
$surveysData[$sid] = $survey;
$campaignId = CRM_Utils_Array::value('campaign_id', $survey);
$surveysData[$sid]['campaign_id'] = CRM_Utils_Array::value($campaignId, $campaigns);
$surveysData[$sid]['activity_type'] = $surveyType[$survey['activity_type_id']];
if (CRM_Utils_Array::value('release_frequency', $survey)) {
$surveysData[$sid]['release_frequency'] = $survey['release_frequency'] . ' Day(s)';
}
$action = array_sum(array_keys($this->surveyActionLinks($surveysData[$sid]['activity_type'])));
if ($survey['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$surveysData[$sid]['action'] = CRM_Core_Action::formLink($this->surveyActionLinks($surveysData[$sid]['activity_type']), $action, array('id' => $sid));
if (CRM_Utils_Array::value('activity_type', $surveysData[$sid]) != 'Petition') {
$surveysData[$sid]['voterLinks'] = CRM_Campaign_BAO_Survey::buildPermissionLinks($sid);
}
}
}
$this->assign('surveys', $surveysData);
$this->assign('addSurveyUrl', CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add'));
}