public static function create() { $msc_id = JRequest::getInt('msc_id', null); if (empty($msc_id)) { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('ERROR'); return $result; } $mscItem = oseRegistry::call("msc")->getInfo($msc_id, $type = 'array'); if (empty($mscItem)) { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('ERROR'); return $result; } $db = oseDB::instance(); $query = " SELECT `shopper_group_id` FROM `#__vm_shopper_group` " . " WHERE `shopper_group_name` = " . $db->Quote($mscItem['title']); $db->setQuery($query); $items = oseDB::loadList(); if (empty($items)) { $query = " INSERT INTO `#__vm_shopper_group` (`shopper_group_id`, `vendor_id`, `shopper_group_name`, `shopper_group_desc`, `shopper_group_discount`, `show_price_including_tax`, `default`) VALUES (NULL, 1, " . $db->Quote($mscItem['title']) . ", " . $db->Quote($mscItem['title']) . ", 0.00, 1, 0);"; $db->setQuery($query); if (!$db->query()) { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = $db->getErrorMsg(); return $result; } } $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('SAVE_SUCCESSFULLY'); return $result; }
public static function save($params) { $result = array(); $post = JRequest::get('post'); $member_id = $params['member_id']; JRequest::setVar('member_id', $member_id); if (empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); return $result; } $db = oseDB::instance(); $firstname = $db->Quote(oseObject::getValue($post, 'juser_firstname', $post['juser_username'])); $lastname = $db->Quote(oseObject::getValue($post, 'juser_lastname')); $query = " SELECT COUNT(*) FROM `#__osemsc_userinfo` WHERE user_id = ". (int)$member_id; $db->setQuery($query); $exists = ($db->loadResult() > 0) ? true : false; if ($exists) { return array('success' => true); } else { $query = " INSERT INTO `#__osemsc_userinfo` (user_id,firstname,lastname)" . " VALUES" . " ({$member_id},{$firstname},{$lastname})"; $db->setQuery($query); if (!oseDB::query()) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Fail Saving OSE User Info.'); return $result; } return array('success' => true); } }
public static function activate($params) { $result = array(); $result['success'] = true; if (empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Renew.History'); return $result; } unset($params['allow_work']); $db = oseDB::instance(); $post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $result = array(); $result['success'] = true; if (empty($msc_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_(" History Error "); return $result; } $history = oseRegistry::call('member')->getInstance('History'); if (!$history->record($msc_id, $member_id, 'activate')) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_(" Fail Record Member's Footprint! "); } return $result; }
public static function getMSCs() { $my = JFactory::getUser(); $member_id = $my->id; $result = array(); $db= oseDB :: instance(); $query= " SELECT acl.id, acl.title FROM `#__osemsc_member_history` AS omh" ." INNER JOIN `#__osemsc_acl` AS acl" ." ON omh.`msc_id` = acl.`id`" ." WHERE omh.`member_id` = '{$member_id}'" ." GROUP BY acl.`id`"; $db->setQuery($query); $items = oseDB :: loadList(); if(count($items) < 1) { $result['total'] = 0; $result['results'] = ''; }else { $result['total'] = count($items); $result['results'] = $items; } $result = oseJson :: encode($result); oseExit($result); }
function generateDesc($order_id) { $title = null; $db = oseDB::instance(); $query = "SELECT * FROM `#__osemsc_order_item` WHERE `order_id` = '{$order_id}'"; $db->setQuery($query); $obj = $db->loadObject(); $params = oseJson::decode($obj->params); $msc_id = $obj->entry_id; $query = "SELECT title FROM `#__osemsc_acl` WHERE `id` = " . (int) $msc_id; $db->setQuery($query); $msc_name = $db->loadResult(); $msc_option = $params->msc_option; $query = "SELECT params FROM `#__osemsc_ext` WHERE `type` = 'payment' AND `id` = " . (int) $msc_id; $db->setQuery($query); $result = oseJson::decode($db->loadResult()); foreach ($result as $key => $value) { if ($msc_option == $key) { if ($value->recurrence_mode == 'period') { if ($value->eternal) { $title = 'Life Time Membership'; } else { $title = $value->recurrence_num . ' ' . ucfirst($value->recurrence_unit) . ' Membership'; } } else { $start_date = date("l,d F Y", strtotime($value->start_date)); $expired_date = date("l,d F Y", strtotime($value->expired_date)); $title = $start_date . ' - ' . $expired_date . ' Membership'; } } } $title = $msc_name . ' : ' . $title; return $title; }
function getLangID($lang) { $db = oseDB::instance(); $query = "SELECT id FROM `#__languages` WHERE `code` = " . $db->Quote($lang, true) . " OR `shortcode` = " . $db->Quote($lang, true); $id = $db->loadResult(); return $id; }
public function getMemlist() { $search = JRequest::getString('search', null); $start = JRequest::getInt('start', 0); $limit = JRequest::getInt('limit', 20); $msc_id = JRequest::getInt('msc'); $status = JRequest::getVar('status'); $db = oseDB::instance(); $where = array(); $where[] = ' m.msc_id = ' . $msc_id; if (isset($status) && $status != 'all') { $where[] = ' m.status = ' . $status; } if (!empty($search)) { $searchQuery = $db->Quote('%' . $search . '%'); $where[] = "m.username LIKE {$searchQuery} OR m.name LIKE {$searchQuery} OR m.email LIKE {$searchQuery}"; } $where = oseDB::implodeWhere($where); $query = " SELECT COUNT(*) " . " FROM `#__osemsc_member_view` AS m " . " INNER JOIN `#__osemsc_billinginfo` AS b ON m.member_id = b.user_id" . $where; $db->setQuery($query); $total = $db->loadResult(); $query = " SELECT * " . " FROM `#__osemsc_member_view` AS m " . " INNER JOIN `#__osemsc_billinginfo` AS b ON m.member_id = b.user_id" . $where; $db->setQuery($query, $start, $limit); $items = oseDB::loadList(); $result = array(); $result['total'] = $total; $result['results'] = $items; 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']; $msc = oseRegistry::call('msc'); $member = oseRegistry::call('member'); $payment = oseRegistry::call('payment'); $ext = $msc->getExtInfo($msc_id, 'msc', 'obj'); $member->instance($member_id); $userInfo = $member->getBasicInfo('obj'); $member = oseRegistry::call('member'); $email = $member->getInstance('email'); $emailTempDetail = $email->getDoc($ext->cancel_email, 'obj'); $variables = $email->getEmailVariablesCancel($member_id, $msc_id); $emailParams = $email->buildEmailParams($emailTempDetail->type); $emailDetail = $email->transEmail($emailTempDetail, $variables, $emailParams); $email->sendEmail($emailDetail, $userInfo->email); $emailConfig = oseMscConfig::getConfig('email', 'obj'); if ($emailConfig->sendWel2Admin) { $email->sendToAdminGroup($emailDetail, $emailConfig->admin_group); } return $result; }
function getloginRedirect($msc_id) { $db = oseDB::instance(); oseDB::lock('#__menu'); $objs = array(); $where = array(); //$where = array_merge($where,oseJSON::generateQueryWhere()); // Added in V 4.4, menu access levels //$where[] = 'm.menutype = '.$db->Quote($menutype); $where[] = 'm.published != -2'; $where[] = 'm.client_id = 0'; $where = count($where) ? ' WHERE (' . implode(') AND (', $where) . ')' : ''; $query = 'SELECT m.*, com.name AS com_name' . ' FROM `#__menu` AS m' . ' LEFT JOIN `#__extensions` AS com ON com.extension_id = m.component_id' . $where . ' ORDER BY m.lft'; $db->setQuery($query); //oseExit($db->getQuery()); $menus = $db->loadObjectList(); $i = 0; if (!empty($menus)) { foreach ($menus as $menu) { $objs[$i]->menuid = $menu->id; $objs[$i]->displayText = str_repeat('<span class="gtr">|—</span>', $menu->level) . '[ID-' . $menu->id . ']-' . $menu->title; $i++; } } oseDB::unlock(); return $objs; }
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; }
public static function save($app = 'msc', $config_type, $vals) { $db = oseDB::instance(); $config = self::load($app, $config_type, 'obj'); $updated = true; foreach ($vals as $k => $v) { $where = array(); $where[] = '`app`=' . $db->Quote($app); $where[] = '`type`=' . $db->Quote($config_type); $where[] = '`key`=' . $db->Quote($k); $where = oseDB::implodeWhere($where); $query = " SELECT COUNT(id) FROM `#__ose_app_config`" . $where; $db->setQuery($query); $total = $db->loadResult(); if ($total > 0) { $iVals = array(); $iVals['id'] = $total; $iVals['value'] = $v; $updated = oseDB::update('#__ose_app_config', 'id', $iVals); } else { $iVals = array(); $iVals['app'] = $app; $iVals['type'] = $config_type; $iVals['key'] = $k; $iVals['value'] = $v; $updated = oseDB::insert('#__ose_app_config', $iVals); } } return $updated; }
function getList() { $db = oseDB::instance(); $query = 'SELECT * FROM `#__groups` AS a ORDER by a.id ASC'; $db->setQuery($query); $results = oseDB::loadList(); return $results; }
public static function save($params) { $result = array(); $result['success'] = true; if (empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Order.1'); return $result; } unset($params['allow_work']); if ($params['join_from'] != 'payment') { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done Join.Order'); return $result; } $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']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where, 'obj'); $member = oseRegistry::call('member'); $member->instance($member_id); $memParams = $member->getMemberInfo($msc_id, 'obj')->memParams; if (empty($memParams)) { $memParams = new stdClass(); } else { $memParams = oseJSON::decode($memParams); } $memParams->order_id = $order_id; $memParams->payment_mode = $curOrder->payment_mode; $memParams->order_item_id = $order_item_id; // Order problem for system add $memParams = oseJSON::encode($memParams); $query = " UPDATE `#__osemsc_member`" . " SET `params` = " . $db->Quote($memParams) . " WHERE msc_id = {$msc_id} AND member_id = {$member_id}"; $memConfig = oseMscConfig::getConfig('register', 'obj'); $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Order.2'); } // User activation function; $params = JComponentHelper::getParams('com_users'); $useractivation = $params->get('useractivation'); if (oseObject::getValue($memConfig, 'disabled_non_paid', false) == true) { if ($useractivation == 0) { $query = " UPDATE `#__users` SET `block` = 0 where `id` = " . $member_id; $db->setQuery($query); $db->query(); } } return $result; }
public static function activate($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']); //oseExit($params); $db = oseDB::instance(); $post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; if (empty($msc_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Renew Msc: No Msc ID"); return $result; } // get the docman groups_id of msc $query = "SELECT * FROM `#__osemsc_ext` WHERE `id` = '{$msc_id}' AND `type` = 'docman'"; $db->setQuery($query); $data = $db->loadObject(); $data = oseJson::decode($data->params); if (empty($data->groups_id) || $data->groups_id == '-1') { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_("Done"); return $result; } $docman_group_id = $data->groups_id; $query = "SELECT * FROM `#__docman_groups` WHERE `groups_id` = " . (int) $docman_group_id; $db->setQuery($query); $obj = $db->loadObject(); if (!empty($obj)) { $newmembers[] = $member_id; if (!empty($obj->groups_members)) { $oldmembers = explode(",", $obj->groups_members); if (count($oldmembers) > 0) { $newmembers = array_merge($oldmembers, $newmembers); } } $newmembers = array_unique($newmembers); $newmembers = implode(",", $newmembers); $query = "UPDATE `#__docman_groups` SET `groups_members` = '" . $newmembers . "' WHERE `groups_id` = " . (int) $docman_group_id; $db->setQuery($query); if (!$db->query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } } return $result; }
public static function renew($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']); //oseExit($params); $db = oseDB::instance(); $post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; if (empty($msc_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Renew Msc: No Msc ID"); return $result; } // get the plan id of msc $query = "SELECT * FROM `#__osemsc_ext` WHERE `id` = '{$msc_id}' AND `type` = 'osecredit'"; $db->setQuery($query); $data = $db->loadObject(); $data = oseJson::decode($data->params); if (empty($data->osecredit_id) || empty($data->enable)) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_("Done"); return $result; } $query = "SELECT credit_amount FROM `#__ose_credit_plan` WHERE `id` = '{$data->osecredit_id}'"; $db->setQuery($query); $amount = $db->loadResult(); $query = "SELECT * FROM `#__ose_credit_member` WHERE `member_id` = '{$member_id}'"; $db->setQuery($query); $obj = $db->loadObject(); if (empty($obj)) { $credit_params = oseJson::encode(array()); $query = " INSERT INTO `#__ose_credit_member` (`member_id`, `credit_amount`, `params`)" . " VALUES" . " ('{$member_id}', '{$amount}', '{$credit_params}')"; } else { $amount = $amount + $obj->credit_amount; $query = "UPDATE `#__ose_credit_member` SET `credit_amount` = '{$amount}' WHERE `id` = '{$obj->id}'"; } $db->setQuery($query); if (!$db->query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); return $result; } $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_("Done"); 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]; }
public static function getUserInfo($member_id) { //@todo : change to load msc addon if no expired date if order mistake $db = oseDB::instance(); $query = "SELECT * FROM `#__users` " . " WHERE `id` = '{$member_id}'"; $db->setQuery($query); $obj = $db->loadObject(); return $obj; }
function PayFastOneOffPostForm($orderInfo, $params = array()) { $pConfig = oseMscConfig::getConfig('payment', 'obj'); $merchantId = $pConfig->payfast_merchant_id; $merchantKey = $pConfig->payfast_merchant_key; $html = array(); $test_mode = $pConfig->payfast_testmode; if (!$test_mode) { if (empty($merchantId) || empty($merchantKey)) { $html['form'] = ""; $html['url'] = ""; return $html; } } if ($test_mode == true) { $merchantId = '10000100'; $merchantKey = '46f0cd694581a'; $url = "https://sandbox.payfast.co.za/eng/process"; } else { $url = "https://www.payfast.co.za/eng/process"; } $db = oseDB::instance(); $member = oseRegistry::call('member'); $member->instance($orderInfo->user_id); $payment = oseRegistry::call('payment'); $paymentOrder = $payment->getInstance('Order'); $billinginfo = $paymentOrder->getBillingInfo($orderInfo->user_id); $amount = $orderInfo->payment_price; $currency = $orderInfo->payment_currency; $order_id = $orderInfo->order_id; $order_number = $orderInfo->order_number; $user =& JFactory::getUser($orderInfo->user_id); $orderInfoParams = oseJson::decode($orderInfo->params); $cancelUrl = JURI::base() . "index.php"; $notifyUrl = JURI::base() . "components/com_osemsc/ipn/payfast_notify.php"; $returnUrl = urldecode(JROUTE::_(JURI::base() . "index.php?option=com_osemsc&view=thankyou&order_id=" . $orderInfo->order_id)); $returnUrl = $returnUrl ? $returnUrl : JURI::base() . "index.php?option=com_osemsc&view=member&result=success&amount={$amount}&ordernumber={$order_number}"; // Create description $description = ''; $vendor_image_url = ""; $app =& JFactory::getApplication(); $currentSession = JSession::getInstance('none', array()); $stores = $currentSession->getStores(); $html['form'] = '<form action="' . $url . '" method="post">'; // Construct variables for post $post_variables = array('merchant_id' => $merchantId, 'merchant_key' => $merchantKey, 'return_url' => $returnUrl, 'cancel_url' => $cancelUrl, 'notify_url' => $notifyUrl, 'name_first' => substr($billinginfo->firstname, 0, 100), 'name_last' => substr($billinginfo->lastname, 0, 100), 'email_address' => substr($billinginfo->email, 0, 255), 'item_name' => JText::_('Order ID: ') . $order_id, 'item_description' => $description, 'amount' => number_format($amount, 2, '.', ''), 'm_payment_id' => $order_id, 'currency_code' => $currency, 'custom_str1' => $order_number, 'user_agent' => 'Open Source Membership Control V5'); $html['form'] .= '<input type="image" id="payfast_image" name="cartImage" src="' . "components/com_osemsc/assets/images/checkout.png" . '" alt="' . JText::_('Click to pay with PayFast') . '" />'; // Process payment variables; $html['url'] = $url . "?"; foreach ($post_variables as $name => $value) { $html['form'] .= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" />'; $html['url'] .= $name . "=" . urlencode($value) . "&"; } $html['form'] .= '</form>'; return $html; }
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']; $user = new JUser($member_id); $iAmSuperAdmin = $user->authorise('core.admin'); if ($iAmSuperAdmin) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_("Done"); return $result; } $db = oseDB::instance(); $query = "SELECT * FROM `#__extensions` WHERE `name` = 'com_users' AND `type` = 'component'"; $db->setQuery($query); $data = $db->loadObject(); $data = oseJson::decode($data->params); $group['groups'] = (array) $data->new_usertype; $member = oseRegistry::call('member'); $member->instance($member_id); $Mscs = $member->getAllOwnedMsc(false, 1, 'obj'); foreach ($Mscs as $Msc) { if ($Msc->msc_id == $params['msc_id']) { continue; } $query = "SELECT * FROM `#__osemsc_ext` WHERE `id` = '{$Msc->msc_id}' AND `type` = 'jgroup'"; $db->setQuery($query); $ext = $db->loadObject(); if (!empty($ext)) { $ext = oseJson::decode($ext->params); $group['groups'] = array_merge($group['groups'], (array) $ext->jgroup_id); } } $group['groups'] = array_unique($group['groups']); //$user = JUser::getInstance($member_id); $user->bind($group); //$user->groups = array_flip($data->jgroup_id); if (!$user->save()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_("Done"); return $result; }
function orderView() { $db = oseDB::instance(); $order_id = JRequest::getInt('order_id', 0); $where = array(); $where[] = " `order_id` = {$order_id}"; $orderInfo = oseRegistry::call('payment')->getOrder($where, 'obj'); $receipt = oseRegistry::call('member')->getReceipt($orderInfo); return $receipt; }
function getTree() { $db = oseDB::instance(); $msc = oseRegistry::call('msc'); $list = $msc->retrieveTree(); foreach ($list as $key => $item) { $list[$key]['displayText'] = '(' . $item['id'] . ') ' . $item['treename']; } return $list; }
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; }
public static function companySave($params) { if (empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Error"); return $result; } unset($params['allow_work']); $db = oseDB::instance(); $post = JRequest::get('post'); $member_id = $params['member_id']; if (empty($member_id)) { return false; } $query = " SELECT username FROM `#__users` WHERE `id` = '{$member_id}'"; $db->setQuery($query); $username = $db->loadResult(); $company = array(); foreach ($post as $key => $value) { if (strstr($key, 'company_')) { $billKey = preg_replace('/company_/', '', $key, 1); $company[$billKey] = $value; } } //get the country name $query = " SELECT country_name FROM `#__osemsc_country` WHERE `country_2_code` = '{$company['country']}'"; $db->setQuery($query); $country_name = $db->loadResult(); $company['country'] = empty($country_name) ? $company['country'] : $country_name; $phpbb_class = dirname(__FILE__) . DS . 'phpbb.php'; require_once $phpbb_class; $phpbb = new phpbbdb(); $check = $phpbb->connect_phpbb(); if ($check == false) { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Fail Connecting PHPBB.'); return $result; } /************************************************************************************/ $phpbb_query = "SELECT user_id FROM `#__users` WHERE `username` = '{$username}' "; $phpbb->setQuery($phpbb_query); //$db->setQuery($phpbb->query); $user_id = $phpbb->loadResult(); $query = " UPDATE `#__profile_fields_data` " . " SET `pf_company` = '{$company['company']}', `pf_address1` = '{$company['addr1']}', `pf_address2` = '{$company['addr2']}', `pf_city` = '{$company['city']}', `pf_state` = '{$company['state']}', `pf_country` = '{$company['country']}', `pf_zip` = '{$company['postcode']}', `pf_phone` = '{$company['telephone']}' " . " WHERE `user_id` = '{$user_id}'"; $phpbb->setQuery($query); $phpbb->query(); $result = array(); $result['success'] = true; $result['title'] = 'Done'; $result['content'] = JText::_('Saved Company Info.'); return $result; }
public static function renew($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(); //$post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; if (empty($msc_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_("Join Msc: No Msc ID"); return $result; } // get the sobi2 credit of msc $query = "SELECT * FROM `#__osemsc_ext` WHERE `id` = '{$msc_id}' AND `type` = 'sobi2credit'"; $db->setQuery($query); $data = $db->loadObject(); $data = oseJson::decode($data->params); if (empty($data->credit)) { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_("Done"); return $result; } $query = "SELECT * FROM `#__osemsc_credit` WHERE `member_id` = '{$member_id}'"; $db->setQuery($query); $obj = $db->loadObject(); if (empty($obj)) { $query = " INSERT INTO `#__osemsc_credit`" . " (`member_id`, `credit`, `recharge_times`, `total_consume_amout`)" . " VALUES" . " ('{$member_id}', '{$data->credit}', '0', '0')"; } else { $credit = $obj->credit + $data->credit; $recharge_times = $obj->recharge_times + 1; $query = "UPDATE `#__osemsc_credit` SET `credit` = '{$credit}', `recharge_times` = '{$recharge_times}' WHERE `member_id` = '{$member_id}'"; } $db->setQuery($query); if (!$db->query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error'); return $result; } $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_("Done"); return $result; }
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; }
public static function save($params) { $result = array(); $result['success'] = true; //oseExit($params); if (empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Idev'); return $result; } unset($params['allow_work']); if ($params['join_from'] != 'payment') { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done Join.Order'); return $result; } $oseMscConfig = oseRegistry::call('msc')->getConfig('thirdparty', 'obj'); if (empty($oseMscConfig->idev_enable)) { return $result; } if (empty($oseMscConfig->idev_url)) { return $result; } $db = oseDB::instance(); //$post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = $params['order_item_id']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where, 'obj'); $curOrderParams = oseJson::decode($curOrder->params); $member = oseRegistry::call('member'); $member->instance($member_id); $userInfo = $member->getUserInfo('obj'); $memParams = $member->getMemberInfo($msc_id, 'obj')->memParams; $memParams = oseJSON::decode($memParams); $memParams->first_ip = $curOrderParams->first_ip; try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $oseMscConfig->idev_url . "/sale.php?profile=72198&idev_saleamt={$curOrder->payment_price}&idev_ordernum={$order_id}&ip_address={$memParams->first_ip}"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); curl_close($ch); return $result; } catch (Exception $e) { return $result; } }
function changeStatus() { $db = oseDB::instance(); $msc_id = JRequest::getInt('msc_id', 0); $catids = JRequest::getVar('catids', array()); $newStatus = JRequest::getInt('status', 0); $content = oseRegistry::call('content')->getInstance('msc'); $contentIds = array(); foreach ($catids as $catid) { $contentIds[] = $catid; $query = "SELECT * FROM `#__rokdownloads` WHERE `id` = '{$catid}'"; $db->setQuery($query); $node = $db->loadObject(); $query = "SELECT * FROM `#__rokdownloads` WHERE lft >= '{$node->lft}' and rgt <= '{$node->rgt}' AND `folder` = '1'"; $db->setQuery($query); $objs = $db->loadObjectList(); foreach ($objs as $obj) { $contentIds[] = $obj->id; } } $contentIds = array_unique($contentIds); foreach ($contentIds as $content_id) { $item = $content->getItem('rokdownload', 'category', $content_id, 'msc', $msc_id, '', 'obj'); if (empty($item)) { $updated = $content->insert('rokdownload', 'category', $content_id, 'msc', $msc_id, $newStatus); if (!$updated) { $result = array(); $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_('ERROR'); return $result; } } else { $status = $item->status; if ($status != $newStatus) { $updated = $content->update($item, $newStatus); 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 __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); } }
public static function archive($msc_id, $member_id, $action) { $db = oseDB::instance(); $date = oseHTML::getDateTime(); $date = $db->Quote($date); $query = " INSERT INTO `#__osemsc_member_history` " . " (`msc_id`,`member_id`,`action`,`date`, `accumulated`) " . " VALUES " . " ({$msc_id},{$member_id},'{$action}',{$date}, '0') "; $db->setQuery($query); if (oseDB::query()) { return $db->insertid(); } else { return false; } }