summaryrefslogtreecommitdiff
path: root/lib/image/editfld.php
diff options
context:
space:
mode:
authorNicolas BERNSTEIN <alexis211@gmail.com>2012-03-18 14:08:31 +0100
committerNicolas BERNSTEIN <alexis211@gmail.com>2012-03-18 14:08:31 +0100
commitccff9ce8d8a2818699ce4e20a310986fc95ea022 (patch)
treec585ead91c894c621c73b63bc84012709e795151 /lib/image/editfld.php
parent24547ccec6526fcef3cccb34bc35fb81f31236b3 (diff)
downloadBits-ccff9ce8d8a2818699ce4e20a310986fc95ea022.tar.gz
Bits-ccff9ce8d8a2818699ce4e20a310986fc95ea022.zip
Added a way of classifying images in folders.
Diffstat (limited to 'lib/image/editfld.php')
-rw-r--r--lib/image/editfld.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/image/editfld.php b/lib/image/editfld.php
new file mode 100644
index 0000000..a0bef1f
--- /dev/null
+++ b/lib/image/editfld.php
@@ -0,0 +1,44 @@
+<?php
+
+require("lib/markdown.php");
+
+assert_redir(count($args) == 3, 'image');
+$fldid = intval($args[2]);
+
+$fld = mysql_fetch_assoc(sql(
+ "SELECT id, name, comment, public, owner ".
+ "FROM img_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 img_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-image-" . $fldid);
+ die();
+ }
+
+}
+
+$title = "Edit folder";
+$fields = array(
+ array("label" => "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");
+