summaryrefslogtreecommitdiff
path: root/lib/file/editfld.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/file/editfld.php')
-rw-r--r--lib/file/editfld.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/file/editfld.php b/lib/file/editfld.php
new file mode 100644
index 0000000..db5a304
--- /dev/null
+++ b/lib/file/editfld.php
@@ -0,0 +1,44 @@
+<?php
+
+require("lib/markdown.php");
+
+assert_redir(count($args) == 3, 'file');
+$fldid = intval($args[2]);
+
+$fld = mysql_fetch_assoc(sql(
+ "SELECT id, name, comment, public, owner ".
+ "FROM folders WHERE id = $fldid"
+ ));
+assert_error($fld && $fld['owner'] == $user['id'],
+ "This folder does not exist, or you are not allowed to edit it.");
+
+$fld_name = $fld['name'];
+$fld_comment = $fld['comment'];
+$fld_public = $fld['public'];
+if (isset($_POST['name']) && isset($_POST['comment'])) {
+ $fld_public = isset($_POST['public']);
+ $fld_name = esca($_POST['name']);
+ $fld_comment = esca($_POST['comment']);
+ $fld_comment_html = Markdown($fld_comment);
+ if ($fld_name == "") {
+ $error = "You must enter a name for your folder.";
+ } else {
+ sql("UPDATE folders SET name = '" . escs($fld_name) . "', comment = '" . escs($fld_comment) .
+ "', comment_html = '" . escs($fld_comment_html) . "', public = " . ($fld_public?'1':'0') .
+ " WHERE id = $fldid");
+ header("Location: folder-file-" . $fldid);
+ die();
+ }
+
+}
+
+$title = "Edit folder";
+$fields = array(
+ array("label" => "Folder name : ", "name" => "name", "value" => $fld_name),
+ array("label" => "Public ? ", "name" => "public", "type" => "checkbox", "checked" => $fld_public),
+ array("label" => "Comment : ", "name" => "comment", "type" => "textarea", "value" => $fld_comment),
+ );
+$validate = "Save";
+
+require("tpl/general/form.php");
+