public static function isValid(Product $OSCOM_Product)
 {
     $OSCOM_Customer = Registry::get('Customer');
     $OSCOM_ShoppingCart = Registry::get('ShoppingCart');
     if ($OSCOM_ShoppingCart->hasBillingAddress() === false) {
         if ($OSCOM_Customer->hasDefaultAddress()) {
             $OSCOM_ShoppingCart->setBillingAddress($OSCOM_Customer->getDefaultAddressID());
             $OSCOM_ShoppingCart->resetBillingMethod();
         } elseif ($OSCOM_ShoppingCart->hasShippingAddress()) {
             $OSCOM_ShoppingCart->setBillingAddress($OSCOM_ShoppingCart->getShippingAddress());
             $OSCOM_ShoppingCart->resetBillingMethod();
         }
     }
     if ($OSCOM_ShoppingCart->hasBillingMethod() === false) {
         if (Registry::exists('Payment') === false) {
             Registry::set('Payment', new Payment());
         }
         $OSCOM_Payment = Registry::get('Payment');
         $OSCOM_Payment->loadAll();
         if ($OSCOM_Payment->hasActive()) {
             $payment_modules = $OSCOM_Payment->getActive();
             $payment_module = $payment_modules[0];
             $OSCOM_PaymentModule = Registry::get('Payment_' . $payment_module);
             $OSCOM_ShoppingCart->setBillingMethod(array('id' => $OSCOM_PaymentModule->getCode(), 'title' => $OSCOM_PaymentModule->getMethodTitle()));
         }
     }
     return $OSCOM_ShoppingCart->hasBillingAddress() && $OSCOM_ShoppingCart->hasBillingMethod();
 }
예제 #2
0
 public function initialize()
 {
     $OSCOM_Product = Registry::exists('Product') ? Registry::get('Product') : null;
     $OSCOM_PDO = Registry::get('PDO');
     $OSCOM_Language = Registry::get('Language');
     if (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid()) {
         $Qmanufacturer = $OSCOM_PDO->query('select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image, mi.manufacturers_url from :table_manufacturers m left join :table_manufacturers_info mi on (m.manufacturers_id = mi.manufacturers_id and mi.languages_id = :languages_id), :table_products p  where p.products_id = :products_id and p.manufacturers_id = m.manufacturers_id');
         $Qmanufacturer->bindInt(':languages_id', $OSCOM_Language->getID());
         $Qmanufacturer->bindInt(':products_id', $OSCOM_Product->getID());
         $Qmanufacturer->execute();
         $result = $Qmanufacturer->fetch();
         if (!empty($result)) {
             $this->_content = '';
             if (strlen($result['manufacturers_image']) > 0) {
                 $this->_content .= '<div style="text-align: center;">' . HTML::link(OSCOM::getLink(null, 'Index', 'Manufacturers=' . $result['manufacturers_id']), HTML::image('public/manufacturers/' . $result['manufacturers_image'], $result['manufacturers_name'])) . '</div>';
             }
             $this->_content .= '<ol style="list-style: none; margin: 0; padding: 0;">';
             if (strlen($result['manufacturers_url']) > 0) {
                 $this->_content .= '<li>' . HTML::link(OSCOM::getLink(null, 'Redirct', 'Manufacturer=' . $result['manufacturers_id']), sprintf(OSCOM::getDef('box_manufacturer_info_website'), $result['manufacturers_name']), 'target="_blank"') . '</li>';
             }
             $this->_content .= '<li>' . HTML::link(OSCOM::getLink(null, 'Index', 'Manufacturers=' . $result['manufacturers_id']), OSCOM::getDef('box_manufacturer_info_products')) . '</li>';
             $this->_content .= '</ol>';
         }
     }
 }
예제 #3
0
 public function initialize()
 {
     $OSCOM_Product = Registry::exists('Product') ? Registry::get('Product') : null;
     $OSCOM_Customer = Registry::get('Customer');
     $OSCOM_Database = Registry::get('Database');
     $OSCOM_Language = Registry::get('Language');
     $this->_title_link = OSCOM::getLink(null, 'Account', 'Notifications', 'SSL');
     if (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid()) {
         if ($OSCOM_Customer->isLoggedOn()) {
             $Qcheck = $OSCOM_Database->query('select global_product_notifications from :table_customers where customers_id = :customers_id');
             $Qcheck->bindInt(':customers_id', $OSCOM_Customer->getID());
             $Qcheck->execute();
             if ($Qcheck->valueInt('global_product_notifications') === 0) {
                 $Qcheck = $OSCOM_Database->query('select products_id from :table_products_notifications where products_id = :products_id and customers_id = :customers_id limit 1');
                 $Qcheck->bindInt(':products_id', $OSCOM_Product->getID());
                 $Qcheck->bindInt(':customers_id', $OSCOM_Customer->getID());
                 $Qcheck->execute();
                 if ($Qcheck->numberOfRows() > 0) {
                     $this->_content = '<div style="float: left; width: 55px;">' . osc_link_object(OSCOM::getLink(null, null, osc_get_all_get_params(array('action')) . '&action=notify_remove', 'AUTO'), osc_image(DIR_WS_IMAGES . 'box_products_notifications_remove.gif', sprintf(OSCOM::getDef('box_product_notifications_remove'), $OSCOM_Product->getTitle()))) . '</div>' . osc_link_object(OSCOM::getLink(null, null, osc_get_all_get_params(array('action')) . '&action=notify_remove', 'AUTO'), sprintf(OSCOM::getDef('box_product_notifications_remove'), $OSCOM_Product->getTitle()));
                 } else {
                     $this->_content = '<div style="float: left; width: 55px;">' . osc_link_object(OSCOM::getLink(null, null, osc_get_all_get_params(array('action')) . '&action=notify_add', 'AUTO'), osc_image(DIR_WS_IMAGES . 'box_products_notifications.gif', sprintf(OSCOM::getDef('box_product_notifications_add'), $OSCOM_Product->getTitle()))) . '</div>' . osc_link_object(OSCOM::getLink(null, null, osc_get_all_get_params(array('action')) . '&action=notify_add', 'AUTO'), sprintf(OSCOM::getDef('box_product_notifications_add'), $OSCOM_Product->getTitle()));
                 }
                 $this->_content .= '<div style="clear: both;"></div>';
             }
         }
     }
 }
예제 #4
0
 public static function execute(ApplicationAbstract $application)
 {
     $OSCOM_Shipping = Registry::get('Shipping');
     $OSCOM_ShoppingCart = Registry::get('ShoppingCart');
     if (!empty($_POST['comments'])) {
         $_SESSION['comments'] = HTML::sanitize($_POST['comments']);
     }
     if ($OSCOM_Shipping->hasQuotes()) {
         if (isset($_POST['shipping_mod_sel']) && strpos($_POST['shipping_mod_sel'], '_')) {
             list($module, $method) = explode('_', $_POST['shipping_mod_sel']);
             if (Registry::exists('Shipping_' . $module) && Registry::get('Shipping_' . $module)->isEnabled()) {
                 $quote = $OSCOM_Shipping->getQuote($_POST['shipping_mod_sel']);
                 if (isset($quote['error'])) {
                     $OSCOM_ShoppingCart->resetShippingMethod();
                 } else {
                     $OSCOM_ShoppingCart->setShippingMethod($quote);
                     OSCOM::redirect(OSCOM::getLink(null, null, null, 'SSL'));
                 }
             } else {
                 $OSCOM_ShoppingCart->resetShippingMethod();
             }
         }
     } else {
         $OSCOM_ShoppingCart->resetShippingMethod();
         OSCOM::redirect(OSCOM::getLink(null, null, null, 'SSL'));
     }
 }
예제 #5
0
 public function initialize()
 {
     if (Registry::exists('Product')) {
         $OSCOM_PDO = Registry::get('PDO');
         $OSCOM_Product = Registry::get('Product');
         $OSCOM_Language = Registry::get('Language');
         $OSCOM_Image = Registry::get('Image');
         $Qorders = $OSCOM_PDO->prepare('select p.products_id, pd.products_name, pd.products_keyword, i.image from :table_orders_products opa, :table_orders_products opb, :table_orders o, :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd where opa.products_id = :products_id and opa.orders_id = opb.orders_id and opb.products_id != :products_id and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id group by p.products_id order by o.date_purchased desc limit :limit');
         $Qorders->bindInt(':default_flag', 1);
         $Qorders->bindInt(':products_id', $OSCOM_Product->getID());
         $Qorders->bindInt(':products_id', $OSCOM_Product->getID());
         $Qorders->bindInt(':language_id', $OSCOM_Language->getID());
         $Qorders->bindInt(':limit', MODULE_CONTENT_ALSO_PURCHASED_MAX_DISPLAY);
         if (MODULE_CONTENT_ALSO_PURCHASED_PRODUCTS_CACHE > 0) {
             $Qorders->setCache('also_purchased-' . $OSCOM_Product->getID(), MODULE_CONTENT_ALSO_PURCHASED_PRODUCTS_CACHE);
         }
         $Qorders->execute();
         $result = $Qorders->fetchAll();
         if (count($result) >= MODULE_CONTENT_ALSO_PURCHASED_MIN_DISPLAY) {
             $this->_content = '<div style="overflow: auto;">';
             foreach ($result as $p) {
                 $this->_content .= '<span style="width: 33%; float: left; text-align: center;">';
                 if (strlen($p['image']) > 0) {
                     $this->_content .= HTML::link(OSCOM::getLink(null, 'Products', $p['products_keyword']), $OSCOM_Image->show($p['image'], $p['products_name'])) . '<br />';
                 }
                 $this->_content .= HTML::link(OSCOM::getLink(null, 'Products', $p['products_keyword']), $p['products_name']) . '</span>';
             }
             $this->_content .= '</div>';
         }
     }
 }
예제 #6
0
 public static function execute($search, $parent_id = 0)
 {
     if (Registry::exists('CategoryTree')) {
         $OSCOM_CategoryTree = Registry::get('CategoryTree');
     } else {
         $OSCOM_CategoryTree = new CategoryTree();
         Registry::set('CategoryTree', $OSCOM_CategoryTree);
     }
     $OSCOM_CategoryTree->reset();
     $OSCOM_CategoryTree->setRootCategoryID($parent_id);
     $OSCOM_CategoryTree->setBreadcrumbUsage(false);
     $categories = array();
     foreach ($OSCOM_CategoryTree->getArray() as $c) {
         if (stripos($c['title'], $search) !== false) {
             if ($c['id'] != $parent_id) {
                 $category_path = $OSCOM_CategoryTree->getPathArray($c['id']);
                 $top_category_id = $category_path[0]['id'];
                 if (!in_array($top_category_id, $categories)) {
                     $categories[] = $top_category_id;
                 }
             }
         }
     }
     $result = array('entries' => array());
     foreach ($categories as $c) {
         $result['entries'][] = array('id' => $OSCOM_CategoryTree->getData($c, 'id'), 'title' => $OSCOM_CategoryTree->getData($c, 'name'), 'products' => $OSCOM_CategoryTree->getData($c, 'count'));
     }
     $result['total'] = count($result['entries']);
     return $result;
 }
예제 #7
0
 public function initialize()
 {
     if (Registry::exists('Product')) {
         $OSCOM_Database = Registry::get('Database');
         $OSCOM_Product = Registry::get('Product');
         $OSCOM_Language = Registry::get('Language');
         $OSCOM_Image = Registry::get('Image');
         $Qorders = $OSCOM_Database->query('select p.products_id, pd.products_name, pd.products_keyword, i.image from :table_orders_products opa, :table_orders_products opb, :table_orders o, :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd where opa.products_id = :products_id and opa.orders_id = opb.orders_id and opb.products_id != :products_id and opb.products_id = p.products_id and opb.orders_id = o.orders_id and p.products_status = 1 and p.products_id = pd.products_id and pd.language_id = :language_id group by p.products_id order by o.date_purchased desc limit :limit');
         $Qorders->bindInt(':default_flag', 1);
         $Qorders->bindInt(':products_id', $OSCOM_Product->getID());
         $Qorders->bindInt(':products_id', $OSCOM_Product->getID());
         $Qorders->bindInt(':language_id', $OSCOM_Language->getID());
         $Qorders->bindInt(':limit', MODULE_CONTENT_ALSO_PURCHASED_MAX_DISPLAY);
         if (MODULE_CONTENT_ALSO_PURCHASED_PRODUCTS_CACHE > 0) {
             $Qorders->setCache('also_purchased-' . $OSCOM_Product->getID(), MODULE_CONTENT_ALSO_PURCHASED_PRODUCTS_CACHE);
         }
         $Qorders->execute();
         if ($Qorders->numberOfRows() >= MODULE_CONTENT_ALSO_PURCHASED_MIN_DISPLAY) {
             $this->_content = '<div style="overflow: auto;">';
             while ($Qorders->next()) {
                 $this->_content .= '<span style="width: 33%; float: left; text-align: center;">';
                 if (strlen($Qorders->value('image')) > 0) {
                     $this->_content .= osc_link_object(OSCOM::getLink(null, 'Products', $Qorders->value('products_keyword')), $OSCOM_Image->show($Qorders->value('image'), $Qorders->value('products_name'))) . '<br />';
                 }
                 $this->_content .= osc_link_object(OSCOM::getLink(null, 'Products', $Qorders->value('products_keyword')), $Qorders->value('products_name')) . '</span>';
             }
             $this->_content .= '</div>';
         }
         $Qorders->freeResult();
     }
 }
예제 #8
0
 public function initialize()
 {
     $OSCOM_Product = Registry::exists('Product') ? Registry::get('Product') : null;
     if (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid()) {
         // HPDL && ($osC_Template->getModule() != 'tell_a_friend')) {
         $this->_content = '<form name="tell_a_friend" action="' . OSCOM::getLink(null, null, 'TellAFriend&' . $OSCOM_Product->getKeyword()) . '" method="post">' . "\n" . HTML::inputField('to_email_address', null, 'style="width: 80%;"') . '&nbsp;' . HTML::submitImage('button_tell_a_friend.gif', OSCOM::getDef('box_tell_a_friend_text')) . '<br />' . OSCOM::getDef('box_tell_a_friend_text') . "\n" . '</form>' . "\n";
     }
 }
예제 #9
0
 protected function process()
 {
     $OSCOM_ShoppingCart = Registry::get('ShoppingCart');
     $OSCOM_Customer = Registry::get('Customer');
     $OSCOM_Language = Registry::get('Language');
     $OSCOM_Service = Registry::get('Service');
     $OSCOM_Breadcrumb = Registry::get('Breadcrumb');
     $OSCOM_MessageStack = Registry::get('MessageStack');
     // redirect to shopping cart if shopping cart is empty
     if (!$OSCOM_ShoppingCart->hasContents()) {
         osc_redirect(OSCOM::getLink(null, 'Cart'));
     }
     // check for e-mail address
     if (!$OSCOM_Customer->hasEmailAddress()) {
         if (isset($_POST['email']) && strlen(trim($_POST['email'])) >= ACCOUNT_EMAIL_ADDRESS) {
             if (osc_validate_email_address($_POST['email'])) {
                 $OSCOM_Customer->setEmailAddress(trim($_POST['email']));
             } else {
                 $OSCOM_MessageStack->add('Cart', OSCOM::getDef('field_customer_email_address_check_error'));
                 osc_redirect(OSCOM::getLink(null, 'Cart'));
             }
         } else {
             $OSCOM_MessageStack->add('Cart', sprintf(OSCOM::getDef('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS));
             osc_redirect(OSCOM::getLink(null, 'Cart'));
         }
     }
     // check product type perform_order conditions
     foreach ($OSCOM_ShoppingCart->getProducts() as $product) {
         $OSCOM_Product = new Product($product['id']);
         $OSCOM_Product->isTypeActionAllowed('PerformOrder');
     }
     $OSCOM_Language->load('checkout');
     $OSCOM_Language->load('order');
     $this->_page_title = OSCOM::getDef('confirmation_heading');
     if ($OSCOM_Service->isStarted('Breadcrumb')) {
         $OSCOM_Breadcrumb->add(OSCOM::getDef('breadcrumb_checkout_confirmation'), OSCOM::getLink(null, 'Checkout', null, 'SSL'));
     }
     if (isset($_POST['comments']) && isset($_SESSION['comments']) && empty($_POST['comments'])) {
         unset($_SESSION['comments']);
     } elseif (!empty($_POST['comments'])) {
         $_SESSION['comments'] = osc_sanitize_string($_POST['comments']);
     }
     if (DISPLAY_CONDITIONS_ON_CHECKOUT == '1') {
         if (!isset($_POST['conditions']) || $_POST['conditions'] != '1') {
             $OSCOM_MessageStack->add('Checkout', OSCOM::getDef('error_conditions_not_accepted'), 'error');
         }
     }
     if (Registry::exists('Payment') === false) {
         Registry::set('Payment', new Payment());
     }
     if ($OSCOM_ShoppingCart->hasBillingMethod()) {
         $OSCOM_Payment = Registry::get('Payment');
         $OSCOM_Payment->load($OSCOM_ShoppingCart->getBillingMethod('id'));
     }
 }
예제 #10
0
 public static function execute(ApplicationAbstract $application)
 {
     $OSCOM_Payment = Registry::get('Payment');
     $OSCOM_ShoppingCart = Registry::get('ShoppingCart');
     if (isset($_POST['payment_method']) && !empty($_POST['payment_method'])) {
         if ($OSCOM_Payment->hasActive() && Registry::exists('Payment_' . $_POST['payment_method']) && Registry::get('Payment_' . $_POST['payment_method']) instanceof PaymentModuleAbstract && Registry::get('Payment_' . $_POST['payment_method'])->isEnabled()) {
             $OSCOM_ShoppingCart->setBillingMethod(array('id' => Registry::get('Payment_' . $_POST['payment_method'])->getCode(), 'title' => Registry::get('Payment_' . $_POST['payment_method'])->getMethodTitle()));
             OSCOM::redirect(OSCOM::getLink(null, null, null, 'SSL'));
         }
     }
 }
예제 #11
0
    public static function execute() {
      if ( !Registry::exists('Currencies') ) {
        Registry::set('Currencies', new Currencies());
      }

      $OSCOM_Currencies = Registry::get('Currencies');

      $result = array('value' => $OSCOM_Currencies->format($_GET['value']),
                      'rpcStatus' => RPC::STATUS_SUCCESS);

      echo json_encode($result);
    }
예제 #12
0
 public function initialize()
 {
     $OSCOM_Service = Registry::get('Service');
     $OSCOM_Cache = Registry::get('Cache');
     $OSCOM_Product = Registry::exists('Product') ? Registry::get('Product') : null;
     $OSCOM_Language = Registry::get('Language');
     $OSCOM_PDO = Registry::get('PDO');
     $OSCOM_Image = Registry::get('Image');
     $this->_title_link = OSCOM::getLink(null, 'Products', 'Reviews');
     if ($OSCOM_Service->isStarted('Reviews')) {
         if (BOX_REVIEWS_CACHE > 0 && $OSCOM_Cache->read('box-reviews' . (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid() ? '-' . $OSCOM_Product->getID() : '') . '-' . $OSCOM_Language->getCode(), BOX_REVIEWS_CACHE)) {
             $data = $OSCOM_Cache->getCache();
         } else {
             $data = array();
             $sql_query = 'select r.reviews_id, r.reviews_rating, p.products_id, pd.products_name, pd.products_keyword, i.image from :table_reviews r, :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd where r.products_id = p.products_id and p.products_status = 1 and r.languages_id = :language_id and p.products_id = pd.products_id and pd.language_id = :language_id and r.reviews_status = 1';
             if (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid()) {
                 $sql_query .= ' and p.products_id = :products_id';
             }
             $sql_query .= ' order by r.reviews_id desc limit :max_random_select_reviews';
             $Qreview = $OSCOM_PDO->prepare($sql_query);
             $Qreview->bindInt(':default_flag', 1);
             $Qreview->bindInt(':language_id', $OSCOM_Language->getID());
             $Qreview->bindInt(':language_id', $OSCOM_Language->getID());
             if (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid()) {
                 $Qreview->bindInt(':products_id', $OSCOM_Product->getID());
             }
             $Qreview->bindInt(':max_random_select_reviews', BOX_REVIEWS_RANDOM_SELECT);
             $Qreview->execute();
             $result = $Qreview->fetchAll();
             if (count($result) > 0) {
                 $result = $result[rand(0, count($result) - 1)];
                 $Qtext = $OSCOM_PDO->prepare('select substring(reviews_text, 1, 60) as reviews_text from :table_reviews where reviews_id = :reviews_id and languages_id = :languages_id');
                 $Qtext->bindInt(':reviews_id', $result['reviews_id']);
                 $Qtext->bindInt(':languages_id', $OSCOM_Language->getID());
                 $Qtext->execute();
                 $data = array_merge($result, $Qtext->fetch());
             }
             $OSCOM_Cache->write($data);
         }
         $this->_content = '';
         if (empty($data)) {
             if (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid()) {
                 $this->_content = '<div style="float: left; width: 55px;">' . HTML::button(array('href' => OSCOM::getLink(null, 'Products', 'Reviews&Write&' . $OSCOM_Product->getKeyword()), 'icon' => 'pencil', 'title' => OSCOM::getDef('button_write_review'))) . '</div>' . HTML::link(OSCOM::getLink(null, 'Products', 'Reviews&Write&' . $OSCOM_Product->getKeyword()), OSCOM::getDef('box_reviews_write')) . '<div style="clear: both;"></div>';
             }
         } else {
             if (!empty($data['image'])) {
                 $this->_content = '<div align="center">' . HTML::link(OSCOM::getLink(null, 'Products', 'Reviews&View=' . $data['reviews_id'] . '&' . $data['products_keyword']), $OSCOM_Image->show($data['image'], $data['products_name'])) . '</div>';
             }
             $this->_content .= HTML::link(OSCOM::getLink(null, 'Products', 'Reviews&View=' . $data['reviews_id'] . '&' . $data['products_keyword']), wordwrap(HTML::outputProtected($data['reviews_text']), 15, '&shy;') . ' ..') . '<br /><div align="center">' . HTML::image(OSCOM::getPublicSiteLink('images/stars_' . $data['reviews_rating'] . '.png'), sprintf(OSCOM::getDef('box_reviews_stars_rating'), $data['reviews_rating'])) . '</div>';
         }
     }
 }
예제 #13
0
 public static function execute($id)
 {
     if (Registry::exists('CategoryTree')) {
         $OSCOM_CategoryTree = Registry::get('CategoryTree');
     } else {
         $OSCOM_CategoryTree = new CategoryTree();
         Registry::set('CategoryTree', $OSCOM_CategoryTree);
     }
     $data = $OSCOM_CategoryTree->getData($id);
     if (!empty($data['image']) && file_exists(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $data['image'])) {
         unlink(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $data['image']);
     }
 }
예제 #14
0
 public function initialize()
 {
     $OSCOM_Service = Registry::get('Service');
     $OSCOM_Cache = Registry::get('Cache');
     $OSCOM_Product = Registry::exists('Product') ? Registry::get('Product') : null;
     $OSCOM_Language = Registry::get('Language');
     $OSCOM_Database = Registry::get('Database');
     $OSCOM_Image = Registry::get('Image');
     $this->_title_link = OSCOM::getLink(null, 'Products', 'Reviews');
     if ($OSCOM_Service->isStarted('Reviews')) {
         if (BOX_REVIEWS_CACHE > 0 && $OSCOM_Cache->read('box-reviews' . (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid() ? '-' . $OSCOM_Product->getID() : '') . '-' . $OSCOM_Language->getCode(), BOX_REVIEWS_CACHE)) {
             $data = $OSCOM_Cache->getCache();
         } else {
             $data = array();
             $Qreview = $OSCOM_Database->query('select r.reviews_id, r.reviews_rating, p.products_id, pd.products_name, pd.products_keyword, i.image from :table_reviews r, :table_products p left join :table_products_images i on (p.products_id = i.products_id and i.default_flag = :default_flag), :table_products_description pd where r.products_id = p.products_id and p.products_status = 1 and r.languages_id = :language_id and p.products_id = pd.products_id and pd.language_id = :language_id and r.reviews_status = 1');
             $Qreview->bindInt(':default_flag', 1);
             $Qreview->bindInt(':language_id', $OSCOM_Language->getID());
             $Qreview->bindInt(':language_id', $OSCOM_Language->getID());
             if (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid()) {
                 $Qreview->appendQuery('and p.products_id = :products_id');
                 $Qreview->bindInt(':products_id', $OSCOM_Product->getID());
             }
             $Qreview->appendQuery('order by r.reviews_id desc limit :max_random_select_reviews');
             $Qreview->bindInt(':max_random_select_reviews', BOX_REVIEWS_RANDOM_SELECT);
             $Qreview->executeRandomMulti();
             if ($Qreview->numberOfRows()) {
                 $Qtext = $OSCOM_Database->query('select substring(reviews_text, 1, 60) as reviews_text from :table_reviews where reviews_id = :reviews_id and languages_id = :languages_id');
                 $Qtext->bindInt(':reviews_id', $Qreview->valueInt('reviews_id'));
                 $Qtext->bindInt(':languages_id', $OSCOM_Language->getID());
                 $Qtext->execute();
                 $data = array_merge($Qreview->toArray(), $Qtext->toArray());
             }
             $OSCOM_Cache->write($data);
         }
         $this->_content = '';
         if (empty($data)) {
             if (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid()) {
                 $this->_content = '<div style="float: left; width: 55px;">' . osc_link_object(OSCOM::getLink(null, 'Products', 'Reviews&Write&' . $OSCOM_Product->getKeyword()), osc_image(DIR_WS_IMAGES . 'box_write_review.gif', OSCOM::getDef('button_write_review'))) . '</div>' . osc_link_object(OSCOM::getLink(null, 'Products', 'Reviews&Write&' . $OSCOM_Product->getKeyword()), OSCOM::getDef('box_reviews_write')) . '<div style="clear: both;"></div>';
             }
         } else {
             if (!empty($data['image'])) {
                 $this->_content = '<div align="center">' . osc_link_object(OSCOM::getLink(null, 'Products', 'Reviews&View=' . $data['reviews_id'] . '&' . $data['products_keyword']), $OSCOM_Image->show($data['image'], $data['products_name'])) . '</div>';
             }
             $this->_content .= osc_link_object(OSCOM::getLink(null, 'Products', 'Reviews&View=' . $data['reviews_id'] . '&' . $data['products_keyword']), wordwrap(osc_output_string_protected($data['reviews_text']), 15, '&shy;') . ' ..') . '<br /><div align="center">' . osc_image(DIR_WS_IMAGES . 'stars_' . $data['reviews_rating'] . '.png', sprintf(OSCOM::getDef('box_reviews_stars_rating'), $data['reviews_rating'])) . '</div>';
         }
     }
 }
예제 #15
0
 public static function execute($parent_id = 0)
 {
     if (Registry::exists('CategoryTree')) {
         $OSCOM_CategoryTree = Registry::get('CategoryTree');
     } else {
         $OSCOM_CategoryTree = new CategoryTree();
         Registry::set('CategoryTree', $OSCOM_CategoryTree);
     }
     $OSCOM_CategoryTree->reset();
     $OSCOM_CategoryTree->setMaximumLevel(1);
     $OSCOM_CategoryTree->setBreadcrumbUsage(false);
     $result = $OSCOM_CategoryTree->getArray($parent_id);
     foreach ($result as &$c) {
         $c['products'] = $OSCOM_CategoryTree->getData($c['id'], 'count');
     }
     return array('entries' => $result, 'total' => count($result));
 }
예제 #16
0
 function initialize()
 {
     $OSCOM_Category = Registry::get('Category');
     if (SERVICE_RECENTLY_VISITED_SHOW_PRODUCTS == '1') {
         if (Registry::exists('Product') && Registry::get('Product') instanceof Product) {
             $this->setProduct(Registry::get('Product')->getMasterID());
         }
     }
     if (SERVICE_RECENTLY_VISITED_SHOW_CATEGORIES == '1' && $OSCOM_Category->getID() > 0) {
         $this->setCategory($OSCOM_Category->getID());
     }
     if (SERVICE_RECENTLY_VISITED_SHOW_SEARCHES == '1') {
         if (Registry::exists('Search') && Registry::get('Search') instanceof Search && Registry::get('Search')->hasKeywords()) {
             $this->setSearchQuery(Registry::get('Search')->getKeywords());
         }
     }
 }
예제 #17
0
 public static function execute($id)
 {
     if (Registry::exists('CategoryTree')) {
         $OSCOM_CategoryTree = Registry::get('CategoryTree');
     } else {
         $OSCOM_CategoryTree = new CategoryTree();
         Registry::set('CategoryTree', $OSCOM_CategoryTree);
     }
     $data = array('id' => $id);
     foreach (array_merge(array($data['id']), $OSCOM_CategoryTree->getChildren($data['id'])) as $c) {
         Categories::deleteImage($c);
     }
     if (OSCOM::callDB('Admin\\Categories\\Delete', $data)) {
         Cache::clear('categories');
         Cache::clear('category_tree');
         Cache::clear('also_purchased');
         return true;
     }
     return false;
 }
예제 #18
0
 public static function execute($id, $key = null, $language_id = null)
 {
     $OSCOM_Language = Registry::get('Language');
     if (Registry::exists('CategoryTree')) {
         $OSCOM_CategoryTree = Registry::get('CategoryTree');
     } else {
         $OSCOM_CategoryTree = new CategoryTree();
         Registry::set('CategoryTree', $OSCOM_CategoryTree);
     }
     if (!isset($language_id)) {
         $language_id = $OSCOM_Language->getID();
     }
     $data = array('id' => $id, 'language_id' => $language_id);
     $result = OSCOM::callDB('Admin\\Categories\\Get', $data);
     $result['children_count'] = count($OSCOM_CategoryTree->getChildren($id));
     $result['product_count'] = $OSCOM_CategoryTree->getNumberOfProducts($id);
     if (isset($key)) {
         $result = $result[$key] ?: null;
     }
     return $result;
 }
예제 #19
0
 public static function execute($id = null, $data)
 {
     if (Registry::exists('CategoryTree')) {
         $OSCOM_CategoryTree = Registry::get('CategoryTree');
     } else {
         $OSCOM_CategoryTree = new CategoryTree();
         Registry::set('CategoryTree', $OSCOM_CategoryTree);
     }
     if (is_numeric($id)) {
         $data['id'] = $id;
     }
     // Prevent another big bang and check if category is not being moved to a child category
     if (isset($data['id']) && $OSCOM_CategoryTree->getParentID($data['id']) != $data['parent_id']) {
         if (in_array($data['id'], explode('_', $OSCOM_CategoryTree->buildBreadcrumb($data['parent_id'])))) {
             return false;
         }
     }
     if (isset($data['image'])) {
         $new_image = $data['image'];
         while (file_exists(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $new_image)) {
             $new_image = rand(10, 99) . $new_image;
         }
         if (rename(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'upload/' . $data['image'], OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $new_image)) {
             if (is_numeric($id)) {
                 $old_image = Categories::get($id, 'categories_image');
                 unlink(OSCOM::getConfig('dir_fs_public', 'OSCOM') . 'categories/' . $old_image);
             }
             $data['image'] = $new_image;
         } else {
             $data['image'] = null;
         }
     }
     if (OSCOM::callDB('Admin\\Categories\\Save', $data)) {
         Cache::clear('categories');
         Cache::clear('category_tree');
         Cache::clear('also_purchased');
         return true;
     }
     return false;
 }
예제 #20
0
 public function initialize()
 {
     $OSCOM_Product = Registry::exists('Product') ? Registry::get('Product') : null;
     $OSCOM_Customer = Registry::get('Customer');
     $OSCOM_PDO = Registry::get('PDO');
     $OSCOM_Language = Registry::get('Language');
     $this->_title_link = OSCOM::getLink(null, 'Account', 'Notifications', 'SSL');
     if (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid()) {
         if ($OSCOM_Customer->isLoggedOn()) {
             $Qcheck = $OSCOM_PDO->prepare('select global_product_notifications from :table_customers where customers_id = :customers_id');
             $Qcheck->bindInt(':customers_id', $OSCOM_Customer->getID());
             $Qcheck->execute();
             if ($Qcheck->valueInt('global_product_notifications') === 0) {
                 $get_params = array();
                 foreach ($_GET as $key => $value) {
                     if ($key != 'action' && $key != Registry::get('Session')->getName() && $key != 'x' && $key != 'y') {
                         $get_params[] = $key . '=' . $value;
                     }
                 }
                 $get_params = implode($get_params, '&');
                 if (!empty($get_params)) {
                     $get_params .= '&';
                 }
                 $Qcheck = $OSCOM_PDO->prepare('select products_id from :table_products_notifications where products_id = :products_id and customers_id = :customers_id limit 1');
                 $Qcheck->bindInt(':products_id', $OSCOM_Product->getID());
                 $Qcheck->bindInt(':customers_id', $OSCOM_Customer->getID());
                 $Qcheck->execute();
                 $result = $Qcheck->fetch();
                 if (!empty($result)) {
                     $this->_content = '<div style="float: left; width: 55px;">' . HTML::link(OSCOM::getLink(null, null, $get_params . 'action=notify_remove', 'AUTO'), HTML::image(DIR_WS_IMAGES . 'box_products_notifications_remove.gif', sprintf(OSCOM::getDef('box_product_notifications_remove'), $OSCOM_Product->getTitle()))) . '</div>' . HTML::link(OSCOM::getLink(null, null, $get_params . 'action=notify_remove', 'AUTO'), sprintf(OSCOM::getDef('box_product_notifications_remove'), $OSCOM_Product->getTitle()));
                 } else {
                     $this->_content = '<div style="float: left; width: 55px;">' . HTML::link(OSCOM::getLink(null, null, $get_params . 'action=notify_add', 'AUTO'), HTML::image(DIR_WS_IMAGES . 'box_products_notifications.gif', sprintf(OSCOM::getDef('box_product_notifications_add'), $OSCOM_Product->getTitle()))) . '</div>' . HTML::link(OSCOM::getLink(null, null, $get_params . 'action=notify_add', 'AUTO'), sprintf(OSCOM::getDef('box_product_notifications_add'), $OSCOM_Product->getTitle()));
                 }
                 $this->_content .= '<div style="clear: both;"></div>';
             }
         }
     }
 }
예제 #21
0
 public static function execute($id, $parent_id)
 {
     if (Registry::exists('CategoryTree')) {
         $OSCOM_CategoryTree = Registry::get('CategoryTree');
     } else {
         $OSCOM_CategoryTree = new CategoryTree();
         Registry::set('CategoryTree', $OSCOM_CategoryTree);
     }
     $data = array('id' => $id, 'parent_id' => $parent_id);
     // Prevent another big bang and check if category is not being moved to a child category
     if ($OSCOM_CategoryTree->getParentID($data['id']) != $data['parent_id']) {
         if (in_array($data['id'], explode('_', $OSCOM_CategoryTree->buildBreadcrumb($data['parent_id'])))) {
             return false;
         }
     }
     if (OSCOM::callDB('Admin\\Categories\\Move', $data)) {
         Cache::clear('categories');
         Cache::clear('category_tree');
         Cache::clear('also_purchased');
         return true;
     }
     return false;
 }
예제 #22
0
 public function initialize()
 {
     $OSCOM_Product = Registry::exists('Product') ? Registry::get('Product') : null;
     $OSCOM_Database = Registry::get('Database');
     $OSCOM_Language = Registry::get('Language');
     if (isset($OSCOM_Product) && $OSCOM_Product instanceof \osCommerce\OM\Site\Shop\Product && $OSCOM_Product->isValid()) {
         $Qmanufacturer = $OSCOM_Database->query('select m.manufacturers_id, m.manufacturers_name, m.manufacturers_image, mi.manufacturers_url from :table_manufacturers m left join :table_manufacturers_info mi on (m.manufacturers_id = mi.manufacturers_id and mi.languages_id = :languages_id), :table_products p  where p.products_id = :products_id and p.manufacturers_id = m.manufacturers_id');
         $Qmanufacturer->bindInt(':languages_id', $OSCOM_Language->getID());
         $Qmanufacturer->bindInt(':products_id', $OSCOM_Product->getID());
         $Qmanufacturer->execute();
         if ($Qmanufacturer->numberOfRows()) {
             $this->_content = '';
             if (!osc_empty($Qmanufacturer->value('manufacturers_image'))) {
                 $this->_content .= '<div style="text-align: center;">' . osc_link_object(OSCOM::getLink(null, 'Index', 'Manufacturers=' . $Qmanufacturer->valueInt('manufacturers_id')), osc_image(DIR_WS_IMAGES . 'manufacturers/' . $Qmanufacturer->value('manufacturers_image'), $Qmanufacturer->value('manufacturers_name'))) . '</div>';
             }
             $this->_content .= '<ol style="list-style: none; margin: 0; padding: 0;">';
             if (!osc_empty($Qmanufacturer->value('manufacturers_url'))) {
                 $this->_content .= '<li>' . osc_link_object(OSCOM::getLink(null, 'Redirct', 'Manufacturer=' . $Qmanufacturer->valueInt('manufacturers_id')), sprintf(OSCOM::getDef('box_manufacturer_info_website'), $Qmanufacturer->value('manufacturers_name')), 'target="_blank"') . '</li>';
             }
             $this->_content .= '<li>' . osc_link_object(OSCOM::getLink(null, 'Index', 'Manufacturers=' . $Qmanufacturer->valueInt('manufacturers_id')), OSCOM::getDef('box_manufacturer_info_products')) . '</li>';
             $this->_content .= '</ol>';
         }
     }
 }
예제 #23
0
 /**
  * Return an internal URL address.
  *
  * @param string $site The Site to link to. Default: The currently used Site.
  * @param string $application The Site Application to link to. Default: The currently used Site Application.
  * @param string $parameters Parameters to add to the link. Example: key1=value1&key2=value2
  * @param string $connection The type of connection to use for the link. Values: NONSSL, SSL, AUTO. Default: NONSSL.
  * @param bool $add_session_id Add the session ID to the link. Default: True.
  * @param bool $search_engine_safe Use search engine safe URLs. Default: True.
  * @return string The URL address.
  */
 public static function getLink($site = null, $application = null, $parameters = null, $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true)
 {
     if (empty($site)) {
         $site = static::getSite();
     }
     if (empty($application) && $site == static::getSite()) {
         $application = static::getSiteApplication();
     }
     if (!in_array($connection, array('NONSSL', 'SSL', 'AUTO'))) {
         $connection = 'NONSSL';
     }
     if (!is_bool($add_session_id)) {
         $add_session_id = true;
     }
     if (!is_bool($search_engine_safe)) {
         $search_engine_safe = true;
     }
     // Wrapper for RPC links; RPC cannot perform cross domain requests
     $real_site = $site == 'RPC' ? $application : $site;
     if ($connection == 'AUTO') {
         if (static::getRequestType() == 'SSL' && static::getConfig('enable_ssl', $real_site) == 'true') {
             $link = static::getConfig('https_server', $real_site) . static::getConfig('dir_ws_https_server', $real_site);
         } else {
             $link = static::getConfig('http_server', $real_site) . static::getConfig('dir_ws_http_server', $real_site);
         }
     } elseif ($connection == 'SSL' && static::getConfig('enable_ssl', $real_site) == 'true') {
         $link = static::getConfig('https_server', $real_site) . static::getConfig('dir_ws_https_server', $real_site);
     } else {
         $link = static::getConfig('http_server', $real_site) . static::getConfig('dir_ws_http_server', $real_site);
     }
     $link .= static::getConfig('bootstrap_file', 'OSCOM') . '?';
     if ($site != static::getDefaultSite()) {
         $link .= $site . '&';
     }
     if (!empty($application) && $application != static::getDefaultSiteApplication()) {
         $link .= $application . '&';
     }
     if (!empty($parameters)) {
         $link .= HTML::output($parameters) . '&';
     }
     if ($add_session_id === true && Registry::exists('Session') && Registry::get('Session')->hasStarted() && SERVICE_SESSION_FORCE_COOKIE_USAGE == '-1') {
         if (strlen(SID) > 0) {
             $_sid = SID;
         } elseif (static::getRequestType() == 'NONSSL' && $connection == 'SSL' && static::getConfig('enable_ssl', $site) == 'true' || static::getRequestType() == 'SSL' && $connection != 'SSL') {
             if (static::getConfig('http_cookie_domain', $site) != static::getConfig('https_cookie_domain', $site)) {
                 $_sid = Registry::get('Session')->getName() . '=' . Registry::get('Session')->getID();
             }
         }
     }
     if (isset($_sid)) {
         $link .= HTML::output($_sid);
     }
     while (substr($link, -1) == '&' || substr($link, -1) == '?') {
         $link = substr($link, 0, -1);
     }
     if ($search_engine_safe === true && Registry::exists('osC_Services') && Registry::get('osC_Services')->isStarted('sefu')) {
         $link = str_replace(array('?', '&', '='), array('/', '/', ','), $link);
     }
     return $link;
 }
예제 #24
0
    public function __construct() {
      $OSCOM_Language = Registry::get('Language');

      $OSCOM_Language->loadIniFile('modules/Dashboard/Products.php');

      $this->_title = OSCOM::getDef('admin_indexmodules_products_title');
      $this->_title_link = OSCOM::getLink(null, 'Products');

      if ( Access::hasAccess(OSCOM::getSite(), 'Products') ) {
        if ( !Registry::exists('Currencies') ) {
          Registry::set('Currencies', new Currencies());
        }

        $OSCOM_Currencies = Registry::get('Currencies');

        $data = array('language_id' => $OSCOM_Language->getID(),
                      'batch_pageset' => 1,
                      'batch_max_results' => 6);

        $result = OSCOM::callDB('Admin\Products\GetAll', $data);

        foreach ( $result['entries'] as &$p ) {
          if ( $p['has_children'] === 1 ) {
            $p['products_price_formatted'] = $OSCOM_Currencies->format($p['products_price_min']);

            if ( $p['products_price_min'] != $p['products_price_max'] ) {
              $p['products_price_formatted'] .= ' - ' . $OSCOM_Currencies->format($p['products_price_max']);
            }

            $p['products_quantity'] = '(' . $p['products_quantity_variants'] . ')';
          } else {
            $p['products_price_formatted'] = $OSCOM_Currencies->format($p['products_price']);
          }
        }

        $this->_data = '<table border="0" width="100%" cellspacing="0" cellpadding="2" class="dataTable">' .
                       '  <thead>' .
                       '    <tr>' .
                       '      <th>' . OSCOM::getDef('admin_indexmodules_products_table_heading_products') . '</th>' .
                       '      <th>' . OSCOM::getDef('admin_indexmodules_products_table_heading_price') . '</th>' .
                       '      <th>' . OSCOM::getDef('admin_indexmodules_products_table_heading_date') . '</th>' .
                       '      <th>' . OSCOM::getDef('admin_indexmodules_products_table_heading_status') . '</th>' .
                       '    </tr>' .
                       '  </thead>' .
                       '  <tbody>';

/*
        $Qproducts = Registry::get('PDO')->query('select products_id, greatest(products_date_added, products_last_modified) as date_last_modified from :table_products where parent_id is null order by date_last_modified desc limit 6');
        $Qproducts->execute();

        $counter = 0;

        while ( $Qproducts->fetch() ) {
          $data = osC_Products_Admin::get($Qproducts->valueInt('products_id'));

          $products_icon = osc_icon('products.png');
          $products_price = $data['products_price'];

          if ( !empty($data['variants']) ) {
            $products_icon = osc_icon('attach.png');
            $products_price = null;

            foreach ( $data['variants'] as $variant ) {
              if ( ($products_price === null) || ($variant['data']['price'] < $products_price) ) {
                $products_price = $variant['data']['price'];
              }
            }

            if ( $products_price === null ) {
              $products_price = 0;
            }
          }
*/

        $counter = 0;

        foreach ( $result['entries'] as $p ) {
          if ( $p['has_children'] === 1 ) {
            $products_icon = HTML::icon('products.png');
          } else {
            $products_icon = HTML::icon('attach.png');
          }

          $this->_data .= '    <tr onmouseover="$(this).addClass(\'mouseOver\');" onmouseout="$(this).removeClass(\'mouseOver\');"' . ($counter % 2 ? ' class="alt"' : '') . '>' .
                          '      <td>' . HTML::link(OSCOM::getLink(null, 'Products', 'Save&id=' . (int)$p['products_id']), $products_icon . '&nbsp;' . HTML::outputProtected($p['products_name'])) . '</td>' .
                          '      <td>' . $p['products_price_formatted'] . '</td>' .
                          '      <td>' . $p['products_last_modified'] . '</td>' .
                          '      <td align="center">' . HTML::icon(((int)$p['products_status'] === 1) ? 'checkbox_ticked.gif' : 'checkbox_crossed.gif', null, null) . '</td>' .
                          '    </tr>';

          $counter++;
        }

        $this->_data .= '  </tbody>' .
                        '</table>';
      }
    }