本文整理汇总了PHP中CRM_Case_XMLProcessor_Process::getMaxInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Case_XMLProcessor_Process::getMaxInstance方法的具体用法?PHP CRM_Case_XMLProcessor_Process::getMaxInstance怎么用?PHP CRM_Case_XMLProcessor_Process::getMaxInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Case_XMLProcessor_Process
的用法示例。
在下文中一共展示了CRM_Case_XMLProcessor_Process::getMaxInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
//.........这里部分代码省略.........
示例2: preProcess
/**
* Function to build the form
*
* @return None
* @access public
*/
function preProcess()
{
$this->_caseId = CRM_Utils_Request::retrieve('caseid', 'Positive', $this);
$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->_cdType || $this->_addAssigneeContact || $this->_addTargetContact) {
return $result;
}
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);
}
if (!$this->_caseId || !$this->_activityId && !$this->_activityTypeId) {
CRM_Core_Error::fatal('required params missing.');
}
$caseType = CRM_Case_PseudoConstant::caseTypeName($this->_caseId);
$this->_caseType = $caseType['name'];
$this->assign('caseType', $this->_caseType);
$clientName = $this->_getDisplayNameById($this->_currentlyViewedContactId);
$this->assign('client_name', $clientName);
// set context for pushUserContext and for statusBounce
$url = CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$this->_caseId}&show=1");
if (!$this->_activityId) {
// check if activity count is within the limit
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$activityInst = $xmlProcessor->getMaxInstance($this->_caseType);
// If not bounce back and also provide activity edit link
if (isset($activityInst[$this->_activityTypeName])) {
$activityCount = CRM_Case_BAO_Case::getCaseActivityCount($this->_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($this->_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={$this->_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 => "Do you want to <a href='{$editUrl}'>edit the existing activity</a> ?")), $url);
}
}
}
CRM_Utils_System::setTitle($this->_activityTypeName);
$session =& CRM_Core_Session::singleton();
$session->pushUserContext($url);
}