Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ActivityModelsDefaultController.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
42  {
43  public function filters()
44  {
45  $modelClassName = $this->getModule()->getPrimaryModelName();
46  $viewClassName = $modelClassName . 'EditAndDetailsView';
47  return array_merge(parent::filters(),
48  array(
49  array(
50  ZurmoBaseController::REQUIRED_ATTRIBUTES_FILTER_PATH . ' + create, createFromRelation, edit',
51  'moduleClassName' => get_class($this->getModule()),
52  'viewClassName' => $viewClassName,
53  ),
54  )
55  );
56  }
57 
58  protected function getPageViewClassName()
59  {
60  return $this->getModule()->getPluralCamelCasedName() . 'PageView';
61  }
62 
69  public function actionCreateFromRelation($relationAttributeName, $relationModelId, $relationModuleId, $redirectUrl)
70  {
71  $modelClassName = $this->getModule()->getPrimaryModelName();
72  $activity = $this->resolveNewModelByRelationInformation( new $modelClassName(),
73  $relationAttributeName,
74  (int)$relationModelId,
75  $relationModuleId);
76  $this->actionCreateByModel($activity, $redirectUrl);
77  }
78 
83  protected function actionCreateByModel(Activity $activity, $redirectUrl)
84  {
85  $titleBarAndEditView = $this->makeEditAndDetailsView(
86  $this->attemptToSaveModelFromPost($activity, $redirectUrl), 'Edit');
87  $pageViewClassName = $this->getPageViewClassName();
88  $view = new $pageViewClassName(ZurmoDefaultViewUtil::
89  makeStandardViewForCurrentUser($this, $titleBarAndEditView));
90  echo $view->render();
91  }
92 
97  public function actionDetails($id, $redirectUrl = null)
98  {
99  $modelClassName = $this->getModule()->getPrimaryModelName();
100  $activity = static::getModelAndCatchNotFoundAndDisplayError($modelClassName, intval($id));
101  AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($activity), get_class($this->getModule())), $activity);
103  $pageViewClassName = $this->getPageViewClassName();
104  $view = new $pageViewClassName(ZurmoDefaultViewUtil::
105  makeStandardViewForCurrentUser($this,
106  $this->makeEditAndDetailsView($activity, 'Details')));
107  echo $view->render();
108  }
109 
114  public function actionEdit($id, $redirectUrl = null)
115  {
116  $modelClassName = $this->getModule()->getPrimaryModelName();
117  $activity = $modelClassName::getById(intval($id));
119  $this->processEdit($activity, $redirectUrl);
120  }
121 
126  public function actionCopy($id, $redirectUrl = null)
127  {
128  $modelClassName = $this->getModule()->getPrimaryModelName();
129  $copyToActivity = new $modelClassName();
130  $postVariableName = get_class($copyToActivity);
131  if (!isset($_POST[$postVariableName]))
132  {
133  $activity = $modelClassName::getById((int)$id);
135  ActivityCopyModelUtil::copy($activity, $copyToActivity);
136  }
137  $this->processEdit($copyToActivity, $redirectUrl);
138  }
139 
144  protected function processEdit(Activity $activity, $redirectUrl = null)
145  {
146  $pageViewClassName = $this->getPageViewClassName();
147  $view = new $pageViewClassName(ZurmoDefaultViewUtil::
148  makeStandardViewForCurrentUser($this,
149  $this->makeEditAndDetailsView(
150  $this->attemptToSaveModelFromPost($activity, $redirectUrl), 'Edit')));
151  echo $view->render();
152  }
153 
158  public function actionDelete($id, $redirectUrl = null)
159  {
160  if ($redirectUrl == null)
161  {
162  $redirectUrl = array('/home/default');
163  }
164  $modelClassName = $this->getModule()->getPrimaryModelName();
165  $activity = $modelClassName::getById(intval($id));
167  $activity->delete();
168  $this->redirect($redirectUrl);
169  }
170  }
171 ?>
actionCreateFromRelation($relationAttributeName, $relationModelId, $relationModuleId, $redirectUrl)
static resolveAccessCanCurrentUserDeleteModel(RedBeanModel $model, $fromAjax=false)
static copy(RedBeanModel $model, RedBeanModel $copyToModel)
attemptToSaveModelFromPost($model, $redirectUrlParams=null, $redirect=true, $returnOnValidate=false)
static resolveAccessCanCurrentUserReadModel(RedBeanModel $model, $fromAjax=false)
resolveNewModelByRelationInformation($model, $relationModelClassName, $relationModelId, $relationModuleId)
processEdit(Activity $activity, $redirectUrl=null)
actionCreateByModel(Activity $activity, $redirectUrl)
static resolveAccessCanCurrentUserWriteModel(RedBeanModel $model, $fromAjax=false)
Generated on Wed Oct 21 2020 07:10:27
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.