* @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()) { ItemGroupHandler::setChildren(1, $planlist); } }
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')); }
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; }