mambax7 /
publisher
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php declare(strict_types=1); |
||
| 2 | |||
| 3 | namespace XoopsModules\Publisher; |
||
| 4 | |||
| 5 | /* |
||
| 6 | You may not change or alter any portion of this comment or credits |
||
| 7 | of supporting developers from this source code or any supporting source code |
||
| 8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, |
||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Publisher module for xoops |
||
| 17 | * |
||
| 18 | * @copyright module for xoops |
||
| 19 | * @license GPL 3.0 or later |
||
| 20 | * @since 1.0 |
||
| 21 | * @min_xoops 2.5.10 |
||
| 22 | * @author XOOPS Development Team |
||
| 23 | */ |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Class Object VoteHandler |
||
| 27 | */ |
||
| 28 | class VoteHandler extends \XoopsPersistableObjectHandler |
||
| 29 | { |
||
| 30 | private const TABLE = 'publisher_rating'; |
||
| 31 | private const ENTITY = Vote::class; |
||
| 32 | private const ENTITYNAME = 'Vote'; |
||
| 33 | private const KEYNAME = 'ratingid'; |
||
| 34 | private const IDENTIFIER = 'itemid'; |
||
| 35 | private const SOURCE = 'source'; |
||
| 36 | /** |
||
| 37 | * @var Helper |
||
| 38 | */ |
||
| 39 | public $helper; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Constructor |
||
| 43 | * @param \XoopsModules\Publisher\Helper|null $helper |
||
| 44 | */ |
||
| 45 | public function __construct(?\XoopsDatabase $db = null, ?Helper $helper = null) |
||
| 46 | { |
||
| 47 | $this->db = $db; |
||
| 48 | /** @var Helper $this- >helper */ |
||
| 49 | $this->helper = $helper ?? Helper::getInstance(); |
||
| 50 | |||
| 51 | parent::__construct($db, static::TABLE, static::ENTITY, static::KEYNAME, static::IDENTIFIER); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * get inserted id |
||
| 56 | * |
||
| 57 | * @return int reference to the {@link Get} object |
||
| 58 | */ |
||
| 59 | public function getInsertId(): int |
||
| 60 | { |
||
| 61 | return $this->db->getInsertId(); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Get Rating per item in the database |
||
| 66 | * @param int|null $itemId |
||
| 67 | * @param int|null $source |
||
| 68 | */ |
||
| 69 | public function getItemRating($itemId = null, $source = null): array |
||
| 70 | { |
||
| 71 | $itemId = $itemId ?? 0; |
||
| 72 | $source = $source ?? 0; |
||
| 73 | $xoopsUser = $GLOBALS['xoopsUser']; |
||
| 74 | |||
| 75 | $itemRating = []; |
||
| 76 | $itemRating['nb_vote'] = 0; |
||
| 77 | $uid = \is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
||
| 78 | $voted = false; |
||
| 79 | $ip = \getenv('REMOTE_ADDR'); |
||
| 80 | $currentRating = 0; |
||
| 81 | $count = 0; |
||
| 82 | |||
| 83 | $max_units = 10; |
||
| 84 | $ratingbarsValue = (int)$this->helper->getConfig('ratingbars'); |
||
| 85 | $ratingArray = [Constants::RATING_5STARS, Constants::RATING_10STARS, Constants::RATING_10NUM]; |
||
| 86 | |||
| 87 | if (\in_array($ratingbarsValue, $ratingArray, true)) { |
||
| 88 | $rating_unitwidth = 25; |
||
| 89 | if (Constants::RATING_5STARS === (int)$this->helper->getConfig('ratingbars')) { |
||
| 90 | $max_units = 5; |
||
| 91 | } |
||
| 92 | |||
| 93 | $criteria = new \CriteriaCompo(); |
||
| 94 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 95 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 96 | |||
| 97 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 98 | ->getObjects($criteria); |
||
| 99 | $count = \count($voteObjs); |
||
| 100 | $itemRating['nb_vote'] = $count; |
||
| 101 | |||
| 102 | foreach ($voteObjs as $voteObj) { |
||
| 103 | $currentRating += $voteObj->getVar('rate'); |
||
| 104 | if (($voteObj->getVar('ip') == $ip && 0 == $uid) || ($uid > 0 && $uid == $voteObj->getVar('uid'))) { |
||
| 105 | $voted = true; |
||
| 106 | $itemRating['id'] = $voteObj->getVar('ratingid'); |
||
| 107 | } |
||
| 108 | } |
||
| 109 | unset($criteria); |
||
| 110 | |||
| 111 | $itemRating['avg_rate_value'] = 0; |
||
| 112 | if ($count > 0) { |
||
| 113 | $itemRating['avg_rate_value'] = \number_format((float)$currentRating / $count, 2); |
||
| 114 | } |
||
| 115 | if (1 == $count) { |
||
| 116 | $text = \str_replace('%c', (string)$itemRating['avg_rate_value'], \_MA_PUBLISHER_RATING_CURRENT_1); |
||
| 117 | $shorttext = \str_replace('%c', (string)$itemRating['avg_rate_value'], \_MA_PUBLISHER_RATING_CURRENT_SHORT_1); |
||
| 118 | } else { |
||
| 119 | $text = \str_replace('%c', (string)$itemRating['avg_rate_value'], \_MA_PUBLISHER_RATING_CURRENT_X); |
||
| 120 | $shorttext = \str_replace('%c', (string)$itemRating['avg_rate_value'], \_MA_PUBLISHER_RATING_CURRENT_SHORT_X); |
||
| 121 | } |
||
| 122 | $text = \str_replace('%m', (string)$max_units, $text); |
||
| 123 | $text = \str_replace('%t', (string)$itemRating['nb_vote'], $text); |
||
| 124 | $shorttext = \str_replace('%t', (string)$itemRating['nb_vote'], $shorttext); |
||
| 125 | $itemRating['text'] = $text; |
||
| 126 | $itemRating['shorttext'] = $shorttext; |
||
| 127 | $itemRating['size'] = ($itemRating['avg_rate_value'] * $rating_unitwidth) . 'px'; |
||
| 128 | $itemRating['maxsize'] = ($max_units * $rating_unitwidth) . 'px'; |
||
| 129 | |||
| 130 | $itemRating['ip'] = $ip; |
||
| 131 | $itemRating['uid'] = $uid; |
||
| 132 | $itemRating['voted'] = $voted; |
||
| 133 | // YouTube Liking ========================================== |
||
| 134 | } elseif (Constants::RATING_LIKES === (int)$this->helper->getConfig('ratingbars')) { |
||
| 135 | // get count of "dislikes" |
||
| 136 | $criteria = new \CriteriaCompo(); |
||
| 137 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 138 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 139 | $criteria->add(new \Criteria('rate', 0, '<')); |
||
| 140 | |||
| 141 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 142 | ->getObjects($criteria); |
||
| 143 | $count = \count($voteObjs); |
||
| 144 | |||
| 145 | foreach ($voteObjs as $voteObj) { |
||
| 146 | $currentRating += $voteObj->getVar('rate'); |
||
| 147 | if (($voteObj->getVar('ip') == $ip && 0 == $uid) || ($uid > 0 && $uid == $voteObj->getVar('uid'))) { |
||
| 148 | $voted = true; |
||
| 149 | $itemRating['id'] = $voteObj->getVar('ratingid'); |
||
| 150 | } |
||
| 151 | } |
||
| 152 | unset($criteria); |
||
| 153 | $itemRating['dislikes'] = $count; |
||
| 154 | |||
| 155 | // get count of "likes" |
||
| 156 | $criteria = new \CriteriaCompo(); |
||
| 157 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 158 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 159 | $criteria->add(new \Criteria('rate', 0, '>')); |
||
| 160 | |||
| 161 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 162 | ->getObjects($criteria); |
||
| 163 | $count = \count($voteObjs); |
||
| 164 | $currentRating = 0; |
||
| 165 | foreach ($voteObjs as $voteObj) { |
||
| 166 | $currentRating += $voteObj->getVar('rate'); |
||
| 167 | if (($voteObj->getVar('ip') == $ip && 0 == $uid) || ($uid > 0 && $uid == $voteObj->getVar('uid'))) { |
||
| 168 | $voted = true; |
||
| 169 | $itemRating['id'] = $voteObj->getVar('ratingid'); |
||
| 170 | } |
||
| 171 | } |
||
| 172 | unset($criteria); |
||
| 173 | $itemRating['likes'] = $count; |
||
| 174 | |||
| 175 | $itemRating['nb_vote'] = $itemRating['likes'] + $itemRating['dislikes']; |
||
| 176 | $itemRating['ip'] = $ip; |
||
| 177 | $itemRating['uid'] = $uid; |
||
| 178 | $itemRating['voted'] = $voted; |
||
| 179 | // Facebook Reactions ========================================== |
||
| 180 | } elseif (Constants::RATING_REACTION === (int)$this->helper->getConfig('ratingbars')) { |
||
| 181 | $criteria = new \CriteriaCompo(); |
||
| 182 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 183 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 184 | $criteria->add(new \Criteria('rate', 0, '<')); |
||
| 185 | |||
| 186 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 187 | ->getObjects($criteria); |
||
| 188 | $count = \count($voteObjs); |
||
| 189 | $itemRating['nb_vote'] = $count; |
||
| 190 | |||
| 191 | foreach ($voteObjs as $voteObj) { |
||
| 192 | $currentRating += $voteObj->getVar('rate'); |
||
| 193 | if (($voteObj->getVar('ip') == $ip && 0 == $uid) || ($uid > 0 && $uid == $voteObj->getVar('uid'))) { |
||
| 194 | $voted = true; |
||
| 195 | $itemRating['id'] = $voteObj->getVar('ratingid'); |
||
| 196 | } |
||
| 197 | } |
||
| 198 | unset($criteria); |
||
| 199 | $itemRating['dislikes'] = $count; |
||
| 200 | |||
| 201 | $criteria = new \CriteriaCompo(); |
||
| 202 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 203 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 204 | $criteria->add(new \Criteria('rate', 0, '>')); |
||
| 205 | |||
| 206 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 207 | ->getObjects($criteria); |
||
| 208 | $count = \count($voteObjs); |
||
| 209 | $currentRating = 0; |
||
| 210 | foreach ($voteObjs as $voteObj) { |
||
| 211 | $currentRating += $voteObj->getVar('rate'); |
||
| 212 | if (($voteObj->getVar('ip') == $ip && 0 == $uid) || ($uid > 0 && $uid == $voteObj->getVar('uid'))) { |
||
| 213 | $voted = true; |
||
| 214 | $itemRating['id'] = $voteObj->getVar('ratingid'); |
||
| 215 | } |
||
| 216 | } |
||
| 217 | unset($criteria); |
||
| 218 | $itemRating['likes'] = $count; |
||
| 219 | |||
| 220 | $itemRating['nb_vote'] = $itemRating['likes'] + $itemRating['dislikes']; |
||
| 221 | $itemRating['ip'] = $ip; |
||
| 222 | $itemRating['uid'] = $uid; |
||
| 223 | $itemRating['voted'] = $voted; |
||
| 224 | } else { |
||
| 225 | $itemRating['uid'] = $uid; |
||
| 226 | $itemRating['nb_vote'] = $count; |
||
| 227 | $itemRating['voted'] = $voted; |
||
| 228 | $itemRating['ip'] = $ip; |
||
| 229 | } |
||
| 230 | |||
| 231 | return $itemRating; |
||
| 232 | } |
||
| 233 | |||
| 234 | /** |
||
| 235 | * Get Rating per item in the database |
||
| 236 | * @param Item|null $itemObj |
||
| 237 | * @param int|null $source |
||
| 238 | */ |
||
| 239 | public function getItemRating5($itemObj = null, $source = null): array |
||
| 240 | { |
||
| 241 | $itemId = $itemObj->itemid(); |
||
| 242 | $source = $source ?? 0; |
||
| 243 | $xoopsUser = $GLOBALS['xoopsUser']; |
||
| 244 | |||
| 245 | $itemRating = []; |
||
| 246 | $itemRating['nb_vote'] = 0; |
||
| 247 | $uid = \is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
||
| 248 | $voted = false; |
||
| 249 | $ip = \getenv('REMOTE_ADDR'); |
||
| 250 | $currentRating = 0; |
||
| 251 | $count = 0; |
||
| 252 | |||
| 253 | $max_units = 10; |
||
| 254 | $ratingbarsValue = $itemObj->votetype(); |
||
| 255 | $ratingArray = [Constants::RATING_5STARS, Constants::RATING_10STARS, Constants::RATING_10NUM]; |
||
| 256 | |||
| 257 | if (\in_array($ratingbarsValue, $ratingArray, true)) { |
||
| 258 | $rating_unitwidth = 25; |
||
| 259 | if (Constants::RATING_5STARS === $ratingbarsValue) { |
||
| 260 | $max_units = 5; |
||
| 261 | } |
||
| 262 | |||
| 263 | $criteria = new \CriteriaCompo(); |
||
| 264 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 265 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 266 | |||
| 267 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 268 | ->getObjects($criteria); |
||
| 269 | $count = \count($voteObjs); |
||
| 270 | $itemRating['nb_vote'] = $count; |
||
| 271 | |||
| 272 | foreach ($voteObjs as $voteObj) { |
||
| 273 | $currentRating += $voteObj->getVar('rate'); |
||
| 274 | if (($voteObj->getVar('ip') == $ip && 0 == $uid) || ($uid > 0 && $uid == $voteObj->getVar('uid'))) { |
||
| 275 | $voted = true; |
||
| 276 | $itemRating['id'] = $voteObj->getVar('ratingid'); |
||
| 277 | } |
||
| 278 | } |
||
| 279 | unset($criteria); |
||
| 280 | |||
| 281 | $itemRating['avg_rate_value'] = 0; |
||
| 282 | if ($count > 0) { |
||
| 283 | $itemRating['avg_rate_value'] = \number_format((float)$currentRating / $count, 2); |
||
| 284 | } |
||
| 285 | if (1 == $count) { |
||
| 286 | $text = \str_replace('%c', (string)$itemRating['avg_rate_value'], \_MA_PUBLISHER_RATING_CURRENT_1); |
||
| 287 | $shorttext = \str_replace('%c', (string)$itemRating['avg_rate_value'], \_MA_PUBLISHER_RATING_CURRENT_SHORT_1); |
||
| 288 | } else { |
||
| 289 | $text = \str_replace('%c', (string)$itemRating['avg_rate_value'], \_MA_PUBLISHER_RATING_CURRENT_X); |
||
| 290 | $shorttext = \str_replace('%c', (string)$itemRating['avg_rate_value'], \_MA_PUBLISHER_RATING_CURRENT_SHORT_X); |
||
| 291 | } |
||
| 292 | $text = \str_replace('%m', (string)$max_units, $text); |
||
| 293 | $text = \str_replace('%t', (string)$itemRating['nb_vote'], $text); |
||
| 294 | $shorttext = \str_replace('%t', (string)$itemRating['nb_vote'], $shorttext); |
||
| 295 | $itemRating['text'] = $text; |
||
| 296 | $itemRating['shorttext'] = $shorttext; |
||
| 297 | $itemRating['size'] = ($itemRating['avg_rate_value'] * $rating_unitwidth) . 'px'; |
||
| 298 | $itemRating['maxsize'] = ($max_units * $rating_unitwidth) . 'px'; |
||
| 299 | |||
| 300 | $itemRating['ip'] = $ip; |
||
| 301 | $itemRating['uid'] = $uid; |
||
| 302 | $itemRating['voted'] = $voted; |
||
| 303 | // YouTube Liking ========================================== |
||
| 304 | } elseif (Constants::RATING_LIKES === $ratingbarsValue) { |
||
| 305 | // get count of "dislikes" |
||
| 306 | $criteria = new \CriteriaCompo(); |
||
| 307 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 308 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 309 | $criteria->add(new \Criteria('rate', 0, '<')); |
||
| 310 | |||
| 311 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 312 | ->getObjects($criteria); |
||
| 313 | $count = \count($voteObjs); |
||
| 314 | |||
| 315 | foreach ($voteObjs as $voteObj) { |
||
| 316 | $currentRating += $voteObj->getVar('rate'); |
||
| 317 | if (($voteObj->getVar('ip') == $ip && 0 == $uid) || ($uid > 0 && $uid == $voteObj->getVar('uid'))) { |
||
| 318 | $voted = true; |
||
| 319 | $itemRating['id'] = $voteObj->getVar('ratingid'); |
||
| 320 | } |
||
| 321 | } |
||
| 322 | unset($criteria); |
||
| 323 | $itemRating['dislikes'] = $count; |
||
| 324 | |||
| 325 | // get count of "likes" |
||
| 326 | $criteria = new \CriteriaCompo(); |
||
| 327 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 328 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 329 | $criteria->add(new \Criteria('rate', 0, '>')); |
||
| 330 | |||
| 331 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 332 | ->getObjects($criteria); |
||
| 333 | $count = \count($voteObjs); |
||
| 334 | $currentRating = 0; |
||
| 335 | foreach ($voteObjs as $voteObj) { |
||
| 336 | $currentRating += $voteObj->getVar('rate'); |
||
| 337 | if (($voteObj->getVar('ip') == $ip && 0 == $uid) || ($uid > 0 && $uid == $voteObj->getVar('uid'))) { |
||
| 338 | $voted = true; |
||
| 339 | $itemRating['id'] = $voteObj->getVar('ratingid'); |
||
| 340 | } |
||
| 341 | } |
||
| 342 | unset($criteria); |
||
| 343 | $itemRating['likes'] = $count; |
||
| 344 | |||
| 345 | $itemRating['nb_vote'] = $itemRating['likes'] + $itemRating['dislikes']; |
||
| 346 | $itemRating['ip'] = $ip; |
||
| 347 | $itemRating['uid'] = $uid; |
||
| 348 | $itemRating['voted'] = $voted; |
||
| 349 | // Facebook Reactions ========================================== |
||
| 350 | } elseif (Constants::RATING_REACTION === $ratingbarsValue) { |
||
| 351 | $criteria = new \CriteriaCompo(); |
||
| 352 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 353 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 354 | $criteria->add(new \Criteria('rate', 1)); |
||
| 355 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 356 | ->getObjects($criteria); |
||
| 357 | $count = \count($voteObjs); |
||
| 358 | $itemRating['likes'] = $count; |
||
| 359 | |||
| 360 | $criteria = new \CriteriaCompo(); |
||
| 361 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 362 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 363 | $criteria->add(new \Criteria('rate', 2)); |
||
| 364 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 365 | ->getObjects($criteria); |
||
| 366 | $count = \count($voteObjs); |
||
| 367 | $itemRating['love'] = $count; |
||
| 368 | |||
| 369 | $criteria = new \CriteriaCompo(); |
||
| 370 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 371 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 372 | $criteria->add(new \Criteria('rate', 3)); |
||
| 373 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 374 | ->getObjects($criteria); |
||
| 375 | $count = \count($voteObjs); |
||
| 376 | $itemRating['smile'] = $count; |
||
| 377 | |||
| 378 | $criteria = new \CriteriaCompo(); |
||
| 379 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 380 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 381 | $criteria->add(new \Criteria('rate', 4)); |
||
| 382 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 383 | ->getObjects($criteria); |
||
| 384 | $count = \count($voteObjs); |
||
| 385 | $itemRating['wow'] = $count; |
||
| 386 | |||
| 387 | $criteria = new \CriteriaCompo(); |
||
| 388 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 389 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 390 | $criteria->add(new \Criteria('rate', 5)); |
||
| 391 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 392 | ->getObjects($criteria); |
||
| 393 | $count = \count($voteObjs); |
||
| 394 | $itemRating['sad'] = $count; |
||
| 395 | |||
| 396 | $criteria = new \CriteriaCompo(); |
||
| 397 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 398 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 399 | $criteria->add(new \Criteria('rate', 6)); |
||
| 400 | $voteObjs = $this->helper->getHandler(static::ENTITYNAME) |
||
| 401 | ->getObjects($criteria); |
||
| 402 | $count = \count($voteObjs); |
||
| 403 | $itemRating['angry'] = $count; |
||
| 404 | |||
| 405 | $itemRating['nb_vote'] = $itemRating['likes'] + $itemRating['love'] + $itemRating['smile'] + $itemRating['wow'] + $itemRating['sad'] + $itemRating['angry']; |
||
| 406 | $itemRating['ip'] = $ip; |
||
| 407 | $itemRating['uid'] = $uid; |
||
| 408 | $itemRating['voted'] = $voted; |
||
| 409 | } else { |
||
| 410 | $itemRating['uid'] = $uid; |
||
| 411 | $itemRating['nb_vote'] = $count; |
||
| 412 | $itemRating['voted'] = $voted; |
||
| 413 | $itemRating['ip'] = $ip; |
||
| 414 | } |
||
| 415 | |||
| 416 | return $itemRating; |
||
| 417 | } |
||
| 418 | |||
| 419 | /** |
||
| 420 | * delete vote of given item |
||
| 421 | * @param mixed $itemId |
||
| 422 | * @param mixed $source |
||
| 423 | */ |
||
| 424 | public function deleteAllVote($itemId, $source): bool |
||
| 425 | { |
||
| 426 | $criteria = new \CriteriaCompo(); |
||
| 427 | $criteria->add(new \Criteria(static::IDENTIFIER, $itemId)); |
||
| 428 | $criteria->add(new \Criteria(static::SOURCE, $source)); |
||
| 429 | |||
| 430 | return $this->deleteAll($criteria); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 431 | } |
||
| 432 | |||
| 433 | //TODO |
||
| 434 | // delete all votes for an item |
||
| 435 | // delete all votes |
||
| 436 | // updates Vote counts for an item after new vote |
||
| 437 | // convert vote type to another |
||
| 438 | // TopRated |
||
| 439 | // getAggregate |
||
| 440 | |||
| 441 | // Average, Sum, Count |
||
| 442 | // getVotingElement (FiveStarts, Reaction) |
||
| 443 | // buildForm, getStyle |
||
| 444 | // |
||
| 445 | //tableName |
||
| 446 | //behaviors |
||
| 447 | //rules |
||
| 448 | //attributeLabels |
||
| 449 | //afterSave |
||
| 450 | //getModelIdByName |
||
| 451 | //getModelNameById |
||
| 452 | //getIsAllowGuests |
||
| 453 | //getIsAllowChangeVote |
||
| 454 | //updateRating |
||
| 455 | |||
| 456 | //getId |
||
| 457 | //getVoterId |
||
| 458 | //getVoterName |
||
| 459 | //getVoteableId |
||
| 460 | //getVotableName |
||
| 461 | //getValue |
||
| 462 | //getRange |
||
| 463 | //getMinValue |
||
| 464 | //getMaxValue |
||
| 465 | //getTime |
||
| 466 | |||
| 467 | //VoteRepositoryInterface: |
||
| 468 | //find |
||
| 469 | //findByVoter |
||
| 470 | //findByVotable |
||
| 471 | //getCountByVotable |
||
| 472 | //getAvgByVotable |
||
| 473 | //create |
||
| 474 | //delete |
||
| 475 | |||
| 476 | //VotesRepositoryTest |
||
| 477 | //repo |
||
| 478 | //vote |
||
| 479 | //__construct |
||
| 480 | //testRepo |
||
| 481 | //_testCreate |
||
| 482 | //_testFindByVoter |
||
| 483 | //_testFindByVotable |
||
| 484 | //_testAvg |
||
| 485 | //_testCount |
||
| 486 | //_testDelete |
||
| 487 | //_votable |
||
| 488 | //_voter |
||
| 489 | |||
| 490 | //FieldVoteResultBase: |
||
| 491 | //calculateResult |
||
| 492 | //getVotesForField |
||
| 493 | // |
||
| 494 | // |
||
| 495 | //VotingApiField: |
||
| 496 | //defaultFieldSettings |
||
| 497 | //defaultStorageSettings |
||
| 498 | //fieldSettingsForm |
||
| 499 | //generateSampleValue |
||
| 500 | //isEmpty |
||
| 501 | //mainPropertyName |
||
| 502 | //postSave |
||
| 503 | //propertyDefinitions |
||
| 504 | //schema |
||
| 505 | //storageSettingsForm |
||
| 506 | // |
||
| 507 | // |
||
| 508 | //VotingApiWidgetBase: |
||
| 509 | //canVote |
||
| 510 | //getEntityForVoting |
||
| 511 | //getForm |
||
| 512 | //getInitialVotingElement |
||
| 513 | //getLabel |
||
| 514 | //getResults |
||
| 515 | //getValues |
||
| 516 | //getVoteSummary |
||
| 517 | //getWindow |
||
| 518 | |||
| 519 | //Rating |
||
| 520 | //afterSave |
||
| 521 | //attributeLabels |
||
| 522 | //behaviors |
||
| 523 | //compressIp |
||
| 524 | //expandIp |
||
| 525 | //getIsAllowChangeVote |
||
| 526 | //getIsAllowGuests |
||
| 527 | //getModelIdByName |
||
| 528 | //getModelNameById |
||
| 529 | //rules |
||
| 530 | //tableName |
||
| 531 | //updateRating |
||
| 532 | } |
||
| 533 |