Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
DefaultController.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 
38  {
39  public function filters()
40  {
41  return array_merge(parent::filters(),
42  array(
43  array(
44  ZurmoBaseController::RIGHTS_FILTER_PATH . ' - index, welcome, hideWelcome, getTip',
45  'moduleClassName' => 'HomeModule',
46  'rightName' => HomeModule::RIGHT_ACCESS_DASHBOARDS,
47  ),
48  array(
49  ZurmoBaseController::RIGHTS_FILTER_PATH . ' + createDashboard',
50  'moduleClassName' => 'HomeModule',
51  'rightName' => HomeModule::RIGHT_CREATE_DASHBOARDS,
52  ),
53  array(
54  ZurmoBaseController::RIGHTS_FILTER_PATH . ' + deleteDashboard',
55  'moduleClassName' => 'HomeModule',
56  'rightName' => HomeModule::RIGHT_DELETE_DASHBOARDS,
57  ),
58  array(
59  ZurmoBaseController::RIGHTS_FILTER_PATH . ' + pushDashboard',
60  'moduleClassName' => 'ZurmoModule',
61  'rightName' => ZurmoModule::RIGHT_PUSH_DASHBOARD_OR_LAYOUT,
62  ),
63  )
64  );
65  }
66 
67  public function actionIndex()
68  {
70  'HomeModule',
71  HomeModule::RIGHT_ACCESS_DASHBOARDS,
72  Yii::app()->user->userModel))
73  {
74  $id = Yii::app()->request->getQuery('id', -1);
75  $this->actionDashboardDetails($id);
76  }
77  else
78  {
79  $this->actionWelcome();
80  }
81  }
82 
83  public function actionWelcome()
84  {
85  $hasDashboardAccess = true;
87  'HomeModule',
88  HomeModule::RIGHT_ACCESS_DASHBOARDS,
89  Yii::app()->user->userModel)
90  )
91  {
92  $hasDashboardAccess = false;
93  }
94  $welcomeView = new HomeView();
95  if ($this->hideWelcomeViewGlobally() || UserConfigurationFormAdapter::resolveAndGetValue(Yii::app()->user->userModel, 'hideWelcomeView'))
96  {
97  //If you can see dashboards, then go there, otherwise stay here since the user has limited access.
98  if ($hasDashboardAccess)
99  {
100  $this->redirect(array($this->getId() . '/index'));
101  }
102  }
103  else
104  {
105  $tipContent = ZurmoTipsUtil::getRandomTipResolvedForCurrentUser();
106 
107  if (Yii::app()->userInterface->isMobile())
108  {
109  $welcomeView = new MobileWelcomeView($tipContent, $hasDashboardAccess);
110  }
111  else
112  {
113  $welcomeView = new WelcomeView($tipContent, $hasDashboardAccess);
114  }
115  }
116  $view = new HomePageView(ZurmoDefaultViewUtil::
117  makeStandardViewForCurrentUser($this, $welcomeView));
118  echo $view->render();
119  }
120 
121  public function actionHideWelcome()
122  {
123  $configurationForm = UserConfigurationFormAdapter::
124  makeFormFromUserConfigurationByUser(Yii::app()->user->userModel);
125  $configurationForm->hideWelcomeView = true;
126  UserConfigurationFormAdapter::setConfigurationFromForm($configurationForm, Yii::app()->user->userModel);
127  $this->redirect(array($this->getId() . '/index'));
128  }
129 
130  public function actionDashboardDetails($id)
131  {
132  if (intval($id) > 0)
133  {
134  $dashboard = Dashboard::getById(intval($id));
135  $layoutId = $dashboard->layoutId;
136  }
137  else
138  {
139  $dashboard = Dashboard::getByLayoutIdAndUser(Dashboard::DEFAULT_USER_LAYOUT_ID, Yii::app()->user->userModel);
140  $layoutId = $dashboard->layoutId;
141  }
142  $params = array(
143  'controllerId' => $this->getId(),
144  'moduleId' => $this->getModule()->getId(),
145  );
148  $homeTitleBarAndDashboardView = new HomeTitleBarAndDashboardView(
149  $this->getId(),
150  $this->getModule()->getId(),
151  'HomeDashboard' . $layoutId,
152  $dashboard,
153  $params);
154  $view = new HomePageView(ZurmoDefaultViewUtil::
155  makeStandardViewForCurrentUser($this, $homeTitleBarAndDashboardView));
156  echo $view->render();
157  }
158 
159  public function actionCreateDashboard()
160  {
161  $dashboard = new Dashboard();
162  if (isset($_POST['Dashboard']))
163  {
164  $dashboard->owner = Yii::app()->user->userModel;
165  $dashboard->layoutId = Dashboard::getNextLayoutId();
167  $dashboard, $_POST['Dashboard']);
168  $dashboard->setAttributes($_POST['Dashboard']);
169  assert('in_array($dashboard->layoutType, array_keys(Dashboard::getLayoutTypesData()))');
170  if ($dashboard->save())
171  {
172  GeneralCache::forgetAll(); //Ensure menu refreshes
173  $this->redirect(array('default/dashboardDetails', 'id' => $dashboard->id));
174  }
175  }
176  $editView = new DashboardEditView($this->getId(), $this->getModule()->getId(), $dashboard,
177  Zurmo::t('HomeModule', 'Create Dashboard'));
179  echo $view->render();
180  }
181 
186  public function actionEditDashboard($id)
187  {
188  $id = intval($id);
189  $dashboard = Dashboard::getById(intval($id));
191  if (isset($_POST['Dashboard']))
192  {
193  $oldLayoutType = $dashboard->layoutType;
195  $dashboard, $_POST['Dashboard']);
196  $dashboard->setAttributes($_POST['Dashboard']);
197  assert('in_array($dashboard->layoutType, array_keys(Dashboard::getLayoutTypesData()))');
198  if ($dashboard->save())
199  {
200  if ($oldLayoutType != $dashboard->layoutType && $dashboard->layoutType == '100')
201  {
202  $uniqueLayoutId = 'HomeDashboard' . $dashboard->layoutId;
203  $portletCollection = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($uniqueLayoutId, Yii::app()->user->userModel->id, array());
204  Portlet::shiftPositionsBasedOnColumnReduction($portletCollection, 1);
205  }
206  GeneralCache::forgetAll(); //Ensure menu refreshes
207  $this->redirect(array('default/dashboardDetails', 'id' => $dashboard->id));
208  }
209  }
210  $editView = new DashboardEditView($this->getId(), $this->getModule()->getId(), $dashboard, strval($dashboard));
212  makeStandardViewForCurrentUser($this, $editView));
213  echo $view->render();
214  }
215 
220  public function actionDeleteDashboard()
221  {
222  $id = intval($_GET['dashboardId']);
223  $dashboard = Dashboard::getById($id);
225  if ($dashboard->isDefault)
226  {
227  //todo: make a specific exception or view for this situation.
228  throw new NotSupportedException();
229  }
230  $portlets = Portlet::getByLayoutIdAndUserSortedById('HomeDashboard' . $id, Yii::app()->user->userModel->id);
231  foreach ($portlets as $portlet)
232  {
233  $portlet->delete();
234  unset($portlet);
235  }
236  $dashboard->delete();
237  unset($dashboard);
238  $this->redirect(array('default/index'));
239  }
240 
244  public function actionGetTip()
245  {
246  $tipContent = ZurmoTipsUtil::getRandomTipResolvedForCurrentUser();
247  echo CJSON::encode($tipContent);
248  }
249 
250  protected function hideWelcomeViewGlobally()
251  {
252  if (null != $hideWelcomeViewGlobally = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'hideWelcomeViewGlobally'))
253  {
254  return $hideWelcomeViewGlobally;
255  }
256  else
257  {
258  return (bool)$hideWelcomeViewGlobally;
259  }
260  }
261 
262  public function actionPushDashboard($id)
263  {
264  $dashboard = Dashboard::getById(intval($id));
265  $modelClassName = get_class($dashboard);
266  if (isset($_POST[$modelClassName]))
267  {
268  $groupsAndUsers = PushDashboardUtil::resolveGroupsAndUsersFromPost($_POST[$modelClassName]);
269  PushDashboardUtil::pushDashboardToUsers($dashboard, $groupsAndUsers);
270  Yii::app()->user->setFlash('notification', Zurmo::t('HomeModule', 'Dashboard pushed successfully'));
271  $this->redirect(array('default/dashboardDetails', 'id' => $dashboard->id));
272  }
273  $editView = new PushDashboardEditView($this->getId(), $this->getModule()->getId(), $dashboard,
274  Zurmo::t('HomeModule', 'Push Dashboard'));
276  echo $view->render();
277  }
278 
279  public function actionAutoCompleteGroupsAndUsers($term)
280  {
281  $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType(
282  'autoCompleteListPageSize', get_class($this->getModule()));
283  $groups = ModelAutoCompleteUtil::getByPartialName('Group', $term, $pageSize);
284  $users = UserSearch::getUsersByPartialFullNameOrAnyEmailAddress($term, $pageSize, null);
285  $autoCompleteResults = array();
286  foreach ($groups as $group)
287  {
288  $autoCompleteResults[] = array(
289  'id' => PushDashboardUtil::GROUP_PREFIX . $group['id'],
290  'name' => $group['value']
291  );
292  }
293  foreach ($users as $user)
294  {
295  $autoCompleteResults[] = array(
296  'id' => PushDashboardUtil::USER_PREFIX . $user->id,
297  'name' => MultipleContactsForMeetingElement::renderHtmlContentLabelFromUserAndKeyword($user, $term)
298  );
299  }
300  echo CJSON::encode($autoCompleteResults);
301  }
302 
303  public function actionDetails($id)
304  {
305  $this->actionDashboardDetails($id);
306  }
307  }
308 ?>
static resolveGroupsAndUsersFromPost($postData)
static resolvePortletCollectionColumnIndexes($layoutId)
Definition: Portlet.php:312
static getByLayoutIdAndUser($layoutId, $user)
Definition: Dashboard.php:46
static setConfigurationFromForm(UserConfigurationForm $form, User $user)
static doesUserHaveAllowByRightName($moduleClassName, $rightName, $user)
Definition: RightsUtil.php:121
static resolveAccessCanCurrentUserDeleteModel(RedBeanModel $model, $fromAjax=false)
static resolveAccessCanCurrentUserReadModel(RedBeanModel $model, $fromAjax=false)
static getByPartialName($modelClassName, $partialName, $pageSize, $autoCompleteOptions=null)
static getByModuleName($moduleName, $key, $cache=true)
static makeFormFromUserConfigurationByUser(User $user)
static pushDashboardToUsers(Dashboard $dashboard, $groupsAndUsers)
static getById($id, $modelClassName=null)
static resolveAndGetValue(User $user, $key, $returnBoolean=true)
static makeStandardViewForCurrentUser(CController $controller, View $containedView)
static sanitizePostByDesignerTypeForSavingModel($model, $postData)
Definition: PostUtil.php:94
static resolveAccessCanCurrentUserWriteModel(RedBeanModel $model, $fromAjax=false)
Generated on Fri Jul 10 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.