-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhooks.php
More file actions
38 lines (33 loc) · 1.46 KB
/
hooks.php
File metadata and controls
38 lines (33 loc) · 1.46 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
<?php
use WHMCS\Module\Addon\PopupJSClient\ModuleController as AnnouncementController;
use WHMCS\Module\Addon\PopupJSClient\Model as Announcement;
if (!defined("WHMCS")) {
die("This file cannot be accessed directly");
}
add_hook('ClientAreaFooterOutput', 1, 'ClientAreaFooterOutput_ModuleView');
/**
* @throws Exception
*/
function ClientAreaFooterOutput_ModuleView($vars)
{
$lang = AnnouncementController::getLang($vars);
$userGroup = $vars['clientsdetails']['groupid'] ?? null;
$announcement = Announcement::getLatest($userGroup);
if ($announcement && !empty($announcement->announcement)) {
Announcement::incrementViews($announcement->id);
$announcementText = addslashes($announcement->announcement);
$interactionLink = $lang['interaction_link'];
echo "<script>
window.addEventListener('load', function() {
var popup = document.createElement('div');
popup.innerHTML = `
<div style=\"position: fixed; top: 20px; right: 20px; background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 0 15px rgba(0,0,0,0.2);\">
<p>${announcementText}</p>
<a href=\"#\" onclick=\"this.parentElement.style.display='none'; return false;\">${interactionLink}</a>
</div>
`;
document.body.appendChild(popup);
});
</script>";
}
}