Ejemplo n.º 1
0
 public function getList($type, $backend = false)
 {
     $db = oseDB::instance();
     $where = array();
     if ('member' == substr($type, 0, 6)) {
         $where[] = "a.`type` LIKE 'member_%'";
     } else {
         $where[] = "a.`type` = " . $db->Quote($type);
     }
     $where[] = "b.`enabled` = 1 ";
     $where = oseDB::implodeWhere($where);
     $query = " SELECT a.*,b.enabled,b.custom,b.backend AS custom_backend, b.backend_enabled AS custom_backend_enabled,b.frontend AS custom_frontend, b.frontend_enabled AS custom_frontend_enabled" . " FROM `#__osemsc_addon` AS a" . " INNER JOIN `#__osemsc_addon_applied` AS b ON b.addon_id =a.id" . $where;
     $db->setQuery($query);
     $types = oseDB::loadList('array', 'name');
     foreach ($types as $key => $type) {
         $valid = $this->authorize($type['type'], $type['name'], $backend);
         if (!$valid) {
             unset($types[$key]);
             continue;
         }
         if ($type['custom']) {
             $type['backend'] = $type['custom_backend'];
             $type['frontend'] = $type['custom_frontend'];
             $type['backend_enabled'] = $type['custom_backend_enabled'];
             $type['frontend_enabled'] = $type['custom_frontend_enabled'];
         }
         if ($type['action'] == 1) {
             $type['action'] = "{$type['type']}.{$type['name']}";
         }
         $types[$key] = $type;
     }
     //$types = array_values($types);
     return $types;
 }
Ejemplo n.º 2
0
	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;
	}
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 function sendToGroup($email, $group, $force2Send = false)
 {
     $db = oseDB::instance();
     $version = oseHTML::getJoomlaVersion();
     if (is_array($group)) {
         $group = implode(',', $group);
     }
     $where = array();
     if (!$force2Send) {
         $where[] = "`sendEmail` =1";
     }
     if ($version == '1.5') {
         $where[] = "`gid` IN ( {$group} )";
         $where = oseDB::implodeWhere($where);
         $query = " SELECT * FROM `#__users` AS u " . $where;
     } else {
         $where[] = "g.group_id IN ( {$group} )";
         $where = oseDB::implodeWhere($where);
         $query = " SELECT u.* FROM `#__users` AS u " . " INNER JOIN `#__user_usergroup_map` AS g ON g.user_id = u.id" . $where;
     }
     $db->setQuery($query);
     $objs = oseDB::loadList('obj');
     foreach ($objs as $obj) {
         self::sendEmail($email, $obj->email);
     }
     return true;
 }
Ejemplo n.º 5
0
 function getMap()
 {
     // get License
     $db = oseDB::instance();
     // active
     $where = array();
     $where[] = "`member_id` = '{$this->user_id}'";
     $where[] = "`status` = 1";
     $where = oseDB::implodeWhere($where);
     $query = " SELECT * FROM `{$this->_table}`" . $where . " ORDER BY `id` ASC";
     $db->setQuery($query);
     $items = oseDB::loadList('obj', 'msc_id');
     $this->set('active_membership', $items);
     //expired
     $where = array();
     $where[] = "`member_id` = '{$this->user_id}'";
     $where[] = "`status` = 0";
     $where = oseDB::implodeWhere($where);
     $query = " SELECT * FROM `{$this->_table}`" . $where . " ORDER BY `id` ASC";
     $db->setQuery($query);
     $items = oseDB::loadList('obj', 'msc_id');
     $this->set('expired_membership', $items);
     //suspend
     $where = array();
     $where[] = "`member_id` = '{$this->user_id}'";
     $where[] = "`status` = 3";
     $where = oseDB::implodeWhere($where);
     $query = " SELECT * FROM `{$this->_table}`" . $where . " ORDER BY `id` ASC";
     $db->setQuery($query);
     $items = oseDB::loadList('obj', 'msc_id');
     $this->set('suspend_membership', $items);
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
0
 function uniqueUserName($username, $user_id = 0)
 {
     $db = oseDB::instance();
     $where = array();
     $username = $db->Quote(strtolower($username));
     $where[] = "LOWER(username) = {$username}";
     if (!empty($user_id)) {
         $where[] = "id != {$user_id}";
     }
     $where = oseDB::implodeWhere($where);
     $query = " SELECT COUNT(*) FROM `#__users`" . $where;
     $db->setQuery($query);
     $isValid = $db->loadResult() > 0 ? false : true;
     return $isValid;
 }
Ejemplo n.º 9
0
 private function getTotal()
 {
     $db = oseDB::instance();
     //$my = JFactory::getUser();
     $member_id = JRequest::getInt('member_id', 0);
     $where = array();
     $where[] = "o.user_id = '{$member_id}'";
     $where[] = "o.entry_type IN ('msc','msc_list')";
     $where = oseDB::implodeWhere($where);
     $query = " SELECT COUNT(*) " . " FROM `#__osemsc_order` AS o " . " INNER JOIN `#__users` AS u ON u.id = o.user_id" . $where;
     $db->setQuery($query);
     //oseExit($db->_sql);
     $result = $db->loadResult();
     return $result;
 }
Ejemplo n.º 10
0
 public static function getHistory($msc_id, $member_id, $action = null)
 {
     $db = oseDB::instance();
     $where = array();
     if (!empty($action)) {
         $where[] = " `action` = '{$action}'";
     }
     $where[] = " `msc_id` = '{$msc_id}'";
     $where[] = " `member_id` = '{$member_id}'";
     $where = oseDB::implodeWhere($where);
     $query = " SELECT * FROM `#__osemsc_member_history` " . $where . " ORDER BY date DESC";
     $db->setQuery($query);
     $objs = oseDB::loadList('obj');
     return $objs;
 }
Ejemplo n.º 11
0
 function &getArtList()
 {
     $db = oseDB::instance();
     $cat_id = JRequest::getInt('cat_id', 0);
     $search = JRequest::getString('search', null);
     $search = JString::strtolower($search);
     $msc_id = JRequest::getInt('msc_id', 0);
     $start = JRequest::getInt('start', 0);
     $limit = JRequest::getInt('limit', 20);
     $where = array();
     if ($cat_id) {
         $where[] = 'c.category_id = ' . $cat_id;
     }
     $where = oseDB::implodeWhere($where);
     $query = " SELECT COUNT(*)" . " FROM `#__zoo_category_item` AS c " . $where;
     $db->setQuery($query);
     $total = $db->loadResult();
     $query = " SELECT i.id,i.name" . " FROM `#__zoo_item` AS i " . " RIGHT JOIN `#__zoo_category_item` AS c" . " ON i.`id` = c.`item_id`" . $where . " ORDER BY i.id";
     $db->setQuery($query, $start, $limit);
     $rows = oseDB::loadList('obj');
     foreach ($rows as $item) {
         $item->treename = $item->name;
         $obj = oseRegistry::call('content')->getInstance('msc')->getItem('zoo', 'article', $item->id, 'msc', $msc_id, null, 'obj');
         $controlled = empty($obj) ? 0 : $obj->status;
         if ($controlled == '1') {
             $item->controlled = JText::_('SHOW_TO_MEMBERS');
         } elseif ($controlled == '-1') {
             $item->controlled = JText::_('HIDE_TO_MEMBERS');
         } else {
             $item->controlled = JText::_('SHOW_TO_ALL');
         }
         $item->leaf = true;
         $item->iconCls = 'task';
         $item->checked = false;
         //$item->controlled = $controlled;
     }
     $result = array();
     $result['total'] = $total;
     $result['results'] = $rows;
     return $result;
 }
 public function getOrders()
 {
     $member_id = JRequest::getInt('member_id', 0);
     $start = JRequest::getInt('start', 0);
     $limit = JRequest::getInt('limit', 0);
     $type = JRequest::getInt('type', 0);
     $db = oseDB::instance();
     $where = array();
     $filterStatus = JRequest::getString('filter_status', null);
     $where[] = "o.entry_type IN ('msc','msc_list')";
     $where[] = "o.payment_from != 'system_admin'";
     $where[] = "o.`user_id` = '{$member_id}'";
     $where[] = "o.`payment_method` IN ('beanstream','authorize','paypal_cc')";
     $where[] = "o.`payment_mode` = 'a' ";
     $where[] = "o.`order_status`='confirmed'";
     $where = oseDB::implodeWhere($where);
     $query = " SELECT COUNT(*) " . " FROM `#__osemsc_order` AS o " . " INNER JOIN `#__users` AS u ON u.id = o.user_id" . $where;
     $db->setQuery($query);
     //oseExit($db->getQuery());
     $total = $db->loadResult();
     $query = " SELECT CONCAT('Order:',o.order_id) AS title, u.username,u.name, o.* " . " FROM `#__osemsc_order` AS o " . " INNER JOIN `#__users` AS u ON u.id = o.user_id" . $where . " ORDER BY o.create_date DESC";
     $db->setQuery($query, $start, $limit);
     //oseExit($db->getQuery());
     $items = oseDB::loadList();
     $return = array();
     $i = 0;
     foreach ($items as $item) {
         $item['mscTitle'] = self::getMSCTitle($item['order_id']);
         $item['name'] = $item['user_id'] . ' - ' . $item['name'];
         $item['title'] = $item['title'] . ' - ' . $item['mscTitle'];
         $return[$i] = $item;
         $i++;
     }
     $result = array();
     $result['total'] = $total;
     //$this->getTotal();
     $result['results'] = $return;
     $result = oseJson::encode($result);
     oseExit($result);
 }
Ejemplo n.º 13
0
 static function getConfig($config_type = null, $type = 'array')
 {
     $db = oseDB::instance();
     $where = array();
     if (!empty($config_type)) {
         if (is_array($config_type)) {
             $values = array();
             foreach ($config_type as $configType) {
                 $values[] = $db->Quote($configType);
             }
             $where[] = 'type IN (' . implode(',', $values) . ')';
         } else {
             $where[] = 'type=' . $db->Quote($config_type);
         }
     }
     $where = oseDB::implodeWhere($where);
     $query = " SELECT * FROM `#__osemsc_configuration` " . $where;
     $db->setQuery($query);
     $objs = oseDB::loadList('obj');
     if ($type == 'array') {
         $config = array();
         foreach ($objs as $obj) {
             $config[$obj->key] = $obj->value;
             //oseObject::setValue($config,$obj->key,$obj->value);
         }
     } else {
         $config = new stdClass();
         foreach ($objs as $obj) {
             $config->{$obj->key} = $obj->value;
             //oseObject::setValue($config,$obj->key,$obj->value);
         }
     }
     /*foreach($objs as $obj)
     		{
     			$config = oseObject::setValue($config,$obj->key,$obj->value);
     		}*/
     $config = oseObject::setValue($config, 'id', 1);
     return $config;
 }
Ejemplo n.º 14
0
 public function getList()
 {
     $db = oseDB::instance();
     $search = JRequest::getString('search', null);
     $search = JString::strtolower($search);
     $start = JRequest::getInt('start', 0);
     $limit = JRequest::getInt('limit', 20);
     $dir = JRequest::getCmd('dir', 'ASC');
     $sortField = JRequest::getCmd('sort', 'domain');
     $msc_id = JRequest::getInt('msc_id');
     $user_id = JRequest::getInt('user_id');
     $where = array();
     $where[] = "`mscID` = '{$msc_id}'";
     $where[] = "`userID` = '{$user_id}'";
     if (!empty($search)) {
         $searchQuery = $db->Quote('%' . $search . '%');
         $where[] = "`domain` LIKE {$searchQuery}";
     }
     $where = oseDB::implodeWhere($where);
     $query = " SELECT COUNT(*) " . " FROM `#__osetickets_domains` " . $where;
     $db->setQuery($query);
     $total = $db->loadResult();
     $query = " SELECT *" . " FROM `#__osetickets_domains` " . $where . " ORDER BY {$sortField} {$dir}";
     if ($start >= 0 && $limit >= 0) {
         $db->setQuery($query, $start, $limit);
     } else {
         $db->setQuery($query);
     }
     $items = oseDB::loadList('obj');
     $list = array();
     foreach ($items as $key => $item) {
         $list[$key] = $item;
     }
     $resul = array();
     $result['total'] = $total;
     $result['results'] = $list;
     oseExit(oseJson::encode($result));
 }
Ejemplo n.º 15
0
 function getTotal($email_type)
 {
     $db = oseDB::instance();
     $where = array();
     $items = array();
     if (!empty($email_type)) {
         $where[] = ' type = ' . $db->Quote($email_type);
     }
     $where = oseDB::implodeWhere($where);
     $query = " SELECT COUNT(*) FROM `#__osemsc_email` " . $where;
     $db->setQuery($query);
     $result = $db->loadResult();
     return $result;
 }
Ejemplo n.º 16
0
 function getOrderItems($order_id, $type = 'array')
 {
     $db = oseDB::instance();
     $where = array();
     $where[] = '`order_id`=' . $db->Quote($order_id);
     $where = oseDB::implodeWhere($where);
     $query = " SELECT * FROM `#__osemsc_order_item` " . $where . ' ORDER BY create_date ASC';
     $db->setQuery($query);
     $items = oseDB::loadList($type);
     return $items;
 }
Ejemplo n.º 17
0
 function getCouponHistory()
 {
     $db = oseDB::instance();
     $id = JRequest::getInt('id', 0);
     $start = JRequest::getInt('start', 0);
     $limit = JRequest::getInt('limit', 25);
     $paid = JRequest::getInt('paid', -1);
     $where = array();
     $where[] = ' c.`coupon_id` = ' . $db->Quote($id);
     if ($paid >= 0) {
         $where[] = ' c.`paid` = ' . $db->Quote($paid);
     }
     $where = oseDB::implodeWhere($where);
     $query = " SELECT count(*) FROM `#__osemsc_coupon_user` AS c" . $where;
     $db->setQuery($query);
     $total = $db->loadResult();
     $query = " SELECT c.* FROM `#__osemsc_coupon_user` AS c" . $where;
     $db->setQuery($query, $start, $limit);
     $items = $db->loadObjectlist();
     foreach ($items as $item) {
         $user_id = $item->user_id;
         $query = " SELECT username FROM `#__users`" . " WHERE `id` = '{$user_id}'";
         $db->setQuery($query);
         $username = $db->loadResult();
         $item->username = empty($username) ? 'Guest' : $username;
     }
     $result = array();
     $result['total'] = $total;
     $result['results'] = $items;
     $result = oseJSON::encode($result);
     oseExit($result);
 }
Ejemplo n.º 18
0
 function getOrder($type)
 {
     $db = oseDB::instance();
     $where = array();
     //$where[] = "id = {$addon_id}";
     $where[] = "type = '{$type}'";
     $where = oseDB::implodeWhere($where);
     $query = " SELECT * FROM `#__osemsc_addon`" . $where . " ORDER BY ordering ASC";
     $db->setQuery($query);
     $items = oseDB::loadList();
     foreach ($items as $key => $item) {
         $item['displayText'] = "({$item['ordering']}){$item['title']}";
         $items[$key] = $item;
     }
     return $items;
 }
Ejemplo n.º 19
0
	function getMscList($msc_id = 0) {
		$db = oseDB::instance();
		$where = array();
		$where[] = "published = 1";
		if (!empty($msc_id)) {
			$where[] = "id = {$msc_id}";
		}
		$where = oseDB::implodeWhere($where);
		$query = " SELECT * FROM `#__osemsc_acl`" . $where . " ORDER BY lft ASC";
		$db->setQuery($query);
		$objs = oseDB::loadList('obj');
		$mscExtend = oseRegistry::call('msc')->getConfig('global', 'obj')->msc_extend;
		$items = array();
		$session = JFactory::getSession();
		$osePaymentCurrency = $session->get('osePaymentCurrency', oseRegistry::call('msc')->getConfig('currency', 'obj')->primary_currency);
		foreach ($objs as $obj) {
			$paymentInfos = oseRegistry::call('msc')->getExtInfo($obj->id, 'payment', 'array');
			foreach ($paymentInfos as $key => $paymentInfo) {
				if (!empty($mscExtend)) {
					$ext = oseRegistry::call($mscExtend);
					$item = oseRegistry::call('payment')->getInstance('View')->getMscInfo($obj->id, $osePaymentCurrency, oseObject::getValue($paymentInfo, 'id'));
					$itemExtend = $ext->getMscExtendInfo($obj->id);
					$fItem = (object) array_merge((array) $item, (array) $itemExtend);
				} else {
					$item = oseRegistry::call('payment')->getInstance('View')->getMscInfo($obj->id, $osePaymentCurrency, oseObject::getValue($paymentInfo, 'id'));
					$fItem = $item;
				}
				$items[] = $fItem;
			}
		}
		return $items;
	}
Ejemplo n.º 20
0
 function getMemberRestrictedContent($type = 'joomla', $content_type, $member_id, $rType = 'array')
 {
     $db = oseDB::instance();
     $member = oseRegistry::call('member');
     $member->instance($member_id);
     $mscs = $member->getAllOwnedMsc(false, 1, 'obj');
     // get restricted of status 1; Step 1 get the start date
     $mValues = array();
     $startDate = array();
     foreach ($mscs as $msc) {
         $startDate[$msc->msc_id] = $msc->start_date;
         $mValues[] = $msc->msc_id;
     }
     if (!empty($mValues)) {
         $mValues = '(' . implode(',', $mValues) . ')';
         $cquery = " (child.entry_id IN {$mValues} AND child.entry_type = 'msc') " . " OR " . " (child.entry_id = '{$member_id}' AND child.entry_type = 'member') ";
         $bquery = " (entry_id IN {$mValues} AND entry_type = 'msc') " . " OR " . " (entry_id = '{$member_id}' AND entry_type = 'member') ";
     } else {
         $cquery = " (child.entry_id = '{$member_id}' AND child.entry_type = 'member') ";
         $bquery = " (entry_id = '{$member_id}' AND entry_type = 'member') ";
     }
     $cWhere = array();
     $cWhere[] = $cquery;
     $cWhere[] = "child.type = '{$type}'";
     $cWhere[] = "child.content_type = '{$content_type}'";
     $cWhere[] = "child.status = '1'";
     $cWhere = oseDB::implodeWhere($cWhere);
     $pWhere = array();
     $pWhere[] = "parent.type = '{$type}'";
     $pWhere[] = "parent.content_type = '{$content_type}'";
     $pWhere[] = "parent.status = '1'";
     $pWhere = oseDB::implodeWhere($pWhere);
     $query = " SELECT parent.* FROM `{$this->table}` AS parent" . " WHERE parent.content_id NOT IN (" . " \t\tSELECT DISTINCT child.content_id " . " \t\tFROM `{$this->table}` AS child" . $cWhere . " )" . " AND " . str_replace('WHERE', '', $pWhere);
     $db->setQuery($query);
     //oseExit($db->_sql);
     $objs = oseDB::loadList($rType);
     // get restricted of status -1;
     $bWhere = array();
     $bWhere[] = $bquery;
     $bWhere[] = "type = '{$type}'";
     $bWhere[] = "content_type = '{$content_type}'";
     $bWhere[] = "status = '-1'";
     $bWhere = oseDB::implodeWhere($bWhere);
     $query = " SELECT DISTINCT content_id " . " FROM `{$this->table}` " . $bWhere;
     $db->setQuery($query);
     $banObj = oseDB::loadList($rType);
     if (empty($objs)) {
         $objs = array();
     }
     if (empty($banObj)) {
         $banObj = array();
     }
     // get restricted of sequential, status = 1
     $query = " SELECT DISTINCT child.content_id, child.entry_id, child.params " . " \tFROM `{$this->table}` AS child" . $cWhere;
     $db->setQuery($query);
     $sqeObjs = oseDB::loadList($rType);
     foreach ($sqeObjs as $key => $sqeObj) {
         $params = oseJson::decode(oseObject::getValue($sqeObj, 'params', '{}'));
         $timeLength = oseObject::getValue($params, 'time_length', false);
         if ($timeLength) {
             // provided that entry type is msc
             $total = strtotime("+{$timeLength}  week", strtotime($startDate[oseObject::getValue($sqeObj, 'entry_id')]));
             $cur = strtotime(oseHTML::getDateTime());
             //oseExit($timeLength);
             if ($cur > $total) {
                 unset($sqeObjs[$key]);
             }
         } else {
             unset($sqeObjs[$key]);
         }
     }
     $objs = array_merge($objs, $banObj, $sqeObjs);
     //oseExit(oseDB::loadList($rType));
     return $objs;
 }
Ejemplo n.º 21
0
	static public function getList() {
		$where = array();
		$type = JRequest::getVar('type', null);
		if ($type != 'renew') {
			$where[] = "`published` = 1";
		}
		$where[] = "`leaf` =1";
		$where = oseDB::implodeWhere($where);
		$db = oseDB::instance();
		$query = " SELECT id,title,alias,description,ordering,image,params" . " FROM `#__osemsc_acl`" . $where . " ORDER BY lft ASC";
		$db->setQuery($query);
		$objs = oseDB::loadList();
		return $objs;
	}
Ejemplo n.º 22
0
 function getDefState()
 {
     $db = oseDB::instance();
     $where = array();
     $query = "SELECT value FROM `#__osemsc_configuration` WHERE `key` = 'default_country'";
     $db->setQuery($query);
     $country_id = $db->loadResult();
     if (!empty($country_id)) {
         $where[] = "`country_id` = {$country_id}";
     }
     $where = oseDB::implodeWhere($where);
     $query = "SELECT * FROM `#__osemsc_state` " . $where;
     $db->setQuery($query);
     $items = oseDB::loadList();
     $total = count($items);
     $result = array();
     $result['total'] = $total;
     $result['results'] = $items;
     return $result;
 }
Ejemplo n.º 23
0
    public function getConfirmedOrders()
	{
		$db = oseDB::instance();
		$my = JFactory::getUser();

		$start = JRequest::getInt('start',0);
		$limit = JRequest::getInt('limit',20);

		$member = oseRegistry::call('member');
		$member->instance($my->id);
		$memberships = $member->getMemberOwnedMscInfo(false,1,'obj');

		/*$order_ids = array();
		foreach($memberships as $membership)
		{
			$memParams = oseJson::decode($membership->params);
			if($memParams->payment_mode == 'a')
			{
				$order_ids[$memParams->order_id] = $db->Quote($memParams->order_id);
			}

		}

		$order_ids = '('.implode(',',$order_ids).')';*/

		$where = array();
		//$where[] = "o.order_id IN {$order_ids}";
		$where[] = "o.payment_mode = 'a'";
		$where[] = "o.order_status = 'confirmed'";
		$where[] = "o.user_id = '{$my->id}'";
		//$where[] = "`order_status` = 'confirmed'";
		//$where[] = "`payment_mode` = 'a'";
		$where = oseDB::implodeWhere($where);

		$query = " SELECT COUNT(*) "
				." FROM `#__osemsc_order` AS o "
				. $where
				;

		$db->setQuery($query);
		$total = $db->loadResult();

		$title = JText::_('INVOICE_ID').': '.JText::_('ORDER').' ';
		$query = " SELECT o.* , CONCAT('{$title}', o.order_id) AS invoice"
				." FROM `#__osemsc_order` AS o "
				. $where
				." ORDER BY o.order_id DESC"
				." LIMIT {$start},{$limit} "
				;

		$db->setQuery($query);

		$items = oseDB::loadList();

		$result = array();
		$result['total'] = $total;
		$result['results'] = $items;

		return $result;
	}
Ejemplo n.º 24
0
 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;
 }
Ejemplo n.º 25
0
	function getMscList_M()
	{
		$cartItems = oseMscPublic::getCartItems();
		///$item = $items[0];

		$db = oseDB::instance();

		$where = array();

		$where[] = "published = 1";

		$msc_option = 0;

		if(!empty($items[0]))
		{
			$msc_id = oseObject::getValue($items[0],'entry_id');

			if(!empty($msc_id))
			{
				$where[] = "id = {$msc_id}";
			}
			$msc_option = oseObject::getValue($items[0],'msc_option');
		}

		$where = oseDB::implodeWhere($where);

		$query = " SELECT * FROM `#__osemsc_acl`"
				. $where
				." ORDER BY lft ASC"
				;

		$db->setQuery($query);

		$objs = oseDB::loadList('obj');

		//$mscExtend = oseRegistry::call('msc')->getConfig('global','obj')->msc_extend;

		$items = array();

		$session =& JFactory::getSession();
    	$osePaymentCurrency = $session->get('osePaymentCurrency',oseRegistry::call('msc')->getConfig('currency','obj')->primary_currency);

		foreach($objs as  $obj)
		{


			if(empty($msc_option))
			{
				$paymentInfos = oseRegistry::call('msc')->getExtInfo($obj->id,'payment','array');
				//oseExit($paymentInfos);
				foreach($paymentInfos as $key => $paymentInfo)
				{
					$fItem = oseRegistry::call('msc')->getPaymentMscInfo($obj->id,$osePaymentCurrency,$key);
					$fItem = oseObject::setValue($fItem,'msc_option',$key);
					$items[] = $fItem;

				}
			}
			else
			{
				$fItem = oseRegistry::call('msc')->getPaymentMscInfo($obj->id,$osePaymentCurrency,$msc_option);
				$fItem = oseObject::setValue($fItem,'msc_option',$msc_option);
				$items[] = $fItem;
			}

		}

		$total = count($items);

		$result = array();

		if($total > 0)
		{
			$result['total'] = $total;
			$result['results'] = $items;
		}
		$result = oseJson::encode($result);

		oseExit($result);
	}
Ejemplo n.º 26
0
 public static function getProfile($params = array())
 {
     $member_id = JRequest::getInt('member_id', 0);
     $db = oseDB::instance();
     $member = oseRegistry::call('member');
     $member->instance($member_id);
     $mscs = $member->getAllOwnedMsc(true, 1, 'obj');
     if (!empty($mscs)) {
         foreach ($mscs as $msc) {
             $Mem_mscs[] = $msc->msc_id;
         }
     } else {
         $Mem_mscs = array();
     }
     $pids = array();
     if (!empty($Mem_mscs)) {
         foreach ($Mem_mscs as $msc_id) {
             $query = "SELECT params FROM `#__osemsc_ext` WHERE `type` = 'profilecontrol' AND `id` = " . $msc_id;
             $db->setQuery($query);
             $paymentParams = $db->loadResult();
             $paymentParams = oseJSON::decode($paymentParams);
             if (!empty($paymentParams->enable)) {
                 $values = explode(",", $paymentParams->value);
                 $pids = array_merge($pids, $values);
             }
         }
     }
     $where = array();
     if (!empty($pids)) {
         $pids = array_unique($pids);
         $pids = implode(",", $pids);
         $where[] = " `id` IN (" . $pids . ")";
     }
     $where[] = " `published` = '1'";
     $where = oseDB::implodeWhere($where);
     $query = "SELECT * FROM `#__osemsc_fields` " . $where . " ORDER BY `ordering`";
     $db->setQuery($query);
     $items = oseDB::loadList('obj');
     foreach ($items as $item) {
         if ($item->type == 'radio') {
             $params = explode(',', $item->params);
             foreach ($params as $param) {
                 $option = array();
                 $option['boxLabel'] = $param;
                 $option['inputValue'] = $param;
                 $option['autoWidth'] = true;
                 $options[] = $option;
             }
             $item->params = $options;
             unset($options);
         }
         $query = "SELECT value FROM `#__osemsc_fields_values` WHERE `field_id` = '{$item->id}' AND `member_id` = '{$member_id}'";
         $db->setQuery($query);
         $item->value = $db->loadResult();
     }
     if (empty($items)) {
         $result['total'] = 0;
         $result['results'] = '';
     } else {
         $result['total'] = count($items);
         $result['results'] = $items;
     }
     return $result;
 }
Ejemplo n.º 27
0
 private function ordering($id, $msc_id, $orderingChange)
 {
     $db = oseDB::instance();
     //$post = JRequest::get('post');
     $extItem = oseRegistry::call('msc')->getExtInfoItem($msc_id, 'payment', 'obj');
     $extItem->params = empty($extItem->params) ? array() : $extItem->params;
     $items = oseJson::decode($extItem->params, true);
     // if no ordering exists, resort it.
     $i = 1;
     foreach ($items as $key => $item) {
         if (!oseObject::getValue($item, 'ordering', 0)) {
             $item = oseObject::setValue($item, 'ordering', $i);
             $items[$key] = $item;
         } else {
             break;
         }
         $i++;
     }
     if (oseObject::getValue($items[$id], 'ordering') == 1 && $orderingChange < 0) {
         return true;
     }
     if (oseObject::getValue($items[$id], 'ordering') == count($items) && $orderingChange > 0) {
         return true;
     }
     // get new array by ordering
     $nItems = array();
     foreach ($items as $key => $item) {
         $ordering = oseObject::getValue($item, 'ordering');
         $nItems[$ordering] = $item;
     }
     ksort($nItems);
     $curOrdering = oseObject::getValue($items[$id], 'ordering');
     $curItem = $nItems[$curOrdering];
     $toOrdering = $curOrdering + $orderingChange;
     $toItem = $nItems[$toOrdering];
     // resort the ordering
     $i = 1;
     $rItems = array();
     foreach ($nItems as $key => $item) {
         if ($i == $curOrdering) {
             $rItems[$i] = $toItem;
         } elseif ($i == $toOrdering) {
             $rItems[$i] = $curItem;
         } else {
             $rItems[$i] = $item;
         }
         $i++;
     }
     // restore key: id
     $i = 1;
     $items = array();
     foreach ($rItems as $key => $item) {
         $nkey = oseObject::getValue($item, 'id');
         $items[$nkey] = oseObject::setValue($item, 'ordering', $key);
     }
     $where = array();
     $where[] = 'id = ' . $db->Quote($msc_id);
     $where[] = 'type = ' . $db->Quote('payment');
     $newParams = $db->Quote(oseJson::encode($items));
     $where = oseDB::implodeWhere($where);
     $query = " UPDATE `#__osemsc_ext` " . " SET " . " params = {$newParams} " . $where;
     $db->setQuery($query);
     if (oseDB::query()) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 28
0
 function getUsers()
 {
     $db = oseDB::instance();
     $member = oseRegistry::call('member');
     $post = JRequest::get('post');
     $where = array();
     $search = $post['search'];
     if ($search) {
         $searchQuery = $db->Quote('%' . $search . '%');
         $where[] = "u.username LIKE {$searchQuery} OR u.name LIKE {$searchQuery} OR u.email LIKE {$searchQuery}";
     }
     $where = count($where > 0) ? oseDB::implodeWhere($where) : null;
     $start = $post['start'];
     $limit = $post['limit'];
     $result['results'] = oseMemGroup::getUsers($where, $start, $limit);
     //oseExit($db->_sql);
     $result['total'] = oseMemGroup::getUsersTotal($where);
     return $result;
 }
Ejemplo n.º 29
0
 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;
 }
Ejemplo n.º 30
0
 function getMemberAccessContent($type = 'joomla', $content_type, $member_id, $rType = 'array')
 {
     $db = oseDB::instance();
     $member = oseRegistry::call('member');
     $member->instance($member_id);
     $mscs = $member->getAllOwnedMsc(false, 1, 'obj');
     // get restricted of status 1; Step 1 get the start date
     $mValues = array();
     $startDate = array();
     foreach ($mscs as $msc) {
         $startDate[$msc->msc_id] = $msc->start_date;
         $mValues[] = $msc->msc_id;
     }
     if (!empty($mValues)) {
         $mValues = '(' . implode(',', $mValues) . ')';
         $bquery = " (entry_id IN {$mValues} AND entry_type = 'msc') " . " OR " . " (entry_id = '{$member_id}' AND entry_type = 'member') ";
     } else {
         $bquery = " (entry_id = '{$member_id}' AND entry_type = 'member') ";
     }
     // filter the intersect access content
     $aWhere = array();
     $aWhere[] = $bquery;
     $aWhere[] = "type = '{$type}'";
     $aWhere[] = "content_type = '{$content_type}'";
     $aWhere[] = "status = '1'";
     $aWhere = oseDB::implodeWhere($aWhere);
     $query = " SELECT DISTINCT content_id, params, entry_id" . " FROM `#__osemsc_content` " . $aWhere;
     $db->setQuery($query);
     $aObj = oseDB::loadList($rType);
     foreach ($aObj as $key => $sqeObj) {
         $params = oseJson::decode(oseObject::getValue($sqeObj, 'params', '{}'));
         $timeLength = oseObject::getValue($params, 'time_length', false);
         $time_unit = oseObject::getValue($params, 'time_unit', 'week');
         if ($timeLength) {
             // provided that entry type is msc
             $total = strtotime("+{$timeLength}  {$time_unit}", strtotime($startDate[oseObject::getValue($sqeObj, 'entry_id')]));
             $cur = strtotime(oseHTML::getDateTime());
             //oseExit($timeLength);
             if ($cur < $total) {
                 unset($aObj[$key]);
             }
         }
     }
     return $aObj;
 }