[BUGFIX] Fix for custom categories 26/17326/3
authorWolfgang Becker <wolfgang.becker@visionate.com>
Thu, 3 Jan 2013 09:43:19 +0000 (10:43 +0100)
committerSimon Schaufelberger <simonschaufi@googlemail.com>
Fri, 25 Jan 2013 17:36:26 +0000 (18:36 +0100)
Resolves: #7905
Releases: 1.5.3

Change-Id: Icd3d481ed0c0ddd623de9bb597707bc0b08b19ef
Reviewed-on: https://review.typo3.org/17326
Reviewed-by: Simon Schaufelberger
Tested-by: Simon Schaufelberger
pi1/class.tx_macinabanners_pi1.php

index 30574f7..ec01d00 100755 (executable)
@@ -128,10 +128,10 @@ class tx_macinabanners_pi1 extends tslib_pibase {
         * @return      string          html content
         */
        function listView($content, $conf) {
-               $this->conf = $conf; // Setting the TypoScript passed to this function in $this->conf
+               $this->conf = $conf;
 
                $this->pi_setPiVarDefaults();
-               $this->pi_loadLL();     // Loading the LOCAL_LANG values
+               $this->pi_loadLL();
 
                $this->siteRelPath = $GLOBALS['TYPO3_LOADED_EXT'][$this->extKey]['siteRelPath'];
 
@@ -142,13 +142,22 @@ class tx_macinabanners_pi1 extends tslib_pibase {
                $allowedPlacements = t3lib_div::trimExplode(',',$conf['placement']);
                if (count($allowedPlacements) > 0) {
                        $placementClause = '';
-                       foreach ($allowedPlacements AS $placement) {
-                               if ($placementClause != '') {
-                                       $placementClause .= ' OR ';
+
+                       foreach ($allowedPlacements AS $key => $placement) {
+                               if (t3lib_div::inList("top,bottom,right,left", $placement)) {
+                                       $allowedPlacements[$key] = $placement;
+                               } else {
+                                       $catWhere = ' AND description LIKE \'%' . $placement . '%\'';
+                                       $catRS = $this->pi_exec_query('tx_macinabanners_categories', 0, $catWhere, '', '', '');
+                                       $catRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($catRS);
+                                       $allowedPlacements[$key] = 'tx_macinabanners_categories:' . $catRow['uid'];
                                }
-                               $placementClause .= 'placement LIKE "%'.$placement.'%"';
+                               if ($placementClause != '')
+                                       $placementClause .= ", '" . $allowedPlacements[$key] . "'";
+                               else
+                                       $placementClause .= "'" . $allowedPlacements[$key] . "'";
                        }
-                       $where .= ' AND ('.$placementClause.')';
+                       $where .= ' AND placement IN (' . $placementClause . ') ';
                }
 
                // alle banner die die aktuelle page id nicht in excludepages stehen haben