Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
DashboardView.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 
40  abstract class DashboardView extends PortletFrameView
41  {
42  protected $model;
43  protected $isDefaultDashboard;
44 
45  public function __construct($controllerId, $moduleId, $uniqueLayoutId, $model, $params)
46  {
47  assert('$model instanceof Dashboard');
48  $this->controllerId = $controllerId;
49  $this->moduleId = $moduleId;
50  $this->uniqueLayoutId = $uniqueLayoutId;
51  $this->model = $model;
52  $this->modelId = $model->id;
53  $this->layoutType = $model->layoutType;
54  $this->isDefaultDashboard = $model->isDefault;
55  $this->params = $params;
56  }
57 
65  protected function getPortlets($uniqueLayoutId, $metadata)
66  {
67  assert('is_string($uniqueLayoutId)');
68  assert('is_array($metadata)');
69  $portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($uniqueLayoutId, Yii::app()->user->userModel->id, $this->params);
70  if (empty($portlets) && $this->isDefaultDashboard)
71  {
72  $portlets = Portlet::makePortletsUsingMetadataSortedByColumnIdAndPosition($uniqueLayoutId, $metadata, Yii::app()->user->userModel, $this->params);
73  Portlet::savePortlets($portlets);
74  }
76  }
77 
78  protected function renderContent()
79  {
80  $actionElementContent = $this->renderActionElementBar(false);
81  if ($actionElementContent != null)
82  {
83  $content = '<div class="view-toolbar-container clearfix"><nav class="pillbox clearfix">';
84  $content .= $actionElementContent;
85  $content .= '</nav></div>';
86  }
87  $this->portlets = $this->getPortlets($this->uniqueLayoutId, self::getMetadata());
88  $content .= $this->renderPortlets($this->uniqueLayoutId);
89  return $content;
90  }
91 
98  protected function renderActionElementBar($renderedInForm)
99  {
100  $content = parent::renderActionElementBar($renderedInForm);
101 
102  $deleteDashboardLinkActionElement = new DeleteDashboardMenuActionElement(
103  $this->controllerId,
104  $this->moduleId,
105  $this->modelId,
106  array('htmlOptions' => array('confirm' => Zurmo::t('HomeModule', 'Are you sure want to delete this dashboard?')),
107  'iconClass' => 'icon-delete')
108  );
109  $pushDashboardLinkActionElement = new PushDashboardLinkActionElement(
110  $this->controllerId,
111  $this->moduleId,
112  $this->modelId,
113  array('htmlOptions' => array('id' => 'PushDashboardLink'),
114  'iconClass' => 'icon-push-dashboard')
115  );
116  if (ActionSecurityUtil::canCurrentUserPerformAction($deleteDashboardLinkActionElement->getActionType(),
117  $this->model) && !$this->isDefaultDashboard)
118  {
119  $content .= $deleteDashboardLinkActionElement->render();
120  }
122  {
123  $content .= $pushDashboardLinkActionElement->render();
124  }
125  $content .= $this->renderChangeDashboardMenuActionContent();
126  return $content;
127  }
128 
129  protected function renderChangeDashboardMenuActionContent()
130  {
131  $dashboardsData = Dashboard::getRowsByUserId(Yii::app()->user->userModel->id);
132  if (count($dashboardsData) > 1)
133  {
134  foreach ($dashboardsData as $key => $dashboardData)
135  {
136  if ($dashboardData['id'] == $this->model->id)
137  {
138  unset($dashboardsData[$key]);
139  }
140  }
141  $changeDashboardMenuActionElement = new ChangeDashboardMenuActionElement(
142  $this->controllerId,
143  $this->moduleId,
144  $this->modelId,
145  array('htmlOptions' => array('id' => 'ChangeDashboardsMenu'),
146  'iconClass' => 'icon-change-dashboard',
147  'dashboardsData' => $dashboardsData));
148  return $changeDashboardMenuActionElement->render();
149  }
150  }
151  }
152 ?>
getPortlets($uniqueLayoutId, $metadata)
static getRowsByUserId($userId)
Definition: Dashboard.php:79
static resolvePortletsForCurrentUser(array $portlets)
static canCurrentUserPushDashboardOrLayout()
static canCurrentUserPerformAction($actionType, $model)
renderActionElementBar($renderedInForm)
Generated on Tue Jul 14 2020 07:10:33
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.