本文整理汇总了PHP中CRM_Campaign_BAO_Campaign::accessCampaign方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Campaign_BAO_Campaign::accessCampaign方法的具体用法?PHP CRM_Campaign_BAO_Campaign::accessCampaign怎么用?PHP CRM_Campaign_BAO_Campaign::accessCampaign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Campaign_BAO_Campaign
的用法示例。
在下文中一共展示了CRM_Campaign_BAO_Campaign::accessCampaign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
if ($this->_surveyId) {
$this->_single = TRUE;
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
$this->_surveyTitle = $surveyInfo['title'];
$this->assign('surveyTitle', $this->_surveyTitle);
CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle)));
}
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
$this->set('type', 'Event');
$this->set('entityId', $this->_surveyId);
CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
// CRM-11480, CRM-11682
// Preload libraries required by the "Questions" tab
CRM_UF_Page_ProfileEditor::registerProfileScripts();
CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel'));
CRM_Campaign_Form_Survey_TabHeader::build($this);
}
示例2: preProcess
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $this->_context);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_System::setTitle(ts('Edit Survey'));
} else {
CRM_Utils_System::setTitle(ts('Delete Survey'));
}
}
$this->_cdType = CRM_Utils_Array::value('type', $_GET);
$this->assign('cdType', FALSE);
if ($this->_cdType) {
$this->assign('cdType', TRUE);
return CRM_Custom_Form_CustomData::preProcess($this);
}
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
CRM_Custom_Form_CustomData::preProcess($this);
CRM_Custom_Form_CustomData::buildQuickForm($this);
}
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
$session->pushUserContext($url);
$this->_values = $this->get('values');
if (!is_array($this->_values)) {
$this->_values = array();
if ($this->_surveyId) {
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $this->_values);
}
$this->set('values', $this->_values);
}
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
// for custom data
$this->assign('entityID', $this->_surveyId);
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_System::setTitle(ts('Edit Petition'));
} else {
CRM_Utils_System::setTitle(ts('Delete Petition'));
}
}
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=petition');
$session->pushUserContext($url);
CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Petition Dashboard'), 'url' => $url)));
}
示例3: run
function run()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0);
$this->assign('action', $action);
$this->browse();
return parent::run();
}
示例4: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
$this->_surveyTitle = $surveyInfo['title'];
$this->assign('surveyTitle', $this->_surveyTitle);
CRM_Utils_System::setTitle(ts('Delete Survey') . ' - ' . $this->_surveyTitle);
}
示例5: preProcess
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
//check for custom data type.
$this->_cdType = CRM_Utils_Array::value('type', $_GET);
$this->assign('cdType', FALSE);
if ($this->_cdType) {
$this->assign('cdType', TRUE);
return CRM_Custom_Form_CustomData::preProcess($this);
}
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $this->_context);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
$this->_campaignId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$title = NULL;
if ($this->_action & CRM_Core_Action::UPDATE) {
$title = ts('Edit Campaign');
}
if ($this->_action & CRM_Core_Action::DELETE) {
$title = ts('Delete Campaign');
}
if ($title) {
CRM_Utils_System::setTitle($title);
}
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
$this->assign('action', $this->_action);
//load the values;
$this->_values = $this->get('values');
if (!is_array($this->_values)) {
$this->_values = array();
// if we are editing
if (isset($this->_campaignId) && $this->_campaignId) {
$params = array('id' => $this->_campaignId);
CRM_Campaign_BAO_Campaign::retrieve($params, $this->_values);
}
//lets use current object session.
$this->set('values', $this->_values);
}
// when custom data is included in form.
if (!empty($_POST['hidden_custom'])) {
$this->set('type', 'Campaign');
$this->set('subType', CRM_Utils_Array::value('campaign_type_id', $_POST));
$this->set('entityId', $this->_campaignId);
CRM_Custom_Form_CustomData::preProcess($this);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
}
示例6: preProcess
public function preProcess()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
$this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
if ($this->_surveyId) {
$this->_single = TRUE;
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
$this->_surveyTitle = $surveyInfo['title'];
$this->assign('surveyTitle', $this->_surveyTitle);
CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle)));
}
$this->assign('action', $this->_action);
$this->assign('surveyId', $this->_surveyId);
// CRM-11480, CRM-11682
// Preload libraries required by the "Questions" tab
CRM_UF_Page_ProfileEditor::registerProfileScripts();
CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel'));
CRM_Campaign_Form_Survey_TabHeader::build($this);
}
示例7: preProcess
/**
* Processing needed for buildForm and later.
*/
public function preProcess()
{
$this->_search = CRM_Utils_Array::value('search', $_GET);
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_surveyId = CRM_Utils_Request::retrieve('sid', 'Positive', $this);
$this->_interviewerId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
//does control come from voting tab interface.
$this->_votingTab = $this->get('votingTab');
$this->_subVotingTab = $this->get('subVotingTab');
$this->_searchVoterFor = 'gotv';
if ($this->_votingTab) {
if ($this->_subVotingTab == 'searchANDReserve') {
$this->_searchVoterFor = 'reserve';
} elseif ($this->_subVotingTab == 'searchANDInterview') {
$this->_searchVoterFor = 'interview';
}
}
$this->assign('force', $this->_force);
$this->assign('votingTab', $this->_votingTab);
$this->assign('searchParams', json_encode($this->get('searchParams')));
$this->assign('buildSelector', $this->_search);
$this->assign('searchVoterFor', $this->_searchVoterFor);
$this->set('searchVoterFor', $this->_searchVoterFor);
$surveyTitle = NULL;
if ($this->_surveyId) {
$surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_surveyId, 'title');
}
$this->assign('surveyTitle', $surveyTitle);
//append breadcrumb to survey dashboard.
if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
$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 form title.
CRM_Utils_System::setTitle(ts('GOTV (Voter Tracking)'));
}
示例8: buildSearchForm
/**
* add all the elements shared between case activity search and advanaced search
*
* @access public
*
* @return void
* @static
*/
static function buildSearchForm(&$form)
{
$activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
asort($activityOptions);
foreach ($activityOptions as $activityID => $activity) {
$form->_activityElement =& $form->addElement('checkbox', "activity_type_id[{$activityID}]", NULL, $activity, array('onClick' => 'showCustomData( this.id );'));
}
CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
$activityRoles = array(1 => ts('Created by'), 2 => ts('Assigned to'));
$form->addRadio('activity_role', NULL, $activityRoles, NULL, '<br />');
$form->addElement('text', 'activity_contact_name', ts('Contact Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
foreach ($activityStatus as $activityStatusID => $activityStatusName) {
$activity_status[] = $form->createElement('checkbox', $activityStatusID, NULL, $activityStatusName);
}
$form->addGroup($activity_status, 'activity_status', ts('Activity Status'));
$form->setDefaults(array('activity_status[1]' => 1, 'activity_status[2]' => 1));
$form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$form->addElement('checkbox', 'activity_test', ts('Find Test Activities?'));
$activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
if ($activity_tags) {
foreach ($activity_tags as $tagID => $tagName) {
$form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", NULL, $tagName);
}
}
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, FALSE, TRUE);
$surveys = CRM_Campaign_BAO_Survey::getSurveys();
if ($surveys) {
$form->add('select', 'activity_survey_id', ts('Survey'), array('' => ts('- none -')) + $surveys, FALSE);
}
$extends = array('Activity');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
if ($groupDetails) {
$form->assign('activityGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
}
}
}
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
//add engagement level CRM-7775
$buildEngagementLevel = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$buildEngagementLevel = TRUE;
$form->add('select', 'activity_engagement_level', ts('Engagement Index'), array('' => ts('- select -')) + CRM_Campaign_PseudoConstant::engagementLevel());
}
$form->assign('buildEngagementLevel', $buildEngagementLevel);
}
示例9: buildQuickForm
public function buildQuickForm()
{
if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
//enable form element (ActivityLinks sets this true)
$this->assign('suppressForm', FALSE);
$button = ts('Delete');
if ($this->_action & CRM_Core_Action::RENEW) {
$button = ts('Restore');
}
$this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
// Build other activity links.
CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this);
// Enable form element (ActivityLinks sets this true).
$this->assign('suppressForm', FALSE);
$element =& $this->add('select', 'activity_type_id', ts('Activity Type'), array('' => '- ' . ts('select') . ' -') + $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );", 'class' => 'crm-select2 required'));
// Freeze for update mode.
if ($this->_action & CRM_Core_Action::UPDATE) {
$element->freeze();
}
// Call to RecurringEntity buildQuickForm for add/update mode.
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
CRM_Core_Form_RecurringEntity::buildQuickForm($this);
}
foreach ($this->_fields as $field => $values) {
if (!empty($this->_fields[$field])) {
$attribute = CRM_Utils_Array::value('attributes', $values);
$required = !empty($values['required']);
if ($values['type'] == 'select' && empty($attribute)) {
$this->addSelect($field, array('entity' => 'activity'), $required);
} elseif ($values['type'] == 'entityRef') {
$this->addEntityRef($field, $values['label'], $attribute, $required);
} else {
$this->add($values['type'], $field, $values['label'], $attribute, $required, CRM_Utils_Array::value('extra', $values));
}
}
}
// CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
// Add engagement level CRM-7775
$buildEngagementLevel = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$buildEngagementLevel = TRUE;
$this->addSelect('engagement_level', array('entity' => 'activity'));
$this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger');
}
$this->assign('buildEngagementLevel', $buildEngagementLevel);
// check for survey activity
$this->_isSurveyActivity = FALSE;
if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId);
if ($this->_isSurveyActivity) {
$surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id');
$responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId);
if ($responseOptions) {
$this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions));
}
$surveyTitle = NULL;
if ($surveyId) {
$surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title');
}
$this->assign('surveyTitle', $surveyTitle);
}
}
$this->assign('surveyActivity', $this->_isSurveyActivity);
// this option should be available only during add mode
if ($this->_action != CRM_Core_Action::UPDATE) {
$this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.'));
}
$this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
$this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime'));
// Add followup date.
$this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
// Only admins and case-workers can change the activity source
if (!CRM_Core_Permission::check('administer CiviCRM') && $this->_context != 'caseActivity') {
$this->getElement('source_contact_id')->freeze();
}
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Activity');
$this->assign('customDataSubType', $this->_activityTypeId);
$this->assign('entityID', $this->_activityId);
CRM_Core_BAO_Tag::getTags('civicrm_activity', $tags, NULL, ' ', TRUE);
if (!empty($tags)) {
$this->add('select', 'tag', ts('Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2 huge'));
}
// we need to hide activity tagset for special activities
$specialActivities = array('Open Case');
if (!in_array($this->_activityTypeName, $specialActivities)) {
// build tag widget
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId);
}
// if we're viewing, we're assigning different buttons than for adding/editing
if ($this->_action & CRM_Core_Action::VIEW) {
if (isset($this->_groupTree)) {
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree);
}
// form should be frozen for view mode
$this->freeze();
//.........这里部分代码省略.........
示例10: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
$this->_votingTab = $this->get('votingTab');
$this->_reserveToInterview = $this->get('reserveToInterview');
if ($this->_reserveToInterview || $this->_votingTab) {
//user came from voting tab / reserve form.
foreach (array('surveyId', 'contactIds', 'interviewerId') as $fld) {
$this->{"_{$fld}"} = $this->get($fld);
}
//get the target voter ids.
if ($this->_votingTab) {
$this->getVoterIds();
}
} 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'));
}
//get the contact read only fields to display.
$readOnlyFields = array_merge(array('contact_type' => '', 'sort_name' => ts('Name')));
//get the read only field data.
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
$returnProperties['contact_sub_type'] = TRUE;
//validate all voters for required activity.
//get the survey activities for given voters.
$this->_surveyActivityIds = CRM_Campaign_BAO_Survey::voterActivityDetails($this->_surveyId, $this->_contactIds, $this->_interviewerId);
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$scheduledStatusId = array_search('Scheduled', $activityStatus);
$activityIds = array();
foreach ($this->_contactIds as $key => $voterId) {
$actVals = CRM_Utils_Array::value($voterId, $this->_surveyActivityIds);
$statusId = CRM_Utils_Array::value('status_id', $actVals);
$activityId = CRM_Utils_Array::value('activity_id', $actVals);
if ($activityId && $statusId && $scheduledStatusId == $statusId) {
$activityIds["activity_id_{$voterId}"] = $activityId;
} else {
unset($this->_contactIds[$key]);
}
}
//retrieve the contact details.
$voterDetails = CRM_Campaign_BAO_Survey::voterDetails($this->_contactIds, $returnProperties);
$this->_allowAjaxReleaseButton = FALSE;
if ($this->_votingTab && (CRM_Core_Permission::check('manage campaign') || CRM_Core_Permission::check('administer CiviCampaign') || CRM_Core_Permission::check('release campaign contacts'))) {
$this->_allowAjaxReleaseButton = TRUE;
}
//validate voter ids across profile.
$this->filterVoterIds();
$this->assign('votingTab', $this->_votingTab);
$this->assign('componentIds', $this->_contactIds);
$this->assign('voterDetails', $voterDetails);
$this->assign('readOnlyFields', $readOnlyFields);
$this->assign('interviewerId', $this->_interviewerId);
$this->assign('surveyActivityIds', json_encode($activityIds));
$this->assign('allowAjaxReleaseButton', $this->_allowAjaxReleaseButton);
//get the survey values.
$this->_surveyValues = $this->get('surveyValues');
if (!is_array($this->_surveyValues)) {
$this->_surveyValues = array();
if ($this->_surveyId) {
$surveyParams = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($surveyParams, $this->_surveyValues);
}
$this->set('surveyValues', $this->_surveyValues);
}
$this->assign('surveyValues', $this->_surveyValues);
//get the survey result options.
$this->_resultOptions = $this->get('resultOptions');
if (!is_array($this->_resultOptions)) {
$this->_resultOptions = array();
if ($resultOptionId = CRM_Utils_Array::value('result_id', $this->_surveyValues)) {
$this->_resultOptions = CRM_Core_OptionGroup::valuesByID($resultOptionId);
}
$this->set('resultOptions', $this->_resultOptions);
}
//validate the required ids.
$this->validateIds();
//append breadcrumb to survey dashboard.
if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
$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.
$activityTypes = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE);
$this->_surveyTypeId = CRM_Utils_Array::value('activity_type_id', $this->_surveyValues);
CRM_Utils_System::setTitle(ts('Record %1 Responses', array(1 => $activityTypes[$this->_surveyTypeId])));
}
示例11: preProcess
/**
* Build all the data structures needed to build the form.
*/
public function preProcess()
{
parent::preProcess();
//get the survey id from user submitted values.
$this->_surveyId = $this->get('surveyId');
$this->_interviewerId = $this->get('interviewerId');
if (!$this->_surveyId) {
CRM_Core_Error::statusBounce(ts("Could not find Survey Id."));
}
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 contacts for reservation."));
}
$params = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails);
//get the survey activities.
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$statusIds = array();
foreach (array('Scheduled') as $name) {
if ($statusId = array_search($name, $activityStatus)) {
$statusIds[] = $statusId;
}
}
// these are the activities count that are linked to the current
// interviewer and current survey and not the list of ALL survey activities
$this->_numVoters = CRM_Campaign_BAO_Survey::getSurveyActivities($this->_surveyId, $this->_interviewerId, $statusIds, NULL, TRUE);
//validate the selected survey.
$this->validateSurvey();
$this->assign('surveyTitle', $this->_surveyDetails['title']);
$this->assign('activityType', $this->_surveyDetails['activity_type_id']);
$this->assign('surveyId', $this->_surveyId);
//append breadcrumb to survey dashboard.
if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
$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('Reserve Respondents'));
}
示例12: preProcess
/**
* Build all the data structures needed to build the form.
*/
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'));
}
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);
$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.
if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
$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'));
}
示例13: preProcess
//.........这里部分代码省略.........
}
$orderClause = FALSE;
$buttonName = $this->controller->getButtonName();
if ($buttonName == '_qf_Interview_submit_orderBy' && !empty($_POST['order_bys'])) {
$orderByParams = CRM_Utils_Array::value('order_bys', $_POST);
} elseif (CRM_Core_OptionGroup::getValue('activity_type', 'WalkList') == $this->_surveyDetails['activity_type_id']) {
$orderByParams = array(1 => array('column' => 'civicrm_address.street_name', 'order' => 'ASC'), 2 => array('column' => 'civicrm_address.street_number%2', 'order' => 'ASC'), 3 => array('column' => 'civicrm_address.street_number', 'order' => 'ASC'), 4 => array('column' => 'contact_a.sort_name', 'order' => 'ASC'));
}
$orderBy = array();
if (!empty($orderByParams)) {
foreach ($orderByParams as $key => $val) {
if (!empty($val['column'])) {
$orderBy[] = "{$val['column']} {$val['order']}";
}
}
if (!empty($orderBy)) {
$orderClause = "ORDER BY " . implode(', ', $orderBy);
}
}
$this->_contactIds = array_unique($this->_contactIds);
if (!empty($this->_contactIds) && $orderClause) {
$clause = 'contact_a.id IN ( ' . implode(',', $this->_contactIds) . ' ) ';
$sql = "\nSELECT contact_a.id\nFROM civicrm_contact contact_a\nLEFT JOIN civicrm_address ON contact_a.id = civicrm_address.contact_id\nWHERE {$clause}\n{$orderClause}";
$this->_contactIds = array();
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$this->_contactIds[] = $dao->id;
}
}
//get the contact read only fields to display.
$readOnlyFields = array_merge(array('contact_type' => '', 'sort_name' => ts('Name')));
//get the read only field data.
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
$returnProperties['contact_sub_type'] = TRUE;
//validate all voters for required activity.
//get the survey activities for given voters.
$this->_surveyActivityIds = CRM_Campaign_BAO_Survey::voterActivityDetails($this->_surveyId, $this->_contactIds, $this->_interviewerId);
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$scheduledStatusId = array_search('Scheduled', $activityStatus);
$activityIds = array();
foreach ($this->_contactIds as $key => $voterId) {
$actVals = CRM_Utils_Array::value($voterId, $this->_surveyActivityIds);
$statusId = CRM_Utils_Array::value('status_id', $actVals);
$activityId = CRM_Utils_Array::value('activity_id', $actVals);
if ($activityId && $statusId && $scheduledStatusId == $statusId) {
$activityIds["activity_id_{$voterId}"] = $activityId;
} else {
unset($this->_contactIds[$key]);
}
}
//retrieve the contact details.
$voterDetails = CRM_Campaign_BAO_Survey::voterDetails($this->_contactIds, $returnProperties);
$this->_allowAjaxReleaseButton = FALSE;
if ($this->_votingTab && (CRM_Core_Permission::check('manage campaign') || CRM_Core_Permission::check('administer CiviCampaign') || CRM_Core_Permission::check('release campaign contacts'))) {
$this->_allowAjaxReleaseButton = TRUE;
}
//validate voter ids across profile.
$this->filterVoterIds();
$this->assign('votingTab', $this->_votingTab);
$this->assign('componentIds', $this->_contactIds);
$this->assign('componentIdsJson', json_encode($this->_contactIds));
$this->assign('voterDetails', $voterDetails);
$this->assign('readOnlyFields', $readOnlyFields);
$this->assign('interviewerId', $this->_interviewerId);
$this->assign('surveyActivityIds', json_encode($activityIds));
$this->assign('allowAjaxReleaseButton', $this->_allowAjaxReleaseButton);
//get the survey values.
$this->_surveyValues = $this->get('surveyValues');
if (!is_array($this->_surveyValues)) {
$this->_surveyValues = array();
if ($this->_surveyId) {
$surveyParams = array('id' => $this->_surveyId);
CRM_Campaign_BAO_Survey::retrieve($surveyParams, $this->_surveyValues);
}
$this->set('surveyValues', $this->_surveyValues);
}
$this->assign('surveyValues', $this->_surveyValues);
$result = CRM_Campaign_BAO_Survey::getReportID($this->_surveyId);
$this->assign("instanceId", $result);
//get the survey result options.
$this->_resultOptions = $this->get('resultOptions');
if (!is_array($this->_resultOptions)) {
$this->_resultOptions = array();
if ($resultOptionId = CRM_Utils_Array::value('result_id', $this->_surveyValues)) {
$this->_resultOptions = CRM_Core_OptionGroup::valuesByID($resultOptionId);
}
$this->set('resultOptions', $this->_resultOptions);
}
//validate the required ids.
$this->validateIds();
//append breadcrumb to survey dashboard.
if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
$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.
$activityTypes = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE);
$this->_surveyTypeId = CRM_Utils_Array::value('activity_type_id', $this->_surveyValues);
CRM_Utils_System::setTitle(ts('Record %1 Responses', array(1 => $activityTypes[$this->_surveyTypeId])));
}
示例14: run
/**
* @return string
*/
public function run()
{
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
}
$this->browse();
return parent::run();
}
示例15: buildSearchForm
/**
* Add all the elements shared between case activity search and advanced search.
*
*
* @param CRM_Core_Form $form
* @return void
*/
public static function buildSearchForm(&$form)
{
$activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
$form->addSelect('activity_type_id', array('entity' => 'activity', 'label' => 'Activity Type(s)', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')));
CRM_Core_Form_Date::buildDateRange($form, 'activity_date', 1, '_low', '_high', ts('From'), FALSE, FALSE);
$followUpActivity = array(1 => ts('Yes'), 2 => ts('No'));
$form->addRadio('parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
$form->addRadio('followup_parent_id', NULL, $followUpActivity, array('allowClear' => TRUE));
$activityRoles = array(3 => ts('With'), 2 => ts('Assigned to'), 1 => ts('Added by'));
$form->addRadio('activity_role', NULL, $activityRoles, array('allowClear' => TRUE));
$form->setDefaults(array('activity_role' => 3));
$activityStatus = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'status_id', array('flip' => 1, 'labelColumn' => 'name'));
$form->addSelect('status_id', array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')));
$form->setDefaults(array('status_id' => array($activityStatus['Completed'], $activityStatus['Scheduled'])));
$form->addElement('text', 'activity_subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$form->addYesNo('activity_test', ts('Activity is a Test?'));
$activity_tags = CRM_Core_BAO_Tag::getTags('civicrm_activity');
if ($activity_tags) {
foreach ($activity_tags as $tagID => $tagName) {
$form->_tagElement =& $form->addElement('checkbox', "activity_tags[{$tagID}]", NULL, $tagName);
}
}
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_activity', NULL, TRUE, TRUE);
$surveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, FALSE, FALSE, TRUE);
if ($surveys) {
$form->add('select', 'activity_survey_id', ts('Survey / Petition'), array('' => ts('- none -')) + $surveys, FALSE, array('class' => 'crm-select2'));
}
$extends = array('Activity');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
if ($groupDetails) {
$form->assign('activityGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
}
}
}
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id');
//add engagement level CRM-7775
$buildEngagementLevel = FALSE;
$buildSurveyResult = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$buildEngagementLevel = TRUE;
$form->addSelect('activity_engagement_level', array('entity' => 'activity', 'context' => 'search'));
// Add survey result field.
$optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name');
$resultOptions = array();
foreach ($optionGroups as $gid => $name) {
if ($name) {
$value = array();
$value = CRM_Core_OptionGroup::values($name);
if (!empty($value)) {
while (list($k, $v) = each($value)) {
$resultOptions[$v] = $v;
}
}
}
}
// If no survey result options have been created, don't build
// the field to avoid clutter.
if (count($resultOptions) > 0) {
$buildSurveyResult = TRUE;
asort($resultOptions);
$form->add('select', 'activity_result', ts("Survey Result"), $resultOptions, FALSE, array('id' => 'activity_result', 'multiple' => 'multiple', 'class' => 'crm-select2'));
}
}
$form->assign('buildEngagementLevel', $buildEngagementLevel);
$form->assign('buildSurveyResult', $buildSurveyResult);
$form->setDefaults(array('activity_test' => 0));
}