require_once Environment::getBasePath() . 'includes/Interface.inc.php';
if (!$permission->Check('help', 'enabled') or !($permission->Check('help', 'edit') or $permission->Check('help', 'edit_own'))) {
    $permission->Redirect(FALSE);
    //Redirect
}
$smarty->assign('title', TTi18n::gettext($title = 'Edit Help Group'));
// See index.php
/*
 * Get FORM variables
 */
extract(FormVariables::GetVariables(array('action', 'id', 'help_data', 'script', 'name')));
$hgcf = new HelpGroupControlFactory();
switch ($action) {
    case 'submit':
        Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
        $hgcf->setId($help_data['id']);
        $hgcf->setScriptName($help_data['script_name']);
        $hgcf->setName($help_data['name']);
        if ($hgcf->isValid()) {
            $hgcf->Save();
            Redirect::Page(URLBuilder::getURL(NULL, 'HelpGroupControlList.php'));
            break;
        }
    default:
        $hgclf = new HelpGroupControlListFactory();
        if (isset($script) and !isset($id)) {
            Debug::Text('Script and Name were passed, attempt lookup!', __FILE__, __LINE__, __METHOD__, 10);
            $hgclf->getByScriptAndName($script, $name);
            if ($hgclf->getRecordCount() > 0) {
                $id = $hgclf->getCurrent()->getID();
                Debug::Text('Found already existing ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10);