本文整理汇总了PHP中CRM_Activity_BAO_Activity::checkPermission方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_Activity::checkPermission方法的具体用法?PHP CRM_Activity_BAO_Activity::checkPermission怎么用?PHP CRM_Activity_BAO_Activity::checkPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Activity_BAO_Activity
的用法示例。
在下文中一共展示了CRM_Activity_BAO_Activity::checkPermission方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
//get the activity values
$activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
//check for required permissions, CRM-6264
if ($activityId && !CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
$session = CRM_Core_Session::singleton();
if (!in_array($context, array('home', 'dashlet', 'dashletFullscreen'))) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
} else {
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
}
$session->pushUserContext($url);
$defaults = array();
$params = array('id' => $activityId);
CRM_Activity_BAO_Activity::retrieve($params, $defaults);
//set activity type name and description to template
list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']);
$this->assign('activityTypeName', $activityTypeName);
$this->assign('activityTypeDescription', $activityTypeDescription);
if (CRM_Utils_Array::value('mailingId', $defaults)) {
$this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults);
$mailingReport = CRM_Mailing_BAO_Mailing::report($this->_mailing_id, TRUE);
CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this);
$this->assign('mailingReport', $mailingReport);
$full_open_report = CRM_Mailing_Event_BAO_Opened::getRows($this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, $cid);
$this->assign('openreport', $full_open_report);
$click_thru_report = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($this->_mailing_id, NULL, FALSE, NULL, NULL, NULL, NULL, $cid);
$this->assign('clickreport', $click_thru_report);
}
foreach ($defaults as $key => $value) {
if (substr($key, -3) != '_id') {
$values[$key] = $value;
}
}
//get the campaign
if ($campaignId = CRM_Utils_Array::value('campaign_id', $defaults)) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values['campaign'] = $campaigns[$campaignId];
}
if ($engagementLevel = CRM_Utils_Array::value('engagement_level', $defaults)) {
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
$values['engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
}
$values['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityId);
$this->assign('values', $values);
}
示例2: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
//get the activity values
$activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
//check for required permissions, CRM-6264
if ($activityId && !CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
$session = CRM_Core_Session::singleton();
if ($context != 'home') {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
} else {
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
}
$session->pushUserContext($url);
$params = array('id' => $activityId);
CRM_Activity_BAO_Activity::retrieve($params, $defaults);
//set activity type name and description to template
require_once 'CRM/Core/BAO/OptionValue.php';
list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']);
$this->assign('activityTypeName', $activityTypeName);
$this->assign('activityTypeDescription', $activityTypeDescription);
if (CRM_Utils_Array::value('mailingId', $defaults)) {
$this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults);
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailingReport =& CRM_Mailing_BAO_Mailing::report($this->_mailing_id, true);
CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this);
$this->assign('mailingReport', $mailingReport);
}
foreach ($defaults as $key => $value) {
if (substr($key, -3) != '_id') {
$values[$key] = $value;
}
}
require_once 'CRM/Core/BAO/File.php';
$values['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityId);
$this->assign('values', $values);
}
示例3: preProcess
/**
* Process the view.
*
*
* @return void
*/
public function preProcess()
{
$contactID = CRM_Utils_Request::retrieve('cid', 'Integer', $this, TRUE);
$activityID = CRM_Utils_Request::retrieve('aid', 'Integer', $this, TRUE);
$revs = CRM_Utils_Request::retrieve('revs', 'Boolean', CRM_Core_DAO::$_nullObject);
$caseID = CRM_Utils_Request::retrieve('caseID', 'Boolean', CRM_Core_DAO::$_nullObject);
$activitySubject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'subject');
//check for required permissions, CRM-6264
if ($activityID && !CRM_Activity_BAO_Activity::checkPermission($activityID, CRM_Core_Action::VIEW)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
$this->assign('contactID', $contactID);
$this->assign('caseID', $caseID);
// CRM-9145
$this->assign('activityID', $activityID);
$xmlProcessor = new CRM_Case_XMLProcessor_Report();
$report = $xmlProcessor->getActivityInfo($contactID, $activityID, TRUE);
$attachmentUrl = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityID);
if ($attachmentUrl) {
$report['fields'][] = array('label' => 'Attachment(s)', 'value' => $attachmentUrl, 'type' => 'Link');
}
$tags = CRM_Core_BAO_EntityTag::getTag($activityID, 'civicrm_activity');
if (!empty($tags)) {
$allTag = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
foreach ($tags as $tid) {
$tags[$tid] = $allTag[$tid];
}
$report['fields'][] = array('label' => 'Tags', 'value' => implode('<br />', $tags), 'type' => 'String');
}
$this->assign('report', $report);
$latestRevisionID = CRM_Activity_BAO_Activity::getLatestActivityId($activityID);
$viewPriorActivities = array();
$priorActivities = CRM_Activity_BAO_Activity::getPriorAcitivities($activityID);
foreach ($priorActivities as $activityId => $activityValues) {
if (CRM_Case_BAO_Case::checkPermission($activityId, 'view', NULL, $contactID)) {
$viewPriorActivities[$activityId] = $activityValues;
}
}
if ($revs) {
CRM_Utils_System::setTitle(ts('Activity Revision History'));
$this->assign('revs', $revs);
$this->assign('result', $viewPriorActivities);
$this->assign('subject', $activitySubject);
$this->assign('latestRevisionID', $latestRevisionID);
} else {
if (count($viewPriorActivities) > 1) {
$this->assign('activityID', $activityID);
}
if ($latestRevisionID != $activityID) {
$this->assign('latestRevisionID', $latestRevisionID);
}
}
$parentID = CRM_Activity_BAO_Activity::getParentActivity($activityID);
if ($parentID) {
$this->assign('parentID', $parentID);
}
//viewing activity should get diplayed in recent list.CRM-4670
$activityTypeID = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'activity_type_id');
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$activityTargetContacts = CRM_Activity_BAO_ActivityContact::retrieveContactIdsByActivityId($activityID, $targetID);
if (!empty($activityTargetContacts)) {
$recentContactId = $activityTargetContacts[0];
} else {
$recentContactId = $contactID;
}
if (!isset($caseID)) {
$caseID = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseActivity', $activityID, 'case_id', 'activity_id');
}
$url = CRM_Utils_System::url('civicrm/case/activity/view', "reset=1&aid={$activityID}&cid={$recentContactId}&caseID={$caseID}&context=home");
$recentContactDisplay = CRM_Contact_BAO_Contact::displayName($recentContactId);
// add the recently created Activity
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
$title = "";
if (isset($activitySubject)) {
$title = $activitySubject . ' - ';
}
$title = $title . $recentContactDisplay . ' (' . $activityTypes[$activityTypeID] . ')';
$recentOther = array();
if (CRM_Case_BAO_Case::checkPermission($activityID, 'edit')) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/case/activity', "reset=1&action=update&id={$activityID}&cid={$recentContactId}&caseid={$caseID}&context=home");
}
if (CRM_Case_BAO_Case::checkPermission($activityID, 'delete')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/case/activity', "reset=1&action=delete&id={$activityID}&cid={$recentContactId}&caseid={$caseID}&context=home");
}
CRM_Utils_Recent::add($title, $url, $activityID, 'Activity', $recentContactId, $recentContactDisplay, $recentOther);
}
示例4: preProcess
/**
* Build the form object.
*/
public function preProcess()
{
CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity');
$this->_atypefile = CRM_Utils_Array::value('atypefile', $_GET);
$this->assign('atypefile', FALSE);
if ($this->_atypefile) {
$this->assign('atypefile', TRUE);
}
$session = CRM_Core_Session::singleton();
$this->_currentUserId = $session->get('userID');
$this->_currentlyViewedContactId = $this->get('contactId');
if (!$this->_currentlyViewedContactId) {
$this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
}
$this->assign('contactId', $this->_currentlyViewedContactId);
// Give the context.
if (!isset($this->_context)) {
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
if (CRM_Contact_Form_Search::isSearchContext($this->_context)) {
$this->_context = 'search';
} elseif (!in_array($this->_context, array('dashlet', 'dashletFullscreen')) && $this->_currentlyViewedContactId) {
$this->_context = 'activity';
}
$this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
}
$this->assign('context', $this->_context);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
if ($this->_action & CRM_Core_Action::DELETE) {
if (!CRM_Core_Permission::check('delete activities')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
}
// CRM-6957
// When we come from contact search, activity id never comes.
// So don't try to get from object, it might gives you wrong one.
// if we're not adding new one, there must be an id to
// an activity we're trying to work on.
if ($this->_action != CRM_Core_Action::ADD && get_class($this->controller) != 'CRM_Contact_Controller_Search') {
$this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
}
$this->_activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
$this->assign('atype', $this->_activityTypeId);
$this->assign('activityId', $this->_activityId);
// Check for required permissions, CRM-6264.
if ($this->_activityId && in_array($this->_action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) && !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
if ($this->_action & CRM_Core_Action::VIEW && CRM_Activity_BAO_Activity::checkPermission($this->_activityId, CRM_Core_Action::UPDATE)) {
$this->assign('permission', 'edit');
}
if (!$this->_activityTypeId && $this->_activityId) {
$this->_activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'activity_type_id');
}
// Assigning Activity type name.
if ($this->_activityTypeId) {
$activityTName = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $this->_activityTypeId, 'label');
if ($activityTName[$this->_activityTypeId]) {
$this->_activityTypeName = $activityTName[$this->_activityTypeId];
$this->assign('activityTName', $activityTName[$this->_activityTypeId]);
}
}
// Set title.
if (isset($activityTName)) {
$activityName = CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
$this->assign('pageTitle', ts('%1 Activity', array(1 => $activityName)));
if ($this->_currentlyViewedContactId) {
$displayName = CRM_Contact_BAO_Contact::displayName($this->_currentlyViewedContactId);
// Check if this is default domain contact CRM-10482.
if (CRM_Contact_BAO_Contact::checkDomainContact($this->_currentlyViewedContactId)) {
$displayName .= ' (' . ts('default organization') . ')';
}
CRM_Utils_System::setTitle($displayName . ' - ' . $activityName);
} else {
CRM_Utils_System::setTitle(ts('%1 Activity', array(1 => $activityName)));
}
}
// Check the mode when this form is called either single or as
// search task action.
if ($this->_activityTypeId || $this->_context == 'standalone' || $this->_currentlyViewedContactId) {
$this->_single = TRUE;
$this->assign('urlPath', 'civicrm/activity');
} else {
// Set the appropriate action.
$url = CRM_Utils_System::currentPath();
$urlArray = explode('/', $url);
$searchPath = array_pop($urlArray);
$searchType = 'basic';
$this->_action = CRM_Core_Action::BASIC;
switch ($searchPath) {
case 'basic':
$searchType = $searchPath;
$this->_action = CRM_Core_Action::BASIC;
break;
case 'advanced':
$searchType = $searchPath;
$this->_action = CRM_Core_Action::ADVANCED;
break;
//.........这里部分代码省略.........
示例5: run
/**
* perform actions and display for activities.
*
* @return none
*
* @access public
*/
function run()
{
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
//do check for view/edit operation.
if ($this->_id && in_array($action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW))) {
if (!CRM_Activity_BAO_Activity::checkPermission($this->_id, $action)) {
CRM_Core_Error::fatal(ts('You are not authorized to access this page.'));
}
}
if ($context == 'standalone' || !$contactId && $action != CRM_Core_Action::DELETE && !$this->_id) {
$this->_action = CRM_Core_Action::ADD;
$this->assign('action', $this->_action);
} else {
// we should call contact view, preprocess only for activity in contact summary
$this->preProcess();
}
// route behaviour of contact/view/activity based on action defined
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::VIEW)) {
$this->edit();
$activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
// Email and Create Letter activities use a different form class
$emailTypeValue = CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name');
$letterTypeValue = CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name');
if (in_array($activityTypeId, array($emailTypeValue, $letterTypeValue))) {
return;
}
} elseif ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::DETACH)) {
$this->delete();
} else {
$this->browse();
}
return parent::run();
}
示例6: actionLinks
//.........这里部分代码省略.........
if (!$activityActTypes) {
$activeActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE);
}
$activityTypeName = CRM_Utils_Array::value($activityTypeId, $activeActTypes);
// CRM-7607
// Lets allow to have normal operation for only activity types.
// When activity type is disabled or no more exists give only delete.
switch ($activityTypeName) {
case 'Event Registration':
case 'Change Registration':
$url = 'civicrm/contact/view/participant';
$qsView = "action=view&reset=1&id={$sourceRecordId}&cid=%%cid%%&context=%%cxt%%{$extraParams}";
break;
case 'Contribution':
$url = 'civicrm/contact/view/contribution';
$qsView = "action=view&reset=1&id={$sourceRecordId}&cid=%%cid%%&context=%%cxt%%{$extraParams}";
break;
case 'Payment':
case 'Refund':
$participantId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $sourceRecordId, 'participant_id', 'contribution_id');
if (!empty($participantId)) {
$url = 'civicrm/contact/view/participant';
$qsView = "action=view&reset=1&id={$participantId}&cid=%%cid%%&context=%%cxt%%{$extraParams}";
}
break;
case 'Membership Signup':
case 'Membership Renewal':
case 'Change Membership Status':
case 'Change Membership Type':
$url = 'civicrm/contact/view/membership';
$qsView = "action=view&reset=1&id={$sourceRecordId}&cid=%%cid%%&context=%%cxt%%{$extraParams}";
break;
case 'Pledge Reminder':
case 'Pledge Acknowledgment':
$url = 'civicrm/contact/view/activity';
$qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
break;
case 'Email':
case 'Bulk Email':
$url = 'civicrm/activity/view';
$delUrl = 'civicrm/activity';
$qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
if ($activityTypeName == 'Email') {
$showDelete = TRUE;
}
break;
case 'Inbound Email':
$url = 'civicrm/contact/view/activity';
$qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
break;
case 'Open Case':
case 'Change Case Type':
case 'Change Case Status':
case 'Change Case Start Date':
$showUpdate = $showDelete = FALSE;
$url = 'civicrm/activity';
$qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
$qsUpdate = "atype={$activityTypeId}&action=update&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
break;
default:
$url = 'civicrm/activity';
$showView = $showDelete = $showUpdate = TRUE;
$qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
$qsUpdate = "atype={$activityTypeId}&action=update&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
// When type is not available lets hide view and update.
if (empty($activityTypeName)) {
$showView = $showUpdate = FALSE;
}
break;
}
$qsDelete = "atype={$activityTypeId}&action=delete&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
$actionLinks = array();
if ($showView) {
$actionLinks += array(CRM_Core_Action::VIEW => array('name' => ts('View'), 'url' => $url, 'qs' => $qsView, 'title' => ts('View Activity')));
}
if ($showUpdate) {
$updateUrl = 'civicrm/activity/add';
if ($activityTypeName == 'Email') {
$updateUrl = 'civicrm/activity/email/add';
} elseif ($activityTypeName == 'Print PDF Letter') {
$updateUrl = 'civicrm/activity/pdf/add';
}
if (CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::UPDATE)) {
$actionLinks += array(CRM_Core_Action::UPDATE => array('name' => ts('Edit'), 'url' => $updateUrl, 'qs' => $qsUpdate, 'title' => ts('Update Activity')));
}
}
if ($activityTypeName && CRM_Case_BAO_Case::checkPermission($activityId, 'File On Case', $activityTypeId)) {
$actionLinks += array(CRM_Core_Action::ADD => array('name' => ts('File on Case'), 'url' => '#', 'extra' => 'onclick="javascript:fileOnCase( \'file\', \'%%id%%\', null, this ); return false;"', 'title' => ts('File on Case')));
}
if ($showDelete) {
if (!isset($delUrl) || !$delUrl) {
$delUrl = $url;
}
$actionLinks += array(CRM_Core_Action::DELETE => array('name' => ts('Delete'), 'url' => $delUrl, 'qs' => $qsDelete, 'title' => ts('Delete Activity')));
}
if ($accessMailingReport) {
$actionLinks += array(CRM_Core_Action::BROWSE => array('name' => ts('Mailing Report'), 'url' => 'civicrm/mailing/report', 'qs' => "mid={$sourceRecordId}&reset=1&cid=%%cid%%&context=activitySelector", 'title' => ts('View Mailing Report')));
}
return $actionLinks;
}
示例7: 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->_atypefile = CRM_Utils_Array::value('atypefile', $_GET);
$this->assign('atypefile', false);
if ($this->_atypefile) {
$this->assign('atypefile', true);
}
$this->_addAssigneeContact = CRM_Utils_Array::value('assignee_contact', $_GET);
$this->assign('addAssigneeContact', false);
if ($this->_addAssigneeContact) {
$this->assign('addAssigneeContact', true);
}
$this->_addTargetContact = CRM_Utils_Array::value('target_contact', $_GET);
$this->assign('addTargetContact', false);
if ($this->_addTargetContact) {
$this->assign('addTargetContact', true);
}
$session = CRM_Core_Session::singleton();
$this->_currentUserId = $session->get('userID');
//give the context.
if (!$this->_context) {
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
require_once 'CRM/Contact/Form/Search.php';
if (CRM_Contact_Form_Search::isSearchContext($this->_context)) {
$this->_context = 'search';
}
$this->_compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
}
$this->assign('context', $this->_context);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
if ($this->_action & CRM_Core_Action::DELETE) {
if (!CRM_Core_Permission::check('delete activities')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
}
}
//CRM-6957
//when we come from contact search, activity id never comes.
//so don't try to get from object, it might gives you wrong one.
// if we're not adding new one, there must be an id to
// an activity we're trying to work on.
if ($this->_action != CRM_Core_Action::ADD && get_class($this->controller) != 'CRM_Contact_Controller_Search') {
$this->_activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
}
$this->_currentlyViewedContactId = $this->get('contactId');
if (!$this->_currentlyViewedContactId) {
$this->_currentlyViewedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
}
$this->_activityTypeId = CRM_Utils_Request::retrieve('atype', 'Positive', $this);
$this->assign('atype', $this->_activityTypeId);
//check for required permissions, CRM-6264
require_once 'CRM/Case/BAO/Case.php';
if ($this->_activityId && in_array($this->_action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) && !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
if (!$this->_activityTypeId && $this->_activityId) {
$this->_activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'activity_type_id');
}
//Assigning Activity type name
if ($this->_activityTypeId) {
require_once 'CRM/Core/OptionGroup.php';
$activityTName = CRM_Core_OptionGroup::values('activity_type', false, false, false, 'AND v.value = ' . $this->_activityTypeId, 'name');
if ($activityTName[$this->_activityTypeId]) {
$this->assign('activityTName', $activityTName[$this->_activityTypeId]);
}
}
// Assign pageTitle to be "Activity - "+ activity name
$pageTitle = 'Activity - ' . CRM_Utils_Array::value($this->_activityTypeId, $activityTName);
$this->assign('pageTitle', $pageTitle);
//check the mode when this form is called either single or as
//search task action
if ($this->_activityTypeId || $this->_context == 'standalone' || $this->_currentlyViewedContactId) {
$this->_single = true;
$this->assign('urlPath', 'civicrm/activity');
} else {
//set the appropriate action
$url = CRM_Utils_System::currentPath();
$seachPath = array_pop(explode('/', $url));
$searchType = 'basic';
$this->_action = CRM_Core_Action::BASIC;
switch ($seachPath) {
case 'basic':
$searchType = $seachPath;
$this->_action = CRM_Core_Action::BASIC;
break;
case 'advanced':
$searchType = $seachPath;
$this->_action = CRM_Core_Action::ADVANCED;
break;
//.........这里部分代码省略.........
示例8: civicrm_api3_activity_get
/**
* Gets a CiviCRM activity according to parameters.
*
* @param array $params
* Array per getfields documentation.
*
* @return array API result array
* API result array
*
* @throws \API_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
function civicrm_api3_activity_get($params)
{
if (!empty($params['check_permissions']) && !CRM_Core_Permission::check('view all activities')) {
// In absence of view all activities permission it's possible to see a specific activity by ACL.
// Note still allowing view all activities to override ACLs is based on the 'don't change too much
// if you are not sure principle' and it could be argued that the ACLs should always be applied.
if (empty($params['id']) || !empty($params['contact_id'])) {
// We fall back to the original blunt permissions if we don't have an id to check or we are about
// to go to the weird place that the legacy 'contact_id' parameter takes us to.
throw new \Civi\API\Exception\UnauthorizedException("Cannot access activities. Required permission: 'view all activities''");
}
if (!CRM_Activity_BAO_Activity::checkPermission($params['id'], CRM_Core_Action::VIEW)) {
throw new \Civi\API\Exception\UnauthorizedException('You do not have permission to view this activity');
}
}
if (!empty($params['contact_id'])) {
$activities = CRM_Activity_BAO_Activity::getContactActivity($params['contact_id']);
// BAO function doesn't actually return a contact ID - hack api for now & add to test so when api re-write
// happens it won't get missed.
foreach ($activities as $key => $activityArray) {
$activities[$key]['id'] = $key;
}
} else {
$sql = CRM_Utils_SQL_Select::fragment();
$options = civicrm_api3('ActivityContact', 'getoptions', array('field' => 'record_type_id'));
$options = $options['values'];
$activityContactOptions = array('target_contact_id' => array_search('Activity Targets', $options), 'source_contact_id' => array_search('Activity Source', $options), 'assignee_contact_id' => array_search('Activity Assignees', $options));
foreach ($activityContactOptions as $activityContactName => $activityContactValue) {
if (!empty($params[$activityContactName])) {
// If the intent is to have multiple joins -- one for each relation -- then you would
// need different table aliases. Consider replacing 'ac' and passing in a '!alias' param,
// with a different value for each relation.
$sql->join('activity_' . $activityContactName, 'LEFT JOIN civicrm_activity_contact ac ON a.id = ac.activity_id AND ac.record_type_id = #typeId', array('typeId' => $activityContactValue));
$sql->where('ac.contact_id IN (#cid)', array('cid' => $params[$activityContactName]));
}
}
$activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Activity', $sql);
}
$options = _civicrm_api3_get_options_from_params($params, FALSE, 'Activity', 'get');
if ($options['is_count']) {
return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
$activities = _civicrm_api3_activity_get_formatResult($params, $activities);
//legacy custom data get - so previous formatted response is still returned too
return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}