forked from ABSAhmad/IpsDiscordIntegration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplication.php
76 lines (68 loc) · 2.5 KB
/
Application.php
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
<?php
/**
* @brief Discord Integration Application Class
* @author <a href=''>Ahmad E.</a>
* @copyright (c) 2017 Ahmad E.
* @package IPS Community Suite
* @subpackage Discord Integration
* @since 01 Jan 2017
*/
namespace IPS\discord;
/**
* Discord Integration Application Class
* @TODO: Feature: Invite members to the discord server.
* @TODO: Feature: Delay notifications.
* @TODO: Feature: Bit.ly URL shortening?
* @TODO: Discord Widget.
*
* @TODO: Feature: Pages support. Status: BLOCKED. Reason: \IPS\cms\modules\admin\databases::form() is not extendable.
*
* @TODO: Concept of notification settings.
* @TODO: Feature: Notifications for PMs.
* @TODO: Feature: Notifications for watched topics.
* @TODO: (User)Setting: Send notifications on Discord?
* @TODO: (User)Setting: Send notifications for approved posts.
*/
class _Application extends \IPS\Application
{
/**
* Make sure we have our login handler in the correct table.
* Make sure we move our login handler files.
* Make sure we add our needed columns.
*/
public function installOther()
{
$maxLoginOrder = \IPS\Db::i()->select( 'MAX(login_order)', 'core_login_handlers' )->first();
\IPS\Db::i()->insert('core_login_handlers', [
'login_settings' => '',
'login_key' => 'Discord',
'login_enabled' => 1,
'login_order' => $maxLoginOrder + 1,
'login_acp' => 0
]);
/* Copy to /applications/core/sources/ProfileSync/ */
$profileSync = \copy(
\IPS\ROOT_PATH . '/applications/discord/sources/MoveOnInstall/ProfileSync/Discord.php',
\IPS\ROOT_PATH . '/applications/core/sources/ProfileSync/Discord.php'
);
/* Copy to /system/Login/ */
$systemLogin = \copy(
\IPS\ROOT_PATH . '/applications/discord/sources/MoveOnInstall/Login/Discord.php',
\IPS\ROOT_PATH . '/system/Login/Discord.php'
);
/**
* Fix: "Permission too open" error.
* Chmod files that need to be directly called to 644.
* Because on some server configurations those are set to 666 by default and thus error out.
*/
\chmod(
\IPS\ROOT_PATH . '/applications/discord/interface/oauth/auth.php',
\IPS\FILE_PERMISSION_NO_WRITE
);
if ( !$profileSync || !$systemLogin )
{
throw new \OutOfRangeException( 'Copying required file failed.' );
}
\IPS\discord\Util::addAllAttributes();
}
}