X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCase%2FBAO%2FCase.php;h=caac6b3c11e6c76ca259598a3b90fdbf68bf0241;hb=e96d5fa3b3b73b9854c9082ac73701965ed314d3;hp=e66d30d684ebd72cc494960b7ba194b2d1b97a4d;hpb=1ddee35559d1f2bae7f97373c95d13b7e8add94e;p=civicrm-core.git
diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php
index e66d30d684..7df56b3dc3 100644
--- a/CRM/Case/BAO/Case.php
+++ b/CRM/Case/BAO/Case.php
@@ -1,9 +1,9 @@
enableComponents);
+ }
+
+ /**
+ * Takes an associative array and creates a case object
*
* the function extract all the params it needs to initialize the create a
* case object. the params array could contain additional unused name/value
* pairs
*
- * @param array $params (reference ) an assoc array of name/value pairs
- * @param array $ids the array that holds all the db ids
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
*
- * @return object CRM_Case_BAO_Case object
- * @access public
- * @static
+ * @return CRM_Case_BAO_Case
*/
- static function add(&$params) {
+ public static function add(&$params) {
$caseDAO = new CRM_Case_DAO_Case();
$caseDAO->copyValues($params);
return $caseDAO->save();
@@ -75,15 +84,16 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
* Given the list of params in the params array, fetch the object
* and store the values in the values array
*
- * @param array $params input parameters to find object
- * @param array $values output values of the object
- * @param array $ids the array that holds all the db ids
+ * @param array $params
+ * Input parameters to find object.
+ * @param array $values
+ * Output values of the object.
+ * @param array $ids
+ * The array that holds all the db ids.
*
* @return CRM_Case_BAO_Case|null the found object or null
- * @access public
- * @static
*/
- static function &getValues(&$params, &$values, &$ids) {
+ public static function &getValues(&$params, &$values, &$ids) {
$case = new CRM_Case_BAO_Case();
$case->copyValues($params);
@@ -97,19 +107,17 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
}
/**
- * takes an associative array and creates a case object
+ * Takes an associative array and creates a case object
*
- * @param array $params (reference ) an assoc array of name/value pairs
- * @param array $ids the array that holds all the db ids
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
*
- * @return object CRM_Case_BAO_Case object
- * @access public
- * @static
+ * @return CRM_Case_BAO_Case
*/
- static function &create(&$params) {
+ public static function &create(&$params) {
$transaction = new CRM_Core_Transaction();
- if (CRM_Utils_Array::value('id', $params)) {
+ if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'Case', $params['id'], $params);
}
else {
@@ -118,7 +126,7 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
$case = self::add($params);
- if (CRM_Utils_Array::value('custom', $params) &&
+ if (!empty($params['custom']) &&
is_array($params['custom'])
) {
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_case', $case->id);
@@ -129,7 +137,7 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
return $case;
}
- if (CRM_Utils_Array::value('id', $params)) {
+ if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'Case', $case->id, $case);
}
else {
@@ -145,12 +153,12 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
/**
* Create case contact record
*
- * @param array case_id, contact_id
+ * @param array $params
+ * case_id, contact_id
*
* @return object
- * @access public
*/
- static function addCaseToContact($params) {
+ public static function addCaseToContact($params) {
$caseContact = new CRM_Case_DAO_CaseContact();
$caseContact->case_id = $params['case_id'];
$caseContact->contact_id = $params['contact_id'];
@@ -158,12 +166,12 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
$caseContact->save();
// add to recently viewed
- $caseType = CRM_Case_PseudoConstant::caseTypeName($caseContact->case_id, 'label');
+ $caseType = CRM_Case_BAO_Case::getCaseType($caseContact->case_id);
$url = CRM_Utils_System::url('civicrm/contact/view/case',
"action=view&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home"
);
- $title = CRM_Contact_BAO_Contact::displayName($caseContact->contact_id) . ' - ' . $caseType['name'];
+ $title = CRM_Contact_BAO_Contact::displayName($caseContact->contact_id) . ' - ' . $caseType;
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) {
@@ -188,12 +196,11 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
/**
* Delet case contact record
*
- * @param int case_id
+ * @param int $caseID
*
- * @return Void
- * @access public
+ * @return void
*/
- static function deleteCaseContact($caseID) {
+ public static function deleteCaseContact($caseID) {
$caseContact = new CRM_Case_DAO_CaseContact();
$caseContact->case_id = $caseID;
$caseContact->delete();
@@ -207,14 +214,14 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
}
/**
- * This function is used to convert associative array names to values
+ * convert associative array names to values
* and vice-versa.
*
* This function is used by both the web form layer and the api. Note that
* the api needs the name => value conversion, also the view layer typically
* requires value => name conversion
*/
- static function lookupValue(&$defaults, $property, &$lookup, $reverse) {
+ public static function lookupValue(&$defaults, $property, &$lookup, $reverse) {
$id = $property . '_id';
$src = $reverse ? $property : $id;
@@ -241,30 +248,30 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
* full featured over a period of time. This is the inverse function of
* create. 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 name / value pairs
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
+ * @param array $defaults
+ * (reference ) an assoc array to hold the name / value pairs.
* in a hierarchical manner
- * @param array $ids (reference) the array that holds all the db ids
+ * @param array $ids
+ * (reference) the array that holds all the db ids.
*
- * @return object CRM_Case_BAO_Case object
- * @access public
- * @static
+ * @return CRM_Case_BAO_Case
*/
- static function retrieve(&$params, &$defaults, &$ids) {
+ public static function retrieve(&$params, &$defaults, &$ids) {
$case = CRM_Case_BAO_Case::getValues($params, $defaults, $ids);
return $case;
}
/**
- * Function to process case activity add/delete
+ * Process case activity add/delete
* takes an associative array and
*
- * @param array $params (reference ) an assoc array of name/value pairs
+ * @param array $params
+ * (reference ) an assoc array of name/value pairs.
*
- * @access public
- * @static
*/
- static function processCaseActivity(&$params) {
+ public static function processCaseActivity(&$params) {
$caseActivityDAO = new CRM_Case_DAO_CaseActivity();
$caseActivityDAO->activity_id = $params['activity_id'];
$caseActivityDAO->case_id = $params['case_id'];
@@ -274,15 +281,14 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
}
/**
- * Function to get the case subject for Activity
+ * Get the case subject for Activity
*
- * @param int $activityId activity id
+ * @param int $activityId
+ * Activity id.
*
- * @return case subject or null
- * @access public
- * @static
+ * @return string|null
*/
- static function getCaseSubject($activityId) {
+ public static function getCaseSubject($activityId) {
$caseActivity = new CRM_Case_DAO_CaseActivity();
$caseActivity->activity_id = $activityId;
if ($caseActivity->find(TRUE)) {
@@ -292,43 +298,39 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
}
/**
- * Function to get the case type.
+ * Get the case type.
*
* @param int $caseId
+ * @param string $colName
*
- * @return case type
- * @access public
- * @static
+ * @return string
+ * case type
*/
- static function getCaseType($caseId, $colName = 'label') {
- $caseType = NULL;
- if (!$caseId) {
- return $caseType;
- }
-
- $sql = "
- SELECT ov.{$colName}
- FROM civicrm_case ca
- INNER JOIN civicrm_option_group og ON og.name='case_type'
- INNER JOIN civicrm_option_value ov ON ( ca.case_type_id=ov.value AND ov.option_group_id=og.id )
- WHERE ca.id = %1";
+ public static function getCaseType($caseId, $colName = 'title') {
+ $query = "
+SELECT civicrm_case_type.{$colName} FROM civicrm_case
+LEFT JOIN civicrm_case_type ON
+ civicrm_case.case_type_id = civicrm_case_type.id
+WHERE civicrm_case.id = %1";
- $params = array(1 => array($caseId, 'Integer'));
+ $queryParams = array(1 => array($caseId, 'Integer'));
- return CRM_Core_DAO::singleValueQuery($sql, $params);
+ return CRM_Core_DAO::singleValueQuery($query, $queryParams);
}
/**
* Delete the record that are associated with this case
* record are deleted from case
*
- * @param int $caseId id of the case to delete
+ * @param int $caseId
+ * Id of the case to delete.
*
- * @return void
- * @access public
- * @static
+ * @param bool $moveToTrash
+ *
+ * @return bool
+ * is successful
*/
- static function deleteCase($caseId, $moveToTrash = FALSE) {
+ public static function deleteCase($caseId, $moveToTrash = FALSE) {
CRM_Utils_Hook::pre('delete', 'Case', $caseId, CRM_Core_DAO::$_nullArray);
//delete activities
@@ -372,16 +374,16 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
}
/**
- * Function to enable disable case related relationships
+ * Enable disable case related relationships
*
- * @param int $caseId case id
- * @param boolean $enable action
+ * @param int $caseId
+ * Case id.
+ * @param bool $enable
+ * Action.
*
* @return void
- * @access public
- * @static
*/
- static function enableDisableCaseRelationships($caseId, $enable) {
+ public static function enableDisableCaseRelationships($caseId, $enable) {
$contactIds = self::retrieveContactIdsByCaseId($caseId);
if (!empty($contactIds)) {
foreach ($contactIds as $cid) {
@@ -400,13 +402,12 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
/**
* Delete the activities related to case
*
- * @param int $activityId id of the activity
+ * @param int $activityId
+ * Id of the activity.
*
* @return void
- * @access public
- * @static
*/
- static function deleteCaseActivity($activityId) {
+ public static function deleteCaseActivity($activityId) {
$case = new CRM_Case_DAO_CaseActivity();
$case->activity_id = $activityId;
$case->delete();
@@ -415,13 +416,14 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
/**
* Retrieve contact_id by case_id
*
- * @param int $caseId ID of the case
+ * @param int $caseId
+ * ID of the case.
*
- * @return array
- * @access public
+ * @param int $contactID
*
+ * @return array
*/
- static function retrieveContactIdsByCaseId($caseId, $contactID = NULL) {
+ public static function retrieveContactIdsByCaseId($caseId, $contactID = NULL) {
$caseContact = new CRM_Case_DAO_CaseContact();
$caseContact->case_id = $caseId;
$caseContact->find();
@@ -440,11 +442,11 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
/**
* Look up a case using an activity ID
*
- * @param $activity_id
+ * @param int $activityId
*
* @return int, case ID
*/
- static function getCaseIdByActivityId($activityId) {
+ public static function getCaseIdByActivityId($activityId) {
$originalId = CRM_Core_DAO::singleValueQuery(
'SELECT original_id FROM civicrm_activity WHERE id = %1',
array('1' => array($activityId, 'Integer'))
@@ -462,14 +464,12 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
/**
* Retrieve contact names by caseId
*
- * @param int $caseId ID of the case
+ * @param int $caseId
+ * ID of the case.
*
* @return array
- *
- * @access public
- *
*/
- static function getContactNames($caseId) {
+ public static function getContactNames($caseId) {
$contactNames = array();
if (!$caseId) {
return $contactNames;
@@ -507,21 +507,27 @@ class CRM_Case_BAO_Case extends CRM_Case_DAO_Case {
/**
* Retrieve case_id by contact_id
*
- * @param int $contactId ID of the contact
- * @param boolean $includeDeleted include the deleted cases in result
+ * @param int $contactID
+ * @param bool $includeDeleted
+ * Include the deleted cases in result.
+ * @param null $caseType
*
* @return array
- *
- * @access public
- *
*/
- static function retrieveCaseIdsByContactId($contactID, $includeDeleted = FALSE) {
+ public static function retrieveCaseIdsByContactId($contactID, $includeDeleted = FALSE, $caseType = NULL) {
$query = "
SELECT ca.id as id
FROM civicrm_case_contact cc
INNER JOIN civicrm_case ca ON cc.case_id = ca.id
-WHERE cc.contact_id = %1
";
+ if (isset($caseType)) {
+ $query .=
+ "INNER JOIN civicrm_case_type ON civicrm_case_type.id = ca.case_type_id
+WHERE cc.contact_id = %1 AND civicrm_case_type.name = '{$caseType}'";
+ }
+ if (!isset($caseType)) {
+ $query .= "WHERE cc.contact_id = %1";
+ }
if (!$includeDeleted) {
$query .= " AND ca.is_deleted = 0";
}
@@ -538,7 +544,15 @@ WHERE cc.contact_id = %1
return $caseArray;
}
- static function getCaseActivityQuery($type = 'upcoming', $userID = NULL, $condition = NULL, $isDeleted = 0) {
+ /**
+ * @param string $type
+ * @param int $userID
+ * @param null $condition
+ * @param int $isDeleted
+ *
+ * @return string
+ */
+ public static function getCaseActivityQuery($type = 'upcoming', $userID = NULL, $condition = NULL, $isDeleted = 0) {
if (!$userID) {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
@@ -556,8 +570,8 @@ civicrm_phone.phone as phone,
civicrm_contact.contact_type as contact_type,
civicrm_contact.contact_sub_type as contact_sub_type,
t_act.activity_type_id,
-cov_type.label as case_type,
-cov_type.name as case_type_name,
+c_type.title as case_type,
+civicrm_case.case_type_id as case_type_id,
cov_status.label as case_status,
cov_status.label as case_status_name,
t_act.status_id,
@@ -578,8 +592,8 @@ t_act.id as case_recent_activity_id,
t_act.act_type_name as case_recent_activity_type_name,
t_act.act_type AS case_recent_activity_type ";
}
- elseif ( $type == 'any' ) {
- $query .= "
+ elseif ($type == 'any') {
+ $query .= "
t_act.desired_date as case_activity_date,
t_act.id as case_activity_id,
t_act.act_type_name as case_activity_type_name,
@@ -631,7 +645,7 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
LEFT JOIN civicrm_option_value aov ON ( aov.option_group_id = aog.id AND aov.value = act.activity_type_id )
) AS t_act ";
}
- elseif ( $type == 'any' ) {
+ elseif ($type == 'any') {
$query .= " LEFT JOIN
(
SELECT ca4.case_id, act4.id AS id, act4.activity_date_time AS desired_date, act4.activity_type_id, act4.status_id, aov.name AS act_type_name, aov.label AS act_type
@@ -658,12 +672,8 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
ON ( case_relation_type.id = case_relationship.relationship_type_id
AND case_relation_type.id = case_relationship.relationship_type_id )
- LEFT JOIN civicrm_option_group cog_type
- ON cog_type.name = 'case_type'
-
- LEFT JOIN civicrm_option_value cov_type
- ON ( civicrm_case.case_type_id = cov_type.value
- AND cog_type.id = cov_type.option_group_id )
+ LEFT JOIN civicrm_case_type c_type
+ ON civicrm_case.case_type_id = c_type.id
LEFT JOIN civicrm_option_group cog_status
ON cog_status.name = 'case_status'
@@ -684,7 +694,7 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
elseif ($type == 'recent') {
$query .= " ORDER BY case_recent_activity_date ASC ";
}
- elseif ( $type == 'any' ) {
+ elseif ($type == 'any') {
$query .= " ORDER BY case_activity_date ASC ";
}
@@ -695,18 +705,19 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
* Retrieve cases related to particular contact or whole contact
* used in Dashboad and Tab
*
- * @param boolean $allCases
+ * @param bool $allCases
*
* @param int $userID
*
- * @param String $type /upcoming,recent,all/
+ * @param string $type
+ * /upcoming,recent,all/.
*
- * @return array Array of Cases
- *
- * @access public
+ * @param string $context
*
+ * @return array
+ * Array of Cases
*/
- static function getCases($allCases = TRUE, $userID = NULL, $type = 'upcoming', $context = 'dashboard') {
+ public static function getCases($allCases = TRUE, $userID = NULL, $type = 'upcoming', $context = 'dashboard') {
$condition = NULL;
$casesList = array();
@@ -725,13 +736,12 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
$allCases = FALSE;
}
-
$condition = " AND civicrm_case.is_deleted = 0 ";
if (!$allCases) {
$condition .= " AND case_relationship.contact_id_b = {$userID} ";
}
- if ( $type == 'upcoming' || $type == 'any' ) {
+ if ($type == 'upcoming' || $type == 'any') {
$closedId = CRM_Core_OptionGroup::getValue('case_status', 'Closed', 'name');
$condition .= "
AND civicrm_case.status_id != $closedId";
@@ -754,7 +764,7 @@ AND civicrm_case.status_id != $closedId";
'case_id',
'case_subject',
'case_type',
- 'case_type_name',
+ 'case_type_id',
'status_id',
'case_status',
'case_status_name',
@@ -775,7 +785,7 @@ AND civicrm_case.status_id != $closedId";
$resultFields[] = 'case_recent_activity_type';
$resultFields[] = 'case_recent_activity_id';
}
- elseif ( $type == 'any' ) {
+ elseif ($type == 'any') {
$resultFields[] = 'case_activity_date';
$resultFields[] = 'case_activity_type_name';
$resultFields[] = 'case_activity_type';
@@ -785,7 +795,6 @@ AND civicrm_case.status_id != $closedId";
// we're going to use the usual actions, so doesn't make sense to duplicate definitions
$actions = CRM_Case_Selector_Search::links();
-
// check is the user has view/edit signer permission
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('access all cases and activities') ||
@@ -802,15 +811,19 @@ AND civicrm_case.status_id != $closedId";
foreach ($resultFields as $donCare => $field) {
$casesList[$result->case_id][$field] = $result->$field;
if ($field == 'contact_type') {
- $casesList[$result->case_id]['contact_type_icon'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ?
- $result->contact_sub_type : $result->contact_type
+ $casesList[$result->case_id]['contact_type_icon'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type
);
$casesList[$result->case_id]['action'] = CRM_Core_Action::formLink($actions['primaryActions'], $mask,
array(
'id' => $result->case_id,
'cid' => $result->contact_id,
'cxt' => $context,
- )
+ ),
+ ts('more'),
+ FALSE,
+ 'case.actions.primary',
+ 'Case',
+ $result->case_id
);
$casesList[$result->case_id]['moreActions'] = CRM_Core_Action::formLink($actions['moreActions'],
$mask,
@@ -820,7 +833,10 @@ AND civicrm_case.status_id != $closedId";
'cxt' => $context,
),
ts('more'),
- TRUE
+ TRUE,
+ 'case.actions.more',
+ 'Case',
+ $result->case_id
);
}
elseif ($field == 'case_status') {
@@ -833,7 +849,8 @@ AND civicrm_case.status_id != $closedId";
}
}
//CRM-4510.
- $caseManagerContact = self::getCaseManagerContact($result->case_type_name, $result->case_id);
+ $caseTypes = CRM_Case_PseudoConstant::caseType('name');
+ $caseManagerContact = self::getCaseManagerContact($caseTypes[$result->case_type_id], $result->case_id);
if (!empty($caseManagerContact)) {
$casesList[$result->case_id]['casemanager_id'] = CRM_Utils_Array::value('casemanager_id', $caseManagerContact);
$casesList[$result->case_id]['casemanager'] = CRM_Utils_Array::value('casemanager', $caseManagerContact);
@@ -858,9 +875,13 @@ AND civicrm_case.status_id != $closedId";
}
/**
- * Function to get the summary of cases counts by type and status.
+ * Get the summary of cases counts by type and status.
+ *
+ * @param bool $allCases
+ * @param int $userID
+ * @return array
*/
- static function getCasesSummary($allCases = TRUE, $userID) {
+ public static function getCasesSummary($allCases = TRUE, $userID) {
$caseSummary = array();
//validate access for civicase.
@@ -900,15 +921,11 @@ AND civicrm_case.status_id != $closedId";
$myGroupByClause = " GROUP BY CONCAT(case_relationship.case_id,'-',case_relationship.contact_id_b)";
}
- $seperator = CRM_Core_DAO::VALUE_SEPARATOR;
-
$query = "
-SELECT case_status.label AS case_status, status_id, case_type.label AS case_type,
- REPLACE(case_type_id,'{$seperator}','') AS case_type_id, case_relationship.contact_id_b
+SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS case_type,
+ case_type_id, case_relationship.contact_id_b
FROM civicrm_case
- LEFT JOIN civicrm_option_group option_group_case_type ON ( option_group_case_type.name = 'case_type' )
- LEFT JOIN civicrm_option_value case_type ON ( civicrm_case.case_type_id = case_type.value
- AND option_group_case_type.id = case_type.option_group_id )
+ LEFT JOIN civicrm_case_type ON civicrm_case.case_type_id = civicrm_case_type.id
LEFT JOIN civicrm_option_group option_group_case_status ON ( option_group_case_status.name = 'case_status' )
LEFT JOIN civicrm_option_value case_status ON ( civicrm_case.status_id = case_status.value
AND option_group_case_status.id = case_status.option_group_id )
@@ -919,7 +936,7 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
$res = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
while ($res->fetch()) {
- if (CRM_Utils_Array::value($res->case_type, $rows) && CRM_Utils_Array::value($res->case_status, $rows[$res->case_type])) {
+ if (!empty($rows[$res->case_type]) && !empty($rows[$res->case_type][$res->case_status])) {
$rows[$res->case_type][$res->case_status]['count'] = $rows[$res->case_type][$res->case_status]['count'] + 1;
}
else {
@@ -937,15 +954,19 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
}
/**
- * Function to get Case roles
+ * Get Case roles
*
- * @param int $contactID contact id
- * @param int $caseID case id
- * @return returns case role / relationships
+ * @param int $contactID
+ * Contact id.
+ * @param int $caseID
+ * Case id.
+ * @param int $relationshipID
+ *
+ * @return array
+ * case role / relationships
*
- * @static
*/
- static function getCaseRoles($contactID, $caseID, $relationshipID = NULL) {
+ public static function getCaseRoles($contactID, $caseID, $relationshipID = NULL) {
$query = '
SELECT civicrm_relationship.id as civicrm_relationship_id,
civicrm_contact.sort_name as sort_name,
@@ -962,7 +983,6 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
LEFT JOIN civicrm_email ON (civicrm_email.contact_id = civicrm_contact.id )
WHERE civicrm_relationship.contact_id_a = %1 AND civicrm_relationship.case_id = %2';
-
$params = array(
1 => array($contactID, 'Positive'),
2 => array($caseID, 'Positive'),
@@ -992,17 +1012,24 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
}
/**
- * Function to get Case Activities
+ * Get Case Activities
*
- * @param int $caseID case id
- * @param array $params posted params
- * @param int $contactID contact id
+ * @param int $caseID
+ * Case id.
+ * @param array $params
+ * Posted params.
+ * @param int $contactID
+ * Contact id.
*
- * @return returns case activities
+ * @param null $context
+ * @param int $userID
+ * @param null $type
+ *
+ * @return array
+ * Array of case activities
*
- * @static
*/
- static function getCaseActivity($caseID, &$params, $contactID, $context = NULL, $userID = NULL, $type = NULL) {
+ public static function getCaseActivity($caseID, &$params, $contactID, $context = NULL, $userID = NULL, $type = NULL) {
$values = array();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
@@ -1049,29 +1076,29 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
$where = 'WHERE cca.case_id= %1
AND ca.is_current_revision = 1';
- if (CRM_Utils_Array::value('reporter_id', $params)) {
+ if (!empty($params['reporter_id'])) {
$where .= " AND cac.contact_id = " . CRM_Utils_Type::escape($params['reporter_id'], 'Integer');
}
- if (CRM_Utils_Array::value('status_id', $params)) {
+ if (!empty($params['status_id'])) {
$where .= " AND ca.status_id = " . CRM_Utils_Type::escape($params['status_id'], 'Integer');
}
- if (CRM_Utils_Array::value('activity_deleted', $params)) {
+ if (!empty($params['activity_deleted'])) {
$where .= " AND ca.is_deleted = 1";
}
else {
$where .= " AND ca.is_deleted = 0";
}
- if (CRM_Utils_Array::value('activity_type_id', $params)) {
+ if (!empty($params['activity_type_id'])) {
$where .= " AND ca.activity_type_id = " . CRM_Utils_Type::escape($params['activity_type_id'], 'Integer');
}
- if (CRM_Utils_Array::value('activity_date_low', $params)) {
+ if (!empty($params['activity_date_low'])) {
$fromActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_low']), 'Date');
}
- if (CRM_Utils_Array::value('activity_date_high', $params)) {
+ if (!empty($params['activity_date_high'])) {
$toActivityDate = CRM_Utils_Type::escape(CRM_Utils_Date::processDate($params['activity_date_high']), 'Date');
$toActivityDate = $toActivityDate ? $toActivityDate + 235959 : NULL;
}
@@ -1135,7 +1162,6 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
//EXIT;
$dao = CRM_Core_DAO::executeQuery($query, $params);
-
$activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE);
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$activityPriority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id');
@@ -1151,8 +1177,8 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
$editUrl = "{$url}&action=update{$contextUrl}";
$deleteUrl = "{$url}&action=delete{$contextUrl}";
$restoreUrl = "{$url}&action=renew{$contextUrl}";
- $viewTitle = ts('View this activity.');
- $statusTitle = ts('Edit status');
+ $viewTitle = ts('View activity');
+ $statusTitle = ts('Edit Status');
$emailActivityTypeIDs = array(
'Email' => CRM_Core_OptionGroup::getValue('activity_type',
@@ -1236,7 +1262,8 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
//check for view activity.
$subject = (empty($dao->subject)) ? '(' . ts('no subject') . ')' : $dao->subject;
if ($allowView) {
- $subject = '' . $subject . '';
+ $url = CRM_Utils_System::url('civicrm/case/activity/view', array('cid' => $contactID, 'aid' => $dao->id));
+ $subject = '' . $subject . '';
}
$values[$dao->id]['subject'] = $subject;
@@ -1252,34 +1279,33 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
$values[$dao->id]['reporter'] .= ' / ' . ts('(multiple)');
}
}
+ // FIXME: Why are we not using CRM_Core_Action for these links? This is too much manual work and likely to get out-of-sync with core markup.
$url = "";
+ $css = 'class="action-item crm-hover-button"';
$additionalUrl = "&id={$dao->id}";
if (!$dao->deleted) {
//hide edit link of activity type email.CRM-4530.
if (!in_array($dao->type, $emailActivityTypeIDs)) {
//hide Edit link if activity type is NOT editable (special case activities).CRM-5871
if ($allowEdit) {
- $url = '' . ts('Edit') . ' ';
+ $url = '' . ts('Edit') . ' ';
}
}
if ($allowDelete) {
- if (!empty($url)) {
- $url .= " | ";
- }
- $url .= '' . ts('Delete') . '';
+ $url .= ' ' . ts('Delete') . '';
}
}
elseif (!$caseDeleted) {
- $url = '' . ts('Restore') . '';
+ $url = ' ' . ts('Restore') . '';
$values[$dao->id]['status'] = $values[$dao->id]['status'] . '
(deleted)';
}
//check for operations.
if (self::checkPermission($dao->id, 'Move To Case', $dao->activity_type_id)) {
- $url .= " | " . '' . ts('Move To Case') . ' ';
+ $url .= ' ' . ts('Move To Case') . ' ';
}
if (self::checkPermission($dao->id, 'Copy To Case', $dao->activity_type_id)) {
- $url .= " | " . '' . ts('Copy To Case') . ' ';
+ $url .= ' ' . ts('Copy To Case') . ' ';
}
// if there are file attachments we will return how many and, if only one, add a link to it
if (!empty($dao->attachment_ids)) {
@@ -1294,11 +1320,10 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
NULL,
FALSE
);
- $url .= " | " . "" . ts('View Attachment') . ' ';
+ $url .= " ";
}
}
-
$values[$dao->id]['links'] = $url;
$values[$dao->id]['class'] = "";
@@ -1324,7 +1349,7 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type
}
if ($allowEdit) {
- $values[$dao->id]['status'] = '' . $values[$dao->id]['status'] . '';
+ $values[$dao->id]['status'] = '