*/
class CRM_Contribute_Page_ContributionRecur extends CRM_Core_Page {
- public static $_links = NULL;
- public $_permission = NULL;
- public $_contactId = NULL;
- public $_id = NULL;
- public $_action = NULL;
+ use CRM_Core_Page_EntityPageTrait;
+
+ /**
+ * @return string
+ */
+ public function getDefaultEntity() {
+ return 'ContributionRecur';
+ }
+
+ protected function getDefaultAction() {
+ return 'view';
+ }
/**
* View details of a recurring contribution.
*/
public function view() {
- if (empty($this->_id)) {
+ if (empty($this->getEntityId())) {
CRM_Core_Error::statusBounce('Recurring contribution not found');
}
try {
$contributionRecur = civicrm_api3('ContributionRecur', 'getsingle', [
- 'id' => $this->_id,
+ 'id' => $this->getEntityId(),
]);
}
catch (Exception $e) {
- CRM_Core_Error::statusBounce('Recurring contribution not found (ID: ' . $this->_id);
+ CRM_Core_Error::statusBounce('Recurring contribution not found (ID: ' . $this->getEntityId());
}
$contributionRecur['payment_processor'] = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorName(
}
public function preProcess() {
- $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'view');
- $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
- $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
- $this->assign('contactId', $this->_contactId);
-
- // check logged in url permission
- CRM_Contact_Page_View::checkUserPermission($this);
-
- $this->assign('action', $this->_action);
-
- if ($this->_permission == CRM_Core_Permission::EDIT && !CRM_Core_Permission::check('edit contributions')) {
- // demote to view since user does not have edit contrib rights
- $this->_permission = CRM_Core_Permission::VIEW;
- $this->assign('permission', 'view');
- }
+ $this->preProcessQuickEntityPage();
}
/**
public function run() {
$this->preProcess();
- if ($this->_action & CRM_Core_Action::VIEW) {
+ if ($this->isViewContext()) {
$this->view();
}
return NULL;
}
+ /**
+ * @return string
+ */
+ protected function getDefaultAction() {
+ return 'browse';
+ }
+
public function preProcessQuickEntityPage() {
- $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
+ $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, $this->getDefaultAction());
$this->assign('action', $this->getAction());
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);