本文整理汇总了PHP中CRM_Campaign_BAO_Survey::getSurvey方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Campaign_BAO_Survey::getSurvey方法的具体用法?PHP CRM_Campaign_BAO_Survey::getSurvey怎么用?PHP CRM_Campaign_BAO_Survey::getSurvey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Campaign_BAO_Survey
的用法示例。
在下文中一共展示了CRM_Campaign_BAO_Survey::getSurvey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
示例2: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @param null
*
* @return array array of default values
* @access public
*/
function setDefaultValues()
{
$defaults = $this->_values;
if ($this->_surveyId) {
require_once 'CRM/Core/BAO/UFJoin.php';
if (CRM_Utils_Array::value('result_id', $defaults) && CRM_Utils_Array::value('recontact_interval', $defaults)) {
require_once 'CRM/Core/OptionValue.php';
$resultId = $defaults['result_id'];
$recontactInterval = unserialize($defaults['recontact_interval']);
unset($defaults['recontact_interval']);
$defaults['option_group_id'] = $resultId;
}
$ufJoinParams = array('entity_table' => 'civicrm_survey', 'entity_id' => $this->_surveyId, 'weight' => 1);
if ($ufGroupId = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams)) {
$defaults['profile_id'] = $ufGroupId;
}
}
if (!isset($defaults['is_active'])) {
$defaults['is_active'] = 1;
}
// set defaults for weight.
for ($i = 1; $i <= self::NUM_OPTION; $i++) {
$defaults["option_weight[{$i}]"] = $i;
}
$defaultSurveys = CRM_Campaign_BAO_Survey::getSurvey(false, false, true);
if (!isset($defaults['is_default']) && empty($defaultSurveys)) {
$defaults['is_default'] = 1;
}
return $defaults;
}
示例3: buildQuickForm
/**
* Build the form
*
* @access public
* @return void
*/
function buildQuickForm()
{
if ($this->_search) {
return;
}
//build common search form.
require_once 'CRM/Campaign/BAO/Query.php';
CRM_Campaign_BAO_Query::buildSearchForm($this);
//build the array of all search params.
$this->_searchParams = array();
foreach ($this->_elements as $element) {
$name = $element->_attributes['name'];
$this->_searchParams[$name] = $name;
}
$this->set('searchParams', $this->_searchParams);
$this->assign('searchParams', json_encode($this->_searchParams));
$defaults = array();
if (!$this->_surveyId) {
$this->_surveyId = key(CRM_Campaign_BAO_Survey::getSurvey(false, null, true));
}
if ($this->_force || $this->_votingTab) {
$session = CRM_Core_Session::singleton();
$userId = $session->get('userID');
// get interviewer id
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, false, $userId);
require_once 'CRM/Contact/BAO/Contact.php';
$defaults['survey_interviewer_id'] = $cid;
$defaults['survey_interviewer_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name', 'id');
}
if ($this->_surveyId) {
$defaults['campaign_survey_id'] = $this->_surveyId;
}
if (!empty($defaults)) {
$this->setDefaults($defaults);
}
//validate the required ids.
$this->validateIds();
}
示例4: fixFormValues
function fixFormValues()
{
// if this search has been forced
// then see if there are any get values, and if so over-ride the post values
// note that this means that GET over-rides POST :)
//since we have qfKey, no need to manipulate set defaults.
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject);
if (!$this->_force || CRM_Utils_Rule::qfKey($qfKey)) {
return;
}
// get survey id
$surveyId = CRM_Utils_Request::retrieve('sid', 'Positive', CRM_Core_DAO::$_nullObject);
if ($surveyId) {
$surveyId = CRM_Utils_Type::escape($surveyId, 'Integer');
} else {
// use default survey id
$surveyId = key(CRM_Campaign_BAO_Survey::getSurvey(false, null, true));
}
if (!$surveyId) {
CRM_Core_Error::fatal('Could not find valid Survey Id.');
}
$this->_formValues['campaign_survey_id'] = $this->_formValues['campaign_survey_id'] = $surveyId;
$session = CRM_Core_Session::singleton();
$userId = $session->get('userID');
// get interviewer id
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, false, $userId);
//to force other contact as interviewer, user should be admin.
if ($cid != $userId && !CRM_Core_Permission::check('administer CiviCampaign')) {
CRM_Utils_System::permissionDenied();
CRM_Utils_System::civiExit();
}
require_once 'CRM/Contact/BAO/Contact.php';
$this->_formValues['survey_interviewer_id'] = $cid;
$this->_formValues['survey_interviewer_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name', 'id');
//get all in defaults.
$this->_defaults = $this->_formValues;
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
}
示例5: 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'));
}