<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
*/
class CRM_Campaign_Page_AJAX {
- static function registerInterview() {
+ public static function registerInterview() {
$fields = array(
'result',
'voter_id',
$params[$fld] = CRM_Utils_Array::value($fld, $_POST);
}
$params['details'] = CRM_Utils_Array::value('note', $_POST);
- $voterId = $params['voter_id'];
- $activityId = $params['activity_id'];
+ $voterId = $params['voter_id'];
+ $activityId = $params['activity_id'];
$customKey = "field_{$voterId}_custom";
foreach ($_POST as $key => $value) {
CRM_Utils_JSON::output($result);
}
- static function loadOptionGroupDetails() {
+ public static function loadOptionGroupDetails() {
- $id = CRM_Utils_Array::value('option_group_id', $_POST);
- $status = 'fail';
+ $id = CRM_Utils_Array::value('option_group_id', $_POST);
+ $status = 'fail';
$opValues = array();
if ($id) {
$surveyId = CRM_Utils_Array::value('survey_id', $_POST);
if ($surveyId) {
- $survey = new CRM_Campaign_DAO_Survey();
- $survey->id = $surveyId;
+ $survey = new CRM_Campaign_DAO_Survey();
+ $survey->id = $surveyId;
$survey->result_id = $id;
if ($survey->find(TRUE)) {
if ($survey->recontact_interval) {
CRM_Utils_JSON::output($result);
}
- function voterList() {
+ public function voterList() {
//get the search criteria params.
$searchParams = explode(',', CRM_Utils_Array::value('searchCriteria', $_POST));
//format multi-select group and contact types.
foreach (array(
- 'group', 'contact_type') as $param) {
+ 'group',
+ 'contact_type',
+ ) as $param) {
$paramValue = CRM_Utils_Array::value($param, $params);
if ($paramValue) {
unset($params[$param]);
$voterClauseParams = array();
foreach (array(
- 'campaign_survey_id', 'survey_interviewer_id', 'campaign_search_voter_for') as $fld) {
+ 'campaign_survey_id',
+ 'survey_interviewer_id',
+ 'campaign_search_voter_for',
+ ) as $fld) {
$voterClauseParams[$fld] = CRM_Utils_Array::value($fld, $params);
}
$groups = CRM_Utils_Array::value('group', $params);
if ($campaignId && CRM_Utils_System::isNull($groups)) {
$campaignGroups = CRM_Campaign_BAO_Campaign::getCampaignGroups($campaignId);
- foreach ($campaignGroups as $id => $group) $params['group'][$id] = 1;
+ foreach ($campaignGroups as $id => $group) {
+ $params['group'][$id] = 1;
+ }
}
//apply filter of survey contact type for search.
// get the data table params.
$dataTableParams = array(
- 'sEcho' => array('name' => 'sEcho',
+ 'sEcho' => array(
+ 'name' => 'sEcho',
'type' => 'Integer',
'default' => 0,
),
$$pName = $pValues['default'];
if (!empty($_POST[$pValues['name']])) {
$$pName = CRM_Utils_Type::escape($_POST[$pValues['name']], $pValues['type']);
- if ($pName == 'sort')$$pName = $selectorCols[$$pName];
+ if ($pName == 'sort') {
+ $$pName = $selectorCols[$$pName];
+ }
}
}
$iTotal = $searchCount;
$selectorCols = array(
- 'contact_type', 'sort_name', 'street_address',
- 'street_name', 'street_number', 'street_unit',
+ 'contact_type',
+ 'sort_name',
+ 'street_address',
+ 'street_name',
+ 'street_number',
+ 'street_unit',
);
$extraVoterColName = 'is_interview_conducted';
);
while ($result->fetch()) {
$contactID = $result->contact_id;
- $typeImage = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ?
- $result->contact_sub_type : $result->contact_type,
+ $typeImage = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type,
FALSE,
$result->contact_id
);
$voterExtraColHtml .= " <span id='success_msg_{$contactID}' class='ok' style='display:none;'>$msg</span>";
}
elseif ($searchVoterFor == 'gotv') {
- $surveyActId = $result->survey_activity_id;
+ $surveyActId = $result->survey_activity_id;
$voterExtraColHtml = '<input type="checkbox" id="survey_activity[' . $surveyActId . ']" name="survey_activity[' . $surveyActId . ']" value=' . $surveyActId . ' onClick="processVoterData( this, \'gotv\' );" />';
- $msg = ts('Vote Recorded.');
+ $msg = ts('Vote Recorded.');
$voterExtraColHtml .= " <span id='success_msg_{$surveyActId}' class='ok' style='display:none;'>$msg</span>";
}
else {
- $surveyActId = $result->survey_activity_id;
+ $surveyActId = $result->survey_activity_id;
$voterExtraColHtml = '<input type="checkbox" id="survey_activity[' . $surveyActId . ']" name="survey_activity[' . $surveyActId . ']" value=' . $surveyActId . ' onClick="processVoterData( this, \'release\' );" />';
- $msg = ts('Vote Recorded.');
+ $msg = ts('Vote Recorded.');
$voterExtraColHtml .= " <span id='success_msg_{$surveyActId}' class='ok' style='display:none;'>$msg</span>";
}
$searchRows[$contactID][$extraVoterColName] = $voterExtraColHtml;
$iFilteredTotal = $iTotal;
+ header('Content-Type: application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
- function processVoterData() {
+ public function processVoterData() {
$status = NULL;
$operation = CRM_Utils_Type::escape($_POST['operation'], 'String');
if ($operation == 'release') {
}
}
if ($createActivity) {
- $isReserved = CRM_Utils_String::strtoboolstr(CRM_Utils_Type::escape($_POST['isReserved'], 'String'));
- $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
+ $isReserved = CRM_Utils_String::strtoboolstr(CRM_Utils_Type::escape($_POST['isReserved'], 'String'));
+ $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$scheduledStatusId = array_search('Scheduled', $activityStatus);
if ($isReserved) {
$surveyValues = array();
CRM_Utils_JSON::output(array('status' => $status));
}
- function allActiveCampaigns() {
+ public function allActiveCampaigns() {
$currentCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns();
- $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
- $options = array(
- array('value' => '',
+ $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
+ $options = array(
+ array(
+ 'value' => '',
'title' => ts('- select -'),
- ));
+ ),
+ );
foreach ($campaigns as $value => $title) {
$class = NULL;
if (!array_key_exists($value, $currentCampaigns)) {
CRM_Utils_JSON::output($results);
}
- function campaignGroups() {
+ public function campaignGroups() {
$surveyId = CRM_Utils_Request::retrieve('survey_id', 'Positive',
CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST'
);
$campGroups = CRM_Core_PseudoConstant::group();
}
$groups = array(
- array('value' => '',
+ array(
+ 'value' => '',
'title' => ts('- select -'),
- ));
+ ),
+ );
foreach ($campGroups as $grpId => $title) {
$groups[] = array(
'value' => $grpId,
/**
* Retrieve campaigns as for campaign dashboard.
*
- **/
- function campaignList() {
+ */
+ public function campaignList() {
//get the search criteria params.
$searchParams = explode(',', CRM_Utils_Array::value('searchCriteria', $_POST));
// get the data table params.
$dataTableParams = array(
- 'sEcho' => array('name' => 'sEcho',
+ 'sEcho' => array(
+ 'name' => 'sEcho',
'type' => 'Integer',
'default' => 0,
),
}
}
foreach (array(
- 'sort', 'offset', 'rowCount', 'sortOrder') as $sortParam) {
+ 'sort',
+ 'offset',
+ 'rowCount',
+ 'sortOrder',
+ ) as $sortParam) {
$params[$sortParam] = $$sortParam;
}
$searchCount = CRM_Campaign_BAO_Campaign::getCampaignSummary($params, TRUE);
- $campaigns = CRM_Campaign_Page_DashBoard::getCampaignSummary($params);
- $iTotal = $searchCount;
+ $campaigns = CRM_Campaign_Page_DashBoard::getCampaignSummary($params);
+ $iTotal = $searchCount;
if ($searchCount > 0) {
if ($searchCount < $offset) {
$iFilteredTotal = $iTotal;
+ header('Content-Type: application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
/**
* Retrieve survey for survey dashboard.
*
- **/
- function surveyList() {
+ */
+ public function surveyList() {
//get the search criteria params.
$searchParams = explode(',', CRM_Utils_Array::value('searchCriteria', $_POST));
// get the data table params.
$dataTableParams = array(
- 'sEcho' => array('name' => 'sEcho',
+ 'sEcho' => array(
+ 'name' => 'sEcho',
'type' => 'Integer',
'default' => 0,
),
}
}
foreach (array(
- 'sort', 'offset', 'rowCount', 'sortOrder') as $sortParam) {
+ 'sort',
+ 'offset',
+ 'rowCount',
+ 'sortOrder',
+ ) as $sortParam) {
$params[$sortParam] = $$sortParam;
}
- $surveys = CRM_Campaign_Page_DashBoard::getSurveySummary($params);
+ $surveys = CRM_Campaign_Page_DashBoard::getSurveySummary($params);
$searchCount = CRM_Campaign_BAO_Survey::getSurveySummary($params, TRUE);
- $iTotal = $searchCount;
+ $iTotal = $searchCount;
if ($searchCount > 0) {
if ($searchCount < $offset) {
$iFilteredTotal = $iTotal;
+ header('Content-Type: application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
/**
* Retrieve petitions for petition dashboard.
*
- **/
- function petitionList() {
+ */
+ public function petitionList() {
//get the search criteria params.
$searchParams = explode(',', CRM_Utils_Array::value('searchCriteria', $_POST));
// get the data table params.
$dataTableParams = array(
- 'sEcho' => array('name' => 'sEcho',
+ 'sEcho' => array(
+ 'name' => 'sEcho',
'type' => 'Integer',
'default' => 0,
),
}
}
foreach (array(
- 'sort', 'offset', 'rowCount', 'sortOrder') as $sortParam) {
+ 'sort',
+ 'offset',
+ 'rowCount',
+ 'sortOrder',
+ ) as $sortParam) {
$params[$sortParam] = $$sortParam;
}
- $petitions = CRM_Campaign_Page_DashBoard::getPetitionSummary($params);
+ $petitions = CRM_Campaign_Page_DashBoard::getPetitionSummary($params);
$searchCount = CRM_Campaign_BAO_Petition::getPetitionSummary($params, TRUE);
- $iTotal = $searchCount;
+ $iTotal = $searchCount;
if ($searchCount > 0) {
if ($searchCount < $offset) {
$iFilteredTotal = $iTotal;
+ header('Content-Type: application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
-}
+}