Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
KanbanBoard.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  const GROUP_BY_ATTRIBUTE_VISIBLE_VALUES = 'groupByAttributeVisibleValues';
43 
44  const SELECTED_THEME = 'selectedTheme';
45 
46  const ATTRIBUTE_SEPARATOR = '_';
47 
48  protected $model;
49 
50  protected $groupByAttribute;
51 
52  protected $groupByDataAndTranslatedLabels;
53 
54  protected $groupByAttributeVisibleValues;
55 
56  protected $selectedTheme;
57 
61  protected $active;
62 
67  protected $clearSticky = false;
68 
76  public static function resolveKanbanBoardOptionsForSearchModelFromArray($searchModel, $getArrayName, $sourceData)
77  {
78  assert('$searchModel instanceof RedBeanModel || $searchModel instanceof ModelForm');
79  assert('is_string($getArrayName)');
80  if ($searchModel->getKanbanBoard() != null && !empty($sourceData[$getArrayName]))
81  {
82  assert('$searchModel instanceof SearchForm');
83  if (isset($sourceData[$getArrayName][self::GROUP_BY_ATTRIBUTE_VISIBLE_VALUES]))
84  {
85  if (!is_array($sourceData[$getArrayName][self::GROUP_BY_ATTRIBUTE_VISIBLE_VALUES]))
86  {
87  $groupByAttributeVisibleValues = null;
88  }
89  else
90  {
91  $groupByAttributeVisibleValues = $sourceData[$getArrayName][self::GROUP_BY_ATTRIBUTE_VISIBLE_VALUES];
92  $searchModel->getKanbanBoard()->setIsActive();
93  }
94  $searchModel->getKanbanBoard()->setGroupByAttributeVisibleValues($groupByAttributeVisibleValues);
95  }
96  if (isset($sourceData[$getArrayName][self::SELECTED_THEME]))
97  {
98  if (empty($sourceData[$getArrayName][self::SELECTED_THEME]))
99  {
100  $selectedTheme = null;
101  }
102  else
103  {
104  $selectedTheme = $sourceData[$getArrayName][self::SELECTED_THEME];
105  }
106  $searchModel->getKanbanBoard()->setSelectedTheme($selectedTheme);
107  }
108  }
109  }
110 
114  public static function getGridViewWidgetPath()
115  {
116  return 'application.core.kanbanBoard.widgets.KanbanBoardExtendedGridView';
117  }
118 
124  public function __construct(RedBeanModel $model, $groupByAttribute)
125  {
126  $this->model = $model;
127  $this->groupByAttribute = $groupByAttribute;
128  if (!$this->model->{$this->groupByAttribute} instanceof CustomField)
129  {
130  throw new NotSupportedException();
131  }
132  $this->groupByDataAndTranslatedLabels = $this->resolveGroupByDataAndTranslatedLabels();
133  $this->groupByAttributeVisibleValues = array_keys($this->groupByDataAndTranslatedLabels);
134  }
135 
139  public function getIsActive()
140  {
141  return $this->active;
142  }
143 
144  public function setIsActive()
145  {
146  $this->active = true;
147  }
148 
149  public function setIsNotActive()
150  {
151  $this->active = false;
152  }
153 
157  public function getGridViewParams()
158  {
159  return array('groupByAttribute' => $this->groupByAttribute,
160  'groupByAttributeVisibleValues' => $this->groupByAttributeVisibleValues,
161  'groupByDataAndTranslatedLabels' => $this->groupByDataAndTranslatedLabels,
162  'selectedTheme' => $this->getSelectedTheme());
163  }
164 
169  {
170  return $this->groupByAttributeVisibleValues;
171  }
172 
176  public function setGroupByAttributeVisibleValues($groupByAttributeVisibleValues)
177  {
178  assert('$groupByAttributeVisibleValues === null || is_array($groupByAttributeVisibleValues)');
179  $this->groupByAttributeVisibleValues = $groupByAttributeVisibleValues;
180  }
181 
186  {
187  return $this->groupByDataAndTranslatedLabels;
188  }
189 
193  public function getSelectedTheme()
194  {
195  return $this->resolveAndGetSelectedTheme();
196  }
197 
201  public function setSelectedTheme($selectedTheme)
202  {
203  assert('is_string($selectedTheme) || $selectedTheme == null');
204  $this->selectedTheme = $selectedTheme;
205  $user = Yii::app()->user->userModel;
206  $modelName = get_class($this->model);
207  $key = $this->getSelectedThemeKeyByModelName($modelName);
208  ZurmoConfigurationUtil::setByUserAndModuleName($user, 'ZurmoModule', $key, $selectedTheme);
209  }
210 
214  public function getDefaultTheme()
215  {
216  return null;
217  }
218 
223  protected function resolveAndGetSelectedTheme()
224  {
225  $user = Yii::app()->user->userModel;
226  $modelName = get_class($this->model);
227  $key = $this->getSelectedThemeKeyByModelName($modelName);
228  if (null != $theme = ZurmoConfigurationUtil::getByUserAndModuleName($user, 'ZurmoModule', $key))
229  {
230  $this->selectedTheme = $theme;
231  }
232  else
233  {
234  $this->selectedTheme = $this->getDefaultTheme();
235  }
236  return $this->selectedTheme;
237  }
238 
239  public function getSelectedThemeKeyByModelName($modelName)
240  {
241  return $modelName . self::ATTRIBUTE_SEPARATOR . self::SELECTED_THEME;
242  }
243 
247  public function getThemeNamesAndLabels()
248  {
249  return array('' => Zurmo::t('Core', 'White'),
250  'kanban-background-football' => Zurmo::t('Core', 'Football'),
251  'kanban-background-tennis' => Zurmo::t('Core', 'Tennis'),
252  'kanban-background-motor' => Zurmo::t('Core', 'Motor Sport'),
253  'kanban-background-yoga' => Zurmo::t('Core', 'Yoga'),
254  'kanban-background-blurred-lights' => Zurmo::t('Core', 'Blurred Lights'),
255  'kanban-background-blurred-city' => Zurmo::t('Core', 'Blurred City'),
256  'kanban-background-blurred-vera' => Zurmo::t('Core', 'Vera in Blur'),
257  'kanban-background-perfect-beach' => Zurmo::t('Core', 'Perfect Beach'),
258  'kanban-background-flip-flops' => Zurmo::t('Core', 'Flip Flops'),
259  'kanban-background-blue-structure' => Zurmo::t('Core', 'Blue Structure'),
260  'kanban-background-sepia-sf' => Zurmo::t('Core', 'Sepia SF'),
261  'kanban-background-men-on-bridge' => Zurmo::t('Core', 'Men on Bridge'));
262  }
263 
264  public function getThemeColorNamesAndUnlockedAtLevel()
265  {
266  return array('' => 1,
267  'kanban-background-football' => 1,
268  'kanban-background-tennis' => 1,
269  'kanban-background-motor' => 1,
270  'kanban-background-yoga' => 1,
271  'kanban-background-blurred-lights' => 3,
272  'kanban-background-blurred-city' => 5,
273  'kanban-background-blurred-vera' => 7,
274  'kanban-background-perfect-beach' => 9,
275  'kanban-background-flip-flops' => 10,
276  'kanban-background-blue-structure' => 11,
277  'kanban-background-sepia-sf' => 13,
278  'kanban-background-men-on-bridge' => 14);
279  }
280 
281  public function setClearSticky()
282  {
283  $this->clearSticky = true;
284  }
285 
289  public function getClearSticky()
290  {
291  return $this->clearSticky;
292  }
293 
297  public function resolveVisibleValuesForAdaptedMetadata(& $metadata)
298  {
299  $clauseCount = count($metadata['clauses']);
300  $startingCount = $clauseCount + 1;
301  $structure = '';
302  $first = true;
303  //No StateIds mean the list should come up empty
304  if (count($this->groupByAttributeVisibleValues) == 0)
305  {
306  return;
307  }
308  else
309  {
310  foreach ($this->groupByAttributeVisibleValues as $value)
311  {
312  $metadata['clauses'][$startingCount] = array(
313  'attributeName' => $this->groupByAttribute,
314  'relatedAttributeName' => 'value',
315  'operatorType' => 'equals',
316  'value' => $value
317  );
318  if (!$first)
319  {
320  $structure .= ' or ';
321  }
322  $first = false;
323  $structure .= $startingCount;
324  $startingCount++;
325  }
326  }
327  if (empty($metadata['structure']))
328  {
329  $metadata['structure'] = '(' . $structure . ')';
330  }
331  else
332  {
333  $metadata['structure'] = '(' . $metadata['structure'] . ') and (' . $structure . ')';
334  }
335  }
336 
341  {
342  $dropDownModel = $this->model->{$this->groupByAttribute};
343  return CustomFieldDataUtil::getDataIndexedByDataAndTranslatedLabelsByLanguage($dropDownModel->data, Yii::app()->language);
344  }
345 }
346 ?>
static getGridViewWidgetPath()
getGroupByDataAndTranslatedLabels()
static getDataIndexedByDataAndTranslatedLabelsByLanguage(CustomFieldData $customFieldData, $language)
static setByUserAndModuleName($user, $moduleName, $key, $value, $cache=true)
static resolveKanbanBoardOptionsForSearchModelFromArray($searchModel, $getArrayName, $sourceData)
Definition: KanbanBoard.php:76
getThemeNamesAndLabels()
resolveGroupByDataAndTranslatedLabels()
__construct(RedBeanModel $model, $groupByAttribute)
getGroupByAttributeVisibleValues()
static getByUserAndModuleName($user, $moduleName, $key, $cache=true)
resolveAndGetSelectedTheme()
resolveVisibleValuesForAdaptedMetadata(&$metadata)
setSelectedTheme($selectedTheme)
setGroupByAttributeVisibleValues($groupByAttributeVisibleValues)
Generated on Tue Jul 14 2020 07:10:28
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.