X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCase%2FPage%2FAJAX.php;h=7e7256cc744c4502e1fa5c8d11d7bb5c9d870f82;hb=504e40d849d89dffb3d851e49cbb92c4d7b70795;hp=4686ad1e688c764205d676022169a1027741ac30;hpb=37f3ae13667f0324b3c075e7b1c47c80f81177e8;p=civicrm-core.git diff --git a/CRM/Case/Page/AJAX.php b/CRM/Case/Page/AJAX.php index 4686ad1e68..7e7256cc74 100644 --- a/CRM/Case/Page/AJAX.php +++ b/CRM/Case/Page/AJAX.php @@ -1,7 +1,7 @@ $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();