Skip to content

Commit

Permalink
feat(releases): upgrade for Elgg 3
Browse files Browse the repository at this point in the history
  • Loading branch information
hypeJunction committed Jul 8, 2019
1 parent b31fa59 commit 81a9f56
Show file tree
Hide file tree
Showing 35 changed files with 1,030 additions and 858 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
hypeInbox
===========
![Elgg 2.3](https://img.shields.io/badge/Elgg-2.3-orange.svg?style=flat-square)
![Elgg 3.0](https://img.shields.io/badge/Elgg-3.0-orange.svg?style=flat-square)

Enhanced messaging for Elgg

Expand Down
16 changes: 8 additions & 8 deletions actions/messages/markread.php
Expand Up @@ -6,8 +6,7 @@
$threaded = get_input('threaded');

if (!is_array($guids) || empty($guids)) {
register_error(elgg_echo('inbox:markread:error'));
forward(REFERRER);
return elgg_error_response(elgg_echo('inbox:markread:error'));
}

$count = count($guids);
Expand All @@ -24,9 +23,9 @@
}

if ($count > 1) {
$msg[] = elgg_echo('inbox:markread:success', array($success));
$msg[] = elgg_echo('inbox:markread:success', [$success]);
if ($notfound > 0) {
$msg[] = elgg_echo('inbox:error:notfound', array($notfound));
$msg[] = elgg_echo('inbox:error:notfound', [$notfound]);
}
} else if ($success) {
$msg[] = elgg_echo('inbox:markread:success:single');
Expand All @@ -35,8 +34,9 @@
}

$msg = implode('<br />', $msg);

if ($success < $count) {
register_error($msg);
} else {
system_message($msg);
}
return elgg_error_response($msg);
}

return elgg_ok_response('', $msg);
38 changes: 0 additions & 38 deletions activate.php

This file was deleted.

107 changes: 107 additions & 0 deletions classes/hypeJunction/Inbox/Bootstrap.php
@@ -0,0 +1,107 @@
<?php

namespace hypeJunction\Inbox;

use Elgg\PluginBootstrap;

class Bootstrap extends PluginBootstrap {

public function getPath() {
return $this->plugin->getPath();
}

public function load() {
require_once $this->getPath() . 'autoloader.php';
}

public function boot() {

}

public function init() {
elgg_extend_view('elgg.css', 'framework/inbox.css');
elgg_extend_view('elgg.js', 'framework/inbox/message.js');

// URL and page handling
elgg_register_plugin_hook_handler('page_owner', 'system', [Router::class, 'resolvePageOwner']);
elgg_register_plugin_hook_handler('entity:url', 'object', [Router::class, 'messageUrlHandler']);
elgg_register_plugin_hook_handler('entity:icon:url', 'object', [Router::class, 'messageIconUrlHandler']);

// Third party integrations
elgg_register_plugin_hook_handler('config:user_types', 'framework:inbox', [Config::class, 'filterUserTypes']);

elgg_unregister_plugin_hook_handler('register', 'menu:user_hover', 'messages_user_hover_menu');

elgg_register_plugin_hook_handler('register', 'menu:page', [Menus::class, 'setupPageMenu']);
elgg_register_plugin_hook_handler('register', 'menu:page', [Menus::class, 'setupAdminPageMenu']);
elgg_register_plugin_hook_handler('register', 'menu:page', [Menus::class, 'setupInboxThreadMenu']);
elgg_register_plugin_hook_handler('register', 'menu:inbox', [Menus::class, 'setupInboxMenu']);
elgg_register_plugin_hook_handler('register', 'menu:entity', [Menus::class, 'setupMessageMenu']);
elgg_register_plugin_hook_handler('register', 'menu:user_hover', [Menus::class, 'setupUserHoverMenu']);
elgg_register_plugin_hook_handler('register', 'menu:title', [Menus::class, 'setupTitleMenu']);

// Export
if (elgg_is_active_plugin('hypeApps')) {
elgg_register_plugin_hook_handler('aliases', 'graph', [Graph::class, 'getGraphAlias']);
elgg_register_plugin_hook_handler('graph:properties', 'object:messages', [
Graph::class,
'getMessageProperties'
]);
}

// Top bar
elgg_unregister_plugin_hook_handler('register', 'menu:topbar', 'messages_register_topbar');
elgg_register_plugin_hook_handler('register', 'menu:topbar', [Menus::class, 'setupTopbarMenu']);
elgg_register_plugin_hook_handler('output', 'ajax', [Ajax::class, 'setUnreadMessagesCount']);
elgg_extend_view('page/elements/topbar', 'framework/inbox/popup');

// Notification Templates
elgg_register_plugin_hook_handler('get_templates', 'notifications', [
Notifications::class,
'registerCustomTemplates'
]);
}

public function ready() {

}

public function shutdown() {

}

public function activate() {
$message_types = [
'__private' => [
'labels' => [
'singular' => 'Private Message',
'plural' => 'Private Messages',
],
'multiple' => true,
'attachments' => true,
'persistent' => false,
'allowed_senders' => [
'all'
],
'policy' => [
[
'sender' => 'all',
'recipient' => 'all',
]
],
],
];

if (is_null(elgg_get_plugin_setting('default_message_types', 'hypeInbox'))) {
elgg_set_plugin_setting('default_message_types', serialize($message_types), 'hypeInbox');
}
}

public function deactivate() {

}

public function upgrade() {

}
}

0 comments on commit 81a9f56

Please sign in to comment.