AntonLV преди 6 години
родител
ревизия
7a2229a371

+ 6 - 1
inc/classes/BxDolCmts.php

@@ -1189,6 +1189,11 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         return array('msg' => _t('_cmt_err_cannot_perform_action'));
     }
 
+    public function add($aValues)
+    {
+        return $this->_getFormAdd($aValues);
+    }
+
     public function actionResumeLiveUpdate()
     {
     	$sKey = $this->getNotificationId();
@@ -1197,7 +1202,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
     	BxDolSession::getInstance()->unsetValue($sKey);
     }
 
-	public function actionPauseLiveUpdate()
+    public function actionPauseLiveUpdate()
     {
     	$sKey = $this->getNotificationId();
 

+ 6 - 1
inc/classes/BxDolReport.php

@@ -72,6 +72,8 @@ class BxDolReport extends BxDolObject
 
     protected $_sBaseUrl;
 
+    protected $_sObjectCmts;
+
     protected $_sFormObject;
     protected $_sFormDisplayPost;
 
@@ -94,6 +96,8 @@ class BxDolReport extends BxDolObject
         if(get_mb_substr($this->_sBaseUrl, 0, 4) != 'http')
             $this->_sBaseUrl = BX_DOL_URL_ROOT . $this->_sBaseUrl;
 
+        $this->_sObjectCmts = $this->_aSystem['object_comment'];
+
         $this->_sFormObject = 'sys_report';
         $this->_sFormDisplayPost = 'sys_report_post';
 
@@ -141,6 +145,7 @@ class BxDolReport extends BxDolObject
                     `table_track` AS `table_track`,
                     `is_on` AS `is_on`,
                     `base_url` AS `base_url`,
+                    `object_comment` AS `object_comment`,
                     `trigger_table` AS `trigger_table`,
                     `trigger_field_id` AS `trigger_field_id`,
                     `trigger_field_author` AS `trigger_field_author`,
@@ -183,7 +188,7 @@ class BxDolReport extends BxDolObject
         return echoJson($this->_getReport());
     }
 
-	public function actionGetReportedBy()
+    public function actionGetReportedBy()
     {
         if (!$this->isEnabled())
            return '';

+ 9 - 0
inc/js/functions.js

@@ -708,6 +708,15 @@ function bx_set_badge (sModule, iContentId, iBadgeId, mixedLoadingElement) {
     }, 'json');
 }
 
+function bx_get_notes(oSource,  sModule, iContentId, oOptions, oVars) {
+    var oOptions = oOptions || {};
+    var oVars = oVars || {};
+
+    var oOptions = $.extend({}, $.fn.dolPopupDefaultOptions, {id: sModule + '_notes_' + iContentId, url: bx_append_url_params('modules/?r=' + sModule + '/get_notes/', $.extend({content_id: iContentId}, oVars))}, oOptions);
+
+    $(window).dolPopupAjax(oOptions);
+}
+
 
 function validateLoginForm(eForm) {
     return true;

+ 1 - 0
install/sql/system.sql

@@ -1710,6 +1710,7 @@ CREATE TABLE `sys_objects_report` (
   `table_track` varchar(32) NOT NULL,
   `is_on` tinyint(4) NOT NULL default '1',
   `base_url` varchar(256) NOT NULL default '',
+  `object_comment` varchar(64) NOT NULL,
   `trigger_table` varchar(32) NOT NULL,
   `trigger_field_id` varchar(32) NOT NULL,
   `trigger_field_author` varchar(32) NOT NULL,

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

@@ -82,6 +82,8 @@
 	<string name="_Please enter n1-n2 characters"><![CDATA[Please enter {0}-{1} characters]]></string>
 	<string name="_Please select value"><![CDATA[Please select a value from the list]]></string>
 	<string name="_Preview"><![CDATA[Preview]]></string>
+        <string name="_report_comment"><![CDATA[reported as '{0}']]></string>
+        <string name="_report_comment_with_note"><![CDATA[reported as '{0}' with a note: {1}]]></string>
 	<string name="_report_counter"><![CDATA[{0}]]></string>
 	<string name="_report_do_report"><![CDATA[Report]]></string>
 	<string name="_report_do_report_by"><![CDATA[Reported by]]></string>
@@ -2552,7 +2554,9 @@ If it is not enabled then please consider implement this optimization, since it
         <string name="_sys_menu_item_title_system_va_reaction"><![CDATA[Reaction]]></string>
         <string name="_sys_menu_item_title_system_va_repost"><![CDATA[Repost]]></string>
         <string name="_sys_menu_item_title_system_va_report"><![CDATA[Report]]></string>
+        <string name="_sys_menu_item_title_system_va_notes"><![CDATA[Notes]]></string>
         <string name="_sys_menu_item_title_system_va_more_auto"><![CDATA[More]]></string>
+        <string name="_sys_menu_item_title_va_notes"><![CDATA[Notes]]></string>
         <string name="_sys_menu_item_title_va_more_auto"><![CDATA[]]></string>
 	<string name="_sys_menu_item_title_system_social_sharing_facebook"><![CDATA[Share in Facebook]]></string>
     <string name="_sys_menu_item_title_system_social_sharing_twitter"><![CDATA[Share in Twitter]]></string>

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

@@ -82,6 +82,8 @@
 	<string name="_Please enter n1-n2 characters"><![CDATA[Пожалуйста, введите {0}-{1} символов]]></string>
 	<string name="_Please select value"><![CDATA[Пожалуйста, выберите значение из списка]]></string>
 	<string name="_Preview"><![CDATA[Предпросмотр]]></string>
+        <string name="_report_comment"><![CDATA[подал жалобу на '{0}']]></string>
+        <string name="_report_comment_with_note"><![CDATA[подал жалобу на '{0}' с пометкой: {1}]]></string>
 	<string name="_report_counter"><![CDATA[{0}]]></string>
 	<string name="_report_do_report"><![CDATA[Пожаловаться]]></string>
 	<string name="_report_do_report_by"><![CDATA[Пожаловались]]></string>
@@ -2537,7 +2539,9 @@
         <string name="_sys_menu_item_title_system_va_reaction"><![CDATA[Отреагировать]]></string>
         <string name="_sys_menu_item_title_system_va_repost"><![CDATA[Сделать репост]]></string>
         <string name="_sys_menu_item_title_system_va_report"><![CDATA[Пожаловаться]]></string>
+        <string name="_sys_menu_item_title_system_va_notes"><![CDATA[Заметки]]></string>
         <string name="_sys_menu_item_title_system_va_more_auto"><![CDATA[Еще]]></string>
+        <string name="_sys_menu_item_title_va_notes"><![CDATA[Заметки]]></string>
         <string name="_sys_menu_item_title_va_more_auto"><![CDATA[]]></string>
         <string name="_sys_menu_item_title_system_social_sharing_facebook"><![CDATA[Поделиться в Facebook]]></string>
     <string name="_sys_menu_item_title_system_social_sharing_twitter"><![CDATA[Поделиться в Twitter]]></string>

+ 67 - 0
template/scripts/BxBaseCmts.php

@@ -891,6 +891,73 @@ class BxBaseCmts extends BxDolCmts
         ));
     }
 
+    protected function _getFormAdd($aValues)
+    {
+        $iCmtAuthorId = isset($aValues['cmt_author_id']) ? (int)$aValues['cmt_author_id'] : $this->_getAuthorId();
+        $iCmtParentId = isset($aValues['cmt_parent_id']) ? (int)$aValues['cmt_parent_id'] : 0;
+
+        $oForm = $this->_getForm(BX_CMT_ACTION_POST, $iCmtParentId);
+        $oForm->aFormAttrs['method'] = BX_DOL_FORM_METHOD_SPECIFIC;
+        $oForm->aParams['csrf']['disable'] = true;
+        $oForm->aInputs['cmt_parent_id']['value'] = $iCmtParentId;
+        if(!empty($oForm->aParams['db']['submit_name'])) {            
+            $sSubmitName = false;
+            if(is_array($oForm->aParams['db']['submit_name']))
+                foreach($oForm->aParams['db']['submit_name'] as $sVal) {
+                    if(isset($oForm->aInputs[$sVal])) {
+                        $sSubmitName = $sVal;
+                        break;
+                    }
+                }
+            else
+                $sSubmitName = $oForm->aParams['db']['submit_name'];
+
+            if($sSubmitName && isset($oForm->aInputs[$sSubmitName]))
+                $aValues[$sSubmitName] = $oForm->aInputs[$sSubmitName]['value'];
+        }
+
+        $oForm->initChecker(array(), $aValues);
+        if(!$oForm->isSubmittedAndValid()) 
+            return array('code' => 1, 'message' => '_sys_txt_error_occured');
+
+        $iLevel = 0;
+        $iCmtVisualParentId = 0;
+        if((int)$iCmtParentId > 0) {
+            $aParent = $this->getCommentRow($iCmtParentId);
+
+            $iLevel = (int)$aParent['cmt_level'] + 1;
+            $iCmtVisualParentId = $iLevel > $this->getMaxLevel() ? $aParent['cmt_vparent_id'] : $iCmtParentId;
+        }
+
+        $iCmtId = (int)$oForm->insert(array('cmt_vparent_id' => $iCmtVisualParentId, 'cmt_object_id' => $this->_iId, 'cmt_author_id' => $iCmtAuthorId, 'cmt_level' => $iLevel, 'cmt_time' => time()));
+        if(!$iCmtId) {
+            if(!$oForm->isValid())
+                return array('code' => 1, 'message' => '_sys_txt_error_occured');
+            else
+                return array('code' => 2, 'message' => '_cmt_err_cannot_perform_action');
+        }
+
+        $iCmtUniqId = $this->_oQuery->getUniqId($this->_aSystem['system_id'], $iCmtId, $iCmtAuthorId);
+
+        if($iCmtParentId) {
+            $this->_oQuery->updateRepliesCount($iCmtParentId, 1);
+
+            if(!BxDolModuleQuery::getInstance()->isEnabledByName('bx_notifications'))
+                $this->_sendNotificationEmail($iCmtId, $iCmtParentId);
+        }
+
+        $this->_triggerComment();
+
+        if($this->_sMetatagsObj && ($oMetatags = BxDolMetatags::getObjectInstance($this->_sMetatagsObj)) !== false)
+            $oMetatags->metaAdd($iCmtUniqId, $aValues['cmt_text']);
+
+        $mixedResult = $this->onPostAfter($iCmtId);
+        if($mixedResult === false)
+            return array('code' => 2, 'message' => '_cmt_err_cannot_perform_action');
+
+        return $mixedResult;
+    }
+
     protected function _getFormPost($iCmtParentId = 0, $aDp = array())
     {
         $bCmtParentId = !empty($iCmtParentId);

+ 6 - 3
template/scripts/BxBaseMenuCustom.php

@@ -31,16 +31,19 @@ class BxBaseMenuCustom extends BxTemplMenuMoreAuto
             return false;
 
     	$sMethod = '_getMenuItem' . str_replace(' ', '', ucwords(str_replace('-', ' ', $aItem['name'])));
+        $bMethod = method_exists($this, $sMethod);
 
-    	if(!method_exists($this, $sMethod)) {
+        $mixedItem = false;
+        if($bMethod)
+            $mixedItem = $this->$sMethod($aItem);
+
+    	if($mixedItem === true || !$bMethod) {
             $aItem = parent::_getMenuItem($aItem);
             if($aItem === false)
                 return false;
 
             $mixedItem = $this->_getMenuItemDefault($aItem);
     	}
-    	else
-            $mixedItem = $this->$sMethod($aItem);
 
     	if(empty($mixedItem))
             return false;

+ 69 - 62
template/scripts/BxBaseReport.php

@@ -218,91 +218,98 @@ class BxBaseReport extends BxDolReport
 
     protected function _getReport()
     {
-    	if (!$this->isEnabled())
-           return array('code' => 1, 'message' => _t('_report_err_not_enabled'));
+        if (!$this->isEnabled())
+            return array('code' => 1, 'message' => _t('_report_err_not_enabled'));
 
-	    if(!$this->isAllowedReport())
+        if(!$this->isAllowedReport())
             return array('code' => 2, 'message' => $this->msgErrAllowedReport());
 
-    	$oForm = $this->_getFormObject();
-		$oForm->setId($this->_aHtmlIds['do_form']);
-		$oForm->setName($this->_aHtmlIds['do_form']);
-		$oForm->aParams['db']['table'] = $this->_aSystem['table_track'];
+        $oForm = $this->_getFormObject();
+        $oForm->setId($this->_aHtmlIds['do_form']);
+        $oForm->setName($this->_aHtmlIds['do_form']);
+        $oForm->aParams['db']['table'] = $this->_aSystem['table_track'];
         $oForm->aInputs['sys']['value'] = $this->_sSystem;
         $oForm->aInputs['object_id']['value'] = $this->_iId;
         $oForm->aInputs['action']['value'] = 'Report';
 
         $oForm->initChecker();
         if($oForm->isSubmittedAndValid()) {
-        	$iObjectId = $oForm->getCleanValue('object_id');
-	        $iObjectAuthorId = $this->_oQuery->getObjectAuthorId($iObjectId);
-	        $iAuthorId = $this->_getAuthorId();
-	        $iAuthorNip = ip2long($this->_getAuthorIp());
+            $iObjectId = $oForm->getCleanValue('object_id');
+            $iObjectAuthorId = $this->_oQuery->getObjectAuthorId($iObjectId);
+            $iAuthorId = $this->_getAuthorId();
+            $iAuthorNip = ip2long($this->_getAuthorIp());
 
-        	if(!$this->isAllowedReport(true))
-        		return array('code' => 2, 'message' => $this->msgErrAllowedReport());
+            if(!$this->isAllowedReport(true))
+                return array('code' => 2, 'message' => $this->msgErrAllowedReport());
 
-	        $bPerformed = $this->isPerformed($iObjectId, $iAuthorId);
-	        if($bPerformed)
-	        	return array('code' => 4, 'message' => _t('_report_err_duplicate_report'));
+            $bPerformed = $this->isPerformed($iObjectId, $iAuthorId);
+            if($bPerformed)
+                return array('code' => 4, 'message' => _t('_report_err_duplicate_report'));
 
-			$sType = $oForm->getCleanValue('type');
-	        if(!in_array($sType, $this->_aTypes)) 
-	        	return array('code' => 5, 'message' => _t('_report_err_wrong_type'));
+            $sType = $oForm->getCleanValue('type');
+            if(!in_array($sType, $this->_aTypes)) 
+                return array('code' => 5, 'message' => _t('_report_err_wrong_type'));
 
-			$sText = $oForm->getCleanValue('text');
+            $sText = $oForm->getCleanValue('text');
             $sText = bx_process_input($sText, BX_DATA_TEXT_MULTILINE);
             $oForm->setSubmittedValue('text', $sText, $oForm->aFormAttrs['method']);
 
-			$iId = (int)$oForm->insert(array('author_id' => $iAuthorId, 'author_nip' => $iAuthorNip, 'date' => time()));
-			if($iId != 0 && $this->_oQuery->putReport($iObjectId)) {
-				$this->_trigger();
-
-        		$aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_Reported', array(
-        			'report_type' => $sType,
-        			'report_text' => $sText,
-        			'report_url' => $this->getBaseUrl(),
-        		));
-        		if($aTemplate)
-        			sendMail(getParam('site_email'), $aTemplate['Subject'], $aTemplate['Body']);
-
-		        $oZ = new BxDolAlerts($this->_sSystem, 'doReport', $iObjectId, $iAuthorId, array('report_id' => $iId, 'report_author_id' => $iAuthorId, 'object_author_id' => $iObjectAuthorId, 'type' => $sType, 'text' => $sText));
-		        $oZ->alert();
-		
-		        $oZ = new BxDolAlerts('report', 'do', $iId, $iAuthorId, array('object_system' => $this->_sSystem, 'object_id' => $iObjectId, 'object_author_id' => $iObjectAuthorId, 'type' => $sType, 'text' => $sText));
-		        $oZ->alert();
-                $mixedParams = $this->_prepareAuditParams($iObjectId, array('type' => $sType, 'text' => $sText));
-                if ($mixedParams){
-                    bx_audit(
-                        $iObjectId, 
-                        $this->_sSystem, 
-                        '_sys_audit_action_report',  
-                        $mixedParams
-                    );
+            $iId = (int)$oForm->insert(array('author_id' => $iAuthorId, 'author_nip' => $iAuthorNip, 'date' => time()));
+            if($iId != 0 && $this->_oQuery->putReport($iObjectId)) {
+                $this->_trigger();
+
+                if(!empty($this->_sObjectCmts) && ($oCmts = BxDolCmts::getObjectInstance($this->_sObjectCmts, $this->getId()))) {
+                    $sCmtText = '_report_comment';
+                    if(!empty($sText))
+                        $sCmtText = '_report_comment_with_note';
+                    
+                    $aTypes = BxDolForm::getDataItems('sys_report_types');
+
+                    $oCmts->add(array(
+                        'cmt_author_id' => $iAuthorId,
+                        'cmt_parent_id' => 0,
+                        'cmt_text' => _t($sCmtText, $aTypes[$sType], $sText)
+                    ));
                 }
 
-		        $aReport = $this->_oQuery->getReport($iObjectId);
-		        return array(
-		        	'eval' => $this->getJsObjectName() . '.onReport(oData, oElement)',
-		        	'code' => 0,
-		        	'id' => $iId, 
-		        	'count' => $aReport['count'], 
-		        	'countf' => (int)$aReport['count'] > 0 ? $this->_getCounterLabel($aReport['count']) : '',
-		        	'label_icon' => $this->_getIconDoReport(!$bPerformed),
-		        	'label_title' => _t($this->_getTitleDoReport(!$bPerformed)),
-		        	'disabled' => !$bPerformed
-		        );
-			}
-
-			return array('code' => 3, 'message' => _t('_report_err_cannot_perform_action'));
+                $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_Reported', array(
+                    'report_type' => $sType,
+                    'report_text' => $sText,
+                    'report_url' => $this->getBaseUrl(),
+                ));
+                if($aTemplate)
+                    sendMail(getParam('site_email'), $aTemplate['Subject'], $aTemplate['Body']);
+
+                bx_alert($this->_sSystem, 'doReport', $iObjectId, $iAuthorId, array('report_id' => $iId, 'report_author_id' => $iAuthorId, 'object_author_id' => $iObjectAuthorId, 'type' => $sType, 'text' => $sText));
+
+                bx_alert('report', 'do', $iId, $iAuthorId, array('object_system' => $this->_sSystem, 'object_id' => $iObjectId, 'object_author_id' => $iObjectAuthorId, 'type' => $sType, 'text' => $sText));
+
+                $mixedParams = $this->_prepareAuditParams($iObjectId, array('type' => $sType, 'text' => $sText));
+                if($mixedParams)
+                    bx_audit($iObjectId, $this->_sSystem, '_sys_audit_action_report', $mixedParams);
+
+                $aReport = $this->_oQuery->getReport($iObjectId);
+                return array(
+                        'eval' => $this->getJsObjectName() . '.onReport(oData, oElement)',
+                        'code' => 0,
+                        'id' => $iId, 
+                        'count' => $aReport['count'], 
+                        'countf' => (int)$aReport['count'] > 0 ? $this->_getCounterLabel($aReport['count']) : '',
+                        'label_icon' => $this->_getIconDoReport(!$bPerformed),
+                        'label_title' => _t($this->_getTitleDoReport(!$bPerformed)),
+                        'disabled' => !$bPerformed
+                );
+            }
+
+            return array('code' => 3, 'message' => _t('_report_err_cannot_perform_action'));
         }
 
         $sPopupId = $this->_aHtmlIds['do_popup'];
         $sPopupContent = BxTemplFunctions::getInstance()->transBox($sPopupId, $this->_oTemplate->parseHtmlByName('report_do_report_form.html', array(
             'style_prefix' => $this->_sStylePrefix,
-        	'js_object' => $this->getJsObjectName(),
-        	'form' => $oForm->getCode(),
-        	'form_id' => $oForm->id,
+                'js_object' => $this->getJsObjectName(),
+                'form' => $oForm->getCode(),
+                'form_id' => $oForm->id,
         )));
 
         return array('popup' => $sPopupContent, 'popup_id' => $sPopupId);