| [928] | 1 | <?php |
|---|
| 2 | require_once(WCF_DIR.'lib/system/event/EventListener.class.php'); |
|---|
| 3 | |
|---|
| 4 | /** |
|---|
| 5 | * Shows the additonalRatings in the Webdisk-Item |
|---|
| 6 | * |
|---|
| 7 | * @author Markus Gerdelmann |
|---|
| 8 | * @copyright 2005-2009 |
|---|
| 9 | * @package de.wbb-security.database |
|---|
| 10 | */ |
|---|
| 11 | class DatabaseAdditionalRatingAddListener implements EventListener { |
|---|
| 12 | |
|---|
| [986] | 13 | public $itemID = 0; |
|---|
| 14 | public $catID = 0; |
|---|
| 15 | public $fields = array(); |
|---|
| [951] | 16 | protected $item = array(); |
|---|
| [928] | 17 | |
|---|
| 18 | |
|---|
| 19 | /** |
|---|
| 20 | * @see EventListener::execute() |
|---|
| 21 | */ |
|---|
| 22 | public function execute($eventObj, $className, $eventName){ |
|---|
| [941] | 23 | |
|---|
| 24 | if (MODULE_DATABASE_ADDITIONALRATING == 1) { |
|---|
| [928] | 25 | |
|---|
| [941] | 26 | // Hier wird geschaut, welches ITEM aktuell angezeigt wird. |
|---|
| [951] | 27 | $this->itemID = $eventObj->getItemID(); |
|---|
| [941] | 28 | |
|---|
| 29 | |
|---|
| [951] | 30 | // Nun wird die aktuelle Kategorie ermittelt |
|---|
| 31 | $this->item = $eventObj->getItem(); |
|---|
| 32 | $this->catID = $this->item['categoryID']; |
|---|
| [941] | 33 | |
|---|
| 34 | // Hier wird geschaut, ob der User die Bewertung machen darf. |
|---|
| 35 | if (WCF::getUser()->getPermission('user.database.canAddAdditionalRating') == 1 && $this->catID > 0) { |
|---|
| 36 | // Hier werden alle zusaetzlichen Felder ermittelt |
|---|
| 37 | $sql = "SELECT `a`.*, `b`.`ipAddress`, `b`.`userID`, `b`.`itemID`, |
|---|
| 38 | IFNULL(`b`.`rating`, '0') AS `rating` |
|---|
| 39 | FROM `wcf".WCF_N."_database_additionalrating` AS `a` |
|---|
| 40 | LEFT JOIN ( |
|---|
| 41 | SELECT * |
|---|
| 42 | FROM `wcf".WCF_N."_database_additionalrating_ratings` |
|---|
| 43 | WHERE `itemID` = '".$this->itemID."' |
|---|
| 44 | AND `userID` = '".WCF::getUser()->userID."' |
|---|
| 45 | ) AS `b` |
|---|
| 46 | ON (`a`.`ratingID` = `b`.`ratingID`) |
|---|
| 47 | WHERE `a`.`catID` = '".$this->catID."' |
|---|
| 48 | GROUP BY `ratingID` |
|---|
| 49 | ORDER BY `a`.`sortOrder` ASC |
|---|
| 50 | "; |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | $result = WCF::getDB()->sendQuery($sql); |
|---|
| 54 | while ($row = WCF::getDB()->fetchArray($result)) { |
|---|
| 55 | $this->fields[] = $row; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | //Hier werden die Variablen in den Template-Variabeln registriert |
|---|
| 59 | WCF::getTPL()->assign(array( |
|---|
| 60 | 'fields' => $this->fields, |
|---|
| 61 | 'itemID' => $this->itemID |
|---|
| 62 | )); |
|---|
| 63 | |
|---|
| 64 | //Hier wird das Template in den Platzhalter der databaseItem.tpl geladen |
|---|
| 65 | if(!defined("DATABASE_ADDITIONAL_RATING_ADD_TPL")) { |
|---|
| 66 | WCF::getTPL()->append('additionalFields2', WCF::getTPL()->fetch('databaseAdditionalRatingAdd')); |
|---|
| 67 | define("DATABASE_ADDITIONAL_RATING_ADD_TPL",1); |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | } |
|---|
| [928] | 72 | } |
|---|
| 73 | ?> |
|---|