-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.php
93 lines (86 loc) · 2.04 KB
/
helper.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* @author Drajat Hasan
* @email drajathasan20@gmail.com
* @create date 2022-05-18 07:47:29
* @modify date 2022-05-20 12:45:36
* @license GPLv3
* @desc [description]
*/
if (!function_exists('assetsPath'))
{
/**
* Retrieve plugin url link
*
* @param string $additionalPath
* @return string
*/
function assetsUrl(string $additionalPath)
{
$pluginDirectory = basename(__DIR__);
return SWB . 'plugins/' . $pluginDirectory . '/assets/' . $additionalPath;
}
}
if (!function_exists('pluginDir'))
{
/**
* Retrieve plugin path directory
*
* @param string $additionalPath
* @return string
*/
function pluginDir(string $additionalDirPath)
{
$pluginDirectory = basename(__DIR__);
return SB . 'plugins/' . $pluginDirectory . DS . $additionalDirPath;
}
}
if (!function_exists('downloadImage'))
{
/**
* Download user image after
* OAuth login success
*
* @param string $url
* @param string $pathToSave
* @return void
*/
function downloadImage(string $url, string $pathToSave)
{
$client = new \GuzzleHttp\Client;
$client->request('GET', $url, ['sink' => $pathToSave]);
}
}
if (!function_exists('getSLiMSOAuthConfig'))
{
/**
* Getter for plugin configuration
*
* @return void
*/
function getSLiMSOAuthConfig()
{
$db = \SLiMS\DB::getInstance();
$configState = $db->query("select setting_value from setting where setting_name = 'oauth_provider'");
if ($configState->rowCount())
{
$data = $configState->fetch(PDO::FETCH_OBJ);
return @unserialize($data->setting_value);
}
}
}
if (!function_exists('isHttps'))
{
/**
* This plugin need HTTPS connection,
* Https checker is need to make sure
* it running on HTTPS or not
*
* @return boolean
*/
function isHttps()
{
$url = parse_url($_SERVER['HTTP_REFERER']);
return $url['scheme'] === 'https';
}
}