AntonLV 8 лет назад
Родитель
Сommit
afddff0667

+ 9 - 3
modules/boonex/russian/data/langs/bx_timeline/ru.xml

@@ -17,6 +17,7 @@
 	<string name="_bx_timeline_form_post"><![CDATA[Сообщение]]></string>
 	<string name="_bx_timeline_form_post_display_add"><![CDATA[Написать сообщение]]></string>
 	<string name="_bx_timeline_form_post_display_add_public"><![CDATA[Написать публичное сообщение]]></string>
+	<string name="_bx_timeline_form_post_display_edit"><![CDATA[Изменить сообщение]]></string>
 	<string name="_bx_timeline_form_post_input_sys_owner_id"><![CDATA[ID владельца]]></string>
 	<string name="_bx_timeline_form_post_input_sys_action"><![CDATA[Действие]]></string>
 	<string name="_bx_timeline_form_post_input_sys_type"><![CDATA[Тип]]></string>
@@ -36,6 +37,8 @@
 	<string name="_bx_timeline_form_post_input_sys_attachments"><![CDATA[Прикрепления]]></string>
 	<string name="_bx_timeline_form_post_input_sys_do_submit"><![CDATA[Создать]]></string>
 	<string name="_bx_timeline_form_post_input_do_submit"><![CDATA[Создать]]></string>
+	<string name="_bx_timeline_form_post_input_sys_do_cancel"><![CDATA[Отмена]]></string>
+    <string name="_bx_timeline_form_post_input_do_cancel"><![CDATA[Отмена]]></string>
 
 	<string name="_bx_timeline_form_attach_link"><![CDATA[Прикрепить ссылку]]></string>
 	<string name="_bx_timeline_form_attach_link_display_add"><![CDATA[Прикрепить ссылку]]></string>
@@ -48,10 +51,11 @@
 
 	<string name="_bx_timeline_privacy_view"><![CDATA[Просматривать события]]></string>
 
-	<string name="_bx_timeline_acl_action_post"><![CDATA[Сообщение]]></string>
-	<string name="_bx_timeline_acl_action_delete"><![CDATA[Удалить]]></string>
+	<string name="_bx_timeline_acl_action_post"><![CDATA[Писать сообщения]]></string>
+	<string name="_bx_timeline_acl_action_edit"><![CDATA[Изменять любое сообщение]]></string>
+	<string name="_bx_timeline_acl_action_delete"><![CDATA[Удалять любое сообщение]]></string>
 	<string name="_bx_timeline_acl_action_vote"><![CDATA[Голосовать]]></string>
-	<string name="_bx_timeline_acl_action_repost"><![CDATA[Сделать репост]]></string>
+	<string name="_bx_timeline_acl_action_repost"><![CDATA[Делать репост]]></string>
 	<string name="_bx_timeline_acl_action_send"><![CDATA[Послать]]></string>
 	<string name="_bx_timeline_acl_action_pin"><![CDATA[Прикреплять]]></string>
 	<string name="_bx_timeline_acl_action_promote"><![CDATA[Рекламировать]]></string>
@@ -112,6 +116,8 @@
     <string name="_bx_timeline_menu_item_title_item_promote"><![CDATA[Рекламировать]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_unpromote"><![CDATA[Не рекламировать]]></string>
     <string name="_bx_timeline_menu_item_title_item_unpromote"><![CDATA[Не рекламировать]]></string>
+    <string name="_bx_timeline_menu_item_title_system_item_edit"><![CDATA[Изменить]]></string>
+    <string name="_bx_timeline_menu_item_title_item_edit"><![CDATA[Изменить]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_delete"><![CDATA[Удалить]]></string>
     <string name="_bx_timeline_menu_item_title_item_delete"><![CDATA[Удалить]]></string>
 

+ 16 - 2
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -13,6 +13,7 @@ bx_import('BxDolPrivacy');
 
 class BxTimelineConfig extends BxBaseModNotificationsConfig
 {
+    protected $_bAllowEdit;
     protected $_bAllowDelete;
 
     protected $_iRssLength;
@@ -52,12 +53,16 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         	'FIELD_ADDED' => 'date',
         	'FIELD_TITLE' => 'title',
         	'FIELD_TEXT' => 'description',
+        	'FIELD_PHOTO' => 'photo',
+        	'FIELD_CONTROLS' => 'controls',
         	'FIELD_LOCATION_PREFIX' => 'location',
 
             // page URIs
         	'URL_HOME' => 'page.php?i=timeline-view-home',
 
         	// objects
+        	'OBJECT_STORAGE' => $this->_sName . '_photos',
+            'OBJECT_IMAGES_TRANSCODER_PREVIEW' => $this->_sName . '_photos_preview',
         	'OBJECT_METATAGS' => $this->_sName,
             'OBJECT_COMMENTS' => $this->_sName,
         	'OBJECT_VIEWS' => $this->_sName,
@@ -87,9 +92,9 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         	'report' => $this->CNF['OBJECT_REPORTS'],
         	'metatags' => $this->_sName,
 
-        	'storage_photos' => $this->_sName . '_photos',
+        	'storage_photos' => $this->CNF['OBJECT_STORAGE'],
         	'storage_videos' => $this->_sName . '_videos',
-        	'transcoder_photos_preview' => $this->_sName . '_photos_preview',
+        	'transcoder_photos_preview' => $this->CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW'],
         	'transcoder_photos_view' => $this->_sName . '_photos_view',
         	'transcoder_photos_big' => $this->_sName . '_photos_big',
         	'transcoder_videos_poster' => $this->_sName . '_videos_poster',
@@ -106,6 +111,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         	'form_attach_link' => $this->_sName . '_attach_link',
         	'form_display_post_add' => $this->_sName . '_post_add',
         	'form_display_post_add_public' => $this->_sName . '_post_add_public',
+            'form_display_post_edit' => $this->_sName . '_post_edit',
         	'form_display_attach_link_add' => $this->_sName . '_attach_link_add'
         ));
 
@@ -135,6 +141,8 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         $sHpS = BX_TIMELINE_VIEW_SEARCH;
         $this->_aHtmlIds = array(
         	'view' => array(
+                'edit_form' => $sHp . '-edit-',
+                
         		'main_' . $sHpI => $sHp . '-' . $sHpI,
         		'item_' . $sHpI => $sHp . '-item-' . $sHpI . '-',
                 'item_popup_' . $sHpI => $sHp . '-item-popup-' . $sHpI,
@@ -193,6 +201,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
     	parent::init($oDb);
 
     	$sOptionPrefix = $this->getPrefix('option');
+    	$this->_bAllowEdit = getParam($sOptionPrefix . 'enable_edit') == 'on';
         $this->_bAllowDelete = getParam($sOptionPrefix . 'enable_delete') == 'on';
 
         $this->_aPerPage = array(
@@ -207,6 +216,11 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         $this->_iCharsDisplayMaxTitle = 20;
     }
 
+    public function isAllowEdit()
+    {
+        return $this->_bAllowEdit;
+    }
+
     public function isAllowDelete()
     {
         return $this->_bAllowDelete;

+ 5 - 0
modules/boonex/timeline/classes/BxTimelineMenuItemManage.php

@@ -77,6 +77,11 @@ class BxTimelineMenuItemManage extends BxTemplMenu
 				$aCheckFuncParams = array($this->_aEvent);
                 break;
 
+            case 'item-edit':
+                $sCheckFuncName = 'isAllowedEdit';
+				$aCheckFuncParams = array($this->_aEvent);
+                break;
+
             case 'item-delete':
                 $sCheckFuncName = 'isAllowedDelete';
 				$aCheckFuncParams = array($this->_aEvent);

+ 122 - 23
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -59,23 +59,24 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
      */
     public function actionPost()
     {
-        $sType = bx_process_input($_POST['type']);
-        $sMethod = 'getForm' . ucfirst($sType);
-        if(!method_exists($this, $sMethod)) {
-            echoJson(array());
-            return;
-        }
+        $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
+
+        $mixedAllowed = $this->isAllowedPost(true);
+        if($mixedAllowed !== true)
+            return echoJson(array('message' => strip_tags($mixedAllowed)));
+
+        echoJson($this->getFormPost());
+    }
 
+    public function actionEdit($iId)
+    {
         $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
 
         $mixedAllowed = $this->isAllowedPost(true);
-        if($mixedAllowed !== true) {
-            echoJson(array('message' => strip_tags($mixedAllowed)));
-            return;
-        }
+        if($mixedAllowed !== true)
+            return echoJson(array('message' => strip_tags($mixedAllowed)));
 
-        $aResult = $this->$sMethod();
-        echoJson($aResult);
+        echoJson($this->getFormEdit($iId));
     }
 
 	function actionPin()
@@ -202,10 +203,16 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
     function actionGetPost()
     {
-        $sView = bx_process_input(bx_get('view'));
         $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
 
-        $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => bx_process_input(bx_get('id'), BX_DATA_INT)));
+        $sJsObject = bx_process_input(bx_get('js_object'));
+        if(empty($sJsObject))
+            $sJsObject = $this->_oConfig->getJsObject('post');
+
+        $sView = bx_process_input(bx_get('view'));
+        $iId = bx_process_input(bx_get('id'), BX_DATA_INT);
+
+        $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
         if(empty($aEvent) || !is_array($aEvent))
             return echoJson(array());
 
@@ -218,7 +225,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         		'owner_id' => $this->_iOwnerId, 
         		'dynamic_mode' => true
             )),
-            'eval' => $this->_oConfig->getJsObject('post') . "._onGetPost(oData)"
+            'eval' => $sJsObject . "._onGetPost(oData)"
         ));
     }
 
@@ -237,18 +244,18 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         ));
     }
 
-    public function actionGetPostForm($sType)
+    public function actionGetPostForm()
     {
         $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
 
-        $sMethod = 'getForm' . ucfirst($sType);
-        if(!method_exists($this, $sMethod)) {
-            echoJson(array());
-            return;
-        }
-        $aResult = $this->$sMethod();
+        echoJson($this->getFormPost());
+    }
 
-        echoJson($aResult);
+    public function actionGetEditForm($iId)
+    {
+        $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
+
+        echoJson($this->getFormEdit($iId));
     }
 
     public function actionGetComments()
@@ -1441,6 +1448,69 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         return array('form' => $oForm->getCode(), 'form_id' => $oForm->id);
     }
 
+    public function getFormEdit($iId, $aParams = array())
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $aEvent = $this->_oDb->getEvents(array('browse' => 'id', 'value' => $iId));
+        if(empty($aEvent) || !is_array($aEvent))
+            return array();
+
+        $aContent = unserialize($aEvent['content']);
+        if(is_array($aContent) && !empty($aContent['text']))
+            $aEvent['text'] = $aContent['text'];
+
+        $sFormObject = !empty($aParams['form_object']) ? $aParams['form_object'] : 'form_post';
+        $sFormDisplay = !empty($aParams['form_display']) ? $aParams['form_display'] : 'form_display_post_edit';
+        $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject($sFormObject), $this->_oConfig->getObject($sFormDisplay), $this->_oTemplate);
+        $oForm->setId($this->_oConfig->getHtmlIds('view', 'edit_form') . $iId);
+
+        $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'edit/' . $iId ;
+        foreach($oForm->aInputs[$CNF['FIELD_CONTROLS']] as $mixedIndex => $aInput) {
+            if(!is_numeric($mixedIndex))
+                continue;
+
+            $oForm->aInputs[$CNF['FIELD_CONTROLS']][$mixedIndex]['attrs'] = bx_replace_markers($aInput['attrs'], array(
+                'js_object_view' => $this->_oConfig->getJsObject('view'),
+            	'content_id' => $iId
+            ));
+        }
+
+        $oForm->initChecker($aEvent);
+        if($oForm->isSubmittedAndValid()) {
+            $aContent = array();
+
+            //--- Process Text ---//
+            $sText = $oForm->getCleanValue('text');
+            $sText = $this->_prepareTextForSave($sText);
+            $bText = !empty($sText);
+            unset($oForm->aInputs['text']);
+
+            if($bText)
+            	$aContent['text'] = $sText;
+
+            //--- Process Privacy ---//
+            $iObjectPrivacyView = (int)$oForm->getCleanValue('object_privacy_view');
+            if(empty($iObjectPrivacyView))
+                $iObjectPrivacyView = $this->_oConfig->getPrivacyViewDefault('object');
+
+            if(!$oForm->update($iId, array('object_privacy_view' => $iObjectPrivacyView,'content' => serialize($aContent))))
+                return array('message' => _t('_bx_timeline_txt_err_cannot_perform_action'));
+
+            return array(
+                'id' => $iId,
+            	'eval' => $this->_oConfig->getJsObject('view') . '.onEditPostSubmit(oData)'
+            );
+        }
+
+        return array(
+            'id' => $iId, 
+        	'form' => $oForm->getCode(), 
+        	'form_id' => $oForm->id,
+        	'eval' => $this->_oConfig->getJsObject('view') . '.onEditPost(oData)'
+        );
+    }
+
     public function getCmtsObject($sSystem, $iId)
     {
         if(empty($sSystem) || (int)$iId == 0)
@@ -1535,6 +1605,30 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 		return true;
     }
 
+    public function isAllowedEdit($aEvent, $bPerform = false)
+    {
+        //--- System posts cannot be edited at all.
+        if(!isLogged() || !$this->_oConfig->isCommon($aEvent['type'], $aEvent['action']))
+            return false;
+
+        if(isAdmin())
+            return true;
+
+        $iUserId = (int)$this->getUserId();
+        $iOwnerId = (int)$aEvent['owner_id'];
+        $iObjectId = (int)$aEvent['object_id'];
+        if($iObjectId == $iUserId && $this->_oConfig->isAllowEdit())
+           return true;
+
+        $aCheckResult = checkActionModule($iUserId, 'edit', $this->getName(), $bPerform);
+
+        $oProfileOwner = BxDolProfile::getInstance($iOwnerId);
+        if($oProfileOwner !== false)
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_edit', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
+
+        return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
+    }
+
     public function isAllowedDelete($aEvent, $bPerform = false)
     {
         if(!isLogged())
@@ -1558,6 +1652,11 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         return $aCheckResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED ? $aCheckResult[CHECK_ACTION_MESSAGE] : true;
     }
 
+    protected function _isAllowedModerate($sAction, $aEvent, $bPerform = false)
+    {
+        
+    }
+
     public function isAllowedComment($aEvent, $bPerform = false)
     {
         $mixedComments = $this->getCommentsData($aEvent['comments']);

+ 8 - 1
modules/boonex/timeline/install/langs/en.xml

@@ -4,6 +4,7 @@
 	<string name="_bx_timeline"><![CDATA[Timeline]]></string>
 	<string name="_bx_timeline_cmts"><![CDATA[Timelines' Comments]]></string>
 
+    <string name="_bx_timeline_option_enable_edit"><![CDATA[Allow Timeline owner to edit items]]></string>
 	<string name="_bx_timeline_option_enable_delete"><![CDATA[Allow Timeline owner to remove items]]></string>
 	<string name="_bx_timeline_option_events_per_page_profile"><![CDATA[Number of items on profile page]]></string>
 	<string name="_bx_timeline_option_events_per_page_account"><![CDATA[Number of items on dashboard page]]></string>
@@ -17,6 +18,7 @@
 	<string name="_bx_timeline_form_post"><![CDATA[Post]]></string>
 	<string name="_bx_timeline_form_post_display_add"><![CDATA[Write Post]]></string>
 	<string name="_bx_timeline_form_post_display_add_public"><![CDATA[Write Public Post]]></string>
+	<string name="_bx_timeline_form_post_display_edit"><![CDATA[Edit Post]]></string>
 	<string name="_bx_timeline_form_post_input_sys_owner_id"><![CDATA[Owner ID]]></string>
 	<string name="_bx_timeline_form_post_input_sys_action"><![CDATA[Action]]></string>
 	<string name="_bx_timeline_form_post_input_sys_type"><![CDATA[Type]]></string>
@@ -36,6 +38,8 @@
 	<string name="_bx_timeline_form_post_input_sys_attachments"><![CDATA[Attachments]]></string>
 	<string name="_bx_timeline_form_post_input_sys_do_submit"><![CDATA[Post]]></string>
 	<string name="_bx_timeline_form_post_input_do_submit"><![CDATA[Post]]></string>
+	<string name="_bx_timeline_form_post_input_sys_do_cancel"><![CDATA[Cancel]]></string>
+    <string name="_bx_timeline_form_post_input_do_cancel"><![CDATA[Cancel]]></string>
 
 	<string name="_bx_timeline_form_attach_link"><![CDATA[Attach Link]]></string>
 	<string name="_bx_timeline_form_attach_link_display_add"><![CDATA[Attach Link]]></string>
@@ -49,7 +53,8 @@
 	<string name="_bx_timeline_privacy_view"><![CDATA[View event]]></string>
 
 	<string name="_bx_timeline_acl_action_post"><![CDATA[Post]]></string>
-	<string name="_bx_timeline_acl_action_delete"><![CDATA[Delete]]></string>
+	<string name="_bx_timeline_acl_action_edit"><![CDATA[Edit Any Post]]></string>
+	<string name="_bx_timeline_acl_action_delete"><![CDATA[Delete Any Post]]></string>
 	<string name="_bx_timeline_acl_action_vote"><![CDATA[Vote]]></string>
 	<string name="_bx_timeline_acl_action_repost"><![CDATA[Repost]]></string>
 	<string name="_bx_timeline_acl_action_send"><![CDATA[Send]]></string>
@@ -112,6 +117,8 @@
     <string name="_bx_timeline_menu_item_title_item_promote"><![CDATA[Promote]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_unpromote"><![CDATA[Unpromote]]></string>
     <string name="_bx_timeline_menu_item_title_item_unpromote"><![CDATA[Unpromote]]></string>
+    <string name="_bx_timeline_menu_item_title_system_item_edit"><![CDATA[Edit]]></string>
+    <string name="_bx_timeline_menu_item_title_item_edit"><![CDATA[Edit]]></string>
     <string name="_bx_timeline_menu_item_title_system_item_delete"><![CDATA[Delete]]></string>
     <string name="_bx_timeline_menu_item_title_item_delete"><![CDATA[Delete]]></string>
 

+ 12 - 2
modules/boonex/timeline/install/sql/enable.sql

@@ -74,7 +74,8 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-unpin', '_bx_timeline_menu_item_title_system_item_unpin', '_bx_timeline_menu_item_title_item_unpin', 'javascript:void(0)', 'javascript:{js_object_view}.pinPost(this, {content_id}, 0)', '_self', 'thumb-tack', '', 2147483647, 1, 0, 1),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-promote', '_bx_timeline_menu_item_title_system_item_promote', '_bx_timeline_menu_item_title_item_promote', 'javascript:void(0)', 'javascript:{js_object_view}.promotePost(this, {content_id}, 1)', '_self', 'certificate ', '', 2147483647, 1, 0, 2),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-unpromote', '_bx_timeline_menu_item_title_system_item_unpromote', '_bx_timeline_menu_item_title_item_unpromote', 'javascript:void(0)', 'javascript:{js_object_view}.promotePost(this, {content_id}, 0)', '_self', 'certificate', '', 2147483647, 1, 0, 3),
-('bx_timeline_menu_item_manage', 'bx_timeline', 'item-delete', '_bx_timeline_menu_item_title_system_item_delete', '_bx_timeline_menu_item_title_item_delete', 'javascript:void(0)', 'javascript:{js_object_view}.deletePost(this, {content_id})', '_self', 'remove', '', 2147483647, 1, 0, 4);
+('bx_timeline_menu_item_manage', 'bx_timeline', 'item-edit', '_bx_timeline_menu_item_title_system_item_edit', '_bx_timeline_menu_item_title_item_edit', 'javascript:void(0)', 'javascript:{js_object_view}.editPost(this, {content_id})', '_self', 'pencil', '', 2147483647, 1, 0, 4),
+('bx_timeline_menu_item_manage', 'bx_timeline', 'item-delete', '_bx_timeline_menu_item_title_system_item_delete', '_bx_timeline_menu_item_title_item_delete', 'javascript:void(0)', 'javascript:{js_object_view}.deletePost(this, {content_id})', '_self', 'remove', '', 2147483647, 1, 0, 5);
 
 -- MENU: Item Actions (Comment, Vote, Share, Report, etc)
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
@@ -125,6 +126,7 @@ VALUES (@iTypeId, 'bx_timeline', '_bx_timeline', 1);
 SET @iCategId = LAST_INSERT_ID();
 
 INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `check`, `check_params`, `check_error`, `extra`, `order`) VALUES
+('bx_timeline_enable_edit', 'on', @iCategId, '_bx_timeline_option_enable_edit', 'checkbox', '', '', '', '', 0),
 ('bx_timeline_enable_delete', 'on', @iCategId, '_bx_timeline_option_enable_delete', 'checkbox', '', '', '', '', 1),
 ('bx_timeline_events_per_page_profile', '12', @iCategId, '_bx_timeline_option_events_per_page_profile', 'digit', '', '', '', '', 2),
 ('bx_timeline_events_per_page_account', '12', @iCategId, '_bx_timeline_option_events_per_page_account', 'digit', '', '', '', '', 3),
@@ -145,6 +147,10 @@ INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`,
 ('bx_timeline', 'post', NULL, '_bx_timeline_acl_action_post', '', 1, 3);
 SET @iIdActionPost = LAST_INSERT_ID();
 
+INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
+('bx_timeline', 'edit', NULL, '_bx_timeline_acl_action_edit', '', 1, 3);
+SET @iIdActionEdit = LAST_INSERT_ID();
+
 INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
 ('bx_timeline', 'delete', NULL, '_bx_timeline_acl_action_delete', '', 1, 3);
 SET @iIdActionDelete = LAST_INSERT_ID();
@@ -187,7 +193,11 @@ INSERT INTO `sys_acl_matrix` (`IDLevel`, `IDAction`) VALUES
 (@iAdministrator, @iIdActionPost),
 (@iPremium, @iIdActionPost),
 
--- delete
+-- edit any post
+(@iModerator, @iIdActionEdit),
+(@iAdministrator, @iIdActionEdit),
+
+-- delete any post
 (@iModerator, @iIdActionDelete),
 (@iAdministrator, @iIdActionDelete),
 

+ 17 - 3
modules/boonex/timeline/install/sql/install.sql

@@ -288,7 +288,9 @@ INSERT INTO `sys_objects_form` (`object`, `module`, `title`, `action`, `form_att
 
 INSERT INTO `sys_form_displays` (`display_name`, `module`, `object`, `title`, `view_mode`) VALUES
 ('bx_timeline_post_add', @sName, 'bx_timeline_post', '_bx_timeline_form_post_display_add', 0),
-('bx_timeline_post_add_public', @sName, 'bx_timeline_post', '_bx_timeline_form_post_display_add_public', 0);
+('bx_timeline_post_add_public', @sName, 'bx_timeline_post', '_bx_timeline_form_post_display_add_public', 0),
+
+('bx_timeline_post_edit', @sName, 'bx_timeline_post', '_bx_timeline_form_post_display_edit', 0);
 
 INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `checked`, `type`, `caption_system`, `caption`, `info`, `required`, `collapsed`, `html`, `attrs`, `attrs_tr`, `attrs_wrapper`, `checker_func`, `checker_params`, `checker_error`, `db_pass`, `db_params`, `editable`, `deletable`) VALUES
 ('bx_timeline_post', @sName, 'type', 'post', '', 0, 'hidden', '_bx_timeline_form_post_input_sys_type', '', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0),
@@ -301,7 +303,9 @@ INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `c
 ('bx_timeline_post', @sName, 'photo', 'a:1:{i:0;s:24:"bx_timeline_simple_photo";}', 'a:1:{s:24:"bx_timeline_simple_photo";s:26:"_sys_uploader_simple_title";}', 0, 'files', '_bx_timeline_form_post_input_sys_photo', '_bx_timeline_form_post_input_photo', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_timeline_post', @sName, 'video', 'a:1:{i:0;s:24:"bx_timeline_simple_video";}', 'a:1:{s:24:"bx_timeline_simple_video";s:26:"_sys_uploader_simple_title";}', 0, 'files', '_bx_timeline_form_post_input_sys_video', '_bx_timeline_form_post_input_video', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_timeline_post', @sName, 'attachments', '', '', 0, 'custom', '_bx_timeline_form_post_input_sys_attachments', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
-('bx_timeline_post', @sName, 'do_submit', '_bx_timeline_form_post_input_do_submit', '', 0, 'submit', '_bx_timeline_form_post_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0);
+('bx_timeline_post', @sName, 'controls', '', 'do_submit,do_cancel', 0, 'input_set', '', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('bx_timeline_post', @sName, 'do_submit', '_bx_timeline_form_post_input_do_submit', '', 0, 'submit', '_bx_timeline_form_post_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0),
+('bx_timeline_post', @sName, 'do_cancel', '_bx_timeline_form_post_input_do_cancel', '', 0, 'button', '_bx_timeline_form_post_input_sys_do_cancel', '', '', 0, 0, 0, 'a:2:{s:7:"onclick";s:51:"{js_object_view}.editPostCancel(this, {content_id})";s:5:"class";s:22:"bx-def-margin-sec-left";}', '', '', '', '', '', '', '', 0, 0);
 
 INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_for_levels`, `active`, `order`) VALUES
 ('bx_timeline_post_add', 'type', 2147483647, 1, 1),
@@ -326,7 +330,17 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo
 ('bx_timeline_post_add_public', 'photo', 2147483647, 1, 8),
 ('bx_timeline_post_add_public', 'video', 2147483647, 1, 9),
 ('bx_timeline_post_add_public', 'attachments', 2147483647, 1, 10),
-('bx_timeline_post_add_public', 'do_submit', 2147483647, 1, 11);
+('bx_timeline_post_add_public', 'do_submit', 2147483647, 1, 11),
+
+('bx_timeline_post_edit', 'type', 2147483647, 1, 1),
+('bx_timeline_post_edit', 'action', 2147483647, 1, 2),
+('bx_timeline_post_edit', 'owner_id', 2147483647, 1, 3),
+('bx_timeline_post_edit', 'text', 2147483647, 1, 4),
+('bx_timeline_post_edit', 'object_privacy_view', 2147483647, 1, 5),
+('bx_timeline_post_edit', 'location', 2147483647, 1, 6),
+('bx_timeline_post_edit', 'controls', 2147483647, 1, 7),
+('bx_timeline_post_edit', 'do_submit', 2147483647, 1, 8),
+('bx_timeline_post_edit', 'do_cancel', 2147483647, 1, 9);
 
 -- Forms -> Attach link
 INSERT INTO `sys_objects_form` (`object`, `module`, `title`, `action`, `form_attrs`, `submit_name`, `table`, `key`, `uri`, `uri_title`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES

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

@@ -40,13 +40,13 @@ DELETE FROM `sys_transcoder_images_files` WHERE `transcoder_object` LIKE 'bx_tim
 DELETE FROM `sys_transcoder_videos_files` WHERE `transcoder_object` LIKE 'bx_timeline%';
 
 
-
 -- Forms All
 DELETE FROM `sys_form_display_inputs` WHERE `display_name` IN  (SELECT `display_name` FROM `sys_form_displays` WHERE `module` = @sName);
 DELETE FROM `sys_form_inputs` WHERE `module` = @sName;
 DELETE FROM `sys_form_displays` WHERE `module` = @sName;
 DELETE FROM `sys_objects_form` WHERE `module` = @sName;
 
+
 -- STUDIO PAGE & WIDGET
 DELETE FROM `tp`, `tw`, `tpw`
 USING `sys_std_pages` AS `tp`, `sys_std_widgets` AS `tw`, `sys_std_pages_widgets` AS `tpw`

+ 24 - 0
modules/boonex/timeline/js/main.js

@@ -24,6 +24,7 @@ function BxTimelineMain() {
 	this.sClassItems = this.sSP + '-items';
 	this.sClassItem = this.sSP + '-item';
 	this.sClassDividerToday = this.sSP + '-divider-today';
+	this.sClassItemContent = this.sSP + '-item-content';
 	this.sClassItemComments = this.sSP + '-item-comments-holder';
 	this.sClassItemImages = this.sSP + '-item-images';
 	this.sClassItemImage = this.sSP + '-item-image';
@@ -228,6 +229,29 @@ BxTimelineMain.prototype._getDefaultData = function(oElement) {
     });
 };
 
+
+BxTimelineMain.prototype._getPost = function(oElement, iId, sView) {
+    var $this = this;
+    var oData = this._getDefaultData();
+    oData['js_object'] = this._sObjName;
+    oData['view'] = sView;
+    oData['id'] = iId;
+
+    var oElementView = $('#' + this._aHtmlIds['main_' + sView]);
+    this.loadingInBlock(oElementView, true);
+
+    jQuery.post (
+        this._sActionsUrl + 'get_post/',
+        oData,
+        function(oData) {
+        	$this.loadingInBlock(oElementView, false);
+
+        	processJsonData(oData);
+        },
+        'json'
+    );
+};
+
 (function($) {
     $.fn.checkOverflowHeight = function(sClass, onFind) {
     	if(!sClass)

+ 3 - 24
modules/boonex/timeline/js/post.js

@@ -70,7 +70,7 @@ BxTimelinePost.prototype.afterFormPostSubmit = function (oForm, oData)
 	        if($('#' + $this._aHtmlIds['main_outline']).length)
 	        	$this._getPost(oForm, iId, 'outline');
 
-	        $this._getForm(oForm, $(oForm).find("input[name = 'type']").val());
+	        $this._getForm(oForm);
 
 	        return;
 		}
@@ -194,12 +194,12 @@ BxTimelinePost.prototype.showAttachLink = function(oLink) {
 	return false;
 };
 
-BxTimelinePost.prototype._getForm = function(oElement, sType) {
+BxTimelinePost.prototype._getForm = function(oElement) {
     var $this = this;
     var oData = this._getDefaultData();
 
     jQuery.post (
-	    this._sActionsUrl + 'get_post_form/' + sType + '/',
+	    this._sActionsUrl + 'get_post_form/',
 	    oData,
 	    function(oData) {
             if(oData && oData.form != undefined && oData.form_id != undefined) {
@@ -211,27 +211,6 @@ BxTimelinePost.prototype._getForm = function(oElement, sType) {
 	);
 };
 
-BxTimelinePost.prototype._getPost = function(oElement, iId, sView) {
-    var $this = this;
-    var oData = this._getDefaultData();
-    oData['id'] = iId;
-    oData['view'] = sView;
-
-    var oElementView = $('#' + this._aHtmlIds['main_' + sView]);
-    this.loadingInBlock(oElementView, true);
-
-    jQuery.post (
-        this._sActionsUrl + 'get_post/',
-        oData,
-        function(oData) {
-        	$this.loadingInBlock(oElementView, false);
-
-        	processJsonData(oData);
-        },
-        'json'
-    );
-};
-
 BxTimelinePost.prototype._onGetPost = function(oData) {
 	if(!$.trim(oData.item).length) 
 		return;

+ 141 - 2
modules/boonex/timeline/js/view.js

@@ -24,6 +24,7 @@ function BxTimelineView(oOptions) {
     };
 
     this._fOutsideOffset = 0.8;
+    this._oSaved = {};
 
     var $this = this;
     $(document).ready(function() {
@@ -311,6 +312,125 @@ BxTimelineView.prototype.promotePost = function(oLink, iId, iWay) {
     );
 };
 
+BxTimelineView.prototype.initFormEdit = function(sFormId)
+{
+	var $this = this;
+	var oForm = $('#' + sFormId);
+
+	autosize(oForm.find('textarea'));
+	oForm.ajaxForm({
+        dataType: "json",
+        beforeSubmit: function (formData, jqForm, options) {
+        	window[$this._sObjName].beforeFormEditSubmit(oForm);
+        },
+        success: function (oData) {
+        	window[$this._sObjName].afterFormEditSubmit(oForm, oData);
+        }
+    });
+};
+
+BxTimelineView.prototype.beforeFormEditSubmit = function(oForm)
+{
+	this.loadingInButton($(oForm).children().find(':submit'), true);
+};
+
+BxTimelineView.prototype.afterFormEditSubmit = function (oForm, oData)
+{
+	var $this = this;
+	var fContinue = function() {
+		if(oData && oData.id != undefined) {
+			var iId = parseInt(oData.id);
+	        if(iId <= 0) 
+	        	return;
+
+	        if($('#' + $this._aHtmlIds['main_timeline']).length)
+	        	$this._getPost(oForm, iId, 'timeline');
+
+	        if($('#' + $this._aHtmlIds['main_outline']).length)
+	        	$this._getPost(oForm, iId, 'outline');
+
+	        return;
+		}
+
+		if(oData && oData.form != undefined && oData.form_id != undefined) {
+			$('#' + oData.form_id).replaceWith(oData.form);
+			$this.initFormEdit(oData.form_id);
+
+			return;
+		}
+	};
+
+	this.loadingInButton($(oForm).children().find(':submit'), false);
+
+	if(oData && oData.message != undefined)
+        bx_alert(oData.message, fContinue);
+	else
+		fContinue();
+};
+
+BxTimelineView.prototype.editPost = function(oLink, iId) {
+	var $this = this;
+    var oData = this._getDefaultData();
+    oData['id'] = iId;
+
+    $(oLink).parents('.bx-popup-applied:first:visible').dolPopupHide();
+
+    var oItem = null;
+    if(this.bViewTimeline)
+    	oItem = $(this.sIdItemTimeline + iId);
+
+    if(this.bViewOutline)
+    	oItem = $(this.sIdItemOutline + iId);
+
+    var oContent = oItem.find('.' + this.sClassItemContent);
+    if(oContent.find('form').length) {
+        $(oContent).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
+            $(this).html($this._oSaved[iId]).bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+        });
+        return;
+    }
+    else
+        this._oSaved[iId] = oContent.html();
+
+    this.loadingInItem(oItem, true);
+
+    jQuery.post (
+		this._sActionsUrl + 'get_edit_form/' + iId + '/',
+		oData,
+        function (oData) {
+			processJsonData(oData);
+        },
+        'json'
+    );
+};
+
+BxTimelineView.prototype.onEditPost = function(oData) {
+	var $this = this;
+
+	if(!oData || !oData.id)
+		return;
+
+	var oItem = null;
+	if(this.bViewTimeline)
+		oItem = $(this.sIdItemTimeline + oData.id);
+    if(this.bViewOutline)
+    	oItem = $(this.sIdItemOutline + oData.id);
+
+    this.loadingInItem(oItem, false);
+
+	if(oData && oData.form != undefined && oData.form_id != undefined) {
+		oItem.find('.' + this.sClassItemContent).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
+            $(this).html(oData.form).bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+            	$this.initFormEdit(oData.form_id);
+            });
+        });
+	}
+};
+
+BxTimelineView.prototype.editPostCancel = function(oButton, iId) {
+	this.editPost(oButton, iId);
+};
+
 BxTimelineView.prototype.deletePost = function(oLink, iId) {
     var $this = this;
     var oData = this._getDefaultData();
@@ -439,7 +559,26 @@ BxTimelineView.prototype._onGetPosts = function(oData) {
 			    });
 				break;
 		}
-	}
+	}	
+};
 
-	
+
+BxTimelineView.prototype._onGetPost = function(oData) {
+	if(!$.trim(oData.item).length) 
+		return;
+
+	var oItem = $(oData.item).bxTime();
+	var oView = $('#' + this._aHtmlIds['main_' + oData.view]);
+
+	switch(oData.view) {
+		case 'timeline':
+			oView.find(this.sIdItemTimeline + oData.id).replaceWith(oItem);
+			break;
+
+		case 'outline':
+			oView.find(this.sIdItemOutline + oData.id).replaceWith(oItem);
+
+			this.reloadMasonry();
+			break;
+	}
 };