3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 trait CRM_Core_Page_EntityPageTrait
{
20 * Pages MUST declare the following functions:
21 * public function getDefaultEntity() {
25 * Page MAY want to override the following functions:
26 * public function getDefaultContext()
30 * The id of the contact.
37 * The mode of operation for this page
44 * The context that we are working on.
51 * Contact ID of the contact on the page.
55 public $_contactID = NULL;
58 * Contact ID of the contact on the page.
61 * @deprecated Historically pages alternate between $_contactID and $_contactId. We'll standardise on one
63 public $_contactId = NULL;
68 public $_permission = NULL;
71 * The action links that we need to display for the browse screen.
75 public static $_links = NULL;
78 * Get the entity id being edited.
82 public function getEntityId() {
87 * Get the context we are working in
91 public function getContext() {
92 return $this->_context
;
100 public function getContactId() {
101 return $this->_contactID
;
109 public function setContactId($contactId) {
110 $this->_contactID
= $contactId;
111 $this->_contactId
= $contactId;
114 public function getAction() {
115 return $this->_action
;
119 * Explicitly declare the form context.
121 * @return string|null
123 public function getDefaultContext() {
130 protected function getDefaultAction() {
134 public function preProcessQuickEntityPage() {
135 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, $this->getDefaultAction());
136 $this->assign('action', $this->getAction());
138 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
139 $this->setContactId(CRM_Utils_Request
::retrieve('cid', 'Positive', $this, FALSE, CRM_Core_Session
::getLoggedInContactID()));
141 $this->assign('contactId', $this->getContactId());
143 $this->_context
= CRM_Utils_Request
::retrieve('context', 'Alphanumeric', $this, FALSE, $this->getDefaultContext());
144 $this->assign('context', $this->_context
);
146 // check logged in url permission
147 CRM_Contact_Page_View
::checkUserPermission($this);
149 $this->assign('entityInClassFormat', strtolower(str_replace('_', '-', $this->getDefaultEntity())));
153 * Is the form being used in the context of a deletion.
155 * (For some reason rather than having separate forms Civi overloads one form).
159 protected function isDeleteContext() {
160 return ($this->getAction() & CRM_Core_Action
::DELETE
);
164 * Is the form being used in the context of a view.
168 protected function isViewContext() {
169 return ($this->getAction() & CRM_Core_Action
::VIEW
);
173 * Is the form being used in the context of a edit.
177 protected function isEditContext() {
178 return ($this->getAction() & (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD
));