Commit 5c2ea586 authored by totten's avatar totten
Browse files

INFRA-132 - CRM/Campaign - Misc

parent 83ba323f
......@@ -32,7 +32,7 @@
* $Id$
*
*/
Class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign {
class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign {
/**
* Takes an associative array and creates a campaign object
......@@ -157,11 +157,11 @@ Class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign {
*/
public static function getCampaigns(
$includeId = NULL,
$excludeId = NULL,
$onlyActive = TRUE,
$onlyCurrent = TRUE,
$excludeId = NULL,
$onlyActive = TRUE,
$onlyCurrent = TRUE,
$appendDatesToTitle = FALSE,
$forceAll = FALSE
$forceAll = FALSE
) {
static $campaigns;
$cacheKey = 0;
......@@ -236,7 +236,8 @@ Order By camp.title";
* w/ permissions and component check.
*
*/
public static function getPermissionedCampaigns($includeId = NULL,
public static function getPermissionedCampaigns(
$includeId = NULL,
$excludeId = NULL,
$onlyActive = TRUE,
$onlyCurrent = TRUE,
......@@ -261,7 +262,8 @@ Order By camp.title";
static $validCampaigns;
if (!isset($validCampaigns[$cacheKey])) {
$isValid = TRUE;
$campaigns = array('campaigns' => array(),
$campaigns = array(
'campaigns' => array(),
'hasAccessCampaign' => FALSE,
'isCampaignEnabled' => FALSE,
);
......@@ -335,7 +337,6 @@ Order By camp.title";
}
}
//need to lookup tables.
$orderOnCampaignTable = TRUE;
if ($sortParams['sort'] == 'status') {
......@@ -447,7 +448,7 @@ SELECT campaign.id as id,
//in case of only count.
if ($onlyCount) {
return (int)CRM_Core_DAO::singleValueQuery($query, $queryParams);
return (int) CRM_Core_DAO::singleValueQuery($query, $queryParams);
}
$campaign = CRM_Core_DAO::executeQuery($query, $queryParams);
......@@ -466,7 +467,7 @@ SELECT campaign.id as id,
* @static
*/
public static function getCampaignCount() {
return (int)CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM civicrm_campaign');
return (int) CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM civicrm_campaign');
}
/**
......@@ -555,7 +556,9 @@ INNER JOIN civicrm_group grp ON ( grp.id = campgrp.entity_id )
$campaignDetails = self::getPermissionedCampaigns($connectedCampaignId, NULL, TRUE, TRUE, $appendDates);
$fields = array('campaigns', 'hasAccessCampaign', 'isCampaignEnabled');
foreach ($fields as $fld)$$fld = CRM_Utils_Array::value($fld, $campaignDetails);
foreach ($fields as $fld) {
$$fld = CRM_Utils_Array::value($fld, $campaignDetails);
}
//lets see do we have past campaigns.
$hasPastCampaigns = FALSE;
......@@ -618,7 +621,9 @@ INNER JOIN civicrm_group grp ON ( grp.id = campgrp.entity_id )
'includePastCampaignURL',
'alreadyIncludedPastCampaigns',
);
foreach ($infoFields as $fld) $campaignInfo[$fld] = $$fld;
foreach ($infoFields as $fld) {
$campaignInfo[$fld] = $$fld;
}
$form->assign('campaignInfo', $campaignInfo);
}
......@@ -633,7 +638,9 @@ INNER JOIN civicrm_group grp ON ( grp.id = campgrp.entity_id )
$campaignInfo = array();
$campaignDetails = self::getPermissionedCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$fields = array('campaigns', 'hasAccessCampaign', 'isCampaignEnabled');
foreach ($fields as $fld)$$fld = CRM_Utils_Array::value($fld, $campaignDetails);
foreach ($fields as $fld) {
$$fld = CRM_Utils_Array::value($fld, $campaignDetails);
}
$showCampaignInSearch = FALSE;
if ($isCampaignEnabled && $hasAccessCampaign && !empty($campaigns)) {
//get the current campaign only.
......@@ -658,7 +665,9 @@ INNER JOIN civicrm_group grp ON ( grp.id = campgrp.entity_id )
'isCampaignEnabled',
'showCampaignInSearch',
);
foreach ($infoFields as $fld) $campaignInfo[$fld] = $$fld;
foreach ($infoFields as $fld) {
$campaignInfo[$fld] = $$fld;
}
$form->assign('campaignInfo', $campaignInfo);
}
}
......@@ -101,7 +101,6 @@ class CRM_Campaign_BAO_Query {
}
}
//get survey clause in force,
//only when we have survey id.
if (!self::$_applySurveyClause) {
......@@ -270,7 +269,8 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) ";
*
* @return array|null
*/
static function defaultReturnProperties($mode,
static function defaultReturnProperties(
$mode,
$includeCustomFields = TRUE
) {
$properties = NULL;
......@@ -307,13 +307,15 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) ";
/**
* @param $tables
*/
public static function tableNames(&$tables) {}
public static function tableNames(&$tables) {
}
/**
* @param $row
* @param int $id
*/
public static function searchAction(&$row, $id) {}
public static function searchAction(&$row, $id) {
}
/**
* @param $tables
......@@ -587,7 +589,8 @@ INNER JOIN civicrm_custom_group grp on fld.custom_group_id = grp.id
foreach (array(
'current_campaign', 'past_campaign') as $ignore) {
$index = array_search($ignore, $campaign);
if ($index !== FALSE)unset($campaign[$index]);
if ($index !== FALSE) { unset($campaign[$index]);
}
}
}
......
......@@ -85,7 +85,7 @@ class CRM_Campaign_BAO_Survey extends CRM_Campaign_DAO_Survey {
*/
public static function create(&$params) {
if (empty($params)) {
return false;
return FALSE;
}
if (!empty($params['is_default'])) {
......@@ -213,7 +213,7 @@ SELECT survey.id as id,
//return only count.
if ($onlyCount) {
return (int)CRM_Core_DAO::singleValueQuery($query, $queryParams);
return (int) CRM_Core_DAO::singleValueQuery($query, $queryParams);
}
$surveys = array();
......@@ -238,7 +238,7 @@ SELECT survey.id as id,
* @static
*/
public static function getSurveyCount() {
return (int)CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM civicrm_survey');
return (int) CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM civicrm_survey');
}
/**
......@@ -255,7 +255,7 @@ SELECT survey.id as id,
*
* @static
*/
public static function getSurveys($onlyActive = TRUE, $onlyDefault = FALSE, $forceAll = FALSE, $includePetition = FALSE ) {
public static function getSurveys($onlyActive = TRUE, $onlyDefault = FALSE, $forceAll = FALSE, $includePetition = FALSE) {
$cacheKey = 0;
$cacheKeyParams = array('onlyActive', 'onlyDefault', 'forceAll', 'includePetition');
foreach ($cacheKeyParams as $param) {
......@@ -308,7 +308,8 @@ SELECT survey.id as id,
*
* @static
*/
static function getSurveyActivityType($returnColumn = 'label',
static function getSurveyActivityType(
$returnColumn = 'label',
$includePetitionActivityType = FALSE
) {
static $activityTypes;
......@@ -494,8 +495,7 @@ Group By contact.id";
foreach ($returnProperties as $property => $ignore) {
$voterDetails[$contact->contactId][$property] = $contact->$property;
}
$image = CRM_Contact_BAO_Contact_Utils::getImage($contact->contact_sub_type ?
$contact->contact_sub_type : $contact->contact_type,
$image = CRM_Contact_BAO_Contact_Utils::getImage($contact->contact_sub_type ? $contact->contact_sub_type : $contact->contact_type,
FALSE,
$contact->contactId
);
......@@ -520,7 +520,8 @@ Group By contact.id";
*
* @return array $activityDetails array of survey activity.@static
*/
static function voterActivityDetails($surveyId, $voterIds, $interviewerId = NULL,
static function voterActivityDetails(
$surveyId, $voterIds, $interviewerId = NULL,
$statusIds = array()) {
$activityDetails = array();
if (!$surveyId ||
......@@ -582,11 +583,12 @@ INNER JOIN civicrm_activity_contact activityAssignment
* @param bool $onlyCount
* @return array $activities an array of survey activity.@static
*/
static function getSurveyActivities($surveyId,
static function getSurveyActivities(
$surveyId,
$interviewerId = NULL,
$statusIds = NULL,
$voterIds = NULL,
$onlyCount = FALSE
$statusIds = NULL,
$voterIds = NULL,
$onlyCount = FALSE
) {
$activities = array();
$surveyActivityCount = 0;
......@@ -647,7 +649,8 @@ INNER JOIN civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
AND ( activity.is_deleted IS NULL OR activity.is_deleted = 0 )
$whereClause";
$params = array(1 => array($surveyId, 'Integer'),
$params = array(
1 => array($surveyId, 'Integer'),
2 => array($actTypeId, 'Integer'),
);
......@@ -686,7 +689,7 @@ INNER JOIN civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
* @return array $$contactIds survey related contact ids.
* @static
*/
public static function getSurveyVoterInfo($surveyId, $interviewerId = NULL, $statusIds = array( )) {
public static function getSurveyVoterInfo($surveyId, $interviewerId = NULL, $statusIds = array()) {
$voterIds = array();
if (!$surveyId) {
return $voterIds;
......@@ -718,7 +721,7 @@ INNER JOIN civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
* @param string $valueColumnName
* @return array $resultSets an array of option groups.@static
*/
public static function getResultSets( $valueColumnName = 'title' ) {
public static function getResultSets($valueColumnName = 'title') {
$resultSets = array();
$valueColumnName = CRM_Utils_Type::escape($valueColumnName, 'String');
......@@ -910,7 +913,7 @@ INNER JOIN civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
if (!array_key_exists($surveyId, $reportIds)) {
$query = "SELECT MAX(id) as id FROM civicrm_report_instance WHERE name = %1";
$reportID = CRM_Core_DAO::singleValueQuery($query, array(1 => array("survey_{$surveyId}",'String')));
$reportID = CRM_Core_DAO::singleValueQuery($query, array(1 => array("survey_{$surveyId}", 'String')));
$reportIds[$surveyId] = $reportID;
}
return $reportIds[$surveyId];
......@@ -944,7 +947,7 @@ INNER JOIN civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
if (!isset($profileTypes)) {
$profileTypes = array_merge(array('Activity', 'Contact'), CRM_Contact_BAO_ContactType::basicTypes());
$profileTypes = array_diff($profileTypes, array('Organization','Household'));
$profileTypes = array_diff($profileTypes, array('Organization', 'Household'));
}
return $profileTypes;
......
......@@ -597,7 +597,8 @@ WHERE {$clause}
$statusIds
);
$this->_contactIds = array();
foreach ($surveyActivities as $val) { $this->_contactIds[$val['voter_id']] = $val['voter_id'];
foreach ($surveyActivities as $val) {
$this->_contactIds[$val['voter_id']] = $val['voter_id'];
}
$this->set('contactIds', $this->_contactIds);
}
......
......@@ -191,7 +191,8 @@ class CRM_Campaign_Page_AJAX {
$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;
}
}
......@@ -257,7 +258,8 @@ class CRM_Campaign_Page_AJAX {
$$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];
}
}
}
......
......@@ -149,7 +149,8 @@ class CRM_Campaign_Selector_Search extends CRM_Core_Selector_Base implements CRM
* @return \CRM_Campaign_Selector_Search
@access public
*/
function __construct(&$queryParams,
function __construct(
&$queryParams,
$action = CRM_Core_Action::NONE,
$surveyClause = NULL,
$single = FALSE,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment