Example #1
0
<?php

include '../include/admin-header.php';
if ($db) {
    if ($action == 'add') {
        if (array_key_exists('name', $_POST) && array_key_exists('definition', $_POST)) {
            if ($db->insert_row('aggregators', 'aggregator', array('name' => $_POST['name'], 'definition' => $_POST['definition']))) {
                notice('Inserted the new aggregator');
            } else {
                notice('Could not add the aggregator');
            }
        } else {
            notice('Invalid parameters.');
        }
    } else {
        if ($action == 'update') {
            if (!update_field('aggregators', 'aggregator', 'name') && !update_field('aggregators', 'aggregator', 'definition')) {
                notice('Invalid parameters.');
            }
        }
    }
    $page = new AdministrativePage($db, 'aggregators', 'aggregator', array('name' => array('editing_mode' => 'string'), 'definition' => array('editing_mode' => 'text')));
    $page->render_table('name');
    $page->render_form_to_add();
}
include '../include/admin-footer.php';
Example #2
0
    $platforms = $db->fetch_table('platforms', 'platform_name');
    function merge_list($platform_row)
    {
        global $db;
        global $platforms;
        $id = $platform_row['platform_id'];
        $content = <<<END
<form method="POST"><input type="hidden" name="id" value="{$id}">
<select name="destination">
END;
        foreach ($platforms as $platform) {
            if ($platform['platform_id'] == $id) {
                continue;
            }
            $content .= <<<END
<option value="{$platform['platform_id']}">{$platform['platform_name']}</option>
END;
        }
        $content .= <<<END
</select>
<button type="submit" name="action" value="merge">Merge</button>
</form>
END;
        return array($content);
    }
    $page = new AdministrativePage($db, 'platforms', 'platform', array('name' => array('editing_mode' => 'string'), 'hidden' => array('editing_mode' => 'boolean'), 'merge into' => array('custom' => function ($platform_row) {
        return merge_list($platform_row);
    })));
    $page->render_table('name');
}
include '../include/admin-footer.php';
Example #3
0
                }
            }
        }
    }
    function associated_repositories($row)
    {
        global $db;
        $tracker_repositories = $db->query_and_fetch_all('SELECT * FROM repositories LEFT OUTER JOIN tracker_repositories
            ON tracrepo_repository = repository_id AND (tracrepo_tracker = $1 OR tracrepo_tracker IS NULL)
            ORDER BY repository_name', array($row['tracker_id']));
        $content = <<<END
<form method="POST"><input type="hidden" name="id" value="{$row['tracker_id']}">
END;
        foreach ($tracker_repositories as $repository) {
            $id = intval($repository['repository_id']);
            $name = htmlspecialchars($repository['repository_name']);
            $checked = $repository['tracrepo_tracker'] ? ' checked' : '';
            $content .= "<label><input type=\"checkbox\" name=\"tracker_repositories[]\" value=\"{$id}\"{$checked}>{$name}</label>";
        }
        $content .= <<<END
<button type="submit" name="action" value="associate">Save</button></form>
END;
        return array($content);
    }
    $page = new AdministrativePage($db, 'bug_trackers', 'tracker', array('name' => array('editing_mode' => 'string'), 'bug_url' => array('editing_mode' => 'url', 'label' => 'Bug URL ($number)'), 'new_bug_url' => array('editing_mode' => 'text', 'label' => 'New Bug URL ($title, $description)'), 'Associated repositories' => array('custom' => function ($row) {
        return associated_repositories($row);
    })));
    $page->render_table('name');
    $page->render_form_to_add('New Bug Tracker');
}
include '../include/admin-footer.php';