Pārlūkot izejas kodu

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

RomanL 8 gadi atpakaļ
vecāks
revīzija
ec1b4be01c

+ 8 - 5
inc/classes/BxDolQueueEmail.php

@@ -35,23 +35,26 @@ class BxDolQueueEmail extends BxDolQueue implements iBxDolSingleton
      * @param string $sBody - message body
      * @return true on success, false on error
      */
-    public function add($sEmail, $sSubject, $sBody, $sHeaders = '', $sParams = '')
+    public function add($sEmail, $sSubject, $sBody, $iRecipientID, $aPlus, $iEmailType, $sEmailFlag, $isDisableAlert, $aCustomHeaders)
     {
         return (int)$this->_oQuery->insertItem(array(
         	'email' => $sEmail,
             'subject' => $sSubject,
             'body' => $sBody,
-            'headers' => $sHeaders,
-        	'params' => $sParams
+        	'params' => serialize(array($iRecipientID, $aPlus, $iEmailType, $sEmailFlag, $isDisableAlert, $aCustomHeaders))
         )) > 0;
     }
 
     /**
      * Internal method which performs sending using predefined list of params.
      */
-    protected function _send($sEmail, $sSubject, $sBody, $sHeaders = '', $sParams = '')
+    protected function _send($sEmail, $sSubject, $sBody, $sParams = '')
     {
-        return mail($sEmail, $sSubject, $sBody, $sHeaders, $sParams);
+        $aParams = array();
+        if(!empty($sParams))
+            $aParams = unserialize($sParams);
+
+        return call_user_func_array('sendMail', array_merge(array($sEmail, $sSubject, $sBody), $aParams));
     }
 }
 

+ 3 - 0
inc/classes/BxDolScore.php

@@ -239,6 +239,8 @@ class BxDolScore extends BxDolObject
         if(!$this->isAllowedVote(true))
             return echoJson(array('code' => 2, 'message' => $this->msgErrAllowedVote()));
 
+        $aParams = $this->_decodeElementParams(bx_process_input(bx_get('element_params')));
+
         $iObjectId = $this->getId();
         $iObjectAuthorId = $this->getObjectAuthorId($iObjectId);
         $iAuthorId = $this->_getAuthorId();
@@ -268,6 +270,7 @@ class BxDolScore extends BxDolObject
         	'scoref' => $iCup > 0 || $iCdown > 0 ? $this->_getLabelCounter($aScore['score']) : '',
             'cup' => $iCup,
         	'cdown' => $iCdown,
+            'counter' => $this->getCounter($aParams),
         	'label_icon' => $this->_getIconDo($sType),
         	'label_title' => _t($this->_getTitleDo($sType)),
         	'disabled' => !$bVoted,

+ 1 - 5
inc/classes/BxDolSearch.php

@@ -692,17 +692,13 @@ class BxDolSearchResult implements iBxDolReplaceable
     {
         // keyword
         $sKeyword = bx_process_input(isset($this->_aCustomSearchCondition['keyword']) ? $this->_aCustomSearchCondition['keyword'] : bx_get('keyword'));
-        if ($sKeyword) {
+        if ($sKeyword !== false) {
             $this->aCurrent['restriction']['keyword'] = array(
                 'value' => $sKeyword,
                 'field' => '',
                 'operator' => 'against'
             );
         }
-        else {
-            $this->aCurrent['paginate']['num'] = 0;
-            return;
-        }
 
         // owner
         if (isset($_GET['ownerName'])) {

+ 4 - 3
inc/js/classes/BxDolScore.js

@@ -73,9 +73,10 @@ BxDolScore.prototype._vote = function (oLink, sType, onComplete)
 
                 var oCounter = $this._getCounter(oLink);
                 if(oCounter && oCounter.length > 0) {
-                	oCounter.html(oData.scoref);
-
-                	oCounter.parents('.' + $this._sSP + '-counter-holder:first:hidden').bx_anim('show');
+                	if(oData && oData.counter)
+                		oCounter.replaceWith(oData.counter);
+                	else
+	                	oCounter.html(oData.scoref).parents('.' + $this._sSP + '-counter-holder:first:hidden').bx_anim('show');
                 }
 
                 if(typeof onComplete == 'function')

+ 6 - 5
inc/utils.inc.php

@@ -346,6 +346,9 @@ function sendMail($sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID = 0
     if ($aAccountInfo && BX_EMAIL_NOTIFY == $iEmailType && (!$aAccountInfo['email_confirmed'] || !$aAccountInfo['receive_updates']))
         return false;
 
+    if($bAddToQueue && BxDolQueueEmail::getInstance()->add($sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID, $aPlus, $iEmailType, $sEmailFlag, $isDisableAlert, $aCustomHeaders))
+        return true;
+
     // if profile id is provided - get profile's info
     $aRecipientInfo = false;
     if ($iRecipientID) {
@@ -404,7 +407,7 @@ function sendMail($sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID = 0
     );
 
     // system alert
-    if (!$bAddToQueue && !$isDisableAlert) {
+    if (!$isDisableAlert) {
         bx_alert('system', 'before_send_mail', (isset($aRecipientInfo['ID']) ? $aRecipientInfo['ID'] : 0), '', $aAlert);
         if ($bResult !== null)
             return $bResult;
@@ -420,12 +423,10 @@ function sendMail($sRecipientEmail, $sMailSubject, $sMailBody, $iRecipientID = 0
     }
 
     // send mail or put it into queue
-    $bResult = false;
-    if(!$bAddToQueue || !($bResult = BxDolQueueEmail::getInstance()->add($sRecipientEmail, $sMailSubject, $sMailBody, $sMailHeader, $sMailParameters)))
-        $bResult = mail($sRecipientEmail, $sMailSubject, $sMailBody, $sMailHeader, $sMailParameters);     
+    $bResult = mail($sRecipientEmail, $sMailSubject, $sMailBody, $sMailHeader, $sMailParameters);
 
     // system alert
-    if (!$bAddToQueue && !$isDisableAlert)
+    if (!$isDisableAlert)
         bx_alert('system', 'send_mail', (isset($aRecipientInfo['ID']) ? $aRecipientInfo['ID'] : 0), '', $aAlert);
 
     return $bResult;

+ 0 - 1
install/sql/system.sql

@@ -171,7 +171,6 @@ CREATE TABLE `sys_queue_email` (
   `email` varchar(64) NOT NULL default '',
   `subject` varchar(255) NOT NULL default '',
   `body` text NOT NULL default '',
-  `headers` text NOT NULL default '',
   `params` text NOT NULL default '',
   PRIMARY KEY (`id`)
 );

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

@@ -2452,6 +2452,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_request_method_not_found_cpt"><![CDATA[Method was not found]]></string>
 	<string name="_sys_request_method_not_found_cnt"><![CDATA[Method({0}) was not found in module({1})]]></string>
 	<string name="_sys_score_counter"><![CDATA[{0}]]></string>
+	<string name="_sys_score_counter_empty"><![CDATA[Vote]]></string>
 	<string name="_sys_score_do_up"><![CDATA[Up vote]]></string>
 	<string name="_sys_score_do_down"><![CDATA[Down vote]]></string>
 	<string name="_sys_score_do_by"><![CDATA[Voted by]]></string>

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

@@ -39,6 +39,7 @@
 	<string name="_bx_videos_form_entry_input_pictures"><![CDATA[Картинки]]></string>
 	<string name="_bx_videos_form_entry_input_sys_videos"><![CDATA[Видео]]></string>
     <string name="_bx_videos_form_entry_input_videos"><![CDATA[Видео]]></string>
+    <string name="_bx_videos_form_entry_input_videos_error"><![CDATA[Видео обязателено. Пожалуйста, загрузите видео файл.]]></string>
     <string name="_bx_videos_form_entry_input_videos_upload"><![CDATA[Загрузить]]></string>
     <string name="_bx_videos_form_entry_input_sys_allow_view_to"><![CDATA[Видимость]]></string>
     <string name="_bx_videos_form_entry_input_allow_view_to"><![CDATA[Видимость]]></string>

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

@@ -2451,6 +2451,7 @@
 	<string name="_sys_request_method_not_found_cpt"><![CDATA[Метод не найден]]></string>
 	<string name="_sys_request_method_not_found_cnt"><![CDATA[Метод ({0}) не найден в модуле ({1})]]></string>
 	<string name="_sys_score_counter"><![CDATA[{0}]]></string>
+	<string name="_sys_score_counter_empty"><![CDATA[Проголосовать]]></string>
     <string name="_sys_score_do_up"><![CDATA[Проголосовать за]]></string>
     <string name="_sys_score_do_down"><![CDATA[Проголосовать против]]></string>
     <string name="_sys_score_do_by"><![CDATA[Проголосовали]]></string>

+ 30 - 2
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -1108,15 +1108,43 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         if($iOwnerId == 0 || $iOwnerId == (int)$aEvent['object_owner_id'])
             return array();
 
-        list($sTaName, $sTaUrl, $sTaThumb, $sTaUnit, $sTaUnitWoInfo) = $this->getModule()->getUserInfo($aEvent['owner_id']);
+        $sStylePrefix = $this->_oConfig->getPrefix('style');
+        $iUser = bx_get_logged_profile_id();
+
+        $oModule = $this->getModule();
+        list($sTaName, $sTaUrl, $sTaThumb, $sTaUnit, $sTaUnitWoInfo) = $oModule->getUserInfo($aEvent['owner_id']);
+        $sTaType = $oModule->getObjectUser($aEvent['owner_id'])->getModule();
+
+        $aTmplVarsActions = array();
+        if(!empty($iUser) && !empty($aEvent['owner_id']) && $iUser != $aEvent['owner_id']) {
+            $sConnection = $this->_oConfig->getObject('conn_subscriptions');
+            if(BxDolConnection::getObjectInstance($sConnection)->checkAllowedConnect($iUser, $aEvent['owner_id']) === CHECK_ACTION_RESULT_ALLOWED) {
+                $sContent = _t('_sys_menu_item_title_sm_subscribe');
+                $aTmplVarsActions[] = array(
+                    'href' => "javascript:void(0)",
+                    'onclick' => "bx_conn_action(this, '" . $sConnection . "', 'add', '" . $aEvent['owner_id'] . "')",
+                	'title' => bx_html_attribute($sContent),
+                    'content' => $sContent,
+                    'icon' => 'check'
+                );
+            }
+        }
 
         return array(
-        	'style_prefix' => $this->_oConfig->getPrefix('style'),
+        	'style_prefix' => $sStylePrefix,
+			'owner_type' => _t('_' . $sTaType),
             'owner_url' => $sTaUrl,
             'owner_username' => $sTaName,
             'owner_thumb' => $sTaThumb,
             'owner_unit' => $sTaUnit,
             'owner_unit_wo_info' => $sTaUnitWoInfo,
+            'bx_if:show_timeline_owner_actions' => array(
+                'condition' => !empty($aTmplVarsActions),
+                'content' => array(
+                    'style_prefix' => $sStylePrefix,
+                    'bx_repeat:actions' => $aTmplVarsActions
+                )
+            )
         );
     }
 

+ 0 - 2
modules/boonex/videos/classes/BxVideosTemplate.php

@@ -87,8 +87,6 @@ class BxVideosTemplate extends BxBaseModTextTemplate
         $CNF = &$this->getModule()->_oConfig->CNF;
 
         list($sImageThumb, $sImageGallery) = $this->getUnitThumbAndGallery ($aData);
-        if(empty($sImageThumb) && empty($sImageGallery))
-            return array($sImageThumb, $sImageGallery);
 
         $sImageCover = $this->_getUnitImage($CNF['FIELD_THUMB'], $CNF['OBJECT_IMAGES_TRANSCODER_COVER'], $aData);
         if(!empty($sImageCover))

+ 1 - 0
modules/boonex/videos/install/langs/en.xml

@@ -39,6 +39,7 @@
 	<string name="_bx_videos_form_entry_input_pictures"><![CDATA[Pictures]]></string>
 	<string name="_bx_videos_form_entry_input_sys_videos"><![CDATA[Video]]></string>
     <string name="_bx_videos_form_entry_input_videos"><![CDATA[Video]]></string>
+    <string name="_bx_videos_form_entry_input_videos_error"><![CDATA[Video is essential. Please upload a video file.]]></string>
     <string name="_bx_videos_form_entry_input_videos_upload"><![CDATA[Upload]]></string>
     <string name="_bx_videos_form_entry_input_sys_allow_view_to"><![CDATA[Visibility]]></string>
     <string name="_bx_videos_form_entry_input_allow_view_to"><![CDATA[Visibility]]></string>

+ 1 - 1
modules/boonex/videos/install/sql/install.sql

@@ -248,7 +248,7 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 ('bx_videos', 'bx_videos', 'do_publish', '_bx_videos_form_entry_input_do_publish', '', 0, 'submit', '_bx_videos_form_entry_input_sys_do_publish', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_videos', 'bx_videos', 'do_submit', '_bx_videos_form_entry_input_do_submit', '', 0, 'submit', '_bx_videos_form_entry_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_videos', 'bx_videos', 'location', '', '', 0, 'location', '_sys_form_input_sys_location', '_sys_form_input_location', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
-('bx_videos', 'bx_videos', 'videos', 'a:1:{i:0;s:15:"bx_videos_html5";}', 'a:2:{s:16:"bx_videos_simple";s:26:"_sys_uploader_simple_title";s:15:"bx_videos_html5";s:25:"_sys_uploader_html5_title";}', 0, 'files', '_bx_videos_form_entry_input_sys_videos', '_bx_videos_form_entry_input_videos', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
+('bx_videos', 'bx_videos', 'videos', 'a:1:{i:0;s:15:"bx_videos_html5";}', 'a:2:{s:16:"bx_videos_simple";s:26:"_sys_uploader_simple_title";s:15:"bx_videos_html5";s:25:"_sys_uploader_html5_title";}', 0, 'files', '_bx_videos_form_entry_input_sys_videos', '_bx_videos_form_entry_input_videos', '', 1, 0, 0, '', '', '', 'Avail', '', '_bx_videos_form_entry_input_videos_error', '', '', 1, 0),
 ('bx_videos', 'bx_videos', 'pictures', 'a:1:{i:0;s:15:"bx_videos_html5";}', 'a:2:{s:16:"bx_videos_simple";s:26:"_sys_uploader_simple_title";s:15:"bx_videos_html5";s:25:"_sys_uploader_html5_title";}', 0, 'files', '_bx_videos_form_entry_input_sys_pictures', '_bx_videos_form_entry_input_pictures', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_videos', 'bx_videos', 'text', '', '', 0, 'textarea', '_bx_videos_form_entry_input_sys_text', '_bx_videos_form_entry_input_text', '', 0, 0, 3, '', '', '', '', '', '', 'XssHtml', '', 1, 0),
 ('bx_videos', 'bx_videos', 'title', '', '', 0, 'text', '_bx_videos_form_entry_input_sys_title', '_bx_videos_form_entry_input_title', '', 1, 0, 0, '', '', '', 'Avail', '', '_bx_videos_form_entry_input_title_err', 'Xss', '', 1, 0),

+ 6 - 0
template/score_counter.html

@@ -0,0 +1,6 @@
+<bx_if:show_link>
+    <a id="__id__" class="__class__" href="javascript:void(0)" onclick="__onclick__" title="__title__">__content__</a>
+</bx_if:show_link>
+<bx_if:show_text>
+    <span id="__id__" class="__class__ bx-def-font-grayed">__content__</a>
+</bx_if:show_text>

+ 22 - 7
template/scripts/BxBaseScore.php

@@ -50,7 +50,7 @@ class BxBaseScore extends BxDolScore
             'show_do_vote_icon' => true,
             'show_do_vote_label' => false,
             'show_counter' => true,
-        	'show_counter_empty' => false,
+        	'show_counter_empty' => true,
         	'show_legend' => false
         );
 
@@ -139,20 +139,35 @@ class BxBaseScore extends BxDolScore
         $bShowDoVoteAsButton = !$bShowDoVoteAsButtonSmall && isset($aParams['show_do_vote_as_button']) && $aParams['show_do_vote_as_button'] == true;
 
         $aScore = $this->_oQuery->getScore($this->getId());
+
+        $iCup = (int)$aScore['count_up'];
+        $iCdown = (int)(int)$aScore['count_down'];
+        $bEmpty = $iCup == 0 && $iCdown == 0;
+
         $sClass = $this->_sStylePrefix . '-counter';
         if($bShowDoVoteAsButtonSmall)
             $sClass .= ' bx-btn-small-height';
         if($bShowDoVoteAsButton)
             $sClass .= ' bx-btn-height';
 
-        $iCup = (int)$aScore['count_up'];
-        $iCdown = (int)(int)$aScore['count_down'];
-        $sCounter = $bShowEmpty || $iCup > 0 || $iCdown > 0 ? $this->_getLabelCounter($iCup - $iCdown) : '';
-        return $this->_oTemplate->parseLink('javascript:void(0)', $sCounter, array(
+        $sCounter = !$bEmpty || $bShowEmpty ? $this->_getLabelCounter($iCup - $iCdown) : '';
+        $aTmplVars = array(
             'id' => $this->_aHtmlIds['counter'],
             'class' => $sClass,
             'title' => _t($this->_getTitleDoBy()),
-            'onclick' => 'javascript:' . $this->getJsClickCounter() 
+            'onclick' => 'javascript:' . $this->getJsClickCounter(),
+            'content' => $sCounter
+        );
+
+        return $this->_oTemplate->parseHtmlByName('score_counter.html', array(
+            'bx_if:show_link' => array(
+                'condition' => !$bEmpty,
+                'content' => $aTmplVars
+            ),
+            'bx_if:show_text' => array(
+                'condition' => $bEmpty,
+                'content' => $aTmplVars
+            ),
         ));
     }
 
@@ -302,7 +317,7 @@ class BxBaseScore extends BxDolScore
 
     protected function _getLabelCounter($iCount)
     {
-        return _t('_sys_score_counter', $iCount);
+        return (int)$iCount != 0 ? _t('_sys_score_counter', $iCount) : _t('_sys_score_counter_empty');
     }
 
     protected function _getLabelDo($sType, $aParams = array())