当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Case_BAO_Case::caseCount方法代码示例

本文整理汇总了PHP中CRM_Case_BAO_Case::caseCount方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Case_BAO_Case::caseCount方法的具体用法?PHP CRM_Case_BAO_Case::caseCount怎么用?PHP CRM_Case_BAO_Case::caseCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Case_BAO_Case的用法示例。


在下文中一共展示了CRM_Case_BAO_Case::caseCount方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildQuickForm

 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'name'), true);
     $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_OptionGroup', $this->_id));
     $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description'));
     $element = $this->add('checkbox', 'is_active', ts('Enabled?'));
     if ($this->_action & CRM_Core_Action::UPDATE) {
         if (in_array($this->_values['name'], array('encounter_medium', 'case_type', 'case_status'))) {
             static $caseCount = null;
             require_once 'CRM/Case/BAO/Case.php';
             if (!isset($caseCount)) {
                 $caseCount = CRM_Case_BAO_Case::caseCount(null, false);
             }
             if ($caseCount > 0) {
                 $element->freeze();
             }
         }
         if ($this->_values['is_reserved']) {
             $this->freeze(array('name', 'description', 'is_active'));
         }
     }
     $this->assign('id', $this->_id);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:34,代码来源:OptionGroup.php

示例2: buildQuickForm

 /**
  * Function to build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     CRM_Utils_System::setTitle(ts('Dropdown Options'));
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'name'), TRUE);
     $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_OptionGroup', $this->_id));
     $this->add('text', 'title', ts('Group Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'title'));
     $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description'));
     $element = $this->add('checkbox', 'is_active', ts('Enabled?'));
     if ($this->_action & CRM_Core_Action::UPDATE) {
         if (in_array($this->_values['name'], array('encounter_medium', 'case_type', 'case_status'))) {
             static $caseCount = NULL;
             if (!isset($caseCount)) {
                 $caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE);
             }
             if ($caseCount > 0) {
                 $element->freeze();
             }
         }
         if (!empty($this->_values['is_reserved'])) {
             $this->freeze(array('name', 'is_active'));
         }
     }
     $this->assign('id', $this->_id);
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:35,代码来源:OptionGroup.php

示例3: isCaseConfigured

 /**
  * Function to check case configuration.
  *
  * @param null $contactId
  *
  * @return array $configured
  */
 static function isCaseConfigured($contactId = NULL)
 {
     $configured = array_fill_keys(array('configured', 'allowToAddNewCase', 'redirectToCaseAdmin'), FALSE);
     //lets check for case configured.
     $allCasesCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE);
     $configured['configured'] = $allCasesCount ? TRUE : FALSE;
     if (!$configured['configured']) {
         //do check for case type and case status.
         $caseTypes = CRM_Case_PseudoConstant::caseType('title', FALSE);
         if (!empty($caseTypes)) {
             $configured['configured'] = TRUE;
             if (!$configured['configured']) {
                 $caseStatuses = CRM_Case_PseudoConstant::caseStatus('label', FALSE);
                 if (!empty($caseStatuses)) {
                     $configured['configured'] = TRUE;
                 }
             }
         }
     }
     if ($configured['configured']) {
         //do check for active case type and case status.
         $caseTypes = CRM_Case_PseudoConstant::caseType();
         if (!empty($caseTypes)) {
             $caseStatuses = CRM_Case_PseudoConstant::caseStatus();
             if (!empty($caseStatuses)) {
                 $configured['allowToAddNewCase'] = TRUE;
             }
         }
         //do we need to redirect user to case admin.
         if (!$configured['allowToAddNewCase'] && $contactId) {
             //check for current contact case count.
             $currentContatCasesCount = CRM_Case_BAO_Case::caseCount($contactId);
             //redirect user to case admin page.
             if (!$currentContatCasesCount) {
                 $configured['redirectToCaseAdmin'] = TRUE;
             }
         }
     }
     return $configured;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:47,代码来源:Case.php

示例4: action

 /**
  * Given an object, get the actions that can be associated with this
  * object. Check the is_active and is_required flags to display valid
  * actions
  *
  * @param CRM_Core_DAO $object
  *   The object being considered.
  * @param int $action
  *   The base set of actions.
  * @param array $values
  *   The array of values that we send to the template.
  * @param array $links
  *   The array of links.
  * @param string $permission
  *   The permission assigned to this object.
  *
  * @param bool $forceAction
  */
 public function action(&$object, $action, &$values, &$links, $permission, $forceAction = FALSE)
 {
     $values['class'] = '';
     $newAction = $action;
     $hasDelete = $hasDisable = TRUE;
     if (!empty($values['name']) && in_array($values['name'], array('encounter_medium', 'case_type', 'case_status'))) {
         static $caseCount = NULL;
         if (!isset($caseCount)) {
             $caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE);
         }
         if ($caseCount > 0) {
             $hasDelete = $hasDisable = FALSE;
         }
     }
     if (!$forceAction) {
         if (array_key_exists('is_reserved', $object) && $object->is_reserved) {
             $values['class'] = 'reserved';
             // check if object is relationship type
             $object_type = get_class($object);
             $exceptions = array('CRM_Contact_BAO_RelationshipType', 'CRM_Core_BAO_LocationType', 'CRM_Badge_BAO_Layout');
             if (in_array($object_type, $exceptions)) {
                 $newAction = CRM_Core_Action::VIEW + CRM_Core_Action::UPDATE;
             } else {
                 $newAction = 0;
                 $values['action'] = '';
                 return;
             }
         } else {
             if (array_key_exists('is_active', $object)) {
                 if ($object->is_active) {
                     if ($hasDisable) {
                         $newAction += CRM_Core_Action::DISABLE;
                     }
                 } else {
                     $newAction += CRM_Core_Action::ENABLE;
                 }
             }
         }
     }
     //CRM-4418, handling edit and delete separately.
     $permissions = array($permission);
     if ($hasDelete && $permission == CRM_Core_Permission::EDIT) {
         //previously delete was subset of edit
         //so for consistency lets grant delete also.
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     // make sure we only allow those actions that the user is permissioned for
     $newAction = $newAction & CRM_Core_Action::mask($permissions);
     $values['action'] = CRM_Core_Action::formLink($links, $newAction, array('id' => $object->id));
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:68,代码来源:Basic.php

示例5: getCountComponent

 /**
  * Given the component name and returns the count of participation of contact.
  *
  * @param string $component
  *   Input component name.
  * @param int $contactId
  *   Input contact id.
  * @param string $tableName
  *   Optional tableName if component is custom group.
  *
  * @return int
  *   total number in database
  */
 public static function getCountComponent($component, $contactId, $tableName = NULL)
 {
     $object = NULL;
     switch ($component) {
         case 'tag':
             return CRM_Core_BAO_EntityTag::getContactTags($contactId, TRUE);
         case 'rel':
             $result = CRM_Contact_BAO_Relationship::getRelationship($contactId, CRM_Contact_BAO_Relationship::CURRENT, 0, 1);
             return $result;
         case 'group':
             return CRM_Contact_BAO_GroupContact::getContactGroup($contactId, "Added", NULL, TRUE);
         case 'log':
             if (CRM_Core_BAO_Log::useLoggingReport()) {
                 return FALSE;
             }
             return CRM_Core_BAO_Log::getContactLogCount($contactId);
         case 'note':
             return CRM_Core_BAO_Note::getContactNoteCount($contactId);
         case 'contribution':
             return CRM_Contribute_BAO_Contribution::contributionCount($contactId);
         case 'membership':
             return CRM_Member_BAO_Membership::getContactMembershipCount($contactId, TRUE);
         case 'participant':
             return CRM_Event_BAO_Participant::getContactParticipantCount($contactId);
         case 'pledge':
             return CRM_Pledge_BAO_Pledge::getContactPledgeCount($contactId);
         case 'case':
             return CRM_Case_BAO_Case::caseCount($contactId);
         case 'grant':
             return CRM_Grant_BAO_Grant::getContactGrantCount($contactId);
         case 'activity':
             $input = array('contact_id' => $contactId, 'admin' => FALSE, 'caseId' => NULL, 'context' => 'activity');
             return CRM_Activity_BAO_Activity::getActivitiesCount($input);
         case 'mailing':
             $params = array('contact_id' => $contactId);
             return CRM_Mailing_BAO_Mailing::getContactMailingsCount($params);
         default:
             $custom = explode('_', $component);
             if ($custom['0'] = 'custom') {
                 if (!$tableName) {
                     $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $custom['1'], 'table_name');
                 }
                 $queryString = "SELECT count(id) FROM {$tableName} WHERE entity_id = {$contactId}";
                 return CRM_Core_DAO::singleValueQuery($queryString);
             }
     }
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:60,代码来源:Contact.php

示例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);
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:95,代码来源:CaseView.php

示例7: 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);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:96,代码来源:CaseView.php

示例8: getCountComponent

 /**
  * Given the component name and returns 
  * the count of participation of contact
  *
  * @param string $component input component name
  * @param integer $contactId input contact id
  *
  * @return total number of count of occurence in database
  * @access public
  * @static
  */
 static function getCountComponent($component, $contactId)
 {
     $object = null;
     switch ($component) {
         case 'tag':
             require_once 'CRM/Core/BAO/EntityTag.php';
             return count(CRM_Core_BAO_EntityTag::getTag($contactId));
         case 'rel':
             require_once 'CRM/Contact/BAO/Relationship.php';
             return count(CRM_Contact_BAO_Relationship::getRelationship($contactId));
         case 'group':
             require_once 'CRM/Contact/BAO/GroupContact.php';
             return CRM_Contact_BAO_GroupContact::getContactGroup($contactId, null, null, true);
         case 'log':
         case 'note':
             eval('$object =& new CRM_Core_DAO_' . $component . '( );');
             $object->entity_table = 'civicrm_contact';
             $object->entity_id = $contactId;
             $object->orderBy('modified_date desc');
             break;
         case 'contribution':
             require_once 'CRM/Contribute/BAO/Contribution.php';
             return CRM_Contribute_BAO_Contribution::contributionCount($contactId);
             break;
         case 'membership':
             require_once 'CRM/Member/DAO/Membership.php';
             eval('$object =& new CRM_Member_DAO_Membership( );');
             $object->contact_id = $contactId;
             $object->is_test = 0;
             break;
         case 'participant':
             require_once 'CRM/Event/DAO/Participant.php';
             eval('$object =& new CRM_Event_DAO_Participant( );');
             $object->contact_id = $contactId;
             $object->is_test = 0;
             break;
         case 'pledge':
             require_once 'CRM/Pledge/DAO/Pledge.php';
             eval('$object =& new CRM_Pledge_DAO_Pledge( );');
             $object->contact_id = $contactId;
             $object->is_test = 0;
             break;
         case 'case':
             require_once 'CRM/Case/BAO/Case.php';
             return CRM_Case_BAO_Case::caseCount($contactId);
         case 'grant':
             require_once 'CRM/Grant/DAO/Grant.php';
             eval('$object =& new CRM_Grant_DAO_Grant( );');
             $object->contact_id = $contactId;
             break;
         case 'activity':
             require_once 'CRM/Activity/BAO/Activity.php';
             return CRM_Activity_BAO_Activity::getActivitiesCount($contactId, false, null, null);
         default:
             $custom = explode('_', $component);
             if ($custom['0'] = 'custom') {
                 require_once 'CRM/Core/DAO/CustomGroup.php';
                 $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $custom['1'], 'table_name');
                 $queryString = "SELECT count(id) FROM {$tableName} WHERE entity_id = {$contactId}";
                 return CRM_Core_DAO::singleValueQuery($queryString);
             }
     }
     $object->find();
     return $object->N;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:76,代码来源:Contact.php

示例9: getCountComponent

 /**
  * Given the component name and returns 
  * the count of participation of contact
  *
  * @param string  $component input component name
  * @param integer $contactId input contact id
  * @param string  $tableName optional tableName if component is custom group
  *
  * @return total number of count of occurence in database
  * @access public
  * @static
  */
 static function getCountComponent($component, $contactId, $tableName = null)
 {
     $object = null;
     switch ($component) {
         case 'tag':
             require_once 'CRM/Core/BAO/EntityTag.php';
             return CRM_Core_BAO_EntityTag::getContactTags($contactId, true);
         case 'rel':
             require_once 'CRM/Contact/BAO/Relationship.php';
             return count(CRM_Contact_BAO_Relationship::getRelationship($contactId));
         case 'group':
             require_once 'CRM/Contact/BAO/GroupContact.php';
             return CRM_Contact_BAO_GroupContact::getContactGroup($contactId, null, null, true);
         case 'log':
             require_once 'CRM/Core/BAO/Log.php';
             return CRM_Core_BAO_Log::getContactLogCount($contactId);
         case 'note':
             require_once 'CRM/Core/BAO/Note.php';
             return CRM_Core_BAO_Note::getContactNoteCount($contactId);
         case 'contribution':
             require_once 'CRM/Contribute/BAO/Contribution.php';
             return CRM_Contribute_BAO_Contribution::contributionCount($contactId);
         case 'membership':
             require_once 'CRM/Member/BAO/Membership.php';
             return CRM_Member_BAO_Membership::getContactMembershipCount($contactId);
         case 'participant':
             require_once 'CRM/Event/BAO/Participant.php';
             return CRM_Event_BAO_Participant::getContactParticipantCount($contactId);
         case 'pledge':
             require_once 'CRM/Pledge/BAO/Pledge.php';
             return CRM_Pledge_BAO_Pledge::getContactPledgeCount($contactId);
         case 'case':
             require_once 'CRM/Case/BAO/Case.php';
             return CRM_Case_BAO_Case::caseCount($contactId);
         case 'grant':
             require_once 'CRM/Grant/BAO/Grant.php';
             return CRM_Grant_BAO_Grant::getContactGrantCount($contactId);
         case 'activity':
             require_once 'CRM/Activity/BAO/Activity.php';
             return CRM_Activity_BAO_Activity::getActivitiesCount($contactId, false, null, null);
         default:
             $custom = explode('_', $component);
             if ($custom['0'] = 'custom') {
                 require_once 'CRM/Core/DAO/CustomGroup.php';
                 if (!$tableName) {
                     $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $custom['1'], 'table_name');
                 }
                 $queryString = "SELECT count(id) FROM {$tableName} WHERE entity_id = {$contactId}";
                 return CRM_Core_DAO::singleValueQuery($queryString);
             }
     }
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:64,代码来源:Contact.php

示例10: isCaseConfigured

 /**
  * Function to check case configuration.
  *
  * @return an array $configured  
  */
 function isCaseConfigured($contactId = null)
 {
     $configured = array_fill_keys(array('configured', 'allowToAddNewCase', 'redirectToCaseAdmin'), false);
     //lets check for case configured.
     require_once 'CRM/Case/BAO/Case.php';
     $allCasesCount = CRM_Case_BAO_Case::caseCount(null, false);
     $configured['configured'] = $allCasesCount ? true : false;
     if (!$configured['configured']) {
         //do check for case type and case status.
         require_once 'CRM/Case/PseudoConstant.php';
         $caseTypes = CRM_Case_PseudoConstant::caseType('label', false);
         if (!empty($caseTypes)) {
             $configured['configured'] = true;
             if (!$configured['configured']) {
                 $caseStatuses = CRM_Case_PseudoConstant::caseStatus('label', false);
                 if (!empty($caseStatuses)) {
                     $configured['configured'] = true;
                 }
             }
         }
     }
     if ($configured['configured']) {
         //do check for active case type and case status.
         require_once 'CRM/Case/PseudoConstant.php';
         $caseTypes = CRM_Case_PseudoConstant::caseType();
         if (!empty($caseTypes)) {
             $caseStatuses = CRM_Case_PseudoConstant::caseStatus();
             if (!empty($caseStatuses)) {
                 $configured['allowToAddNewCase'] = true;
             }
         }
         //do we need to redirect user to case admin.
         if (!$configured['allowToAddNewCase'] && $contactId) {
             //check for current contact case count.
             $currentContatCasesCount = CRM_Case_BAO_Case::caseCount($contactId);
             //redirect user to case admin page.
             if (!$currentContatCasesCount) {
                 $configured['redirectToCaseAdmin'] = true;
             }
         }
     }
     return $configured;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:48,代码来源:Case.php


注:本文中的CRM_Case_BAO_Case::caseCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。