public function setUserId($url_slug) { $user = \Config::get('webshoppack::logged_user_id'); $this->logged_user_id = $user(); $shop_details = ShopDetails::Select('shop_details.user_id', 'shop_details.shop_name')->whereRaw('shop_details.url_slug = ? AND users.activated = 1', array($url_slug))->join('users', 'shop_details.user_id', '=', 'users.id')->first(); if (count($shop_details) > 0 && $shop_details['shop_name'] != '') { $this->shop_owner_id = $shop_details['user_id']; $this->current_user = strcmp($this->logged_user_id, $this->shop_owner_id) == 0; } }
public static function getShopImage($shop_id, $image_size = "thumb", $shop_image_info = array(), $cache = true) { $image_exists = false; $image_details = array(); if (count($shop_image_info) == 0) { $shop_image_info = ShopDetails::whereRaw('id = ? ', array($shop_id))->first(); } if (count($shop_image_info) > 0 && $shop_image_info['image_name'] != '') { $image_exists = true; $image_details["image_id"] = $shop_image_info['id']; $image_details["image_ext"] = $shop_image_info['image_ext']; $image_details["image_name"] = $shop_image_info['image_name']; $image_details["image_server_url"] = $shop_image_info['image_server_url']; $image_details["image_thumb_width"] = $shop_image_info['t_width']; $image_details["image_thumb_height"] = $shop_image_info['t_height']; $image_details["image_folder"] = Config::get("webshoppack::shop_image_folder"); } $image_path = ""; $image_url = ""; $image_attr = ""; if ($image_exists) { $image_path = URL::asset(Config::get("webshoppack::shop_image_folder")) . "/"; } $cfg_shop_img_thumb_width = Config::get("webshoppack::shop_image_thumb_width"); $cfg_shop_img_thumb_height = Config::get("webshoppack::shop_image_thumb_height"); switch ($image_size) { case "thumb": $image_url = ""; $image_attr = ""; if ($image_exists) { $image_url = $image_path . $image_details["image_name"] . "_T." . $image_details["image_ext"]; $image_attr = CUtil::TPL_DISP_IMAGE($cfg_shop_img_thumb_width, $cfg_shop_img_thumb_height, $image_details["image_thumb_width"], $image_details["image_thumb_height"]); } break; default: $image_url = ""; $image_attr = ""; if ($image_exists) { $image_url = $image_path . $image_details["image_name"] . "_T." . $image_details["image_ext"]; $image_attr = CUtil::TPL_DISP_IMAGE(90, 90, $image_details["image_thumb_width"], $image_details["image_thumb_height"]); } } $image_details['image_url'] = $image_url; $image_details['image_attr'] = $image_attr; return $image_details; }
/** * CUtil::isShopOwner() * added by mohamed_158at11 * * @return boolean */ public static function isShopOwner($user_id = null) { if (is_null($user_id)) { $user = \Config::get('webshoppack::logged_user_id'); $logged_user_id = $user(); } else { $logged_user_id = $user_id; } if ($logged_user_id > 0) { $details = \Agriya\Webshoppack\ShopDetails::where('user_id', $logged_user_id)->count(); if ($details) { return true; } } return false; }