Permalink
Browse files

feature(discussions): allow plugins to use custom discussion reply ob…

…ject class

The plugin no longer needlessly enforces class checks for discussion replies,
thus allowing plugin to register subtype class that does not extend ElggDiscussionReply.
  • Loading branch information...
hypeJunction committed Mar 21, 2016
1 parent b96c736 commit ac55f8f48cbc17c45db7ebab52e2c95c7594022c
@@ -7,7 +7,7 @@
$reply = get_entity($guid);
if (!elgg_instanceof($reply, 'object', 'discussion_reply', 'ElggDiscussionReply')) {
if (!elgg_instanceof($reply, 'object', 'discussion_reply')) {
register_error(elgg_echo('discussion:reply:error:notdeleted'));
forward(REFERER);
}
@@ -32,7 +32,7 @@
if ($reply_guid) {
$reply = get_entity($reply_guid);
if (!elgg_instanceof($reply, 'object', 'discussion_reply', 'ElggDiscussionReply')) {
if (!elgg_instanceof($reply, 'object', 'discussion_reply')) {
register_error(elgg_echo('discussion:reply:error:notfound'));
forward(REFERER);
}
View
@@ -164,7 +164,7 @@ function discussion_redirect_to_reply($reply_guid, $fallback_guid) {
forward($fallback->getURL());
}
if (!$reply instanceof ElggDiscussionReply) {
if (!elgg_instanceof($reply, 'object', 'discussion_reply')) {
$fail();
}
@@ -219,13 +219,10 @@ function discussion_set_topic_url($hook, $type, $url, $params) {
return "discussion/view/{$entity->guid}/{$title}";
}
if (!$entity instanceof ElggDiscussionReply) {
return;
if ($entity->getSubtype() === 'discussion_reply') {
$topic = $entity->getContainerEntity();
return "discussion/reply/view/{$entity->guid}/{$topic->guid}";
}
$topic = $entity->getContainerEntity();
return "discussion/reply/view/{$entity->guid}/{$topic->guid}";
}
/**
@@ -299,7 +296,7 @@ function discussion_add_to_river_menu($hook, $type, $return, $params) {
$return[] = ElggMenuItem::factory($options);
}
} else {
if (elgg_instanceof($object, 'object', 'discussion_reply', 'ElggDiscussionReply')) {
if (elgg_instanceof($object, 'object', 'discussion_reply')) {
// Discussion replies cannot be commented
foreach ($return as $key => $item) {
if ($item->getName() === 'comment') {
@@ -381,7 +378,7 @@ function discussion_prepare_reply_notification($hook, $type, $notification, $par
function discussion_get_subscriptions($hook, $type, $subscriptions, $params) {
$reply = $params['event']->getObject();
if (!elgg_instanceof($reply, 'object', 'discussion_reply', 'ElggDiscussionReply')) {
if (!elgg_instanceof($reply, 'object', 'discussion_reply')) {
return $subscriptions;
}
@@ -415,7 +412,7 @@ function discussion_can_edit_reply($hook, $type, $return, $params) {
$reply = $params['entity'];
$user = $params['user'];
if (!elgg_instanceof($reply, 'object', 'discussion_reply', 'ElggDiscussionReply')) {
if (!elgg_instanceof($reply, 'object', 'discussion_reply')) {
return $return;
}
@@ -7,7 +7,7 @@
$hidden = elgg_extract('hidden', $vars, true);
$reply = get_entity($guid);
if (!elgg_instanceof($reply, 'object', 'discussion_reply', 'ElggDiscussionReply') || !$reply->canEdit()) {
if (!elgg_instanceof($reply, 'object', 'discussion_reply') || !$reply->canEdit()) {
return false;
}
@@ -4,7 +4,7 @@
$guid = elgg_extract('guid', $vars);
$reply = get_entity($guid);
if (!elgg_instanceof($reply, 'object', 'discussion_reply', 'ElggDiscussionReply') || !$reply->canEdit()) {
if (!elgg_instanceof($reply, 'object', 'discussion_reply') || !$reply->canEdit()) {
register_error(elgg_echo('discussion:reply:error:notfound'));
forward();
}

0 comments on commit ac55f8f

Please sign in to comment.