本文整理汇总了PHP中CRM_Case_XMLProcessor_Process::getAllowMultipleCaseClients方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Case_XMLProcessor_Process::getAllowMultipleCaseClients方法的具体用法?PHP CRM_Case_XMLProcessor_Process::getAllowMultipleCaseClients怎么用?PHP CRM_Case_XMLProcessor_Process::getAllowMultipleCaseClients使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Case_XMLProcessor_Process
的用法示例。
在下文中一共展示了CRM_Case_XMLProcessor_Process::getAllowMultipleCaseClients方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @param $caseType
* @param array $params
*
* @return bool
* @throws Exception
*/
public function run($caseType, &$params)
{
$xml = $this->retrieve($caseType);
if ($xml === FALSE) {
$docLink = CRM_Utils_System::docURL2("user/case-management/setup");
CRM_Core_Error::fatal(ts("Configuration file could not be retrieved for case type = '%1' %2.", array(1 => $caseType, 2 => $docLink)));
return FALSE;
}
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$this->_isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
$this->process($xml, $params);
}
示例2: run
function run($caseType, &$params)
{
$xml = $this->retrieve($caseType);
if ($xml === false) {
require_once 'CRM/Utils/System.php';
$docLink = CRM_Utils_System::docURL2("CiviCase Configuration");
CRM_Core_Error::fatal(ts("Configuration file could not be retrieved for case type = '%1' %2.", array(1 => $caseType, 2 => $docLink)));
return false;
}
require_once 'CRM/Case/XMLProcessor/Process.php';
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$this->_isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
$this->process($xml, $params);
}
示例3: buildQuickForm
public function buildQuickForm()
{
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
$this->assign('multiClient', $isMultiClient);
if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) {
$title = 'Delete';
if ($this->_action & CRM_Core_Action::RENEW) {
$title = 'Restore';
}
$this->addButtons(array(array('type' => 'next', 'name' => $title, 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
if ($this->_cdType) {
return CRM_Custom_Form_CustomData::buildQuickForm($this);
}
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Case');
CRM_Custom_Form_CustomData::buildQuickForm($this);
// we don't want to show button on top of custom form
$this->assign('noPreCustomButton', TRUE);
$s = CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'subject');
if (!is_array($s)) {
$s = array();
}
$this->add('text', 'activity_subject', ts('Subject'), array_merge($s, array('maxlength' => '128')), TRUE);
$tags = CRM_Core_BAO_Tag::getTags('civicrm_case');
if (!empty($tags)) {
$this->add('select', 'tag', ts('Select Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
}
// build tag widget
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case');
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', NULL, FALSE, TRUE);
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}::buildQuickForm( \$this );");
}
示例4: preProcess
/**
* Build the form object.
*
* @return void
*/
public function preProcess()
{
$caseIds = CRM_Utils_Request::retrieve('caseid', 'String', $this);
$this->_caseId = explode(',', $caseIds);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
if (!$this->_context) {
$this->_context = 'caseActivity';
}
$this->_crmDir = 'Case';
$this->assign('context', $this->_context);
$result = parent::preProcess();
$scheduleStatusId = CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name');
$this->assign('scheduleStatusId', $scheduleStatusId);
if (!$this->_caseId && $this->_activityId) {
$this->_caseId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseActivity', $this->_activityId, 'case_id', 'activity_id');
}
if ($this->_caseId) {
$this->assign('caseId', $this->_caseId);
$this->assign('countId', count($this->_caseId));
$this->assign('caseID', CRM_Utils_Array::first($this->_caseId));
}
if (!$this->_caseId || !$this->_activityId && !$this->_activityTypeId) {
CRM_Core_Error::fatal('required params missing.');
}
//check for case activity access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
//validate case id.
if ($this->_caseId && !CRM_Core_Permission::check('access all cases and activities')) {
$session = CRM_Core_Session::singleton();
$allCases = CRM_Case_BAO_Case::getCases(TRUE, $session->get('userID'), 'any');
if (!array_key_exists($this->_caseId, $allCases)) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
}
//validate case activity id.
if ($this->_activityId && $this->_action & CRM_Core_Action::UPDATE) {
$valid = CRM_Case_BAO_Case::checkPermission($this->_activityId, 'edit', $this->_activityTypeId);
if (!$valid) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
}
foreach ($this->_caseId as $casePos => $caseId) {
$this->_caseType[$casePos] = CRM_Case_BAO_Case::getCaseType($caseId, 'name');
}
$this->assign('caseType', $this->_caseType);
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
$this->assign('multiClient', $isMultiClient);
foreach ($this->_caseId as $casePos => $caseId) {
$clients[] = CRM_Case_BAO_Case::getContactNames($caseId);
}
$this->assign('client_names', $clients);
$caseIds = implode(',', $this->_caseId);
// set context for pushUserContext and for statusBounce
if ($this->_context == 'fulltext') {
if ($this->_action == CRM_Core_Action::UPDATE || $this->_action == CRM_Core_Action::DELETE) {
$url = CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseIds}&show=1&context={$this->_context}");
} else {
$url = CRM_Utils_System::url('civicrm/contact/search/custom', 'force=1');
}
} else {
$url = CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseIds}&show=1");
}
if (!$this->_activityId) {
$caseTypes = CRM_Case_PseudoConstant::caseType();
if (empty($caseTypes) && $this->_activityTypeName == 'Change Case Type' && !$this->_caseId) {
$url = CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseIds}&show=1");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
CRM_Core_Error::statusBounce(ts("You do not have any active Case Types"));
}
// check if activity count is within the limit
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
foreach ($this->_caseId as $casePos => $caseId) {
$caseType = $this->_caseType[$casePos];
$activityInst = $xmlProcessor->getMaxInstance($caseType);
// If not bounce back and also provide activity edit link
if (isset($activityInst[$this->_activityTypeName])) {
$activityCount = CRM_Case_BAO_Case::getCaseActivityCount($caseId, $this->_activityTypeId);
if ($activityCount >= $activityInst[$this->_activityTypeName]) {
if ($activityInst[$this->_activityTypeName] == 1) {
$atArray = array('activity_type_id' => $this->_activityTypeId);
$activities = CRM_Case_BAO_Case::getCaseActivity($caseId, $atArray, $this->_currentUserId);
$activities = array_keys($activities);
$activities = $activities[0];
$editUrl = CRM_Utils_System::url('civicrm/case/activity', "reset=1&cid={$this->_currentlyViewedContactId}&caseid={$caseId}&action=update&id={$activities}");
}
CRM_Core_Error::statusBounce(ts("You can not add another '%1' activity to this case. %2", array(1 => $this->_activityTypeName, 2 => ts("Do you want to <a %1>edit the existing activity</a>?", array(1 => "href='{$editUrl}'")))), $url);
}
}
}
}
$session = CRM_Core_Session::singleton();
//.........这里部分代码省略.........
示例5: endPostProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
static function endPostProcess(&$form, &$params)
{
if ($form->_context == 'caseActivity') {
return;
}
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
if (!$isMultiClient && !$form->_currentlyViewedContactId) {
CRM_Core_Error::fatal('Required parameter missing for OpenCase - end post processing');
}
if (!$form->_currentUserId || !$params['case_id'] || !$params['case_type']) {
CRM_Core_Error::fatal('Required parameter missing for OpenCase - end post processing');
}
// 1. create case-contact
if ($isMultiClient && $form->_context != 'case') {
$client = explode(',', $params['contact'][1]);
foreach ($client as $key => $cliId) {
if (empty($cliId)) {
CRM_Core_Error::fatal('contact_id cannot be empty');
}
$contactParams = array('case_id' => $params['case_id'], 'contact_id' => $cliId);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
}
} else {
$contactParams = array('case_id' => $params['case_id'], 'contact_id' => $form->_currentlyViewedContactId);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
$client = $form->_currentlyViewedContactId;
}
// 2. initiate xml processor
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $client, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 1, 'activityTypeName' => 'Open Case', 'caseID' => $params['case_id'], 'subject' => $params['activity_subject'], 'location' => $params['location'], 'activity_date_time' => $params['start_date'], 'duration' => CRM_Utils_Array::value('duration', $params), 'medium_id' => $params['medium_id'], 'details' => $params['activity_details']);
if (array_key_exists('custom', $params) && is_array($params['custom'])) {
$xmlProcessorParams['custom'] = $params['custom'];
}
// Add parameters for attachments
$numAttachments = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments');
for ($i = 1; $i <= $numAttachments; $i++) {
$attachName = "attachFile_{$i}";
if (isset($params[$attachName]) && !empty($params[$attachName])) {
$xmlProcessorParams[$attachName] = $params[$attachName];
}
}
$xmlProcessor->run($params['case_type'], $xmlProcessorParams);
// status msg
$params['statusMsg'] = ts('Case opened successfully.');
$buttonName = $form->controller->getButtonName();
$session = CRM_Core_Session::singleton();
if ($buttonName == $form->getButtonName('upload', 'new')) {
if ($form->_context == 'standalone') {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/case/add', 'reset=1&action=add&context=standalone'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=add&context=case&cid={$form->_contactID}"));
}
}
}
示例6: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$this->_showRelatedCases = CRM_Utils_Array::value('relatedCases', $_GET);
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
$this->assign('multiClient', $isMultiClient);
//pull the related cases.
$this->assign('showRelatedCases', FALSE);
if ($this->_showRelatedCases) {
$relatedCases = $this->get('relatedCases');
if (!isset($relatedCases)) {
$cId = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
$caseId = CRM_Utils_Request::retrieve('id', 'Integer', CRM_Core_DAO::$_nullObject);
$relatedCases = CRM_Case_BAO_Case::getRelatedCases($caseId, $cId);
}
$this->assign('relatedCases', $relatedCases);
$this->assign('showRelatedCases', TRUE);
CRM_Utils_System::setTitle(ts('Related Cases'));
return;
}
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
$this->_hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
$this->assign('hasAccessToAllCases', $this->_hasAccessToAllCases);
$this->_contactID = $this->get('cid');
$this->_caseID = $this->get('id');
$fulltext = CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject);
if ($fulltext == 'fulltext') {
$this->assign('fulltext', $fulltext);
}
$this->assign('caseID', $this->_caseID);
$this->assign('contactID', $this->_contactID);
//validate case id.
$this->_userCases = array();
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if (!$this->_hasAccessToAllCases) {
$this->_userCases = CRM_Case_BAO_Case::getCases(FALSE, $userID, 'any');
if (!array_key_exists($this->_caseID, $this->_userCases)) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
}
$this->assign('userID', $userID);
if (CRM_Case_BAO_Case::caseCount($this->_contactID) >= 2) {
$this->_mergeCases = TRUE;
}
$this->assign('mergeCases', $this->_mergeCases);
//retrieve details about case
$params = array('id' => $this->_caseID);
$returnProperties = array('case_type_id', 'subject', 'status_id', 'start_date');
CRM_Core_DAO::commonRetrieve('CRM_Case_BAO_Case', $params, $values, $returnProperties);
$statuses = CRM_Case_PseudoConstant::caseStatus('label', FALSE);
$caseTypeName = CRM_Case_BAO_Case::getCaseType($this->_caseID, 'name');
$caseType = CRM_Case_BAO_Case::getCaseType($this->_caseID);
$this->_caseDetails = array('case_type' => $caseType, 'case_status' => CRM_Utils_Array::value($values['case_status_id'], $statuses), 'case_subject' => CRM_Utils_Array::value('subject', $values), 'case_start_date' => $values['case_start_date']);
$this->_caseType = $caseTypeName;
$this->assign('caseDetails', $this->_caseDetails);
$reportUrl = CRM_Utils_System::url('civicrm/case/report', "reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&asn=", FALSE, NULL, FALSE);
$this->assign('reportUrl', $reportUrl);
// add to recently viewed
$url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home");
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID);
$this->assign('displayName', $displayName);
CRM_Utils_System::setTitle($displayName . ' - ' . $caseType);
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/case', "action=delete&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home");
}
// Add the recently viewed case
CRM_Utils_Recent::add($displayName . ' - ' . $caseType, $url, $this->_caseID, 'Case', $this->_contactID, NULL, $recentOther);
//get the related cases for given case.
$relatedCases = $this->get('relatedCases');
if (!isset($relatedCases)) {
$relatedCases = CRM_Case_BAO_Case::getRelatedCases($this->_caseID, $this->_contactID);
$relatedCases = empty($relatedCases) ? FALSE : $relatedCases;
$this->set('relatedCases', $relatedCases);
}
$this->assign('hasRelatedCases', (bool) $relatedCases);
if ($relatedCases) {
$this->assign('relatedCaseLabel', ts('%1 Related Case', array('count' => count($relatedCases), 'plural' => '%1 Related Cases')));
$this->assign('relatedCaseUrl', CRM_Utils_System::url('civicrm/contact/view/case', array('id' => $this->_caseID, 'cid' => $this->_contactID, 'relatedCases' => 1, 'action' => 'view')));
}
$entitySubType = !empty($values['case_type_id']) ? $values['case_type_id'] : NULL;
$this->assign('caseTypeID', $entitySubType);
$groupTree =& CRM_Core_BAO_CustomGroup::getTree('Case', $this, $this->_caseID, NULL, $entitySubType);
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
}
示例7: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
$tx = new CRM_Core_Transaction();
if ($this->_action & CRM_Core_Action::DELETE) {
$statusMsg = NULL;
//block deleting activities which affects
//case attributes.CRM-4543
$activityCondition = " AND v.name IN ('Open Case', 'Change Case Type', 'Change Case Status', 'Change Case Start Date')";
$caseAttributeActivities = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, $activityCondition);
if (!array_key_exists($this->_activityTypeId, $caseAttributeActivities)) {
$params = array('id' => $this->_activityId);
$activityDelete = CRM_Activity_BAO_Activity::deleteActivity($params, TRUE);
if ($activityDelete) {
$statusMsg = ts('The selected activity has been moved to the Trash. You can view and / or restore deleted activities by checking "Deleted Activities" from the Case Activities search filter (under Manage Case).<br />');
}
} else {
$statusMsg = ts("Selected Activity cannot be deleted.");
}
$tagParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId);
CRM_Core_BAO_EntityTag::del($tagParams);
CRM_Core_Session::setStatus($statusMsg);
return;
}
if ($this->_action & CRM_Core_Action::RENEW) {
$statusMsg = NULL;
$params = array('id' => $this->_activityId);
$activityRestore = CRM_Activity_BAO_Activity::restoreActivity($params);
if ($activityRestore) {
$statusMsg = ts('The selected activity has been restored.<br />');
}
CRM_Core_Session::setStatus($statusMsg);
return;
}
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
if ($params['source_contact_id']) {
$params['source_contact_id'] = $params['source_contact_qid'];
}
//set parent id if its edit mode
if ($parentId = CRM_Utils_Array::value('parent_id', $this->_defaults)) {
$params['parent_id'] = $parentId;
}
// required for status msg
$recordStatus = 'created';
// store the dates with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
$params['activity_type_id'] = $this->_activityTypeId;
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
$this->assign('multiClient', $isMultiClient);
$targetContacts = array($this->_currentlyViewedContactId);
if (CRM_Utils_Array::value('hidden_target_contact', $params) && CRM_Utils_Array::value('target_contact_id', $params)) {
$targetContacts = array_unique(explode(',', $params['target_contact_id']));
}
$params['target_contact_id'] = $targetContacts;
// format activity custom data
if (CRM_Utils_Array::value('hidden_custom', $params)) {
if ($this->_activityId) {
// unset custom fields-id from params since we want custom
// fields to be saved for new activity.
foreach ($params as $key => $value) {
$match = array();
if (preg_match('/^(custom_\\d+_)(\\d+)$/', $key, $match)) {
$params[$match[1] . '-1'] = $params[$key];
// for autocomplete transfer hidden value instead of label
if ($params[$key] && isset($params[$key . '_id'])) {
$params[$match[1] . '-1_id'] = $params[$key . '_id'];
unset($params[$key . '_id']);
}
unset($params[$key]);
}
}
}
// build custom data getFields array
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
}
if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
$assineeContacts = explode(',', $params['assignee_contact_id']);
$assineeContacts = array_unique($assineeContacts);
unset($params['assignee_contact_id']);
} else {
$params['assignee_contact_id'] = $assineeContacts = array();
}
if (isset($this->_activityId)) {
// activity which hasn't been modified by a user yet
if ($this->_defaults['is_auto'] == 1) {
$params['is_auto'] = 0;
}
// always create a revision of an case activity. CRM-4533
$newActParams = $params;
// add target contact values in update mode
//.........这里部分代码省略.........
示例8: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
$this->_showRelatedCases = CRM_Utils_Array::value('relatedCases', $_GET);
require_once 'CRM/Case/XMLProcessor/Process.php';
$xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
$isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients();
$this->assign('multiClient', $isMultiClient);
//pull the related cases.
$this->assign('showRelatedCases', false);
if ($this->_showRelatedCases) {
$relatedCases = $this->get('relatedCases');
if (!isset($relatedCases)) {
$cId = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
$caseId = CRM_Utils_Request::retrieve('id', 'Integer', CRM_Core_DAO::$_nullObject);
$relatedCases = CRM_Case_BAO_Case::getRelatedCases($caseId, $cId);
}
$this->assign('relatedCases', $relatedCases);
$this->assign('showRelatedCases', true);
return;
}
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
$this->_hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
$this->assign('hasAccessToAllCases', $this->_hasAccessToAllCases);
$this->_contactID = $this->get('cid');
$this->_caseID = $this->get('id');
$fulltext = CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject);
if ($fulltext == 'fulltext') {
$this->assign('fulltext', $fulltext);
}
$this->assign('caseID', $this->_caseID);
$this->assign('contactID', $this->_contactID);
//validate case id.
$this->_userCases = array();
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if (!$this->_hasAccessToAllCases) {
$this->_userCases = CRM_Case_BAO_Case::getCases(false, $userID);
if (!array_key_exists($this->_caseID, $this->_userCases)) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
}
$this->assign('userID', $userID);
if (CRM_Case_BAO_Case::caseCount($this->_contactID) >= 2) {
$this->_mergeCases = true;
}
$this->assign('mergeCases', $this->_mergeCases);
//retrieve details about case
$params = array('id' => $this->_caseID);
$returnProperties = array('case_type_id', 'subject', 'status_id', 'start_date');
CRM_Core_DAO::commonRetrieve('CRM_Case_BAO_Case', $params, $values, $returnProperties);
$values['case_type_id'] = explode(CRM_Case_BAO_Case::VALUE_SEPERATOR, CRM_Utils_Array::value('case_type_id', $values));
require_once 'CRM/Case/PseudoConstant.php';
$statuses = CRM_Case_PseudoConstant::caseStatus('label', false);
$caseTypeName = CRM_Case_BAO_Case::getCaseType($this->_caseID, 'name');
$caseType = CRM_Case_BAO_Case::getCaseType($this->_caseID);
$this->_caseDetails = array('case_type' => $caseType, 'case_status' => $statuses[$values['case_status_id']], 'case_subject' => CRM_Utils_Array::value('subject', $values), 'case_start_date' => $values['case_start_date']);
$this->_caseType = $caseTypeName;
$this->assign('caseDetails', $this->_caseDetails);
$newActivityUrl = CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype=", false, null, false);
$this->assign('newActivityUrl', $newActivityUrl);
// Send Email activity requires a different URL format from all other activities
$newActivityEmailUrl = CRM_Utils_System::url('civicrm/activity/add', "action=add&context=standalone&reset=1&caseid={$this->_caseID}&atype=", false, null, false);
$this->assign('newActivityEmailUrl', $newActivityEmailUrl);
$reportUrl = CRM_Utils_System::url('civicrm/case/report', "reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&asn=", false, null, false);
$this->assign('reportUrl', $reportUrl);
// add to recently viewed
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
$url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home");
$displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID);
$this->assign('displayName', $displayName);
$title = $displayName . ' - ' . $caseType;
$recentOther = array();
if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/case', "action=delete&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home");
}
// add the recently created case
CRM_Utils_Recent::add($displayName . ' - ' . $caseType, $url, $this->_caseID, 'Case', $this->_contactID, null, $recentOther);
//get the related cases for given case.
$relatedCases = $this->get('relatedCases');
if (!isset($relatedCases)) {
$relatedCases = CRM_Case_BAO_Case::getRelatedCases($this->_caseID, $this->_contactID);
$relatedCases = empty($relatedCases) ? false : $relatedCases;
$this->set('relatedCases', $relatedCases);
}
$this->assign('hasRelatedCases', $relatedCases);
}