Exemplo n.º 1
0
 function save()
 {
     $apply = JRequest::getVar("apply");
     $vendor = JSFactory::getTable('vendor', 'jshop');
     $dispatcher = JDispatcher::getInstance();
     $id = JRequest::getInt("id");
     $vendor->load($id);
     if (!isset($_POST['publish'])) {
         $_POST['publish'] = 0;
     }
     $post = JRequest::get("post");
     $dispatcher->trigger('onBeforeSaveVendor', array(&$post));
     $vendor->bind($post);
     JSFactory::loadLanguageFile();
     if (!$vendor->check()) {
         JError::raiseWarning("", $vendor->getError());
         $this->setRedirect("index.php?option=com_jshopping&controller=vendors&task=edit&id=" . $vendor->id);
         return 0;
     }
     if (!$vendor->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=vendors&task=edit&id=" . $vendor->id);
         return 0;
     }
     $dispatcher->trigger('onAfterSaveVendor', array(&$vendor));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=vendors&task=edit&id=" . $vendor->id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=vendors");
     }
 }
Exemplo n.º 2
0
 public static function getList(&$params)
 {
     $db = JFactory::getDBO();
     $jshopConfig = JSFactory::getConfig();
     $jshopConfig->cur_lang = $jshopConfig->frontend_lang;
     JSFactory::loadCssFiles();
     JSFactory::loadLanguageFile();
     $lang = JSFactory::getLang();
     $jshopConfig = JSFactory::getConfig();
     $field_sort = $params->get('sort', 'id');
     $ordering = $params->get('ordering', 'asc');
     $_limit = (int) $params->get('count_cat', 10);
     $catids = $params->get('catids', 0);
     $_catids = array();
     $list = array();
     settype($catids, 'array');
     if (!empty($catids)) {
         $catid = implode(", ", $catids);
         $list = self::getCategory($catid, $field_sort, $ordering, $_limit, 1);
     }
     if (!empty($list)) {
         foreach ($list as $i => $item) {
             $item->_short_desc = self::_cleanText($item->short_description);
             $item->_description = self::_cleanText($item->description);
             $item->_description = $item->_description != '' ? $item->_description : $item->_short_desc;
             self::getJSCImages($item, $params, 'imgcfgcat');
         }
     }
     return $list;
 }
 public function store()
 {
     $jshopConfig = JSFactory::getConfig();
     $dispatcher = JDispatcher::getInstance();
     if ($this->getAppAdmin()) {
         $dispatcher->trigger('onBeforeChangeOrderStatusAdmin', array(&$this->order_id, &$this->status, &$this->status_id, &$this->notify, &$this->comments, &$this->include_comment, &$this->view_order));
     } else {
         $dispatcher->trigger('onBeforeChangeOrderStatus', array(&$this->order_id, &$this->status, &$this->sendmessage, &$this->comments));
     }
     $prev_order_status = $this->orderStatusStore();
     if ($this->getAppAdmin()) {
         JSFactory::loadLanguageFile($this->order->getLang());
         JSFactory::getLang($this->order->getLang());
     }
     $this->vendorinfo = $this->order->getVendorInfo();
     $this->tbl_order_status->load($this->status);
     $this->order->updateProductsInStock();
     $this->order->saveOrderHistory($this->notify, $this->comments);
     $this->order_details_url = $this->getOrderDetailsUrl();
     if (!$this->include_comment) {
         $this->comments = '';
     }
     $message = $this->getMessage($this->order, $this->tbl_order_status->getName(), $this->vendorinfo, $this->order_details_url, $this->comments);
     $this->listVendors = $this->getListVendors($this->order);
     $this->vendors_send_message = $this->getVendorSendMessage($this->order);
     $this->vendor_send_order = $this->getVendorSendOrder($this->order);
     $this->admin_send_order = $this->getAdminSendOrder($this->order, $this->listVendors);
     $send_msg_client = $this->getSendMsg('client');
     $send_msg_admin = $this->getSendMsg('admin');
     $send_msg_vendor = $this->getSendMsg('vendor');
     if ($send_msg_client) {
         $this->sendMail('client', $this->order->email, $message, $this->order);
     }
     if ($send_msg_admin) {
         $this->sendMail('admin', $jshopConfig->getAdminContactEmails(), $message, $this->order);
     }
     if ($send_msg_vendor) {
         foreach ($this->listVendors as $k => $datavendor) {
             $this->sendMail('vendor', $datavendor->email, $message, $this->order, $datavendor);
         }
     }
     if ($this->getAppAdmin()) {
         $dispatcher->trigger('onAfterChangeOrderStatusAdmin', array(&$this->order_id, &$this->status, &$this->status_id, &$this->notify, &$this->comments, &$this->include_comment, &$this->view_order, &$prev_order_status));
     } else {
         $dispatcher->trigger('onAfterChangeOrderStatus', array(&$this->order_id, &$this->status, &$this->sendmessage, &$prev_order_status));
     }
     return 1;
 }
Exemplo n.º 4
0
 function send()
 {
     $order_id = JRequest::getInt("order_id");
     $order = JTable::getInstance('order', 'jshop');
     $order->load($order_id);
     JSFactory::loadLanguageFile($order->getLang());
     JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jshopping/models');
     $checkout = JModelLegacy::getInstance('checkout', 'jshop');
     $checkout->sendOrderEmail($order_id, 1);
     JSFactory::loadAdminLanguageFile();
     $this->setRedirect("index.php?option=com_jshopping&controller=orders&task=show&order_id=" . $order_id, _JSHOP_MAIL_HAS_BEEN_SENT);
 }
Exemplo n.º 5
0
function initLoadJoomshoppingLanguageFile()
{
    if (!JRequest::getInt('no_lang')) {
        JSFactory::loadLanguageFile();
    }
}
Exemplo n.º 6
0
 public function __construct($params)
 {
     parent::__construct($params);
     JSFactory::loadLanguageFile();
 }
Exemplo n.º 7
0
function jshoppingParseRoute($segments)
{
    $vars = array();
    JSFactory::loadLanguageFile();
    $reservedFirstAlias = JSFactory::getReservedFirstAlias();
    $menu = JFactory::getApplication()->getMenu();
    $menuItem = $menu->getActive();
    JPluginHelper::importPlugin('jshoppingrouter');
    $dispatcher = JDispatcher::getInstance();
    $dispatcher->trigger('onBeforeParseRoute', array(&$vars, &$segments));
    $segments[0] = getSeoSegment($segments[0]);
    if (isset($segments[1])) {
        $segments[1] = getSeoSegment($segments[1]);
    } else {
        $segments[1] = "";
    }
    if (isset($menuItem->query['controller'])) {
        if ($menuItem->query['controller'] == "cart") {
            $vars['controller'] = "cart";
            $vars['task'] = $segments[0];
            $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
            return $vars;
        }
        if ($menuItem->query['controller'] == "wishlist") {
            $vars['controller'] = "wishlist";
            $vars['task'] = $segments[0];
            $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
            return $vars;
        }
        if ($menuItem->query['controller'] == "search") {
            $vars['controller'] = "search";
            $vars['task'] = $segments[0];
            $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
            return $vars;
        }
        if ($menuItem->query['controller'] == "user" && $menuItem->query['task'] == "") {
            $vars['controller'] = "user";
            $vars['task'] = $segments[0];
            $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
            return $vars;
        }
        if ($menuItem->query['controller'] == "checkout") {
            $vars['controller'] = "checkout";
            $vars['task'] = $segments[0];
            $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
            return $vars;
        }
        if ($menuItem->query['controller'] == "vendor" && $menuItem->query['task'] == "") {
            $vars['controller'] = "vendor";
            $vars['task'] = $segments[0];
            $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
            return $vars;
        }
        if ($menuItem->query['controller'] == "content" && $menuItem->query['task'] == "view") {
            $vars['controller'] = "content";
            $vars['page'] = $segments[0];
            $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
            return $vars;
        }
        if ($menuItem->query['controller'] == "category" && $menuItem->query['category_id'] && $segments[1] == "") {
            $prodalias = JSFactory::getAliasProduct();
            $product_id = array_search($segments[0], $prodalias, true);
            if (!$product_id) {
                JError::raiseError(404, _JSHOP_PAGE_NOT_FOUND);
            }
            $vars['controller'] = "product";
            $vars['task'] = "view";
            $vars['category_id'] = $menuItem->query['category_id'];
            $vars['product_id'] = $product_id;
            $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
            return $vars;
        }
    }
    if ($segments[0] && !in_array($segments[0], $reservedFirstAlias)) {
        $catalias = JSFactory::getAliasCategory();
        $category_id = array_search($segments[0], $catalias, true);
        if ($category_id && $segments[1] == "") {
            $vars['controller'] = "category";
            $vars['task'] = "view";
            $vars['category_id'] = $category_id;
            $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
            return $vars;
        }
        if ($category_id && $segments[1] != "") {
            $prodalias = JSFactory::getAliasProduct();
            $product_id = array_search($segments[1], $prodalias, true);
            if (!$product_id) {
                JError::raiseError(404, _JSHOP_PAGE_NOT_FOUND);
            }
            if ($category_id && $product_id) {
                $vars['controller'] = "product";
                $vars['task'] = "view";
                $vars['category_id'] = $category_id;
                $vars['product_id'] = $product_id;
                $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
                return $vars;
            }
        }
        if (!$category_id && $segments[1] == "") {
            $manalias = JSFactory::getAliasManufacturer();
            $manufacturer_id = array_search($segments[0], $manalias, true);
            if ($manufacturer_id) {
                $vars['controller'] = "manufacturer";
                $vars['task'] = "view";
                $vars['manufacturer_id'] = $manufacturer_id;
                $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
                return $vars;
            }
        }
        JError::raiseError(404, _JSHOP_PAGE_NOT_FOUND);
    } else {
        $vars['controller'] = $segments[0];
        $vars['task'] = $segments[1];
        if ($vars['controller'] == "category" && $vars['task'] == "view") {
            $vars['category_id'] = $segments[2];
        }
        if ($vars['controller'] == "product" && $vars['task'] == "view") {
            $vars['category_id'] = $segments[2];
            $vars['product_id'] = $segments[3];
        }
        if ($vars['controller'] == "product" && $vars['task'] == "ajax_attrib_select_and_price") {
            $vars['product_id'] = $segments[2];
        }
        if ($vars['controller'] == "manufacturer" && isset($segments[2])) {
            $vars['manufacturer_id'] = $segments[2];
        }
        if ($vars['controller'] == "content") {
            $vars['page'] = $segments[2];
        }
    }
    $dispatcher->trigger('onAfterParseRoute', array(&$vars, &$segments));
    return $vars;
}
Exemplo n.º 8
0
 function save()
 {
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     $apply = JRequest::getVar("apply");
     JSFactory::loadLanguageFile();
     $dispatcher = JDispatcher::getInstance();
     $user_shop = JSFactory::getTable('userShop', 'jshop');
     $user_id = JRequest::getInt("user_id");
     $post = JRequest::get("post");
     if ($post['f_name'] == "") {
         $post['f_name'] = $post['email'];
     }
     if (!$user_id) {
         $params = JComponentHelper::getParams('com_users');
         $user_shop->bind($post);
         $user_shop->password = $post['password'];
         $user_shop->password2 = $post['password2'];
         if (!$user_shop->check("editaccountadmin.edituser")) {
             JError::raiseWarning('', $user_shop->getError());
             $this->setRedirect("index.php?option=com_jshopping&controller=users&task=edit");
             return 0;
         }
         $user = new JUser();
         $data = array();
         $data['groups'][] = $params->get('new_usertype', 2);
         $data['email'] = $post['email'];
         $data['password'] = $post['password'];
         $data['password2'] = $post['password2'];
         $data['name'] = $post['f_name'] . ' ' . $post['l_name'];
         $data['username'] = $post["u_name"];
         $user->bind($data);
         if (!$user->save()) {
             JError::raiseWarning('', $user->getError());
             $this->setRedirect("index.php?option=com_jshopping&controller=users&task=edit");
             return 0;
         }
         $user_id = $user->id;
         unset($user);
         $user_shop->user_id = $user_id;
         $user_shop->number = $user_shop->getNewUserNumber();
         unset($user_shop->password);
         unset($user_shop->password2);
         if (!$db->insertObject($user_shop->getTableName(), $user_shop, $user_shop->getKeyName())) {
             JError::raiseWarning('', "Error insert in table " . $user_shop->getTableName());
             $this->setRedirect("index.php?option=com_jshopping&controller=users");
             return 0;
         }
         $post['user_id'] = $user_id;
         if (!$post['number']) {
             $post['number'] = $user_shop->number;
         }
     }
     $user_shop->load($user_id);
     $dispatcher->trigger('onBeforeSaveUser', array(&$post));
     if ($post['birthday']) {
         $post['birthday'] = getJsDateDB($post['birthday'], $jshopConfig->field_birthday_format);
     }
     if ($post['d_birthday']) {
         $post['d_birthday'] = getJsDateDB($post['d_birthday'], $jshopConfig->field_birthday_format);
     }
     $user_shop->bind($post);
     $user_shop->password = JRequest::getVar('password');
     $user_shop->password2 = JRequest::getVar('password2');
     if (!$user_shop->check("editaccountadmin.edituser")) {
         JError::raiseWarning("", $user_shop->getError());
         $this->setRedirect("index.php?option=com_jshopping&controller=users&task=edit&user_id=" . $user_shop->user_id);
         return 0;
     }
     unset($user_shop->password);
     unset($user_shop->password2);
     if (!$user_shop->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=users&task=edit&user_id=" . $user_shop->user_id);
         return 0;
     }
     $user = new JUser($user_id);
     $data['email'] = JRequest::getVar("email");
     $data['password'] = JRequest::getVar("password");
     $data['password2'] = JRequest::getVar("password2");
     $data['name'] = JRequest::getVar("f_name");
     $data['username'] = JRequest::getVar("u_name");
     $data['block'] = JRequest::getVar("block");
     $user->bind($data);
     $user->save(true);
     $dispatcher->trigger('onAfterSaveUser', array(&$user, &$user_shop));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=users&task=edit&user_id=" . $user_shop->user_id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=users");
     }
 }
Exemplo n.º 9
0
 function step7()
 {
     $checkout = JSFactory::getModel('checkout', 'jshop');
     $wmiframe = JRequest::getInt("wmiframe");
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     $session = JFactory::getSession();
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onLoadStep7', array());
     $pm_method = JSFactory::getTable('paymentMethod', 'jshop');
     $str = "url: " . $_SERVER['REQUEST_URI'] . "\n";
     foreach ($_POST as $k => $v) {
         $str .= $k . "=" . $v . "\n";
     }
     saveToLog("paymentdata.log", $str);
     $act = JRequest::getVar("act");
     $payment_method = JRequest::getVar("js_paymentclass");
     $pm_method->loadFromClass($payment_method);
     $paymentsysdata = $pm_method->getPaymentSystemData();
     $payment_system = $paymentsysdata->paymentSystem;
     if ($paymentsysdata->paymentSystemVerySimple) {
         if (JRequest::getInt('no_lang')) {
             JSFactory::loadLanguageFile();
         }
         saveToLog("payment.log", "#001 - Error payment method file. PM " . $payment_method);
         JError::raiseWarning(500, _JSHOP_ERROR_PAYMENT);
         return 0;
     }
     if ($paymentsysdata->paymentSystemError) {
         if (JRequest::getInt('no_lang')) {
             JSFactory::loadLanguageFile();
         }
         saveToLog("payment.log", "#002 - Error payment. CLASS " . $payment_method);
         JError::raiseWarning(500, _JSHOP_ERROR_PAYMENT);
         return 0;
     }
     $pmconfigs = $pm_method->getConfigs();
     $urlParamsPS = $payment_system->getUrlParams($pmconfigs);
     $order_id = $urlParamsPS['order_id'];
     $hash = $urlParamsPS['hash'];
     $checkHash = $urlParamsPS['checkHash'];
     $checkReturnParams = $urlParamsPS['checkReturnParams'];
     $session->set('jshop_send_end_form', 0);
     if ($act == "cancel") {
         $this->cancelPayOrder($order_id);
         return 0;
     }
     if ($act == "return" && !$checkReturnParams) {
         $checkout->setMaxStep(10);
         if (!$wmiframe) {
             $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl));
         } else {
             $this->iframeRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl));
         }
         return 1;
     }
     $order = JSFactory::getTable('order', 'jshop');
     $order->load($order_id);
     if (JRequest::getInt('no_lang')) {
         JSFactory::loadLanguageFile($order->getLang());
         $lang = JSFactory::getLang($order->getLang());
     }
     if ($checkHash && $order->order_hash != $hash) {
         saveToLog("payment.log", "#003 - Error order hash. Order id " . $order_id);
         JError::raiseWarning("", _JSHOP_ERROR_ORDER_HASH);
         return 0;
     }
     if (!$order->payment_method_id) {
         saveToLog("payment.log", "#004 - Error payment method id. Order id " . $order_id);
         JError::raiseWarning("", _JSHOP_ERROR_PAYMENT);
         return 0;
     }
     if ($order->payment_method_id != $pm_method->payment_id) {
         saveToLog("payment.log", "#005 - Error payment method set url. Order id " . $order_id);
         JError::raiseWarning("", _JSHOP_ERROR_PAYMENT);
         return 0;
     }
     $res = $payment_system->checkTransaction($pmconfigs, $order, $act);
     $rescode = $res[0];
     $restext = $res[1];
     $transaction = $res[2];
     $transactiondata = $res[3];
     $status = $payment_system->getStatusFromResCode($rescode, $pmconfigs);
     $order->transaction = $transaction;
     $order->store();
     $order->saveTransactionData($rescode, $status, $transactiondata);
     if ($restext != '') {
         saveToLog("payment.log", $restext);
     }
     if ($status && !$order->order_created) {
         $order->order_created = 1;
         $order->order_status = $status;
         $dispatcher->trigger('onStep7OrderCreated', array(&$order, &$res, &$checkout, &$pmconfigs));
         $order->store();
         if ($jshopConfig->send_order_email) {
             $checkout->sendOrderEmail($order->order_id);
         }
         if ($jshopConfig->order_stock_removed_only_paid_status) {
             $product_stock_removed = in_array($status, $jshopConfig->payment_status_enable_download_sale_file);
         } else {
             $product_stock_removed = 1;
         }
         if ($product_stock_removed) {
             $order->changeProductQTYinStock("-");
         }
         $checkout->changeStatusOrder($order_id, $status, 0);
     }
     if ($status && $order->order_status != $status) {
         $checkout->changeStatusOrder($order_id, $status, 1);
     }
     $dispatcher->trigger('onStep7BefereNotify', array(&$order, &$checkout, &$pmconfigs));
     if ($act == "notify") {
         $payment_system->nofityFinish($pmconfigs, $order, $rescode);
         die;
     }
     $payment_system->finish($pmconfigs, $order, $rescode, $act);
     if (in_array($rescode, array(0, 3, 4))) {
         JError::raiseWarning(500, $restext);
         if (!$wmiframe) {
             $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step5', 0, 1, $jshopConfig->use_ssl));
         } else {
             $this->iframeRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step5', 0, 1, $jshopConfig->use_ssl));
         }
         return 0;
     } else {
         $checkout->setMaxStep(10);
         if (!$wmiframe) {
             $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl));
         } else {
             $this->iframeRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl));
         }
         return 1;
     }
 }
Exemplo n.º 10
0
 function send()
 {
     $order_id = JRequest::getInt("order_id");
     $order = JSFactory::getTable('order', 'jshop');
     $order->load($order_id);
     JSFactory::loadLanguageFile($order->getLang());
     $checkout = JSFactory::getModel('checkout', 'jshop');
     $checkout->sendOrderEmail($order_id, 1);
     JSFactory::loadAdminLanguageFile();
     $this->setRedirect("index.php?option=com_jshopping&controller=orders&task=show&order_id=" . $order_id, _JSHOP_MAIL_HAS_BEEN_SENT);
 }
Exemplo n.º 11
0
 function save()
 {
     $apply = JRequest::getVar("apply");
     JSFactory::loadLanguageFile();
     $dispatcher = JDispatcher::getInstance();
     $user_id = JRequest::getInt("user_id");
     $post = JRequest::get("post");
     $dispatcher->trigger('onBeforeSaveUser', array(&$post));
     if ($user_id) {
         $model = JSFactory::getModel('useredit', 'jshop');
         $model->setUserId($user_id);
     } else {
         $model = JSFactory::getModel('userregister', 'jshop');
     }
     $model->setAdminRegistration(1);
     $model->setData($post);
     if (!$model->check('editaccountadmin.edituser')) {
         JError::raiseWarning('', $model->getError());
         $this->setRedirect("index.php?option=com_jshopping&controller=users&task=edit&user_id=" . $user_id);
         return 0;
     }
     if (!$model->save()) {
         JError::raiseWarning('', $model->getError());
         $this->setRedirect("index.php?option=com_jshopping&controller=users&task=edit&user_id=" . $user_id);
         return 0;
     }
     $user_shop = $model->getUser();
     $user = $model->getUserJoomla();
     $dispatcher->trigger('onAfterSaveUser', array(&$user, &$user_shop));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=users&task=edit&user_id=" . $user_shop->user_id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=users");
     }
 }
Exemplo n.º 12
0
 function save()
 {
     $jshopConfig = JSFactory::getConfig();
     $apply = JRequest::getVar("apply");
     JSFactory::loadLanguageFile();
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $user_shop = JTable::getInstance('userShop', 'jshop');
     $user_id = JRequest::getInt("user_id");
     $user_shop->load($user_id);
     $post = JRequest::get("post");
     $dispatcher->trigger('onBeforeSaveUser', array(&$post));
     if ($post['birthday']) {
         $post['birthday'] = getJsDateDB($post['birthday'], $jshopConfig->field_birthday_format);
     }
     if ($post['d_birthday']) {
         $post['d_birthday'] = getJsDateDB($post['d_birthday'], $jshopConfig->field_birthday_format);
     }
     $user_shop->bind($post);
     $user_shop->password = JRequest::getVar('password');
     $user_shop->password2 = JRequest::getVar('password2');
     if (!$user_shop->check("editaccountadmin.edituser")) {
         JError::raiseWarning("", $user_shop->getError());
         $this->setRedirect("index.php?option=com_jshopping&controller=users&task=edit&user_id=" . $user_shop->user_id);
         return 0;
     }
     unset($user_shop->password);
     unset($user_shop->password2);
     if (!$user_shop->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=users&task=edit&user_id=" . $user_shop->user_id);
         return 0;
     }
     $user = new JUser($user_id);
     $data['email'] = JRequest::getVar("email");
     $data['password'] = JRequest::getVar("password");
     $data['password2'] = JRequest::getVar("password2");
     $data['name'] = JRequest::getVar("f_name");
     $data['username'] = JRequest::getVar("u_name");
     $data['block'] = JRequest::getVar("block");
     $user->bind($data);
     $user->save(true);
     $dispatcher->trigger('onAfterSaveUser', array(&$user, &$user_shop));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=users&task=edit&user_id=" . $user_shop->user_id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=users");
     }
 }
Exemplo n.º 13
0
 public function buy()
 {
     $jshopConfig = JSFactory::getConfig();
     $dispatcher = JDispatcher::getInstance();
     $order_id = $this->getOrderId();
     $checkHash = $this->getCheckHash();
     $hash = $this->getHash();
     $pmconfigs = $this->getPmConfigs();
     $act = $this->getAct();
     $payment_system = $this->getPaymentSystem();
     $pm_method = $this->getPmMethod();
     $order = JSFactory::getTable('order', 'jshop');
     $order->load($order_id);
     if ($this->getNoLang()) {
         JSFactory::loadLanguageFile($order->getLang());
         $lang = JSFactory::getLang($order->getLang());
     }
     if ($checkHash && $order->order_hash != $hash) {
         saveToLog("payment.log", "#003 - Error order hash. Order id " . $order_id);
         $this->setError(_JSHOP_ERROR_ORDER_HASH);
         return 0;
     }
     if (!$order->payment_method_id) {
         saveToLog("payment.log", "#004 - Error payment method id. Order id " . $order_id);
         $this->setError(_JSHOP_ERROR_PAYMENT);
         return 0;
     }
     if ($order->payment_method_id != $pm_method->payment_id) {
         saveToLog("payment.log", "#005 - Error payment method set url. Order id " . $order_id);
         $this->setError(_JSHOP_ERROR_PAYMENT);
         return 0;
     }
     $res = $payment_system->checkTransaction($pmconfigs, $order, $act);
     $rescode = $res[0];
     $restext = $res[1];
     $transaction = $res[2];
     $transactiondata = $res[3];
     $status = $payment_system->getStatusFromResCode($rescode, $pmconfigs);
     $order->transaction = $transaction;
     $order->store();
     $order->saveTransactionData($rescode, $status, $transactiondata);
     if ($restext != '') {
         saveToLog("payment.log", $restext);
     }
     if ($status && !$order->order_created) {
         $order->order_created = 1;
         $order->order_status = $status;
         $dispatcher->trigger('onStep7OrderCreated', array(&$order, &$res, &$this, &$pmconfigs));
         $order->store();
         if ($jshopConfig->send_order_email) {
             $this->sendOrderEmail($order->order_id);
         }
         $this->changeStatusOrder($order_id, $status, 0);
     }
     if ($status && $order->order_status != $status) {
         $this->changeStatusOrder($order_id, $status, 1);
     }
     $this->setCheckTransactionResCode($rescode);
     $this->setCheckTransactionResText($restext);
     $dispatcher->trigger('onStep7BefereNotify', array(&$order, &$this, &$pmconfigs));
     if ($act == "notify") {
         $payment_system->nofityFinish($pmconfigs, $order, $rescode);
         return 2;
     }
     $payment_system->finish($pmconfigs, $order, $rescode, $act);
     return 1;
 }
if (!file_exists(JPATH_SITE . '/components/com_jshopping/jshopping.php')) {
    JError::raiseError(500, "Please install component \"joomshopping\"");
}
$layout = $params->get('layout', 'default');
$display_fileters = 0;
if (JRequest::getVar("controller") == "category" && JRequest::getInt("category_id")) {
    $display_fileters = 1;
}
if (JRequest::getVar("controller") == "manufacturer" && JRequest::getInt("manufacturer_id")) {
    $display_fileters = 1;
}
//if (!$display_fileters) return "";
require_once JPATH_SITE . '/components/com_jshopping/lib/factory.php';
require_once JPATH_SITE . '/components/com_jshopping/lib/functions.php';
JSFactory::loadCssFiles();
JSFactory::loadLanguageFile();
$jshopConfig = JSFactory::getConfig();
$mainframe = JFactory::getApplication();
$show_manufacturers = $params->get('show_manufacturers');
$show_categorys = $params->get('show_categorys');
$show_prices = $params->get('show_prices');
$show_characteristics = $params->get('show_characteristics');
$category_id = JRequest::getInt('category_id');
$manufacturer_id = JRequest::getInt('manufacturer_id');
//$contextfilter = "";
$contextfilter = "jshoping.list.front.product.cat.1";
if (JRequest::getVar("controller") == "category") {
    $contextfilter = "jshoping.list.front.product.cat." . $category_id;
}
if (JRequest::getVar("controller") == "manufacturer") {
    $contextfilter = "jshoping.list.front.product.manf." . $manufacturer_id;
Exemplo n.º 15
0
    function step7(){
        
        $mainframe =& JFactory::getApplication();
        $jshopConfig = &JSFactory::getConfig();
        $session =& JFactory::getSession();
        $pm_method = &JTable::getInstance('paymentMethod', 'jshop');
        
        if ($jshopConfig->savelog && $jshopConfig->savelogpaymentdata){            
            $str = "url: ".$_SERVER['REQUEST_URI']."\n";
            foreach($_POST as $k=>$v) $str .= $k."=".$v."\n";
            saveToLog("paymentdata.log", $str);
        }
        
        $act = JRequest::getVar("act");        
        $payment_method = JRequest::getVar("js_paymentclass");        
        
         if (!file_exists($jshopConfig->path . 'payments/' . $payment_method."/".$payment_method. '.php')) {
            if (JRequest::getInt('no_lang')) JSFactory::loadLanguageFile();
            saveToLog("payment.log", "#001 - Error payment method file. PM ".$payment_method);
            JError::raiseWarning(500, _JSHOP_ERROR_PAYMENT);            
            return 0;
        } 
        require_once ($jshopConfig->path . 'payments/' . $payment_method."/".$payment_method. '.php');        

        if (!class_exists($payment_method)) {
            if (JRequest::getInt('no_lang')) JSFactory::loadLanguageFile();
            saveToLog("payment.log", "#002 - Error payment. CLASS ".$payment_method);
            JError::raiseWarning(500, _JSHOP_ERROR_PAYMENT);            
            return 0;
        }
        
        $pmconfigs = $pm_method->getConfigsForClassName($payment_method);        
        $payment_system = new $payment_method();
        $urlParamsPS = $payment_system->getUrlParams($pmconfigs);
        
        $order_id = $urlParamsPS['order_id'];
        $hash = $urlParamsPS['hash'];
        $checkHash = $urlParamsPS['checkHash'];
        $checkReturnParams = $urlParamsPS['checkReturnParams'];
        
        $session->set('jshop_send_end_form', 0);
        
        if ($act == "cancel"){
            $this->_cancelPayOrder($order_id);
            return 0;
        }
        
        if ($act == "return" && !$checkReturnParams){
            $this->_setMaxStep(10);
            $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl));
            return 1;    
        }               
        
        $order = &JTable::getInstance('order', 'jshop');
        $order->load($order_id);
        
        if (JRequest::getInt('no_lang')){
            JSFactory::loadLanguageFile($order->getLang());
            $lang = &JSFactory::getLang($order->getLang());
        }

        if ($checkHash && $order->order_hash != $hash){
            saveToLog("payment.log", "#003 - Error order hash. Order id ".$order_id);
            JError::raiseWarning("", _JSHOP_ERROR_ORDER_HASH);
            return 0;    
        }
        
        if (!$order->payment_method_id){
            saveToLog("payment.log", "#004 - Error payment method id. Order id ".$order_id);
            JError::raiseWarning("", _JSHOP_ERROR_PAYMENT);
            return 0;    
        }        
                
        $pm_method->load($order->payment_method_id);
        
        if ($payment_method != $pm_method->payment_class){
            saveToLog("payment.log", "#005 - Error payment method set url. Order id ".$order_id);
            JError::raiseWarning("", _JSHOP_ERROR_PAYMENT);
            return 0;
        }
                
        $pmconfigs = $pm_method->getConfigs();
        $res = $payment_system->checkTransaction($pmconfigs, $order, $act);
        $rescode = $res[0];
        $restext = $res[1];        
        
        if ($rescode == 0 || $rescode == 3){        
            saveToLog("payment.log", $restext);
        }
        
        if ($rescode==0){
            $status = 0;
        }elseif($rescode==1){
            $status = $pmconfigs['transaction_end_status'];
        }elseif($rescode==2){
            $status = $pmconfigs['transaction_pending_status'];
        }elseif($rescode==3){
            $status = $pmconfigs['transaction_failed_status'];
        }
        
        if ($status && !$order->order_created){
            $order->order_created = 1;
            $order->order_status = $status;
            $order->store();
            $this->_sendOrderEmail($order->order_id);
            $order->changeProductQTYinStock("-");
            $this->_changeStatusOrder($order_id, $status, 0);
        }
            
        if ($status && $order->order_status != $status){            
           $this->_changeStatusOrder($order_id, $status, 1);
        }        

        if ($act == "notify"){
            $payment_system->nofityFinish($pmconfigs, $order, $rescode);            
            die();            
        }
              
        if ($rescode == 0 || $rescode == 3){			
            JError::raiseWarning(500, $restext); 
            $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step5',0,1,$jshopConfig->use_ssl));
            return 0;
        }else{
            $this->_setMaxStep(10);
            $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish',0,1,$jshopConfig->use_ssl));
            return 1;
        }
        
    }
Exemplo n.º 16
0
 function step7()
 {
     $checkout = JModelLegacy::getInstance('checkout', 'jshop');
     $wmiframe = JRequest::getInt("wmiframe");
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     $session = JFactory::getSession();
     $pm_method = JTable::getInstance('paymentMethod', 'jshop');
     if ($jshopConfig->savelog && $jshopConfig->savelogpaymentdata) {
         $str = "url: " . $_SERVER['REQUEST_URI'] . "\n";
         foreach ($_POST as $k => $v) {
             $str .= $k . "=" . $v . "\n";
         }
         saveToLog("paymentdata.log", $str);
     }
     $act = JRequest::getVar("act");
     $payment_method = JRequest::getVar("js_paymentclass");
     $paymentsysdata = $pm_method->getPaymentSystemData($payment_method);
     $payment_system = $paymentsysdata->paymentSystem;
     if ($paymentsysdata->paymentSystemVerySimple) {
         if (JRequest::getInt('no_lang')) {
             JSFactory::loadLanguageFile();
         }
         saveToLog("payment.log", "#001 - Error payment method file. PM " . $payment_method);
         JError::raiseWarning(500, _JSHOP_ERROR_PAYMENT);
         return 0;
     }
     if ($paymentsysdata->paymentSystemError) {
         if (JRequest::getInt('no_lang')) {
             JSFactory::loadLanguageFile();
         }
         saveToLog("payment.log", "#002 - Error payment. CLASS " . $payment_method);
         JError::raiseWarning(500, _JSHOP_ERROR_PAYMENT);
         return 0;
     }
     $pmconfigs = $pm_method->getConfigsForClassName($payment_method);
     $urlParamsPS = $payment_system->getUrlParams($pmconfigs);
     $order_id = $urlParamsPS['order_id'];
     $hash = $urlParamsPS['hash'];
     $checkHash = $urlParamsPS['checkHash'];
     $checkReturnParams = $urlParamsPS['checkReturnParams'];
     $session->set('jshop_send_end_form', 0);
     if ($act == "cancel") {
         $this->_cancelPayOrder($order_id);
         return 0;
     }
     if ($act == "return" && !$checkReturnParams) {
         $checkout->setMaxStep(10);
         if (!$wmiframe) {
             $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl));
         } else {
             $this->iframeRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl));
         }
         return 1;
     }
     $order = JTable::getInstance('order', 'jshop');
     $order->load($order_id);
     if (JRequest::getInt('no_lang')) {
         JSFactory::loadLanguageFile($order->getLang());
         $lang = JSFactory::getLang($order->getLang());
     }
     if ($checkHash && $order->order_hash != $hash) {
         saveToLog("payment.log", "#003 - Error order hash. Order id " . $order_id);
         JError::raiseWarning("", _JSHOP_ERROR_ORDER_HASH);
         return 0;
     }
     if (!$order->payment_method_id) {
         saveToLog("payment.log", "#004 - Error payment method id. Order id " . $order_id);
         JError::raiseWarning("", _JSHOP_ERROR_PAYMENT);
         return 0;
     }
     $pm_method->load($order->payment_method_id);
     if ($payment_method != $pm_method->payment_class) {
         saveToLog("payment.log", "#005 - Error payment method set url. Order id " . $order_id);
         JError::raiseWarning("", _JSHOP_ERROR_PAYMENT);
         return 0;
     }
     $pmconfigs = $pm_method->getConfigs();
     $res = $payment_system->checkTransaction($pmconfigs, $order, $act);
     $rescode = $res[0];
     $restext = $res[1];
     if ($rescode != 1) {
         saveToLog("payment.log", $restext);
     }
     $status = 0;
     $types_status = array(0 => 0, 1 => $pmconfigs['transaction_end_status'], 2 => $pmconfigs['transaction_pending_status'], 3 => $pmconfigs['transaction_failed_status'], 4 => $pmconfigs['transaction_cancel_status'], 5 => $pmconfigs['transaction_open_status'], 6 => $pmconfigs['transaction_shipping_status'], 7 => $pmconfigs['transaction_refunded_status'], 8 => $pmconfigs['transaction_confirm_status'], 9 => $pmconfigs['transaction_complete_status'], 10 => $pmconfigs['transaction_other_status'], 99 => 0);
     if (isset($types_status[$rescode])) {
         $status = $types_status[$rescode];
     }
     if ($status && !$order->order_created) {
         $order->order_created = 1;
         $order->order_status = $status;
         $order->store();
         if ($jshopConfig->send_order_email) {
             $checkout->sendOrderEmail($order->order_id);
         }
         $checkout->sendOrderEmail($order->order_id);
         $order->changeProductQTYinStock("-");
         $checkout->changeStatusOrder($order_id, $status, 0);
     }
     if ($status && $order->order_status != $status) {
         $checkout->changeStatusOrder($order_id, $status, 1);
     }
     if ($act == "notify") {
         $payment_system->nofityFinish($pmconfigs, $order, $rescode);
         die;
     }
     $payment_system->finish($pmconfigs, $order, $rescode, $act);
     if (in_array($rescode, array(0, 3, 4))) {
         JError::raiseWarning(500, $restext);
         if (!$wmiframe) {
             $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step5', 0, 1, $jshopConfig->use_ssl));
         } else {
             $this->iframeRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=step5', 0, 1, $jshopConfig->use_ssl));
         }
         return 0;
     } else {
         $checkout->setMaxStep(10);
         if (!$wmiframe) {
             $this->setRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl));
         } else {
             $this->iframeRedirect(SEFLink('index.php?option=com_jshopping&controller=checkout&task=finish', 0, 1, $jshopConfig->use_ssl));
         }
         return 1;
     }
 }
Exemplo n.º 17
0
    function save(){
        $jshopConfig = &JSFactory::getConfig();
        $post = JRequest::get('post');
        $order = &JTable::getInstance('order', 'jshop');
        $order_id = $post['order_id'];
        $db = &JFactory::getDBO();
        JPluginHelper::importPlugin('jshoppingadmin');
        $dispatcher =& JDispatcher::getInstance();
        
        $n = JRequest::getVar('amount_tax_items');        
        $a = null;
        if (!$jshopConfig->hide_tax){
            $post['order_tax'] = 0;
            for($i = 1; $i<=$n; $i++) {
                $a[number_format(JRequest::getVar('tax_percent_'.$i,''),2)] = JRequest::getVar('tax_value_'.$i,'');     
                $post['order_tax'] += JRequest::getVar('tax_value_'.$i,'');   
            } 
            $post['order_tax_ext'] = serialize($a);
            $post['order_tax'] = number_format($post['order_tax'],2);  
        }
        
        $dispatcher->trigger( 'onBeforeSaveOrder', array(&$post) );
        
        $k = JRequest::getVar('amount_order_items');
        if ($k){
            for($i = 1; $i<=$k; $i++) {
                $product_name       = JRequest::getVar('product_name_'.$i,'');
                $product_ean        = JRequest::getVar('product_ean_'.$i,'');
                $product_item_price = JRequest::getVar('product_item_price_'.$i,0);
                $product_quantity   = JRequest::getVar('product_quantity_'.$i,0);
                $order_item_id   = JRequest::getVar('order_item_id_'.$i); 
                $query = 'UPDATE #__jshopping_order_item SET `product_name`="'.$product_name.'",`product_ean`="'.$product_ean.'",`product_item_price`="'.$product_item_price.'",`product_quantity`="'.$product_quantity.'" WHERE `order_id`='.$order_id.' AND `order_item_id`='.$order_item_id;          
                $db->setQuery($query);
                $db->query();    
            }
        }

        if (!$order->bind($post)) {
            JError::raiseWarning("",_JSHOP_ERROR_BIND);
            $this->setRedirect("index.php?option=com_jshopping&controller=orders");
        }

        if (!$order->store()) {
            JError::raiseWarning("",_JSHOP_ERROR_SAVE_DATABASE);
            $this->setRedirect("index.php?option=com_jshopping&controller=orders");
        }    
        
        if ($jshopConfig->order_send_pdf_client || $jshopConfig->order_send_pdf_admin){
            $order->load($post['order_id']);
            $order->products = $order->getAllItems();
            JSFactory::loadLanguageFile($order->getLang());
            $lang = &JSFactory::getLang($order->getLang());
            
            $order->order_date = strftime($jshopConfig->store_date_format, strtotime($order->order_date));
            $order->order_tax_list = $order->getTaxExt();
            $country = &JTable::getInstance('country', 'jshop');
            $country->load($order->country);
            $field_country_name = $lang->get("name");
            $order->country = $country->$field_country_name;        
            
            $d_country = &JTable::getInstance('country', 'jshop');
            $d_country->load($order->d_country);
            $field_country_name = $lang->get("name");
            $order->d_country = $d_country->$field_country_name;

            $shippingMethod = &JTable::getInstance('shippingMethod', 'jshop');
            $shippingMethod->load($order->shipping_method_id);
            
            $pm_method = &JTable::getInstance('paymentMethod', 'jshop');
            $pm_method->load($order->payment_method_id);
            
            $name = $lang->get("name");
            $description = $lang->get("description");
            $order->shipping_information = $shippingMethod->$name;
            $order->payment_name = $pm_method->$name;
            $order->payment_information = $order->payment_params;
            
            include_once(JPATH_SITE . "/components/com_jshopping/lib/generete_pdf_order.php");
            $order->pdf_file = generatePdf($order);
            $order->insertPDF();
        }
        
        $dispatcher->trigger( 'onAfterSaveOrder', array(&$order) );
        
        $this->setRedirect("index.php?option=com_jshopping&controller=orders");       
    }