X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FDashboardContact.php;h=4df7815f4b84ede66aaedd72925016569729d45f;hb=85bb0909cffd925f4cd5c0022a68a1ff74d3ad8e;hp=280420f70243e28ea11aab3ede957ffa3b2134e8;hpb=b31a1c8c2b955c26f08339c38cd04c883a72545d;p=civicrm-core.git diff --git a/api/v3/DashboardContact.php b/api/v3/DashboardContact.php index 280420f702..4df7815f4b 100644 --- a/api/v3/DashboardContact.php +++ b/api/v3/DashboardContact.php @@ -2,9 +2,9 @@ /* +--------------------------------------------------------------------+ - | CiviCRM version 4.4 | + | CiviCRM version 4.5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2013 | + | Copyright CiviCRM LLC (c) 2004-2014 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -32,7 +32,7 @@ * @package CiviCRM_APIv3 * @subpackage API_ActionSchedule * - * @copyright CiviCRM LLC (c) 2004-2013 + * @copyright CiviCRM LLC (c) 2004-2014 * */ @@ -42,19 +42,22 @@ * @param array $params * * @return array - * + * */ function civicrm_api3_dashboard_contact_create($params) { - civicrm_api3_verify_one_mandatory($params, - NULL, - array( - 'dashboard_id', - ) - ); + if (empty($params['id'])) { + civicrm_api3_verify_one_mandatory($params, + NULL, + array( + 'dashboard_id', + ) + ); + } $errors = _civicrm_api3_dashboard_contact_check_params($params); - $dashboard[] = $params; - $dashbordContact = CRM_Core_BAO_Dashboard::addContactDashletToDashboard($dashboard); - return civicrm_api3_create_success(TRUE); + if ($errors !== NULL) { + return $errors; + } + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); } /** @@ -67,15 +70,7 @@ function civicrm_api3_dashboard_contact_create($params) { * */ function civicrm_api3_dashboard_contact_get($params) { - civicrm_api3_verify_one_mandatory($params, - NULL, - array( - 'contact_id', - ) - ); - $bao = new CRM_Core_BAO_Dashboard(); - $dashboardContact = CRM_Core_BAO_Dashboard::getContactDashlets(TRUE, CRM_Utils_Array::value('contact_id',$params)); - return civicrm_api3_create_success($dashboardContact, $params, 'dashboard_contact', 'get'); + return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } /** @@ -88,11 +83,31 @@ function _civicrm_api3_dashboard_contact_create_spec(&$params) { unset($params['version']); } +/** + * @param $params + * + * @return array|null + */ function _civicrm_api3_dashboard_contact_check_params(&$params) { $dashboard_id = CRM_Utils_Array::value('dashboard_id', $params); - $allDashlets = CRM_Core_BAO_Dashboard::getDashlets(); - if (!in_array($dashboard_id, $allDashlets)) { - return civicrm_api3_create_error('Invalid Dashboard ID'); + if ($dashboard_id) { + $allDashlets = CRM_Core_BAO_Dashboard::getDashlets(TRUE, CRM_Utils_Array::value('check_permissions', $params, 0)); + if (!isset($allDashlets[$dashboard_id])) { + return civicrm_api3_create_error('Invalid or inaccessible dashboard ID'); + } } - return null; -} \ No newline at end of file + return NULL; +} + +/** + * Delete an existing dashboard-contact + * + * This method is used to delete any existing dashboard-board. the id of the dashboard-contact + * is required field in $params array + * + * {@getfields dashboard_contact_delete} + * @access public + */ +function civicrm_api3_dashboard_contact_delete($params) { + return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); +}