echo "</tr>\n";
    }
    echo "</table>\n";
} else {
    $imso_code = $_GET['name'];
    $imso = mysql_fetch_assoc(mysql_query("\n        SELECT\n            full_name,\n            display_name,\n            public_comment,\n            internal_comment,\n            info_page_visibility,\n            concat('<a href=\"',url,'\">',url,'</a>') as 'info_url'\n        FROM image_sources\n        WHERE code_name = '{$imso_code}'\n    "));
    $visibility = $imso['info_page_visibility'];
    // info page visibility
    //  0 = Image Source Managers and SAs
    //  1 = also any PM
    //  2 = also any logged-in user
    //  3 = anyone
    // layout below intended to make logic easier to follow:
    // see it as a tree lying on it's side, the root node the "or"
    // on the third line
    $can_see = ($visibility == 3 or $logged_in and ($visibility == 2 or user_is_PM() and $visibility == 1 or user_is_image_sources_manager()));
    if ($can_see) {
        $base_link = "<a href='show_image_sources.php?name=%s&which=%s'>%s</a>";
        $all_link = sprintf($base_link, $imso_code, "ALL", _("All"));
        $inprog_link = sprintf($base_link, $imso_code, "INPROG", _("In-Progress"));
        $done_link = sprintf($base_link, $imso_code, "DONE", _("Completed"));
        switch ($which) {
            case 'ALL':
                $where_cls = " AND state != 'project_delete'";
                $title = sprintf(_("All Ebooks being produced with images from %s"), $imso['full_name']);
                $links_list = $inprog_link . ", " . $done_link . ".";
                break;
            case 'INPROG':
                $where_cls = " AND state != 'project_delete' AND state != 'proj_submit_pgposted'";
                $title = sprintf(_("In-Progress Ebooks being produced with images from %s"), $imso['full_name']);
                $links_list = $all_link . ", " . $done_link . ".";
include_once $relPath . 'theme.inc';
include_once $relPath . 'project_states.inc';
include_once $relPath . 'user_is.inc';
include_once $relPath . 'maybe_mail.inc';
include_once $relPath . 'metarefresh.inc';
include_once $relPath . 'misc.inc';
// attr_safe(), html_safe()
include_once $relPath . 'SettingsClass.inc';
include_once $relPath . 'User.inc';
include_once $relPath . 'misc.inc';
// get_enumerated_param()
require_login();
$theme_args['css_data'] = "\ntable.listing { border-collapse: collapse; width: 80%; margin: auto;}\ntable.listing td { border: 1px solid #999; padding: 5px; }\ntable.listing tr.e { background-color: #eee; }\ntable.listing tr.o { background-color: #ddd; }\ntable.listing td.enabled { background-color: #9f9; text-align: center; }\ntable.listing td.disabled { background-color: #ddd; text-align: center; }\ntable.listing td.center { text-align: center; }\ntable.listing td.pending { background-color: #ff8; text-align: center; }\nform { padding-top: 10px; margin: 0; }\ninput[type='submit'] { margin: 2px; }\n\ntable.source { border-collapse: collapse; width: 80%;\n    margin: auto; margin-bottom: 1em; }\ntable.source td { border: 1px solid black; padding: 5px; background-color: #eeeeee; }\ntable.source td.pa { width: 30%; font-weight: bold; }\ntable.source td.center { text-align: center; }\ndiv.perms_wrapper { width: 40%; display: inline-block;\n    border-bottom: dotted black 1px; padding: 2px; }\np.toolbar { text-align: center; margin: 5px 0 5px 0; }\n.error { font-weight: bold; color: red; margin: 4px; }";
$page_url = "{$code_url}/tools/project_manager/manage_image_sources.php?";
$action = get_enumerated_param($_REQUEST, 'action', 'show_sources', array('show_sources', 'add_source', 'update_oneshot'));
$can_edit = user_is_image_sources_manager();
// Action 'update_oneshot' is used as a target for form submit buttons. The
// desired action is based on the submit button's name. Here we do the action
// and set $action to 'show_sources' to display the list all in one page load.
if ($action == 'update_oneshot') {
    if (isset($_REQUEST['edit'])) {
        $action = 'edit_source';
    } elseif (isset($_REQUEST['enable'])) {
        $source = new ImageSource($_REQUEST['source']);
        $source->enable();
        $action = 'show_sources';
    } elseif (isset($_REQUEST['disable'])) {
        $source = new ImageSource($_REQUEST['source']);
        $source->disable();
        $action = 'show_sources';
    } elseif (isset($_REQUEST['approve'])) {