Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ReportDetailsView.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 
41  {
42  protected $savedReport;
43 
47  public function __construct($controllerId, $moduleId, Report $model, $title = null, SavedReport$savedReport)
48  {
49  parent::__construct($controllerId, $moduleId, $model);
50  $this->savedReport = $savedReport;
51  }
52 
56  public static function assertModelIsValid($model)
57  {
58  assert('$model instanceof Report');
59  }
60 
64  public static function getDefaultMetadata()
65  {
66  $metadata = array(
67  'global' => array(
68  'toolbar' => array(
69  'elements' => array(
70  array('type' => 'ReportOptionsMenu',
71  'iconClass' => 'icon-options',
72  'htmlOptions' => array('id' => 'ListViewOptionsActionMenu'),
73  ),
74  array('type' => 'ReportExportMenu',
75  'iconClass' => 'icon-export',
76  'htmlOptions' => array('id' => 'ListViewExportActionMenu'),
77  ),
78  array('type' => 'ReportTogglePortletsLink',
79  'htmlOptions' => array('class' => 'hasCheckboxes'),
80  'hasRuntimeFilters' => 'eval:$this->model->hasRuntimeFilters()',
81  'hasChart' => 'eval:$this->model->hasChart()'
82  ),
83  ),
84  ),
85  ),
86  );
87  return $metadata;
88  }
89 
94  public function getTitle()
95  {
96  if ($this->model->id > 0)
97  {
98  $moduleClassName = $this->model->moduleClassName;
99  $moduleLabel = $this->getPuralModuleLabelForReportTitle($moduleClassName);
100  $typesAndLabels = Report::getTypeDropDownArray();
101  $title = strval($this->model) . ' - ' .
102  Zurmo::t('ReportsModule', '{moduleLabel} {typeLabel} Report',
103  array('{moduleLabel}' => $moduleLabel,
104  '{typeLabel}' => $typesAndLabels[$this->model->type]));
105  return $title;
106  }
107  else
108  {
109  throw new NotSupportedException();
110  }
111  }
112 
113  public function getPuralModuleLabelForReportTitle($moduleClassName)
114  {
116  $moduleLabel = $moduleClassName::getModuleLabelByTypeAndLanguage('Plural');
117  if (isset($moduleLabels[$moduleClassName]))
118  {
119  $moduleLabel = $moduleLabels[$moduleClassName];
120  }
121  return $moduleLabel;
122  }
123 
124  public function registerScripts()
125  {
126  $script = '$(".ReportSQLForPortletView").hide();';
127  Yii::app()->getClientScript()->registerScript('ReportPortletsDefaultHideScript', $script);
128  Yii::app()->getClientScript()->registerCoreScript('bbq');
129  }
130 
134  protected function renderContent()
135  {
136  $content = $this->renderTitleContent();
137  $content .= '<div class="view-toolbar-container clearfix"><nav class="pillbox clearfix">';
138  $content .= $this->renderActionElementBar(false);
139  $content .= '</nav></div>';
140  $this->registerScripts();
141  return $content;
142  }
143 
144  public function getPostTruncatedTitleContent()
145  {
146  return StarredUtil::getToggleStarStatusLink($this->savedReport, null);
147  }
148 
149  protected function shouldRenderToolBarElement($element, $elementInformation)
150  {
151  if (get_class($element) == 'ReportExportLinkActionElement' &&
152  !$this->userCanExportReport())
153  {
154  return false;
155  }
156  if (get_class($element) == 'ReportOptionsLinkActionElement')
157  {
158  $userCanEditReport = $this->userCanEditReport();
159  $userCanDeleteReport = $this->userCanDeleteReport();
160  $userCanCreateReport = $this->userCanCreateReport();
161  if (!$userCanEditReport && !$userCanDeleteReport && !$userCanCreateReport)
162  {
163  return false;
164  }
165  if (!$userCanEditReport)
166  {
167  $element->setHideEdit();
168  }
169  if (!$userCanDeleteReport)
170  {
171  $element->setHideDelete();
172  }
173  if (!$userCanCreateReport)
174  {
175  $element->setHideCopy();
176  }
177  }
178  return true;
179  }
180 
181  protected function userCanCreateReport()
182  {
183  return ActionSecurityUtil::canCurrentUserPerformAction('Create', $this->savedReport);
184  }
185 
186  protected function userCanEditReport()
187  {
188  return ActionSecurityUtil::canCurrentUserPerformAction('Edit', $this->savedReport);
189  }
190 
191  protected function userCanDeleteReport()
192  {
193  return ActionSecurityUtil::canCurrentUserPerformAction('Delete', $this->savedReport);
194  }
195 
196  protected function userCanExportReport()
197  {
198  return ActionSecurityUtil::canCurrentUserPerformAction('Export', $this->savedReport);
199  }
200  }
201 ?>
__construct($controllerId, $moduleId, Report $model, $title=null, SavedReport $savedReport)
static getReportableModulesAndLabelsForCurrentUser()
Definition: Report.php:197
static assertModelIsValid($model)
static canCurrentUserPerformAction($actionType, $model)
static getTypeDropDownArray()
Definition: Report.php:185
renderActionElementBar($renderedInForm)
Generated on Sun Aug 9 2020 07:10:34
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.