forked from goautodial/v4.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrocketchat.php
148 lines (134 loc) · 5.54 KB
/
rocketchat.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
/**
* @file rocketchat.php
* @brief Loadup Rocketchat
* @copyright Copyright (c) 2021 GOautodial Inc.
* @author Alexander Jim Abenoja
*
* @par <b>License</b>:
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once('php/UIHandler.php');
require_once('php/APIHandler.php');
require_once('./php/CRMDefaults.php');
require_once('./php/LanguageHandler.php');
include('./php/Session.php');
$ui = \creamy\UIHandler::getInstance();
$api = \creamy\APIHandler::getInstance();
$lh = \creamy\LanguageHandler::getInstance();
$user = \creamy\CreamyUser::currentUser();
//proper user redirects
if($user->getUserRole() != CRM_DEFAULTS_USER_ROLE_ADMIN){
if($user->getUserRole() == CRM_DEFAULTS_USER_ROLE_AGENT){
header("location: agent.php");
}
}
if(ROCKETCHAT_ENABLE === 'n'){
header("location: index.php");
}
?>
<html>
<head>
<meta charset="UTF-8">
<title><?php $lh->translateText('portal_title'); ?> - <?php $lh->translateText("call_times"); ?></title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php
print $ui->standardizedThemeCSS();
print $ui->creamyThemeCSS();
print $ui->dataTablesTheme();
?>
<!-- Wizard Form style -->
<link href="css/wizard-form.css" rel="stylesheet" type="text/css" />
<!-- Wizard Form style -->
<link rel="stylesheet" href="css/easyWizard.css">
<link href="css/style.css" rel="stylesheet" type="text/css" />
<!-- datetime picker -->
<link rel="stylesheet" src="js/dashboard/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css">
<!-- Date Picker -->
<script type="text/javascript" src="js/dashboard/eonasdan-bootstrap-datetimepicker/build/js/moment.js"></script>
<script type="text/javascript" src="js/dashboard/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
</head>
<?php print $ui->creamyBody(); ?>
<div class="wrapper">
<!-- header logo: style can be found in header.less -->
<?php print $ui->creamyHeader($user); ?>
<!-- Left side column. contains the logo and sidebar -->
<?php print $ui->getSidebar($user->getUserId(), $user->getUserName(), $user->getUserRole(), $user->getUserAvatar()); ?>
<!-- Right side column. Contains the navbar and content of the page -->
<aside class="right-side">
<div id="rc_div">
<!--<iframe src="https://kuts.justgocloud.com?layout=embedded" width="100%" height="100%">-->
</div>
</aside><!-- /.right-side -->
<?php print $ui->getRightSidebar($user->getUserId(), $user->getUserName(), $user->getUserAvatar()); ?>
</div><!-- ./wrapper -->
<!-- Forms and actions -->
<?php print $ui->standardizedThemeJS(); ?>
<script type="text/javascript">
$(document).ready(function() {
// login_rocketchat("<?php echo $user->getUserName();?>", "<?php echo $user->getUserName();?>");
$('<iframe>', {
src: '<?php echo ROCKETCHAT_URL;?>',
id: 'rc_frame',
frameborder: 0,
width: '100%',
height: '100%',
scrolling: 'no',
load:function(){
$.ajax({
url: "./php/LoginRocketChat.php",
type: 'POST',
data: {
user: "felipe", pass: "felipe"
},
success: function(data) {
console.log(data);
var obj = JSON.parse(data);
var authToken = obj.data['authToken'];
console.log(authToken);
document.getElementById("rc_frame").contentWindow.postMessage({
event: 'login-with-token',
resume: authToken
}, '<?php echo ROCKETCHAT_URL;?>/api/v1/login');
}
});
}
}).appendTo('#rc_div');
window.addEventListener('message', function(e) {
console.log(e.data.eventName); // event name
console.log(e.data.data); // event data
});
//login_rocketchat("devadmin", "hayopka2021");
}); // end of document ready
function login_rocketchat(user, pass){
$.ajax({
url: "./php/LoginRocketChat.php",
type: 'POST',
data: {
user: user, pass: pass
},
success: function(data) {
var obj = JSON.parse(data);
var authToken = obj.data['authToken'];
document.getElementById("rc_frame").contentWindow.postMessage({
event: 'login-with-token',
loginToken: authToken
}, 'https://rcwits.justgocloud.com');
}
});
}
</script>
<?php print $ui->creamyFooter(); ?>
</body>
</html>