1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Integration hooks for user notifications. Hooks are Dynamically registered. |
5
|
|
|
* |
6
|
|
|
* @package ElkArte Forum |
7
|
|
|
* @copyright ElkArte Forum contributors |
8
|
|
|
* @license BSD http://opensource.org/licenses/BSD-3-Clause (see accompanying LICENSE.txt file) |
9
|
|
|
* |
10
|
|
|
* @version 2.0 dev |
11
|
|
|
* |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace ElkArte; |
15
|
|
|
|
16
|
|
|
use ElkArte\Helper\HttpReq; |
17
|
|
|
use ElkArte\Notifications\UserNotification; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class UserNotificationIntegrate |
21
|
|
|
* |
22
|
|
|
* @package ElkArte |
23
|
|
|
*/ |
24
|
|
|
class UserNotificationIntegrate |
25
|
|
|
{ |
26
|
1 |
|
/** |
27
|
|
|
* Dynamically registers the hooks for the feature. |
28
|
1 |
|
*/ |
29
|
|
|
public static function register() |
30
|
1 |
|
{ |
31
|
|
|
global $modSettings; |
32
|
1 |
|
|
33
|
|
|
if (empty($modSettings['usernotif_favicon_enable']) && empty($modSettings['usernotif_desktop_enable'])) |
34
|
|
|
{ |
35
|
|
|
return []; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
// $hook, $function, $file |
39
|
|
|
return [ |
40
|
|
|
['integrate_load_theme', '\\ElkArte\\UserNotificationIntegrate::integrate_load_theme'],]; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Dynamically registers the admin panel hooks for the feature. |
45
|
|
|
*/ |
46
|
|
|
public static function settingsRegister() |
47
|
|
|
{ |
48
|
|
|
// $hook, $function, $file |
49
|
|
|
return [ |
50
|
|
|
['integrate_modify_mention_settings', '\\ElkArte\\UserNotificationIntegrate::integrate_modify_mention_settings'], |
51
|
|
|
['integrate_save_modify_mention_settings', '\\ElkArte\\UserNotificationIntegrate::integrate_save_modify_mention_settings'], |
52
|
|
|
]; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Adds the relevant javascript code when loading the page. |
57
|
|
|
*/ |
58
|
|
|
public static function integrate_load_theme() |
59
|
|
|
{ |
60
|
|
|
if (User::$info->is_guest) |
|
|
|
|
61
|
|
|
{ |
62
|
|
|
return; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$notification = new UserNotification(database(), User::$info); |
66
|
|
|
$notification->present(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Adds the settings to the admin page. |
71
|
|
|
* |
72
|
|
|
* @param array $config_vars |
73
|
|
|
*/ |
74
|
|
|
public static function integrate_modify_mention_settings(&$config_vars) |
75
|
|
|
{ |
76
|
|
|
$notification = new UserNotification(database(), User::$info); |
77
|
|
|
|
78
|
|
|
$notification_cfg = $notification->addConfig(); |
79
|
|
|
$config_vars = elk_array_insert($config_vars, $config_vars[1], $notification_cfg, 'after', false); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Does some magic when settings are saved. |
84
|
|
|
*/ |
85
|
|
|
public static function integrate_save_modify_mention_settings() |
86
|
|
|
{ |
87
|
|
|
$req = HttpReq::instance(); |
88
|
|
|
|
89
|
|
|
$notification = new UserNotification(database(), User::$info); |
90
|
|
|
$req->post = $notification->validate($req->post); |
|
|
|
|
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|