public function savePOSTsettings($post) { // Fake knowing the planid if is zero. if (!empty($post['id'])) { $groupid = $post['id']; } else { $groupid = $this->getMax() + 1; } if (isset($post['id'])) { unset($post['id']); } if (isset($post['inherited_micro_integrations'])) { unset($post['inherited_micro_integrations']); } if (!empty($post['add_group'])) { ItemGroupHandler::setChildren($post['add_group'], array($groupid), 'group'); } if ($this->id == 1) { $post['active'] = 1; $post['visible'] = 1; $post['name'] = JText::_('AEC_INST_ROOT_GROUP_NAME'); $post['desc'] = JText::_('AEC_INST_ROOT_GROUP_DESC'); $post['reveal_child_items'] = 1; } // Filter out fixed variables $fixed = array('active', 'visible', 'name', 'desc'); foreach ($fixed as $varname) { $this->{$varname} = $post[$varname]; unset($post[$varname]); } foreach ($post['micro_integrations'] as $k => $v) { if ($v) { $post['micro_integrations'][$k] = $v; } else { unset($post['micro_integrations'][$k]); } } // Filter out params $fixed = array('color', 'reveal_child_items', 'symlink', 'symlink_userid', 'notauth_redirect', 'micro_integrations', 'meta'); $params = array(); foreach ($fixed as $varname) { if (!isset($post[$varname])) { continue; } if ($varname == 'color') { if (strpos($post[$varname], '#') !== false) { $post[$varname] = substr($post[$varname], 1); } } $params[$varname] = $post[$varname]; unset($post[$varname]); } $this->saveParams($params); // Filter out restrictions $fixed = aecRestrictionHelper::paramList(); $restrictions = array(); foreach ($fixed as $varname) { if (!isset($post[$varname])) { continue; } $restrictions[$varname] = $post[$varname]; unset($post[$varname]); } $this->restrictions = $restrictions; // There might be deletions set for groups foreach ($post as $varname => $content) { if (strpos($varname, 'group_delete_') !== false && $content) { $parentid = (int) str_replace('group_delete_', '', $varname); ItemGroupHandler::removeChildren($groupid, array($parentid), 'group'); unset($post[$varname]); } } // The rest of the vars are custom params $custom_params = array(); foreach ($post as $varname => $content) { if (substr($varname, 0, 4) != 'mce_') { $custom_params[$varname] = $content; } unset($post[$varname]); } $this->custom_params = $custom_params; }
public function remove($id) { $ids = implode(',', $id); $this->db->setQuery('SELECT count(*)' . ' FROM #__acctexp_itemgroups' . ' WHERE `id` IN (' . $ids . ')'); $total = $this->db->loadResult(); if ($total == 0) { echo "<script> alert('" . html_entity_decode(JText::_('AEC_MSG_NO_ITEMS_TO_DELETE')) . "'); window.history.go(-1);</script>\n"; exit; } $total = 0; foreach ($id as $i) { $ig = new ItemGroup(); $ig->load($i); if ($ig->delete() !== false) { ItemGroupHandler::removeChildren($i, false, 'group'); $total++; } } if ($total == 0) { echo "<script> alert('" . html_entity_decode(JText::_('AEC_MSG_NO_ITEMS_TO_DELETE')) . "'); window.history.go(-1);</script>\n"; exit; } else { $msg = $total . ' ' . JText::_('AEC_MSG_ITEMS_DELETED'); aecRedirect('index.php?option=com_acctexp&task=showItemGroups', $msg); } }
public function delete($pk = null) { ItemGroupHandler::removeChildren($this->id); return parent::delete($pk); }