exit;
}
if (isset($_POST["share_path"])) {
    folder_save();
    exit;
}
if (isset($_POST["share_delete"])) {
    folder_delete();
    exit;
}
if (isset($_POST["browsable"])) {
    params_save();
    exit;
}
if (isset($_GET["folder-id"])) {
    folder_edit();
    exit;
}
start();
function start()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $html = "\n\t<center>\n\t\t<table style='width:99%' class=form>\n\t\t\t<tr>\n\t\t\t\t<td class=legend>{folders}:</td>\n\t\t\t\t<td>" . Field_text("browse-sambaF-search", null, "font-size:14px;padding:3px", null, null, null, false, "BrowseSambaFSearchCheck(event)") . "</td>\n\t\t\t\t<td>" . button("{search}", "BrowseSambaFSearch()") . "</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t</center>\n\t<div id='browse-sambaF-list' style='width:100%;height:420px;overflow:auto;text-align:center'></div>\n\t\t\n<script>\n\t\tfunction BrowseSambaFSearchCheck(e){\n\t\t\tif(checkEnter(e)){BrowseSambaFSearch();}\n\t\t}\n\t\t\n\t\tfunction BrowseSambaFSearch(){\n\t\t\tvar se=escape(document.getElementById('browse-sambaF-search').value);\n\t\t\tLoadAjax('browse-sambaF-list','{$page}?browse-folder-list=yes&hostname={$_GET["hostname"]}&search='+se+'&field={$_GET["field"]}');\n\t\t}\n\t\t\n\t\t\t\n\tBrowseSambaFSearch();\n</script>";
    echo $tpl->_ENGINE_parse_body($html);
}
function folders_list()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $users = new usersMenus();
Ejemplo n.º 2
0
function folder_admin()
{
    // Fix for #16: Admin (et al.) should not rely on l10n labels for actions:
    // Look for a meta-action first, which should be the (untranslated) *name* of
    // the (translated) action constant.
    // Fixme: should replace 'action's with a constant
    if (array_key_exists(CST_ADMIN_METAACTION, $_REQUEST)) {
        $__action__ = $_REQUEST[CST_ADMIN_METAACTION];
    } elseif (array_key_exists('action', $_REQUEST)) {
        $__action__ = $_REQUEST['action'];
    } else {
        $__action__ = "";
    }
    if (isset($_REQUEST['fid'])) {
        $fid = sanitize($_REQUEST['fid'], RSS_SANITIZER_NUMERIC);
    }
    $ret__ = CST_ADMIN_DOMAIN_FOLDER;
    switch ($__action__) {
        case CST_ADMIN_EDIT_ACTION:
            folder_edit($fid);
            $ret__ = CST_ADMIN_DOMAIN_NONE;
            break;
        case CST_ADMIN_DELETE_ACTION:
            if ($fid == 0) {
                rss_error(__("You can't delete the Root folder"), RSS_ERROR_ERROR, true);
                break;
            }
            if (array_key_exists(CST_ADMIN_CONFIRMED, $_POST) && $_POST[CST_ADMIN_CONFIRMED] == __('Yes')) {
                $sql = "delete from " . getTable("folders") . " where id={$fid}";
                rss_query($sql);
                $sql = "update " . getTable("channels") . " set parent=" . getRootFolder() . " where parent={$fid}";
                rss_query($sql);
                rss_invalidate_cache();
            } elseif (array_key_exists(CST_ADMIN_CONFIRMED, $_REQUEST) && $_REQUEST[CST_ADMIN_CONFIRMED] == __('No')) {
                // nop;
            } else {
                list($fname) = rss_fetch_row(rss_query("select name from " . getTable("folders") . " where id = {$fid}"));
                echo "<form class=\"box\" method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\">\n" . "<p class=\"error\">";
                printf(__("Are you sure you wish to delete '%s'?"), $fname);
                echo "</p>\n" . "<p><input type=\"submit\" name=\"" . CST_ADMIN_CONFIRMED . "\" value=\"" . __('No') . "\"/>\n" . "<input type=\"submit\" name=\"" . CST_ADMIN_CONFIRMED . "\" value=\"" . __('Yes') . "\"/>\n" . "<input type=\"hidden\" name=\"fid\" value=\"{$fid}\"/>\n" . "<input type=\"hidden\" name=\"" . CST_ADMIN_DOMAIN . "\" value=\"" . CST_ADMIN_DOMAIN_FOLDER . "\"/>\n" . "<input type=\"hidden\" name=\"action\" value=\"" . CST_ADMIN_DELETE_ACTION . "\"/>\n" . "</p>\n</form>\n";
                $ret__ = CST_ADMIN_DOMAIN_NONE;
            }
            break;
        case CST_ADMIN_SUBMIT_EDIT:
            // TBD
            $new_label = sanitize($_REQUEST['f_name'], RSS_SANITIZER_URL);
            $new_label = rss_real_escape_string($new_label);
            if (is_numeric($fid) && strlen($new_label) > 0) {
                $res = rss_query("select count(*) as cnt from " . getTable("folders") . " where binary name='{$new_label}'");
                list($cnt) = rss_fetch_row($res);
                if ($cnt > 0) {
                    rss_error(sprintf(__("You can't rename this item '%s' because such an item already exists."), $new_label), RSS_ERROR_ERROR, true);
                    break;
                }
                rss_query("update " . getTable("folders") . " set name='{$new_label}' where id={$fid}");
                rss_invalidate_cache();
            }
            break;
        case __('Add'):
        case 'ACT_ADMIN_ADD':
            $label = sanitize($_REQUEST['new_folder'], RSS_SANITIZER_URL);
            $new_label = rss_real_escape_string($new_label);
            assert(strlen($label) > 0);
            create_folder($label);
            break;
        case CST_ADMIN_MOVE_UP_ACTION:
        case CST_ADMIN_MOVE_DOWN_ACTION:
            if ($fid == 0) {
                return;
            }
            $res = rss_query("select position from " . getTable("folders") . " where id={$fid}");
            list($position) = rss_fetch_row($res);
            $sql = "select id, position from " . getTable("folders") . " where\tid != {$fid} order by abs({$position}-position) limit 2";
            $res = rss_query($sql);
            // Let's look for a lower/higher position than the one we got.
            $switch_with_position = $position;
            while (list($oid, $oposition) = rss_fetch_row($res)) {
                if ($switch_with_position == $position && ($_REQUEST['action'] == CST_ADMIN_MOVE_UP_ACTION && $oposition < $switch_with_position || $_REQUEST['action'] == CST_ADMIN_MOVE_DOWN_ACTION && $oposition > $switch_with_position)) {
                    $switch_with_position = $oposition;
                    $switch_with_id = $oid;
                }
            }
            // right, lets!
            if ($switch_with_position != $position) {
                rss_query("update " . getTable("folders") . " set position = {$switch_with_position} where id={$fid}");
                rss_query("update " . getTable("folders") . " set position = {$position} where id={$switch_with_id}");
                rss_invalidate_cache();
            }
            break;
        default:
            break;
    }
    return $ret__;
}