Răsfoiți Sursa

#2842 Reviews module with multi voting options

Alexander 6 ani în urmă
părinte
comite
9f52a0a6da

+ 5 - 2
modules/boonex/reviews/classes/BxReviewsConfig.php

@@ -87,6 +87,7 @@ class BxReviewsConfig extends BxBaseModTextConfig
             'PARAM_NUM_RSS' => 'bx_reviews_rss_num',
             'PARAM_NUM_RSS' => 'bx_reviews_rss_num',
             'PARAM_SEARCHABLE_FIELDS' => 'bx_reviews_searchable_fields',
             'PARAM_SEARCHABLE_FIELDS' => 'bx_reviews_searchable_fields',
             'PARAM_PER_PAGE_BROWSE_SHOWCASE' => 'bx_reviews_per_page_browse_showcase',
             'PARAM_PER_PAGE_BROWSE_SHOWCASE' => 'bx_reviews_per_page_browse_showcase',
+            'PARAM_MAX_STARS' => 'bx_reviews_voting_max_stars',
 
 
             // objects
             // objects
             'OBJECT_STORAGE' => 'bx_reviews_covers',
             'OBJECT_STORAGE' => 'bx_reviews_covers',
@@ -203,12 +204,14 @@ class BxReviewsConfig extends BxBaseModTextConfig
         
         
         $this->_aJsClasses = array_merge($this->_aJsClasses, array(
         $this->_aJsClasses = array_merge($this->_aJsClasses, array(
             'manage_tools' => 'BxReviewsManageTools',
             'manage_tools' => 'BxReviewsManageTools',
-            'categories' => 'BxDolCategories'
+            'categories' => 'BxDolCategories',
+            'multi_voting' => 'BxReviewsVoteStars',
         ));
         ));
 
 
         $this->_aJsObjects = array_merge($this->_aJsObjects, array(
         $this->_aJsObjects = array_merge($this->_aJsObjects, array(
             'manage_tools' => 'oBxReviewsManageTools',
             'manage_tools' => 'oBxReviewsManageTools',
-             'categories' => 'oBxDolCategories'
+            'categories' => 'oBxDolCategories',
+            'multi_voting' => 'oBxReviewsVoteStars',
         ));
         ));
 
 
         $this->_aGridObjects = array(
         $this->_aGridObjects = array(

+ 10 - 0
modules/boonex/reviews/classes/BxReviewsDb.php

@@ -18,6 +18,16 @@ class BxReviewsDb extends BxBaseModTextDb
     {
     {
         parent::__construct($oConfig);
         parent::__construct($oConfig);
     }
     }
+
+    public function getVotingOptionLKey($iOptionId) {
+        return $this->getOne("SELECT `lkey` FROM `bx_reviews_voting_options` WHERE `id` = :id", [
+            'id' => $iOptionId,
+        ]);
+    }
+
+    public function getVotingOptions() {
+        return $this->getAll("SELECT `id`, `lkey` FROM `bx_reviews_voting_options` ORDER BY `order`");
+    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 17 - 0
modules/boonex/reviews/classes/BxReviewsFormEntry.php

@@ -175,6 +175,23 @@ class BxReviewsFormEntry extends BxBaseModTextFormEntry
             'editor_id' => isset($CNF['FIELD_TEXT_ID']) ? $CNF['FIELD_TEXT_ID'] : ''
             'editor_id' => isset($CNF['FIELD_TEXT_ID']) ? $CNF['FIELD_TEXT_ID'] : ''
     	);
     	);
     }
     }
+
+    protected function genCustomInputVotingOptions ($aInput)
+    {
+        return $this->_oModule->_oTemplate->getMultiVoting(isset($aInput['value']) ? $aInput['value'] : array(), true);
+    }
+}
+
+class BxReviewsFormEntryCheckerHelper extends BxDolFormCheckerHelper {
+    public function passVotingOptions ($s) {
+        if (!is_array($s))
+            return false;
+        return serialize($s);
+    }
+
+    public function displayVotingOptions ($s) {
+        return unserialize($s);
+    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 167 - 0
modules/boonex/reviews/classes/BxReviewsGridVotingOptions.php

@@ -0,0 +1,167 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Reviews Reviews
+ * @ingroup     UnaModules
+ * 
+ * @{
+ */
+
+class BxReviewsGridVotingOptions extends BxTemplGrid
+{
+    public function __construct ($aOptions, $oTemplate = false)
+    {
+    	$this->MODULE = 'bx_reviews';
+        parent::__construct ($aOptions, $oTemplate);
+    }
+
+    private function getVotingOptionForm($iVotingOptionId, $sLKey, $sActionurl) {
+        $aForm = [
+            'form_attrs' => [
+                'id' => 'bx-reviews-voting-option-form',
+                'action' => bx_append_url_params($sActionurl, 'ids[]='.$iVotingOptionId),
+                'method' => 'post'
+            ],
+            'params' => [
+                'db' => [
+                    'table' => 'bx_reviews_voting_options',
+                    'key' => 'id',
+                    'uri' => '',
+                    'uri_title' => '',
+                    'submit_name' => 'do_submit'
+                ],
+            ],
+            'inputs' => [
+                'id' => [
+                    'type' => 'hidden',
+                    'name' => 'id',
+                    'value' => $iVotingOptionId,
+                    'db' => [
+                        'pass' => 'Int',
+                    ],
+                ],
+                'lkey' => [
+                    'type' => 'text_translatable',
+                    'name' => 'lkey',
+                    'caption' => _t('_bx_reviews_form_entry_input_option_name'),
+                    'value' => $sLKey,
+                    'required' => '1',
+                    'db' => [
+                        'pass' => 'Xss',
+                    ],
+                    'checker' => [
+                        'func' => 'LengthTranslatable',
+                        'params' => [3, 100, 'lkey'],
+                        'error' => _t('_bx_reviews_form_entry_input_option_name_err'),
+                    ],
+                ],
+                'controls' => [
+                    'name' => 'controls',
+                    'type' => 'input_set',
+                    [
+                        'type' => 'submit',
+                        'name' => 'do_submit',
+                        'value' => _t('_bx_reviews_form_entry_input_do_submit')
+                    ],
+                    [
+                        'type' => 'reset',
+                        'name' => 'close',
+                        'value' => _t('_bx_reviews_txt_cancel'),
+                        'attrs' => [
+                            'onclick' => '$(this).closest(\'.bx-popup-responsive\').dolPopupHide();',
+                            'class' => 'bx-def-margin-sec-left',
+                        ],
+                    ]
+                ]
+            ]
+        ];
+
+        $oForm = new BxTemplStudioFormView($aForm);
+        $oForm->initChecker();
+        return $oForm;
+    }
+
+    public function performActionAdd() {
+        $this->performActionAddEdit('add', 0, '');
+    }
+
+    public function performActionEdit() {
+        $aIds = bx_get('ids');
+        if (!$aIds || !is_array($aIds)) {
+            echoJson(array());
+            exit;
+        }
+
+        $iOptionId = $aIds[0];
+        $oModule = BxDolModule::getInstance($this->MODULE);
+        $sLkey = $oModule->_oDb->getVotingOptionLKey($iOptionId);
+
+        $this->performActionAddEdit('edit', $iOptionId, $sLkey);
+    }
+
+    public function performActionDelete() {
+        $aIds = bx_get('ids');
+        if (!$aIds || !is_array($aIds)) {
+            echoJson(array());
+            exit;
+        }
+
+        $iOptionId = $aIds[0];
+        $oModule = BxDolModule::getInstance($this->MODULE);
+        $sLkey = $oModule->_oDb->getVotingOptionLKey($iOptionId);
+
+        $oLanguage = BxDolStudioLanguagesUtils::getInstance();
+        $oLanguage->deleteLanguageString($sLkey);
+
+        return parent::performActionDelete();
+    }
+
+    private function performActionAddEdit($sAction, $iVotingOptionId, $sLKey) {
+        $oForm = $this->getVotingOptionForm($iVotingOptionId, $sLKey, BX_DOL_URL_ROOT.'grid.php?o=' . $this->_sObject . '&a=' . $sAction);
+        if ($oForm->isSubmittedAndValid()) {
+            if ($sAction == 'add') {
+                $iSuccessId = $oForm->insert();
+            }
+            if ($sAction == 'edit') {
+                $oForm->update($iVotingOptionId);
+                $iSuccessId = $iVotingOptionId;
+            }
+
+            if ($iSuccessId) {
+                $aRes = array('grid' => $this->getCode(false), 'blink' => $iSuccessId);
+            } else
+                $aRes = array('msg' => "Error occured"); // if record adding failed, display error message
+
+            echoJson($aRes);
+        } else {
+            $s = PopupBox('bx-reviews-popup', _t('_bx_reviews_popup_voting_option_title'), $oForm->getCode().'                
+                <script>
+                    function bx_grid_ajax_form() {
+                        $("#'.$oForm->aFormAttrs['id'].'").ajaxForm({
+                            dataType: "json",
+                            beforeSubmit: function (formData, jqForm, options) {
+                                bx_loading($("#' . $oForm->aFormAttrs['id'] . '"), true);
+                            },
+                            success: function (data) {
+                                $(".bx-popup-active:visible").dolPopupHide();
+                                glGrids.' . $this->_sObject . '.processJson(data, "add");
+                            }
+                        });
+                    }
+                </script>');
+
+            echoJson([
+                'popup' => [
+                    'html' => $s,
+                    'options' => [
+                        'onShow' => 'bx_grid_ajax_form();'
+                    ]
+                ]
+            ]);
+        }
+    }
+}
+
+/** @} */

+ 25 - 0
modules/boonex/reviews/classes/BxReviewsModule.php

@@ -62,6 +62,31 @@ class BxReviewsModule extends BxBaseModTextModule
 
 
         return parent::serviceCheckAllowedCommentsView($iContentId, $sObjectComments);
         return parent::serviceCheckAllowedCommentsView($iContentId, $sObjectComments);
     }
     }
+
+
+    /*
+     * Rating block for entry view page
+     **/
+    public function serviceEntityVotingOptions($iContentId = 0) {
+        if (!$iContentId) $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+
+        if ($iContentId) {
+            $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+            $aOptions = !empty($aContentInfo['voting_options']) ? unserialize($aContentInfo['voting_options']) : array();
+            return $this->_oTemplate->getMultiVoting($aOptions, false);
+        }
+        return '';
+    }
+
+     /*
+     * ACTIONS
+     */
+    public function actionGetReviewRatingDetails($iContentId) {
+        $sVoting = $this->serviceEntityVotingOptions($iContentId);
+
+        if (!empty($sVoting))
+            echo PopupBox('bx_reviews_rating', _t('_bx_reviews_txt_rating_details_popup_cpt'), $sVoting);
+    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 1 - 1
modules/boonex/reviews/classes/BxReviewsSearchResult.php

@@ -21,7 +21,7 @@ class BxReviewsSearchResult extends BxBaseModTextSearchResult
             'object_metatags' => 'bx_reviews',
             'object_metatags' => 'bx_reviews',
             'title' => _t('_bx_reviews_page_title_browse'),
             'title' => _t('_bx_reviews_page_title_browse'),
             'table' => 'bx_reviews_reviews',
             'table' => 'bx_reviews_reviews',
-            'ownFields' => array('id', 'title', 'text', 'thumb', 'author', 'added'),
+            'ownFields' => array('id', 'title', 'text', 'thumb', 'author', 'added', 'voting_options'),
             'searchFields' => array(),
             'searchFields' => array(),
             'restriction' => array(
             'restriction' => array(
                 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),
                 'author' => array('value' => '', 'field' => 'author', 'operator' => '='),

+ 15 - 0
modules/boonex/reviews/classes/BxReviewsStudioPage.php

@@ -20,6 +20,21 @@ class BxReviewsStudioPage extends BxTemplStudioModule
     	$this->_oModule = BxDolModule::getInstance($this->_sModule);
     	$this->_oModule = BxDolModule::getInstance($this->_sModule);
 
 
         parent::__construct($sModule, $sPage);
         parent::__construct($sModule, $sPage);
+
+        $this->aMenuItems = [
+            ['name' => 'settings', 'icon' => 'cog', 'title' => '_bx_reviews_txt_settings'],
+            ['name' => 'voting_options', 'icon' => 'star', 'title' => '_bx_reviews_txt_voting_options'],
+        ];
+    }
+
+    protected function getVoting_Options()
+    {
+        bx_import('BxTemplGrid');
+        /** @noinspection PhpParamsInspection */
+        $oGrid = BxDolGrid::getObjectInstance('bx_reviews_voting_options', BxDolStudioTemplate::getInstance());
+        if (!$oGrid) die('"bx_reviews_voting_options" grid object is not defined');
+
+        return $oGrid->getCode();
     }
     }
 }
 }
 
 

+ 118 - 0
modules/boonex/reviews/classes/BxReviewsTemplate.php

@@ -21,6 +21,11 @@ class BxReviewsTemplate extends BxBaseModTextTemplate
         parent::__construct($oConfig, $oDb);
         parent::__construct($oConfig, $oDb);
     }
     }
 
 
+    protected function _addCommonJs() {
+        $sRes = $this->addJs(['BxDolVoteStars.js', 'BxReviewsVoteStars.js'], bx_is_dynamic_request());
+        if (bx_is_dynamic_request()) return $sRes;
+    }
+
     /**
     /**
      * Use Gallery image for both because currently there is no Unit types with small thumbnails.
      * Use Gallery image for both because currently there is no Unit types with small thumbnails.
      */
      */
@@ -30,6 +35,119 @@ class BxReviewsTemplate extends BxBaseModTextTemplate
 
 
         return array($sPhotoGallery, $sPhotoGallery);
         return array($sPhotoGallery, $sPhotoGallery);
     }
     }
+
+    public function getMultiVoting($aValue, $isAllowedVote) {
+        $aOptions = $this->_oModule->_oDb->getVotingOptions();
+        if (empty($aOptions)) return '';
+
+        $CNF = &$this->_oConfig->CNF;
+
+        $sJsObject = $this->_oConfig->getJsObject('multi_voting');
+        $sJsCode = $this->getJsCode('multi_voting');
+
+        $iMinValue = 1;
+        $iMaxValue = $this->_oDb->getParam($CNF['PARAM_MAX_STARS']);
+
+        $aTmplVarsStars = $aTmplVarsSlider = $aTmplVarsButtons = [];
+        for($i = $iMinValue; $i <= $iMaxValue; $i++) {
+            $aTmplVarsStars[] = ['style_prefix' => 'bx-vote', 'value' => $i];
+            $aTmplVarsSlider[] = ['style_prefix' => 'bx-vote'];
+            if($isAllowedVote) $aTmplVarsButtons[] = [
+                'style_prefix' => 'bx-vote',
+                'js_object' => $sJsObject,
+                'value' => $i
+            ];
+        }
+
+        $sStars = $this->parseHtmlByName('vote_do_vote_stars.html', [
+            'style_prefix' => 'bx-vote',
+            'bx_repeat:stars' => $aTmplVarsStars,
+            'bx_repeat:slider' => $aTmplVarsSlider,
+            'bx_repeat:buttons' => $aTmplVarsButtons,
+            'bx_if:show_legend' => ['condition' => false, 'content' => []],
+        ]);
+
+        $aTmplOptions = [];
+        foreach ($aOptions as $aOption) {
+            $iRate = isset($aValue[$aOption['id']]) ? $aValue[$aOption['id']] : 0;
+            if (!$isAllowedVote && !$iRate) continue;
+
+            $aTmplOptions[] = [
+                'voting_option_name' => htmlspecialchars_adv(_t($aOption['lkey'])),
+                'style_prefix' => 'bx-vote',
+                'rate' => $iRate,
+                'stars' => $sStars,
+                'bx_if:vote_allowed' => ['condition' => $isAllowedVote, 'content' => [
+                    'option_id' => $aOption['id'],
+                    'rate' => $iRate,
+                ]],
+            ];
+        }
+        if (empty($aTmplOptions)) return false;
+
+        return $this->parseHtmlByName('voting_multi_stars.html', [
+            'js_code' => $this->_addCommonJs().$sJsCode,
+            'bx_repeat:voting_options' => $aTmplOptions,
+        ]);
+    }
+
+    public function getOverallRating($iEntryId, $sEntryRatings) {
+        if (empty($sEntryRatings)) return '';
+        $aEntryRatings = unserialize($sEntryRatings);
+
+        $sJsCode = $this->getJsCode('multi_voting');
+
+        $iCount = 0;
+        $iSum = 0;
+        foreach ($aEntryRatings as $iRating) {
+            if ($iRating) {
+                $iSum += $iRating;
+                $iCount++;
+            }
+        }
+        if (!$iCount) return '';
+        $fRate = $iSum/$iCount;
+
+        $CNF = &$this->_oConfig->CNF;
+
+        $iMinValue = 1;
+        $iMaxValue = $this->_oDb->getParam($CNF['PARAM_MAX_STARS']);
+
+        $aTmplVarsStars = $aTmplVarsSlider = $aTmplVarsButtons = [];
+        for($i = $iMinValue; $i <= $iMaxValue; $i++) {
+            $aTmplVarsStars[] = ['style_prefix' => 'bx-vote', 'value' => $i];
+            $aTmplVarsSlider[] = ['style_prefix' => 'bx-vote'];
+        }
+
+        $sStars = $this->parseHtmlByName('vote_do_vote_stars.html', [
+            'style_prefix' => 'bx-vote',
+            'bx_repeat:stars' => $aTmplVarsStars,
+            'bx_repeat:slider' => $aTmplVarsSlider,
+            'bx_repeat:buttons' => $aTmplVarsButtons,
+            'bx_if:show_legend' => ['condition' => false, 'content' => []],
+        ]);
+
+        return $this->parseHtmlByName('unit_rating.html', [
+            'rate' => $fRate,
+            'stars' => $sStars,
+            'details_action_url' => BX_DOL_URL_ROOT.$this->_oConfig->getBaseUri().'get_review_rating_details/'.$iEntryId,
+            'js_code' => $this->_addCommonJs().$sJsCode,
+        ]);
+    }
+
+    protected function getUnit($aData, $aParams = array())
+    {
+        $aResult = parent::getUnit($aData, $aParams);
+
+        $sEntryRating = $this->getOverallRating($aData['id'], $aData['voting_options']);
+        if ($sEntryRating) {
+            $aResult['bx_if:meta']['condition'] = true;
+            if (!isset($aResult['bx_if:meta']['content']['meta'])) $aResult['bx_if:meta']['content']['meta'] = '';
+            $aResult['bx_if:meta']['content']['meta'] = $sEntryRating.$aResult['bx_if:meta']['content']['meta'];
+        }
+
+        return $aResult;
+    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 18 - 0
modules/boonex/reviews/install/langs/en.xml

@@ -315,4 +315,22 @@
     <string name="_bx_reviews_txt_poll_answer_vote_do_by"><![CDATA[Voted for]]></string>
     <string name="_bx_reviews_txt_poll_answer_vote_do_by"><![CDATA[Voted for]]></string>
     <string name="_bx_reviews_txt_poll_answer_vote_counter"><![CDATA[{0} votes]]></string>
     <string name="_bx_reviews_txt_poll_answer_vote_counter"><![CDATA[{0} votes]]></string>
     <string name="_bx_reviews_txt_poll_answer_vote_percent"><![CDATA[({0}%)]]></string>
     <string name="_bx_reviews_txt_poll_answer_vote_percent"><![CDATA[({0}%)]]></string>
+
+    <string name="_bx_reviews_txt_settings"><![CDATA[Settings]]></string>
+    <string name="_bx_reviews_txt_voting_options"><![CDATA[Voting Options]]></string>
+    <string name="_bx_reviews_grid_column_title_adm_name"><![CDATA[Option]]></string>
+    <string name="_bx_reviews_form_entry_input_option_name"><![CDATA[Option title]]></string>
+    <string name="_bx_reviews_form_entry_input_option_name_err"><![CDATA[Option title is required and must be at least 3 characters length]]></string>
+    <string name="_bx_reviews_popup_voting_option_title"><![CDATA[Voting Option details]]></string>
+    <string name="_bx_reviews_txt_cancel"><![CDATA[Cancel]]></string>
+    <string name="_bx_reviews_form_entry_input_sys_voting_options"><![CDATA[Voting Options]]></string>
+    <string name="_bx_reviews_form_entry_input_voting_options"><![CDATA[]]></string>
+    <string name="_bx_reviews_option_voting_max_stars"><![CDATA[Max number of stars for a voting option]]></string>
+    <string name="_bx_reviews_page_block_title_entry_voting_options"><![CDATA[Review stars]]></string>
+    <string name="_bx_reviews_txt_rating_details"><![CDATA[Details]]></string>
+    <string name="_bx_reviews_txt_rating_details_popup_cpt"><![CDATA[Rating Details]]></string>
+
+
+
+
 </resources>
 </resources>

+ 3 - 3
modules/boonex/reviews/install/sql/disable.sql

@@ -38,9 +38,9 @@ DELETE FROM `sys_statistics` WHERE `name` LIKE 'bx_reviews%';
 DELETE FROM `sys_objects_chart` WHERE `object` LIKE 'bx_reviews%';
 DELETE FROM `sys_objects_chart` WHERE `object` LIKE 'bx_reviews%';
 
 
 -- GRIDS
 -- GRIDS
-DELETE FROM `sys_objects_grid` WHERE `object` IN ('bx_reviews_administration', 'bx_reviews_common');
-DELETE FROM `sys_grid_fields` WHERE `object` IN ('bx_reviews_administration', 'bx_reviews_common');
-DELETE FROM `sys_grid_actions` WHERE `object` IN ('bx_reviews_administration', 'bx_reviews_common');
+DELETE FROM `sys_objects_grid` WHERE `object` IN ('bx_reviews_administration', 'bx_reviews_common', 'bx_reviews_voting_options');
+DELETE FROM `sys_grid_fields` WHERE `object` IN ('bx_reviews_administration', 'bx_reviews_common', 'bx_reviews_voting_options');
+DELETE FROM `sys_grid_actions` WHERE `object` IN ('bx_reviews_administration', 'bx_reviews_common', 'bx_reviews_voting_options');
 
 
 -- UPLOADERS
 -- UPLOADERS
 DELETE FROM `sys_objects_uploader` WHERE `object` LIKE 'bx_reviews_%';
 DELETE FROM `sys_objects_uploader` WHERE `object` LIKE 'bx_reviews_%';

+ 11 - 2
modules/boonex/reviews/install/sql/enable.sql

@@ -18,7 +18,8 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_reviews_per_page_browse_showcase', '32', @iCategId, '_sys_option_per_page_browse_showcase', 'digit', '', '', '', 15),
 ('bx_reviews_per_page_browse_showcase', '32', @iCategId, '_sys_option_per_page_browse_showcase', 'digit', '', '', '', 15),
 ('bx_reviews_rss_num', '10', @iCategId, '_bx_reviews_option_rss_num', 'digit', '', '', '', 20),
 ('bx_reviews_rss_num', '10', @iCategId, '_bx_reviews_option_rss_num', 'digit', '', '', '', 20),
 ('bx_reviews_searchable_fields', 'title,text', @iCategId, '_bx_reviews_option_searchable_fields', 'list', '', '', 'a:2:{s:6:"module";s:10:"bx_reviews";s:6:"method";s:21:"get_searchable_fields";}', 30),
 ('bx_reviews_searchable_fields', 'title,text', @iCategId, '_bx_reviews_option_searchable_fields', 'list', '', '', 'a:2:{s:6:"module";s:10:"bx_reviews";s:6:"method";s:21:"get_searchable_fields";}', 30),
-('bx_reviews_auto_activation_for_categories', 'on', @iCategId, '_bx_reviews_option_auto_activation_for_categories', 'checkbox', '', '', '', 35);
+('bx_reviews_auto_activation_for_categories', 'on', @iCategId, '_bx_reviews_option_auto_activation_for_categories', 'checkbox', '', '', '', 35),
+('bx_reviews_voting_max_stars', '5', @iCategId, '_bx_reviews_option_voting_max_stars', 'digit', '', '', '', 40);
 
 
 -- PAGE: create entry
 -- PAGE: create entry
 
 
@@ -55,6 +56,7 @@ INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `lay
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
 ('bx_reviews_view_entry', 2, 'bx_reviews', '', '_bx_reviews_page_block_title_entry_text', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:"bx_reviews";s:6:\"method\";s:17:\"entity_text_block\";}', 0, 0, 1, 2),
 ('bx_reviews_view_entry', 2, 'bx_reviews', '', '_bx_reviews_page_block_title_entry_text', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:"bx_reviews";s:6:\"method\";s:17:\"entity_text_block\";}', 0, 0, 1, 2),
 ('bx_reviews_view_entry', 2, 'bx_reviews', '', '_bx_reviews_page_block_title_entry_author', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:"bx_reviews";s:6:\"method\";s:13:\"entity_author\";}', 0, 0, 1, 1),
 ('bx_reviews_view_entry', 2, 'bx_reviews', '', '_bx_reviews_page_block_title_entry_author', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:"bx_reviews";s:6:\"method\";s:13:\"entity_author\";}', 0, 0, 1, 1),
+('bx_reviews_view_entry', 3, 'bx_reviews', '', '_bx_reviews_page_block_title_entry_voting_options', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:"bx_reviews";s:6:\"method\";s:21:\"entity_voting_options\";}', 0, 0, 1, 0),
 ('bx_reviews_view_entry', 3, 'bx_reviews', '_bx_reviews_page_block_title_sys_entry_context', '_bx_reviews_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:"bx_reviews";s:6:\"method\";s:14:\"entity_context\";}', 0, 0, 1, 1),
 ('bx_reviews_view_entry', 3, 'bx_reviews', '_bx_reviews_page_block_title_sys_entry_context', '_bx_reviews_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:"bx_reviews";s:6:\"method\";s:14:\"entity_context\";}', 0, 0, 1, 1),
 ('bx_reviews_view_entry', 3, 'bx_reviews', '', '_bx_reviews_page_block_title_entry_info', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:"bx_reviews";s:6:\"method\";s:11:\"entity_info\";}', 0, 0, 1, 2),
 ('bx_reviews_view_entry', 3, 'bx_reviews', '', '_bx_reviews_page_block_title_entry_info', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:"bx_reviews";s:6:\"method\";s:11:\"entity_info\";}', 0, 0, 1, 2),
 ('bx_reviews_view_entry', 3, 'bx_reviews', '', '_bx_reviews_page_block_title_entry_location', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:"bx_reviews";s:6:\"method\";s:15:\"entity_location\";}', 0, 0, 0, 0),
 ('bx_reviews_view_entry', 3, 'bx_reviews', '', '_bx_reviews_page_block_title_entry_location', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:10:"bx_reviews";s:6:\"method\";s:15:\"entity_location\";}', 0, 0, 0, 0),
@@ -438,6 +440,7 @@ INSERT INTO `sys_objects_chart` (`object`, `title`, `table`, `field_date_ts`, `f
 -- GRIDS: moderation tools
 -- GRIDS: moderation tools
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
 ('bx_reviews_administration', 'Sql', 'SELECT * FROM `bx_reviews_reviews` WHERE 1 ', 'bx_reviews_reviews', 'id', 'added', 'status_admin', '', 20, NULL, 'start', '', 'title,text', '', 'like', 'reports', '', 192, 'BxReviewsGridAdministration', 'modules/boonex/reviews/classes/BxReviewsGridAdministration.php'),
 ('bx_reviews_administration', 'Sql', 'SELECT * FROM `bx_reviews_reviews` WHERE 1 ', 'bx_reviews_reviews', 'id', 'added', 'status_admin', '', 20, NULL, 'start', '', 'title,text', '', 'like', 'reports', '', 192, 'BxReviewsGridAdministration', 'modules/boonex/reviews/classes/BxReviewsGridAdministration.php'),
+('bx_reviews_voting_options', 'Sql', 'SELECT `id`, `lkey` FROM `bx_reviews_voting_options` WHERE 1 ', 'bx_reviews_voting_options', 'id', 'order', '', 20, NULL, 'start', '', '', '', '', '', '', '', 192, 'BxReviewsGridVotingOptions', 'modules/boonex/reviews/classes/BxReviewsGridVotingOptions.php'),
 ('bx_reviews_common', 'Sql', 'SELECT * FROM `bx_reviews_reviews` WHERE 1 ', 'bx_reviews_reviews', 'id', 'added', 'status', '', 20, NULL, 'start', '', 'title,text', '', 'like', '', '', 2147483647, 'BxReviewsGridCommon', 'modules/boonex/reviews/classes/BxReviewsGridCommon.php');
 ('bx_reviews_common', 'Sql', 'SELECT * FROM `bx_reviews_reviews` WHERE 1 ', 'bx_reviews_reviews', 'id', 'added', 'status', '', 20, NULL, 'start', '', 'title,text', '', 'like', '', '', 2147483647, 'BxReviewsGridCommon', 'modules/boonex/reviews/classes/BxReviewsGridCommon.php');
 
 
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES
@@ -448,6 +451,9 @@ INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable
 ('bx_reviews_administration', 'added', '_bx_reviews_grid_column_title_adm_added', '20%', 1, '25', '', 5),
 ('bx_reviews_administration', 'added', '_bx_reviews_grid_column_title_adm_added', '20%', 1, '25', '', 5),
 ('bx_reviews_administration', 'author', '_bx_reviews_grid_column_title_adm_author', '20%', 0, '25', '', 6),
 ('bx_reviews_administration', 'author', '_bx_reviews_grid_column_title_adm_author', '20%', 0, '25', '', 6),
 ('bx_reviews_administration', 'actions', '', '20%', 0, '', '', 7),
 ('bx_reviews_administration', 'actions', '', '20%', 0, '', '', 7),
+('bx_reviews_voting_options', 'order', '', '5%', 0, '', '', 1),
+('bx_reviews_voting_options', 'lkey', '_bx_reviews_grid_column_title_adm_name', '75%', 1, '', '', 5),
+('bx_reviews_voting_options', 'actions', '', '20%', 0, '', '', 9),
 ('bx_reviews_common', 'checkbox', '_sys_select', '2%', 0, '', '', 1),
 ('bx_reviews_common', 'checkbox', '_sys_select', '2%', 0, '', '', 1),
 ('bx_reviews_common', 'switcher', '_bx_reviews_grid_column_title_adm_active', '8%', 0, '', '', 2),
 ('bx_reviews_common', 'switcher', '_bx_reviews_grid_column_title_adm_active', '8%', 0, '', '', 2),
 ('bx_reviews_common', 'title', '_bx_reviews_grid_column_title_adm_title', '40%', 0, '35', '', 3),
 ('bx_reviews_common', 'title', '_bx_reviews_grid_column_title_adm_title', '40%', 0, '35', '', 3),
@@ -461,6 +467,9 @@ INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon
 ('bx_reviews_administration', 'single', 'delete', '_bx_reviews_grid_action_title_adm_delete', 'remove', 1, 1, 2),
 ('bx_reviews_administration', 'single', 'delete', '_bx_reviews_grid_action_title_adm_delete', 'remove', 1, 1, 2),
 ('bx_reviews_administration', 'single', 'settings', '_bx_reviews_grid_action_title_adm_more_actions', 'cog', 1, 0, 3),
 ('bx_reviews_administration', 'single', 'settings', '_bx_reviews_grid_action_title_adm_more_actions', 'cog', 1, 0, 3),
 ('bx_reviews_administration', 'single', 'audit_content', '_bx_reviews_grid_action_title_adm_audit_content', 'search', 1, 0, 4),
 ('bx_reviews_administration', 'single', 'audit_content', '_bx_reviews_grid_action_title_adm_audit_content', 'search', 1, 0, 4),
+('bx_reviews_voting_options', 'single', 'delete', '_bx_reviews_grid_action_title_adm_delete', 'remove', 0, 1, 1),
+('bx_reviews_voting_options', 'single', 'edit', '_bx_reviews_grid_action_title_adm_edit', 'pencil-alt',0, 0, 2),
+('bx_reviews_voting_options', 'independent', 'add', '_bx_reviews_grid_action_title_adm_add', 'plus', 0, 0, 1),
 ('bx_reviews_common', 'bulk', 'delete', '_bx_reviews_grid_action_title_adm_delete', '', 0, 1, 1),
 ('bx_reviews_common', 'bulk', 'delete', '_bx_reviews_grid_action_title_adm_delete', '', 0, 1, 1),
 ('bx_reviews_common', 'single', 'edit', '_bx_reviews_grid_action_title_adm_edit', 'pencil-alt', 1, 0, 1),
 ('bx_reviews_common', 'single', 'edit', '_bx_reviews_grid_action_title_adm_edit', 'pencil-alt', 1, 0, 1),
 ('bx_reviews_common', 'single', 'delete', '_bx_reviews_grid_action_title_adm_delete', 'remove', 1, 1, 2),
 ('bx_reviews_common', 'single', 'delete', '_bx_reviews_grid_action_title_adm_delete', 'remove', 1, 1, 2),
@@ -493,4 +502,4 @@ INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 
 
 -- CRON
 -- CRON
 INSERT INTO `sys_cron_jobs` (`name`, `time`, `class`, `file`, `service_call`) VALUES
 INSERT INTO `sys_cron_jobs` (`name`, `time`, `class`, `file`, `service_call`) VALUES
-('bx_reviews_publishing', '* * * * *', 'BxReviewsCronPublishing', 'modules/boonex/reviews/classes/BxReviewsCronPublishing.php', '');
+('bx_reviews_publishing', '* * * * *', 'BxReviewsCronPublishing', 'modules/boonex/reviews/classes/BxReviewsCronPublishing.php', '');

+ 40 - 29
modules/boonex/reviews/install/sql/install.sql

@@ -7,6 +7,7 @@ CREATE TABLE IF NOT EXISTS `bx_reviews_reviews` (
   `published` int(11) NOT NULL,
   `published` int(11) NOT NULL,
   `thumb` int(11) NOT NULL,
   `thumb` int(11) NOT NULL,
   `title` varchar(255) NOT NULL,
   `title` varchar(255) NOT NULL,
+  `voting_options` text NOT NULL,
   `cat` int(11) NOT NULL,
   `cat` int(11) NOT NULL,
   `multicat` text NOT NULL,
   `multicat` text NOT NULL,
   `text` mediumtext NOT NULL,
   `text` mediumtext NOT NULL,
@@ -330,6 +331,14 @@ CREATE TABLE IF NOT EXISTS `bx_reviews_polls_answers_votes_track` (
   KEY `vote` (`object_id`, `author_nip`)
   KEY `vote` (`object_id`, `author_nip`)
 );
 );
 
 
+-- VOTING OPTIONS
+CREATE TABLE IF NOT EXISTS `bx_reviews_voting_options` (
+    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+    `lkey` varchar(255) NOT NULL DEFAULT '',
+    `order` int(11) NOT NULL,
+    PRIMARY KEY (`id`)
+);
+
 -- STORAGES & TRANSCODERS
 -- STORAGES & TRANSCODERS
 SET @sStorageEngine = (SELECT `value` FROM `sys_options` WHERE `name` = 'sys_storage_default');
 SET @sStorageEngine = (SELECT `value` FROM `sys_options` WHERE `name` = 'sys_storage_default');
 
 
@@ -380,7 +389,7 @@ INSERT INTO `sys_transcoder_filters` (`transcoder_object`, `filter`, `filter_par
 
 
 -- FORMS: entry (review)
 -- FORMS: entry (review)
 INSERT INTO `sys_objects_form`(`object`, `module`, `title`, `action`, `form_attrs`, `table`, `key`, `uri`, `uri_title`, `submit_name`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
 INSERT INTO `sys_objects_form`(`object`, `module`, `title`, `action`, `form_attrs`, `table`, `key`, `uri`, `uri_title`, `submit_name`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
-('bx_reviews', 'bx_reviews', '_bx_reviews_form_entry', '', 'a:1:{s:7:"enctype";s:19:"multipart/form-data";}', 'bx_reviews_reviews', 'id', '', '', 'a:2:{i:0;s:9:"do_submit";i:1;s:10:"do_publish";}', '', 0, 1, 'BxReviewsFormEntry', 'modules/boonex/reviews/classes/BxReviewsFormEntry.php');
+('bx_reviews', 'bx_reviews', '_bx_reviews_form_entry', '', 'a:1:{s:7:"enctype";s:19:"multipart/form-data";}', 'bx_reviews_reviews', 'id', '', '', 'a:2:{i:0;s:9:"do_submit";i:1;s:10:"do_publish";}', 'a:1:{s:14:"checker_helper";s:31:"BxReviewsFormEntryCheckerHelper";}', 0, 1, 'BxReviewsFormEntry', 'modules/boonex/reviews/classes/BxReviewsFormEntry.php');
 
 
 INSERT INTO `sys_form_displays`(`object`, `display_name`, `module`, `view_mode`, `title`) VALUES 
 INSERT INTO `sys_form_displays`(`object`, `display_name`, `module`, `view_mode`, `title`) VALUES 
 ('bx_reviews', 'bx_reviews_entry_add', 'bx_reviews', 0, '_bx_reviews_form_entry_display_add'),
 ('bx_reviews', 'bx_reviews_entry_add', 'bx_reviews', 0, '_bx_reviews_form_entry_display_add'),
@@ -409,7 +418,8 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 ('bx_reviews', 'bx_reviews', 'attachments', '', '', 0, 'custom', '_bx_reviews_form_entry_input_sys_attachments', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_reviews', 'bx_reviews', 'attachments', '', '', 0, 'custom', '_bx_reviews_form_entry_input_sys_attachments', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_reviews', 'bx_reviews', 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_reviews', 'bx_reviews', 'labels', '', '', 0, 'custom', '_sys_form_input_sys_labels', '_sys_form_input_labels', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_reviews', 'bx_reviews', 'anonymous', '', '', 0, 'switcher', '_sys_form_input_sys_anonymous', '_sys_form_input_anonymous', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_reviews', 'bx_reviews', 'anonymous', '', '', 0, 'switcher', '_sys_form_input_sys_anonymous', '_sys_form_input_anonymous', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
-('bx_reviews', 'bx_reviews', 'disable_comments', '1', '', 0, 'switcher', '_bx_reviews_form_entry_input_sys_disable_comments', '_bx_reviews_form_entry_input_disable_comments', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0);
+('bx_reviews', 'bx_reviews', 'disable_comments', '1', '', 0, 'switcher', '_bx_reviews_form_entry_input_sys_disable_comments', '_bx_reviews_form_entry_input_disable_comments', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
+('bx_reviews', 'bx_reviews', 'voting_options', '', '', 0, 'custom', '_bx_reviews_form_entry_input_sys_voting_options', '_bx_reviews_form_entry_input_voting_options', '', 0, 0, 0, '', '', '', '', '', '', 'VotingOptions', '', 1, 0);
 
 
 
 
 
 
@@ -418,17 +428,18 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_reviews_entry_add', 'title', 2147483647, 1, 2),
 ('bx_reviews_entry_add', 'title', 2147483647, 1, 2),
 ('bx_reviews_entry_add', 'cat', 2147483647, 1, 3),
 ('bx_reviews_entry_add', 'cat', 2147483647, 1, 3),
 ('bx_reviews_entry_add', 'text', 2147483647, 1, 4),
 ('bx_reviews_entry_add', 'text', 2147483647, 1, 4),
-('bx_reviews_entry_add', 'attachments', 2147483647, 1, 5),
-('bx_reviews_entry_add', 'pictures', 2147483647, 1, 6),
-('bx_reviews_entry_add', 'videos', 2147483647, 1, 7),
-('bx_reviews_entry_add', 'files', 2147483647, 1, 8),
-('bx_reviews_entry_add', 'polls', 2147483647, 1, 9),
-('bx_reviews_entry_add', 'covers', 2147483647, 1, 10),
-('bx_reviews_entry_add', 'allow_view_to', 2147483647, 1, 11),
-('bx_reviews_entry_add', 'location', 2147483647, 1, 12),
-('bx_reviews_entry_add', 'published', 192, 1, 13),
-('bx_reviews_entry_add', 'disable_comments', 192, 1, 14),
-('bx_reviews_entry_add', 'do_publish', 2147483647, 1, 15),
+('bx_reviews_entry_add', 'voting_options', 2147483647, 1, 5),
+('bx_reviews_entry_add', 'attachments', 2147483647, 1, 6),
+('bx_reviews_entry_add', 'pictures', 2147483647, 1, 7),
+('bx_reviews_entry_add', 'videos', 2147483647, 1, 8),
+('bx_reviews_entry_add', 'files', 2147483647, 1, 9),
+('bx_reviews_entry_add', 'polls', 2147483647, 1, 10),
+('bx_reviews_entry_add', 'covers', 2147483647, 1, 11),
+('bx_reviews_entry_add', 'allow_view_to', 2147483647, 1, 12),
+('bx_reviews_entry_add', 'location', 2147483647, 1, 13),
+('bx_reviews_entry_add', 'published', 192, 0, 14),
+('bx_reviews_entry_add', 'disable_comments', 192, 0, 15),
+('bx_reviews_entry_add', 'do_publish', 2147483647, 1, 16),
 
 
 ('bx_reviews_entry_delete', 'delete_confirm', 2147483647, 1, 1),
 ('bx_reviews_entry_delete', 'delete_confirm', 2147483647, 1, 1),
 ('bx_reviews_entry_delete', 'do_submit', 2147483647, 1, 2),
 ('bx_reviews_entry_delete', 'do_submit', 2147483647, 1, 2),
@@ -436,24 +447,25 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_reviews_entry_edit', 'do_publish', 2147483647, 0, 1),
 ('bx_reviews_entry_edit', 'do_publish', 2147483647, 0, 1),
 ('bx_reviews_entry_edit', 'delete_confirm', 2147483647, 0, 2),
 ('bx_reviews_entry_edit', 'delete_confirm', 2147483647, 0, 2),
 ('bx_reviews_entry_edit', 'title', 2147483647, 1, 3),
 ('bx_reviews_entry_edit', 'title', 2147483647, 1, 3),
-('bx_reviews_entry_edit', 'cat', 2147483647, 1, 4),
-('bx_reviews_entry_edit', 'text', 2147483647, 1, 5),
-('bx_reviews_entry_edit', 'attachments', 2147483647, 1, 6),
-('bx_reviews_entry_edit', 'pictures', 2147483647, 1, 7),
-('bx_reviews_entry_edit', 'videos', 2147483647, 1, 8),
-('bx_reviews_entry_edit', 'files', 2147483647, 1, 9),
-('bx_reviews_entry_edit', 'polls', 2147483647, 1, 10),
-('bx_reviews_entry_edit', 'covers', 2147483647, 1, 11),
-('bx_reviews_entry_edit', 'allow_view_to', 2147483647, 1, 12),
-('bx_reviews_entry_edit', 'location', 2147483647, 1, 13),
-('bx_reviews_entry_edit', 'disable_comments', 192, 1, 14),
-('bx_reviews_entry_edit', 'published', 192, 1, 15),
-('bx_reviews_entry_edit', 'do_submit', 2147483647, 1, 16),
+('bx_reviews_entry_edit', 'voting_options', 2147483647, 1, 4),
+('bx_reviews_entry_edit', 'cat', 2147483647, 1, 5),
+('bx_reviews_entry_edit', 'text', 2147483647, 1, 6),
+('bx_reviews_entry_edit', 'attachments', 2147483647, 1, 7),
+('bx_reviews_entry_edit', 'pictures', 2147483647, 1, 8),
+('bx_reviews_entry_edit', 'videos', 2147483647, 1, 9),
+('bx_reviews_entry_edit', 'files', 2147483647, 1, 10),
+('bx_reviews_entry_edit', 'polls', 2147483647, 1, 11),
+('bx_reviews_entry_edit', 'covers', 2147483647, 1, 12),
+('bx_reviews_entry_edit', 'allow_view_to', 2147483647, 1, 13),
+('bx_reviews_entry_edit', 'location', 2147483647, 1, 14),
+('bx_reviews_entry_edit', 'disable_comments', 192, 0, 15),
+('bx_reviews_entry_edit', 'published', 192, 0, 16),
+('bx_reviews_entry_edit', 'do_submit', 2147483647, 1, 17),
 
 
 ('bx_reviews_entry_view', 'cat', 2147483647, 1, 1),
 ('bx_reviews_entry_view', 'cat', 2147483647, 1, 1),
 ('bx_reviews_entry_view', 'added', 2147483647, 1, 2),
 ('bx_reviews_entry_view', 'added', 2147483647, 1, 2),
 ('bx_reviews_entry_view', 'changed', 2147483647, 1, 3),
 ('bx_reviews_entry_view', 'changed', 2147483647, 1, 3),
-('bx_reviews_entry_view', 'published', 192, 1, 4);
+('bx_reviews_entry_view', 'published', 192, 0, 4);
 
 
 -- FORMS: poll
 -- FORMS: poll
 INSERT INTO `sys_objects_form` (`object`, `module`, `title`, `action`, `form_attrs`, `submit_name`, `table`, `key`, `uri`, `uri_title`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES
 INSERT INTO `sys_objects_form` (`object`, `module`, `title`, `action`, `form_attrs`, `submit_name`, `table`, `key`, `uri`, `uri_title`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES
@@ -570,5 +582,4 @@ SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE
 INSERT INTO `sys_std_widgets` (`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
 INSERT INTO `sys_std_widgets` (`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
 (@iPageId, 'bx_reviews', '{url_studio}module.php?name=bx_reviews', '', 'bx_reviews@modules/boonex/reviews/|std-icon.svg', '_bx_reviews', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioModules";}');
 (@iPageId, 'bx_reviews', '{url_studio}module.php?name=bx_reviews', '', 'bx_reviews@modules/boonex/reviews/|std-icon.svg', '_bx_reviews', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioModules";}');
 INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
 INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
-(@iParentPageId, LAST_INSERT_ID(), IF(ISNULL(@iParentPageOrder), 1, @iParentPageOrder + 1));
-
+(@iParentPageId, LAST_INSERT_ID(), IF(ISNULL(@iParentPageOrder), 1, @iParentPageOrder + 1));

+ 1 - 1
modules/boonex/reviews/install/sql/uninstall.sql

@@ -1,6 +1,6 @@
 
 
 -- TABLES
 -- TABLES
-DROP TABLE IF EXISTS `bx_reviews_reviews`, `bx_reviews_covers`, `bx_reviews_files`, `bx_reviews_photos`, `bx_reviews_photos_resized`, `bx_reviews_videos`, `bx_reviews_videos_resized`, `bx_reviews_cmts`, `bx_reviews_cmts_notes`, `bx_reviews_votes`, `bx_reviews_votes_track`, `bx_reviews_reactions`, `bx_reviews_reactions_track`, `bx_reviews_views_track`, `bx_reviews_meta_keywords`, `bx_reviews_meta_locations`, `bx_reviews_meta_mentions`, `bx_reviews_reports`, `bx_reviews_reports_track`, `bx_reviews_favorites_track`, `bx_reviews_scores`, `bx_reviews_scores_track`, `bx_reviews_polls`, `bx_reviews_polls_answers`, `bx_reviews_polls_answers_votes`, `bx_reviews_polls_answers_votes_track`;
+DROP TABLE IF EXISTS `bx_reviews_reviews`, `bx_reviews_covers`, `bx_reviews_files`, `bx_reviews_photos`, `bx_reviews_photos_resized`, `bx_reviews_videos`, `bx_reviews_videos_resized`, `bx_reviews_cmts`, `bx_reviews_cmts_notes`, `bx_reviews_votes`, `bx_reviews_votes_track`, `bx_reviews_reactions`, `bx_reviews_reactions_track`, `bx_reviews_views_track`, `bx_reviews_meta_keywords`, `bx_reviews_meta_locations`, `bx_reviews_meta_mentions`, `bx_reviews_reports`, `bx_reviews_reports_track`, `bx_reviews_favorites_track`, `bx_reviews_scores`, `bx_reviews_scores_track`, `bx_reviews_polls`, `bx_reviews_polls_answers`, `bx_reviews_polls_answers_votes`, `bx_reviews_polls_answers_votes_track`, `bx_reviews_voting_options`;
 
 
 -- STORAGES & TRANSCODERS
 -- STORAGES & TRANSCODERS
 DELETE FROM `sys_objects_storage` WHERE `object` LIKE 'bx_reviews_%';
 DELETE FROM `sys_objects_storage` WHERE `object` LIKE 'bx_reviews_%';

+ 14 - 0
modules/boonex/reviews/js/BxReviewsVoteStars.js

@@ -0,0 +1,14 @@
+function BxReviewsVoteStars(oOptions) {
+    BxDolVoteStars.call(this, oOptions);
+}
+
+BxReviewsVoteStars.prototype = Object.create(BxDolVoteStars.prototype);
+BxReviewsVoteStars.prototype.constructor = BxReviewsVoteStars;
+
+BxReviewsVoteStars.prototype.vote = function (oLink, iValue) {
+    let iCurVal = $(oLink).closest('.sys-action-element-holder').find('.bx-review-voting-input').val();
+    if (iCurVal == iValue) iValue = 0; //unset
+
+    $(oLink).closest('.sys-action-element-holder').find('.bx-review-voting-input').val(iValue);
+    this.onVote(oLink, {code:0, rate:iValue});
+}

+ 5 - 1
modules/boonex/reviews/template/css/main.css

@@ -1 +1,5 @@
-@import url(../../../../base/text/template/css/main.css);
+@import url(../../../../base/text/template/css/main.css);
+
+.bx-reviews-voting-options .bx-def-margin-bottom:last-of-type {
+    margin-bottom: 0px;
+}

+ 10 - 0
modules/boonex/reviews/template/unit_rating.html

@@ -0,0 +1,10 @@
+<div>
+    <div class="sys-action bx-vote bx-vote-stars" bx_vote_data_rate="__rate__">
+        <div class="sys-action-cnt bx-vote-cnt bx-vote-do bx-def-valign-center bx-clearfix">
+            <div class="sys-action-element-holder bx-vote-element-holder">
+                __stars__
+            </div>
+        </div>
+    </div><span class="bx-base-general-unit-meta-div bx-def-font-grayed">&nbsp;&#183;&nbsp;</span><a href="#" onclick="showPopupAnyHtml('__details_action_url__', 'bx_reviews_rating'); return false;"><bx_text:_bx_reviews_txt_rating_details /></a>
+    __js_code__
+</div>

+ 18 - 0
modules/boonex/reviews/template/voting_multi_stars.html

@@ -0,0 +1,18 @@
+<div class="bx-reviews-voting-options">
+    <bx_repeat:voting_options>
+    <div class="bx-def-margin-bottom">
+        <div class="bx-def-font">__voting_option_name__</div>
+        <div class="sys-action bx-vote bx-vote-stars bx-def-margin-right-auto bx-def-margin-thd-topbottom" bx_vote_data_rate="__rate__">
+            <div class="sys-action-cnt bx-vote-cnt bx-vote-do bx-def-valign-center bx-clearfix">
+                <div class="sys-action-element-holder bx-vote-element-holder">
+                    __stars__
+                    <bx_if:vote_allowed>
+                        <input type="hidden" name="voting_options[__option_id__]" value="__rate__" class="bx-review-voting-input" />
+                    </bx_if:vote_allowed>
+                </div>
+            </div>
+        </div>
+    </div>
+    </bx_repeat:voting_options>
+    __js_code__
+</div>