Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
TaskCheckItemsController.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 113 McHenry Road Suite 207,
24  * Buffalo Grove, IL 60089, USA. or at email address contact@zurmo.com.
25  ********************************************************************************/
26 
28  {
33  public function actionInlineCreateTaskCheckItemSave($relatedModelId, $relatedModelClassName,
34  $relatedModelRelationName, $redirectUrl = null)
35  {
36  if (isset($_POST['ajax']) && $_POST['ajax'] === 'task-check-item-inline-edit-form')
37  {
39  }
40  $taskCheckListItem = new TaskCheckListItem();
41  $postData = PostUtil::getData();
42  $postFormData = ArrayUtil::getArrayValue($postData, get_class($taskCheckListItem));
43  $taskCheckListItem->name = $postFormData['name'];
44  $task = Task::getById(intval($relatedModelId));
45  $task->checkListItems->add($taskCheckListItem);
46  $saved = $task->save();
47  if (!$saved)
48  {
49  throw new FailedToSaveModelException();
50  }
51  if ($task->project->id > 0)
52  {
53  ProjectsUtil::logTaskCheckItemEvent($task, $taskCheckListItem);
54  }
55  if ($redirectUrl != null)
56  {
57  $this->redirect($redirectUrl);
58  }
59  }
60 
66  public function actionInlineCreateTaskCheckItemFromAjax($id, $uniquePageId)
67  {
68  $taskCheckListItem = new TaskCheckListItem();
69  $redirectUrl = Yii::app()->createUrl('/tasks/taskCheckItems/inlineCreateTaskCheckItemFromAjax',
70  array('id' => $id,
71  'uniquePageId' => $uniquePageId));
72  $urlParameters = array('relatedModelId' => $id,
73  'relatedModelClassName' => 'Task',
74  'relatedModelRelationName' => 'checkListItems',
75  'redirectUrl' => $redirectUrl); //After save, the url to go to.
76  $inlineView = new TaskCheckItemInlineEditView($taskCheckListItem, 'taskCheckItems',
77  'tasks', 'inlineCreateTaskCheckItemSave', $urlParameters, $uniquePageId);
78  $view = new AjaxPageView($inlineView);
79  echo $view->render();
80  }
81 
85  protected function actionInlineEditValidate($model)
86  {
87  $postData = PostUtil::getData();
88  $postFormData = ArrayUtil::getArrayValue($postData, get_class($model));
89  $sanitizedPostData = PostUtil::
90  sanitizePostByDesignerTypeForSavingModel($model, $postFormData);
91  $model->setAttributes($sanitizedPostData);
92  $model->validate();
94  echo CJSON::encode($errorData);
95  Yii::app()->end(0, false);
96  }
97 
102  public function actionAjaxCheckItemListForRelatedTaskModel($uniquePageId = null)
103  {
104  $getData = GetUtil::getData();
105  $taskId = ArrayUtil::getArrayValue($getData, 'relatedModelId');
106  $taskCheckListItem = TaskCheckListItem::getByTask((int)$taskId);
107  $getParams = array('uniquePageId' => $uniquePageId,
108  'relatedModelId' => $taskId,
109  'relatedModelClassName' => 'Task',
110  'relatedModelRelationName' => 'checkListItems');
111  $task = Task::getById((int)$taskId);
112  $view = new TaskCheckListItemsForTaskView('taskCheckItems', 'tasks',
113  $taskCheckListItem, $task,
114  null, $getParams);
115  $content = $view->render();
116  Yii::app()->getClientScript()->setToAjaxMode();
117  Yii::app()->getClientScript()->render($content);
118  echo $content;
119  }
120 
126  public function actionUpdateStatusViaAjax($id, $checkListItemCompleted)
127  {
128  $taskCheckListItem = TaskCheckListItem::getById(intval($id));
129  $taskCheckListItem->completed = (bool)$checkListItemCompleted;
130  $taskCheckListItem->unrestrictedSave();
131  }
132 
138  public function actionUpdateSortViaAjax()
139  {
140  if (isset($_GET['SortedTaskCheckListItems']) && is_array($_GET['SortedTaskCheckListItems']))
141  {
142  foreach ($_GET['SortedTaskCheckListItems'] as $sortIndex => $checkListItemId)
143  {
144  $taskCheckListItem = TaskCheckListItem::getById(intval($checkListItemId));
145  $taskCheckListItem->sortOrder = $sortIndex;
146  $taskCheckListItem->unrestrictedSave();
147  }
148  }
149  }
150 
154  public function actionUpdateNameViaAjax($id, $name)
155  {
156  $taskCheckListItem = TaskCheckListItem::getById(intval($id));
157  $taskCheckListItem->name = $name;
158  $taskCheckListItem->unrestrictedSave();
159  echo $name;
160  }
161 
165  public function actionDeleteCheckListItem($id, $taskId)
166  {
167  $task = Task::getById((int)$taskId);
168  $taskCheckListItem = TaskCheckListItem::getById(intval($id));
169  $task->checkListItems->remove($taskCheckListItem);
170  $saved = $task->save();
171  if (!$saved)
172  {
173  throw new FailedToSaveModelException();
174  }
175  $getParams = array('uniquePageId' => null,
176  'relatedModelId' => $task->id,
177  'relatedModelClassName' => 'Task',
178  'relatedModelRelationName' => 'checkListItems');
179  $url = Yii::app()->createUrl('tasks/taskCheckItems/ajaxCheckItemListForRelatedTaskModel', $getParams);
180  $this->redirect($url);
181  }
182  }
183 ?>
actionInlineCreateTaskCheckItemFromAjax($id, $uniquePageId)
static getByTask($taskId)
static getArrayValue($array, $element, $defaultValue=null)
Definition: ArrayUtil.php:45
static makeErrorsDataAndResolveForOwnedModelAttributes($model)
actionUpdateStatusViaAjax($id, $checkListItemCompleted)
actionInlineCreateTaskCheckItemSave($relatedModelId, $relatedModelClassName, $relatedModelRelationName, $redirectUrl=null)
static getById($id, $modelClassName=null)
actionAjaxCheckItemListForRelatedTaskModel($uniquePageId=null)
static logTaskCheckItemEvent(Task $task, TaskCheckListItem $taskCheckListItem)
static sanitizePostByDesignerTypeForSavingModel($model, $postData)
Definition: PostUtil.php:94
Generated on Wed Sep 30 2020 07:10:35
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.