Index: /controller/wpsg_ShopController.class.php
===================================================================
--- /controller/wpsg_ShopController.class.php	(revision 6327)
+++ /controller/wpsg_ShopController.class.php	(revision 6328)
@@ -1332,5 +1332,7 @@
 						else $this->titleDisplayed = false;
 						
-						$content .= $this->renderProdukt($product_id, $template);
+						$oProduct = wpsg_product::getInstance($product_id);
+						
+						if ($oProduct->canDisplay()) $content .= $this->renderProdukt($product_id, $template);
 						
 					}
Index: /model/wpsg_model.class.php
===================================================================
--- /model/wpsg_model.class.php	(revision 6327)
+++ /model/wpsg_model.class.php	(revision 6328)
@@ -73,4 +73,5 @@
 		 * Gibt eine Instanz dieses Models zurÃŒck anhand des PrimÃ€rschlÃŒssels
 		 * @param int $id
+		 * @return self
 		 */
 		public static function getInstance($id, $noCache = false)
Index: /model/wpsg_product.class.php
===================================================================
--- /model/wpsg_product.class.php	(revision 6327)
+++ /model/wpsg_product.class.php	(revision 6328)
@@ -252,36 +252,49 @@
 
 		} // public function getDefaultTaxValue()
-
-		/**
-		 * Gibt true zurÃŒck, wenn der Produktpreis angezeigt werden darf
-		 */
-		public function canDisplayPrice()
-		{
+ 
+		/**
+		 * Bestimmt ob das Produkt z.B. in den ProduktÃŒbersichten angezeigt werden kann
+		 * 
+		 * @param String $product_key Der ProduktKey
+		 * @return bool true wenn das Produkt sichtbar ist
+		 */
+		public function canDisplay($product_key = false)
+		{
+			
+			if ($product_key === false) $product_key = $this->id;
+					
+			// Module Checken
+			$bOK = $this->shop->callMods('canDisplay', array($product_key));
+			
+			return $bOK;
+			
+		} // public function canDisplay($product_key = false)
+
+		/**
+		 * Bestimmt ob der Preis des Produktes angezeigt werden darf
+		 * 
+		 * @param String $product_key Der ProduktKey
+		 * @param bool $product_key true wenn der Preis angezeigt werden darf
+		 */
+		public function canDisplayPrice($product_key = false)
+		{
+			
+			if ($product_key === false) $product_key = $this->id;
+			
+			// War mal im Produkt, muss aber auch ohne Produktbezug funktionieren z.B. fÃŒr den Preisfilter
+			// Im ShopController wird die Preisanzeige fÃŒr angemeldete Nutzer geprÃŒft			
+			return $GLOBALS['wpsg_sc']->canDisplayPrice();
+						
+		} // public function canDisplayPrice($product_key = false)
+		
+		/**
+		 * Gibt true zurÃŒck, wenn das Produkt gekauft werden kann, false wenn nicht 
+		 * Bestimmt ob der Button im Warenkorb angezeigt wird
+		 */
+		public function canOrder($product_key = false)
+		{
+				
+			if ($product_key === false) $product_key = $this->id;
 			 
-			// War mal im Produkt, muss aber auch ohne Produktbezug funktionieren z.B. fÃŒr den Preisfilter			
-			return $GLOBALS['wpsg_sc']->canDisplayPrice();
-			
-		} // public function canDisplayPrice()
-		
-		/**
-		 * Gibt true zurÃŒck, wenn das Produkt gekauft werden kann, false wenn nicht 
-		 */
-		public function canOrder($product_key = false)
-		{
-				
-			if ($product_key === false) $product_key = $this->id;
-			
-			// Preis und Kauf nur fÃŒr angemeldete Benutzer?
-			$wpsg_mod_kundenverwaltung_preisAnzeige = $this->shop->get_option('wpsg_mod_kundenverwaltung_preisAnzeige');
-			
-			if (wpsg_isSizedInt($wpsg_mod_kundenverwaltung_preisAnzeige))
-			{
-				
-				$isLoggedIn = $this->shop->callMod('wpsg_mod_kundenverwaltung', 'isLoggedIn');
-				
-				if (!wpsg_isSizedInt($isLoggedIn)) return false;
-				
-			} 
-			
 			// Anfrageprodukt?
 			if ($this->shop->hasMod('wpsg_mod_request'))
@@ -293,4 +306,16 @@
 				
 			}
+			
+			// Kauf nur fÃŒr angemeldete Benutzer?
+			$wpsg_mod_kundenverwaltung_preisAnzeige = $this->shop->get_option('wpsg_mod_kundenverwaltung_preisAnzeige');
+			
+			if (wpsg_isSizedInt($wpsg_mod_kundenverwaltung_preisAnzeige))
+			{
+				
+				$isLoggedIn = $this->shop->callMod('wpsg_mod_kundenverwaltung', 'isLoggedIn');
+				
+				if (!wpsg_isSizedInt($isLoggedIn)) return false;
+				
+			} 
 			
 			// Module Checken
@@ -607,6 +632,7 @@
 			$force_load = false;
 			
-			if (wpsg_isSizedInt($arFilter['hidesoldout'])) $force_load = true;
-			
+			// Wenn ich die nicht kaufbaren Produkte rausfiltern will, kann ich es nicht auf einen DB Query beschrÃ€nken, da ich die Module anfragen muss
+			//if (wpsg_isSizedInt($arFilter['hideNotBuyable'])) $force_load = true;
+				 			
 			foreach ($arID as $id)
 			{
@@ -617,8 +643,12 @@
 					$arReturn[$id] = self::getInstance($id);
 										
-					if (wpsg_isSizedInt($arFilter['hidesoldout']) && !$arReturn[$id]->canOrder()) unset($arReturn[$id]); 
+					//if (wpsg_isSizedInt($arFilter['hideNotBuyable']) && !$arReturn[$id]->canOrder()) { unset($arReturn[$id]); continue; } 
+					
+					// StandardmÃ€Ãig werden nicht anzeigbare Produkte ausgeblendet
+					// Erfordert das die Objekt geladen wurden, sonst muss spÃ€ter geprÃŒft werden
+					if (!$arReturn[$id]->canDisplay()) { unset($arReturn[$id]); continue; } 
 					
 					if (isset($arReturn[$id]) && $force_load === true && $load === false) $arReturn[$id] = $id;
-					
+										
 				}
 				else $arReturn[$id] = $id;
Index: /mods/wpsg_mod_basic.class.php
===================================================================
--- /mods/wpsg_mod_basic.class.php	(revision 6327)
+++ /mods/wpsg_mod_basic.class.php	(revision 6328)
@@ -947,4 +947,7 @@
 		public function canOrder($product_key) { }
 		
+		/** Bestimmt ob das Produkt angezeigt werden kann */
+		public function canDisplay($product_key) { }
+		
 		/**
 		 *  Hilfsfunktion, die die Zahlungskosten auf den Warenkorb Array draufschlÃ€gt
Index: /mods/wpsg_mod_productview.class.php
===================================================================
--- /mods/wpsg_mod_productview.class.php	(revision 6327)
+++ /mods/wpsg_mod_productview.class.php	(revision 6328)
@@ -362,6 +362,6 @@
 				
 			}
-						 
-			if (!wpsg_isSizedInt($atts['showsoldout'])) $arFilter = wpsg_array_merge($arFilter, array('hidesoldout' => '1'));
+				
+			if (!wpsg_isSizedInt($atts['hideNotBuyable'])) $arFilter = wpsg_array_merge($arFilter, array('hideNotBuyable' => '1'));
 			if (wpsg_isSizedString($atts['filter']['price_min'])) $arFilter = wpsg_array_merge($arFilter, array('price_min' => $atts['filter']['price_min']));
 			if (wpsg_isSizedString($atts['filter']['price_max'])) $arFilter = wpsg_array_merge($arFilter, array('price_max' => $atts['filter']['price_max']));
Index: /mods/wpsg_mod_produktartikel.class.php
===================================================================
--- /mods/wpsg_mod_produktartikel.class.php	(revision 6327)
+++ /mods/wpsg_mod_produktartikel.class.php	(revision 6328)
@@ -96,6 +96,6 @@
 		public function be_ajax() 
 		{ 
-			
-			if (wpsg_isSizedString($_REQUEST['do'], 'setWPMLPathKey'))
+			 
+			if (wpsg_getStr($_REQUEST['do'], 'setWPMLPathKey'))
 			{
 				
@@ -109,104 +109,4 @@
 				
 			}
-			else if (wpsg_isSizedString($_REQUEST['do'], 'index_rebuild'))
-			{
-				
-				$arProductIDs = $this->db->fetchAssocField("SELECT `id` FROM `".WPSG_TBL_PRODUCTS."` ", "id");
-				
-				if (wpsg_isSizedArray($arProductIDs))
-				{
-				
-					// Ich lÃ¶sche alle Posts zu denen es die Produkte nicht mehr gibt
-					$this->db->Query("
-						DELETE FROM 
-							`".$this->shop->prefix."posts` 
-						WHERE  
-							`wpsg_produkt_id` NOT IN (".wpsg_q(implode(',', $arProductIDs)).") AND
-							`wpsg_produkt_id` > 0
-					");
-					
-					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', array(
-						'max' => sizeof($arProductIDs),
-						'product_ids' => $arProductIDs
-					));
-					 					
-					$this->shop->addBackendMessage(__('Zuordnungen werden neu aufgebaut. Bitte schlieÃen Sie die Seite nicht bis der Vorgang abgeschlossen ist.', 'wpsg'));				
-									
-				}
-				else
-				{
-									
-					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', null);
-					
-					$this->shop->addBackendMessage(__('Ein Aufbau der Zuordnung nicht nicht notwendig.', 'wpsg'));
-					
-				}
-				
-				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_produktartikel');
-				
-			}
-			else if (wpsg_isSizedString($_REQUEST['do'], 'rebuild'))
-			{
-				
-				$arToDo = $this->shop->get_option('wpsg_mod_produktartikel_rebuild');				
-				$arProductIDs = $arToDo['product_ids'];
-				
-				$i = 0;
-				$limit = 20; 
-				 
-				foreach ($arProductIDs as $k => $product_id)
-				{
-					
-					$product_data = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".wpsg_q($product_id)."' ");
-					$post_data = $this->db->fetchRow("SELECT * FROM `".$this->shop->prefix."posts` WHERE `wpsg_produkt_id` = '".wpsg_q($product_id)."' ");
-					
-					$_REQUEST['wpsg_mod_produktartikel']['path'] = wpsg_getStr($post_data['post_name'], '');
-					$_REQUEST['wpsg_mod_produktartikel']['kommentare'] = wpsg_getStr($post_data['comment_status'], '');
-					$_REQUEST['wpsg_produktartikel_menuorder'] = wpsg_getStr($post_data['menu_order'], '');
-					
-					if (wpsg_isSizedInt($product_data['lang_parent']))
-					{
-						
-						$_REQUEST['wpsg_lang'] = $product_data['lang_code'];
-						
-						$this->produkt_save_translation($product_data['lang_parent'], $product_data['id']);
-						
-					}
-					else
-					{
-					
-						$this->produkt_save($product_data['id']);
-						
-					}
-					
-					unset($arProductIDs[$k]);
-					
-					$i ++;
-					
-					if ($i >= $limit) break;
-					
-				}
-				
-				if (wpsg_isSizedArray($arProductIDs))
-				{
-					
-					$arToDo['product_ids'] = $arProductIDs;
-					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', $arToDo);
-					$done = 1 - (sizeof($arProductIDs) / $arToDo['max']); 
-						
-				}
-				else
-				{
-					
-					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', null);
-					$done = 1;
-					
-				}
-				
-				wpsg_header::JSONData(array(
-					'done' => $done
-				));
-				
-			}
 			
 		}
@@ -236,6 +136,11 @@
 			{
 				 
-				$produkt_id = $post->wpsg_produkt_id;  
-				$content = $this->shop->renderProdukt($produkt_id);
+				$product_id = $post->wpsg_produkt_id;
+				
+				$oProduct = wpsg_product::getInstance($product_id); 
+				
+				if (!$oProduct->canDisplay()) return -2;
+				
+				$content = $this->shop->renderProdukt($product_id);
 				
 				return -2;
@@ -289,7 +194,4 @@
 		public function settings_edit()
 		{
-			
-			// Rebuild
-			$this->shop->view['ToRebuild'] = $this->shop->get_option('wpsg_mod_produktartikel_rebuild');
 			
 			// VerfÃŒgbare Produkttemplates
@@ -407,5 +309,4 @@
 			
 			$post_content = $this->shop->renderProdukt($copy_id);
-			$post_content = $this->clear_post_content($post_content);
 			
 			$post_data = $this->db->fetchRow("
@@ -1018,6 +919,4 @@
 				}
 				
-				$post_content = $this->clear_post_content($post_content);
-				
 				$data = array(
 					"post_title" => wpsg_q($post_title), 
@@ -1106,11 +1005,4 @@
 			
 		} // private function getPostIdFromProductId($product_id)
-		
-		private function clear_post_content($post_content) 
-		{
-			
-			return preg_replace('#<script(.*?)>(.*?)</script>#is', '', $post_content);
-			
-		} // private function clear_post_content($post_content)
 		
 		/**
Index: /mods/wpsg_mod_stock.class.php
===================================================================
--- /mods/wpsg_mod_stock.class.php	(revision 6327)
+++ /mods/wpsg_mod_stock.class.php	(revision 6328)
@@ -63,4 +63,5 @@
 			$this->shop->update_option('wpsg_mod_stock_showBackendStock', $_REQUEST['wpsg_mod_stock_showBackendStock']);
 			$this->shop->update_option('wpsg_mod_stock_minstockproduct', $_REQUEST['wpsg_mod_stock_minstockproduct']);
+			$this->shop->update_option('wpsg_mod_stock_hideSoldout', $_REQUEST['wpsg_mod_stock_hideSoldout']);
 			
 			if ($this->shop->hasMod('wpsg_mod_productindex'))
@@ -83,4 +84,11 @@
 			
 		} // public function canOrder($oProduct)
+		
+		public function canDisplay($product_key)
+		{
+			
+			if ($this->shop->get_option('wpsg_mod_stock_hideSoldout') === '1' && $this->getBestand($product_key) - $this->getAmountSession($product_key) <= 0) return -2;
+			
+		} // public function canDisplay($product_key)
 		
 		public function produkt_ajax() { 
Index: /views/admin/presentation.phtml
===================================================================
--- /views/admin/presentation.phtml	(revision 6327)
+++ /views/admin/presentation.phtml	(revision 6328)
@@ -35,5 +35,5 @@
 			 	<?php echo wpsg_drawForm_Checkbox('wpsg_showArticelnumber', __('Artikelnummer im Produkttemplate anzeigen', 'wpsg'), $this->get_option('wpsg_showArticelnumber')); ?>
 			 	<?php echo wpsg_drawForm_Checkbox('wpsg_hideBasketCountrySelect', __('LÃ€nderauswahl im Warenkorb verbergen', 'wpsg'), $this->get_option('wpsg_hideBasketCountrySelect')); ?>
-			 	
+				
 			 </div>
 		</div>
Index: /views/mods/mod_stock/settings_edit.phtml
===================================================================
--- /views/mods/mod_stock/settings_edit.phtml	(revision 6327)
+++ /views/mods/mod_stock/settings_edit.phtml	(revision 6328)
@@ -9,11 +9,11 @@
 <?php echo wpsg_drawForm_Checkbox('wpsg_mod_stock_allow', __('Bestellungen bei negativen Bestand verhindern', 'wpsg'), $this->get_option('wpsg_mod_stock_allow'), array('help' => 'wpsg_mod_stock_allow')); ?>
 <?php echo wpsg_drawForm_Checkbox('wpsg_mod_stock_showBackendStock', __('Bestand in ProduktÃŒbersicht (Backend) anzeigen', 'wpsg'), $this->get_option('wpsg_mod_stock_showBackendStock'), array('help' => 'wpsg_mod_stock_showBackendStock')); ?>
+
 <?php if ($this->hasMod('wpsg_mod_productindex')) { ?>
 <?php echo wpsg_drawForm_Checkbox('wpsg_mod_stock_showProductindex', __('Bestand in ProduktÃŒbersicht (Frontend) anzeigen', 'wpsg'), $this->get_option('wpsg_mod_stock_showProductindex'), array('help' => 'wpsg_mod_stock_showProductindex')); ?>
 <?php } ?>
+
 <?php echo wpsg_drawForm_Checkbox('wpsg_mod_stock_showProduct', __('Bestand in Produkt (Frontend) anzeigen', 'wpsg'), $this->get_option('wpsg_mod_stock_showProduct'), array('help' => 'wpsg_mod_stock_showProduct')); ?>
-
-<br />
-
 <?php echo wpsg_drawForm_Checkbox('wpsg_mod_stock_minstockproduct',  __('Minimalbestand im Produkt hinterlegen', 'wpsg'), $this->get_option('wpsg_mod_stock_minstockproduct'), array('help' => 'wpsg_mod_stock_minstockproduct')); ?>
+<?php echo wpsg_drawForm_Checkbox('wpsg_mod_stock_hideSoldout',  __('Ausverkaufte Produkte nicht anzeigen', 'wpsg'), $this->get_option('wpsg_mod_stock_hideSoldout'), array('help' => 'wpsg_mod_stock_hideSoldout')); ?>
  
