Преглед изворни кода

#24 - Minor fixes and improvements.

AntonLV пре 13 година
родитељ
комит
b2e6ce64ec

+ 4 - 2
inc/classes/BxDolVoteQuery.php

@@ -48,8 +48,9 @@ class BxDolVoteQuery extends BxDolDb
     	if($this->_iPostTimeout == 0) 
     		return true;
 
+		$iDate = time() - $this->_iPostTimeout;
 		$iAuthorNip = ip2long($sAuthorIp);
-		$sQuery = $this->prepare("SELECT `object_id` FROM `{$this->_sTableTrack}` WHERE `object_id` = ? AND `author_nip` = ? AND `date` > (UNIX_TIMESTAMP() - ?)", $iObjectId, $iAuthorNip, $this->_iPostTimeout);
+		$sQuery = $this->prepare("SELECT `object_id` FROM `{$this->_sTableTrack}` WHERE `object_id` = ? AND `author_nip` = ? AND `date` > ?", $iObjectId, $iAuthorNip, $iDate);
 		return (int)$this->getOne($sQuery) == 0;
     }
 
@@ -88,8 +89,9 @@ class BxDolVoteQuery extends BxDolDb
         if($bUndo)
         	$sQuery = $this->prepare("DELETE FROM `{$this->_sTableTrack}` WHERE `object_id` = ? AND `author_id` = ? LIMIT 1", $iObjectId, $iAuthorId);
         else {
+        	$iNow = time();
         	$iAuthorNip = ip2long($sAuthorIp);
-        	$sQuery = $this->prepare("INSERT INTO `{$this->_sTableTrack}` SET `object_id` = ?, `author_id` = ?, `author_nip` = ?, `value` = ?, `date` = UNIX_TIMESTAMP()", $iObjectId, $iAuthorId, $iAuthorNip, $iValue);
+        	$sQuery = $this->prepare("INSERT INTO `{$this->_sTableTrack}` SET `object_id` = ?, `author_id` = ?, `author_nip` = ?, `value` = ?, `date` = ?", $iObjectId, $iAuthorId, $iAuthorNip, $iValue, $iNow);
         }
 
         return (int)$this->query($sQuery) > 0;

+ 3 - 5
modules/boonex/timeline/classes/BxTimelineDb.php

@@ -267,10 +267,7 @@ class BxTimelineDb extends BxDolModuleDb
                 `{$this->_sTable}`.`description` AS `description`,
                 `{$this->_sTable}`.`shares` AS `shares`,
                 `{$this->_sTable}`.`date` AS `date`,
-                YEAR(FROM_UNIXTIME(`{$this->_sTable}`.`date`)) AS `year`,
-                DAYOFYEAR(FROM_UNIXTIME(`{$this->_sTable}`.`date`)) AS `day_date`,
-                DAYOFYEAR(NOW()) AS `day_now`,
-                (UNIX_TIMESTAMP() - `{$this->_sTable}`.`date`)/86400 AS `ago_days`
+                YEAR(FROM_UNIXTIME(`{$this->_sTable}`.`date`)) AS `year`
             FROM `{$this->_sTable}`
             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;
@@ -295,8 +292,9 @@ class BxTimelineDb extends BxDolModuleDb
     //--- Share related methods ---//
     public function insertShareTrack($iEventId, $iAuthorId, $sAuthorIp, $iSharedId)
     {
+    	$iNow = time();
     	$iAuthorNip = ip2long($sAuthorIp);
-		$sQuery = $this->prepare("INSERT INTO `{$this->_sTableSharesTrack}` SET `event_id` = ?, `author_id` = ?, `author_nip` = ?, `shared_id` = ?, `date` = UNIX_TIMESTAMP()", $iEventId, $iAuthorId, $iAuthorNip, $iSharedId);
+		$sQuery = $this->prepare("INSERT INTO `{$this->_sTableSharesTrack}` SET `event_id` = ?, `author_id` = ?, `author_nip` = ?, `shared_id` = ?, `date` = ?", $iEventId, $iAuthorId, $iAuthorNip, $iSharedId, $iNow);
 		return (int)$this->query($sQuery) > 0;
     }
 

+ 1 - 0
modules/boonex/timeline/classes/BxTimelineMenuItem.php

@@ -62,6 +62,7 @@ class BxTimelineMenuItem extends BxTemplMenu {
 
     	$this->addMarkers(array(
     		'content_id' => $aEvent['id'],
+    		'comment_onclick' => $this->_oModule->_oConfig->getJsObject('view') . ".commentItem(this, '" . $this->_aEvent['comments']['system'] . "', " . $this->_aEvent['id'] . ")",
     		'share_onclick' => $this->_oModule->serviceGetShareJsClick($iOwnerId, $sType, $sAction, $iObjectId),
     		'vote_onclick' => $sVotesOnclick
 		));    	

+ 1 - 1
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -589,7 +589,7 @@ class BxTimelineModule extends BxDolModule
 
 	public function getUserIp()
     {
-        return $_SERVER['REMOTE_ADDR'];
+        return getVisitorIP();
     }
 
 	public function getUserInfo($iUserId = 0)

+ 14 - 18
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -32,28 +32,24 @@ class BxTimelineTemplate extends BxDolModuleTemplate
 
     public function getJsCode($sType, $aRequestParams = array(), $bWrap = true)
     {
-    	$oJson = new Services_JSON();
     	$oModule = $this->getModule();
 
     	$sBaseUri = $this->_oConfig->getBaseUri();
     	$sJsClass = $this->_oConfig->getJsClass($sType);
     	$sJsObject = $this->_oConfig->getJsObject($sType);
-    	$aHtmlIds = $this->_oConfig->getHtmlIds($sType);
-
-        ob_start();
-?>
-		var <?=$sJsObject; ?> = new <?=$sJsClass; ?>({
-			sActionUri: '<?=$sBaseUri; ?>',
-            sActionUrl: '<?=BX_DOL_URL_ROOT . $sBaseUri; ?>',
-			sObjName: '<?=$sJsObject; ?>',
-			iOwnerId: <?=$oModule->_iOwnerId; ?>,
-            sAnimationEffect: '<?=$this->_oConfig->getAnimationEffect(); ?>',
-            iAnimationSpeed: '<?=$this->_oConfig->getAnimationSpeed(); ?>',
-            aHtmlIds: <?=$oJson->encode($aHtmlIds); ?>,
-            oRequestParams: <?php echo !empty($aRequestParams) ? $oJson->encode($aRequestParams) : '{}'; ?>
-        });
-<?php
-		$sContent = ob_get_clean();
+
+    	$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);
@@ -656,7 +652,7 @@ class BxTimelineTemplate extends BxDolModuleTemplate
 		$sJsObject = $this->_oConfig->getJsObject('view');
 
 		//--- Process Text ---// 
-		$sUrl = isset($aContent['url']) ? bx_process_output($aContent['url']) : '';
+		$sUrl = isset($aContent['url']) ? bx_html_attribute($aContent['url']) : '';
 		$sTitle = isset($aContent['title']) ? bx_process_output($aContent['title']) : '';
 		if(!empty($sUrl) && !empty($sTitle))
 			$sTitle = $this->parseHtmlByName('bx_a.html', array(