This repository was archived by the owner on Apr 27, 2024. It is now read-only.
forked from ColdTrick/questions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.php
More file actions
109 lines (86 loc) · 6.31 KB
/
start.php
File metadata and controls
109 lines (86 loc) · 6.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* This file is loaded when all the active plugins get loaded
*/
define('QUESTIONS_EXPERT_ROLE', 'questions_expert');
require_once(dirname(__FILE__) . '/lib/functions.php');
require_once(dirname(__FILE__) . '/lib/events.php');
require_once(dirname(__FILE__) . '/lib/hooks.php');
elgg_register_event_handler('init', 'system', 'questions_init');
/**
* This function is executed when the system is initialized
*
* @return void
*/
function questions_init() {
// extend CSS/JS
elgg_extend_view('css/elgg', 'css/questions/site.css');
elgg_extend_view('js/elgg', 'js/questions/site.js');
elgg_register_menu_item('site', [
'name' => 'questions',
'text' => elgg_echo('questions'),
'href' => 'questions/all',
]);
// make question searchable
elgg_register_entity_type('object', 'question');
elgg_register_plugin_hook_handler('search', 'object:question', '\ColdTrick\Questions\Search::handleQuestionsSearch');
elgg_register_plugin_hook_handler('search_params', 'search:combined', '\ColdTrick\Questions\SearchAdvanced::combinedParams');
// register widget
elgg_register_widget_type('questions', elgg_echo('widget:questions:title'), elgg_echo('widget:questions:description'), ['index', 'profile', 'dashboard', 'groups'], true);
// register page handler for nice urls
elgg_register_page_handler('questions', '\ColdTrick\Questions\PageHandler::questions');
elgg_register_page_handler('answers', '\ColdTrick\Questions\PageHandler::answers');
// register group options
add_group_tool_option('questions', elgg_echo('questions:enable'), false);
elgg_extend_view('groups/tool_latest', 'questions/group_module');
elgg_extend_view('groups/edit', 'questions/groups_edit');
// plugin hooks
elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'questions_owner_block_menu_handler');
elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'questions_user_hover_menu_handler');
elgg_register_plugin_hook_handler('register', 'menu:entity', 'questions_entity_menu_handler');
elgg_register_plugin_hook_handler('register', 'menu:filter', 'questions_filter_menu_handler');
elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'questions_container_permissions_handler');
elgg_register_plugin_hook_handler('permissions_check', 'object', 'questions_permissions_handler');
elgg_register_plugin_hook_handler('entity:url', 'object', '\ColdTrick\Questions\WidgetManager::widgetURL');
elgg_register_plugin_hook_handler('cron', 'daily', 'questions_daily_cron_handler');
elgg_register_plugin_hook_handler('cron', 'daily', '\ColdTrick\Questions\Cron::autoCloseQuestions');
elgg_register_plugin_hook_handler('index_entity_type_subtypes', 'elasticsearch', '\ColdTrick\Questions\Elasticsearch::indexTypes');
elgg_register_plugin_hook_handler('likes:is_likable', 'object:' . \ElggQuestion::SUBTYPE, '\Elgg\Values::getTrue');
elgg_register_plugin_hook_handler('likes:is_likable', 'object:' . \ElggAnswer::SUBTYPE, '\Elgg\Values::getTrue');
// notifications
elgg_register_notification_event('object', ElggQuestion::SUBTYPE, ['create', 'move']);
elgg_register_notification_event('object', ElggAnswer::SUBTYPE, ['create', 'correct']);
elgg_register_plugin_hook_handler('prepare', 'notification:create:object:' . ElggQuestion::SUBTYPE, '\ColdTrick\Questions\Notifications::createQuestion');
elgg_register_plugin_hook_handler('prepare', 'notification:move:object:' . ElggQuestion::SUBTYPE, '\ColdTrick\Questions\Notifications::moveQuestion');
elgg_register_plugin_hook_handler('prepare', 'notification:create:object:' . ElggAnswer::SUBTYPE, '\ColdTrick\Questions\Notifications::createAnswer');
elgg_register_plugin_hook_handler('prepare', 'notification:correct:object:' . ElggAnswer::SUBTYPE, '\ColdTrick\Questions\Notifications::correctAnswer');
elgg_register_plugin_hook_handler('prepare', 'notification:create:object:comment', '\ColdTrick\Questions\Notifications::createCommentOnAnswer');
elgg_register_plugin_hook_handler('get', 'subscriptions', '\ColdTrick\Questions\Notifications::addExpertsToSubscribers');
elgg_register_plugin_hook_handler('get', 'subscriptions', '\ColdTrick\Questions\Notifications::addQuestionOwnerToAnswerSubscribers');
elgg_register_plugin_hook_handler('get', 'subscriptions', '\ColdTrick\Questions\Notifications::addAnswerOwnerToAnswerSubscribers');
elgg_register_plugin_hook_handler('get', 'subscriptions', '\ColdTrick\Questions\Notifications::addQuestionSubscribersToAnswerSubscribers');
elgg_register_plugin_hook_handler('entity_types', 'content_subscriptions', '\ColdTrick\Questions\ContentSubscriptions::getEntityTypes');
elgg_register_event_handler('create', 'object', '\ColdTrick\Questions\ContentSubscriptions::createAnswer');
elgg_register_event_handler('create', 'object', '\ColdTrick\Questions\ContentSubscriptions::createCommentOnAnswer');
elgg_register_plugin_hook_handler('supported_types', 'entity_tools', '\ColdTrick\Questions\MigrateQuestions::supportedSubtypes');
// events
elgg_register_event_handler('leave', 'group', 'questions_leave_group_handler');
elgg_register_event_handler('delete', 'relationship', 'questions_leave_site_handler');
elgg_register_event_handler('update:after', 'object', '\ColdTrick\Questions\Access::updateQuestion');
elgg_register_event_handler('upgrade', 'system', '\ColdTrick\Questions\Upgrade::setStatusOnQuestions');
// actions
elgg_register_action('questions/toggle_expert', dirname(__FILE__) . '/actions/toggle_expert.php');
elgg_register_action('questions/group_settings', dirname(__FILE__) . '/actions/group_settings.php');
elgg_register_action('questions/upgrades/set_question_status', dirname(__FILE__) . '/actions/upgrades/set_question_status.php', 'admin');
// question
$actions_base = dirname(__FILE__) . '/actions/object/question';
elgg_register_action('object/question/save', "{$actions_base}/save.php");
elgg_register_action('object/question/move_to_discussions', "{$actions_base}/move_to_discussions.php");
elgg_register_action('questions/delete', "{$actions_base}/delete.php");
// answer
$actions_base = dirname(__FILE__) . '/actions/object/answer';
elgg_register_action('object/answer/add', "{$actions_base}/save.php");
elgg_register_action('object/answer/edit', "{$actions_base}/save.php");
elgg_register_action('answers/delete', "{$actions_base}/delete.php");
elgg_register_action('answers/toggle_mark', "{$actions_base}/toggle_mark.php");
}