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

Merge branch 'master' of https://github.com/unaio/una

AntonLV 10 лет назад
Родитель
Сommit
2879810e1f

+ 1 - 1
modules/boonex/convos/classes/BxCnvConfig.php

@@ -67,7 +67,7 @@ class BxCnvConfig extends BxBaseModTextConfig
             'OBJECT_FORM_ENTRY' => 'bx_convos',
             'OBJECT_FORM_ENTRY_DISPLAY_VIEW' => 'bx_convos_entry_view',
             'OBJECT_FORM_ENTRY_DISPLAY_ADD' => 'bx_convos_entry_add',
-            'OBJECT_FORM_ENTRY_DISPLAY_EDIT' => '',
+            'OBJECT_FORM_ENTRY_DISPLAY_EDIT' => 'bx_convos_entry_edit',
             'OBJECT_FORM_ENTRY_DISPLAY_DELETE' => 'bx_convos_entry_delete',
             'OBJECT_MENU_ACTIONS_VIEW_ENTRY' => 'bx_convos_view', // actions menu on view entry page
             'OBJECT_MENU_ACTIONS_MY_ENTRIES' => 'bx_convos_my', // actions menu on my entries page

+ 7 - 1
modules/boonex/convos/classes/BxCnvDb.php

@@ -21,7 +21,7 @@ class BxCnvDb extends BxBaseModTextDb
 
     public function conversationToFolder($iConversationId, $iFolderId, $iProfileCollaborator, $iReadCommentsNum = -1)
     {
-        $sQuery = $this->prepare("INSERT INTO `" . $this->getPrefix() . "conv2folder` SET `conv_id` = ?, `folder_id` = ?, `collaborator` = ?, `read_comments` = ?", $iConversationId, $iFolderId, $iProfileCollaborator, $iReadCommentsNum);
+        $sQuery = $this->prepare("INSERT IGNORE INTO `" . $this->getPrefix() . "conv2folder` SET `conv_id` = ?, `folder_id` = ?, `collaborator` = ?, `read_comments` = ?", $iConversationId, $iFolderId, $iProfileCollaborator, $iReadCommentsNum);
         return $this->query($sQuery);
     }
 
@@ -37,6 +37,12 @@ class BxCnvDb extends BxBaseModTextDb
         return $this->getOne($sQuery);
     }
 
+    public function removeCollaborator($iConversationId, $iProfileId) 
+    {
+        $sQuery = $this->prepare("DELETE FROM `" . $this->getPrefix() . "conv2folder` WHERE `conv_id` = ? AND `collaborator` = ?", $iConversationId, $iProfileId);
+        return $this->query($sQuery);
+    }
+
     public function getCollaborators($iConversationId)
     {
         $sQuery = $this->prepare("SELECT `collaborator`, `read_comments` FROM `" . $this->getPrefix() . "conv2folder` WHERE `conv_id` = ?", $iConversationId);

+ 35 - 12
modules/boonex/convos/classes/BxCnvFormEntry.php

@@ -26,6 +26,16 @@ class BxCnvFormEntry extends BxBaseModTextFormEntry
         ));
     }
 
+    public function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null)
+    {
+        if ($bRet = parent::update ($iContentId, $aValsToAdd, $aTrackTextFieldsChanges)) {
+            $iFolder = $this->_oModule->_oDb->getConversationFolder($iContentId, bx_get_logged_profile_id());
+            $this->_updateParticipants ($iContentId, $iFolder, $iFolder == BX_CNV_FOLDER_DRAFTS ? true : false);
+        }
+
+        return $bRet;
+    }
+
     public function insert ($aValsToAdd = array(), $isIgnore = false)
     {
         $aValsToAdd['last_reply_timestamp'] = time();
@@ -65,23 +75,36 @@ class BxCnvFormEntry extends BxBaseModTextFormEntry
             bx_alert('system', 'check_spam', 0, getLoggedId(), array('is_spam' => &$bSpam, 'content' => $this->getCleanValue('text'), 'where' => $this->MODULE));
             $iFolder = $bSpam ? BX_CNV_FOLDER_SPAM : BX_CNV_FOLDER_INBOX;
 
-            // place conversation to "inbox" (or "spam" - in case of spam) folder
-            $aRecipients = array_unique(array_merge($this->getCleanValue('recipients'), array(bx_get_logged_profile_id())), SORT_NUMERIC);
-            foreach ($aRecipients as $iProfile) {
-                $oProfile = BxDolProfile::getInstance($iProfile);
-                if (!$oProfile)
-                    continue;
-
-                if ($bDraft && $oProfile->id() == bx_get_logged_profile_id())
-                    $this->_oModule->_oDb->moveConvo($iContentId, $oProfile->id(), $iFolder);
-                else
-                    $this->_oModule->_oDb->conversationToFolder($iContentId, $iFolder, $oProfile->id(), $oProfile->id() == bx_get_logged_profile_id() ? 0 : -1);
-            }
+            $this->_updateParticipants ($iContentId, $iFolder, $bDraft);
         }
 
         return $iContentId;
     }
 
+    protected function _updateParticipants ($iContentId, $iFolder, $bDraft) 
+    {
+        $aRecipientsOld = $this->_oModule->_oDb->getCollaborators($iContentId);
+
+        // place conversation to "inbox" (or "spam" - in case of spam) folder
+        $aRecipients = array_unique(array_merge($this->getCleanValue('recipients'), array(bx_get_logged_profile_id())), SORT_NUMERIC);
+        foreach ($aRecipients as $iProfile) {
+            $oProfile = BxDolProfile::getInstance($iProfile);
+            if (!$oProfile)
+                continue;
+
+            if ($bDraft && $oProfile->id() == bx_get_logged_profile_id())
+                $this->_oModule->_oDb->moveConvo($iContentId, $oProfile->id(), $iFolder);
+            else
+                $this->_oModule->_oDb->conversationToFolder($iContentId, $iFolder, $oProfile->id(), $oProfile->id() == bx_get_logged_profile_id() ? 0 : -1);
+        }
+
+        // remove participants
+        foreach ($aRecipientsOld as $iProfileId => $iCount) {
+            if (!in_array($iProfileId, $aRecipients))
+                $this->_oModule->_oDb->removeCollaborator($iContentId, $iProfileId);
+        }
+    }
+
     protected function genCustomInputRecipients ($aInput)
     {
         $aInput['ajax_get_suggestions'] = BX_DOL_URL_ROOT . "modules/?r=convos/ajax_get_recipients";

+ 15 - 0
modules/boonex/convos/classes/BxCnvFormsEntryHelper.php

@@ -58,6 +58,21 @@ class BxCnvFormsEntryHelper extends BxBaseModTextFormsEntryHelper
             
         return '';
     }
+
+    protected function _getProfileAndContentData ($iContentId)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+        
+        list ($oProfile, $aContentInfo) = parent::_getProfileAndContentData($iContentId);
+        if (!$aContentInfo)
+            return array($oProfile, $aContentInfo);
+
+        $aCollaborators = $this->_oModule->_oDb->getCollaborators($aContentInfo[$CNF['FIELD_ID']]);
+        if ($aCollaborators)
+            $aContentInfo['recipients'] = array_keys($aCollaborators);
+
+        return array($oProfile, $aContentInfo);
+    }
 }
 
 /** @} */

+ 5 - 0
modules/boonex/convos/install/langs/en.xml

@@ -7,6 +7,7 @@
 
 	<string name="_bx_cnv_form_entry"><![CDATA[Conversations]]></string>
 	<string name="_bx_cnv_form_entry_display_add"><![CDATA[New conversation]]></string>
+	<string name="_bx_cnv_form_entry_display_edit"><![CDATA[Edit conversation]]></string>
 	<string name="_bx_cnv_form_entry_display_delete"><![CDATA[Delete conversation]]></string>
 	<string name="_bx_cnv_form_entry_display_view"><![CDATA[View conversation]]></string>
 	<string name="_bx_cnv_form_entry_input_sys_do_submit"><![CDATA[Submit]]></string>
@@ -25,6 +26,7 @@
     <string name="_bx_cnv_form_entry_input_recipients_err"><![CDATA[Recipients is mandatory]]></string>
     <string name="_bx_cnv_form_entry_input_sys_submit_text"><![CDATA[Draft status]]></string>
     <string name="_bx_cnv_form_entry_input_sys_submit_block"><![CDATA[Submit block]]></string>
+    <string name="_bx_cnv_form_entry_input_sys_draft_id"><![CDATA[Draft ID]]></string>
 
 	<string name="_bx_cnv_acl_action_create_entry"><![CDATA[New conversation]]></string>
 	<string name="_bx_cnv_acl_action_delete_entry"><![CDATA[Delete conversation]]></string>
@@ -46,6 +48,9 @@
     <string name="_bx_cnv_page_title_folder"><![CDATA[Folder: {folder}]]></string>
     <string name="_bx_cnv_page_block_title_folder"><![CDATA[Folder: {folder}]]></string>
     <string name="_bx_cnv_page_block_title_convos"><![CDATA[Conversations]]></string>
+    <string name="_bx_cnv_page_title_sys_edit_entry"><![CDATA[Edit conversation]]></string>
+    <string name="_bx_cnv_page_title_edit_entry"><![CDATA[Edit conversation]]></string>
+    <string name="_bx_cnv_page_block_title_edit_entry"><![CDATA[Edit conversation]]></string>
 
     <string name="_bx_cnv_menu_set_title_view_entry"><![CDATA[Conversation Actions]]></string>
     <string name="_bx_cnv_menu_title_view_entry"><![CDATA[Conversation Actions]]></string>

+ 1 - 1
modules/boonex/convos/install/sql/disable.sql

@@ -8,7 +8,7 @@ DELETE FROM `sys_options_types` WHERE `id` = @iTypeId;
 
 -- PAGES
 DELETE FROM `sys_objects_page` WHERE `module` = 'bx_convos';
-DELETE FROM `sys_pages_blocks` WHERE `module` = 'bx_convos' OR `object` IN('bx_convos_create_entry', 'bx_convos_view_entry', 'bx_convos_home');
+DELETE FROM `sys_pages_blocks` WHERE `module` = 'bx_convos' OR `object` IN('bx_convos_create_entry', 'bx_posts_edit_entry', 'bx_convos_view_entry', 'bx_convos_home');
 
 -- MENU
 DELETE FROM `sys_objects_menu` WHERE `module` = 'bx_convos';

+ 7 - 0
modules/boonex/convos/install/sql/enable.sql

@@ -27,6 +27,13 @@ INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `lay
 INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES
 ('bx_convos_create_entry', 1, 'bx_convos', '_bx_cnv_page_block_title_create_entry', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_convos";s:6:"method";s:13:"entity_create";}', 0, 1, 1);
 
+-- PAGE: edit entry
+
+INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
+('bx_convos_edit_entry', '_bx_cnv_page_title_sys_edit_entry', '_bx_cnv_page_title_edit_entry', 'bx_convos', 5, 2147483647, 0, 'edit-convo', '', '', '', '', 0, 0, 0, 'BxCnvPageBrowse', 'modules/boonex/convos/classes/BxCnvPageBrowse.php');
+
+INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES
+('bx_convos_edit_entry', 1, 'bx_convos', '_bx_cnv_page_block_title_edit_entry', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:9:"bx_convos";s:6:"method";s:11:"entity_edit";}', 0, 0, 0);
 
 -- PAGE: view entry
 

+ 1 - 0
modules/boonex/convos/install/sql/install.sql

@@ -123,6 +123,7 @@ INSERT INTO `sys_objects_form`(`object`, `module`, `title`, `action`, `form_attr
 
 INSERT INTO `sys_form_displays`(`object`, `display_name`, `module`, `view_mode`, `title`) VALUES 
 ('bx_convos', 'bx_convos_entry_add', 'bx_convos', 0, '_bx_cnv_form_entry_display_add'),
+('bx_convos', 'bx_convos_entry_edit', 'bx_convos', 0, '_bx_cnv_form_entry_display_edit'),
 ('bx_convos', 'bx_convos_entry_delete', 'bx_convos', 0, '_bx_cnv_form_entry_display_delete'),
 ('bx_convos', 'bx_convos_entry_view', 'bx_convos', 1, '_bx_cnv_form_entry_display_view');
 

+ 1 - 1
modules/boonex/convos/install/sql/uninstall.sql

@@ -17,7 +17,7 @@ DELETE FROM `sys_transcoder_images_files` WHERE `transcoder_object` = 'bx_convos
 DELETE FROM `sys_objects_form` WHERE `module` = 'bx_convos';
 DELETE FROM `sys_form_displays` WHERE `module` = 'bx_convos';
 DELETE FROM `sys_form_inputs` WHERE `module` = 'bx_convos';
-DELETE FROM `sys_form_display_inputs` WHERE `display_name` IN('bx_convos_entry_add', 'bx_convos_entry_view', 'bx_convos_entry_delete');
+DELETE FROM `sys_form_display_inputs` WHERE `display_name` IN('bx_convos_entry_add', 'bx_convos_entry_edit', 'bx_convos_entry_view', 'bx_convos_entry_delete');
 
 -- STUDIO: page & widget
 

+ 6 - 1
modules/boonex/russian/data/langs/bx_convos/ru.xml

@@ -6,7 +6,8 @@
 	<string name="_bx_cnv_option_preview_messages_num"><![CDATA[Количество сообщений для предпросмотра]]></string>
 
 	<string name="_bx_cnv_form_entry"><![CDATA[Переписка]]></string>
-	<string name="_bx_cnv_form_entry_display_add"><![CDATA[Новая переписка]]></string>
+    <string name="_bx_cnv_form_entry_display_add"><![CDATA[Новая переписка]]></string>
+    <string name="_bx_cnv_form_entry_display_edit"><![CDATA[Редактирование сообщения]]></string>
 	<string name="_bx_cnv_form_entry_display_delete"><![CDATA[Удалить переписку]]></string>
 	<string name="_bx_cnv_form_entry_display_view"><![CDATA[Просмотреть переписку]]></string>
 	<string name="_bx_cnv_form_entry_input_sys_do_submit"><![CDATA[Выполнить]]></string>
@@ -25,6 +26,7 @@
     <string name="_bx_cnv_form_entry_input_recipients_err"><![CDATA[Необходимо указать хотя бы одного получателя]]></string>
     <string name="_bx_cnv_form_entry_input_sys_submit_text"><![CDATA[Статус черновика]]></string>
     <string name="_bx_cnv_form_entry_input_sys_submit_block"><![CDATA[Блок отправки сообщения]]></string>
+    <string name="_bx_cnv_form_entry_input_sys_draft_id"><![CDATA[ID черновика]]></string>
 
 	<string name="_bx_cnv_acl_action_create_entry"><![CDATA[Новое сообщение]]></string>
 	<string name="_bx_cnv_acl_action_delete_entry"><![CDATA[Удалить сообщение]]></string>
@@ -46,6 +48,9 @@
     <string name="_bx_cnv_page_title_folder"><![CDATA[Папка: {folder}]]></string>
     <string name="_bx_cnv_page_block_title_folder"><![CDATA[Папка: {folder}]]></string>
     <string name="_bx_cnv_page_block_title_convos"><![CDATA[Сообщения]]></string>
+    <string name="_bx_cnv_page_title_sys_edit_entry"><![CDATA[Редактирование сообщения]]></string>
+    <string name="_bx_cnv_page_title_edit_entry"><![CDATA[Редактирование сообщения]]></string>
+    <string name="_bx_cnv_page_block_title_edit_entry"><![CDATA[Редактирование сообщения]]></string>
 
     <string name="_bx_cnv_menu_set_title_view_entry"><![CDATA[Действия для сообщения]]></string>
     <string name="_bx_cnv_menu_title_view_entry"><![CDATA[Действия для сообщения]]></string>