diff --git a/protected/models/Content.php b/protected/models/Content.php index b563f6a005..1066e4ccab 100644 --- a/protected/models/Content.php +++ b/protected/models/Content.php @@ -285,14 +285,19 @@ class Content extends CActiveRecord public function canDelete($userId = "") { - if (HSetting::Get('canAdminAlwaysDeleteContent', 'security') == 1 && Yii::app()->user->isAdmin()) - return true; - if ($userId == "") $userId = Yii::app()->user->id; if ($this->created_by == $userId) return true; + + if (Yii::app()->user->isAdmin()) { + return true; + } + + if ($this->container instanceof Space && $this->container->isAdmin($userId)) { + return true; + } return false; } diff --git a/protected/modules_core/comment/models/Comment.php b/protected/modules_core/comment/models/Comment.php index 83e7ab70a6..9f05cd8ae2 100644 --- a/protected/modules_core/comment/models/Comment.php +++ b/protected/modules_core/comment/models/Comment.php @@ -172,4 +172,24 @@ class Comment extends HActiveRecordContentAddon return Yii::t('CommentModule.models_comment', 'Comment') . " \"" . Helpers::truncateText($this->message, 40) . "\""; } + public function canDelete($userId = "") + { + + if ($userId == "") + $userId = Yii::app()->user->id; + + if ($this->created_by == $userId) + return true; + + if (Yii::app()->user->isAdmin()) { + return true; + } + + if ($this->content->container instanceof Space && $this->content->container->isAdmin($userId)) { + return true; + } + + return false; + } + } diff --git a/protected/modules_core/comment/widgets/views/showComment.php b/protected/modules_core/comment/widgets/views/showComment.php index e1763dbd21..88aaaea751 100644 --- a/protected/modules_core/comment/widgets/views/showComment.php +++ b/protected/modules_core/comment/widgets/views/showComment.php @@ -9,40 +9,49 @@ * @since 0.5 */ ?> +canWrite(); +$canDelete = $comment->canDelete(); +?>