aboutsummaryrefslogtreecommitdiffstats
path: root/mod/item.php
diff options
context:
space:
mode:
authorMichael Johnston <michaelgeorgejohnston@gmail.com>2012-04-01 21:28:31 -0400
committerMichael Johnston <michaelgeorgejohnston@gmail.com>2012-04-01 21:28:31 -0400
commit581b54c974a9b9a050a8a0b9a17a19bd41b1f2f5 (patch)
treec2a3f1e1d1aaf5e3e2f6d9b194e91d6b8b401cdd /mod/item.php
parent06e9a8b7a0d6b5be141563c77ae3a71e9998b81f (diff)
downloadvolse-hubzilla-581b54c974a9b9a050a8a0b9a17a19bd41b1f2f5.tar.gz
volse-hubzilla-581b54c974a9b9a050a8a0b9a17a19bd41b1f2f5.tar.bz2
volse-hubzilla-581b54c974a9b9a050a8a0b9a17a19bd41b1f2f5.zip
allow users to set categories on their posts
Diffstat (limited to 'mod/item.php')
-rwxr-xr-xmod/item.php30
1 files changed, 24 insertions, 6 deletions
diff --git a/mod/item.php b/mod/item.php
index 24730f53e..72e63865b 100755
--- a/mod/item.php
+++ b/mod/item.php
@@ -216,8 +216,6 @@ function item_post(&$a) {
$emailcc = notags(trim($_REQUEST['emailcc']));
$body = escape_tags(trim($_REQUEST['body']));
- // $categories = TODO
-
$private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);
if(($parent_item) &&
@@ -255,6 +253,19 @@ function item_post(&$a) {
}
}
+ if(strlen($categories)) {
+ // get the "fileas" tags for this post
+ $filedas = file_tag_file_to_list($categories, 'file');
+ }
+ // save old and new categories, so we can determine what needs to be deleted from pconfig
+ $categories_old = $categories;
+ $categories = file_tag_list_to_file(trim($_REQUEST['category']), 'category');
+ $categories_new = $categories;
+ if(strlen($filedas)) {
+ // append the fileas stuff to the new categories list
+ $categories .= file_tag_list_to_file($filedas, 'file');
+ }
+
// Work around doubled linefeeds in Tinymce 3.5b2
// First figure out if it's a status post that would've been
// created using tinymce. Otherwise leave it alone.
@@ -572,6 +583,9 @@ function item_post(&$a) {
intval($profile_uid)
);
+ // update filetags in pconfig
+ file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
+
proc_run('php', "include/notifier.php", 'edit_post', "$post_id");
if((x($_REQUEST,'return')) && strlen($return_path)) {
logger('return: ' . $return_path);
@@ -585,8 +599,8 @@ function item_post(&$a) {
$r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
- `tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated` )
- VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d )",
+ `tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file` )
+ VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s' )",
dbesc($datarray['guid']),
intval($datarray['uid']),
dbesc($datarray['type']),
@@ -624,8 +638,9 @@ function item_post(&$a) {
dbesc($datarray['attach']),
intval($datarray['bookmark']),
intval($datarray['origin']),
- intval($datarray['moderated'])
- );
+ intval($datarray['moderated']),
+ dbesc($datarray['file'])
+ );
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($datarray['uri']));
@@ -633,6 +648,9 @@ function item_post(&$a) {
$post_id = $r[0]['id'];
logger('mod_item: saved item ' . $post_id);
+ // update filetags in pconfig
+ file_tag_update_pconfig($uid,$categories_old,$categories_new,'category');
+
if($parent) {
// This item is the last leaf and gets the comment box, clear any ancestors