aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/groups/actions/discussion/delete.php29
-rw-r--r--mod/groups/actions/discussion/save.php75
-rw-r--r--mod/groups/actions/forums/addtopic.php76
-rw-r--r--mod/groups/actions/forums/deletetopic.php38
-rw-r--r--mod/groups/actions/forums/edittopic.php66
-rw-r--r--mod/groups/addtopic.php21
-rw-r--r--mod/groups/edittopic.php25
-rw-r--r--mod/groups/forum.php45
-rw-r--r--mod/groups/languages/en.php22
-rw-r--r--mod/groups/lib/discussion.php209
-rw-r--r--mod/groups/start.php77
-rw-r--r--mod/groups/topicposts.php46
-rw-r--r--mod/groups/views/default/forms/discussion/save.php56
-rw-r--r--mod/groups/views/default/forms/forums/addtopic.php103
-rw-r--r--mod/groups/views/default/forms/forums/edittopic.php96
-rw-r--r--mod/groups/views/default/forum/maintopic.php2
-rw-r--r--mod/groups/views/default/forum/viewposts.php5
-rw-r--r--mod/groups/views/default/groups/group_sort_menu.php2
-rw-r--r--mod/groups/views/default/groups/profile/forum_widget.php4
-rw-r--r--mod/groups/views/default/object/groupforumtopic.php2
20 files changed, 455 insertions, 544 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());
diff --git a/mod/groups/actions/forums/addtopic.php b/mod/groups/actions/forums/addtopic.php
deleted file mode 100644
index 0b8a0f590..000000000
--- a/mod/groups/actions/forums/addtopic.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-
- /**
- * Elgg groups plugin add topic action.
- *
- * @package ElggGroups
- */
-
- // Make sure we're logged in; forward to the front page if not
- if (!isloggedin()) forward();
-
- // Check the user is a group member
- $group_entity = get_entity(get_input('group_guid'));
- if (!$group_entity->isMember(get_loggedin_user())) forward();
-
- // Get input data
- $title = strip_tags(get_input('topictitle'));
- $message = get_input('topicmessage');
- $tags = get_input('topictags');
- $access = get_input('access_id');
- $group_guid = (int) get_input('group_guid');
- $user = get_loggedin_userid(); // you need to be logged in to comment on a group forum
- $status = get_input('status'); // sticky, resolved, closed
-
- // Convert string of tags into a preformatted array
- $tagarray = string_to_tag_array($tags);
-
- // Make sure the title / message aren't blank
- if (empty($title) || empty($message)) {
- register_error(elgg_echo("grouptopic:blank"));
- forward("pg/groups/forum/{$group_guid}/");
-
- // Otherwise, save the topic
- } else {
-
- // Initialise a new ElggObject
- $grouptopic = new ElggObject();
- // Tell the system it's a group forum topic
- $grouptopic->subtype = "groupforumtopic";
- // Set its owner to the current user
- $grouptopic->owner_guid = $user;
- // Set the group it belongs to
- $grouptopic->container_guid = $group_guid;
- // For now, set its access to public (we'll add an access dropdown shortly)
- $grouptopic->access_id = $access;
- // Set its title and description appropriately
- $grouptopic->title = $title;
- // Set its title and description appropriately
- $grouptopic->description = $message;
- // Before we can set metadata, we need to save the topic
- if (!$grouptopic->save()) {
- register_error(elgg_echo("grouptopic:error"));
- forward("pg/groups/forum/{$group_guid}/");
- }
- // Now let's add tags. We can pass an array directly to the object property! Easy.
- if (is_array($tagarray)) {
- $grouptopic->tags = $tagarray;
- }
- // add metadata
- $grouptopic->status = $status; // the current status i.e sticky, closed, resolved, open
-
- // add to river
- add_to_river('river/forum/topic/create','create',get_loggedin_userid(),$grouptopic->guid);
-
- // Success message
- system_message(elgg_echo("grouptopic:created"));
-
- // Forward to the group forum page
- global $CONFIG;
- $url = elgg_get_site_url() . "pg/groups/forum/{$group_guid}/";
- forward($url);
-
- }
-
-?>
-
diff --git a/mod/groups/actions/forums/deletetopic.php b/mod/groups/actions/forums/deletetopic.php
deleted file mode 100644
index c67228a2f..000000000
--- a/mod/groups/actions/forums/deletetopic.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
- /**
- * Elgg Groups: delete topic action
- *
- * @package ElggGroups
- */
-
- $group_entity = get_entity(get_input('group'));
-
- // Get input data
- $topic_guid = (int) get_input('topic');
- $group_guid = (int) get_input('group');
-
- $topic = get_entity($topic_guid);
- if ($topic->getSubtype() == "groupforumtopic") {
-
- // Make sure we actually have permission to edit
- if (!$topic->canEdit()) {
- register_error(elgg_echo("groupstopic:notdeleted"));
- forward(REFERER);
- }
-
- // Delete it!
- $rowsaffected = $topic->delete();
- if ($rowsaffected > 0) {
- // Success message
- system_message(elgg_echo("groupstopic:deleted"));
- } else {
- register_error(elgg_echo("groupstopic:notdeleted"));
- }
- // Forward to the group forum page
- $url = elgg_get_site_url() . "pg/groups/forum/{$group_guid}/";
- forward($url);
-
- }
-
-?> \ No newline at end of file
diff --git a/mod/groups/actions/forums/edittopic.php b/mod/groups/actions/forums/edittopic.php
deleted file mode 100644
index b032e37d7..000000000
--- a/mod/groups/actions/forums/edittopic.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/**
-* Elgg groups plugin edit topic action.
- */
-
-// Make sure we're logged in (send us to the front page if not)
-if (!isloggedin()) forward();
-
-// Check the user is a group member
-$group_entity = get_entity(get_input('group_guid'));
-if (!$group_entity->isMember(get_loggedin_user())) forward();
-
-// Get input data
-$title = strip_tags(get_input('topictitle'));
-$message = get_input('topicmessage');
-$message_id = get_input('message_id');
-$tags = get_input('topictags');
-$topic_guid = get_input('topic');
-$access = get_input('access_id');
-$group_guid = get_input('group_guid');
-$status = get_input('status'); // open, closed
-
-// Convert string of tags into a preformatted array
-$tagarray = string_to_tag_array($tags);
-
-// Make sure we actually have permission to edit
-$topic = get_entity($topic_guid);
-if ($topic){
- $user = $topic->getOwnerGUID();
- if ($topic->getSubtype() == "groupforumtopic") {
-
- // Convert string of tags into a preformatted array
- $tagarray = string_to_tag_array($tags);
-
- // Make sure the title isn't blank
- if (empty($title) || empty($message)) {
- register_error(elgg_echo("groupstopic:blank"));
-
- // Otherwise, save the forum
- } else {
- $topic->access_id = $access;
- // Set its title
- $topic->title = $title;
- // Set the message
- $topic->description = $message;
- // if no tags are present, clear existing ones
- if (is_array($tagarray)) {
- $topic->tags = $tagarray;
- } else $topic->clearMetadata('tags');
- // edit metadata
- $topic->status = $status; // the current status i.e sticky, closed, resolved
-
- // save the changes
- if (!$topic->save()) {
- // register_error(elgg_echo("forumtopic:error"));
- }
- // Success message
- system_message(elgg_echo("groups:forumtopic:edited"));
- }
- }
-}
-// Forward to the discussion
-global $CONFIG;
-$url = elgg_get_site_url() . "mod/groups/topicposts.php?topic={$topic_guid}&group_guid={$group_guid}/";
-forward($url);
-
diff --git a/mod/groups/addtopic.php b/mod/groups/addtopic.php
deleted file mode 100644
index 008f34d9e..000000000
--- a/mod/groups/addtopic.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-/**
- * Elgg Groups add a forum topic page
- */
-
-// Load Elgg engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-group_gatekeeper();
-
-$page_owner = set_page_owner((int) get_input('group_guid'));
-
-if (!(elgg_get_page_owner() instanceof ElggGroup)) forward();
-
-// sort the display
-$area2 = elgg_view("forms/forums/addtopic");
-$content = $area1 . $area2;
-$body = elgg_view_layout('one_column_with_sidebar', array('content' => $content));
-
-// Display page
-echo elgg_view_page(elgg_echo('groups:addtopic'),$body); \ No newline at end of file
diff --git a/mod/groups/edittopic.php b/mod/groups/edittopic.php
deleted file mode 100644
index 73730904f..000000000
--- a/mod/groups/edittopic.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-/**
- * Elgg Groups edit a forum topic page
- */
-
-// Load Elgg engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-gatekeeper();
-
-get_input('group');
-$page_owner = set_page_owner((int)get_input('group'));
-
-// check the user is a member of the group
-if (!(elgg_get_page_owner() instanceof ElggGroup)) forward();
-
-//get the topic
-$topic = get_entity((int) get_input('topic'));
-
-// sort the display
-$area2 = elgg_view("forms/forums/edittopic", array('entity' => $topic));
-$body = elgg_view_layout('one_column_with_sidebar', array('content' => $area2));
-
-// Display page
-echo elgg_view_page(elgg_echo('groups:edittopic'),$body); \ No newline at end of file
diff --git a/mod/groups/forum.php b/mod/groups/forum.php
deleted file mode 100644
index 55f7dd95e..000000000
--- a/mod/groups/forum.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-/**
- * Elgg groups forum
- */
-
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-$group_guid = (int)get_input('group_guid');
-set_page_owner($group_guid);
-if (!(elgg_get_page_owner() instanceof ElggGroup)) {
- forward();
-}
-
-group_gatekeeper();
-
-//get any forum topics
-$options = array(
- 'type' => 'object',
- 'subtype' => 'groupforumtopic',
- 'limit' => 20,
- 'order_by' => 'e.last_action desc',
- 'container_guid' => $group_guid,
- 'fullview' => FALSE
-);
-
-//$topics = elgg_list_entities_from_annotations($options);
-$topics = elgg_list_entities($options);
-
-// set up breadcrumbs
-$group = get_entity($group_guid);
-elgg_push_breadcrumb(elgg_echo('groups'), elgg_get_site_url()."pg/groups/world/");
-elgg_push_breadcrumb($group->name, $group->getURL());
-elgg_push_breadcrumb(elgg_echo('item:object:groupforumtopic'));
-
-$area1 = elgg_view('navigation/breadcrumbs');
-
-$area1 .= elgg_view("forum/topics", array('topics' => $topics, 'group_guid' => $group_guid));
-elgg_set_context('groups');
-
-$body = elgg_view_layout('one_column_with_sidebar', array('content' => $area1));
-
-$title = elgg_echo('item:object:groupforumtopic');
-
-// Finally draw the page
-echo elgg_view_page($title, $body); \ No newline at end of file
diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php
index 1d136e741..af4592f99 100644
--- a/mod/groups/languages/en.php
+++ b/mod/groups/languages/en.php
@@ -89,19 +89,28 @@ $english = array(
/*
Group tools
*/
- 'groups:enablepages' => 'Enable group pages',
'groups:enableforum' => 'Enable group discussion',
- 'groups:enablefiles' => 'Enable group files',
'groups:yes' => 'yes',
'groups:no' => 'no',
'groups:lastupdated' => 'Last updated %s by %s',
'groups:lastcomment' => 'Last comment %s by %s',
- 'groups:pages' => 'Group pages',
- 'groups:files' => 'Group files',
/*
- Group forum strings
+ Group discussion
*/
+ 'discussion' => 'Discussion',
+ 'discussion:add' => 'New discussion topic',
+ 'discussion:latest' => 'Latest discussion',
+
+ 'discussion:topic:created' => 'The discussion topic was created.',
+ 'discussion:topic:updated' => 'The discussion topic was updated.',
+ 'discussion:topic:deleted' => 'Discussion topic has been deleted.',
+
+ 'discussion:topic:notfound' => 'Discussion topic not found',
+ 'discussion:error:notsaved' => 'Unable to save this topic',
+ 'discussion:error:missing' => 'Both title and message are required fields',
+ 'discussion:error:permissions' => 'You do not have permissions to perform this action',
+ 'discussion:error:notdeleted' => 'Could not delete the discussion topic',
'group:replies' => 'Replies',
'groups:forum:created' => 'Created %s with %d comments',
@@ -134,6 +143,8 @@ $english = array(
'grouptopic:error' => 'Your group topic could not be created. Please try again or contact a system administrator.',
'groups:forumpost:edited' => "You have successfully edited the forum post.",
'groups:forumpost:error' => "There was a problem editing the forum post.",
+
+
'groups:privategroup' => 'This group is closed. Requesting membership.',
'groups:notitle' => 'Groups must have a title',
'groups:cantjoin' => 'Can not join group',
@@ -210,6 +221,7 @@ or click below to view the group's join requests:
'group:deleted' => 'Group and group contents deleted',
'group:notdeleted' => 'Group could not be deleted',
+ 'group:notfound' => 'Could not find the group',
'grouppost:deleted' => 'Group posting successfully deleted',
'grouppost:notdeleted' => 'Group posting could not be deleted',
'groupstopic:deleted' => 'Topic deleted',
diff --git a/mod/groups/lib/discussion.php b/mod/groups/lib/discussion.php
new file mode 100644
index 000000000..92ee94013
--- /dev/null
+++ b/mod/groups/lib/discussion.php
@@ -0,0 +1,209 @@
+<?php
+/**
+ * Discussion function library
+ */
+
+/**
+ * List all discussion topics
+ */
+function discussion_handle_all_page() {
+
+ elgg_pop_breadcrumb();
+ elgg_push_breadcrumb(elgg_echo('discussion'));
+
+ $content = elgg_list_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'groupforumtopic',
+ 'annotation_name' => 'generic_comment',
+ 'order_by' => 'e.last_action desc',
+ 'limit' => 40,
+ 'fullview' => false,
+ ));
+
+ $params = array(
+ 'content' => $content,
+ 'title' => elgg_echo('discussion:latest'),
+ 'filter' => '',
+ 'buttons' => '',
+ );
+ $body = elgg_view_layout('content', $params);
+
+ echo elgg_view_page($title, $body);
+}
+
+/**
+ * List discussion topics in a group
+ *
+ * @param int $guid Group entity GUID
+ */
+function discussion_handle_list_page($guid) {
+
+ elgg_set_page_owner_guid($guid);
+
+ $group = get_entity($guid);
+ if (!$group) {
+ register_error(elgg_echo('group:notfound'));
+ forward();
+ }
+ elgg_push_breadcrumb($group->name);
+
+ group_gatekeeper();
+
+ $title = elgg_echo('item:object:groupforumtopic');
+
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => 'groupforumtopic',
+ 'limit' => 20,
+ 'order_by' => 'e.last_action desc',
+ 'container_guid' => $guid,
+ 'fullview' => true,
+ );
+ $content = elgg_list_entities($options);
+
+
+ $params = array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+ );
+
+ if (!$group->isMember() && !$group->canEdit()) {
+ $params['buttons'] = '';
+ }
+
+ $body = elgg_view_layout('content', $params);
+
+ echo elgg_view_page($title, $body);
+}
+
+/**
+ * Edit or add a discussion topic
+ *
+ * @param string $type 'add' or 'edit'
+ * @param int $guid GUID of group or topic
+ */
+function discussion_handle_edit_page($type, $guid) {
+ gatekeeper();
+
+ if ($type == 'add') {
+ elgg_set_page_owner_guid($guid);
+ $group = get_entity($guid);
+ if (!$group) {
+ register_error(elgg_echo('group:notfound'));
+ forward();
+ }
+ group_gatekeeper();
+
+ $title = elgg_echo('groups:addtopic');
+
+ elgg_push_breadcrumb($group->name, "pg/discussion/owner/$group->guid");
+ elgg_push_breadcrumb($title);
+
+ $body_vars = discussion_prepare_form_vars();
+ $content = elgg_view_form('discussion/save', array(), $body_vars);
+ } else {
+ $topic = get_entity($guid);
+ if (!$topic || !$topic->canEdit()) {
+ register_error(elgg_echo('discussion:topic:notfound'));
+ forward();
+ }
+ $group = $topic->getContainerEntity();
+ if (!$group) {
+ register_error(elgg_echo('group:notfound'));
+ forward();
+ }
+ elgg_set_page_owner_guid($group->getGUID());
+
+ $title = elgg_echo('groups:edittopic');
+
+ elgg_push_breadcrumb($group->name, "pg/discussion/owner/$group->guid");
+ elgg_push_breadcrumb($topic->title, $topic->getURL());
+ elgg_push_breadcrumb($title);
+
+ $body_vars = discussion_prepare_form_vars($topic);
+ $content = elgg_view_form('discussion/save', array(), $body_vars);
+ }
+
+ $params = array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+ 'buttons' => '',
+ );
+ $body = elgg_view_layout('content', $params);
+
+ echo elgg_view_page($title, $body);
+}
+
+/**
+ * View a discussion topic
+ *
+ * @param int $guid GUID of topic
+ */
+function discussion_handle_view_page($guid) {
+ // We now have RSS on topics
+ global $autofeed;
+ $autofeed = true;
+
+ $topic = get_entity($guid);
+ if (!$topic) {
+ register_error(elgg_echo('discussion:topic:notfound'));
+ forward();
+ }
+
+ $group = $topic->getContainerEntity();
+ if (!$group) {
+ register_error(elgg_echo('group:notfound'));
+ forward();
+ }
+
+ elgg_set_page_owner_guid($group->getGUID());
+
+ group_gatekeeper();
+
+ elgg_push_breadcrumb($group->name, "pg/discussion/owner/$group->guid");
+ elgg_push_breadcrumb($topic->title);
+
+ $content = elgg_view('forum/viewposts', array('entity' => $topic));
+
+ $params = array(
+ 'content' => $content,
+ 'title' => $topic->title,
+ 'filter' => '',
+ 'buttons' => '',
+ );
+ $body = elgg_view_layout('content', $params);
+
+ echo elgg_view_page($title, $body);
+}
+
+function discussion_prepare_form_vars($topic = NULL) {
+ // input names => defaults
+ $values = array(
+ 'title' => '',
+ 'description' => '',
+ 'status' => '',
+ 'access_id' => ACCESS_DEFAULT,
+ 'tags' => '',
+ 'container_guid' => elgg_get_page_owner_guid(),
+ 'guid' => null,
+ 'entity' => $topic,
+ );
+
+ if ($topic) {
+ foreach (array_keys($values) as $field) {
+ $values[$field] = $topic->$field;
+ }
+ }
+
+ if (elgg_is_sticky_form('topic')) {
+ foreach (array_keys($values) as $field) {
+ $values[$field] = elgg_get_sticky_value('topic', $field);
+ }
+ }
+
+ elgg_clear_sticky_form('topic');
+
+ return $values;
+}
diff --git a/mod/groups/start.php b/mod/groups/start.php
index 0b76cc43c..199e3b27d 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -14,13 +14,15 @@ function groups_init() {
global $CONFIG;
elgg_register_library('elgg:groups', elgg_get_plugin_path() . 'groups/lib/groups.php');
+ elgg_register_library('elgg:discussion', elgg_get_plugin_path() . 'groups/lib/discussion.php');
// Set up the menu
- $item = new ElggMenuItem('groups', elgg_echo('groups'), 'pg/groups/world');
+ $item = new ElggMenuItem('groups', elgg_echo('groups'), 'pg/groups/all');
elgg_register_menu_item('site', $item);
// Register a page handler, so we can have nice URLs
register_page_handler('groups', 'groups_page_handler');
+ register_page_handler('discussion', 'discussion_page_handler');
// Register a URL handler for groups and forum topics
register_entity_url_handler('groups_url', 'group', 'all');
@@ -39,6 +41,7 @@ function groups_init() {
elgg_register_action("groups/killinvitation", $CONFIG->pluginspath . "groups/actions/groupskillinvitation.php");
elgg_register_action("groups/addtogroup", $CONFIG->pluginspath . "groups/actions/addtogroup.php");
elgg_register_action("groups/invite", $CONFIG->pluginspath . "groups/actions/invite.php");
+ elgg_register_action("groups/featured", $CONFIG->pluginspath . "groups/actions/featured.php", 'admin');
// Add a page owner handler
//elgg_register_plugin_hook_handler('page_owner', 'system', 'groups_page_owner_handler');
@@ -232,6 +235,7 @@ function groups_page_owner_handler() {
/**
* Groups page handler
+ *
* URLs take the form of
* All groups: pg/groups/all
* User's owned groups: pg/groups/owned/<username>
@@ -247,15 +251,13 @@ function groups_page_owner_handler() {
* @param array $page Array of url segments for routing
*/
function groups_page_handler($page) {
- global $CONFIG;
elgg_load_library('elgg:groups');
- elgg_push_breadcrumb(elgg_echo('groups'), "pg/groups/world");
+ elgg_push_breadcrumb(elgg_echo('groups'), "pg/groups/all");
- // beginnings of new page handler
switch ($page[0]) {
- case 'world':
+ case 'all':
groups_handle_all_page();
break;
case 'owned':
@@ -289,21 +291,42 @@ function groups_page_handler($page) {
groups_handle_requests_page($page[1]);
break;
}
+}
- // old page handler
- if (isset($page[0])) {
- // See what context we're using
- switch ($page[0]) {
- case "forum":
- set_input('group_guid', $page[1]);
- include($CONFIG->pluginspath . "groups/forum.php");
- break;
- case "edittopic":
- set_input('group', $page[1]);
- set_input('topic', $page[2]);
- include($CONFIG->pluginspath . "groups/edittopic.php");
- break;
- }
+/**
+ * Discussion page handler
+ *
+ * URLs take the form of
+ * All topics in site: pg/discussion/all
+ * List topics in forum: pg/discussion/owner/<guid>
+ * View discussion topic: pg/discussion/view/<guid>
+ * Add discussion topic: pg/discussion/add/<guid>
+ * Edit discussion topic: pg/discussion/edit/<guid>
+ *
+ * @param array $page Array of url segments for routing
+ */
+function discussion_page_handler($page) {
+
+ elgg_load_library('elgg:discussion');
+
+ elgg_push_breadcrumb(elgg_echo('discussion'), 'pg/discussion/all');
+
+ switch ($page[0]) {
+ case 'all':
+ discussion_handle_all_page();
+ break;
+ case 'owner':
+ discussion_handle_list_page($page[1]);
+ break;
+ case 'add':
+ discussion_handle_edit_page('add', $page[1]);
+ break;
+ case 'edit':
+ discussion_handle_edit_page('edit', $page[1]);
+ break;
+ case 'view':
+ discussion_handle_view_page($page[1]);
+ break;
}
}
@@ -340,7 +363,7 @@ function groups_url($entity) {
}
function groups_groupforumtopic_url($entity) {
- return 'mod/groups/topicposts.php?topic=' . $entity->guid . '&group_guid=' . $entity->container_guid;
+ return 'pg/discussion/view/' . $entity->guid;
}
/**
@@ -518,8 +541,7 @@ function groups_can_edit_discussion($entity, $group_owner) {
*/
function group_topicpost_url($annotation) {
if ($parent = get_entity($annotation->entity_guid)) {
- global $CONFIG;
- return 'mod/groups/topicposts.php?topic=' . $parent->guid . '&amp;group_guid=' . $parent->container_guid . '#' . $annotation->id;
+ return 'pg/discussion/view/' . $parent->guid . '#' . $annotation->id;
}
}
@@ -627,12 +649,5 @@ elgg_register_event_handler('annotate', 'all', 'group_object_notifications');
// Register actions
global $CONFIG;
-elgg_register_action("groups/addtopic", $CONFIG->pluginspath . "groups/actions/forums/addtopic.php");
-elgg_register_action("groups/deletetopic", $CONFIG->pluginspath . "groups/actions/forums/deletetopic.php");
-elgg_register_action("groups/addpost", $CONFIG->pluginspath . "groups/actions/forums/addpost.php");
-elgg_register_action("groups/edittopic", $CONFIG->pluginspath . "groups/actions/forums/edittopic.php");
-elgg_register_action("groups/deletepost", $CONFIG->pluginspath . "groups/actions/forums/deletepost.php");
-elgg_register_action("groups/featured", $CONFIG->pluginspath . "groups/actions/featured.php", 'admin');
-elgg_register_action("groups/editpost", $CONFIG->pluginspath . "groups/actions/forums/editpost.php");
-
-
+elgg_register_action('discussion/save', $CONFIG->pluginspath . "groups/actions/discussion/save.php");
+elgg_register_action('discussion/delete', $CONFIG->pluginspath . "groups/actions/discussion/delete.php");
diff --git a/mod/groups/topicposts.php b/mod/groups/topicposts.php
index fe9b85cec..f9dd3344b 100644
--- a/mod/groups/topicposts.php
+++ b/mod/groups/topicposts.php
@@ -1,33 +1,19 @@
<?php
+/**
+ * Elgg Groups topic posts page
+ *
+ * @package ElggGroups
+ *
+ * @deprecated 1.8
+ */
- /**
- * Elgg Groups topic posts page
- *
- * @package ElggGroups
- */
+// Load Elgg engine
+require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
- // Load Elgg engine
- require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
- // We now have RSS on topics
- global $autofeed;
- $autofeed = true;
-
- //get_input('group_guid');
- set_page_owner(get_input('group_guid'));
- if (!(elgg_get_page_owner() instanceof ElggGroup)) forward();
-
- group_gatekeeper();
-
- // get the entity from id
- $topic = get_entity(get_input('topic'));
- if (!$topic) forward();
-
- // Display them
- $area2 = elgg_view("forum/viewposts", array('entity' => $topic));
- $body = elgg_view_layout("one_column_with_sidebar", array('content' => $area2));
-
- // Display page
- echo elgg_view_page($topic->title,$body);
-
-?> \ No newline at end of file
+elgg_load_library('elgg:topic');
+
+$guid = get_input('topic');
+
+register_error(elgg_echo('changebookmark'));
+
+topic_handle_view_page($guid);
diff --git a/mod/groups/views/default/forms/discussion/save.php b/mod/groups/views/default/forms/discussion/save.php
new file mode 100644
index 000000000..39f273f3e
--- /dev/null
+++ b/mod/groups/views/default/forms/discussion/save.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Discussion topic add/edit form body
+ *
+ */
+
+$title = elgg_get_array_value('title', $vars, '');
+$desc = elgg_get_array_value('description', $vars, '');
+$status = elgg_get_array_value('status', $vars, '');
+$tags = elgg_get_array_value('tags', $vars, '');
+$access_id = elgg_get_array_value('access_id', $vars, ACCESS_DEFAULT);
+$container_guid = elgg_get_array_value('container_guid', $vars);
+$guid = elgg_get_array_value('guid', $vars, null);
+
+?>
+<p>
+ <label><?php echo elgg_echo('title'); ?></label><br />
+ <?php echo elgg_view('input/text', array('internalname' => 'title', 'value' => $title)); ?>
+</p>
+<p>
+ <label><?php echo elgg_echo('groups:topicmessage'); ?></label>
+ <?php echo elgg_view('input/longtext', array('internalname' => 'description', 'value' => $desc)); ?>
+</p>
+<p>
+ <label><?php echo elgg_echo('tags'); ?></label>
+ <?php echo elgg_view('input/tags', array('internalname' => 'tags', 'value' => $tags)); ?>
+</p>
+<p>
+ <label><?php echo elgg_echo("groups:topicstatus"); ?></label><br />
+ <?php
+ echo elgg_view('input/pulldown', array(
+ 'internalname' => 'status',
+ 'value' => $status,
+ 'options_values' => array(
+ 'open' => elgg_echo('groups:topicopen'),
+ 'closed' => elgg_echo('groups:topicclosed'),
+ ),
+ ));
+ ?>
+<p>
+ <label><?php echo elgg_echo('access'); ?></label><br />
+ <?php echo elgg_view('input/access', array('internalname' => 'access_id', 'value' => $access_id)); ?>
+</p>
+<p>
+<?php
+
+echo elgg_view('input/hidden', array('internalname' => 'container_guid', 'value' => $container_guid));
+
+if ($guid) {
+ echo elgg_view('input/hidden', array('internalname' => 'topic_guid', 'value' => $guid));
+}
+
+echo elgg_view('input/submit', array('value' => elgg_echo("save")));
+
+?>
+</p>
diff --git a/mod/groups/views/default/forms/forums/addtopic.php b/mod/groups/views/default/forms/forums/addtopic.php
deleted file mode 100644
index cf4921e20..000000000
--- a/mod/groups/views/default/forms/forums/addtopic.php
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * Elgg Groups topic edit/add page
- *
- * @package ElggGroups
- *
- * @uses $vars['object'] Optionally, the topic to edit
- */
-
- // Set title, form destination
- $title = elgg_echo("groups:addtopic");
- $action = "groups/addtopic";
- $tags = "";
- $title = "";
- $message = "";
- $message_id = "";
- $status = "";
-
- // get the group guid
- $group_guid = (int) get_input('group_guid');
-
- // set up breadcrumbs
- $group = get_entity($group_guid);
- $access_id = $group->group_acl;
- $options = group_access_options($group);
- elgg_push_breadcrumb(elgg_echo('groups'), elgg_get_site_url()."pg/groups/world/");
- elgg_push_breadcrumb($group->name, $group->getURL());
- elgg_push_breadcrumb(elgg_echo('item:object:groupforumtopic'), elgg_get_site_url()."pg/groups/forum/{$group_guid}/");
- elgg_push_breadcrumb(elgg_echo("groups:addtopic"));
-
- echo elgg_view('navigation/breadcrumbs');
-
- // set the title
- echo elgg_view_title(elgg_echo("groups:addtopic"));
-
-?>
-<!-- display the input form -->
-<form id="group_addtopic" action="<?php echo elgg_get_site_url(); ?>action/<?php echo $action; ?>" method="post" class="margin-top">
-<?php echo elgg_view('input/securitytoken'); ?>
-
- <p>
- <label><?php echo elgg_echo("title"); ?><br />
- <?php
- //display the topic title input
- echo elgg_view("input/text", array(
- "internalname" => "topictitle",
- "value" => $title,
- ));
- ?>
- </label>
- </p>
-
- <!-- display the tag input -->
- <p>
- <label><?php echo elgg_echo("tags"); ?><br />
- <?php
-
- echo elgg_view("input/tags", array(
- "internalname" => "topictags",
- "value" => $tags,
- ));
-
- ?>
- </label>
- </p>
-
- <!-- topic message input -->
- <p class="longtext_inputarea">
- <label><?php echo elgg_echo("groups:topicmessage"); ?></label>
- <?php
-
- echo elgg_view("input/longtext",array(
- "internalname" => "topicmessage",
- "value" => $message,
- ));
- ?>
- </p>
-
- <!-- set the topic status -->
- <p>
- <label><?php echo elgg_echo("groups:topicstatus"); ?><br />
- <select name="status">
- <option value="open" <?php if($status == "") echo "SELECTED";?>><?php echo elgg_echo('groups:topicopen'); ?></option>
- <option value="closed" <?php if($status == "closed") echo "SELECTED";?>><?php echo elgg_echo('groups:topicclosed'); ?></option>
- </select>
- </label>
- </p>
-
- <!-- access -->
- <p>
- <label>
- <?php echo elgg_echo('access'); ?><br />
- <?php echo elgg_view('input/access', array('internalname' => 'access_id','value' => $access_id, 'options' => $options)); ?>
- </label>
- </p>
-
- <!-- required hidden info and submit button -->
- <p>
- <input type="hidden" name="group_guid" value="<?php echo $group_guid; ?>" />
- <?php echo elgg_view('input/submit', array('value' => elgg_echo('post'))); ?>
- </p>
-
-</form>
diff --git a/mod/groups/views/default/forms/forums/edittopic.php b/mod/groups/views/default/forms/forums/edittopic.php
deleted file mode 100644
index d05389218..000000000
--- a/mod/groups/views/default/forms/forums/edittopic.php
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-
- /**
- * Elgg Groups topic edit/add page
- *
- * @package ElggGroups
- *
- * @uses $vars['entity'] Optionally, the topic to edit
- */
-
- //users can edit the access and status for now
- $access_id = $vars['entity']->access_id;
- $status = $vars['entity']->status;
- $tags = $vars['entity']->tags;
- $title = $vars['entity']->title;
- $message = $vars['entity']->description;
-
- // get the group GUID
- $group_guid = get_input("group");
-
- // topic guid
- $topic_guid = $vars['entity']->guid;
-
- // set the title
- echo elgg_view_title(elgg_echo("groups:edittopic"));
-
-?>
-<!-- display the input form -->
- <form id="group_edittopic" action="<?php echo elgg_get_site_url(); ?>action/groups/edittopic" method="post">
- <?php echo elgg_view('input/securitytoken'); ?>
-
- <p>
- <label><?php echo elgg_echo("title"); ?><br />
- <?php
- //display the topic title input
- echo elgg_view("input/text", array(
- "internalname" => "topictitle",
- "value" => $title,
- ));
- ?>
- </label>
- </p>
-
- <!-- display the tag input -->
- <p>
- <label><?php echo elgg_echo("tags"); ?><br />
- <?php
-
- echo elgg_view("input/tags", array(
- "internalname" => "topictags",
- "value" => $tags,
- ));
-
- ?>
- </label>
- </p>
-
- <!-- topic message input -->
- <p class="longtext_inputarea">
- <label><?php echo elgg_echo("groups:topicmessage"); ?></label>
- <?php
-
- echo elgg_view("input/longtext",array(
- "internalname" => "topicmessage",
- "value" => html_entity_decode($message, ENT_COMPAT, 'UTF-8')
- ));
- ?>
- </p>
-
- <!-- set the topic status -->
- <p>
- <label><?php echo elgg_echo("groups:topicstatus"); ?><br />
- <select name="status">
- <option value="open" <?php if($status == "") echo "SELECTED";?>><?php echo elgg_echo('groups:topicopen'); ?></option>
- <option value="closed" <?php if($status == "closed") echo "SELECTED";?>><?php echo elgg_echo('groups:topicclosed'); ?></option>
- </select>
- </label>
- </p>
-
- <!-- access -->
- <p>
- <label>
- <?php echo elgg_echo('access'); ?><br />
- <?php echo elgg_view('input/access', array('internalname' => 'access_id','value' => $access_id)); ?>
- </label>
- </p>
-
- <!-- required hidden info and submit button -->
- <p>
- <input type="hidden" name="group_guid" value="<?php echo $group_guid; ?>" />
- <input type="hidden" name="topic" value="<?php echo $topic_guid; ?>" />
- <input type="hidden" name="message_id" value="<?php echo $message_id; ?>" />
- <?php echo elgg_view('input/submit', array('value' => elgg_echo('save'))); ?>
- </p>
-
- </form> \ No newline at end of file
diff --git a/mod/groups/views/default/forum/maintopic.php b/mod/groups/views/default/forum/maintopic.php
index 2c75c0a77..7031c7418 100644
--- a/mod/groups/views/default/forum/maintopic.php
+++ b/mod/groups/views/default/forum/maintopic.php
@@ -30,7 +30,7 @@
'text' => elgg_echo('delete'),
'confirm' => elgg_echo('deleteconfirm')
))."</span>";
- echo "<span class='entity-edit'><a class='link' href=\"".elgg_get_site_url()."pg/groups/edittopic/{$group_guid}/{$topic}/\">".elgg_echo('edit')."</a></span>";
+ echo "<span class='entity-edit'><a class='link' href=\"".elgg_get_site_url()."pg/discussion/edit/{$vars['entity']->guid}\">".elgg_echo('edit')."</a></span>";
echo "</div>";
}
diff --git a/mod/groups/views/default/forum/viewposts.php b/mod/groups/views/default/forum/viewposts.php
index f12a3f306..3c9da1258 100644
--- a/mod/groups/views/default/forum/viewposts.php
+++ b/mod/groups/views/default/forum/viewposts.php
@@ -2,7 +2,7 @@
/**
* Elgg groups plugin display topic posts
*/
-
+/*
// set up breadcrumbs
$group_guid = get_input('group_guid');
$group = get_entity($group_guid);
@@ -12,6 +12,7 @@ elgg_push_breadcrumb(elgg_echo('item:object:groupforumtopic'), elgg_get_site_url
elgg_push_breadcrumb($vars['entity']->title);
echo elgg_view('navigation/breadcrumbs');
+*/
//display follow up comments
$count = $vars['entity']->countAnnotations('group_topic_post');
@@ -26,8 +27,6 @@ echo elgg_view('navigation/pagination',array(
));
?>
-<!-- grab the topic title -->
-<h2><?php echo $vars['entity']->title; ?></h2>
<?php
//display the topic
echo elgg_view("forum/maintopic",array('entity' => $vars['entity']));
diff --git a/mod/groups/views/default/groups/group_sort_menu.php b/mod/groups/views/default/groups/group_sort_menu.php
index 958c4084d..7018b614f 100644
--- a/mod/groups/views/default/groups/group_sort_menu.php
+++ b/mod/groups/views/default/groups/group_sort_menu.php
@@ -8,7 +8,7 @@ $group_count = (int)elgg_get_entities(array('types' => 'group', 'count' => true)
$selected = elgg_get_array_value('selected', $vars);
//url
- $url = elgg_get_site_url() . "pg/groups/world/";
+ $url = elgg_get_site_url() . "pg/groups/all/";
?>
<div class="elgg-tabs margin-top">
diff --git a/mod/groups/views/default/groups/profile/forum_widget.php b/mod/groups/views/default/groups/profile/forum_widget.php
index 265926fb5..969eb0559 100644
--- a/mod/groups/views/default/groups/profile/forum_widget.php
+++ b/mod/groups/views/default/groups/profile/forum_widget.php
@@ -13,7 +13,7 @@ $group = $vars['entity'];
$all_link = elgg_view('output/url', array(
- 'href' => "pg/groups/forum/$group->guid",
+ 'href' => "pg/discussion/owner/$group->guid",
'text' => elgg_echo('link:view:all'),
));
@@ -38,7 +38,7 @@ if (!$content) {
}
$new_link = elgg_view('output/url', array(
- 'href' => "mod/groups/addtopic.php?group_guid=" . $group->getGUID(),
+ 'href' => "pg/discussion/add/" . $group->getGUID(),
'text' => elgg_echo('groups:addtopic'),
));
$content .= "<span class='elgg-widget-more'>$new_link</span>";
diff --git a/mod/groups/views/default/object/groupforumtopic.php b/mod/groups/views/default/object/groupforumtopic.php
index e569bff77..a89419931 100644
--- a/mod/groups/views/default/object/groupforumtopic.php
+++ b/mod/groups/views/default/object/groupforumtopic.php
@@ -43,7 +43,7 @@ if ($num_comments != 0) {
$metadata = elgg_view('layout/objects/list/metadata', array(
'entity' => $topic,
- 'handler' => 'forum',
+ 'handler' => 'discussion',
));
$subtitle = "$poster_text $date $comments_link <span class=\"groups-latest-comment\">$comments_text</span>";