public function edit($id) { $lists = array(); $params_values = array(); $restrictions_values = array(); $customparams_values = array(); $row = new ItemGroup(); $row->load($id); $restrictionHelper = new aecRestrictionHelper(); if (!$row->id) { $row->ordering = 9999; $params_values['active'] = 1; $params_values['visible'] = 0; $restrictions_values['gid_enabled'] = 1; $restrictions_values['gid'] = 18; } else { $params_values = $row->params; $restrictions_values = $row->restrictions; $customparams_values = $row->custom_params; // We need to convert the values that are set as object properties $params_values['active'] = $row->active; $params_values['visible'] = $row->visible; $params_values['name'] = $row->getProperty('name'); $params_values['desc'] = $row->getProperty('desc'); } // params and their type values $params['active'] = array('toggle', 1); $params['visible'] = array('toggle', 0); $params['name'] = array('inputC', ''); $params['desc'] = array('editor', ''); $params['color'] = array('list', ''); $params['reveal_child_items'] = array('toggle', 0); $params['symlink'] = array('inputC', ''); $params['symlink_userid'] = array('toggle', 0); $params['notauth_redirect'] = array('inputD', ''); $params['micro_integrations'] = array('list', ''); $params['meta'] = array('inputD', ''); $params['params_remap'] = array('subarea_change', 'groups'); $groups = ItemGroupHandler::parentGroups($row->id, 'group'); $customparamsarray = new stdClass(); if (!empty($groups)) { $gs = array(); foreach ($groups as $groupid) { $params['group_delete_' . $groupid] = array('checkbox'); $group = new ItemGroup(); $group->load($groupid); $g = array(); $g['id'] = $group->id; $g['name'] = $group->getProperty('name'); $g['color'] = $group->params['color']; $g['group'] = '<strong>' . $groupid . '</strong>'; $gs[$groupid] = $g; } $customparamsarray->groups = $gs; } else { $customparamsarray->groups = null; } $grouplist = ItemGroupHandler::getTree(); $glist = array(); $glist[] = JHTML::_('select.option', 0, '- - - - - -'); $groupids = array(); foreach ($grouplist as $gid => $glisti) { $children = ItemGroupHandler::getParents($glisti[0], 'group'); $disabled = in_array($id, $children); if ($id) { $self = $glisti[0] == $id; $existing = in_array($glisti[0], $groups); $disabled = $disabled || $self || $existing; } if (defined('JPATH_MANIFESTS')) { $glist[] = JHTML::_('select.option', $glisti[0], str_replace(' ', ' ', $glisti[1]), 'value', 'text', $disabled); } else { $glist[] = JHTML::_('select.option', $glisti[0], $glisti[1], 'value', 'text', $disabled); } $groupids[$glisti[0]] = ItemGroupHandler::groupColor($glisti[0]); } $lists['add_group'] = JHTML::_('select.genericlist', $glist, 'add_group', 'size="1"', 'value', 'text', $row->id ? 0 : 1); foreach ($groupids as $groupid => $groupcolor) { $lists['add_group'] = str_replace('value="' . $groupid . '"', 'value="' . $groupid . '" style="background-color: #' . $groupcolor . ' !important;"', $lists['add_group']); } $params['add_group'] = array('list', '', '', $row->id ? 0 : 1); $params['restr_remap'] = array('subarea_change', 'restrictions'); $params = array_merge($params, $restrictionHelper->getParams()); $rewriteswitches = array('cms', 'user'); $params['rewriteInfo'] = array('fieldset', '', AECToolbox::rewriteEngineInfo($rewriteswitches)); $colors = array('3182bd', '6baed6', '9ecae1', 'c6dbef', 'e6550d', 'fd8d3c', 'fdae6b', 'fdd0a2', '31a354', '74c476', 'a1d99b', 'c7e9c0', '756bb1', '9e9ac8', 'bcbddc', 'dadaeb', '636363', '969696', 'bdbdbd', 'd9d9d9', '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'); $colorlist = array(); foreach ($colors as $color) { $obj = new stdClass(); $obj->value = '#' . $color; $obj->text = $color; $colorlist[] = $obj; } $lists['color'] = JHTML::_('select.genericlist', $colorlist, 'color', 'size="1"', 'value', 'text', '#' . arrayValueDefault($params_values, 'color', 'BBDDFF')); $mi_list = microIntegrationHandler::getDetailedList(); $mi_settings = array('inherited' => array(), 'attached' => array(), 'custom' => array()); $attached_mis = $row->getMicroIntegrationsSeparate(true); foreach ($mi_list as $mi_details) { $mi_details->inherited = false; if (in_array($mi_details->id, $attached_mis['inherited'])) { $mi_details->inherited = true; $mi_settings['inherited'][] = $mi_details; } $mi_details->attached = false; if (in_array($mi_details->id, $attached_mis['group'])) { $mi_details->attached = true; } $mi_settings['attached'][] = $mi_details; } $customparamsarray->mi = $mi_settings; $settings = new aecSettings('itemgroup', 'general'); if (is_array($customparams_values)) { $settingsparams = array_merge($params_values, $customparams_values, $restrictions_values); } elseif (is_array($restrictions_values)) { $settingsparams = array_merge($params_values, $restrictions_values); } else { $settingsparams = $params_values; } $lists = array_merge($lists, $restrictionHelper->getLists($params_values, $restrictions_values)); $settings->fullSettingsArray($params, $settingsparams, $lists); // Call HTML Class $aecHTML = new aecHTML($settings->settings, $settings->lists); if (!empty($customparamsarray)) { $aecHTML->customparams = $customparamsarray; } HTML_AcctExp::editItemGroup($aecHTML, $row); }
/** * @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; }