/** * mediaFileAuthorise * * @param STRING $file_id file_id * @param STRING $strorecall strorecall * @param STRING $guest_email guest_email * @param STRING $order_item_id order_item_id * * @return html */ public function mediaFileAuthorise($file_id, $strorecall, $guest_email, $order_item_id) { // Get store id associatd with file id $db = JFactory::getDBO(); $query = "SELECT i.`store_id`,`file_id`,`file_display_name`,`filePath`,`purchase_required` FROM `#__kart_itemfiles` AS f\n\t\tLEFT JOIN `#__kart_items` AS i ON f.item_id=i.item_id\n\t\twhere f.`file_id`=" . $file_id; $db->setQuery($query); $fileDetail = $db->loadAssoc(); $comquick2cartHelper = new comquick2cartHelper(); $ret['validDownload'] = 0; $ret['orderItemFileId'] = 0; // FOR STORE AUTHORIZED PERSONS if (!empty($strorecall)) { $ret['validDownload'] = $comquick2cartHelper->store_authorize('product_default', $fileDetail['store_id']); return $ret; } elseif (empty($order_item_id) && $fileDetail['purchase_required'] == 0) { // Called from product detail page // For free media $ret['validDownload'] = 1; return $ret; } else { // Is authorized guest chekout if (!empty($guest_email)) { $orderid = $comquick2cartHelper->getOrderId($order_item_id); $guest_email_chk = $comquick2cartHelper->checkmailhash($orderid, $guest_email); if (empty($guest_email_chk)) { // Not matched $ret['validDownload'] = 0; return $ret; } } // Is expired date/download conunt or not $productHelper = new productHelper(); $ret = $productHelper->validDownload($file_id, $order_item_id); return $ret; } }