3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2019
33 trait CRM_Core_Page_EntityPageTrait
{
36 * Pages MUST declare the following functions:
37 * public function getDefaultEntity() {
41 * Page MAY want to override the following functions:
42 * public function getDefaultContext()
46 * The id of the contact.
53 * The mode of operation for this page
60 * The context that we are working on.
67 * Contact ID of the contact on the page.
71 public $_contactID = NULL;
74 * Contact ID of the contact on the page.
77 * @deprecated Historically pages alternate between $_contactID and $_contactId. We'll standardise on one
79 public $_contactId = NULL;
84 public $_permission = NULL;
87 * The action links that we need to display for the browse screen.
91 public static $_links = NULL;
94 * Get the entity id being edited.
98 public function getEntityId() {
103 * Get the context we are working in
107 public function getContext() {
108 return $this->_context
;
116 public function getContactId() {
117 return $this->_contactID
;
125 public function setContactId($contactId) {
126 $this->_contactID
= $contactId;
127 $this->_contactId
= $contactId;
130 public function getAction() {
131 return $this->_action
;
135 * Explicitly declare the form context.
137 * @return string|null
139 public function getDefaultContext() {
143 public function preProcessQuickEntityPage() {
144 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'browse');
145 $this->assign('action', $this->getAction());
147 $this->_id
= CRM_Utils_Request
::retrieve('id', 'Positive', $this);
148 $this->setContactId(CRM_Utils_Request
::retrieve('cid', 'Positive', $this, TRUE));
149 $this->assign('contactId', $this->getContactId());
151 $this->_context
= CRM_Utils_Request
::retrieve('context', 'Alphanumeric', $this, FALSE, $this->getDefaultContext());
152 $this->assign('context', $this->_context
);
154 // check logged in url permission
155 CRM_Contact_Page_View
::checkUserPermission($this);
157 $this->assign('entityInClassFormat', strtolower(str_replace('_', '-', $this->getDefaultEntity())));
161 * Is the form being used in the context of a deletion.
163 * (For some reason rather than having separate forms Civi overloads one form).
167 protected function isDeleteContext() {
168 return ($this->getAction() & CRM_Core_Action
::DELETE
);
172 * Is the form being used in the context of a view.
176 protected function isViewContext() {
177 return ($this->getAction() & CRM_Core_Action
::VIEW
);
181 * Is the form being used in the context of a edit.
185 protected function isEditContext() {
186 return ($this->getAction() & (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD
));