Explorar o código

Ticket #923 - In BxDolReport and BxDolVote.

AntonLV %!s(int64=9) %!d(string=hai) anos
pai
achega
5860d3a5ae

+ 3 - 3
inc/classes/BxDolVote.php

@@ -209,7 +209,7 @@ class BxDolVote extends BxDolObject
     public function actionVote()
     {
         if(!$this->isEnabled()) {
-            echoJson(array('code' => 1));
+            echoJson(array('code' => 1, 'message' => _t('_vote_err_not_enabled')));
             return;
         }
 
@@ -225,12 +225,12 @@ class BxDolVote extends BxDolObject
         $bPerformUndo = $bVoted && $bUndo ? true : false;
 
         if(!$bPerformUndo && !$this->isAllowedVote(true)) {
-            echoJson(array('code' => 2, 'msg' => $this->msgErrAllowedVote()));
+            echoJson(array('code' => 2, 'message' => $this->msgErrAllowedVote()));
             return;
         }
 
         if((!$bLikeMode && !$this->_oQuery->isPostTimeoutEnded($iObjectId, $iAuthorIp)) || ($bLikeMode && $bVoted && !$bUndo)) {
-            echoJson(array('code' => 3, 'msg' => _t('_vote_err_duplicate_vote')));
+            echoJson(array('code' => 3, 'message' => _t('_vote_err_duplicate_vote')));
             return;
         }
 

+ 46 - 39
inc/js/classes/BxDolReport.js

@@ -54,58 +54,65 @@ BxDolReport.prototype.report = function(oLink) {
 
 BxDolReport.prototype.onReport = function(oData, oElement)
 {
-	if(oData && oData.msg != undefined)
-        alert(oData.msg);
+	var $this = this;
+	var fContinue = function() {
+		if(oData && oData.code != 0)
+	        return;
 
-	if(oData && oData.code != 0)
-        return;
+		if(oData && oData.label_icon)
+			$(oElement).find('.sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
 
-	if(oData && oData.label_icon)
-		$(oElement).find('.sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
+		if(oData && oData.label_title) {
+			$(oElement).attr('title', oData.label_title);
+			$(oElement).find('span').html(oData.label_title);
+		}
 
-	if(oData && oData.label_title) {
-		$(oElement).attr('title', oData.label_title);
-		$(oElement).find('span').html(oData.label_title);
-	}
+		if(oData && oData.disabled)
+			$(oElement).removeAttr('onclick').addClass($(oElement).hasClass('bx-btn') ? 'bx-btn-disabled' : 'bx-report-disabled');
 
-	if(oData && oData.disabled)
-		$(oElement).removeAttr('onclick').addClass($(oElement).hasClass('bx-btn') ? 'bx-btn-disabled' : 'bx-report-disabled');
+	    var oCounter = $this._getCounter(oElement);
+	    if(oCounter && oCounter.length > 0) {
+	    	oCounter.html(oData.countf);
 
-    var oCounter = this._getCounter(oElement);
-    if(oCounter && oCounter.length > 0) {
-    	oCounter.html(oData.countf);
+	    	oCounter.parents('.' + $this._sSP + '-counter-holder:first').bx_anim(oData.count > 0 ? 'show' : 'hide');
+	    }
+	};
 
-    	oCounter.parents('.' + this._sSP + '-counter-holder:first').bx_anim(oData.count > 0 ? 'show' : 'hide');
-    }
+	if(oData && oData.msg != undefined)
+        bx_alert(oData.msg, fContinue);
+	else
+		fContinue();
 };
 
 BxDolReport.prototype.processJson = function(oData, oElement) {
 	oElement = oElement != undefined ? oElement : this._oParent;
 
+	var fContinue = function() {
+		//--- Show Popup
+	    if(oData && oData.popup != undefined) {
+	    	$('#' + oData.popup_id).remove();
+
+	    	$(oData.popup).hide().prependTo('body').dolPopup({
+	    		pointer: {
+	    			el: oElement
+	    		},
+	            fog: {
+					color: '#fff',
+					opacity: .7
+	            }
+	        });
+	    }
+
+	    //--- Evaluate JS code
+	    if (oData && oData.eval != undefined)
+	        eval(oData.eval);
+	};
+
     //--- Show Message
-    if(oData && oData.msg != undefined)
-        alert(oData.msg);
     if(oData && oData.message != undefined)
-        alert(oData.message);
-
-    //--- Show Popup
-    if(oData && oData.popup != undefined) {
-    	$('#' + oData.popup_id).remove();
-
-    	$(oData.popup).hide().prependTo('body').dolPopup({
-    		pointer: {
-    			el: oElement
-    		},
-            fog: {
-				color: '#fff',
-				opacity: .7
-            }
-        });
-    }
-
-    //--- Evaluate JS code
-    if (oData && oData.eval != undefined)
-        eval(oData.eval);
+        bx_alert(oData.message, fContinue);
+    else
+    	fContinue();
 };
 
 BxDolReport.prototype._getButtons = function(oElement) {

+ 27 - 23
inc/js/classes/BxDolVote.js

@@ -86,37 +86,41 @@ BxDolVote.prototype.vote = function (oLink, iValue, onComplete)
     	this._sActionsUrl,
     	oParams,
     	function(oData) {
-    		if(oData && oData.msg != undefined)
-                alert(oData.msg);
+    		var fContinue = function() {
+    			if(oData && oData.code != 0)
+                    return;
 
-    		if(oData && oData.code != 0)
-                return;
+        		if($this._iLikeMode) {
+    	    		if(oData && oData.label_icon)
+    	    			$(oLink).find('.sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
 
-    		if($this._iLikeMode) {
-	    		if(oData && oData.label_icon)
-	    			$(oLink).find('.sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
+    	    		if(oData && oData.label_title) {
+    	    			$(oLink).attr('title', oData.label_title);
+    	    			$(oLink).find('span').html(oData.label_title);
+    	    		}
 
-	    		if(oData && oData.label_title) {
-	    			$(oLink).attr('title', oData.label_title);
-	    			$(oLink).find('span').html(oData.label_title);
-	    		}
+    	    		if(oData && oData.disabled)
+    	    			$(oLink).removeAttr('onclick').addClass($(oLink).hasClass('bx-btn') ? 'bx-btn-disabled' : 'bx-vote-disabled');
+        		}
 
-	    		if(oData && oData.disabled)
-	    			$(oLink).removeAttr('onclick').addClass($(oLink).hasClass('bx-btn') ? 'bx-btn-disabled' : 'bx-vote-disabled');
-    		}
+        		if(!$this._iLikeMode)
+        			$this._iSaveWidth = Math.round(oData.rate * $this._getStarWidthDo(oLink));
 
-    		if(!$this._iLikeMode)
-    			$this._iSaveWidth = Math.round(oData.rate * $this._getStarWidthDo(oLink));
+                var oCounter = $this._getCounter(oLink);
+                if(oCounter && oCounter.length > 0) {
+                	oCounter.html(oData.countf);
 
-            var oCounter = $this._getCounter(oLink);
-            if(oCounter && oCounter.length > 0) {
-            	oCounter.html(oData.countf);
+                	oCounter.parents('.' + $this._sSP + '-counter-holder:first').bx_anim(oData.count > 0 ? 'show' : 'hide');
+                }
 
-            	oCounter.parents('.' + $this._sSP + '-counter-holder:first').bx_anim(oData.count > 0 ? 'show' : 'hide');
-            }
+                if(typeof onComplete == 'function')
+                	onComplete(oLink, oData);
+    		};
 
-            if(typeof onComplete == 'function')
-            	onComplete(oLink, oData);
+    		if(oData && oData.message != undefined)
+                bx_alert(oData.message, fContinue);
+    		else
+    			fContinue();
         },
         'json'
     );

+ 1 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -2527,6 +2527,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_vote_do_like"><![CDATA[Thank you!]]></string>
 	<string name="_vote_do_unlike"><![CDATA[No thank you]]></string>
 	<string name="_vote_do_by"><![CDATA[Thanked by]]></string>
+	<string name="_vote_err_not_enabled"><![CDATA[The feature is not available right now. Please, try again later.]]></string>
 	<string name="_vote_err_duplicate_vote"><![CDATA[Duplicate vote]]></string>
 	<string name="_week_fri"><![CDATA[Friday]]></string>
 	<string name="_week_mon"><![CDATA[Monday]]></string>

+ 1 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -2526,6 +2526,7 @@
 	<string name="_vote_do_like"><![CDATA[Спасибо!]]></string>
 	<string name="_vote_do_unlike"><![CDATA[Нет, спасибо]]></string>
 	<string name="_vote_do_by"><![CDATA[Поблагодарил]]></string>
+	<string name="_vote_err_not_enabled"><![CDATA[Ваш голос не может быть принят в данный момент. Пожалуйста, попробуйте позднее.]]></string>
 	<string name="_vote_err_duplicate_vote"><![CDATA[Повторный голос]]></string>
 	<string name="_week_fri"><![CDATA[Пятница]]></string>
 	<string name="_week_mon"><![CDATA[Понедельник]]></string>

+ 6 - 6
template/scripts/BxBaseReport.php

@@ -250,10 +250,10 @@ class BxBaseReport extends BxDolReport
     protected function _getReport()
     {
     	if (!$this->isEnabled())
-           return array('code' => 1, 'msg' => _t('_report_err_not_enabled'));
+           return array('code' => 1, 'message' => _t('_report_err_not_enabled'));
 
 	    if(!$this->isAllowedReport())
-            return array('code' => 2, 'msg' => $this->msgErrAllowedReport());
+            return array('code' => 2, 'message' => $this->msgErrAllowedReport());
 
     	$oForm = $this->_getFormObject();
 		$oForm->setId($this->_aHtmlIds['do_form']);
@@ -271,15 +271,15 @@ class BxBaseReport extends BxDolReport
 	        $iAuthorNip = ip2long($this->_getAuthorIp());
 
         	if(!$this->isAllowedReport(true))
-        		return array('code' => 2, 'msg' => $this->msgErrAllowedReport());
+        		return array('code' => 2, 'message' => $this->msgErrAllowedReport());
 
 	        $bPerformed = $this->isPerformed($iObjectId, $iAuthorId);
 	        if($bPerformed)
-	        	return array('code' => 4, 'msg' => _t('_report_err_duplicate_report'));
+	        	return array('code' => 4, 'message' => _t('_report_err_duplicate_report'));
 
 			$sType = $oForm->getCleanValue('type');
 	        if(!in_array($sType, $this->_aTypes)) 
-	        	return array('code' => 5, 'msg' => _t('_report_err_wrong_type'));
+	        	return array('code' => 5, 'message' => _t('_report_err_wrong_type'));
 
 			$sText = $oForm->getCleanValue('text');
             $sText = bx_process_input($sText, BX_DATA_TEXT_MULTILINE);
@@ -316,7 +316,7 @@ class BxBaseReport extends BxDolReport
 		        );
 			}
 
-			return array('code' => 3, 'msg' => _t('_report_err_cannot_perform_action'));
+			return array('code' => 3, 'message' => _t('_report_err_cannot_perform_action'));
         }
 
         $sPopupId = $this->_aHtmlIds['do_popup'];