Skip to content

Commit

Permalink
added rating selection in item form
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Jan 12, 2021
1 parent cae6776 commit 459c887
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions class/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ interface Constants
public const PUBLISHER_SUBTITLE = 24;
public const PUBLISHER_AUTHOR_ALIAS = 25;
public const PUBLISHER_DATEEXPIRE = 26;
public const PUBLISHER_VOTETYPE = 27;
// Global constants
public const PUBLISHER_SEARCH = 1;
public const PUBLISHER_RATE = 2;
Expand Down
28 changes: 28 additions & 0 deletions class/Form/ItemForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ItemForm extends ThemeTabForm
Constants::PUBLISHER_NOTIFY,
Constants::PUBLISHER_AVAILABLE_PAGE_WRAP,
Constants::PUBLISHER_UID,
Constants::PUBLISHER_VOTETYPE,
];
public $imagesTab = [
Constants::PUBLISHER_IMAGE_ITEM,
Expand Down Expand Up @@ -271,6 +272,33 @@ public function createElements($obj)
$this->addElement($availableWrapPages);
}

//VOTING TYPE =====================================
// if ($this->isGranted(Constants::PUBLISHER_VOTETYPE)) {
$groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
/** @var GroupPermHandler $grouppermHandler */
$grouppermHandler = $helper->getHandler('GroupPerm');
$moduleId = $helper->getModule()->getVar('mid');
if ($helper->getConfig('perm_rating') && $grouppermHandler->checkRight('global', _PUBLISHER_RATE, $groups, $moduleId)) {
$options = [
Constants::RATING_NONE => _MI_BLOG_RATING_NONE,
Constants::RATING_5STARS => _MI_BLOG_RATING_5STARS,
Constants::RATING_10STARS => _MI_BLOG_RATING_10STARS,
Constants::RATING_LIKES => _MI_BLOG_RATING_LIKES,
Constants::RATING_10NUM => _MI_BLOG_RATING_10NUM,
Constants::RATING_REACTION => _MI_BLOG_RATING_REACTION,
];

$votetypeSelect = new \XoopsFormSelect(\_MI_BLOG_RATINGBARS, 'votetype', $obj->getVar('votetype'));
$votetypeSelect->addOptionArray($options);
// $votetypeSelect->setDescription(\_MI_BLOG_RATINGBARS_DESC);
$this->addElement($votetypeSelect);
unset($votetypeSelect);
}
// }
//VOTING TYPE END =====================================



$userUid = $obj->getVar('itemid') > 0 ? $obj->uid() : $currentUid;
if ($this->isGranted(Constants::PUBLISHER_UID)) {
$this->addElement(new \XoopsFormSelectUser(\_CO_PUBLISHER_UID, 'uid', false, $userUid, 1, false), false);
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<h5>1.08 Alpha 4 [NOT RELEASED]</h5> Dev: XOOPS 2.5.11, PHP 7.4.13, PHP 8.0
<hr>
- added rating selection in item form (mamba)

<h5>1.08 Alpha 3 [2021-01-01]</h5> Dev: XOOPS 2.5.11, PHP 7.4.13, PHP 8.0
<hr>
- fix in_array() for anonymous permissions (oswaldo/mamba)
Expand Down

0 comments on commit 459c887

Please sign in to comment.