Skip to content

Commit

Permalink
Merge pull request #8576 from juho-jaakkola/forum_plugin
Browse files Browse the repository at this point in the history
feature(discussions): discussion feature has been moved to its own plugin
  • Loading branch information
juho-jaakkola committed Jun 30, 2015
2 parents 5a13cca + a4e484e commit d95dd38
Show file tree
Hide file tree
Showing 45 changed files with 856 additions and 821 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ vendor
!/mod/dashboard/
!/mod/developers/
!/mod/diagnostics/
!/mod/discussions/
!/mod/embed/
!/mod/externalpages/
!/mod/file/
Expand Down
14 changes: 14 additions & 0 deletions docs/guides/upgrading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,14 @@ We dropped support for and/or removed the following views:
* navigation/topbar_tools
* navigation/viewtype
* notifications/subscriptions/groupsform
* object/groupforumtopic
* output/calendar (Use output/date instead)
* output/confirmlink (Use output/url instead)
* page_elements/contentwrapper
* page/elements/shortcut_icon (Use the 'head', 'page' plugin hook instead)
* page/elements/wrapper
* profile/icon (Use ``elgg_get_entity_icon``)
* river/object/groupforumtopic/create
* settings/{plugin}/edit (Use plugins/{plugin}/settings instead)
* user/search/finishblurb
* user/search/startblurb
Expand Down Expand Up @@ -231,6 +233,18 @@ Creating a relationship triggers only one event

Entity relationship creation no longer fires the legacy "create" event using the relationship name as the type. E.g. Listening for the ``"create", "member"`` event will no longer capture group membership additions. Use the ``"create", "relationship"`` event.

Discussion feature has been pulled from groups into its own plugin
-------------------------------------------------------------------

The ``object, groupforumtopic`` subtype has been replaced with the
``object, discussion`` subtype. If your plugin is using or altering
the old discussion feature, you should upgrade it to use the new
subtype.

Nothing changes from the group owners' point of view. The discussion
feature is still available as a group tool and all old discussions
are intact.

Dropped login-over-https feature
--------------------------------

Expand Down
11 changes: 6 additions & 5 deletions engine/classes/ElggPluginManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ElggPluginManifest {
'version' => '',
'comparison' => 'ge'
);

/**
* The expected structure of a requires php_version dependency element
*/
Expand Down Expand Up @@ -113,7 +113,7 @@ class ElggPluginManifest {
'description' => '',
'path' => ''
);

/**
* The expected structure of a contributor element
*/
Expand Down Expand Up @@ -391,6 +391,7 @@ public function getCategories() {
'dashboard',
'developers',
'diagnostics',
'discussions',
'embed',
'externalpages',
'file',
Expand Down Expand Up @@ -452,7 +453,7 @@ public function getScreenshots() {

return $normalized;
}

/**
* Return the contributors listed.
*
Expand Down Expand Up @@ -514,7 +515,7 @@ public function getProvides() {
*/
public function getRequires() {
$reqs = $this->parser->getAttribute('requires');

if (!$reqs) {
$reqs = array();
}
Expand Down Expand Up @@ -571,7 +572,7 @@ private function normalizeDep($dep) {
case 'php_version':
$struct = $this->depsStructPhpVersion;
break;

case 'php_extension':
$struct = $this->depsStructPhpExtension;
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Elgg 1.11.2 upgrade 2015062900
* discussion_plugin
*
* Discussion feature was pulled from groups plugin into its
* own plugin, so we need to update references of subtype
* 'groupforumtopic' into 'discussion'.
*/

$dbprefix = elgg_get_config('dbprefix');

// Update subtype "groupforumtopic" into "discussion"
update_data("UPDATE {$dbprefix}entity_subtypes
SET subtype = 'discussion'
WHERE type = 'object' AND subtype = 'groupforumtopic'");

// Update river items to use the new view and subtype
update_data("UPDATE {$dbprefix}river
SET view = 'river/object/discussion/create', subtype = 'discussion'
WHERE type = 'object' AND subtype = 'groupforumtopic'");

// Update system log to use the new subtype
update_data("UPDATE {$dbprefix}system_log
SET object_subtype = 'discussion'
WHERE object_type = 'object' AND object_subtype = 'groupforumtopic'");

// If groups plugin is enabled, enable also the discussion plugin
// so the feature won't disappear from groups that are using it.
if (elgg_is_active_plugin('groups')) {
// Force Elgg to discover the new plugin in plugins directory
// and create a new \ElggPlugin entity for it so it can be
// found with elgg_get_plugin_from_id().
_elgg_generate_plugin_entities();

$plugin = elgg_get_plugin_from_id('discussion');
$plugin->activate();
}
4 changes: 0 additions & 4 deletions mod/aalborg_theme/views/default/groups/css.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
font-size: 85%;
}

.groups-latest-reply {
float: right;
}

.elgg-menu-groups-my-status li a {
color: #444;
display: block;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php
/**
* Delete topic action
*
*/

$topic_guid = (int) get_input('guid');

$topic = get_entity($topic_guid);
if (!elgg_instanceof($topic, 'object', 'groupforumtopic')) {
if (!elgg_instanceof($topic, 'object', 'discussion')) {
register_error(elgg_echo('discussion:error:notdeleted'));
forward(REFERER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

// reply cannot be empty
if (empty($text)) {
register_error(elgg_echo('grouppost:nopost'));
register_error(elgg_echo('discussion:reply:missing'));
forward(REFERER);
}

if ($topic_guid) {
$topic = get_entity($topic_guid);
if (!elgg_instanceof($topic, 'object', 'groupforumtopic')) {
register_error(elgg_echo('grouppost:nopost'));
if (!elgg_instanceof($topic, 'object', 'discussion')) {
register_error(elgg_echo('discussion:reply:topic_not_found'));
forward(REFERER);
}

$group = $topic->getContainerEntity();
if (!$group->canWriteToContainer()) {
$container = $topic->getContainerEntity();
if (elgg_instanceof($container, 'group') && !$container->canWriteToContainer()) {
register_error(elgg_echo('groups:notmember'));
forward(REFERER);
}
Expand All @@ -38,16 +38,16 @@
}

if (!$reply->canEdit()) {
register_error(elgg_echo('groups:notowner'));
register_error(elgg_echo('discussion:reply:error:cannot_edit'));
forward(REFERER);
}

$reply->description = $text;

if ($reply->save()) {
system_message(elgg_echo('groups:forumpost:edited'));
system_message(elgg_echo('discussion:reply:edited'));
} else {
register_error(elgg_echo('groups:forumpost:error'));
register_error(elgg_echo('discussion:reply:error'));
}
} else {
// add the reply to the forum topic
Expand All @@ -60,7 +60,7 @@
$reply_guid = $reply->save();

if ($reply_guid == false) {
register_error(elgg_echo('groupspost:failure'));
register_error(elgg_echo('discussion:post:failure'));
forward(REFERER);
}

Expand All @@ -72,7 +72,7 @@
'target_guid' => $topic->guid,
));

system_message(elgg_echo('groupspost:success'));
system_message(elgg_echo('discussion:post:success'));
}

forward(REFERER);
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}

$container = get_entity($container_guid);
if (!$container || !$container->canWriteToContainer(0, 'object', 'groupforumtopic')) {
if (!$container || !$container->canWriteToContainer(0, 'object', 'discussion')) {
register_error(elgg_echo('discussion:error:permissions'));
forward(REFERER);
}
Expand All @@ -34,11 +34,11 @@

if ($new_topic) {
$topic = new ElggObject();
$topic->subtype = 'groupforumtopic';
$topic->subtype = 'discussion';
} else {
// load original file object
$topic = get_entity($guid);
if (!elgg_instanceof($topic, 'object', 'groupforumtopic') || !$topic->canEdit()) {
if (!elgg_instanceof($topic, 'object', 'discussion') || !$topic->canEdit()) {
register_error(elgg_echo('discussion:topic:notfound'));
forward(REFERER);
}
Expand Down Expand Up @@ -66,11 +66,13 @@
// handle results differently for new topics and topic edits
if ($new_topic) {
system_message(elgg_echo('discussion:topic:created'));

elgg_create_river_item(array(
'view' => 'river/object/groupforumtopic/create',
'view' => 'river/object/discussion/create',
'action_type' => 'create',
'subject_guid' => elgg_get_logged_in_user_guid(),
'object_guid' => $topic->guid,
'target_guid' => $container_guid,
));
} else {
system_message(elgg_echo('discussion:topic:updated'));
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Class for group discussion reply
*
* Class for discussion reply
*
* We extend ElggComment to get the future thread support.
*/
class ElggDiscussionReply extends ElggComment {
Expand Down
8 changes: 8 additions & 0 deletions mod/discussions/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "elgg/discussions",
"type": "elgg-plugin",
"license": "GPL-2.0",
"require": {
"composer/installers": ">=1.0.8"
}
}
File renamed without changes.
100 changes: 100 additions & 0 deletions mod/discussions/languages/en.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

return array(
'discussion' => 'Discussion',
'discussion:add' => 'Add discussion topic',
'discussion:latest' => 'Latest discussion',
'discussion:group' => 'Group discussion',
'discussion:none' => 'No discussion',
'discussion:reply:title' => 'Reply by %s',
'discussion:new' => "Add discussion post",
'discussion:updated' => "Last reply by %s %s",

'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',

'discussion:reply:edit' => 'Edit reply',
'discussion:reply:deleted' => 'Discussion reply has been deleted.',
'discussion:reply:error:notfound' => 'The discussion reply was not found',
'discussion:reply:error:notfound_fallback' => "Sorry, we could not find the specified reply, but we've forwarded you to the original discussion topic.",
'discussion:reply:error:notdeleted' => 'Could not delete the discussion reply',

'discussion:search:title' => 'Reply on topic: %s',

/**
* Action messages
*/
'discussion:reply:missing' => 'You cannot post an empty reply',
'discussion:reply:topic_not_found' => 'The discussion topic was not found',
'discussion:reply:error:cannot_edit' => 'You do not have the permission to edit this reply',

/**
* River
*/
'river:create:object:discussion' => '%s added a new discussion topic %s',
'river:reply:object:discussion' => '%s replied on the discussion topic %s',
'river:reply:view' => 'view reply',

/**
* Notifications
*/
'discussion:topic:notify:summary' => 'New discussion topic called %s',
'discussion:topic:notify:subject' => 'New discussion topic: %s',
'discussion:topic:notify:body' =>
'%s added a new discussion topic to %s:
Title: %s
%s
View and reply to the discussion topic:
%s
',

'discussion:reply:notify:summary' => 'New reply in topic: %s',
'discussion:reply:notify:subject' => 'New reply in topic: %s',
'discussion:reply:notify:body' =>
'%s replied to the discussion topic %s:
%s
View and reply to the discussion:
%s
',

'item:object:discussion' => "Discussion topics",
'item:object:discussion_reply' => "Discussion replies",

'groups:enableforum' => 'Enable group discussion',

'reply:this' => 'Reply to this',

/**
* ecml
*/
'discussion:ecml:discussion' => 'Group Discussions',

/**
* Discussion status
*/
'discussion:topic:status' => 'Topic status',
'discussion:topic:closed:title' => 'This discussion is closed.',
'discussion:topic:closed:desc' => 'This discussion is closed and is not accepting new comments.',

'discussion:replies' => 'Replies',
'discussion:addtopic' => 'Add a topic',
'discussion:post:success' => 'Your reply was succesfully posted',
'discussion:post:failure' => 'There was problem while posting your reply',
'discussion:topic:edit' => 'Edit topic',
'discussion:topic:description' => 'Topic message',

'discussion:reply:edited' => "You have successfully edited the forum post.",
'discussion:reply:error' => "There was a problem editing the forum post.",
);
File renamed without changes.
Loading

0 comments on commit d95dd38

Please sign in to comment.