/**
* Variable to store redirect path
+ * @var string
*/
private $_userContext;
$this->_reserveToInterview = $this->get('reserveToInterview');
if ($this->_reserveToInterview || $this->_votingTab) {
//user came from voting tab / reserve form.
- foreach (array(
- 'surveyId',
- 'contactIds',
- 'interviewerId',
- ) as $fld) {
+ foreach ([
+ 'surveyId',
+ 'contactIds',
+ 'interviewerId',
+ ] as $fld) {
$this->{"_$fld"} = $this->get($fld);
}
//get the target voter ids.
}
if ($this->_surveyId) {
- $params = array('id' => $this->_surveyId);
+ $params = ['id' => $this->_surveyId];
CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails);
}
}
elseif ($walkListActivityId == $this->_surveyDetails['activity_type_id']) {
$orderByParams
- = array(
- 1 => array(
+ = [
+ 1 => [
'column' => 'civicrm_address.street_name',
'order' => 'ASC',
- ),
- 2 => array(
+ ],
+ 2 => [
'column' => 'civicrm_address.street_number%2',
'order' => 'ASC',
- ),
- 3 => array(
+ ],
+ 3 => [
'column' => 'civicrm_address.street_number',
'order' => 'ASC',
- ),
- 4 => array(
+ ],
+ 4 => [
'column' => 'contact_a.sort_name',
'order' => 'ASC',
- ),
- );
+ ],
+ ];
}
- $orderBy = array();
+ $orderBy = [];
if (!empty($orderByParams)) {
foreach ($orderByParams as $key => $val) {
if (!empty($val['column'])) {
WHERE {$clause}
{$orderClause}";
- $this->_contactIds = array();
+ $this->_contactIds = [];
$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(
+ $readOnlyFields = array_merge([
'contact_type' => '',
'sort_name' => ts('Name'),
- ));
+ ]);
//get the read only field data.
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
);
$scheduledStatusId = CRM_Core_PseudoConstant::getKey('CRM_Activity_DAO_Activity', 'activity_status_id', 'Scheduled');
- $activityIds = array();
+ $activityIds = [];
foreach ($this->_contactIds as $key => $voterId) {
$actVals = CRM_Utils_Array::value($voterId, $this->_surveyActivityIds);
$statusId = CRM_Utils_Array::value('status_id', $actVals);
//get the survey values.
$this->_surveyValues = $this->get('surveyValues');
if (!is_array($this->_surveyValues)) {
- $this->_surveyValues = array();
+ $this->_surveyValues = [];
if ($this->_surveyId) {
- $surveyParams = array('id' => $this->_surveyId);
+ $surveyParams = ['id' => $this->_surveyId];
CRM_Campaign_BAO_Survey::retrieve($surveyParams, $this->_surveyValues);
}
$this->set('surveyValues', $this->_surveyValues);
//get the survey result options.
$this->_resultOptions = $this->get('resultOptions');
if (!is_array($this->_resultOptions)) {
- $this->_resultOptions = array();
+ $this->_resultOptions = [];
if ($resultOptionId = CRM_Utils_Array::value('result_id', $this->_surveyValues)) {
$this->_resultOptions = CRM_Core_OptionGroup::valuesByID($resultOptionId);
}
//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)));
+ CRM_Utils_System::appendBreadCrumb([['title' => ts('Survey(s)'), 'url' => $url]]);
}
//set the title.
$this->_surveyTypeId = CRM_Utils_Array::value('activity_type_id', $this->_surveyValues);
$surveyTypeLabel = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_type_id', $this->_surveyTypeId);
- CRM_Utils_System::setTitle(ts('Record %1 Responses', array(1 => $surveyTypeLabel)));
+ CRM_Utils_System::setTitle(ts('Record %1 Responses', [1 => $surveyTypeLabel]));
}
public function validateIds() {
- $required = array(
+ $required = [
'surveyId' => ts('Could not find Survey.'),
'interviewerId' => ts('Could not find Interviewer.'),
'contactIds' => ts('No respondents are currently reserved for you to interview.'),
'resultOptions' => ts('Oops. It looks like there is no response option configured.'),
- );
+ ];
- $errorMessages = array();
+ $errorMessages = [];
foreach ($required as $fld => $msg) {
if (empty($this->{"_$fld"})) {
if (!$this->_votingTab) {
$this->assign('surveyTypeId', $this->_surveyTypeId);
$options
- = array(
+ = [
'' => ' - none - ',
'civicrm_address.street_name' => 'Street Name',
'civicrm_address.street_number%2' => 'Odd / Even Street Number',
'civicrm_address.street_number' => 'Street Number',
'contact_a.sort_name' => 'Respondent Name',
- );
+ ];
for ($i = 1; $i < count($options); $i++) {
$this->addElement('select', "order_bys[{$i}][column]", ts('Order by Column'), $options);
- $this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), array(
- 'ASC' => ts('Ascending'),
- 'DESC' => ts('Descending'),
- ));
+ $this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), [
+ 'ASC' => ts('Ascending'),
+ 'DESC' => ts('Descending'),
+ ]);
}
//pickup the uf fields.
//build the result field.
if (!empty($this->_resultOptions)) {
$this->add('select', "field[$contactId][result]", ts('Result'),
- array(
+ [
'' => ts('- select -'),
- ) +
+ ] +
array_combine($this->_resultOptions, $this->_resultOptions)
);
}
if ($this->_allowAjaxReleaseButton) {
$this->addElement('hidden',
"field[{$contactId}][is_release_or_reserve]", 0,
- array('id' => "field_{$contactId}_is_release_or_reserve")
+ ['id' => "field_{$contactId}_is_release_or_reserve"]
);
}
}
return;
}
- $buttons = array(
- array(
+ $buttons = [
+ [
'type' => 'cancel',
'name' => ts('Done'),
'subName' => 'interview',
'isDefault' => TRUE,
- ),
- );
+ ],
+ ];
- $buttons[] = array(
+ $buttons[] = [
'type' => 'submit',
'name' => ts('Order By >>'),
'subName' => 'orderBy',
- );
+ ];
$manageCampaign = CRM_Core_Permission::check('manage campaign');
$adminCampaign = CRM_Core_Permission::check('administer CiviCampaign');
$adminCampaign ||
CRM_Core_Permission::check('release campaign contacts')
) {
- $buttons[] = array(
+ $buttons[] = [
'type' => 'next',
'name' => ts('Release Respondents >>'),
'subName' => 'interviewToRelease',
- );
+ ];
}
if ($manageCampaign ||
$adminCampaign ||
CRM_Core_Permission::check('reserve campaign contacts')
) {
- $buttons[] = array(
+ $buttons[] = [
'type' => 'done',
'name' => ts('Reserve More Respondents >>'),
'subName' => 'interviewToReserve',
- );
+ ];
}
$this->addButtons($buttons);
*/
public function setDefaultValues() {
//load default data for only contact fields.
- $contactFields = $defaults = array();
+ $contactFields = $defaults = [];
foreach ($this->_surveyFields as $name => $field) {
$acceptable_types = CRM_Contact_BAO_ContactType::basicTypes();
$acceptable_types[] = 'Contact';
$walkListActivityId = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'WalkList');
if ($walkListActivityId == $this->_surveyDetails['activity_type_id']) {
$defaults['order_bys']
- = array(
- 1 => array(
+ = [
+ 1 => [
'column' => 'civicrm_address.street_name',
'order' => 'ASC',
- ),
- 2 => array(
+ ],
+ 2 => [
'column' => 'civicrm_address.street_number%2',
'order' => 'ASC',
- ),
- 3 => array(
+ ],
+ 3 => [
'column' => 'civicrm_address.street_number',
'order' => 'ASC',
- ),
- 4 => array(
+ ],
+ 4 => [
'column' => 'contact_a.sort_name',
'order' => 'ASC',
- ),
- );
+ ],
+ ];
}
else {
$defaults['order_bys']
- = array(
- 1 => array(
+ = [
+ 1 => [
'column' => 'contact_a.sort_name',
'order' => 'ASC',
- ),
- );
+ ],
+ ];
}
return $defaults;
}
}
elseif ($buttonName == '_qf_Interview_next_interviewToRelease') {
//get ready to jump to release form.
- foreach (array(
- 'surveyId',
- 'contactIds',
- 'interviewerId',
- ) as $fld) {
+ foreach ([
+ 'surveyId',
+ 'contactIds',
+ 'interviewerId',
+ ] as $fld) {
$this->controller->set($fld, $this->{"_$fld"});
}
$this->controller->set('interviewToRelease', TRUE);
CRM_Core_BAO_CustomValueTable::store($customParams, 'civicrm_activity', $activityId);
//process contact data.
- $contactParams = $fields = array();
+ $contactParams = $fields = [];
- $contactFieldTypes = array_merge(array('Contact'), CRM_Contact_BAO_ContactType::basicTypes());
+ $contactFieldTypes = array_merge(['Contact'], CRM_Contact_BAO_ContactType::basicTypes());
$responseFields = CRM_Campaign_BAO_Survey::getSurveyResponseFields($params['survey_id']);
if (!empty($responseFields)) {
foreach ($params as $key => $value) {
$subject .= ts('Respondent Interview');
$activity->subject = $subject;
- $activityParams = array(
+ $activityParams = [
'details' => 'details',
'result' => 'result',
'engagement_level' => 'activity_engagement_level',
'location' => 'activity_location',
'campaign_id' => 'activity_campaign_id',
'duration' => 'activity_duration',
- );
+ ];
foreach ($activityParams as $key => $field) {
if (!empty($params[$field])) {
$activity->$key = $params[$field];
$this->_interviewerId,
$statusIds
);
- $this->_contactIds = array();
+ $this->_contactIds = [];
foreach ($surveyActivities as $val) {
$this->_contactIds[$val['voter_id']] = $val['voter_id'];
}
INNER JOIN {$tempTableName} ON ( {$tempTableName}.survey_contact_id = contact.id )
WHERE contact.contact_type != %1";
$removeContact = CRM_Core_DAO::executeQuery($query,
- array(1 => array($profileType, 'String'))
+ [1 => [$profileType, 'String']]
);
while ($removeContact->fetch()) {
unset($this->_contactIds[$removeContact->id]);