Example #1
0
 public function checkToken($data)
 {
     if (empty($data['user']) || empty($data['token'])) {
         return false;
     }
     $db = JFactory::getDBO();
     $query = 'SELECT * FROM ' . hikashop_table('user') . ' WHERE user_email = ' . $db->Quote($data['user']);
     $db->setQuery($query);
     $hkUser = $db->loadObject();
     if (empty($hkUser)) {
         return false;
     }
     $api_salt = $this->getSalt();
     $token_frame = $this->getTokenFrame();
     $timestamp = time();
     $timestamp -= $timestamp % 60;
     $timestamp -= $timestamp % (60 * $token_frame);
     $token = sha1((int) $hkUser->user_id . '#' . (int) $hkUser->user_cms_id . '#' . (int) $hkUser->user_created . '#' . date('dmY:Hi', $timestamp) . '#' . $api_salt);
     $previous_token = sha1((int) $hkUser->user_id . '#' . (int) $hkUser->user_cms_id . '#' . (int) $hkUser->user_created . '#' . date('dmY:Hi', $timestamp - $token_frame * 60) . '#' . $api_salt);
     if ($data['token'] == $token || $data['token'] == $previous_token) {
         $this->setHeader('token', $token);
         $app = JFactory::getApplication();
         $app->setUserState(HIKASHOP_COMPONENT . '.user_id', $hkUser->user_id);
         if ((int) $hkUser->user_cms_id > 0) {
             $user = JFactory::getUser((int) $hkUser->user_cms_id);
             JFactory::getSession()->set('user', $user);
         } else {
             JFactory::getSession()->set('user', null);
         }
         return true;
     }
     return false;
 }
Example #2
0
 function addColumns($table, $columns)
 {
     if (!is_array($columns)) {
         $columns = array($columns);
     }
     $query = 'ALTER TABLE `' . hikashop_table($table) . '` ADD ' . implode(', ADD', $columns) . ';';
     $this->db->setQuery($query);
     $err = false;
     try {
         $this->db->query();
     } catch (Exception $e) {
         $err = true;
     }
     if (!$err) {
         return true;
     }
     if ($err && count($columns) > 1) {
         foreach ($columns as $col) {
             $query = 'ALTER TABLE `' . hikashop_table($table) . '` ADD ' . $col . ';';
             $this->db->setQuery($query);
             $err = 0;
             try {
                 $this->db->query();
             } catch (Exception $e) {
                 $err++;
             }
         }
         if ($err < count($columns)) {
             return true;
         }
     }
     return false;
 }
Example #3
0
 function checkProducts()
 {
     $db = JFactory::getDBO();
     $query = 'SELECT * FROM ' . hikashop_table('product') . ' WHERE ' . ' product_quantity < ' . (int) $this->stock_limit . ' AND product_published = 1 AND product_quantity != -1 ' . ' AND (product_sale_start = 0 OR product_sale_start < ' . time() . ') AND (product_sale_end = 0 OR product_sale_end > ' . time() . ')';
     $db->setQuery($query);
     $products = $db->loadObjectList();
     if (!empty($products)) {
         $mailClass = hikashop_get('class.mail');
         $infos = new stdClass();
         $infos->products =& $products;
         $mail = $mailClass->get('out_of_stock', $infos);
         $mail->subject = JText::sprintf($mail->subject, HIKASHOP_LIVE);
         $config =& hikashop_config();
         if (!empty($infos->email)) {
             $mail->dst_email = $infos->email;
         } else {
             $mail->dst_email = $config->get('from_email');
         }
         if (!empty($infos->name)) {
             $mail->dst_name = $infos->name;
         } else {
             $mail->dst_name = $config->get('from_name');
         }
         $mailClass->sendMail($mail);
     }
     $app = JFactory::getApplication();
     $this->message = 'Products quantity checked';
     $app->enqueueMessage($this->message);
     return true;
 }
Example #4
0
 function checkOrders($notify = false)
 {
     $db = JFactory::getDBO();
     $config =& hikashop_config();
     $status = $config->get('order_created_status');
     $query = 'SELECT order_id, order_status, order_created FROM ' . hikashop_table('order') . ' WHERE order_type = ' . $db->Quote('sale') . ' AND order_created < ' . (time() - $this->period) . ' AND order_status = ' . $db->Quote($status) . ' ORDER BY order_created ASC LIMIT 0, 20';
     $db->setQuery($query);
     $orders = $db->loadObjectList();
     if (!empty($orders)) {
         $orderClass = hikashop_get('class.order');
         $status = $config->get('cancelled_order_status');
         $statuses = explode(',', $status);
         $status = reset($statuses);
         foreach ($orders as $order) {
             $update = new stdClass();
             $update->order_id = $order->order_id;
             $update->order_status = $status;
             if ($notify) {
                 $update->history = new stdClass();
                 $update->history->history_notified = 1;
             }
             $orderClass->save($update);
         }
     }
     $app = JFactory::getApplication();
     $this->message = 'Orders checked';
     $app->enqueueMessage($this->message);
     return true;
 }
Example #5
0
 function listing()
 {
     $app = JFactory::getApplication();
     $database = JFactory::getDBO();
     $toggleClass = hikashop_get('helper.toggle');
     $this->assignRef('toggleClass', $toggleClass);
     $pageInfo = $this->getPageInfo('a.warehouse_id');
     $filters = array();
     $order = '';
     $searchMap = array('a.warehouse_id', 'a.warehouse_name', 'a.warehouse_description');
     $this->processFilters($filters, $order, $searchMap);
     $query = ' FROM ' . hikashop_table('warehouse') . ' AS a' . $filters . $order;
     $this->getPageInfoTotal($query, '*');
     $database->setQuery('SELECT a.*' . $query, $pageInfo->limit->start, $pageInfo->limit->value);
     $rows = $database->loadObjectList();
     if (!empty($pageInfo->search)) {
         $rows = hikashop_search($pageInfo->search, $rows, 'warehouse_id');
     }
     $database->setQuery('SELECT count(*)' . $query);
     $pageInfo->elements->page = count($rows);
     $toggleClass = hikashop_get('helper.toggle');
     $this->assignRef('toggleClass', $toggleClass);
     $this->assignRef('rows', $rows);
     $this->assignRef('pageInfo', $pageInfo);
     $this->getPagination();
     $this->getOrdering('a.warehouse_ordering', true);
     $this->assignRef('order', $order);
     hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl);
     $config =& hikashop_config();
     $manage = hikashop_isAllowed($config->get('acl_warehouse_manage', 'all'));
     $this->assignRef('manage', $manage);
     $this->toolbar = array(array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'check' => JText::_('HIKA_VALIDDELETEITEMS'), 'display' => hikashop_isAllowed($config->get('acl_warehouse_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard');
 }
Example #6
0
File: tax.php Project: rodhoff/MNW
 function delete(&$ids)
 {
     foreach ($ids as $k => $id) {
         $ids[$k] = $this->database->Quote($id);
     }
     $query = 'DELETE FROM ' . hikashop_table('tax') . ' WHERE tax_namekey IN (' . implode(',', $ids) . ')';
     $this->database->setQuery($query);
     return $this->database->query();
 }
Example #7
0
 function getTable()
 {
     $trans_table = 'jf_content';
     $translationHelper = hikashop_get('helper.translation');
     $translationHelper->isMulti();
     if ($translationHelper->falang) {
         $trans_table = 'falang_content';
     }
     return hikashop_table($trans_table, false);
 }
Example #8
0
 function listing()
 {
     $app = JFactory::getApplication();
     $pageInfo = new stdClass();
     $pageInfo->filter = new stdClass();
     $pageInfo->filter->order = new stdClass();
     $pageInfo->limit = new stdClass();
     $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.currency_id', 'cmd');
     $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word');
     $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int');
     if (JRequest::getVar('search') != $app->getUserState($this->paramBase . ".search")) {
         $app->setUserState($this->paramBase . '.limitstart', 0);
         $pageInfo->limit->start = 0;
     } else {
         $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int');
     }
     $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string');
     $pageInfo->search = JString::strtolower(trim($pageInfo->search));
     $database = JFactory::getDBO();
     $searchMap = array('a.currency_symbol', 'a.currency_code', 'a.currency_name', 'a.currency_id');
     $filters = array();
     if (!empty($pageInfo->search)) {
         $searchVal = '\'%' . hikashop_getEscaped($pageInfo->search, true) . '%\'';
         $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}";
     }
     $query = 'FROM ' . hikashop_table('currency') . ' AS a';
     if (!empty($filters)) {
         $query .= ' WHERE (' . implode(') AND (', $filters) . ')';
     }
     if (!empty($pageInfo->filter->order->value)) {
         $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir;
     }
     $database->setQuery('SELECT a.* ' . $query, $pageInfo->limit->start, $pageInfo->limit->value);
     $rows = $database->loadObjectList('currency_id');
     $currencyClass = hikashop_get('class.currency');
     $currencyClass->getCurrencies(null, $rows);
     if (!empty($pageInfo->search)) {
         $rows = hikashop_search($pageInfo->search, $rows, 'currency_id');
     }
     $database->setQuery('SELECT count(*) ' . $query);
     $pageInfo->elements = new stdClass();
     $pageInfo->elements->total = $database->loadResult();
     $pageInfo->elements->page = count($rows);
     hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl);
     $config =& hikashop_config();
     $manage = hikashop_isAllowed($config->get('acl_currency_manage', 'all'));
     $this->assignRef('manage', $manage);
     $this->toolbar = array(array('name' => 'confirm', 'check' => false, 'msg' => JText::_('UPDATE_RATES_WARNING'), 'icon' => 'upload', 'alt' => JText::_('UPDATE_RATES'), 'task' => 'update', 'display' => $manage && hikashop_level(2)), array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_currency_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard');
     $toggleClass = hikashop_get('helper.toggle');
     $this->assignRef('toggleClass', $toggleClass);
     $this->assignRef('currency', $currencyClass);
     $this->assignRef('rows', $rows);
     $this->assignRef('pageInfo', $pageInfo);
     $this->getPagination();
 }
Example #9
0
 function load()
 {
     $query = 'SELECT * FROM ' . hikashop_table('characteristic') . ' WHERE characteristic_parent_id=0';
     $database = JFactory::getDBO();
     $database->setQuery($query);
     $object = $database->loadObjectList();
     $this->values = array();
     foreach ($object as $val) {
         $this->values[] = JHTML::_('select.option', $val->characteristic_id, $val->characteristic_value);
     }
 }
Example #10
0
 function save(&$element, $reorder = true)
 {
     JPluginHelper::importPlugin('hikashop');
     $dispatcher = JDispatcher::getInstance();
     $do = true;
     if (empty($element->shipping_id)) {
         $dispatcher->trigger('onBeforeHikaPluginCreate', array('shipping', &$element, &$do));
     } else {
         $dispatcher->trigger('onBeforeHikaPluginUpdate', array('shipping', &$element, &$do));
     }
     if (!$do) {
         return false;
     }
     if (isset($element->shipping_params) && !is_string($element->shipping_params)) {
         $element->shipping_params = serialize($element->shipping_params);
     }
     if (isset($element->shipping_currency) && is_array($element->shipping_currency)) {
         $element->shipping_currency = implode(",", $element->shipping_currency);
         if (!empty($element->shipping_currency)) {
             $element->shipping_currency = ',' . $element->shipping_currency . ',';
         }
     }
     $status = parent::save($element);
     if ($status) {
         $this->get('reset_cache');
     }
     if ($status && empty($element->shipping_id)) {
         $element->shipping_id = $status;
         if ($reorder) {
             $orderClass = hikashop_get('helper.order');
             $orderClass->pkey = 'shipping_id';
             $orderClass->table = 'shipping';
             $orderClass->groupMap = 'shipping_type';
             $orderClass->groupVal = $element->shipping_type;
             $orderClass->orderingMap = 'shipping_ordering';
             $orderClass->reOrder();
         }
     }
     if ($status && !empty($element->shipping_published) && !empty($element->shipping_id)) {
         $db = JFactory::getDBO();
         $query = 'SELECT shipping_type FROM ' . hikashop_table('shipping') . ' WHERE shipping_id = ' . (int) $element->shipping_id;
         $db->setQuery($query);
         $name = $db->loadResult();
         if (!HIKASHOP_J16) {
             $query = 'UPDATE ' . hikashop_table('plugins', false) . ' SET published = 1 WHERE published = 0 AND element = ' . $db->Quote($name) . ' AND folder = ' . $db->Quote('hikashopshipping');
         } else {
             $query = 'UPDATE ' . hikashop_table('extensions', false) . ' SET enabled = 1 WHERE enabled = 0 AND type = ' . $db->Quote('plugin') . ' AND element = ' . $db->Quote($name) . ' AND folder = ' . $db->Quote('hikashopshipping');
         }
         $db->setQuery($query);
         $db->query();
     }
     return $status;
 }
Example #11
0
 function load($value)
 {
     $this->values = array();
     $db = JFactory::getDBO();
     $query = 'SELECT * FROM ' . hikashop_table('user') . ' WHERE user_partner_activated = 1 OR user_id=' . $db->Quote($value);
     $db->setQuery($query);
     $partners = $db->loadObjectList();
     if (!empty($partners)) {
         foreach ($partners as $partner) {
             $this->values[] = JHTML::_('select.option', $partner->user_id, $partner->user_id . ' ' . $partner->user_partner_email);
         }
     }
 }
Example #12
0
File: user.php Project: rodhoff/MNW
 function load($value)
 {
     $this->values = array();
     $query = 'SELECT user_id,user_email FROM ' . hikashop_table('user');
     $db = JFactory::getDBO();
     $db->setQuery($query);
     $users = $db->loadObjectList('user_id');
     if (!empty($users)) {
         foreach ($users as $user) {
             $this->values[] = JHTML::_('select.option', (int) $user->user_id, $user->user_email . ' ' . $user->user_id);
         }
     }
 }
Example #13
0
 function wizard()
 {
     $db = JFactory::getDBO();
     hikashop_setTitle(JText::_('HIKA_WIZARD'), 'config', 'update&task=wizard');
     if (!HIKASHOP_PHP5) {
         $bar =& JToolBar::getInstance('toolbar');
     } else {
         $bar = JToolBar::getInstance('toolbar');
     }
     $bar->appendButton('Link', 'hikashop', JText::_('HIKA_SKIP'), hikashop_completeLink('update&task=post_install&fromversion=&update=0'));
     $languagesCodes = array();
     $languagesNames = array();
     if (HIKASHOP_J25) {
         $db->setQuery('SELECT * FROM ' . hikashop_table('languages', false) . ' WHERE `published` = 1');
         $languages = $db->loadObjectList();
         foreach ($languages as $language) {
             $path = JLanguage::getLanguagePath(JPATH_ROOT) . DS . $language->lang_code . DS . $language->lang_code . '.com_hikashop.ini';
             if (!JFile::exists($path)) {
                 $languagesCodes[] = $language->lang_code;
                 $languagesNames[] = $language->title;
             }
         }
     }
     if (!empty($languagesCodes)) {
         $languageCodes = implode('_', $languagesCodes);
     }
     if (!empty($languagesNames)) {
         $languagesNames = implode(', ', $languagesNames);
     }
     $this->assignRef('languageCodes', $languageCodes);
     $this->assignRef('languageNames', $languagesNames);
     $fieldsClass = hikashop_get('class.field');
     $this->assignRef('fieldsClass', $fieldsClass);
     static $Itemid;
     if (isset($Itemid) && !empty($Itemid)) {
         $url_itemid = '&item_id=' . $Itemid;
     } else {
         $url_itemid = '';
     }
     $address = new stdClass();
     $extraFields = array();
     $extraFields['address'] = $fieldsClass->getFields('frontcomp', $address, 'address', 'update&task=state' . $url_itemid);
     $this->assignRef('extraFields', $extraFields);
     $this->assignRef('address', $address);
     $db->setQuery('SELECT * FROM ' . hikashop_table('currency') . ' WHERE 1 ORDER BY `currency_code`');
     $currencies = $db->loadObjectList();
     $this->assignRef('currencies', $currencies);
     hikashop_loadJslib('jquery');
     $app = JFactory::getApplication();
     $app->enqueueMessage(JText::_('WELCOME_WIZARD', 'success'));
 }
Example #14
0
 function load($type, $value = '', $inherit = true)
 {
     $filter = false;
     if ($type == 'product_filter') {
         $type = 'product';
         $filter = true;
     }
     if (substr($type, 0, 1) != '#') {
         $query = 'SELECT * FROM ' . hikashop_table($type);
     } else {
         $query = 'SELECT * FROM ' . hikashop_table(substr($type, 2), false);
     }
     $database = JFactory::getDBO();
     $database->setQuery($query, 0, 1);
     $arr = $database->loadAssoc();
     $object = new stdClass();
     if (!empty($arr)) {
         if (!is_array($value) && !isset($arr[$value]) && !in_array($value, array('ordering', 'inherit'))) {
             $arr[$value] = $value;
         }
         ksort($arr);
         foreach ($arr as $key => $value) {
             if (!empty($key)) {
                 $object->{$key} = $value;
             }
         }
     }
     $this->values = array();
     if ($type == 'product') {
         if (!$filter) {
             $this->values['ordering'] = JHTML::_('select.option', 'ordering', JText::_('ORDERING'));
         } else {
             $this->values['all'] = JHTML::_('select.option', 'all', 'all');
         }
     }
     if (!empty($object)) {
         foreach (get_object_vars($object) as $key => $val) {
             $this->values[$key] = JHTML::_('select.option', $key, $key);
         }
         if (JRequest::getCmd('from_display', false) == false && $inherit) {
             $config = hikashop_config();
             $defaultParams = $config->get('default_params');
             $default = '';
             if (isset($defaultParams['product_order']) && isset($this->values[$defaultParams['product_order']])) {
                 $default = ' (' . $this->values[$defaultParams['product_order']]->text . ')';
             }
             $this->values[] = JHTML::_('select.option', 'inherit', JText::_('HIKA_INHERIT') . $default);
         }
     }
 }
Example #15
0
 function onAfterOrderDelete($elements)
 {
     if (!is_array($elements)) {
         $elements = array($elements);
     }
     $database = JFactory::getDBO();
     foreach ($elements as $key => $val) {
         $elements[$key] = $database->Quote($val);
     }
     $query = 'DELETE FROM ' . hikashop_table('history') . ' WHERE history_order_id IN (' . implode(',', $elements) . ')';
     $database->setQuery($query);
     $database->query();
     return true;
 }
Example #16
0
 function load($form)
 {
     $this->values = array();
     $query = 'SELECT * FROM ' . hikashop_table('tax');
     $db = JFactory::getDBO();
     $db->setQuery($query);
     $this->results = $db->loadObjectList();
     if (!$form) {
         $this->values[] = JHTML::_('select.option', '', JText::_('ALL_RATES'));
     }
     foreach ($this->results as $result) {
         $this->values[] = JHTML::_('select.option', $result->tax_namekey, $result->tax_namekey . ' (' . $result->tax_rate * 100.0 . '%)');
     }
 }
Example #17
0
 function listing()
 {
     $app = JFactory::getApplication();
     $database = JFactory::getDBO();
     $config =& hikashop_config();
     $pageInfo = $this->getPageInfo('a.email_log_id');
     $pageInfo->filter->filter_type = $app->getUserStateFromRequest($this->paramBase . ".filter_type", 'filter_type', '', 'string');
     $filters = array();
     $order = '';
     $searchMap = array('a.email_log_recipient_email', 'a.email_log_id');
     if (!empty($pageInfo->filter->filter_type)) {
         switch ($pageInfo->filter->filter_type) {
             case 'all':
                 break;
             default:
                 $filters[] = 'a.email_log_name = ' . $database->Quote($pageInfo->filter->filter_type);
                 break;
         }
     }
     $filters[] = 'a.email_log_published = 1';
     $this->processFilters($filters, $order, $searchMap);
     $query = ' FROM ' . hikashop_table('email_log') . ' AS a' . $filters . $order;
     $this->getPageInfoTotal($query, '*');
     $database->setQuery('SELECT a.*' . $query, $pageInfo->limit->start, $pageInfo->limit->value);
     $rows = $database->loadObjectList();
     $fields = array('email_log_recipient_email', 'email_log_reply_email', 'email_log_subject');
     foreach ($rows as &$row) {
         foreach ($fields as $field) {
             if (isset($row->{$field})) {
                 $row->{$field} = $this->escape($row->{$field});
             }
         }
     }
     unset($row);
     if (!empty($pageInfo->search)) {
         $rows = hikashop_search($pageInfo->search, $rows, 'email_log_id');
     }
     $emailType = hikashop_get('type.email_log');
     $this->assignRef('filter_type', $emailType);
     $this->assignRef('rows', $rows);
     $this->assignRef('pageInfo', $pageInfo);
     $this->getPagination();
     $this->getOrdering('a.email_log_date', true);
     $this->assignRef('order', $order);
     hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl);
     $manage = hikashop_isAllowed($config->get('acl_email_log_delete', 'all'));
     $this->assignRef('manage', $manage);
     $this->toolbar = array(array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_email_log_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard');
 }
Example #18
0
 function load($value)
 {
     $this->values = array();
     $query = 'SELECT category_id,category_name FROM ' . hikashop_table('category') . ' WHERE category_type = "manufacturer" AND category_depth != 1 ORDER BY category_name ASC';
     $db = JFactory::getDBO();
     $db->setQuery($query);
     $manufacturers = $db->loadObjectList('category_id');
     if (!empty($manufacturers)) {
         $this->values[] = JHTML::_('select.option', '', JText::_('MANUFACTURER'));
         $this->values[] = JHTML::_('select.option', 'none', JText::_('NO_MANUFACTURER'));
         foreach ($manufacturers as $manufacturer) {
             $this->values[] = JHTML::_('select.option', (int) $manufacturer->category_id, $manufacturer->category_name);
         }
     }
 }
Example #19
0
 function filters()
 {
     $db = JFactory::getDBO();
     $db->setQuery('SELECT * FROM ' . hikashop_table('filter') . ' ORDER BY filter_ordering');
     $rows = $db->loadObjectList('filter_namekey');
     $selected = JRequest::getVar('values', '', '', 'string');
     $selectedvalues = explode(',', $selected);
     $newRows = array();
     foreach ($rows as $namkey => $row) {
         if (in_array($namkey, $selectedvalues)) {
             $rows[$namkey]->selected = true;
         }
     }
     $this->assignRef('rows', $rows);
     $controlName = JRequest::getString('control', 'params');
     $this->assignRef('controlName', $controlName);
 }
Example #20
0
 function hikashopEditorType()
 {
     if (version_compare(JVERSION, '1.6', '<')) {
         $query = 'SELECT element,name FROM ' . hikashop_table('plugins', false) . ' WHERE folder=\'editors\' AND published=1 ORDER BY ordering ASC, name ASC';
     } else {
         $query = 'SELECT element,name FROM ' . hikashop_table('extensions', false) . ' WHERE folder=\'editors\' AND enabled=1 AND type=\'plugin\' ORDER BY ordering ASC, name ASC';
     }
     $db = JFactory::getDBO();
     $db->setQuery($query);
     $joomEditors = $db->loadObjectList();
     $this->values = array();
     $this->values[] = JHTML::_('select.option', '0', JText::_('HIKA_DEFAULT'));
     if (!empty($joomEditors)) {
         foreach ($joomEditors as $myEditor) {
             $this->values[] = JHTML::_('select.option', $myEditor->element, $myEditor->name);
         }
     }
 }
Example #21
0
 function checkWaitlists()
 {
     $config =& hikashop_config();
     $waitlist_send_limit = $config->get('product_waitlist_send_limit', 5);
     $db = JFactory::getDBO();
     $query = 'SELECT a.*, b.* FROM ' . hikashop_table('waitlist') . ' AS a ' . ' INNER JOIN ' . hikashop_table('product') . ' AS b ON (a.product_id = b.product_id)' . ' LEFT JOIN ' . hikashop_table('product') . ' AS c ON (c.product_id = b.product_parent_id)' . ' WHERE (b.product_quantity > 0) OR (b.product_quantity = -1 AND b.product_type = ' . $db->Quote('main') . ') ' . '   OR (b.product_type = ' . $db->Quote('variant') . ' AND b.product_quantity = -1 AND (c.product_quantity > 0 OR c.product_quantity = -1))' . ' ORDER BY a.product_id ASC, a.date ASC;';
     $db->setQuery($query);
     $notifies = $db->loadObjectList();
     if (!empty($notifies)) {
         $infos = null;
         $sends = array();
         foreach ($notifies as $notify) {
             if (!isset($sends[$notify->product_id])) {
                 $sends[$notify->product_id] = array();
             }
             $c = count($sends[$notify->product_id]);
             if (($c < $notify->product_quantity || $notify->product_quantity < 0) && ($c < $waitlist_send_limit || $waitlist_send_limit <= 0)) {
                 if ($notify->product_type == 'variant') {
                     $class = hikashop_get('class.product');
                     $db->setQuery('SELECT * FROM ' . hikashop_table('variant') . ' AS a LEFT JOIN ' . hikashop_table('characteristic') . ' AS b ON a.variant_characteristic_id=b.characteristic_id WHERE a.variant_product_id=' . (int) $notify->product_id . ' ORDER BY a.ordering');
                     $notify->characteristics = $db->loadObjectList();
                     $parentProduct = $class->get((int) $notify->product_parent_id);
                     $class->checkVariant($notify, $parentProduct);
                 }
                 $mailClass = hikashop_get('class.mail');
                 $sends[$notify->product_id][] = $notify->waitlist_id;
                 $mail = $mailClass->get('waitlist_notification', $notify);
                 $mail->subject = JText::sprintf($mail->subject, HIKASHOP_LIVE);
                 $mail->dst_email = $notify->email;
                 $mail->dst_name = $notify->name;
                 $mailClass->sendMail($mail);
                 $query = 'DELETE FROM ' . hikashop_table('waitlist') . ' WHERE waitlist_id = ' . $notify->waitlist_id . ';';
                 $db->setQuery($query);
                 $db->query();
             }
         }
     }
     $app = JFactory::getApplication();
     $this->message = 'Waitlist notifies checked';
     $app->enqueueMessage($this->message);
     return true;
 }
Example #22
0
 function load($value)
 {
     $this->values = array();
     $db = JFactory::getDBO();
     $query = 'SELECT COUNT(*) FROM ' . hikashop_table('warehouse') . ' WHERE warehouse_published = 1';
     $db->setQuery($query);
     $ret = (int) $db->loadResult();
     if ($ret > 10) {
         $this->values = $ret;
         return;
     }
     $query = 'SELECT * FROM ' . hikashop_table('warehouse') . ' WHERE warehouse_published = 1';
     $db->setQuery($query);
     $warehouses = $db->loadObjectList();
     $this->values[] = JHTML::_('select.option', 0, JText::_('NO_WAREHOUSE'));
     if (!empty($warehouses)) {
         foreach ($warehouses as $warehouse) {
             if ($warehouse->warehouse_id == 0 || $warehouse->warehouse_id == 1) {
                 continue;
             }
             $this->values[] = JHTML::_('select.option', $warehouse->warehouse_id, $warehouse->warehouse_id . ' ' . $warehouse->warehouse_name);
         }
     }
 }
Example #23
0
 function load()
 {
     $filters = array();
     $leftjoin = '';
     $from = '';
     $db = JFactory::getDBO();
     if (is_array($this->type)) {
         $filters[] = 'a.zone_type IN (\'' . implode('\',\'', $this->type) . '\')';
     } else {
         $filters[] = 'a.zone_type=\'' . $this->type . '\'';
         if ($this->type == 'state' && !empty($this->country_name)) {
             $filters[] = 'b.zone_parent_namekey=' . $db->Quote($this->country_name);
             $from = hikashop_table('zone_link') . ' AS b LEFT JOIN ';
             $leftjoin = ' ON b.zone_child_namekey=a.zone_namekey';
         }
     }
     if ($this->published) {
         $filters[] = 'a.zone_published=1';
     }
     $query = 'SELECT a.* FROM ' . $from . hikashop_table('zone') . ' AS a' . $leftjoin;
     $query .= ' WHERE ' . implode(' AND ', $filters) . ' ORDER BY a.zone_name_english ASC';
     $db->setQuery($query);
     return $db->loadObjectList('zone_namekey');
 }
Example #24
0
    public function onProductFormDisplay(&$product, &$html)
    {
        if ($product->product_type == 'variant') {
            return false;
        }
        $db = JFactory::getDBO();
        if (!HIKASHOP_J25) {
            $tmp = $db->getTableFields(hikashop_table('product'));
            $current = reset($tmp);
            unset($tmp);
        } else {
            $current = $db->getTableColumns(hikashop_table('product'));
        }
        if (!isset($current['product_taxability_code'])) {
            $databaseHelper = hikashop_get('helper.database');
            $databaseHelper->addColumns('product', '`product_taxability_code` INT(10) NOT NULL DEFAULT 0');
        }
        $doc = JFactory::getDocument();
        if (HIKASHOP_J25) {
            $doc->addScript(HIKASHOP_LIVE . 'plugins/hikashop/taxcloud/taxcloud.js');
        } else {
            $doc->addScript(HIKASHOP_LIVE . 'plugins/hikashop/taxcloud.js');
        }
        if (!HIKASHOP_J30) {
            JHTML::_('behavior.mootools');
        } else {
            JHTML::_('behavior.framework');
        }
        $doc->addScriptDeclaration('
window.addEvent("domready", function(){ var taxcloudField = new taxcloud("hikashop_data_product_taxability_code"); });
');
        $html[] = '
<tr>
	<td class="key">
		<label for="">' . JText::_('TAXABILITY_CODE') . '</label>
	</td>
	<td>
		<input type="text" name="data[product][product_taxability_code]" value="' . @$product->product_taxability_code . '" id="hikashop_data_product_taxability_code">
		<input type="hidden" name="product_taxability_code_field" value="1"/>
	</td>
</tr>
		';
    }
Example #25
0
 function onProcessCategoryMassActionupdateValues(&$elements, &$action, $k)
 {
     $current = 'category';
     $current_id = $current . '_id';
     $ids = array();
     foreach ($elements as $element) {
         $ids[] = $element->{$current_id};
         if (isset($element->{$action}['type'])) {
             $element->{$action}['type'] = $action['value'];
         }
     }
     $action['type'] = strip_tags($action['type']);
     $alias = explode('_', $action['type']);
     $queryTables = array($current);
     $possibleTables = array($current);
     if (!isset($this->massaction)) {
         $this->massaction = hikashop_get('class.massaction');
     }
     $value = $this->massaction->updateValuesSecure($action, $possibleTables, $queryTables);
     JArrayHelper::toInteger($ids);
     $db = JFactory::getDBO();
     $max = 500;
     if (count($ids) > $max) {
         $c = ceil((int) count($ids) / $max);
         for ($i = 0; $i < $c; $i++) {
             $offset = $max * $i;
             $id = array_slice($ids, $offset, $max);
             $query = 'UPDATE ' . hikashop_table($current) . ' AS hk_' . $current . ' ';
             $query .= 'SET hk_' . $alias[0] . '.' . $action['type'] . ' = ' . $value . ' ';
             $query .= 'WHERE hk_' . $current . '.' . $current . '_id IN (' . implode(',', $id) . ')';
             $db->setQuery($query);
             $db->query();
         }
     } else {
         $query = 'UPDATE ' . hikashop_table($current) . ' AS hk_' . $current . ' ';
         $query .= 'SET hk_' . $alias[0] . '.' . $action['type'] . ' = ' . $value . ' ';
         $query .= 'WHERE hk_' . $current . '.' . $current . '_id IN (' . implode(',', $ids) . ')';
         $db->setQuery($query);
         $db->query();
     }
 }
Example #26
0
 function listing()
 {
     $app = JFactory::getApplication();
     $pageInfo = new stdClass();
     $pageInfo->filter = new stdClass();
     $pageInfo->filter->order = new stdClass();
     $pageInfo->limit = new stdClass();
     $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.order_created', 'cmd');
     $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word');
     $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string');
     $pageInfo->search = JString::strtolower(trim($pageInfo->search));
     $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int');
     $oldValue = $app->getUserState($this->paramBase . '.list_limit');
     if (empty($oldValue)) {
         $oldValue = $app->getCfg('list_limit');
     }
     $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int');
     if ($oldValue != $pageInfo->limit->value) {
         $pageInfo->limit->start = 0;
         $app->setUserState($this->paramBase . '.limitstart', 0);
     }
     $database = JFactory::getDBO();
     $searchMap = array('a.order_id', 'a.order_status', 'a.order_number');
     $filters = array();
     $order = '';
     if (!empty($pageInfo->filter->order->value)) {
         $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir;
     }
     if (!empty($pageInfo->search)) {
         $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\'';
         $filter = '(' . implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}" . ')';
         $filters[] = $filter;
     }
     if (is_array($filters) && count($filters)) {
         $filters = ' AND ' . implode(' AND ', $filters);
     } else {
         $filters = '';
     }
     $query = 'FROM ' . hikashop_table('order') . ' AS a WHERE a.order_type = ' . $database->Quote('sale') . ' AND a.order_user_id=' . (int) hikashop_loadUser() . $filters . $order;
     $database->setQuery('SELECT a.* ' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value);
     $rows = $database->loadObjectList();
     if (!empty($pageInfo->search)) {
         $rows = hikashop_search($pageInfo->search, $rows, 'order_id');
     }
     $database->setQuery('SELECT COUNT(*) ' . $query);
     $pageInfo->elements = new stdClass();
     $pageInfo->elements->total = $database->loadResult();
     $pageInfo->elements->page = count($rows);
     $currencyClass = hikashop_get('class.currency');
     $this->assignRef('currencyHelper', $currencyClass);
     if (!$pageInfo->elements->page) {
         $app->enqueueMessage(JText::_('NO_ORDERS_FOUND'));
     }
     $pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
     $pagination->hikaSuffix = '';
     $this->assignRef('pagination', $pagination);
     $this->assignRef('pageInfo', $pageInfo);
     $string = '';
     $params = new HikaParameter($string);
     $params->set('show_quantity_field', 0);
     $config =& hikashop_config();
     if (hikashop_level(1) && $config->get('allow_payment_button', 1)) {
         $unpaid_statuses = explode(',', $config->get('order_unpaid_statuses', 'created'));
         if (!empty($rows)) {
             foreach ($rows as $k => $order) {
                 if (in_array($order->order_status, $unpaid_statuses)) {
                     $rows[$k]->show_payment_button = true;
                 }
             }
         }
         $payment_change = $config->get('allow_payment_change', 1);
         $this->assignRef('payment_change', $payment_change);
         $pluginsPayment = hikashop_get('type.plugins');
         $pluginsPayment->type = 'payment';
         $this->assignRef('payment', $pluginsPayment);
     }
     if ($config->get('cancellable_order_status', '') != '') {
         $cancellable_order_status = explode(',', $config->get('cancellable_order_status', ''));
         foreach ($rows as $k => $order) {
             if (in_array($order->order_status, $cancellable_order_status)) {
                 $rows[$k]->show_cancel_button = true;
             }
         }
     }
     $this->assignRef('params', $params);
     $this->assignRef('rows', $rows);
     $this->assignRef('config', $config);
     $cart = hikashop_get('helper.cart');
     $this->assignRef('cart', $cart);
     $category = hikashop_get('type.categorysub');
     $category->type = 'status';
     $category->load(true);
     $this->assignRef('order_statuses', $category);
     hikashop_setPageTitle('ORDERS');
 }
Example #27
0
 function getFields($filter, $datas = '')
 {
     $database = JFactory::getDBO();
     $query = 'SELECT * FROM ' . hikashop_table('field') . ' WHERE field_namekey = ' . $database->Quote($filter->filter_options['custom_field']);
     $database->setQuery($query);
     $field = $database->loadObject();
     if (!empty($filter->filter_options['custom_field']) && !empty($datas['products'])) {
         foreach ($datas['products'] as $data) {
             $optionElement[$data->product_id] = (int) $data->product_id;
         }
         $optionElement = 'product_id IN (' . implode(',', $optionElement) . ')';
         $query = 'SELECT DISTINCT ' . $filter->filter_options['custom_field'] . ' FROM ' . hikashop_table('product') . ' WHERE ' . $optionElement . '';
         $database->setQuery($query);
         if (!HIKASHOP_J25) {
             $values = $database->loadResultArray();
         } else {
             $values = $database->loadColumn();
         }
         if (!empty($values)) {
             foreach ($values as $val) {
                 $els = explode(',', $val);
                 if (count($els) > 1) {
                     foreach ($els as $el) {
                         $values[] = $el;
                     }
                 }
             }
         }
     }
     if (!empty($field->field_value)) {
         $field->field_value = explode("\n", $field->field_value);
         $unset = array();
         foreach ($field->field_value as $key => $val) {
             $temp = explode("::", $val);
             if (!empty($datas['products']) && !in_array($temp[0], $values)) {
                 $unset[] = $key;
             } else {
                 $field->field_value[$key] = array($temp[0], $temp[1]);
             }
         }
         if (!empty($unset)) {
             foreach ($unset as $u) {
                 unset($field->field_value[$u]);
             }
         }
     } elseif ($field->field_type == 'zone') {
         $fieldClass = hikashop_get('class.field');
         if (is_string($field->field_options)) {
             $field->field_options = unserialize($field->field_options);
         }
         $fields = array($field);
         $fieldClass->handleZone($fields, false, null);
         $values = array();
         foreach ($field->field_value as $k => $obj) {
             $values[] = array($k, $obj->value);
         }
         $field->field_value = $values;
     }
     return $field;
 }
Example #28
0
 function onAfterProductUpdate(&$product, $create = false)
 {
     $app = JFactory::getApplication();
     $vendor = null;
     if (!$app->isAdmin()) {
         if (!defined('HIKAMARKET_COMPONENT')) {
             return;
         }
         $marketConfig = hikamarket::config();
         if (!$marketConfig->get('frontend_edition', 0)) {
             return;
         }
         if (!hikamarket::acl('product_edit_plugin_shippingprices')) {
             return;
         }
         $vendor = hikamarket::loadVendor(false);
     }
     $formData = JRequest::getVar('shipping_prices', array(), '', 'array');
     if (empty($formData)) {
         return;
     }
     if (!$app->isAdmin()) {
         if (isset($formData[$product->product_id])) {
             $formData = $formData[$product->product_id];
         } else {
             if (isset($formData[0]) && $create) {
                 $formData = $formData[0];
             } else {
                 $formData = array();
             }
         }
     }
     if (empty($product->product_id)) {
         return;
     }
     $extra_filters = '';
     if ($vendor !== null && $vendor > 1) {
         $extra_filters = ' AND a.shipping_vendor_id IN (-1, 0, ' . (int) $vendor . ') ';
     }
     $db = JFactory::getDBO();
     $query = 'SELECT b.*, a.*, c.currency_symbol FROM ' . hikashop_table('shipping') . ' AS a INNER JOIN ' . hikashop_table('shipping_price') . ' AS b ON a.shipping_id = b.shipping_id INNER JOIN ' . hikashop_table('currency') . ' AS c ON c.currency_id = a.shipping_currency_id ' . 'WHERE a.shipping_params LIKE ' . $db->Quote('%s:20:"shipping_per_product";s:1:"1"%') . ' AND b.shipping_price_ref_id = ' . $product->product_id . ' AND b.shipping_price_ref_type = \'product\' ' . $extra_filters . 'ORDER BY a.shipping_id, b.shipping_price_min_quantity';
     $db->setQuery($query);
     $shippings = $db->loadObjectList('shipping_price_id');
     $toRemove = array_keys($shippings);
     if (!empty($toRemove)) {
         $toRemove = array_combine($toRemove, $toRemove);
     }
     $toInsert = array();
     $checks = array();
     foreach ($formData as &$data) {
         if (is_string($data)) {
             $data = null;
         } else {
             if (empty($checks[$data['shipping_id']])) {
                 $checks[$data['shipping_id']] = array();
             }
             if (!isset($checks[$data['shipping_id']][$data['qty']])) {
                 $checks[$data['shipping_id']][$data['qty']] = true;
             } else {
                 $data = null;
             }
         }
         unset($data);
     }
     unset($checks);
     foreach ($formData as $data) {
         if ($data == null) {
             continue;
         }
         $shipping = null;
         if (!empty($data['id']) && isset($shippings[$data['id']])) {
             if (empty($data['value']) && empty($data['fee'])) {
                 continue;
             }
             $shipping = $shippings[$data['id']];
             unset($toRemove[$data['id']]);
             if (empty($data['qty']) || (int) $data['qty'] < 1) {
                 $data['qty'] = 1;
             }
             if ((int) $shipping->shipping_price_min_quantity != (int) $data['qty'] || (double) $shipping->shipping_price_value != (double) $data['value'] || (double) $shipping->shipping_fee_value != (double) $data['fee']) {
                 $query = 'UPDATE ' . hikashop_table('shipping_price') . ' SET shipping_price_min_quantity = ' . (int) $data['qty'] . ', shipping_price_value = ' . (double) $data['value'] . ', shipping_fee_value = ' . (double) $data['fee'] . ' WHERE shipping_price_id = ' . $data['id'] . ' AND shipping_price_ref_id = ' . $product->product_id . ' AND shipping_price_ref_type = \'product\'';
                 $db->setQuery($query);
                 $db->query();
             }
         } else {
             if ((!empty($data['value']) || !empty($data['fee'])) && !empty($data['shipping_id'])) {
                 if (empty($data['qty']) || (int) $data['qty'] < 1) {
                     $data['qty'] = 1;
                 }
                 $toInsert[] = (int) $data['shipping_id'] . ',' . $product->product_id . ',\'product\',' . (int) $data['qty'] . ',' . (double) $data['value'] . ',' . (double) $data['fee'];
             }
         }
     }
     if (!empty($toRemove)) {
         $db->setQuery('DELETE FROM ' . hikashop_table('shipping_price') . ' WHERE shipping_price_ref_id = ' . $product->product_id . ' AND shipping_price_ref_type = \'product\' AND shipping_price_id IN (' . implode(',', $toRemove) . ')');
         $db->query();
     }
     if (!empty($toInsert)) {
         $db->setQuery('INSERT IGNORE INTO ' . hikashop_table('shipping_price') . ' (`shipping_id`,`shipping_price_ref_id`,`shipping_price_ref_type`,`shipping_price_min_quantity`,`shipping_price_value`,`shipping_fee_value`) VALUES (' . implode('),(', $toInsert) . ')');
         $db->query();
     }
 }
Example #29
0
 function listing()
 {
     $db = JFactory::getDBO();
     $filter = '';
     if (hikashop_level(1)) {
         $app = JFactory::getApplication();
         $selectedType = $app->getUserStateFromRequest($this->paramBase . ".filter_table", 'filter_table', '', 'string');
         if (!empty($selectedType)) {
             $filter = ' WHERE a.field_table=' . $db->Quote($selectedType);
         }
         $table = hikashop_get('type.table');
         $this->assignRef('tabletype', $table);
     } else {
         $filter = ' WHERE a.field_table=\'address\' OR a.field_table LIKE \'plg.%\'';
     }
     $db->setQuery('SELECT a.* FROM ' . hikashop_table('field') . ' AS a' . $filter . ' ORDER BY a.`field_table` ASC, a.`field_ordering` ASC');
     $rows = $db->loadObjectList();
     $config =& hikashop_config();
     $manage = hikashop_isAllowed($config->get('acl_field_manage', 'all'));
     $this->assignRef('manage', $manage);
     $this->toolbar = array(array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_field_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => 'field-listing'), 'dashboard');
     $total = count($rows);
     $pagination = hikashop_get('helper.pagination', $total, 0, $total);
     hikashop_setTitle(JText::_('FIELDS'), 'field', 'field');
     $this->assignRef('rows', $rows);
     $toggle = hikashop_get('helper.toggle');
     $this->assignRef('toggleClass', $toggle);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('selectedType', $selectedType);
     $type = hikashop_get('type.fields');
     $type->load();
     $this->assignRef('fieldtype', $type);
     $fieldClass = hikashop_get('class.field');
     $this->assignRef('fieldsClass', $fieldClass);
 }
Example #30
-1
 function load($value)
 {
     $this->values = array();
     $config =& hikashop_config();
     $forced = array((int) $config->get('main_currency'));
     $filters = array('currency_published = 1');
     if ($this->displayType == 'auto') {
         $app = JFactory::getApplication();
         if ($app->isAdmin()) {
             if (is_array($value)) {
                 $forced = array_merge($forced, $value);
                 JArrayHelper::toInteger($forced);
             } else {
                 $forced[] = (int) $value;
             }
         } else {
             $filters[] = 'currency_displayed = 1';
         }
         $filters[] = 'currency_id IN (' . implode(',', $forced) . ')';
     } elseif ($this->displayType == 'all') {
         $filters[] = 'currency_displayed = 1';
         $this->values[] = JHTML::_('select.option', 0, JText::_('HIKA_NONE'));
     }
     if (empty($this->currencies)) {
         $query = 'SELECT * FROM ' . hikashop_table('currency') . ' WHERE (' . implode(') OR (', $filters) . ')';
         $db = JFactory::getDBO();
         $db->setQuery($query);
         $this->currencies = $db->loadObjectList('currency_id');
     }
     if (!empty($this->currencies)) {
         foreach ($this->currencies as $currency) {
             $this->values[] = JHTML::_('select.option', (int) $currency->currency_id, $currency->currency_symbol . ' ' . $currency->currency_code);
         }
     }
 }