/** * Remove item from the Shopping Cart * @param $cartId * @param null $userId * @return bool */ public function removeItem($cartId, $userId = null) { if (empty($userId)) { //test for removing convention $bundles = ItemGroup::itemBundleGroups(); if (isset($bundles[$this->session->read("shoppingcart.{$cartId}")['sku']])) { foreach ($this->session->read("shoppingcart") as $key => $line) { if (in_array($line['sku'], $bundles[$this->session->read("shoppingcart.{$cartId}")['sku']])) { $this->session->delete("shoppingcart.{$key}"); } } } $this->session->delete("shoppingcart.{$cartId}"); //check current cart $this->pruneItems($this->session->read("shoppingcart")); return true; } }
public function save() { unset($_POST['option']); unset($_POST['task']); $id = $_POST['id'] ? $_POST['id'] : 0; $mi = new microIntegration(); $mi->load($id); if (!empty($_POST['class_name'])) { $load = $mi->callDry($_POST['class_name']); } else { $load = $mi->callIntegration(1); } if ($load) { $save = array('attach_to_plans' => array(), 'attached_to_plans' => array(), 'attach_to_groups' => array(), 'attached_to_groups' => array()); foreach ($save as $pid => $v) { if (isset($_POST[$pid])) { $save[$pid] = $_POST[$pid]; unset($_POST[$pid]); } else { $save[$pid] = array(); } } $mi->savePostParams($_POST); $mi->storeload(); $all_groups = array_unique(array_merge($save['attach_to_groups'], $save['attached_to_groups'])); if (!empty($all_groups)) { foreach ($all_groups as $groupid) { $group = new ItemGroup(); $group->load($groupid); if (in_array($groupid, $save['attach_to_groups']) && !in_array($groupid, $save['attached_to_groups'])) { $group->params['micro_integrations'][] = $mi->id; $group->storeload(); } elseif (!in_array($groupid, $save['attach_to_groups']) && in_array($groupid, $save['attached_to_groups'])) { unset($group->params['micro_integrations'][array_search($mi->id, $group->params['micro_integrations'])]); $group->storeload(); } } } $all_plans = array_unique(array_merge($save['attach_to_plans'], $save['attached_to_plans'])); if (!empty($all_plans)) { foreach ($all_plans as $planid) { $plan = new SubscriptionPlan(); $plan->load($planid); if (in_array($planid, $save['attach_to_plans']) && !in_array($planid, $save['attached_to_plans'])) { $plan->micro_integrations[] = $mi->id; $plan->storeload(); } elseif (!in_array($planid, $save['attach_to_plans']) && in_array($planid, $save['attached_to_plans'])) { unset($plan->micro_integrations[array_search($mi->id, $plan->micro_integrations)]); $plan->storeload(); } } } } else { $short = 'microIntegration storing failure'; if (!empty($_POST['class_name'])) { $event = 'When trying to store microIntegration: ' . $_POST['class_name'] . ', callIntegration failed'; } else { $event = 'When trying to store microIntegration: ' . $mi->id . ', callIntegration failed'; } $tags = 'microintegration,loading,error'; $params = array(); $eventlog = new eventLog(); $eventlog->issue($short, $tags, $event, 128, $params); } $mi->reorder(); $this->setMessage(JText::_('AEC_MSG_SUCESSFULLY_SAVED')); }
/** * @version $Id: create_rootgroup.inc.php * @package AEC - Account Control Expiration - Membership Manager * @subpackage Install Includes * @copyright 2006-2015 Copyright (C) David Deutsch * @author David Deutsch <*****@*****.**> & Team AEC - http://www.valanx.org * @license GNU/GPL v.3 http://www.gnu.org/licenses/gpl.html or, at your option, any later version */ // Dont allow direct linking defined('_JEXEC') or die('Direct Access to this location is not allowed.'); // Check for a root group $db->setQuery("SELECT id FROM #__acctexp_itemgroups WHERE id='1'"); // Create root group completely out of thin air (tadaa!) if ($db->loadResult() != 1) { $rootgroup = new ItemGroup(); $rootgroup->id = 0; $rootgroup->active = 1; $rootgroup->visible = 1; $rootgroup->name = JText::_('AEC_INST_ROOT_GROUP_NAME'); $rootgroup->desc = JText::_('AEC_INST_ROOT_GROUP_DESC'); $rootgroup->params = array('color' => 'bbddff', 'icon' => 'flag_blue', 'reveal_child_items' => 1); $rootgroup->storeload(); if ($rootgroup->id != 1) { $db->setQuery("UPDATE #__acctexp_itemgroups SET id='1' WHERE id='" . $rootgroup->id . "'"); $db->query(); } // Adding in root group relation for all plans $planlist = SubscriptionPlanHandler::listPlans(); $db->setQuery("SELECT count(*) FROM #__acctexp_itemxgroup"); if (count($planlist) > $db->loadResult()) {
public function getMicroIntegrationsSeparate($strip_inherited = false) { if (empty($this->params['micro_integrations'])) { $milist = array(); } else { $milist = $this->params['micro_integrations']; } // Find parent ItemGroups to attach their MIs $parents = ItemGroupHandler::getParents($this->id, 'group'); $gmilist = array(); if (!empty($parents)) { foreach ($parents as $parent) { $g = new ItemGroup(); $g->load($parent); if (!empty($g->params['micro_integrations'])) { $gmilist = array_merge($gmilist, $g->params['micro_integrations']); } } } if (empty($milist) && empty($gmilist)) { return array('group' => array(), 'inherited' => array()); } $milist = microIntegrationHandler::getActiveListbyList($milist); $gmilist = microIntegrationHandler::getActiveListbyList($gmilist); if (empty($milist) && empty($gmilist)) { return array('group' => array(), 'inherited' => array()); } if ($this->id > 1) { // Remove entries from the group MIs that are already inherited if (!empty($gmilist) && !empty($milist) && $strip_inherited) { $theintersect = array_intersect($gmilist, $milist); if (!empty($theintersect)) { foreach ($theintersect as $value) { // STAY IN THE CAR unset($milist[array_search($value, $milist)]); } } } } else { $gmilist = array(); } return array('group' => $milist, 'inherited' => $gmilist); }
public function actionRestrictionCheck() { $this->response->result = false; if (!empty($this->request->details->plan)) { $plan = new SubscriptionPlan(); $plan->load($this->request->details->plan); if ($plan->id != $this->request->details->plan) { $this->error = 'could not find plan to check restrictions for'; return; } $restrictions = $plan->getRestrictionsArray(); if (aecRestrictionHelper::checkRestriction($restrictions, $this->metaUser) !== false) { if (!ItemGroupHandler::checkParentRestrictions($plan, 'item', $this->metaUser)) { $this->error = 'user is denied permission - plans parent group is restricted from this user'; } } else { $this->error = 'user is denied permission - plan is restricted from this user'; } unset($this->request->details->plan); } if (!empty($this->request->details->group)) { $group = new ItemGroup(); $group->load($this->request->details->group); if ($group->id != $this->request->details->group) { $this->error = 'could not find group to check restrictions for'; return; } $restrictions = $group->getRestrictionsArray(); if (aecRestrictionHelper::checkRestriction($restrictions, $this->metaUser) !== false) { if (!ItemGroupHandler::checkParentRestrictions($group, 'group', $this->metaUser)) { $this->error = 'user is denied permission - groups parent group is restricted from this user'; } } else { $this->error = 'user is denied permission - group is restricted from this user'; } unset($this->request->details->group); } if (!empty($this->request->details)) { $re = get_object_vars($this->request->details); $restrictions = aecRestrictionHelper::getRestrictionsArray($re); if (aecRestrictionHelper::checkRestriction($restrictions, $this->metaUser) === false) { $this->error = 'user is denied permission - at least one restriction result was negative'; } } if (empty($this->error)) { $this->response->result = true; } }
/** * @param integer $mi_id */ static function getGroupsbyMI($mi_id, $inherited = true, $extended = false) { $db = JFactory::getDBO(); $query = 'SELECT `id`' . ' FROM #__acctexp_itemgroups'; $db->setQuery($query); $groups = xJ::getDBArray($db); $group_list = array(); foreach ($groups as $groupid) { $group = new ItemGroup(); $group->load($groupid); if ($inherited) { $mis = $group->getMicroIntegrations(); } else { $misx = $group->getMicroIntegrationsSeparate(); $mis = $misx['group']; } if (!empty($mis)) { if (is_array($mi_id)) { if (array_intersect($mi_id, $mis)) { if ($extended) { $group_list[] = $group; } else { $group_list[] = $groupid; } } } else { if (in_array($mi_id, $mis)) { if ($extended) { $group_list[] = $group; } else { $group_list[] = $groupid; } } } } } return $group_list; }
public function create($intro = 0, $usage = 0, $group = 0, $processor = null, $invoice = 0, $autoselect = false) { global $aecConfig; $register = !$this->loadMetaUser(true); $this->getPassthrough(); // Reset $register if we seem to have all data if ($register && !empty($this->passthrough['username']) || !empty($aecConfig->cfg['skip_registration'])) { $register = 0; } if ($intro && $this->metaUser->hasSubscription && !$aecConfig->cfg['customintro_always']) { $intro = false; } if (empty($this->usage) && empty($group) && !$intro && !empty($aecConfig->cfg['customintro'])) { if (!empty($aecConfig->cfg['customintro_userid'])) { aecRedirect($aecConfig->cfg['customintro'], $this->userid, "aechidden"); } else { aecRedirect($aecConfig->cfg['customintro']); } } $this->recurring = aecGetParam('recurring', null); $planlist = new SubscriptionPlanList($usage, $group, $this->metaUser, $this->recurring); $nochoice = false; // There is no choice if we have only one group or only one item with one payment option if (count($planlist->list) === 1) { if ($planlist->list[0]['type'] == 'item') { if (count($planlist->list[0]['gw']) === 1) { $nochoice = true; } elseif (!empty($processor)) { foreach ($planlist->list[0]['gw'] as $gw) { if ($gw->processor_name == $processor) { $nochoice = true; } } if ($nochoice) { $first = 0; foreach ($planlist->list[0]['gw'] as $gwid => $gw) { if ($gw->processor_name != $processor) { unset($planlist->list[0]['gw'][$gwid]); } else { $first = $gwid; } } if (!empty($first)) { $planlist->list[0]['gw'][0] = $planlist->list[0]['gw'][$first]; unset($planlist->list[0]['gw'][$first]); } } } } else { // Jump back and use the only group we've found return $this->create($intro, 0, $planlist->list[0]['id'], null, 0, true); } } // If we have only one processor on one plan, there is no need for a decision if ($nochoice && !($aecConfig->cfg['show_fixeddecision'] && empty($processor))) { // If the user also needs to register, we need to guide him there after the selection has now been made if ($register && empty($aecConfig->cfg['skip_registration'])) { aecRegistration::registerRedirect($intro, $planlist->list[0]); } else { // Existing user account - so we need to move on to the confirmation page with the details $this->usage = $planlist->list[0]['id']; if (isset($planlist->list[0]['gw'][0]->recurring)) { $this->recurring = $planlist->list[0]['gw'][0]->recurring; } else { $this->recurring = 0; } $this->processor = $planlist->list[0]['gw'][0]->processor_name; if ($invoice != 0 && !is_null($invoice)) { $this->invoice_number = $invoice; } return $this->confirm(); } } if ($group) { $g = new ItemGroup(); $g->load($group); $planlist->list['group'] = ItemGroupHandler::getGroupListItem($g); } $cart = $this->userid ? aecCartHelper::getCartidbyUserid($this->userid) : false; $selected = (!empty($group) || !empty($usage)) && !$autoselect; if (!$selected && !empty($planlist->list['group'])) { unset($planlist->list['group']); } $passthrough = $this->getPassthrough(); $csslist = $planlist->addButtons($register, $passthrough); return getView('plans', array('userid' => $this->userid, 'list' => $planlist->list, 'passthrough' => $passthrough, 'register' => $register, 'cart' => $cart, 'selected' => $selected, 'group' => $group, 'csslist' => $csslist)); }
public function createGroups($amount) { $db = JFactory::getDBO(); if (!$_POST['create_groups']) { $query = 'SELECT MIN(id)' . ' FROM #__acctexp_itemgroups' . ' WHERE `id` > 1'; $db->setQuery($query); $this->range['groups']['start'] = $db->loadResult(); $query = 'SELECT MAX(id)' . ' FROM #__acctexp_itemgroups'; $db->setQuery($query); $this->range['groups']['end'] = $db->loadResult(); return array(); } $colors = array('1f77b4', 'aec7e8', 'ff7f0e', 'ffbb78', '2ca02c', '98df8a', 'd62728', 'ff9896', '9467bd', 'c5b0d5', '8c564b', 'c49c94', 'e377c2', 'f7b6d2', '7f7f7f', 'c7c7c7', 'bcbd22', 'dbdb8d', '17becf', '9edae5', 'BBDDFF', '5F8BC4', 'A2BE72', 'DDFF99', 'D07C30', 'C43C42', 'AA89BB', 'B7B7B7', '808080'); $grouplist = array(); for ($i = 0; $i <= $amount; $i++) { $row = new ItemGroup(); $post = array('active' => 1, 'visible' => 0, 'name' => 'Group ' . ($i + 1), 'desc' => 'Group ' . ($i + 1), 'color' => $colors[$i % 29]); $row->savePOSTsettings($post); $row->storeload(); ItemGroupHandler::setChildren(1, array($row->id), $type = 'group'); if ($i == 0) { $this->range['groups']['start'] = $row->id; } elseif ($i == $amount) { $this->range['groups']['end'] = $row->id; } $grouplist[] = $row->id; } return $grouplist; }