Merge pull request #6378 from johanv/CRM-15991-permission_delete_relationship
[civicrm-core.git] / api / v3 / Survey.php
index a6e1858e1ff4309a2cdbc19344bea09c479d35f8..922a634f4962776003c5a391e0fd1f98db0a1b7d 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  */
 
 /**
- * This api exposes CiviCRM survey.
+ * This api exposes CiviCRM survey/petition records.
+ *
+ * @note Campaign component must be enabled.
+ * @note There is no "petition" api.
+ * Surveys and petitions are the same basic object and this api is used for both.
  *
  * @package CiviCRM_APIv3
- * @subpackage API_Survey
  */
 
 
@@ -52,7 +55,7 @@ function civicrm_api3_survey_create($params) {
  * The metadata is used for setting defaults, documentation & validation.
  *
  * @param array $params
- *   Array or parameters determined by getfields.
+ *   Array of parameters determined by getfields.
  */
 function _civicrm_api3_survey_create_spec(&$params) {
   $params['title']['api.required'] = 1;
@@ -62,9 +65,7 @@ function _civicrm_api3_survey_create_spec(&$params) {
  * Returns array of surveys  matching a set of one or more group properties.
  *
  * @param array $params
- *   Array of one or more valid.
- *                       property_name=>value pairs. If $params is set
- *                       as null, all surveys will be returned
+ *   Array of properties. If empty, all records will be returned.
  *
  * @return array
  *   API result Array of matching surveys
@@ -76,8 +77,7 @@ function civicrm_api3_survey_get($params) {
 /**
  * Delete an existing survey.
  *
- * This method is used to delete any existing survey. id of the group
- * to be deleted is required field in $params array
+ * This method is used to delete any existing survey given its id.
  *
  * @param array $params
  *   [id]
@@ -88,3 +88,23 @@ function civicrm_api3_survey_get($params) {
 function civicrm_api3_survey_delete($params) {
   return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
+
+/**
+ * Set default getlist parameters.
+ *
+ * @see _civicrm_api3_generic_getlist_defaults
+ *
+ * @param array $request
+ *
+ * @return array
+ */
+function _civicrm_api3_survey_getlist_defaults(&$request) {
+  return array(
+    'description_field' => array(
+      'campaign_id',
+    ),
+    'params' => array(
+      'is_active' => 1,
+    ),
+  );
+}