Просмотр исходного кода

#135 - problem with conversation deletion + some design fixes

Alex Trofimov 11 лет назад
Родитель
Сommit
d43caedae3

+ 22 - 1
modules/boonex/convos/classes/BxCnvModule.php

@@ -290,6 +290,21 @@ class BxCnvModule extends BxBaseModTextModule
         return _t('_sys_txt_access_denied');
     }
 
+    /**
+     * Conversations can be deleted by author and/or collaborators only.
+     * Admins can't delete conversations, since it's designed for participant only, it's moved to trash actually, also it's private content.
+     */
+    public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false)
+    {
+        if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->isCollaborator($aDataEntry, bx_get_logged_profile_id()))
+            return CHECK_ACTION_RESULT_ALLOWED;
+
+        if ($this->_isModerator($isPerformAction))
+            return _t('_sys_txt_access_denied');
+
+        return parent::checkAllowedDelete ($aDataEntry, $isPerformAction);
+    }
+
     /**
      * Only collaborators can view convo
      */
@@ -298,8 +313,14 @@ class BxCnvModule extends BxBaseModTextModule
         if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = parent::checkAllowedView ($aDataEntry, $isPerformAction)))
             return $sMsg;
 
+        return $this->isCollaborator($aDataEntry, bx_get_logged_profile_id()) ? CHECK_ACTION_RESULT_ALLOWED : _t('_sys_txt_access_denied');
+    }
+
+
+    protected function isCollaborator($aDataEntry, $iProfileId)
+    {
         $aCollaborators = $this->_oDb->getCollaborators($aDataEntry[$this->_oConfig->CNF['FIELD_ID']]);
-        return isset($aCollaborators[bx_get_logged_profile_id()]) ? CHECK_ACTION_RESULT_ALLOWED : _t('_sys_txt_access_denied');
+        return isset($aCollaborators[$iProfileId]);
     }
 }
 

+ 8 - 3
modules/boonex/convos/template/css/main.css

@@ -30,9 +30,14 @@
     overflow:hidden;
 }
 
-.bx-cnv-preview .bx-def-unit-alert-middle {
-    bottom:auto;
-    top:0;
+.bx-cnv-grid-field-label {
+    display:inline-block;
+}
+
+.bx-cnv-preview .bx-cnv-grid-field-label {
+    position: absolute;
+    right: 0;
+    top: 0;
 }
 
 .bx-cnv-grid-field-messages .bx-def-unit-alert-middle {

+ 3 - 3
modules/boonex/convos/template/message_label.html

@@ -1,4 +1,4 @@
 
-<bx_if:unread_messages><div class="bx-def-unit-alert-middle bg-col-blue2-dark">__unread_messages__</div></bx_if:unread_messages>
-<bx_if:viewer_is_last_replier><div class="bx-def-unit-alert-middle"><i title="<bx_text_attribute:_bx_cnv_you_are_last_replier />" class="sys-icon reply bx-def-font-grayed"></i></div></bx_if:viewer_is_last_replier>
-<bx_if:is_read_by_all><div class="bx-def-unit-alert-middle"><i title="<bx_text_attribute:_bx_cnv_read_by_all />" class="sys-icon check bx-def-font-grayed"></i></div></bx_if:is_read_by_all>
+<bx_if:unread_messages><div class="bx-cnv-grid-field-label bx-def-margin-thd-left bx-def-unit-alert-middle bg-col-blue2-dark">__unread_messages__</div></bx_if:unread_messages>
+<bx_if:viewer_is_last_replier><div class="bx-cnv-grid-field-label bx-def-margin-thd-left"><i title="<bx_text_attribute:_bx_cnv_you_are_last_replier />" class="sys-icon reply bx-def-font-grayed"></i></div></bx_if:viewer_is_last_replier>
+<bx_if:is_read_by_all><div class="bx-cnv-grid-field-label bx-def-margin-thd-left"><i title="<bx_text_attribute:_bx_cnv_read_by_all />" class="sys-icon check bx-def-font-grayed"></i></div></bx_if:is_read_by_all>

+ 3 - 3
modules/boonex/ocean/data/template/bx_convos/message_label.html

@@ -1,4 +1,4 @@
 
-<bx_if:unread_messages><div class="bx-def-unit-alert-middle bg-col-blue3-dark">__unread_messages__</div></bx_if:unread_messages>
-<bx_if:viewer_is_last_replier><div class="bx-def-unit-alert-middle"><i title="<bx_text_attribute:_bx_cnv_you_are_last_replier />" class="sys-icon reply bx-def-font-grayed"></i></div></bx_if:viewer_is_last_replier>
-<bx_if:is_read_by_all><div class="bx-def-unit-alert-middle"><i title="<bx_text_attribute:_bx_cnv_read_by_all />" class="sys-icon check bx-def-font-grayed"></i></div></bx_if:is_read_by_all>
+<bx_if:unread_messages><div class="bx-cnv-grid-field-label bx-def-margin-thd-left bx-def-unit-alert-middle bg-col-blue3-dark">__unread_messages__</div></bx_if:unread_messages>
+<bx_if:viewer_is_last_replier><div class="bx-cnv-grid-field-label bx-def-margin-thd-left"><i title="<bx_text_attribute:_bx_cnv_you_are_last_replier />" class="sys-icon reply bx-def-font-grayed"></i></div></bx_if:viewer_is_last_replier>
+<bx_if:is_read_by_all><div class="bx-cnv-grid-field-label bx-def-margin-thd-left"><i title="<bx_text_attribute:_bx_cnv_read_by_all />" class="sys-icon check bx-def-font-grayed"></i></div></bx_if:is_read_by_all>

+ 5 - 1
modules/boonex/ocean/data/template/system/css/default.less

@@ -10,4 +10,8 @@
 
 .bx-def-unit-info-title {
 	font-weight: bold;
-}
+}
+
+.bx-def-unit-alert-middle {
+    .line-height(@bx-font-size-middle);
+}