diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-01-13 12:03:27 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-01-13 12:03:27 +0000 |
commit | 5dfb9a97cd5d99479610339f1c613f1468b96687 (patch) | |
tree | 04000c7a06cbf85506209a93a09ba7e1bbfc65b0 /mod/groups/actions/discussion | |
parent | 901f4bebb98a32212c836888ce7ee4bc15452eec (diff) | |
download | elgg-5dfb9a97cd5d99479610339f1c613f1468b96687.tar.gz elgg-5dfb9a97cd5d99479610339f1c613f1468b96687.tar.bz2 |
discussion topics using new page handler
git-svn-id: http://code.elgg.org/elgg/trunk@7880 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/groups/actions/discussion')
-rw-r--r-- | mod/groups/actions/discussion/delete.php | 29 | ||||
-rw-r--r-- | mod/groups/actions/discussion/save.php | 75 |
2 files changed, 104 insertions, 0 deletions
diff --git a/mod/groups/actions/discussion/delete.php b/mod/groups/actions/discussion/delete.php new file mode 100644 index 000000000..c3de612d7 --- /dev/null +++ b/mod/groups/actions/discussion/delete.php @@ -0,0 +1,29 @@ +<?php +/** + * Delete topic action + * + */ + +$topic_guid = (int) get_input('guid'); + +$topic = get_entity($topic_guid); +if (!$topic || !$topic->getSubtype() == "groupforumtopic") { + register_error(elgg_echo('discussion:error:notdeleted')); + forward(REFERER); +} + +if (!$topic->canEdit()) { + register_error(elgg_echo('discussion:error:permissions')); + forward(REFERER); +} + +$container = $topic->getContainerEntity(); + +$result = $topic->delete(); +if ($result) { + system_message(elgg_echo('discussion:topic:deleted')); +} else { + register_error(elgg_echo('discussion:error:notdeleted')); +} + +forward("pg/discussion/owner/$container->guid"); diff --git a/mod/groups/actions/discussion/save.php b/mod/groups/actions/discussion/save.php new file mode 100644 index 000000000..8e8f08a50 --- /dev/null +++ b/mod/groups/actions/discussion/save.php @@ -0,0 +1,75 @@ +<?php +/** + * Topic save action + */ + +// Get variables +$title = get_input("title"); +$desc = get_input("description"); +$status = get_input("status"); +$access_id = (int) get_input("access_id"); +$container_guid = (int) get_input('container_guid'); +$guid = (int) get_input('topic_guid'); +$tags = get_input("tags"); + +elgg_make_sticky_form('topic'); + +// validation of inputs +if (!$title || !$desc) { + register_error(elgg_echo('discussion:error:missing')); + forward(REFERER); +} + +$container = get_entity($container_guid); +if (!$container || (!$container->isMember() && !$container->canEdit())) { + register_error(elgg_echo('discussion:error:permissions')); + forward(REFERER); +} + +// check whether this is a new topic or an edit +$new_topic = true; +if ($guid > 0) { + $new_topic = false; +} + +if ($new_topic) { + $topic = new ElggObject(); + $topic->subtype = 'groupforumtopic'; +} else { + // load original file object + $topic = new ElggObject($guid); + if (!$topic || !$topic->canEdit()) { + register_error(elgg_echo('discussion:topic:notfound')); + forward(REFERER); + } +} + +$topic->title = $title; +$topic->description = $desc; +$topic->status = $status; +$topic->access_id = $access_id; +$topic->container_guid = $container_guid; + +$tags = explode(",", $tags); +$topic->tags = $tags; + +$result = $topic->save(); + +if (!$result) { + register_error(elgg_echo('discussion:error:notsaved')); + forward(REFERER); +} + +// topic saved so clear sticky form +elgg_clear_sticky_form('topic'); + + +// handle results differently for new topics and topic edits +if ($new_topic) { + system_message(elgg_echo('discussion:topic:created')); + add_to_river('river/forum/topic/create', 'create', get_loggedin_userid(), $topic->guid); +} else { + system_message(elgg_echo('discussion:topic:updated')); +} + +forward($topic->getURL()); |