Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
DefaultController.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 
38  {
43  public function actionInlineCreateSave($redirectUrl = null, $uniquePageId = null)
44  {
45  if (isset($_POST['ajax']) && ($_POST['ajax'] === 'comment-inline-edit-form' . $uniquePageId ||
46  $_POST['ajax'] === 'comment-for-task-inline-edit-form' . $uniquePageId))
47  {
48  $this->actionInlineEditValidate(new Comment());
49  }
50  $this->attemptToSaveModelFromPost(new Comment(), $redirectUrl);
51  }
52 
60  public function actionInlineEditSave($id, $redirectUrl = null, $uniquePageId = null)
61  {
62  $comment = Comment::getById((int)$id);
63  $this->checkIfUserHaveAccessToCommentEditAndDeleteAndRenderAjaxAccessFailure($comment, Yii::app()->user->userModel);
64  if (isset($_POST['ajax']) && $_POST['ajax'] === 'comment-inline-edit-form' . $id)
65  {
66  $this->actionInlineEditValidate($comment);
67  }
68  $this->attemptToSaveModelFromPost($comment, $redirectUrl);
69  }
70 
79  public function actionInlineEditCommentFromAjax($id, $relatedModelId, $relatedModelClassName, $relatedModelRelationName, $uniquePageId = null)
80  {
81  $comment = Comment::getById((int)$id);
82  $this->checkIfUserHaveAccessToCommentEditAndDeleteAndRenderAjaxAccessFailure($comment, Yii::app()->user->userModel);
83  $inlineView = CommentsElement::getRelatedModelCommentInlineEditView($id, $relatedModelId,
84  $relatedModelClassName, $relatedModelRelationName, $uniquePageId);
85  $view = new AjaxPageView($inlineView);
86  echo $view->render();
87  }
88 
89  public function actionAjaxListForRelatedModel($uniquePageId = null)
90  {
91  $getData = GetUtil::getData();
92  $relatedModelId = ArrayUtil::getArrayValue($getData, 'relatedModelId');
93  $relatedModelClassName = ArrayUtil::getArrayValue($getData, 'relatedModelClassName');
94  $relatedModelRelationName = ArrayUtil::getArrayValue($getData, 'relatedModelRelationName');
95  if (ArrayUtil::getArrayValue($getData, 'noPaging'))
96  {
97  $pageSize = null;
98  $retrievalPageSize = null;
99  }
100  else
101  {
102  $pageSize = 5;
103  $retrievalPageSize = ($pageSize + 1);
104  }
105  $commentsData = Comment::getCommentsByRelatedModelTypeIdAndPageSize($relatedModelClassName,
106  (int)$relatedModelId,
107  $retrievalPageSize);
108  $getParams = array('uniquePageId' => $uniquePageId,
109  'relatedModelId' => $relatedModelId,
110  'relatedModelClassName' => $relatedModelClassName,
111  'relatedModelRelationName' => $relatedModelRelationName);
112  $relatedModel = $relatedModelClassName::getById((int)$relatedModelId);
113  $view = new CommentsForRelatedModelView('default', 'comments', $commentsData, $relatedModel,
114  $pageSize, $getParams, $uniquePageId);
115  $content = $view->render();
116  Yii::app()->getClientScript()->setToAjaxMode();
117  Yii::app()->getClientScript()->render($content);
118  echo $content;
119  }
120 
121  public function actionDeleteViaAjax($id)
122  {
123  $comment = Comment::getById(intval($id));
124  $this->checkIfUserHaveAccessToCommentEditAndDeleteAndRenderAjaxAccessFailure($comment, Yii::app()->user->userModel);
125 
126  $deleted = $comment->delete();
127  if (!$deleted)
128  {
129  throw new FailedToDeleteModelException();
130  }
131  }
132 
133  public function actionMarkdownGuide()
134  {
135  Yii::app()->getClientScript()->setToAjaxMode();
136  $view = new ModalView($this, new CommentsMarkdownGuideView());
137  echo $view->render();
138  }
139 
140  protected function actionInlineEditValidate($model)
141  {
142  $postData = PostUtil::getData();
143  $postFormData = ArrayUtil::getArrayValue($postData, get_class($model));
144  $sanitizedPostData = PostUtil::
145  sanitizePostByDesignerTypeForSavingModel($model, $postFormData);
146  $model->setAttributes($sanitizedPostData);
147  $model->validate();
149  echo CJSON::encode($errorData);
150  Yii::app()->end(0, false);
151  }
152 
153  protected static function getZurmoControllerUtil()
154  {
155  $getData = GetUtil::getData();
156  $relatedModelId = ArrayUtil::getArrayValue($getData, 'relatedModelId');
157  $relatedModelClassName = ArrayUtil::getArrayValue($getData, 'relatedModelClassName');
158  $relatedModelRelationName = ArrayUtil::getArrayValue($getData, 'relatedModelRelationName');
159  if ($relatedModelId == null || $relatedModelClassName == null || $relatedModelRelationName == null)
160  {
161  throw new NotSupportedException();
162  }
163  $relatedModel = $relatedModelClassName::getById((int)$relatedModelId);
164  return new CommentZurmoControllerUtil($relatedModel, $relatedModelRelationName);
165  }
166 
173  {
175  {
176  $messageView = new AccessFailureAjaxView();
177  $view = new AjaxPageView($messageView);
178  echo $view->render();
179  Yii::app()->end(0, false);
180  }
181  }
182  }
183 ?>
checkIfUserHaveAccessToCommentEditAndDeleteAndRenderAjaxAccessFailure(Comment $comment, User $user)
Definition: User.php:37
actionInlineEditSave($id, $redirectUrl=null, $uniquePageId=null)
static getCommentsByRelatedModelTypeIdAndPageSize($type, $relatedId, $pageSize)
Definition: Comment.php:76
actionInlineCreateSave($redirectUrl=null, $uniquePageId=null)
actionInlineEditCommentFromAjax($id, $relatedModelId, $relatedModelClassName, $relatedModelRelationName, $uniquePageId=null)
static getArrayValue($array, $element, $defaultValue=null)
Definition: ArrayUtil.php:45
static makeErrorsDataAndResolveForOwnedModelAttributes($model)
attemptToSaveModelFromPost($model, $redirectUrlParams=null, $redirect=true, $returnOnValidate=false)
static getRelatedModelCommentInlineEditView($id, $relatedModelId, $relatedModelClassName, $relatedModelRelationName, $uniquePageId=null)
static getById($id, $modelClassName=null)
static hasUserHaveAccessToEditOrDeleteComment(Comment $comment, User $user)
static sanitizePostByDesignerTypeForSavingModel($model, $postData)
Definition: PostUtil.php:94
Generated on Sat Aug 15 2020 07:10:27
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.