本文整理汇总了PHP中CRM_Case_PseudoConstant::activityType方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Case_PseudoConstant::activityType方法的具体用法?PHP CRM_Case_PseudoConstant::activityType怎么用?PHP CRM_Case_PseudoConstant::activityType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Case_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Case_PseudoConstant::activityType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
function preProcess()
{
// Make sure case types have been configured for the component
require_once 'CRM/Core/OptionGroup.php';
$caseType = CRM_Core_OptionGroup::values('case_type');
if (empty($caseType)) {
$this->assign('notConfigured', 1);
return;
}
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
if ($this->_contactId) {
$this->assign('contactId', $this->_contactId);
// check logged in url permission
require_once 'CRM/Contact/Page/View.php';
CRM_Contact_Page_View::checkUserPermission($this);
} else {
if ($this->_action & CRM_Core_Action::VIEW) {
CRM_Core_Error::fatal('Contact Id is required for view action.');
}
}
$activityTypes = CRM_Case_PseudoConstant::activityType();
$this->assign('openCaseId', $activityTypes['Open Case']['id']);
$this->assign('changeCaseTypeId', $activityTypes['Change Case Type']['id']);
$this->assign('changeCaseStatusId', $activityTypes['Change Case Status']['id']);
$this->assign('changeCaseStartDateId', $activityTypes['Change Case Start Date']['id']);
}
示例2: preProcess
function preProcess()
{
// Make sure case types have been configured for the component
require_once 'CRM/Core/OptionGroup.php';
$caseType = CRM_Core_OptionGroup::values('case_type');
if (empty($caseType)) {
$this->assign('notConfigured', 1);
return;
}
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
// contact id is not mandatory for case form. If not found, don't call
// parent's pre-process and proceed further.
if ($this->_contactId) {
parent::preProcess();
} else {
// we would need action to proceed further.
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
if ($this->_action & CRM_Core_Action::VIEW) {
CRM_Core_Error::fatal('Contact Id is required for view action.');
}
$this->assign('action', $this->_action);
}
$activityTypes = CRM_Case_PseudoConstant::activityType();
$this->assign('openCaseId', $activityTypes['Open Case']['id']);
$this->assign('changeCaseTypeId', $activityTypes['Change Case Type']['id']);
$this->assign('changeCaseStatusId', $activityTypes['Change Case Status']['id']);
$this->assign('changeCaseStartDateId', $activityTypes['Change Case Start Date']['id']);
}
示例3:
function &allActivityTypes($indexName = true, $all = false)
{
static $activityTypes = null;
if (!$activityTypes) {
require_once 'CRM/Case/PseudoConstant.php';
$activityTypes = CRM_Case_PseudoConstant::activityType($indexName, $all);
}
return $activityTypes;
}
示例4: getActivities
function getActivities($clientID, $caseID, $activityTypes, &$activities)
{
// get all activities for this case that in this activityTypes set
foreach ($activityTypes as $aType) {
$map[$aType['id']] = $aType;
}
// get all core activities
require_once "CRM/Case/PseudoConstant.php";
$coreActivityTypes = CRM_Case_PseudoConstant::activityType(false, true);
foreach ($coreActivityTypes as $aType) {
$map[$aType['id']] = $aType;
}
$activityTypeIDs = implode(',', array_keys($map));
$query = "\nSELECT a.*, c.id as caseID\nFROM civicrm_activity a,\n civicrm_case c,\n civicrm_case_activity ac\nWHERE a.is_current_revision = 1\nAND a.is_deleted =0\nAND a.activity_type_id IN ( {$activityTypeIDs} )\nAND c.id = ac.case_id\nAND a.id = ac.activity_id\nAND ac.case_id = %1\n";
$params = array(1 => array($caseID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
while ($dao->fetch()) {
$activityTypeInfo = $map[$dao->activity_type_id];
$activities[] = $this->getActivity($clientID, $dao, $activityTypeInfo);
}
}
示例5: recordActivityViaEmail
/**
* Create an activity for a case via email
*
* @param int $file email sent
*
* @return $activity object of newly creted activity via email
*
* @access public
*
*/
static function recordActivityViaEmail($file)
{
if (!file_exists($file) || !is_readable($file)) {
return CRM_Core_Error::fatal(ts('File %1 does not exist or is not readable', array(1 => $file)));
}
require_once 'CRM/Utils/Mail/Incoming.php';
$result = CRM_Utils_Mail_Incoming::parse($file);
if ($result['is_error']) {
return $result;
}
foreach ($result['to'] as $to) {
$caseId = null;
$emailPattern = '/^([A-Z0-9._%+-]+)\\+([\\d]+)@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i';
$replacement = preg_replace($emailPattern, '$2', $to['email']);
if ($replacement !== $to['email']) {
$caseId = $replacement;
//if caseId is invalid, return as error file
if (!CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseId, 'id')) {
return CRM_Core_Error::createAPIError(ts('Invalid case ID ( %1 ) in TO: field.', array(1 => $caseId)));
}
} else {
continue;
}
// TODO: May want to replace this with a call to getRelatedAndGlobalContacts() when this feature is revisited.
// (Or for efficiency call the global one outside the loop and then union with this each time.)
$contactDetails = self::getRelatedContacts($caseId, true);
if (CRM_Utils_Array::value($result['from']['id'], $contactDetails)) {
$params = array();
$params['subject'] = $result['subject'];
$params['activity_date_time'] = $result['date'];
$params['details'] = $result['body'];
$params['source_contact_id'] = $result['from']['id'];
$params['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
$details = CRM_Case_PseudoConstant::activityType();
$matches = array();
preg_match('/^\\W+([a-zA-Z0-9_ ]+)(\\W+)?\\n/i', $result['body'], $matches);
if (!empty($matches) && isset($matches[1])) {
$activityType = trim($matches[1]);
if (isset($details[$activityType])) {
$params['activity_type_id'] = $details[$activityType]['id'];
}
}
if (!isset($params['activity_type_id'])) {
$params['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name');
}
// create activity
require_once "CRM/Activity/BAO/Activity.php";
$activity = CRM_Activity_BAO_Activity::create($params);
$caseParams = array('activity_id' => $activity->id, 'case_id' => $caseId);
self::processCaseActivity($caseParams);
} else {
return CRM_Core_Error::createAPIError(ts('FROM email contact %1 doesn\'t have a relationship to the referenced case.', array(1 => $result['from']['email'])));
}
}
}
示例6: getFileForActivityTypeId
/**
* Function to get Activity specific File according activity type Id.
*
* @param int $activityTypeId activity id
*
* @return if file exists returns $activityTypeFile activity filename otherwise false.
*
* @static
*/
static function getFileForActivityTypeId($activityTypeId, $crmDir = 'Activity')
{
require_once "CRM/Case/PseudoConstant.php";
$activityTypes = CRM_Case_PseudoConstant::activityType(false, true);
if ($activityTypes[$activityTypeId]['name']) {
require_once 'CRM/Utils/String.php';
$activityTypeFile = CRM_Utils_String::munge(ucwords($activityTypes[$activityTypeId]['name']), '', 0);
} else {
return false;
}
global $civicrm_root;
$config =& CRM_Core_Config::singleton();
if (!file_exists(rtrim($civicrm_root, '/') . "/CRM/{$crmDir}/Form/Activity/{$activityTypeFile}.php")) {
if (empty($config->customPHPPathDir)) {
return false;
} else {
if (!file_exists(rtrim($config->customPHPPathDir, '/') . "/CRM/{$crmDir}/Form/Activity/{$activityTypeFile}.php")) {
return false;
}
}
}
return $activityTypeFile;
}
示例7: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
//this call is for show related cases.
if ($this->_showRelatedCases) {
return;
}
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$caseRoles = $xmlProcessor->get($this->_caseType, 'CaseRoles');
$reports = $xmlProcessor->get($this->_caseType, 'ActivitySets');
//adding case manager.CRM-4510.
$managerRoleId = $xmlProcessor->getCaseManagerRoleId($this->_caseType);
if (!empty($managerRoleId)) {
$caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
}
$aTypes = $xmlProcessor->get($this->_caseType, 'ActivityTypes', true);
require_once 'CRM/Core/PseudoConstant.php';
$allActTypes = CRM_Core_PseudoConstant::activityType(true, true, false, 'name');
// remove Open Case activity type since we're inside an existing case
if (($openActTypeId = array_search('Open Case', $allActTypes)) && array_key_exists($openActTypeId, $aTypes)) {
unset($aTypes[$openActTypeId]);
}
//check for link cases.
$unclosedCases = CRM_Case_BAO_Case::getUnclosedCases(null, array($this->_caseID));
if (empty($unclosedCases) && ($linkActTypeId = array_search('Link Cases', $allActTypes)) && array_key_exists($linkActTypeId, $aTypes)) {
unset($aTypes[$linkActTypeId]);
}
asort($aTypes);
$this->add('select', 'activity_type_id', ts('New Activity'), array('' => ts('- select activity type -')) + $aTypes);
if ($this->_hasAccessToAllCases) {
$this->add('select', 'report_id', ts('Run QA Audit / Redact'), array('' => ts('- select activity set -')) + $reports);
$this->add('select', 'timeline_id', ts('Add Timeline'), array('' => ts('- select activity set -')) + $reports);
}
$this->addElement('submit', $this->getButtonName('next'), ts('Go'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );"));
if ($this->_mergeCases) {
$allCases = CRM_Case_BAO_Case::getContactCases($this->_contactID);
$otherCases = array();
foreach ($allCases as $caseId => $details) {
//filter current and own cases.
if ($caseId == $this->_caseID || !$this->_hasAccessToAllCases && !array_key_exists($caseId, $this->_userCases)) {
continue;
}
$otherCases[$caseId] = 'Case ID: ' . $caseId . ' Type: ' . $details['case_type'] . ' Start: ' . $details['case_start_date'];
}
if (empty($otherCases)) {
$this->_mergeCases = false;
$this->assign('mergeCases', $this->_mergeCases);
} else {
$this->add('select', 'merge_case_id', ts('Select Case for Merge'), array('' => ts('- select case -')) + $otherCases);
$this->addElement('submit', $this->getButtonName('next', 'merge_case'), ts('Merge'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );"));
}
}
$this->add('text', 'change_client_id', ts('Assign to another Client'));
$this->add('hidden', 'contact_id', '', array('id' => 'contact_id'));
$this->addElement('submit', $this->getButtonName('next', 'edit_client'), ts('Reassign Case'), array('class' => 'form-submit-inline', 'onclick' => "return checkSelection( this );"));
$activityStatus = CRM_Core_PseudoConstant::activityStatus();
$this->add('select', 'status_id', ts('Status'), array("" => ts(' - any status - ')) + $activityStatus);
// activity dates
$this->addDate('activity_date_low', ts('Activity Dates - From'), false, array('formatType' => 'searchDate'));
$this->addDate('activity_date_high', ts('To'), false, array('formatType' => 'searchDate'));
require_once "CRM/Core/Permission.php";
if (CRM_Core_Permission::check('administer CiviCRM')) {
$this->add('checkbox', 'activity_deleted', ts('Deleted Activities'));
}
//get case related relationships (Case Role)
$caseRelationships = CRM_Case_BAO_Case::getCaseRoles($this->_contactID, $this->_caseID);
//build reporter select
$reporters = array("" => ts(' - any reporter - '));
foreach ($caseRelationships as $key => &$value) {
$reporters[$value['cid']] = $value['name'] . " ( {$value['relation']} )";
if ($managerRoleId == $value['relation_type']) {
$value['relation'] = $caseRoles[$managerRoleId];
}
//calculate roles that don't have relationships
if (CRM_Utils_Array::value($value['relation_type'], $caseRoles)) {
unset($caseRoles[$value['relation_type']]);
}
}
// take all case activity types for search filter, CRM-7187
$aTypesFilter = array();
$allCaseActTypes = CRM_Case_PseudoConstant::activityType();
foreach ($allCaseActTypes as $typeDetails) {
if (!in_array($typeDetails['name'], array('Open Case'))) {
$aTypesFilter[$typeDetails['id']] = CRM_Utils_Array::value('label', $typeDetails);
}
}
asort($aTypesFilter);
$this->add('select', 'activity_type_filter_id', ts('Activity Type'), array('' => ts('- select activity type -')) + $aTypesFilter);
$this->assign('caseRelationships', $caseRelationships);
//also add client as role. CRM-4438
$caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($this->_caseID);
$this->assign('caseRoles', $caseRoles);
$this->add('select', 'reporter_id', ts('Reporter/Role'), $reporters);
// Retrieve ALL client relationships
$relClient = CRM_Contact_BAO_Relationship::getRelationship($this->_contactID, CRM_Contact_BAO_Relationship::CURRENT, 0, 0, 0, null, null, false);
//.........这里部分代码省略.........
示例8: preProcess
/**
* Function to build the form
*
* @return None
* @access public
*/
function preProcess()
{
$this->_caseId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if ($this->_action & CRM_Core_Action::ADD && !$this->_currentlyViewedContactId) {
// check for add contacts permissions
require_once 'CRM/Core/Permission.php';
if (!CRM_Core_Permission::check('add contacts')) {
CRM_Utils_System::permissionDenied();
return;
}
}
//CRM-4418
if (!CRM_Core_Permission::checkActionPermission('CiviCase', $this->_action)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
}
if ($this->_action & CRM_Core_Action::DELETE || $this->_action & CRM_Core_Action::RENEW) {
return true;
}
if ($this->_action & CRM_Core_Action::ADD) {
require_once 'CRM/Core/OptionGroup.php';
$this->_activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
}
if ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, 'Case')) {
require_once "CRM/Case/Form/Activity/{$this->_activityTypeFile}.php";
$this->assign('activityTypeFile', $this->_activityTypeFile);
}
$details = CRM_Case_PseudoConstant::activityType(false);
CRM_Utils_System::setTitle($details[$this->_activityTypeId]['label']);
$this->assign('activityType', $details[$this->_activityTypeId]['label']);
if (isset($this->_currentlyViewedContactId)) {
require_once 'CRM/Contact/BAO/Contact.php';
$contact =& new CRM_Contact_DAO_Contact();
$contact->id = $this->_currentlyViewedContactId;
if (!$contact->find(true)) {
CRM_Core_Error::statusBounce(ts('Client contact does not exist: %1', array(1 => $this->_currentlyViewedContactId)));
}
$this->assign('clientName', $contact->display_name);
}
$session =& CRM_Core_Session::singleton();
$this->_currentUserId = $session->get('userID');
//when custom data is included in this page
CRM_Custom_Form_Customdata::preProcess($this, null, $this->_activityTypeId, 1, 'Activity');
eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}::preProcess( \$this );");
}
示例9: preProcess
function preProcess()
{
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
//validate case configuration.
require_once 'CRM/Case/BAO/Case.php';
$configured = CRM_Case_BAO_Case::isCaseConfigured($this->_contactId);
$this->assign('notConfigured', !$configured['configured']);
$this->assign('allowToAddNewCase', $configured['allowToAddNewCase']);
$this->assign('redirectToCaseAdmin', $configured['redirectToCaseAdmin']);
if (!$configured['configured'] || $configured['redirectToCaseAdmin']) {
return;
}
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
if ($this->_contactId) {
$this->assign('contactId', $this->_contactId);
// check logged in user permission
require_once 'CRM/Contact/Page/View.php';
if ($this->_id && $this->_action & CRM_Core_Action::VIEW) {
//user might have special permissions to view this case, CRM-5666
if (!CRM_Core_Permission::check('access all cases and activities')) {
$session = CRM_Core_Session::singleton();
$userCases = CRM_Case_BAO_Case::getCases(false, $session->get('userID'));
if (!array_key_exists($this->_id, $userCases)) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
}
} else {
CRM_Contact_Page_View::checkUserPermission($this);
}
// set page title
CRM_Contact_Page_View::setTitle($this->_contactId);
} else {
if ($this->_action & CRM_Core_Action::VIEW) {
CRM_Core_Error::fatal('Contact Id is required for view action.');
}
}
$activityTypes = CRM_Case_PseudoConstant::activityType();
$this->assign('openCaseId', $activityTypes['Open Case']['id']);
$this->assign('changeCaseTypeId', $activityTypes['Change Case Type']['id']);
$this->assign('changeCaseStatusId', $activityTypes['Change Case Status']['id']);
$this->assign('changeCaseStartDateId', $activityTypes['Change Case Start Date']['id']);
}