Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
KanbanItem.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 
37  class KanbanItem extends RedBeanModel
38  {
39  /*
40  * Constants for task status
41  */
42  const TYPE_SOMEDAY = 1;
43 
44  const TYPE_TODO = 2;
45 
46  const TYPE_IN_PROGRESS = 3;
47 
48  const TYPE_COMPLETED = 4;
49 
53  public function __toString()
54  {
55  try
56  {
57  if (trim($this->name) == '')
58  {
59  return Zurmo::t('Core', '(Unnamed)');
60  }
61  return $this->name;
62  }
64  {
65  return '';
66  }
67  }
68 
72  public static function canSaveMetadata()
73  {
74  return true;
75  }
76 
80  public static function getDefaultMetadata()
81  {
82  $metadata = parent::getDefaultMetadata();
83  $metadata[__CLASS__] = array(
84  'members' => array(
85  'type',
86  'sortOrder'
87  ),
88  'relations' => array(
89  'kanbanRelatedItem' => array(static::HAS_ONE, 'Item', static::OWNED,
90  static::LINK_TYPE_SPECIFIC, 'kanbanrelateditem'),
91  'task' => array(static::HAS_ONE, 'Task', static::NOT_OWNED),
92  ),
93  'rules' => array(
94  array('type', 'type', 'type' => 'integer'),
95  array('sortOrder', 'type', 'type' => 'integer'),
96  ),
97  'elements' => array(
98  'kanbanRelatedItem' => 'Item',
99  'task' => 'Task'
100  ),
101  'defaultSortAttribute' => 'sortOrder',
102  'noAudit' => array(
103 
104  ),
105  );
106  return $metadata;
107  }
108 
112  protected static function translatedAttributeLabels($language)
113  {
114  return array_merge(parent::translatedAttributeLabels($language),
115  array(
116  'type' => Zurmo::t('Core', 'Type', array(), null, $language),
117  'sortOrder' => Zurmo::t('Core', 'Order', array(), null, $language),
118  'kanbanItem' => Zurmo::t('TasksModule', 'Kanban Item', array(), null, $language),
119  'task' => Zurmo::t('TasksModule', 'Task', array(), null, $language)
120  )
121  );
122  }
123 
127  public static function isTypeDeletable()
128  {
129  return true;
130  }
131 
135  public static function getTypeDropDownArray()
136  {
137  return array(
138  self::TYPE_SOMEDAY => Zurmo::t('TasksModule', 'Someday'),
139  self::TYPE_TODO => Zurmo::t('TasksModule', 'To Do'),
140  self::TYPE_IN_PROGRESS => Zurmo::t('TasksModule', 'Working On'),
141  self::TYPE_COMPLETED => Zurmo::t('Core', 'Completed'),
142  );
143  }
144 
149  public static function getTypeDisplayName($type)
150  {
151  $typeArray = self::getStatusDropDownArray();
152  return $typeArray[$type];
153  }
154 
160  public static function getByTask($taskId)
161  {
162  assert('is_int($taskId)');
163  $searchAttributeData = array();
164  $searchAttributeData['clauses'] = array(
165  1 => array(
166  'attributeName' => 'task',
167  'operatorType' => 'equals',
168  'value' => intval($taskId),
169  )
170  );
171  $searchAttributeData['structure'] = '1';
172  $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter(get_called_class());
173  $where = RedBeanModelDataProvider::makeWhere(get_called_class(), $searchAttributeData, $joinTablesAdapter);
174  $models = self::getSubset($joinTablesAdapter, null, null, $where, null);
175  if (count($models) == 0)
176  {
177  return null;
178  }
179  elseif (count($models) > 1)
180  {
181  throw new NotSupportedException();
182  }
183  else
184  {
185  return $models[0];
186  }
187  }
188 
195  public static function getMaximumSortOrderByType($taskType, Item $childObjectOfItem)
196  {
197  $models = self::getAllTasksByType($taskType, $childObjectOfItem);
198  if (count($models) == 0)
199  {
200  return 1;
201  }
202  elseif (count($models) >= 1)
203  {
204  return count($models) + 1;
205  }
206  }
207 
214  public static function getAllTasksByType($taskType, Item $childObjectOfItem)
215  {
216  assert('is_int($taskType)');
217  $searchAttributeData = array();
218  $searchAttributeData['clauses'] = array(
219  1 => array(
220  'attributeName' => 'type',
221  'operatorType' => 'equals',
222  'value' => intval($taskType),
223  ),
224  2 => array(
225  'attributeName' => 'kanbanRelatedItem',
226  'operatorType' => 'equals',
227  'value' => $childObjectOfItem->getClassId('Item'),
228  )
229  );
230  $searchAttributeData['structure'] = '(1 and 2)';
231  $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter(get_called_class());
232  $where = RedBeanModelDataProvider::makeWhere(get_called_class(), $searchAttributeData, $joinTablesAdapter);
233  $models = self::getSubset($joinTablesAdapter, null, null, $where, 'sortOrder ASC');
234  return $models;
235  }
236  }
237 ?>
static getDefaultMetadata()
Definition: KanbanItem.php:80
static getTypeDisplayName($type)
Definition: KanbanItem.php:149
getClassId($modelClassName)
static makeWhere($modelClassName, array $metadata, &$joinTablesAdapter)
static getTypeDropDownArray()
Definition: KanbanItem.php:135
static getMaximumSortOrderByType($taskType, Item $childObjectOfItem)
Definition: KanbanItem.php:195
Definition: Item.php:37
static canSaveMetadata()
Definition: KanbanItem.php:72
static getAllTasksByType($taskType, Item $childObjectOfItem)
Definition: KanbanItem.php:214
static isTypeDeletable()
Definition: KanbanItem.php:127
static translatedAttributeLabels($language)
Definition: KanbanItem.php:112
static getByTask($taskId)
Definition: KanbanItem.php:160
Generated on Sun Sep 20 2020 07:10:28
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.