X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCase%2FPage%2FAJAX.php;h=7e7256cc744c4502e1fa5c8d11d7bb5c9d870f82;hb=504e40d849d89dffb3d851e49cbb92c4d7b70795;hp=92ce576c301868539c3c9c45ec442e99d4657020;hpb=444cd89f6b16c08f4312eec9739548c18b8a65b2;p=civicrm-core.git diff --git a/CRM/Case/Page/AJAX.php b/CRM/Case/Page/AJAX.php index 92ce576c30..7e7256cc74 100644 --- a/CRM/Case/Page/AJAX.php +++ b/CRM/Case/Page/AJAX.php @@ -41,30 +41,25 @@ class CRM_Case_Page_AJAX { * Retrieve unclosed cases. */ static function unclosedCases() { - $criteria = explode('-', CRM_Utils_Type::escape(CRM_Utils_Array::value('s', $_GET), 'String')); - - $limit = CRM_Utils_Array::value('limit', $_GET); - if ($limit) { - $limit = CRM_Utils_Type::escape($limit, 'Integer'); - } - $params = array( - 'limit' => $limit, - 'case_type' => trim(CRM_Utils_Array::value(1, $criteria)), - 'sort_name' => trim(CRM_Utils_Array::value(0, $criteria)), + 'limit' => CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'search_autocomplete_count', NULL, 10), + 'sort_name' => CRM_Utils_Type::escape(CRM_Utils_Array::value('term', $_GET, ''), 'String'), ); $excludeCaseIds = array(); - if ($caseIdStr = CRM_Utils_Array::value('excludeCaseIds', $_GET)) { - $excludeIdStr = CRM_Utils_Type::escape($caseIdStr, 'String'); - $excludeCaseIds = explode(',', $excludeIdStr); + if (!empty($_GET['excludeCaseIds'])) { + $excludeCaseIds = explode(',', CRM_Utils_Type::escape($_GET['excludeCaseIds'], 'String')); } $unclosedCases = CRM_Case_BAO_Case::getUnclosedCases($params, $excludeCaseIds); - + $results = array(); foreach ($unclosedCases as $caseId => $details) { - echo $details['sort_name'] . ' (' . $details['case_type'] . ': ' . $details['case_subject'] . ') ' . "|$caseId|" . $details['contact_id'] . '|' . $details['case_type'] . '|' . $details['sort_name'] . "\n"; + $results[] = array( + 'id' => $caseId, + 'text' => $details['sort_name'] . ' (' . $details['case_type'] . ': ' . $details['case_subject'] . ')', + 'extra' => $details, + ); } - + print json_encode($results); CRM_Utils_System::civiExit(); } @@ -72,6 +67,7 @@ class CRM_Case_Page_AJAX { $caseId = CRM_Utils_Type::escape($_POST['case_id'], 'Integer'); $tags = CRM_Utils_Type::escape($_POST['tag'], 'String'); + $tagList = $_POST['taglist']; if (empty($caseId)) { echo 'false'; @@ -83,20 +79,26 @@ class CRM_Case_Page_AJAX { $tagIds = explode(',', $tags); } - $params = array( - 'entity_id' => $caseId, - 'entity_table' => 'civicrm_case', - ); + if (!empty($tagIds)) { + $params = array( + 'entity_id' => $caseId, + 'entity_table' => 'civicrm_case', + ); - CRM_Core_BAO_EntityTag::del($params); + CRM_Core_BAO_EntityTag::del($params); - foreach ($tagIds as $tagid) { - if (is_numeric($tagid)) { - $params['tag_id'] = $tagid; - CRM_Core_BAO_EntityTag::add($params); + foreach ($tagIds as $tagid) { + if (is_numeric($tagid)) { + $params['tag_id'] = $tagid; + CRM_Core_BAO_EntityTag::add($params); + } } } + if (!empty($tagList)) { + CRM_Core_Form_Tag::postProcess($tagList, $caseId, 'civicrm_case', CRM_Core_DAO::$_nullObject); + } + $session = CRM_Core_Session::singleton(); $activityParams = array();