當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Case_XMLProcessor_Process::getMaxInstance方法代碼示例

本文整理匯總了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();
//.........這裏部分代碼省略.........
開發者ID:rajeshrhino,項目名稱:civicrm-core,代碼行數:101,代碼來源:Activity.php

示例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);
 }
開發者ID:ksecor,項目名稱:civicrm,代碼行數:57,代碼來源:Activity.php


注:本文中的CRM_Case_XMLProcessor_Process::getMaxInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。