| 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 | |
|---|
| 13 | public $itemID = 0; |
|---|
| 14 | public $catID = 0; |
|---|
| 15 | public $fields = array(); |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | /** |
|---|
| 19 | * @see EventListener::execute() |
|---|
| 20 | */ |
|---|
| 21 | public function execute($eventObj, $className, $eventName){ |
|---|
| 22 | |
|---|
| 23 | if (MODULE_DATABASE_ADDITIONALRATING == 1) { |
|---|
| 24 | |
|---|
| 25 | // Hier wird geschaut, welches ITEM aktuell angezeigt wird. |
|---|
| 26 | if(isset($_REQUEST['id'])) $this->itemID = intval($_REQUEST['id']); |
|---|
| 27 | |
|---|
| 28 | // Nun wird die aktuelle Kategorie ermittelt |
|---|
| 29 | if($this->itemID > 0) { |
|---|
| 30 | |
|---|
| 31 | $sql = "SELECT categoryID |
|---|
| 32 | FROM wcf".WCF_N."_database_item |
|---|
| 33 | WHERE itemID = ".$this->itemID; |
|---|
| 34 | |
|---|
| 35 | $result = WCF::getDB()->sendQuery($sql); |
|---|
| 36 | while ($row = WCF::getDB()->fetchArray($result)) { |
|---|
| 37 | $this->catID = $row['categoryID']; |
|---|
| 38 | } |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | // Hier wird geschaut, ob der User die Bewertung machen darf. |
|---|
| 42 | if (WCF::getUser()->getPermission('user.database.canAddAdditionalRating') == 1 && $this->catID > 0) { |
|---|
| 43 | // Hier werden alle zusaetzlichen Felder ermittelt |
|---|
| 44 | $sql = "SELECT `a`.*, `b`.`ipAddress`, `b`.`userID`, `b`.`itemID`, |
|---|
| 45 | IFNULL(`b`.`rating`, '0') AS `rating` |
|---|
| 46 | FROM `wcf".WCF_N."_database_additionalrating` AS `a` |
|---|
| 47 | LEFT JOIN ( |
|---|
| 48 | SELECT * |
|---|
| 49 | FROM `wcf".WCF_N."_database_additionalrating_ratings` |
|---|
| 50 | WHERE `itemID` = '".$this->itemID."' |
|---|
| 51 | AND `userID` = '".WCF::getUser()->userID."' |
|---|
| 52 | ) AS `b` |
|---|
| 53 | ON (`a`.`ratingID` = `b`.`ratingID`) |
|---|
| 54 | WHERE `a`.`catID` = '".$this->catID."' |
|---|
| 55 | GROUP BY `ratingID` |
|---|
| 56 | ORDER BY `a`.`sortOrder` ASC |
|---|
| 57 | "; |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | $result = WCF::getDB()->sendQuery($sql); |
|---|
| 61 | while ($row = WCF::getDB()->fetchArray($result)) { |
|---|
| 62 | $this->fields[] = $row; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | //Hier werden die Variablen in den Template-Variabeln registriert |
|---|
| 66 | WCF::getTPL()->assign(array( |
|---|
| 67 | 'fields' => $this->fields, |
|---|
| 68 | 'itemID' => $this->itemID |
|---|
| 69 | )); |
|---|
| 70 | |
|---|
| 71 | //Hier wird das Template in den Platzhalter der databaseItem.tpl geladen |
|---|
| 72 | if(!defined("DATABASE_ADDITIONAL_RATING_ADD_TPL")) { |
|---|
| 73 | WCF::getTPL()->append('additionalFields2', WCF::getTPL()->fetch('databaseAdditionalRatingAdd')); |
|---|
| 74 | define("DATABASE_ADDITIONAL_RATING_ADD_TPL",1); |
|---|
| 75 | } |
|---|
| 76 | } |
|---|
| 77 | } |
|---|
| 78 | } |
|---|
| 79 | } |
|---|
| 80 | ?> |
|---|