+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Campaign_BAO_Survey extends CRM_Campaign_DAO_Survey {
/**
- * Takes a bunch of params that are needed to match certain criteria and
- * retrieves the relevant objects. Typically the valid params are only
- * campaign_id.
+ * Retrieve DB object based on input parameters.
+ *
+ * It also stores all the retrieved values in the default array.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
* @param array $defaults
* (reference ) an assoc array to hold the flattened values.
*
- */
-
- /**
- * The action links that we need to display for the browse screen
- *
- * @param array $params
- * @param $defaults
- *
* @return CRM_Campaign_DAO_Survey|null
*/
public static function retrieve(&$params, &$defaults) {
}
/**
- * Takes an associative array and creates a Survey object
+ * Takes an associative array and creates a Survey object.
*
* the function extract all the params it needs to initialize the create a
* survey object.
*
* @param array $params
*
- * @return CRM_Survey_DAO_Survey object
- * @static
+ * @return CRM_Survey_DAO_Survey
*/
public static function create(&$params) {
if (empty($params)) {
/**
* Retrieve surveys for dashboard.
*
- * @static
*/
public static function getSurveySummary($params = array(), $onlyCount = FALSE) {
//build the limit and order clause.
$surveys = array();
$properties = array(
- 'id', 'title', 'campaign_id', 'is_active', 'is_default', 'result_id', 'activity_type_id',
- 'release_frequency', 'max_number_of_contacts', 'default_number_of_contacts',
+ 'id',
+ 'title',
+ 'campaign_id',
+ 'is_active',
+ 'is_default',
+ 'result_id',
+ 'activity_type_id',
+ 'release_frequency',
+ 'max_number_of_contacts',
+ 'default_number_of_contacts',
);
$survey = CRM_Core_DAO::executeQuery($query, $queryParams);
/**
* Get the survey count.
*
- * @static
*/
public static function getSurveyCount() {
return (int) CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM civicrm_survey');
}
/**
- * Get Surveys
+ * Get Surveys.
*
* @param bool $onlyActive
* Retrieve only active surveys.
* @param bool $includePetition
* Include or exclude petitions.
*
- * @static
*/
public static function getSurveys($onlyActive = TRUE, $onlyDefault = FALSE, $forceAll = FALSE, $includePetition = FALSE) {
$cacheKey = 0;
}
/**
- * Get Surveys activity types
- *
- *
- * @static
+ * Get Survey activity types.
*/
- static function getSurveyActivityType(
- $returnColumn = 'label',
- $includePetitionActivityType = FALSE
- ) {
+ public static function getSurveyActivityType($returnColumn = 'label', $includePetitionActivityType = FALSE) {
static $activityTypes;
$cacheKey = "{$returnColumn}_{$includePetitionActivityType}";
}
/**
- * Get Surveys custom groups
+ * Get Surveys custom groups.
*
* @param array $surveyTypes
* an array of survey type id.
*
* @return array
- * @static
*/
public static function getSurveyCustomGroups($surveyTypes = array()) {
$customGroups = array();
}
/**
- * Update the is_active flag in the db
+ * Update the is_active flag in the db.
*
* @param int $id
* Id of the database record.
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object DAO object on sucess, null otherwise
- * @static
+ * @return Object
+ * DAO object on success, null otherwise
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Campaign_DAO_Survey', $id, 'is_active', $is_active);
}
/**
- * Delete the survey
+ * Delete the survey.
*
* @param int $id
* Survey id.
*
* @return mixed|null
- * @static
- *
*/
public static function del($id) {
if (!$id) {
* @param array $returnProperties
* An array of return elements.
*
- * @return array $voterDetails array of contact info.
- * @static
+ * @return array
+ * array of contact info.
*/
public static function voterDetails($voterIds, $returnProperties = array()) {
$voterDetails = array();
'contact_autocomplete_options'
);
$returnProperties = array_fill_keys(array_merge(array(
- 'contact_type',
- 'contact_sub_type',
- 'sort_name',
- ),
- array_keys($autocompleteContactSearch)
- ), 1);
+ 'contact_type',
+ 'contact_sub_type',
+ 'sort_name',
+ ),
+ array_keys($autocompleteContactSearch)
+ ), 1);
}
$select = $from = array();
foreach ($returnProperties as $property => $ignore) {
$value = (in_array($property, array(
- 'city', 'street_address'))) ? 'address' : $property;
+ 'city',
+ 'street_address',
+ ))) ? 'address' : $property;
switch ($property) {
case 'sort_name':
case 'contact_type':
//finally retrieve contact details.
if (!empty($select) && !empty($from)) {
- $fromClause = implode(' ', $from);
+ $fromClause = implode(' ', $from);
$selectClause = implode(', ', $select);
- $whereClause = "contact.id IN (" . implode(',', $voterIds) . ')';
+ $whereClause = "contact.id IN (" . implode(',', $voterIds) . ')';
$query = "
SELECT contact.id as contactId, $selectClause
* @param int $interviewerId
* @param array $statusIds
*
- * @return array $activityDetails array of survey activity.
- * @static
+ * @return array
+ * array of survey activity.
*/
- static function voterActivityDetails(
- $surveyId, $voterIds, $interviewerId = NULL,
- $statusIds = array()) {
+ public static function voterActivityDetails($surveyId, $voterIds, $interviewerId = NULL, $statusIds = array()) {
$activityDetails = array();
if (!$surveyId ||
!is_array($voterIds) || empty($voterIds)
*
* @return array
* An array of survey activity.
- * @static
*/
- static function getSurveyActivities(
+ public static function getSurveyActivities(
$surveyId,
$interviewerId = NULL,
$statusIds = NULL,
$whereClause";
$params = array(
- 1 => array($surveyId, 'Integer'),
+ 1 => array($surveyId, 'Integer'),
2 => array($actTypeId, 'Integer'),
);
*
* @return array
* Survey related contact ids.
- * @static
*/
public static function getSurveyVoterInfo($surveyId, $interviewerId = NULL, $statusIds = array()) {
$voterIds = array();
}
/**
- * This function retrieve all option groups which are created as a result set
+ * This function retrieve all option groups which are created as a result set.
*
* @param string $valueColumnName
- * @return array $resultSets an array of option groups.
- * @static
+ * @return array
+ * an array of option groups.
*/
public static function getResultSets($valueColumnName = 'title') {
$resultSets = array();
$valueColumnName = CRM_Utils_Type::escape($valueColumnName, 'String');
- $query = "SELECT id, {$valueColumnName} FROM civicrm_option_group WHERE name LIKE 'civicrm_survey_%' AND is_active=1";
- $dao = CRM_Core_DAO::executeQuery($query);
+ $query = "SELECT id, {$valueColumnName} FROM civicrm_option_group WHERE name LIKE 'civicrm_survey_%' AND is_active=1";
+ $dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$resultSets[$dao->id] = $dao->$valueColumnName;
}
*
* @param int $activityId
* Activity id.
- * @return boolean $isSurveyActivity true/false
- * @static
+ * @return bool
*/
public static function isSurveyActivity($activityId) {
$isSurveyActivity = FALSE;
}
/**
- * This function retrive all response options of survey
+ * This function retrive all response options of survey.
*
* @param int $surveyId
* Survey id.
- * @return array $responseOptions an array of option values
- * @static
+ * @return array
+ * an array of option values
*/
public static function getResponsesOptions($surveyId) {
$responseOptions = array();
}
/**
- * This function return all voter links with respecting permissions
+ * This function return all voter links with respecting permissions.
*
* @param int $surveyId
* @param bool $enclosedInUL
* @param string $extraULName
- * @return array|string $url array of permissioned links
- * @static
+ * @return array|string
+ * $url array of permissioned links
*/
public static function buildPermissionLinks($surveyId, $enclosedInUL = FALSE, $extraULName = 'more') {
$menuLinks = array();
if (CRM_Core_Permission::check('access CiviReport')) {
$reportID = self::getReportID($surveyId);
if ($reportID) {
- $voterLinks['report'] =
- array(
- 'name' => 'report',
- 'url' => "civicrm/report/instance/{$reportID}",
- 'qs' => 'reset=1',
- 'title' => ts('View Survey Report'),
- );
+ $voterLinks['report'] = array(
+ 'name' => 'report',
+ 'url' => "civicrm/report/instance/{$reportID}",
+ 'qs' => 'reset=1',
+ 'title' => ts('View Survey Report'),
+ );
}
}
/**
* Retrieve survey associated profile id.
- *
*/
public static function getSurveyProfileId($surveyId) {
if (!$surveyId) {
/**
* Decides the contact type for given survey.
- *
*/
public static function getSurveyContactType($surveyId) {
$contactType = NULL;
}
/**
- * Get survey supportable profile types
- *
+ * Get survey supportable profile types.
*/
public static function surveyProfileTypes() {
static $profileTypes;
}
/**
- * Get the valid survey response fields those
+ * Get the valid survey response fields those.
* are configured with profile and custom fields.
*
* @param int $surveyId
* @param int $surveyTypeId
* Survey activity type id.
*
- * @return array an array of valid survey response fields.
+ * @return array
+ * an array of valid survey response fields.
*/
public static function getSurveyResponseFields($surveyId, $surveyTypeId = NULL) {
if (empty($surveyId)) {
/**
* Get all interviewers of surveys.
*
- * @return array an array of valid survey response fields.
+ * @return array
+ * an array of valid survey response fields.
*/
public static function getInterviewers() {
static $interviewers;
*
* @param array $params
*
- * @return array success message
+ * @return array
+ * success message
*/
public static function releaseRespondent($params) {
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
* @see CRM_Core_DAO::buildOptions
*
* @param string $fieldName
- * @param string $context: @see CRM_Core_DAO::buildOptionsContext
- * @param array $props: whatever is known about this dao object
+ * @param string $context : @see CRM_Core_DAO::buildOptionsContext
+ * @param array $props : whatever is known about this dao object
*
* @return array|bool
*/
case 'activity_type_id':
$campaignCompId = CRM_Core_Component::getComponentID('CiviCampaign');
if ($campaignCompId) {
- $params['condition'] = array("component_id={$campaignCompId}", "v.name != 'Petition'");
+ $params['condition'] = array("component_id={$campaignCompId}");
}
break;
}
return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
}
+
}