本文整理汇总了PHP中CRM_Case_BAO_Case::accessCiviCase方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Case_BAO_Case::accessCiviCase方法的具体用法?PHP CRM_Case_BAO_Case::accessCiviCase怎么用?PHP CRM_Case_BAO_Case::accessCiviCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Case_BAO_Case
的用法示例。
在下文中一共展示了CRM_Case_BAO_Case::accessCiviCase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Case dashboard as dashlet
*
* @return void
*
* @access public
*/
function run()
{
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
$session =& CRM_Core_Session::singleton();
$userID = $session->get('userID');
$summary = CRM_Case_BAO_Case::getCasesSummary(TRUE, $userID);
if (!empty($summary)) {
$this->assign('casesSummary', $summary);
}
return parent::run();
}
示例2: run
/**
* List activities as dashlet
*
* @return none
*
* @access public
*/
function run()
{
require_once 'CRM/Case/BAO/Case.php';
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
require_once 'CRM/Core/OptionGroup.php';
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$upcoming = CRM_Case_BAO_Case::getCases(true, $userID, 'upcoming');
if (!empty($upcoming)) {
$this->assign('AllCases', $upcoming);
}
return parent::run();
}
示例3: run
/**
* List activities as dashlet
*
* @return void
*
* @access public
*/
function run()
{
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'dashlet');
$this->assign('context', $context);
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$upcoming = CRM_Case_BAO_Case::getCases(FALSE, $userID, 'upcoming', $context);
if (!empty($upcoming)) {
$this->assign('upcomingCases', $upcoming);
}
return parent::run();
}
示例4: preProcess
/**
* Heart of the viewing process.
*
* The runner gets all the meta data for the contact and calls the appropriate type of page to view.
*/
public function preProcess()
{
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
//validate case configuration.
$configured = CRM_Case_BAO_Case::isCaseConfigured();
$this->assign('notConfigured', !$configured['configured']);
$this->assign('allowToAddNewCase', $configured['allowToAddNewCase']);
if (!$configured['configured']) {
return;
}
$session = CRM_Core_Session::singleton();
$allCases = CRM_Utils_Request::retrieve('all', 'Positive', $session);
CRM_Utils_System::setTitle(ts('CiviCase Dashboard'));
$userID = $session->get('userID');
//validate access for all cases.
if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) {
$allCases = FALSE;
CRM_Core_Session::setStatus(ts('You are not authorized to access all cases and activities.'), ts('Sorry'), 'error');
}
if (!$allCases) {
$this->assign('myCases', TRUE);
} else {
$this->assign('myCases', FALSE);
}
$this->assign('newClient', FALSE);
if (CRM_Core_Permission::check('add contacts') && CRM_Core_Permission::check('access all cases and activities')) {
$this->assign('newClient', TRUE);
}
$summary = CRM_Case_BAO_Case::getCasesSummary($allCases, $userID);
$upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming');
$recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent');
foreach ($upcoming as $key => $value) {
if (strtotime($value['case_scheduled_activity_date']) < time()) {
$upcoming[$key]['activity_status'] = 'status-overdue';
}
}
$this->assign('casesSummary', $summary);
if (!empty($upcoming)) {
$this->assign('upcomingCases', $upcoming);
}
if (!empty($recent)) {
$this->assign('recentCases', $recent);
}
}
示例5: preProcess
/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*
* @return void
* @access public
*
*/
function preProcess()
{
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
//validate case configuration.
require_once 'CRM/Case/BAO/Case.php';
$configured = CRM_Case_BAO_Case::isCaseConfigured();
$this->assign('notConfigured', !$configured['configured']);
$this->assign('allowToAddNewCase', $configured['allowToAddNewCase']);
if (!$configured['configured']) {
return;
}
$session =& CRM_Core_Session::singleton();
$allCases = CRM_Utils_Request::retrieve('all', 'Positive', $session);
CRM_Utils_System::setTitle(ts('CiviCase Dashboard'));
$userID = $session->get('userID');
//validate access for all cases.
if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) {
$allCases = false;
CRM_Core_Session::setStatus(ts('You are not authorized to access all cases and activities.'));
}
if (!$allCases) {
$this->assign('myCases', true);
} else {
$this->assign('myCases', false);
}
$this->assign('newClient', false);
if (CRM_Core_Permission::check('add contacts') && CRM_Core_Permission::check('access all cases and activities')) {
$this->assign('newClient', true);
}
require_once 'CRM/Case/BAO/Case.php';
$summary = CRM_Case_BAO_Case::getCasesSummary($allCases, $userID);
$upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming');
$recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent');
$this->assign('casesSummary', $summary);
if (!empty($upcoming)) {
$this->assign('upcomingCases', $upcoming);
}
if (!empty($recent)) {
$this->assign('recentCases', $recent);
}
}
示例6: preProcess
/**
* Heart of the viewing process. The runner gets all the meta data for
* the contact and calls the appropriate type of page to view.
*
* @return void
* @access public
*
*/
function preProcess()
{
// js for changing activity status
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Case/Form/ActivityChangeStatus.js');
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
//validate case configuration.
$configured = CRM_Case_BAO_Case::isCaseConfigured();
$this->assign('notConfigured', !$configured['configured']);
$this->assign('allowToAddNewCase', $configured['allowToAddNewCase']);
if (!$configured['configured']) {
return;
}
$session = CRM_Core_Session::singleton();
$allCases = CRM_Utils_Request::retrieve('all', 'Positive', $session);
CRM_Utils_System::setTitle(ts('CiviCase Dashboard'));
$userID = $session->get('userID');
//validate access for all cases.
if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) {
$allCases = FALSE;
CRM_Core_Session::setStatus(ts('You are not authorized to access all cases and activities.'), ts('Sorry'), 'error');
}
if (!$allCases) {
$this->assign('myCases', TRUE);
} else {
$this->assign('myCases', FALSE);
}
$this->assign('newClient', FALSE);
if (CRM_Core_Permission::check('add contacts') && CRM_Core_Permission::check('access all cases and activities')) {
$this->assign('newClient', TRUE);
}
$summary = CRM_Case_BAO_Case::getCasesSummary($allCases, $userID);
$upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming');
$recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent');
$this->assign('casesSummary', $summary);
if (!empty($upcoming)) {
$this->assign('upcomingCases', $upcoming);
}
if (!empty($recent)) {
$this->assign('recentCases', $recent);
}
}
示例7: run
/**
* This function is the main function that is called when the page loads,
* it decides the which action has to be taken for the page.
*
* return null
* @access public
*/
function run()
{
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject);
$this->assign('action', $this->_action);
$this->assign('context', $this->_context);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$caseId = CRM_Utils_Request::retrieve('caseId', 'Positive', $this);
CRM_Case_Page_Tab::setContext();
$params = array('date_range' => 0);
$caseDetails = array();
if (CRM_Case_BAO_Case::accessCiviCase()) {
$caseDetails = CRM_Case_BAO_Case::getCaseActivity($caseId, $params, $this->_contactId, NULL, NULL, $type);
}
$this->assign('rows', $caseDetails);
$this->assign('caseId', $caseId);
$this->assign('contactId', $this->_contactId);
return parent::run();
}
示例8: run
/**
* the main function that is called when the page loads,
* it decides the which action has to be taken for the page.
*
* @return null
*/
public function run()
{
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject);
$this->assign('action', $this->_action);
$this->assign('context', $this->_context);
$this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$caseId = CRM_Utils_Request::retrieve('caseId', 'Positive', $this);
CRM_Case_Page_Tab::setContext();
$params = array('date_range' => 0);
$caseDetails = array();
if (CRM_Case_BAO_Case::accessCiviCase()) {
$caseDetails = CRM_Case_BAO_Case::getCaseActivity($caseId, $params, $this->_contactId, NULL, NULL, $type);
}
$this->assign('rows', $caseDetails);
$this->assign('caseId', $caseId);
$this->assign('contactId', $this->_contactId);
// Make it easy to refresh this table
$params = array('caseId' => $caseId, 'type' => $type, 'context' => $this->_context, 'cid' => $this->_contactId, 'action' => $this->_action, 'snippet' => 4);
$this->assign('data_params', json_encode($params));
return parent::run();
}
示例9: preProcess
/**
* Function to build the form
*
* @return None
* @access public
*/
function preProcess()
{
$this->_cdType = CRM_Utils_Array::value('type', $_GET);
$this->assign('cdType', FALSE);
if ($this->_cdType) {
$this->assign('cdType', TRUE);
return CRM_Custom_Form_CustomData::preProcess($this);
}
$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
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->_caseId) {
$caseAttributes = array('case_type' => CRM_Case_PseudoConstant::caseType(), 'case_status' => CRM_Case_PseudoConstant::caseStatus(), 'encounter_medium' => CRM_Case_PseudoConstant::encounterMedium());
foreach ($caseAttributes as $key => $values) {
if (empty($values)) {
CRM_Core_Error::fatal(ts('You do not have any active %1', array(1 => str_replace('_', ' ', $key))));
break;
}
}
}
if ($this->_action & CRM_Core_Action::ADD) {
$this->_activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Open Case', 'name');
if (!$this->_activityTypeId) {
CRM_Core_Error::fatal(ts('The Open Case activity type is missing or disabled. Please have your site administrator check Administer > Option Lists > Activity Types for the CiviCase component.'));
}
}
//check for case permissions.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
if ($this->_action & CRM_Core_Action::ADD && (!CRM_Core_Permission::check('access all cases and activities') && !CRM_Core_Permission::check('add cases'))) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
if ($this->_activityTypeFile = CRM_Activity_BAO_Activity::getFileForActivityTypeId($this->_activityTypeId, 'Case')) {
$this->assign('activityTypeFile', $this->_activityTypeFile);
}
$details = CRM_Case_PseudoConstant::caseActivityType(FALSE);
CRM_Utils_System::setTitle($details[$this->_activityTypeId]['label']);
$this->assign('activityType', $details[$this->_activityTypeId]['label']);
$this->assign('activityTypeDescription', $details[$this->_activityTypeId]['description']);
if (isset($this->_currentlyViewedContactId)) {
$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 );");
$activityGroupTree = $this->_groupTree;
// for case custom fields to populate with defaults
if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
CRM_Custom_Form_CustomData::preProcess($this);
CRM_Custom_Form_CustomData::buildQuickForm($this);
}
// so that grouptree is not populated with case fields, since the grouptree is used
// for populating activity custom fields.
$this->_groupTree = $activityGroupTree;
}
示例10: 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();
//.........这里部分代码省略.........
示例11: checkActionPermission
/**
* check permissions for delete and edit actions
*
* @param string $module component name.
* @param $action action to be check across component
*
**/
static function checkActionPermission($module, $action)
{
//check delete related permissions.
if ($action & CRM_Core_Action::DELETE) {
$permissionName = "delete in {$module}";
} else {
$editPermissions = array('CiviEvent' => 'edit event participants', 'CiviMember' => 'edit memberships', 'CiviPledge' => 'edit pledges', 'CiviContribute' => 'edit contributions', 'CiviGrant' => 'edit grants', 'CiviMail' => 'access CiviMail', 'CiviAuction' => 'add auction items');
$permissionName = CRM_Utils_Array::value($module, $editPermissions);
}
if ($module == 'CiviCase' && !$permissionName) {
return CRM_Case_BAO_Case::accessCiviCase();
} else {
//check for permission.
return CRM_Core_Permission::check($permissionName);
}
}
示例12: 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);
}
示例13: hrreport_civicrm_pageRun
/**
* Implementation of hook_civicrm_pageRun
*
* @return void
*/
function hrreport_civicrm_pageRun(&$page)
{
$pageName = $page->getVar('_name');
$componentName = $page->getVar('_compName');
//change page title from 'Case Report' to 'Assignment Report'
if ($pageName == 'CRM_Report_Page_InstanceList' && $componentName == 'Case') {
CRM_Utils_System::setTitle(ts('Assignment Reports'));
}
if ($pageName == 'CRM_Report_Page_InstanceList' || $pageName == 'CRM_Report_Page_TemplateList') {
CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.hrreport', 'js/hrreport.js');
}
if ($pageName == 'CRM_Contact_Page_DashBoard') {
$report_id = _hrreport_getId();
$session = CRM_Core_Session::singleton();
$contact_id = $session->get('userID');
//to do entry of default casedashboard report and civicrm news report
foreach (array('blog', 'casedashboard') as $name) {
$caseDashlet = civicrm_api3('Dashboard', 'getsingle', array('return' => array("id", "url", "permission"), 'name' => $name));
$dashboardContactId = civicrm_api3('DashboardContact', 'get', array('return' => array("id", "is_active"), 'dashboard_id' => $caseDashlet['id'], 'contact_id' => $contact_id));
$url = CRM_Utils_System::getServerResponse($caseDashlet['url'], false);
if (empty($dashboardContactId['id'])) {
if ($name == 'blog') {
civicrm_api3('DashboardContact', 'create', array("dashboard_id" => $caseDashlet['id'], 'is_active' => '1', 'contact_id' => $contact_id, 'column_no' => '1', 'content' => $url));
} elseif (CRM_Case_BAO_Case::accessCiviCase()) {
civicrm_api3('DashboardContact', 'create', array("dashboard_id" => $caseDashlet['id'], 'is_active' => '1', 'contact_id' => $contact_id, 'column_no' => '1', 'content' => $url));
}
}
if (!empty($dashboardContactId['id']) && $name == 'casedashboard') {
$id = $dashboardContactId['id'];
if (!CRM_Case_BAO_Case::accessCiviCase()) {
_hrreport_createDashlet($id, '0');
} elseif ($dashboardContactId['values'][$id]['is_active'] == 0) {
_hrreport_createDashlet($id, '1');
}
}
}
$i = 1;
foreach ($report_id as $key => $val) {
$dashletParams['url'] = "civicrm/report/instance/{$val}?reset=1§ion=2&snippet=5&context=dashlet";
$dashlet = civicrm_api3('Dashboard', 'get', array('name' => "report/{$val}"));
if (!empty($dashlet['count']) && $dashlet['count'] > 0) {
$contentUrl = CRM_Utils_System::getServerResponse($dashletParams['url']);
$dashboardContact = civicrm_api3('DashboardContact', 'get', array('return' => array("id", "is_active"), 'dashboard_id' => $dashlet['id'], 'contact_id' => $contact_id));
$dashId = $dashlet['id'];
if (empty($dashboardContact['id'])) {
if (CRM_Core_Permission::check($dashlet['values'][$dashId]['permission'])) {
civicrm_api3('DashboardContact', 'create', array("dashboard_id" => $dashlet['id'], 'is_active' => '1', 'contact_id' => $contact_id, 'column_no' => $i, 'content' => CRM_Utils_System::getServerResponse($dashletParams['url'])));
}
}
if (!empty($dashboardContact['id'])) {
$id = $dashboardContact['id'];
if (!CRM_Core_Permission::check($dashlet['values'][$dashId]['permission'])) {
_hrreport_createDashlet($id, '0');
} elseif ($dashboardContact['values'][$id]['is_active'] == 0) {
_hrreport_createDashlet($id, '1');
}
}
$i = 0;
}
}
}
}
示例14: 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);
}
示例15: preProcess
/**
* Processing needed for buildForm and later.
*/
public function preProcess()
{
$this->set('searchFormName', 'Search');
//check for civicase access.
if (!CRM_Case_BAO_Case::accessCiviCase()) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
//validate case configuration.
$configured = CRM_Case_BAO_Case::isCaseConfigured();
$this->assign('notConfigured', !$configured['configured']);
if (!$configured['configured']) {
return;
}
/**
* set the button names
*/
$this->_searchButtonName = $this->getButtonName('refresh');
$this->_actionButtonName = $this->getButtonName('next', 'action');
$this->_done = FALSE;
$this->defaults = array();
/*
* we allow the controller to set force/reset externally, useful when we are being
* driven by the wizard framework
*/
$this->_reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
$this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE);
$this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'search');
$this->assign('context', $this->_context);
// get user submitted values
// get it from controller only if form has been submitted, else preProcess has set this
if (!empty($_POST) && !$this->controller->isModal()) {
$this->_formValues = $this->controller->exportValues($this->_name);
} else {
$this->_formValues = $this->get('formValues');
}
if (empty($this->_formValues)) {
if (isset($this->_ssID)) {
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
}
}
if ($this->_force) {
$this->postProcess();
$this->set('force', 0);
}
$sortID = NULL;
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID), $this->get(CRM_Utils_Sort::SORT_DIRECTION));
}
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
$selector = new CRM_Case_Selector_Search($this->_queryParams, $this->_action, NULL, $this->_single, $this->_limit, $this->_context);
$prefix = NULL;
if ($this->_context == 'user') {
$prefix = $this->_prefix;
}
$this->assign("{$prefix}limit", $this->_limit);
$this->assign("{$prefix}single", $this->_single);
$controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TRANSFER, $prefix);
$controller->setEmbedded(TRUE);
$controller->moveFromSessionToTemplate();
$this->assign('summary', $this->get('summary'));
}