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

#24 - Inherit from Base Notifications module.

AntonLV 12 лет назад
Родитель
Сommit
416bad06f6

+ 35 - 189
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -10,16 +10,10 @@
  */
 
 bx_import('BxDolPrivacy');
-bx_import('BxDolModuleConfig');
+bx_import('BxBaseModNotificationsConfig');
 
-class BxTimelineConfig extends BxDolModuleConfig
+class BxTimelineConfig extends BxBaseModNotificationsConfig
 {
-    protected $_oDb;
-
-    protected $_sAlertSystemName;
-    protected $_sCommentSystemName;
-    protected $_sVoteSystemName;
-
     protected $_bAllowDelete;
 
     protected $_iPerPageProfile;
@@ -27,31 +21,17 @@ class BxTimelineConfig extends BxDolModuleConfig
     protected $_iRssLength;
     protected $_iCharsDisplayMax;
 
-    protected $_aHandlers;
-    protected $_aHandlersHidden;
-
     protected $_sStorageObject;
     protected $_sTranscoderObjectPreview;
     protected $_sTranscoderObjectView;
     protected $_aImageUploaders;
 
-    protected $_sConnObjSubscriptions;
-
     protected $_sMenuItemManage;
     protected $_sMenuItemActions;
 
     protected $_bJsMode;
-    protected $_aJsClass;
-    protected $_aJsObjects;
-
-    protected $_aHtmlIds;
     protected $_aShareDefaults;
 
-    protected $_sAnimationEffect;
-    protected $_iAnimationSpeed;
-    protected $_sStylePrefix;
-    protected $_sCommonPostPrefix;
-    protected $_iPrivacyViewDefault;
     protected $_iTimelineVisibilityThreshold;
     protected $_aPregPatterns;
 
@@ -62,23 +42,33 @@ class BxTimelineConfig extends BxDolModuleConfig
     {
         parent::__construct($aModule);
 
-        $this->_sAlertSystemName = $this->_sName;
-        $this->_sCommentSystemName = $this->_sName;
-        $this->_sVoteSystemName = $this->_sName;
+        $this->_aSystemNames = array(
+			'alert' => $this->_sName,
+        	'comment' => $this->_sName,
+        	'vote' => $this->_sName
+		);
+
+        $this->_aPrefixes = array(
+        	'style' => 'bx-tl',
+        	'language' => '_bx_timeline',
+        	'option' => 'bx_timeline_',
+        	'common_post' => 'timeline_common_'
+        );
 
-        $this->_aHandlersHidden = array();
-        $this->_aHandlers = array();
+        $this->_aObjects = array(
+        	'storage' => $this->_sName . '_photos',
+        	'transcoder_preview' => $this->_sName . '_photos_preview',
+        	'transcoder_view' => $this->_sName . '_photos_view',
+        	'conn_subscriptions' => 'sys_profiles_subscriptions',
+        	'menu_item_manage' => $this->_sName . '_menu_item_manage',
+        	'menu_item_actions' => $this->_sName . '_menu_item_actions'
+        );
+        
+        $this->_aHandlerDescriptor = array('module_name' => '', 'module_method' => '', 'module_class' => '', 'groupable' => '', 'group_by' => '');
+        $this->_sHandlersMethod = 'get_timeline_data';
 
-        $this->_sStorageObject = $this->_sName . '_photos';
-        $this->_sTranscoderObjectPreview = $this->_sName . '_photos_preview';
-        $this->_sTranscoderObjectView = $this->_sName . '_photos_view';
         $this->_aImageUploaders = array($this->_sName . '_simple');
 
-        $this->_sConnObjSubscriptions = 'sys_profiles_subscriptions';
-
-        $this->_sMenuItemManage = $this->_sName . '_menu_item_manage';
-        $this->_sMenuItemActions = $this->_sName . '_menu_item_actions';
-
         $this->_bJsMode = false;
         $this->_aJsClass = array(
             'main' => 'BxTimelineMain',
@@ -118,11 +108,6 @@ class BxTimelineConfig extends BxDolModuleConfig
             'show_counter' => true
         );
 
-        $this->_sAnimationEffect = 'fade';
-        $this->_iAnimationSpeed = 'slow';
-        $this->_sStylePrefix = 'bx-tl';
-        $this->_sCommonPostPrefix = 'timeline_common_';
-        $this->_iPrivacyViewDefault = BX_DOL_PG_ALL;
         $this->_iTimelineVisibilityThreshold = 0;
 
         $this->_aPregPatterns = array(
@@ -135,98 +120,25 @@ class BxTimelineConfig extends BxDolModuleConfig
 
     public function init(&$oDb)
     {
-        $this->_oDb = &$oDb;
-
-        $this->_bAllowDelete = getParam('bx_timeline_enable_delete') == 'on';
+    	parent::init($oDb);
 
-        $this->_iPerPageProfile = (int)getParam('bx_timeline_events_per_page_profile');
-        $this->_iPerPageAccount = (int)getParam('bx_timeline_events_per_page_account');
-        $this->_iRssLength = (int)getParam('bx_timeline_rss_length');
+    	$sOptionPrefix = $this->getPrefix('option');
+        $this->_bAllowDelete = getParam($sOptionPrefix . 'enable_delete') == 'on';
 
-        $this->_iCharsDisplayMax = (int)getParam('bx_timeline_chars_display_max');
+        $this->_aPerPage = array(
+    		'default' => 10,
+        	'profile' => (int)getParam($sOptionPrefix . 'events_per_page_profile'),
+        	'account' => (int)getParam($sOptionPrefix . 'events_per_page_account')
+    	);
 
-        $aHandlers = $this->_oDb->getHandlers();
-        foreach($aHandlers as $aHandler) {
-            if($aHandler['type'] === BX_TIMELINE_HANDLER_TYPE_INSERT && !empty($aHandler['content'])) {
-                $aContent = unserialize($aHandler['content']);
-                if(is_array($aContent) && !empty($aContent))
-                    $aHandler = array_merge($aHandler, $aContent);
-            }
-
-           $this->_aHandlers[$aHandler['alert_unit'] . '_' . $aHandler['alert_action']] = $aHandler;
-        }
-
-        $sHideTimeline = getParam('bx_timeline_events_hide');
-        if(!empty($sHideTimeline))
-            $this->_aHandlersHidden = explode(',', $sHideTimeline);
+        $this->_iRssLength = (int)getParam($sOptionPrefix . 'rss_length');
+        $this->_iCharsDisplayMax = (int)getParam($sOptionPrefix . 'chars_display_max');
     }
 
     public function isAllowDelete()
     {
         return $this->_bAllowDelete;
     }
-    public function getSystemName($sType)
-    {
-        $sResult = '';
-
-        switch($sType) {
-            case 'alert':
-                $sResult = $this->_sAlertSystemName;
-                break;
-            case 'comment':
-                $sResult = $this->_sCommentSystemName;
-                break;
-            case 'vote':
-                $sResult = $this->_sVoteSystemName;
-                break;
-        }
-
-        return $sResult;
-    }
-
-    public function getPrefix($sType)
-    {
-        $sResult = '';
-
-        switch($sType) {
-            case 'common_post':
-                $sResult = $this->_sCommonPostPrefix;
-                break;
-            case 'style':
-                $sResult = $this->_sStylePrefix;
-                break;
-        }
-
-        return $sResult;
-    }
-
-    public function getObject($sType)
-    {
-        $sResult = '';
-
-        switch($sType) {
-            case 'storage':
-                $sResult = $this->_sStorageObject;
-                break;
-            case 'transcoder_preview':
-                $sResult = $this->_sTranscoderObjectPreview;
-                break;
-            case 'transcoder_view':
-                $sResult = $this->_sTranscoderObjectView;
-                break;
-            case 'conn_subscriptions':
-                $sResult = $this->_sConnObjSubscriptions;
-                break;
-            case 'menu_item_manage':
-                $sResult = $this->_sMenuItemManage;
-                break;
-            case 'menu_item_actions':
-                $sResult = $this->_sMenuItemActions;
-                break;
-        }
-
-        return $sResult;
-    }
 
     public function getUploaders($sType)
     {
@@ -241,21 +153,6 @@ class BxTimelineConfig extends BxDolModuleConfig
         return $aResult;
     }
 
-    public function getPerPage($sPage = 'profile')
-    {
-        $iResult = 10;
-        switch($sPage) {
-            case 'profile':
-                $iResult = $this->_iPerPageProfile;
-                break;
-            case 'account':
-                $iResult = $this->_iPerPageAccount;
-                break;
-        }
-
-        return $iResult;
-    }
-
     public function getRssLength()
     {
         return $this->_iRssLength;
@@ -266,24 +163,6 @@ class BxTimelineConfig extends BxDolModuleConfig
         return $this->_iCharsDisplayMax;
     }
 
-    public function isHandler($sKey = '')
-    {
-        return isset($this->_aHandlers[$sKey]);
-    }
-
-    public function getHandlers($sKey = '')
-    {
-        if($sKey == '')
-            return $this->_aHandlers;
-
-        return $this->_aHandlers[$sKey];
-    }
-
-    public function getHandlersHidden()
-    {
-        return $this->_aHandlersHidden;
-    }
-
     public function isJsMode()
     {
         return $this->_bJsMode;
@@ -299,44 +178,11 @@ class BxTimelineConfig extends BxDolModuleConfig
         $this->_bJsMode = $bJsMode;
     }
 
-    public function getJsClass($sType)
-    {
-        return $this->_aJsClass[$sType];
-    }
-
-    public function getJsObject($sType)
-    {
-        return $this->_aJsObjects[$sType];
-    }
-
-    public function getHtmlIds($sType, $sKey = '')
-    {
-        if(empty($sKey))
-            return $this->_aHtmlIds[$sType];
-
-        return $this->_aHtmlIds[$sType][$sKey];
-    }
-
     public function getShareDefaults()
     {
         return $this->_aShareDefaults;
     }
 
-    public function getAnimationEffect()
-    {
-        return $this->_sAnimationEffect;
-    }
-
-    public function getAnimationSpeed()
-    {
-        return $this->_iAnimationSpeed;
-    }
-
-    public function getPrivacyViewDefault()
-    {
-        return $this->_iPrivacyViewDefault;
-    }
-
     public function getPregPattern($sType)
     {
         return $this->_aPregPatterns[$sType];

+ 11 - 154
modules/boonex/timeline/classes/BxTimelineDb.php

@@ -9,14 +9,10 @@
  * @{
  */
 
-bx_import('BxDolModuleDb');
+bx_import('BxBaseModNotificationsDb');
 
-class BxTimelineDb extends BxDolModuleDb
+class BxTimelineDb extends BxBaseModNotificationsDb
 {
-    protected $_oConfig;
-
-    protected $_sTable;
-    protected $_sTableHandlers;
     protected $_sTablesShareTrack;
 
     /*
@@ -25,122 +21,9 @@ class BxTimelineDb extends BxDolModuleDb
     function __construct(&$oConfig)
     {
         parent::__construct($oConfig);
-
-        $this->_oConfig = $oConfig;
-
-        $this->_sTable = $this->_sPrefix . 'events';
-        $this->_sTableHandlers = $this->_sPrefix . 'handlers';
         $this->_sTableSharesTrack = $this->_sPrefix . 'shares_track';
     }
 
-    public function getAlertHandlerId()
-    {
-        $sQuery = $this->prepare("SELECT `id` FROM `sys_alerts_handlers` WHERE `name`=? LIMIT 1", $this->_oConfig->getSystemName('alert'));
-        return (int)$this->getOne($sQuery);
-    }
-
-    public function insertData($aData)
-    {
-    	//--- Update Timeline Handlers ---//
-        foreach($aData['handlers'] as $aHandler) {
-            $sContent = '';
-            if($aHandler['type'] == BX_TIMELINE_HANDLER_TYPE_INSERT)
-                $sContent = serialize(array(
-                    'module_name' => $aHandler['module_name'],
-                    'module_method' => $aHandler['module_method'],
-                    'module_class' => !empty($aHandler['module_class']) ? $aHandler['module_class'] : 'Module',
-                    'groupable' => $aHandler['groupable'],
-                    'group_by' => $aHandler['group_by']
-                ));
-
-            $sQuery = $this->prepare("INSERT INTO
-                    `{$this->_sTableHandlers}`
-                SET
-                    `type`=?,
-                    `alert_unit`=?,
-                    `alert_action`=?,
-                    `content`=?", $aHandler['type'], $aHandler['alert_unit'], $aHandler['alert_action'], $sContent);
-
-            $this->query($sQuery);
-        }
-
-        //--- Update System Alerts ---//
-        $iHandlerId = $this->getAlertHandlerId();
-        foreach($aData['alerts'] as $aAlert) {
-            $sQuery = $this->prepare("INSERT INTO
-                    `sys_alerts`
-                SET
-                    `unit`=?,
-                    `action`=?,
-                    `handler_id`=?", $aAlert['unit'], $aAlert['action'], $iHandlerId);
-
-            $this->query($sQuery);
-        }
-    }
-
-    public function deleteData($aData)
-    {
-    	//--- Update Timeline Handlers ---//
-        foreach($aData['handlers'] as $aHandler) {
-            $sQuery = $this->prepare("DELETE FROM
-                    `{$this->_sTableHandlers}`
-                WHERE
-                    `alert_unit`=? AND
-                    `alert_action`=?
-                LIMIT 1", $aHandler['alert_unit'], $aHandler['alert_action']);
-
-            $this->query($sQuery);
-        }
-
-        //--- Update System Alerts ---//
-        $iHandlerId = $this->getAlertHandlerId();
-        foreach($aData['alerts'] as $aAlert) {
-            $sQuery = $this->prepare("DELETE FROM
-                    `sys_alerts`
-                WHERE
-                    `unit`=? AND
-                    `action`=? AND
-                    `handler_id`=?
-                LIMIT 1", $aAlert['unit'], $aAlert['action'], $iHandlerId);
-
-            $this->query($sQuery);
-        }
-    }
-
-    public function deleteModuleEvents($aData)
-    {
-    	foreach($aData['handlers'] as $aHandler) {
-    		//Delete system events.
-            $this->deleteEvent(array('type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
-
-            //Delete shared events.
-    		$aEvents = $this->getEvents(array('browse' => 'shared_by_descriptor', 'type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
-			foreach($aEvents as $aEvent) {
-				$aContent = unserialize($aEvent['content']);
-				if(isset($aContent['type']) && $aContent['type'] == $aHandler['alert_unit'] && isset($aContent['action']) && $aContent['action'] == $aHandler['alert_action'])
-					$this->deleteEvent(array('id' => (int)$aEvent['id']));
-			}
-    	}
-    }
-
-	public function activateModuleEvents($aData, $bActivate = true)
-    {
-    	$iActivate = $bActivate ? 1 : 0;
-
-    	foreach($aData['handlers'] as $aHandler) {
-    		//Activate (deactivate) system events.
-            $this->updateEvent(array('active' => $iActivate), array('type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
-
-			//Activate (deactivate) shared events.
-			$aEvents = $this->getEvents(array('browse' => 'shared_by_descriptor', 'type' => $aHandler['alert_unit'], 'action' => $aHandler['alert_action']));
-			foreach($aEvents as $aEvent) {
-				$aContent = unserialize($aEvent['content']);
-				if(isset($aContent['type']) && $aContent['type'] == $aHandler['alert_unit'] && isset($aContent['action']) && $aContent['action'] == $aHandler['alert_action'])
-					$this->updateEvent(array('active' => $iActivate), array('id' => (int)$aEvent['id']));
-			}
-    	}
-    }
-
     public function getHandlers($aParams = array())
     {
         $sMethod = 'getAll';
@@ -161,37 +44,7 @@ class BxTimelineDb extends BxDolModuleDb
         return $this->$sMethod($sSql);
     }
 
-    public function insertEvent($aParamsSet)
-    {
-        if(empty($aParamsSet))
-            return 0;
-
-        $aSet = array();
-        foreach($aParamsSet as $sKey => $sValue)
-           $aSet[] = $this->prepare("`" . $sKey . "`=?", $sValue);
-
-        if((int)$this->query("INSERT INTO `{$this->_sTable}` SET " . implode(", ", $aSet) . ", `date`=UNIX_TIMESTAMP()") <= 0)
-            return 0;
-
-        return (int)$this->lastId();
-    }
-
-    public function updateEvent($aParamsSet, $aParamsWhere)
-    {
-        if(empty($aParamsSet) || empty($aParamsWhere))
-            return false;
-
-        $sSql = "UPDATE `{$this->_sTable}` SET " . $this->arrayToSQL($aParamsSet) . " WHERE " . $this->arrayToSQL($aParamsWhere, " AND ");
-        return $this->query($sSql);
-    }
-
-    public function deleteEvent($aParams, $sWhereAddon = "")
-    {
-        $sSql = "DELETE FROM `{$this->_sTable}` WHERE " . $this->arrayToSQL($aParams, " AND ") . $sWhereAddon;
-        return $this->query($sSql);
-    }
-
-    public function getEvents($aParams)
+    public function getEvents($aParams, $bReturnCount = false)
     {
         $sMethod = 'getAll';
         $sJoinClause = $sWhereClause = $sOrderClause = $sLimitClause = "";
@@ -240,11 +93,11 @@ class BxTimelineDb extends BxDolModuleDb
                 //--- Check type
                 if(!empty($aParams['owner_id']))
                     switch($aParams['type']) {
-                        case BX_TIMELINE_TYPE_OWNER:
+                        case BX_BASE_MOD_NTFS_TYPE_OWNER:
                             $sWhereClause .= $this->prepare("AND `{$this->_sTable}`.`owner_id`=? ", $aParams['owner_id']);
                             break;
 
-                        case BX_TIMELINE_TYPE_CONNECTIONS:
+                        case BX_BASE_MOD_NTFS_TYPE_CONNECTIONS:
                             bx_import('BxDolConnection');
                             $oConnection = BxDolConnection::getObjectInstance($this->_oConfig->getObject('conn_subscriptions'));
 
@@ -280,7 +133,7 @@ class BxTimelineDb extends BxDolModuleDb
                 break;
         }
 
-        $sSql = "SELECT
+        $sSql = "SELECT " . ($bReturnCount ? "SQL_CALC_FOUND_ROWS" : "") . "
                 `{$this->_sTable}`.`id` AS `id`,
                 `{$this->_sTable}`.`owner_id` AS `owner_id`,
                 `{$this->_sTable}`.`type` AS `type`,
@@ -299,7 +152,11 @@ class BxTimelineDb extends BxDolModuleDb
             LEFT JOIN `{$this->_sTableHandlers}` ON `{$this->_sTable}`.`type`=`{$this->_sTableHandlers}`.`alert_unit` AND `{$this->_sTable}`.`action`=`{$this->_sTableHandlers}`.`alert_action` " . $sJoinClause . "
             WHERE 1 " . $sWhereClause . " " . $sOrderClause . " " . $sLimitClause;
 
-        return $this->$sMethod($sSql);
+        $aEntries = $this->$sMethod($sSql);
+        if(!$bReturnCount)
+        	return $aEntries;
+
+		return array($aEntries, (int)$this->getOne("SELECT FOUND_ROWS()"));
     }
 
     public function getMaxDuration($aParams)

+ 10 - 125
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -10,15 +10,10 @@
  */
 
 bx_import('BxDolAcl');
-bx_import('BxDolModule');
+bx_import('BxBaseModNotificationsModule');
 
-define('BX_TIMELINE_TYPE_OWNER', 'owner');
-define('BX_TIMELINE_TYPE_CONNECTIONS', 'connections');
 define('BX_TIMELINE_TYPE_ITEM', 'view_item');
-
-define('BX_TIMELINE_HANDLER_TYPE_INSERT', 'insert');
-define('BX_TIMELINE_HANDLER_TYPE_UPDATE', 'update');
-define('BX_TIMELINE_HANDLER_TYPE_DELETE', 'delete');
+define('BX_TIMELINE_TYPE_DEFAULT', BX_BASE_MOD_NTFS_TYPE_OWNER);
 
 define('BX_TIMELINE_FILTER_ALL', 'all');
 define('BX_TIMELINE_FILTER_OWNER', 'owner');
@@ -32,10 +27,8 @@ define('BX_TIMELINE_PARSE_TYPE_POST', 'post');
 define('BX_TIMELINE_PARSE_TYPE_SHARE', 'share');
 define('BX_TIMELINE_PARSE_TYPE_DEFAULT', BX_TIMELINE_PARSE_TYPE_POST);
 
-class BxTimelineModule extends BxDolModule
+class BxTimelineModule extends BxBaseModNotificationsModule
 {
-    public $_iOwnerId;
-
     protected $_sJsPostObject;
     protected $_sJsViewObject;
     protected $_aPostElements;
@@ -53,9 +46,6 @@ class BxTimelineModule extends BxDolModule
     function __construct($aModule)
     {
         parent::__construct($aModule);
-        $this->_oConfig->init($this->_oDb);
-        $this->_oTemplate->init();
-        $this->_iOwnerId = 0;
     }
 
     /**
@@ -272,43 +262,7 @@ class BxTimelineModule extends BxDolModule
 
     /**
      * SERVICE METHODS
-     */
-    public function serviceAddHandlers($sModuleUri = 'all')
-    {
-        $this->_updateModuleData('add_handlers', $sModuleUri);
-    }
-
-    public function serviceDeleteHandlers($sModuleUri = 'all')
-    {
-        $this->_updateModuleData('delete_handlers', $sModuleUri);
-    }
-
-	public function serviceDeleteModuleEvents($sModuleUri = 'all')
-    {
-        $this->_updateModuleData('delete_module_events', $sModuleUri);
-    }
-
-    function serviceGetActionsChecklist()
-    {
-        $aHandlers = $this->_oConfig->getHandlers();
-
-        $aResults = array();
-        foreach($aHandlers as $aHandler) {
-            if($aHandler['type'] != BX_TIMELINE_HANDLER_TYPE_INSERT)
-                continue;
-
-            $aModule = $this->_oDb->getModuleByName($aHandler['module_name']);
-            if(empty($aModule))
-                $aModule['title'] = _t('_bx_timeline_alert_module_' . $aHandler['alert_unit']);
-
-            $aResults[$aHandler['id']] = $aModule['title'] . ' (' . _t('_bx_timeline_alert_action_' . $aHandler['alert_action']) . ')';
-        }
-
-        asort($aResults);
-        return $aResults;
-    }
-
-    /*
+     * 
      * Get Post block for a separate page.
      */
     public function serviceGetBlockPost($sProfileModule = 'bx_persons', $iProfileId = 0)
@@ -361,7 +315,8 @@ class BxTimelineModule extends BxDolModule
             return array();
 
         $sJsObject = $this->_oConfig->getJsObject('view');
-        $aParams = $this->_prepareParams(BX_TIMELINE_TYPE_OWNER, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
+        $aParams = $this->_prepareParams(BX_BASE_MOD_NTFS_TYPE_OWNER, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
+        $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage('profile');
 
         $this->_iOwnerId = $aParams['owner_id'];
         list($sUserName, $sUserUrl) = $this->getUserInfo($aParams['owner_id']);
@@ -383,7 +338,8 @@ class BxTimelineModule extends BxDolModule
 
     public function serviceGetBlockViewAccount($iProfileId = 0, $iStart = -1, $iPerPage = -1, $iTimeline = -1, $sFilter = '', $aModules = array())
     {
-        $aParams = $this->_prepareParams(BX_TIMELINE_TYPE_CONNECTIONS, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
+        $aParams = $this->_prepareParams(BX_BASE_MOD_NTFS_TYPE_CONNECTIONS, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules, $iTimeline);
+        $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage('account');
 
         $this->_iOwnerId = $aParams['owner_id'];
 
@@ -631,33 +587,6 @@ class BxTimelineModule extends BxDolModule
         return $oVote;
     }
 
-    public function getUserId()
-    {
-        return isLogged() ? bx_get_logged_profile_id() : 0;
-    }
-
-    public function getUserIp()
-    {
-        return getVisitorIP();
-    }
-
-    public function getUserInfo($iUserId = 0)
-    {
-        bx_import('BxDolProfile');
-        $oProfile = BxDolProfile::getInstance($iUserId);
-        if (!$oProfile) {
-            bx_import('BxDolProfileUndefined');
-            $oProfile = BxDolProfileUndefined::getInstance();
-        }
-
-        return array(
-            $oProfile->getDisplayName(),
-            $oProfile->getUrl(),
-            $oProfile->getThumb(),
-            $oProfile->getUnit()
-        );
-    }
-
     //--- Check permissions methods ---//
     public function isAllowedPost($bPerform = false)
     {
@@ -843,7 +772,7 @@ class BxTimelineModule extends BxDolModule
     {
         $aParams = array();
         $aParams['browse'] = 'list';
-        $aParams['type'] = !empty($sType) ? $sType : BX_TIMELINE_TYPE_OWNER;
+        $aParams['type'] = !empty($sType) ? $sType : BX_TIMELINE_TYPE_DEFAULT;
         $aParams['owner_id'] = (int)$iOwnerId != 0 ? $iOwnerId : $this->getUserId();
         $aParams['start'] = (int)$iStart > 0 ? $iStart : 0;
         $aParams['per_page'] = (int)$iPerPage > 0 ? $iPerPage : $this->_oConfig->getPerPage();
@@ -862,7 +791,7 @@ class BxTimelineModule extends BxDolModule
         $aParams['browse'] = 'list';
 
         $sType = bx_get('type');
-        $aParams['type'] = $sType !== false ? bx_process_input($sType, BX_DATA_TEXT) : BX_TIMELINE_TYPE_OWNER;
+        $aParams['type'] = $sType !== false ? bx_process_input($sType, BX_DATA_TEXT) : BX_TIMELINE_TYPE_DEFAULT;
 
         $aParams['owner_id'] = $sType !== false ? bx_process_input(bx_get('owner_id'), BX_DATA_INT) : $this->getUserId();
 
@@ -888,50 +817,6 @@ class BxTimelineModule extends BxDolModule
     {
         return bx_process_input($s, BX_DATA_TEXT_MULTILINE);
     }
-
-    protected function _updateModuleData($sAction, $sModuleUri = 'all')
-    {
-        $aModules = $sModuleUri == 'all' ? $this->_oDb->getModules() : array($this->_oDb->getModuleByUri($sModuleUri));
-
-        foreach($aModules as $aModule) {
-            if(!BxDolRequest::serviceExists($aModule, 'get_timeline_data'))
-                continue;
-
-            $aData = BxDolService::call($aModule['name'], 'get_timeline_data');
-            if(empty($aData) || !is_array($aData))
-                continue;
-
-			switch($sAction) {
-				case 'add_handlers':
-					$this->_oDb->insertData($aData);
-					BxDolAlerts::cacheInvalidate();
-
-					$this->_oDb->activateModuleEvents($aData, true);
-					break;
-
-				case 'delete_handlers':
-					$this->_oDb->deleteData($aData);
-					BxDolAlerts::cacheInvalidate();
-
-					$this->_oDb->activateModuleEvents($aData, false);
-					break;
-
-				case 'delete_module_events':
-					$this->_oDb->deleteModuleEvents($aData);
-					break;
-			}
-        }
-    }
-
-    protected function _echoResultJson($a, $isAutoWrapForFormFileSubmit = false)
-    {
-        header('Content-type: text/html; charset=utf-8');
-
-        $s = json_encode($a);
-        if ($isAutoWrapForFormFileSubmit && !empty($_FILES))
-            $s = '<textarea>' . $s . '</textarea>'; // http://jquery.malsup.com/form/#file-upload
-        echo $s;
-    }
 }
 
 /** @} */

+ 5 - 16
modules/boonex/timeline/classes/BxTimelineResponse.php

@@ -9,16 +9,10 @@
  * @{
  */
 
-bx_import('BxDolAlerts');
+bx_import('BxBaseModNotificationsResponse');
 
-class BxTimelineResponse extends BxDolAlertsResponse
+class BxTimelineResponse extends BxBaseModNotificationsResponse
 {
-    protected $_oModule;
-
-    /**
-     * Constructor
-     * @param BxTimelineModule $oModule - an instance of current module
-     */
     public function __construct()
     {
         parent::__construct();
@@ -48,7 +42,7 @@ class BxTimelineResponse extends BxDolAlertsResponse
 
         $aHandler = $this->_oModule->_oConfig->getHandlers($oAlert->sUnit . '_' . $oAlert->sAction);
         switch($aHandler['type']) {
-            case BX_TIMELINE_HANDLER_TYPE_INSERT:
+            case BX_BASE_MOD_NTFS_HANDLER_TYPE_INSERT:
                 $sContent = !empty($oAlert->aExtras) && is_array($oAlert->aExtras) ? serialize(bx_process_input($oAlert->aExtras)) : '';
 
                 $iId = $this->_oModule->_oDb->insertEvent(array(
@@ -69,13 +63,13 @@ class BxTimelineResponse extends BxDolAlertsResponse
                 $this->_oModule->_oDb->updateSimilarObject($iId, $oAlert);
                 break;
 
-            case BX_TIMELINE_HANDLER_TYPE_UPDATE:
+            case BX_BASE_MOD_NTFS_HANDLER_TYPE_UPDATE:
                 $sContent = !empty($oAlert->aExtras) && is_array($oAlert->aExtras) ? serialize(bx_process_input($oAlert->aExtras)) : '';
 
                 $this->_oModule->_oDb->updateEvent(array('object_privacy_view' => $iPrivacyView, 'content' => $sContent), array('type' => $oAlert->sUnit, 'object_id' => $oAlert->iObject));
                 break;
 
-            case BX_TIMELINE_HANDLER_TYPE_DELETE:
+            case BX_BASE_MOD_NTFS_HANDLER_TYPE_DELETE:
                 $this->_oModule->_oDb->deleteEvent(array('type' => $oAlert->sUnit, 'object_id' => $oAlert->iObject));
 
         		$aEvents = $this->_oModule->_oDb->getEvents(array('browse' => 'shared_by_descriptor', 'type' => $oAlert->sUnit));
@@ -114,11 +108,6 @@ class BxTimelineResponse extends BxDolAlertsResponse
 
         echo $this->_oModule->_oTemplate->_wrapInTagJsCode("parent." . $this->_oModule->_sJsPostObject . "._getPost(null, " . $iId . ");");
     }
-
-    protected function _getPrivacyView($aExtras)
-    {
-        return is_array($aExtras) && isset($aExtras['privacy_view']) ? (int)$aExtras['privacy_view'] : $this->_oModule->_oConfig->getPrivacyViewDefault();
-    }
 }
 
 /** @} */

+ 13 - 52
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -9,28 +9,21 @@
  * @{
  */
 
-bx_import('BxDolModuleTemplate');
+bx_import('BxBaseModNotificationsTemplate');
 
-class BxTimelineTemplate extends BxDolModuleTemplate
+class BxTimelineTemplate extends BxBaseModNotificationsTemplate
 {
     function __construct(&$oConfig, &$oDb)
     {
         parent::__construct($oConfig, $oDb);
     }
 
-    protected function getModule()
-    {
-        $sName = $this->_oConfig->getName();
-        return BxDolModule::getInstance($sName);
-    }
-
     public function getCssJs()
     {
+    	parent::getCssJs();
+
         $this->addCss(array(
             'jquery-ui/jquery-ui.css',
-            'view.css',
-            'view-media-tablet.css',
-            'view-media-desktop.css',
             'post.css',
             'share.css',
         ));
@@ -39,39 +32,11 @@ class BxTimelineTemplate extends BxDolModuleTemplate
             'jquery.form.min.js',
             'jquery.ba-resize.min.js',
             'masonry.pkgd.min.js',
-            'jquery.anim.js',
-            'main.js',
-            'view.js',
             'post.js',
             'share.js',
         ));
     }
 
-    public function getJsCode($sType, $aRequestParams = array(), $bWrap = true)
-    {
-        $oModule = $this->getModule();
-
-        $sBaseUri = $this->_oConfig->getBaseUri();
-        $sJsClass = $this->_oConfig->getJsClass($sType);
-        $sJsObject = $this->_oConfig->getJsObject($sType);
-
-        $aParams = array(
-            'sActionUri' => $sBaseUri,
-            'sActionUrl' => BX_DOL_URL_ROOT . $sBaseUri,
-            'sObjName' => $sJsObject,
-            'iOwnerId' => $oModule->_iOwnerId,
-            'sAnimationEffect' => $this->_oConfig->getAnimationEffect(),
-            'iAnimationSpeed' => $this->_oConfig->getAnimationSpeed(),
-            'aHtmlIds' => $this->_oConfig->getHtmlIds($sType),
-            'oRequestParams' => !empty($aRequestParams) ? $aRequestParams : array()
-        );
-
-        $sContent = "var " . $sJsObject . " = new " . $sJsClass . "(" . json_encode($aParams) . ");";
-
-        $this->getCssJs();
-        return !$bWrap ? $sContent : $this->_wrapInTagJsCode($sContent);
-    }
-
     public function getPostBlock($iOwnerId)
     {
         $aForm = $this->getModule()->getFormPost();
@@ -477,7 +442,7 @@ class BxTimelineTemplate extends BxDolModuleTemplate
         $aTmplVarsMenuItemActions = $this->_getTmplVarsMenuItemActions($aEvent, $aBrowseParams);
 
         $aTmplVarsTimelineOwner = array();
-        if(isset($aBrowseParams['type']) && $aBrowseParams['type'] == BX_TIMELINE_TYPE_CONNECTIONS)
+        if(isset($aBrowseParams['type']) && $aBrowseParams['type'] == BX_BASE_MOD_NTFS_TYPE_CONNECTIONS)
             $aTmplVarsTimelineOwner = $this->_getTmplVarsTimelineOwner($aEvent);
 
         $bBrowseItem = isset($aBrowseParams['type']) && $aBrowseParams['type'] == BX_TIMELINE_TYPE_ITEM;
@@ -796,21 +761,17 @@ class BxTimelineTemplate extends BxDolModuleTemplate
         if(!$this->_oConfig->isHandler($sHandler))
             return '';
 
-        $mixedResult = array();
         $aHandler = $this->_oConfig->getHandlers($sHandler);
-        if(empty($aHandler['module_uri']) && empty($aHandler['module_class']) && empty($aHandler['module_method'])) {
-            $sMethod = 'display' . bx_gen_method_name($aHandler['alert_unit'] . '_' . $aHandler['alert_action']);
-            if(!method_exists($this, $sMethod))
-                return '';
-
-            $mixedResult = $this->$sMethod($aEvent);
-        } else {
-            $aEvent['js_mode'] = $this->_oConfig->getJsMode();
-
-            $mixedResult = BxDolService::call($aHandler['module_name'], $aHandler['module_method'], array($aEvent), $aHandler['module_class']);
+        if(!empty($aHandler['module_name']) && !empty($aHandler['module_class']) && !empty($aHandler['module_method'])) {
+        	$aEvent['js_mode'] = $this->_oConfig->getJsMode();
+            return BxDolService::call($aHandler['module_name'], $aHandler['module_method'], array($aEvent), $aHandler['module_class']);
         }
 
-        return $mixedResult;
+		$sMethod = 'display' . bx_gen_method_name($aHandler['alert_unit'] . '_' . $aHandler['alert_action']);
+		if(!method_exists($this, $sMethod))
+        	return '';
+
+		return $this->$sMethod($aEvent);
     }
 
     protected function _getCommonData(&$aEvent)

+ 2 - 19
modules/boonex/timeline/install/installer.php

@@ -9,9 +9,9 @@
  * @{
  */
 
-bx_import('BxBaseModGeneralInstaller');
+bx_import('BxBaseModNotificationsInstaller');
 
-class BxTimelineInstaller extends BxBaseModGeneralInstaller
+class BxTimelineInstaller extends BxBaseModNotificationsInstaller
 {
     function __construct($aConfig)
     {
@@ -19,23 +19,6 @@ class BxTimelineInstaller extends BxBaseModGeneralInstaller
         $this->_aTranscoders = array ('bx_timeline_photos_preview', 'bx_timeline_photos_view');
         $this->_aStorages = array ('bx_timeline_photos');
     }
-
-    function enable($aParams)
-    {
-        $aResult = parent::enable($aParams);
-
-        if($aResult['result'])
-            BxDolService::call($this->_aConfig['name'], 'add_handlers');
-
-        return $aResult;
-    }
-
-    function disable($aParams)
-    {
-         BxDolService::call($this->_aConfig['name'], 'delete_handlers');
-
-        return parent::disable($aParams);
-    }
 }
 
 /** @} */