/** * Add an sql restriction for shops fields * * @param boolean $share If false, dont check share datas from group. Else can take a Shop::SHARE_* constant value * @param string $alias * @return string */ public static function addSqlRestriction($share = false, $alias = null) { if ($alias) { $alias .= '.'; } $group = JeproshopShopModelShop::getShopGroupFromShop(JeproshopShopModelShop::getContextShopID(), false); if ($share == JeproshopShopModelShop::SHARE_CUSTOMER && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP && $group['share_customer']) { $restriction = " AND " . $alias . "shop_group_id = " . (int) JeproshopShopModelShop::getContextShopGroupId(); } else { $restriction = " AND " . $alias . "shop_id IN (" . implode(', ', JeproshopShopModelShop::getContextListShopIds($share)) . ") "; } return $restriction; }
public static function getContextListShopIds($share = false) { if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) { $list = $share ? JeproshopShopModelShop::getSharedShops(JeproshopShopModelShop::getContextShopId(), $share) : array(JeproshopShopModelShop::getContextShopId()); } elseif (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_GROUP) { $list = JeproshopShopModelShop::getShops(true, JeproshopShopModelShop::getContextShopGroupId(), true); } else { $list = JeproshopShopModelShop::getShops(TRUE, null, true); } return $list; }