function getItem() { $result = array(); $post = JRequest::get('post'); $post = oseMscAddon::getPost('licseat_', $post); if (!isset($post['contact_send'])) { $post['contact_send'] = 0; } if (!isset($post['internal_contact_send'])) { $post['internal_contact_send'] = 0; } $db = oseDB::instance(); $msc_id = JRequest::getInt('msc_id', 0); $member_id = JRequest::getInt('member_id', 0); $mscLicInfo = oseRegistry::call('msc')->getExtInfo($msc_id, 'lic', 'obj'); $mscLicInfoParams = oseObject::getParams($mscLicInfo); $where = array(); $where[] = "license_user_id = '{$member_id}'"; if (empty($mscLicInfoParams->id)) { $where[] = "license_id = '{$mscLicInfoParams->id}'"; } $where = oseDB::implodeWhere(); $query = " SELECT * FROM `#__oselic_license_seat`" . $where . " ORDER BY id DESC"; $db->setQuery($query); $item = oseDB::loadItem('obj'); $result['success'] = empty($item) ? false : true; $result['total'] = empty($item) ? 0 : 1; $result['result'] = empty($item) ? array() : $item; //$result = oseJson::encode($result); return $result; }
function getBasicInfo($type = 'array') { $db = oseDB::instance(); $query = " SELECT id,username,name,email,params " . " FROM `#__users` WHERE id = " . (int) $this->user_id; $db->setQuery($query); return oseDB::loadItem($type); }
public static function save($params = array()) { $db = oseDB::instance(); $post = JRequest::get('post'); $id = JRequest::getCmd('id', null); $msc_id = JRequest::getInt('msc_id', 0); if (empty($id)) { $id = uniqid(); } $extItem = oseRegistry::call('msc')->getExtInfoItem($msc_id, 'acymailing2', 'obj'); $extItem->params = empty($extItem->params) ? '{}' : $extItem->params; $items = oseJson::decode($extItem->params, true); $where = array(); $msc_id = isset($msc_id) ? $msc_id : null; if (empty($msc_id)) { return false; // No membership exists in the addon } else { unset($post['msc_id']); $where[] = 'id = ' . $db->Quote($msc_id); } $where[] = 'type = ' . $db->Quote('acymailing2'); $params = array(); $prefix = 'acymailing2_'; foreach ($post as $key => $value) { if (strstr($key, $prefix)) { $newKey = preg_replace("/{$prefix}/", '', $key, 1); $params[$newKey] = $value; } } ksort($params); $params['id'] = $id; $items[$id] = $params; $newParams = $db->Quote(oseJson::encode($items)); $where = oseDB::implodeWhere($where); $query = " SELECT * FROM `#__osemsc_ext` " . $where; $db->setQuery($query); $obj = oseDB::loadItem('obj'); if (empty($obj)) { $query = " INSERT INTO `#__osemsc_ext` " . " (id,type,params)" . " VALUES " . " ({$msc_id}," . $db->Quote('acymailing2') . ",{$newParams}) "; $db->setQuery($query); //oseExit($db->_sql); } else { $query = " UPDATE `#__osemsc_ext` " . " SET " . " params = {$newParams} " . " WHERE id = {$obj->id}" . " AND type = " . $db->Quote('acymailing2'); $db->setQuery($query); } if (oseDB::query()) { $result['success'] = true; $result['title'] = JText::_('Finished'); $result['content'] = JText::_('Save Successfully!'); } else { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Error in Saving License Parameters'); } return $result; }
function getItems() { // Get a storage key. $store = $this->getStoreId('getItems'); // Try to load the data from internal storage. if (!empty($this->cache[$store])) { return $this->cache[$store]; } $search = $this->getState('filter.search'); $searchid = $this->getState('filter.searchid'); $searchpe = $this->getState('filter.searchpe'); // Load the list items. $items = parent::getItems(); // If emtpy or an error, just return. if (empty($items)) { return array(); } //oseExit($items); $db = oseDB::instance(); // Inject the values back into the array. foreach ($items as $k => $item) { $order_id = null; if ($item->msc_id > 0) { $params = oseJson::decode($item->params); $order_id = oseGetValue($params, 'order_id', 0); $query = " SELECT `title` FROM `#__osemsc_acl`" . " WHERE `id` = '{$item->msc_id}'"; $db->setQuery($query); $item->membership = $db->loadResult(); $query = " SELECT *" . " FROM `#__osemsc_order_fix`" . " WHERE `member_id` = '{$item->id}'"; $db->setQuery($query); $ofItem = oseDB::loadItem('obj'); $item->paypal_email = oseObject::getValue($ofItem, 'email', $item->email); } else { $item->expired_date = null; $item->status = ''; } if (empty($search) && empty($searchid) && empty($searchpe)) { //return array(); } else { //$item->order_number = null; if (!empty($order_id)) { $query = " SELECT `order_id`,`order_number`,`payment_serial_number`,`order_status`" . " FROM `#__osemsc_order`" . " WHERE `order_id` = '{$order_id}'"; $db->setQuery($query); $oItem = oseDB::loadItem('obj'); $item->order_number = $oItem->order_number; $item->order_id = $oItem->order_id; $item->payment_serial_number = $oItem->payment_serial_number; $item->order_status = $oItem->order_status; } else { } } $items[$k] = $item; } // Add the items to the internal cache. $this->cache[$store] = $items; return $this->cache[$store]; }
static function getConfigItem($configItemName, $config_type, $type = 'array') { $db = oseDB::instance(); $configItemName = $db->Quote($configItemName); $config_type = $db->Quote($config_type); $query = " SELECT * FROM `#__osemsc_configuration`" . " WHERE `key` = {$configItemName} AND `type` = {$config_type}"; $db->setQuery($query); $item = oseDB::loadItem($type); return $item; }
function getProperty($msc_id) { $db = oseDB::instance(); oseDB::lock('#__osemsc_acl READ'); $query = " SELECT * FROM `#__osemsc_acl`" . " WHERE id = {$msc_id}"; $db->setQuery($query); $item = oseDB::loadItem(); oseDB::unlock(); return $item; }
function getInfo($id, $type = 'array') { $db = oseDB::instance(); $where = array(); $where[] = "`id` = " . $db->Quote($id); $where = oseDB::implodeWhere($where); $query = " SELECT * FROM `#__osemsc_acl`" . " WHERE `id` = '{$id}'"; $db->setQuery($query); $item = oseDB::loadItem($type); return $item; }
public function getGWInfo($payment_method) { $db = oseDB::instance(); if (is_numeric($payment_method)) { $query = " SELECT * FROM `#__osemsc_paymentgateway`" . " WHERE `id` = '{$payment_method}'"; } else { $query = " SELECT * FROM `#__osemsc_paymentgateway`" . " WHERE `filename` = " . $db->Quote($payment_method); } $db->setQuery($query); $item = oseDB::loadItem('obj'); return $item; }
function __construct($p) { parent::__construct($p); $db = oseDB::instance(); $query = " SELECT * FROM `{$this->_table}`" . " WHERE `plan_id` = '" . $this->get('plan_id') . "'"; $db->setQuery($query); $item = oseDB::loadItem(); if (empty($item)) { $this->create(); } else { $this->setProperties($item); } }
function getItemSubmit($id, $entry_type = 'credit_submit', $type = 'array') { $db = oseDB::instance(); if (empty($id)) { return false; } $where = array(); $where[] = "`id` = " . (int) $id; $where[] = "`entry_type` = " . $db->Quote($entry_type, true); $where = oseDB::implodeWhere($where); $query = " SELECT * FROM `{$this->table}`" . $where; $db->setQuery($query); $item = oseDB::loadItem($type); return $item; }
public static function getItem($params = array()) { $member_id = JRequest::getInt('member_id', 0); $db = oseDB::instance(); $query = " SELECT * FROM `#__osemsc_userinfo_view` " . " WHERE user_id = {$member_id}"; $db->setQuery($query); $info = oseDB::loadItem(); if (empty($info)) { $result['total'] = 0; $result['result'] = ''; } else { $result['total'] = 1; $result['result'] = $info; } return $result; }
function getItem($cType, $content_type, $content_id, $entry_type = 'msc', $entry_id, $status = null, $type = 'array') { $db = oseDB::instance(); $where = array(); $where[] = "content_id = {$content_id}"; $where[] = "content_type='{$content_type}'"; $where[] = "type = '{$cType}'"; $where[] = "entry_id = {$entry_id}"; $where[] = "entry_type = '{$entry_type}'"; if (!empty($status) || $status == '0') { $where[] = "status = {$status}"; } $where = oseDB::implodeWhere($where); $query = " SELECT * FROM `#__osemsc_content`" . $where; $db->setQuery($query); $item = oseDB::loadItem($type); return $item; }
function getFaith() { $id = JRequest::getInt('id',0); $db= oseDB::instance(); $query = " SELECT * FROM `#__osemsc_email` " ." WHERE type = 'faith' AND id = {$id} " ; $db->setQuery($query); $term = oseDB::loadItem(); $result = empty($term)?'':$term; $result = oseJson::encode($result); oseExit($result); }
function removeAllCurrency() { $db = oseDB::instance(); $query = " SELECT * FROM `#__osemsc_configuration`" . " WHERE `key` = 'primary_currency' AND `type` = 'currency'"; $db->setQuery($query); $item = oseDB::loadItem('obj'); //$currencyInfos = oseJson::decode($item->default,true); //unset($currencyInfos[$currency]); $currencyInfos = oseJson::encode(null); $query = " UPDATE `#__osemsc_configuration`" . " SET `default` = " . $db->Quote($currencyInfos) . " WHERE `id` = '{$item->id}'"; $db->setQuery($query); return oseDB::query(); }
function changeStatus() { $db = oseDB::instance(); //$app = JFactory::getApplication(); //$jMenu = $app->getMenu(); $msc_id = JRequest::getInt('msc_id', 0); $menu_ids = JRequest::getVar('menu_ids', array()); $newStatus = JRequest::getInt('status', 0); $timeLength = JRequest::getVar('time_length', array()); $timeUnit = JRequest::getVar('time_unit', array()); //$time_length = array(); //$time_unit = array(); $new_menu_ids = array(); foreach ($menu_ids as $menu_id) { $new_menu_ids[$menu_id] = $menu_id; //$time_length[$menu_id] = $timeLength[$key]; //$time_unit[$menu_id] = $timeUnit[$key]; $query = " SELECT * FROM `#__menu`" . " WHERE id = '{$menu_id}'"; $db->setQuery($query); $menu = oseDB::loadItem('obj'); if ($menu->type == 'alias') { $aliasoptions = oseJson::decode($menu->params)->aliasoptions; $new_menu_ids[$aliasoptions] = $aliasoptions; } } //$menu_ids = $new_menu_ids; foreach ($menu_ids as $key => $menu_id) { $content = oseRegistry::call('content')->getInstance('msc'); $item = $content->getItem('joomla', 'menu', $menu_id, 'msc', $msc_id, '', 'obj'); $ItemParams = array(); $ItemParams['time_length'] = $timeLength[$key]; $ItemParams['time_unit'] = $timeUnit[$key]; if (empty($item)) { /* if($menu->type == 'alias') { $aliasoptions = oseJson::decode($menu->params)->aliasoptions; //$menu_ids[] = $aliasoptions; $updated = $content->insert('joomla','menu',$menu_id,'msc',$msc_id, $newStatus,array('aliasoptions'=>$aliasoptions)); } else { $updated = $content->insert('joomla','menu',$menu_id,'msc',$msc_id, $newStatus); } */ $updated = $content->insert('joomla', 'menu', $menu_id, 'msc', $msc_id, $newStatus, $ItemParams); if (!$updated) { $result = array(); $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('ERROR'); return $result; } } else { $status = $item->status; if ($status == $newStatus) { //continue; $updated = $content->update($item, $newStatus, $ItemParams); if (!$updated) { $result = array(); $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('ERROR'); return $result; } } else { /* if($menu->type == 'alias') { $aliasoptions = oseJson::decode($menu->params)->aliasoptions; $itemParams = oseJson::decode($item->params,true); $itemParams['aliasoptions'] = $aliasoptions; $updated = $content->update($item, $newStatus,$itemParams); } else { $updated = $content->update($item, $newStatus); } */ $updated = $content->update($item, $newStatus, $ItemParams); if (!$updated) { $result = array(); $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('ERROR'); return $result; } } } } $result = array(); $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('SUCCESSFULLY'); return $result; }
function getExt($type) { $db = oseDB::instance(); if (OSEMSCVERSION >= '7.0.0') { $query = "SELECT * FROM `#__osemsc_ext`" . " WHERE `msc_id` = '{$this->id}' AND `type`=" . $db->Quote($type); } else { $query = "SELECT * FROM `#__osemsc_ext`" . " WHERE `id` = '{$this->id}' AND `type`=" . $db->Quote($type); } $db->setQuery($query); $item = oseDB::loadItem(); $item['params'] = oseJson::decode(oseGetValue($item, 'params', '{}'), true); $item = array_merge($item, $item['params']); unset($item['params']); $ext = $this->get('_ext'); $ext[$type] = $item; $this->set('_ext', $ext); return $item; }
function getUsersTable($id) { $db = oseDB::instance(); $where = array(); $where[] = "c.`coupon_id` = '{$id}'"; $where = oseDB::implodeWhere($where); $query = " SELECT c.* FROM `#__osemsc_coupon_user` AS c " . $where; $db->setQuery($query); //oseExit($db->_sql); $items = oseDB::loadList(); //oseExit($items); foreach ($items as $key => $item) { $user_id = oseObject::getValue($item, 'user_id'); $query = " SELECT * FROM `#__users`" . " WHERE `id` = '{$user_id}'"; $db->setQuery($query); $obj = oseDB::loadItem('obj'); $item = oseObject::setValue($item, 'username', oseObject::getValue($obj, 'username')); $items[$key] = $item; } $html = $this->generateTable($items); return $html; }
private function addVmOrder($msc_id, $member_id, $params, $order_number) { if (empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); return $result; } // Get the IP Address if (!empty($_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; } else { $ip = 'unknown'; } $post = JRequest::get('post'); $payment_mode = $params['payment_mode']; $payment_method = $params['payment_method']; //Insert the vm order table(#__vm_orders) $order = array(); //get membership price $payment = oseRegistry::call('payment'); $paymentInfo = oseMscAddon::getExtInfo($msc_id, 'payment', 'obj'); if ($payment_mode == 'm') { $order_subtotal = $paymentInfo->price; } else { $order_subtotal = empty($paymentInfo->has_trial) ? $paymentInfo->a3 : $paymentInfo->a1; } $order['order_subtotal'] = $params['payment_price']; $order_total = $params['payment_price']; $order['order_total'] = $order_total; $db = oseDB::instance(); //$order['order_tax'] = '0.00'; $query = "SELECT user_info_id FROM `#__vm_user_info` WHERE `user_id` = '" . (int) $member_id . "' AND (`address_type` = 'BT' OR `address_type` IS NULL)"; $db->setQuery($query); $result = $db->loadResult(); $hash_secret = "VirtueMartIsCool"; $user_info_id = empty($result) ? md5(uniqid($hash_secret)) : $result; $vendor_id = '1'; $order['user_id'] = $member_id; $order['vendor_id'] = $vendor_id; $order['user_info_id'] = $user_info_id; $order['order_number'] = $order_number; $order['order_currency'] = !empty($payment->currency) ? $payment->currency : "USD"; $order['order_status'] = 'C'; $order['cdate'] = time(); $order['ip_address'] = $ip; $keys = array_keys($order); $keys = '`' . implode('`,`', $keys) . '`'; foreach ($order as $key => $value) { $order[$key] = $db->Quote($value); } $values = implode(',', $order); $query = "INSERT INTO `#__vm_orders` ({$keys}) VALUES ({$values});"; $db->setQuery($query); if (!oseDB::query()) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); } //Insert the #__vm_order_history table $order_id = $db->insertid(); $history = array(); $history['order_id'] = $order_id; $history['order_status_code'] = 'C'; $history['date_added'] = date("Y-m-d G:i:s", time()); $history['customer_notified'] = '1'; $keys = array_keys($history); $keys = '`' . implode('`,`', $keys) . '`'; foreach ($history as $key => $value) { $history[$key] = $db->Quote($value); } $values = implode(',', $history); $query = "INSERT INTO `#__vm_order_history` ({$keys}) VALUES ({$values});"; $db->setQuery($query); if (!oseDB::query()) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); } //Insert the Order payment info $payment = array(); $payment['order_id'] = $order_id; $payment['payment_method_id'] = $payment_method; if ($payment_method == 'authorize') { } //Insert the User Bill $bill = array(); $query = " SELECT * FROM `#__osemsc_billinginfo`" . " WHERE user_id = {$member_id}"; $db->setQuery($query); $billInfo = oseDB::loadItem(); if (isset($billInfo)) { $bill['company'] = $billInfo['company']; $bill['address_1'] = $billInfo['addr1']; $bill['address_2'] = $billInfo['addr2']; $bill['city'] = $billInfo['city']; $bill['state'] = $billInfo['state']; $bill['country'] = $billInfo['country']; //get vm country code $query = " SELECT country_3_code FROM `#__vm_country` WHERE `country_2_code` = '{$bill['country']}' "; $db->setQuery($query); $country_code = $db->loadResult(); $bill['country'] = empty($country_code) ? $bill['country'] : $country_code; //get vm state code $query = " SELECT state_2_code FROM `#__vm_state` WHERE `state_name` = '{$bill['state']}' "; $db->setQuery($query); $state_code = $db->loadResult(); $bill['state'] = empty($state_code) ? $bill['state'] : $state_code; $bill['zip'] = $billInfo['postcode']; $bill['phone_1'] = $billInfo['telephone']; } $query = " SELECT * FROM `#__osemsc_userinfo_view`" . " WHERE user_id = {$member_id}"; $db->setQuery($query); $userInfo = oseDB::loadItem(); $bill['order_id'] = $order_id; $bill['user_id'] = $member_id; $bill['address_type'] = 'BT'; $bill['address_type_name'] = '-default-'; $bill['last_name'] = $userInfo['lastname']; $bill['first_name'] = $userInfo['firstname']; $bill['user_email'] = $userInfo['email']; $keys = array_keys($bill); $keys = '`' . implode('`,`', $keys) . '`'; foreach ($bill as $key => $value) { $bill[$key] = $db->Quote($value); } $values = implode(',', $bill); $query = "INSERT INTO `#__vm_order_user_info` ({$keys}) VALUES ({$values});"; $db->setQuery($query); if (!oseDB::query()) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); } //Insert the itme table(#__vm_order_item) $item = array(); $item['order_id'] = $order_id; $item['user_info_id'] = $user_info_id; $item['vendor_id'] = $vendor_id; //get the product info $vm = oseMscAddon::getExtInfo($msc_id, 'vm', 'obj'); $query = " SELECT * FROM `#__vm_product` WHERE `product_id` = '{$vm->product_id}' "; $db->setQuery($query); $product = $db->loadObject(); $item['product_id'] = $vm->product_id; $item['order_item_sku'] = $product->product_sku; $item['order_item_name'] = $product->product_name; $item['product_quantity'] = '1'; $item['product_item_price'] = $order_subtotal; $item['product_final_price'] = $order_total; $item['order_item_currency'] = !empty($payment->currency) ? $payment->currency : "USD"; $item['order_status'] = 'C'; $item['cdate'] = time(); $keys = array_keys($item); $keys = '`' . implode('`,`', $keys) . '`'; foreach ($item as $key => $value) { $item[$key] = $db->Quote($value); } $values = implode(',', $item); $query = "INSERT INTO `#__vm_order_item` ({$keys}) VALUES ({$values});"; $db->setQuery($query); if (!oseDB::query()) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); } $result = array(); $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText::_('Done'); return $result; }
function oseGetAppTitle($app, $id, $entry_option = null) { $db = oseDB::instance(); switch ($app) { case 'contract': $query = " SELECT * FROM `#__ose_contract_plan`" . " WHERE `id` = '{$id}'"; break; case 'msc': $query = " SELECT * FROM `#__osemsc_acl`" . " WHERE `id` = '{$id}'"; break; } $db->setQuery($query); $appItem = oseDB::loadItem('obj'); if (oseGetValue($appItem, 'parent_id', 0) > 1) { $title = oseGetAppTitle($app, $appItem->parent_id) . '-' . $appItem->title; return $title; } elseif ($app == 'msc' && oseGetVersion('com_osemsc') < 6 && !empty($entry_option)) { $query = "SELECT * FROM `#__osemsc_ext`" . " WHERE `type` = 'payment' AND `id` = '{$id}'"; $db->setQuery($query); $planPayment = oseDB::loadItem('obj'); $options = oseJSON::decode($planPayment->params, true); $option = oseGetValue($options, $entry_option, array()); $title = $appItem->title . '-' . oseGetValue($option, 'optionname', ''); return $title; } else { return $appItem->title; } }
protected function addOrderInfoFix($order_id) { $result = array(); $db = oseDB::instance(); $query = " SELECT * FROM `#__osemsc_order_fix`" . " WHERE `order_id` = '{$order_id}'"; $db->setQuery($query); $item = oseDB::loadItem('obj'); if (empty($item)) { $query = " SELECT b.*,a.entry_id,a.order_item_id" . " FROM `#__osemsc_order_item` AS a" . " INNER JOIN `#__osemsc_order` AS b ON b.order_id = a.order_id" . " WHERE a.`order_id` = '{$order_id}'"; $db->setQuery($query); $oInfo = oseDB::loadItem('obj'); $query = " SELECT * FROM `#__osemsc_member`" . " WHERE `msc_id` = '{$oInfo->entry_id}' AND `member_id`='{$oInfo->user_id}'"; $db->setQuery($query); $mItem = oseDB::loadItem('obj'); if (!empty($mItem)) { // update the order paypal status $ofVals = array(); $ofVals['order_id'] = $oInfo->order_id; $ofVals['order_item_id'] = $oInfo->order_item_id; $ofVals['member_id'] = $mItem->id; $ofVals['msc_id'] = $mItem->msc_id; $ofVals['user_id'] = $mItem->member_id; $ofVals['hasParams'] = 1; $ofVals['payment_method'] = $oInfo->payment_method; $ofVals['payment_mode'] = 'a'; $ofVals['status'] = 'updated'; $ofVals['create_date'] = oseHtml::getDateTime(); $ofVals['params'] = $oInfo->params; $user = JFactory::getUser($mItem->member_id); $ofVals['email'] = $user->email; oseDB::insert("#__osemsc_order_fix", $ofVals); } } }
public static function updateMtCat() { $result = array(); $db = oseDB::instance(); $user = JFactory::getUser(); $member_id = JRequest::getInt('member_id', 0); $cl_id = JRequest::getInt('cl_id', 0); $cat_id = JRequest::getInt('cat_id', 0); $query = " SELECT directory.* FROM `#__osemsc_directory` AS directory " . " INNER JOIN `#__oselic_cs_keys_view` AS luv ON luv.company_id = directory.company_id" . " WHERE luv.user_id = {$member_id}"; $db->setQuery($query); $item = oseDB::loadItem('obj'); $directory_id = $item->directory_id; $linkId = self::getMtLinkId($directory_id); $query = " SELECT count(*) FROM `#__mt_cl` " . " WHERE link_id = {$linkId}"; $db->setQuery($query); $main = $db->loadResult() > 0 ? 0 : 1; if (empty($cl_id)) { $query = "INSERT INTO `#__mt_cl` (link_id, cat_id, main) VALUES " . " ('{$linkId}', '{$cat_id}', '{$main}')"; } else { $query = " UPDATE `#__mt_cl` " . " SET cat_id = '{$cat_id}' " . " WHERE cl_id = '{$cl_id}'"; } $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('Fail Saving Directory Info.'); } else { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Saved Directory Info.'); } return $result; }
function getOrderItem($where = array(), $type = 'array') { $db = oseDB::instance(); $where = oseDB::implodeWhere($where); $where = str_replace('order_id', 'order_item_id', $where); $query = " SELECT * FROM `#__osemsc_order_item` " . $where . ' ORDER BY create_date DESC' . ' LIMIT 1'; $db->setQuery($query); $item = oseDB::loadItem($type); return $item; }
function refresh() { $db = oseDB::instance(); $query = " SELECT * FROM `{$this->_table}`" . " WHERE `id` = '{$this->id}'"; $db->setQuery($query); $item = oseDB::loadItem(); $this->__construct($item); }
public static function cancel($params) { $result = array(); $result['success'] = true; if(empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } unset($params['allow_work']); $member_id = $params['member_id']; $msc_id = $params['msc_id']; $user = JFactory::getUser($member_id); $db = oseDB::instance(); $query = "SELECT * FROM `#__osemsc_member`" ." WHERE `msc_id` = '{$msc_id}' AND `member_id` = '{$member_id}'" ; $db->setQuery($query); $memInfo = oseDB::loadItem('obj'); $memParams = oseJson::decode($memInfo->params,true); $order_id = $memParams['order_id']; $order_item_id = $memParams['order_item_id']; $query = " SELECT * FROM `#__osemsc_order`" ." WHERE `order_id` = '{$order_id}'" ; $db->setQuery($query); $order = oseDB::loadItem('obj'); $oParams = oseJson::decode($order->params); //$msc_option = oseObject::getValue($oParams,'msc_option'); $query = " SELECT * FROM `#__osemsc_order_item`" ." WHERE `order_id` = '{$order_id}'" ; $db->setQuery($query); $order_item = oseDB::loadItem('obj'); $iParams = oseJson::decode($order_item->params); $msc_option = $iParams->msc_option; if(oseGetValue($oParams,'isLicensee',0)) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_("Done"); return $result; } $query = " SELECT * FROM `#__osemsc_ext`" ." WHERE `id` = '{$msc_id}' AND `type` = 'oselic'" ; $db->setQuery($query); $data = oseDB::loadItem('obj'); $data = oseJson::decode($data->params); $data = oseObject::getValue($data,$msc_option,array()); if( oseObject::getValue($data,'enable_license') ) { oseRegistry :: register('user2', 'user2'); oseRegistry :: register('lic', 'lic'); oseRegistry :: register('email', 'email'); oseRegistry :: register('locale', 'locale'); $user = oseCall('user2')->instance( $member_id,'lic'); $query = " SELECT * FROM `#__oselic_type_license_key`" ." WHERE `license_id` = '{$oParams->license_id}' AND `licensee_id` > 0" ; $db->setQuery($query); $licenseKeys = oseDB::loadList('obj'); foreach($licenseKeys as $licenseKey) { if(!empty($licenseKey->licensee_id)) { switch($licenseKey->app) { case('msc'): //version oseAppConfig::load( 'mscv6' ); break; default: oseAppConfig::load($licenseKey->app); break; } $user = oseCall('user2')->instance($licenseKey->licensee_id,$licenseKey->app); $user->cancel($licenseKey->entry_id,$licenseKey->app); } else { continue; } } // delete license info oseDB::delete('#__oselic_type_license_key',array('license_id'=>$oParams->license_id)); $updated = oseDB::delete('#__oselic_type_license',array('id'=>$oParams->license_id)); } $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_("Done"); return $result; }
function getAddon($addon_id) { $db = oseDB::instance(); $query = " SELECT * FROM `#__osemsc_addon`" . " WHERE id = {$addon_id}"; $db->setQuery($query); return oseDB::loadItem(); }
function set($key, $value = null) { if ($key == 'status') { if (!is_numeric($value)) { $db = oseDB::instance(); $query = " SELECT * FROm `#__osemsc_member_status`" . " WHERE `name` = '{$value}'"; $db->setQuery($query); $item = oseDB::loadItem('obj'); parent::set($key, $item->id); } else { parent::set($key, $value); } } else { parent::set($key, $value); } }
function getEmailVariablesReceipt($order_id, $user_id = null) { $db = oseDB::instance(); $content = array(); // get Order Info $payment = oseRegistry::call('payment'); $where = array(); $where[] = "order_id = {$order_id}"; $orderInfo = $payment->getOrder($where, 'obj'); $orderInfoParams = oseJson::decode($orderInfo->params); $paymentInfo = oseMscAddon::getExtInfo($orderInfo->entry_id, 'payment', 'obj'); $member = oseRegistry::call('member'); $member->instance($orderInfo->user_id); $userInfo = $member->getBillingInfo('obj'); $userInfo->email = $userInfo->user_email; $orderInfo->subtotal = $orderInfoParams->subtotal; $orderInfo->total = $orderInfoParams->recurrence_times > 1 ? $orderInfoParams->next_total : $orderInfoParams->total; $orderInfo->discount = isset($orderInfoParams->discount) ? $orderInfoParams->discount : 0; $gw = $payment->getInstance('GateWay'); $gwInfo = $gw->getGWInfo($orderInfo->payment_method); if (!empty($gwInfo)) { if ($gwInfo->is_cc) { $orderInfo->payment_method = 'Credit Card'; } } $orderInfo->itemlist = $this->generateOrderTable($order_id, $orderInfo->user_id); if ($orderInfo->payment_mode == 'm') { $orderInfo->payment_mode = JText::_('Manual Billing'); $orderInfo->gross_tax = oseObject::getValue($orderInfoParams, 'gross_tax', '0.00'); if ($orderInfo->gross_tax > 0) { $orderInfo->vat_number = oseObject::getValue($orderInfoParams, 'vat_number'); } } else { $orderInfo->payment_mode = JText::_('Automatic Billing'); $params = oseJson::decode($orderInfo->params); $price = null; if (oseObject::getValue($orderInfoParams, 'has_trial', 0)) { if (oseObject::getValue($orderInfoParams, 'recurrence_times', 0) <= 1) { $orderInfo->gross_tax = oseObject::getValue($orderInfoParams, 'gross_tax', '0.00'); } else { $orderInfo->gross_tax = oseObject::getValue($orderInfoParams, 'next_gross_tax', '0.00'); } } else { if (oseObject::getValue($orderInfoParams, 'recurrence_times', 0) <= 2) { $orderInfo->gross_tax = oseObject::getValue($orderInfoParams, 'gross_tax', '0.00'); } else { $orderInfo->gross_tax = oseObject::getValue($orderInfoParams, 'next_gross_tax', '0.00'); } } $orderInfo->vat_number = oseObject::getValue($orderInfoParams, 'vat_number'); $orderInfo->recurring_price = $orderInfo->payment_currency . ' ' . $orderInfoParams->next_total; $orderInfo->recurring_frequency = $orderInfoParams->p3 . ' ' . $orderInfoParams->t3; } $query = "SELECT entry_id FROM `#__osemsc_order_item` WHERE `order_id` = " . $order_id; $db->setQuery($query); $msc_id = $db->loadResult(); $query = " SELECT *,DATE_SUB(`expired_date`,INTERVAL 1 DAY) AS `real_expired_date` " . " FROM `#__osemsc_member`" . " WHERE member_id = {$orderInfo->user_id} AND msc_id={$msc_id}"; $db->setQuery($query); $memberInfo = oseDB::loadItem('obj'); $query = "SELECT * FROM `#__osemsc_acl` WHERE `id` = {$msc_id}"; $db->setQuery($query); $mscInfo = oseDB::loadItem('obj'); $memberInfo->msc_title = $mscInfo->title; $memberInfo->msc_des = $mscInfo->description; $orderInfo->current_date = oseHTML::getDateTime(); $globalConfig = oseRegistry::call('msc')->getConfig('global', 'obj'); if (!empty($globalConfig->DateFormat)) { $memberInfo->start_date = date($globalConfig->DateFormat, strtotime($memberInfo->start_date)); $orderInfo->create_date = date($globalConfig->DateFormat, strtotime($orderInfo->create_date)); $orderInfo->current_date = date($globalConfig->DateFormat, strtotime($orderInfo->current_date)); } $content['user'] = $userInfo; $content['order'] = $orderInfo; $content['profile'] = $member->getProfile(); $content['member'] = $memberInfo; return $content; }
public static function save($params = array()) { $db = oseDB::instance(); $result = array(); $post = JRequest::get('post'); $id = JRequest::getCmd('id', null); $msc_id = JRequest::getInt('msc_id', 0); if (empty($id)) { $id = uniqid(); } $extItem = oseRegistry::call('msc')->getExtInfoItem($msc_id, 'payment', 'obj'); $extItem->params = empty($extItem->params) ? '{}' : $extItem->params; $items = oseJson::decode($extItem->params, true); if (empty($post['payment_has_trial'])) { $post['payment_has_trial'] = 0; } if (empty($post['payment_eternal'])) { $post['payment_eternal'] = 0; } else { $post['payment_p1'] = 0; $post['payment_p3'] = 0; } if (empty($post['payment_isFree'])) { $post['payment_isFree'] = 0; } if (empty($post['payment_a3'])) { $post['payment_a3'] = 0; } if (empty($post['payment_p3'])) { $post['payment_p3'] = 0; } if (empty($post['payment_t3'])) { $post['payment_t3'] = 'day'; } if (empty($post['payment_start_date'])) { $post['payment_start_date'] = 0; } // check form value if ($post['payment_isFree'] == 0 && $post['payment_a3'] == 0) { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('PLEASE_SET_THE_PRICE'); return $result; } if ($post['payment_isFree'] == 1 && ($post['payment_p3'] == 0 && $post['payment_start_date'] == 0 && $post['payment_eternal'] != 1)) { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('PLEASE_SELECT_ONE_MODE_TO_SET_BILLING_PERIOD'); return $result; } if ($post['payment_eternal'] == 1 && ($post['payment_a3'] == 0 && $post['payment_isFree'] == 0)) { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('PLEASE_SET_THE_PRICE_IN_THE_RECURRENCE_MODE_FOR_THE_MEMBERSHIP_OR_SET_IT_FOR_FREE'); return $result; } // end if (empty($post['payment_optionname'])) { if ($post['payment_recurrence_mode'] == 'period') { if (oseObject::getValue($post, 'payment_eternal', false)) { if (oseObject::getValue($post, 'payment_isFree', false)) { $post['payment_optionname'] = JText::_('LIFETIME_FREE_MEMBERSHIP'); //JText::_('LIFETIME_FREE_MEMBERSHIP'); } else { $post['payment_optionname'] = JText::_('LIFETIME_MEMBERSHIP'); //JText::_('LIFETIME_FREE_MEMBERSHIP'); } } else { $post['payment_optionname'] = $post['payment_p3'] == 1 ? $post['payment_p3'] . "-" . $post['payment_t3'] : $post['payment_p3'] . "-" . $post['payment_t3'] . "s"; if (oseObject::getValue($post, 'payment_isFree', false)) { $post['payment_optionname'] .= ' ' . JText::_('FREE_MEMBERSHIP'); //JText::_('LIFETIME_FREE_MEMBERSHIP'); } else { $post['payment_optionname'] .= ' ' . JText::_('PAID_MEMBERSHIP'); } } } else { $post['payment_optionname'] = $post['payment_start_date'] . ' - ' . $post['payment_expired_date']; if (oseObject::getValue($post, 'payment_isFree', false)) { $post['payment_optionname'] .= ' ' . JText::_('FREE_MEMBERSHIP'); //JText::_('LIFETIME_FREE_MEMBERSHIP'); } else { $post['payment_optionname'] .= ' ' . JText::_('PAID_MEMBERSHIP'); } } $post['payment_optionname'] = ucwords(strtolower($post['payment_optionname'])); /*if($post['payment_recurrence_mode'] == 'period') { if ($post['payment_eternal']==true) { $post['optionname'] = JText::_("Lifetime"); } else { $post['optionname'] = ($post['payment_p3']==1)?$post['payment_p3']."-".$post['payment_t3']:$post['payment_p3']."-".$post['payment_t3']."s"; } } else { $post['optionname'] = $post['payment_start_date'].' - '.$post['payment_expired_date']; }*/ } $post['payment_payment_mode'] = oseRegistry::call('msc')->getConfig('global', 'obj')->payment_mode; $post['payment_price'] = $post['payment_a3']; $post['payment_recurrence_num'] = $post['payment_p3']; $post['payment_recurrence_unit'] = $post['payment_t3']; $where = array(); $msc_id = isset($msc_id) ? $msc_id : null; if (empty($msc_id)) { return false; // No membership exists in the addon } else { unset($post['msc_id']); $where[] = 'id = ' . $db->Quote($msc_id); } $where[] = 'type = ' . $db->Quote('payment'); $params = array(); $prefix = 'payment_'; foreach ($post as $key => $value) { if (strstr($key, $prefix)) { $newKey = preg_replace("/{$prefix}/", '', $key, 1); $params[$newKey] = $value; } } ksort($params); /* if($id < 0) { $items[] = $params; } else { $items[$id] = $params; } */ $params['id'] = $id; $items[$id] = $params; $i = 1; foreach ($items as $key => $item) { if (!oseObject::getValue($item, 'ordering', 0)) { $item = oseObject::setValue($item, 'ordering', $i); $items[$key] = $item; } else { $items[$key] = $item; } //$item = oseObject::setValue($item,'ordering',1); $i++; } //oseExit($items); //oseExit($items); $newParams = $db->Quote(oseJson::encode($items)); $where = oseDB::implodeWhere($where); $query = " SELECT * FROM `#__osemsc_ext` " . $where; $db->setQuery($query); $obj = oseDB::loadItem('obj'); if (empty($obj)) { $query = " INSERT INTO `#__osemsc_ext` " . " (id,type,params)" . " VALUES " . " ({$msc_id}," . $db->Quote('payment') . ",{$newParams}) "; $db->setQuery($query); //oseExit($db->_sql); } else { $query = " UPDATE `#__osemsc_ext` " . " SET " . " params = {$newParams} " . " WHERE id = {$obj->id}" . " AND type = " . $db->Quote('payment'); $db->setQuery($query); } if (oseDB::query()) { $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('SAVE_SUCCESSFULLY'); //oseMscHelper::generatePlanJs(); } else { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('ERROR_IN_SAVING_MSC_PARAMETERS'); } return $result; }
public static function save($params) { $now = oseHTML::getDateTime(); $result = array(); $result['success'] = true; if(empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } unset($params['allow_work']); if($params['join_from'] != 'payment') { $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText::_("Done"); return $result; } $post = JRequest::get('post'); $member_id = $params['member_id']; $db = oseDB::instance(); $user = JFactory::getUser(); $query = " SELECT * FROM `#__oselic_cs_keys_view`" ." WHERE user_id = {$member_id}" ; $db->setQuery($query); $item = oseDB::loadItem('obj'); $company_id = $item->company_id; //oseExit($company); $query = " SELECT eternal, expired_date FROM `#__osemsc_member`" ." WHERE member_id = {$member_id}" ; $db->setQuery($query); $obj = $db->loadObject(); $publish_down = empty($obj->eternal)?$obj->expired_date:'0000-00-00 00:00:00'; $query = " SELECT directory_id FROM `#__osemsc_directory`" ." WHERE company_id = {$company_id}" ; $db->setQuery($query); $directory_id = $db->loadResult(); if (empty ($directory_id)) { $query = " INSERT INTO `#__mt_links` (user_id,link_published,link_approved,link_created,publish_down) VALUES ('{$member_id}','1','1','{$now}', '$publish_down')"; $db->setQuery($query); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } $newMtLinkID = $db->insertid(); //Insert the image $query = " SELECT cf_id FROM `#__mt_customfields`" ." WHERE caption = 'Image' AND field_type = 'image'"; $db->setQuery($query); $cf_id = $db->loadResult(); $query = " INSERT INTO `#__mt_cfvalues` (cf_id, link_id) VALUES ('{$cf_id}', '{$newMtLinkID}')"; $db->setQuery($query); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } $query = " INSERT INTO `#__mt_cfvalues_att` (cf_id, link_id) VALUES ('{$cf_id}', '{$newMtLinkID}')"; $db->setQuery($query); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } $query = " INSERT INTO `#__osemsc_directory` (company_id) VALUES ({$company_id})"; $db->setQuery($query); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } $newDirID = $db->insertid(); $query = " INSERT INTO `#__osemsc_mtrel` (link_id,directory_id) " ." VALUES ('{$newMtLinkID}','{$newDirID}')" ; $db->setQuery($query); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText::_('Joined Directory.'); } else { $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText::_('Joined Directory.'); } //echo $query;exit; return $result; }
public static function cancel($params) { $result = array(); $result['success'] = true; if(empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } unset($params['allow_work']); $db = oseDB::instance(); $msc_id =$params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = $params['order_item_id']; $query = " SELECT * FROM `#__osemsc_order_item`" ." WHERE `order_id` = '{$order_id}'" ; $db->setQuery($query); $order_item = oseDB::loadItem('obj'); $iParams = oseJson::decode($order_item->params); $msc_option = $iParams->msc_option; // get the list id of msc $query = "SELECT * FROM `#__osemsc_ext` WHERE `id` = '{$msc_id}' AND `type` = 'acymailing2'"; $db->setQuery($query); $data = $db->loadObject(); $data = oseJson::decode($data->params); $data = oseObject::getValue($data,$msc_option,array()); $listid = oseObject::getValue($data,'listid'); if(empty($listid)) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_("Done"); return $result; } if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_acymailing'.DS.'helpers'.DS.'helper.php')){ $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_("This plugin can not work without the AcyMailing Component"); return $result; } // delete member in mail list $userClass = acymailing::get('class.subscriber'); $newSubscription = array(); $newList = null; $newList['status'] = 0; $newSubscription[$listid] = $newList; $subid = $userClass->subid($member_id); if(!empty($subid)) { $userClass->saveSubscription($subid,$newSubscription); } return $result; }