This repository was archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail_credentials.php
270 lines (257 loc) · 8.4 KB
/
email_credentials.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?php
if (!logged_in()) {
login_then_redirect_back_here();
}
$user_id = $_SESSION['user_id'] ?? '';
define('TITLE', 'S!zzle - Email Credentials');
require __DIR__.'/header.php';
?>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&lang=en">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/create_recruiting.min.css">
<!-- Polymer -->
<script src="/components/webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="/components/iron-icons/iron-icons.html">
<link rel="import" href="/components/iron-icon/iron-icon.html">
<link rel="import" href="/components/iron-form/iron-form.html">
<link rel="import" href="/components/paper-menu/paper-menu.html">
<link rel="import" href="/components/paper-item/paper-item.html">
<link rel="import" href="/components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="/components/paper-input/paper-input.html">
<link rel="import" href="/components/paper-header-panel/paper-header-panel.html">
<link rel="import" href="/components/paper-toolbar/paper-toolbar.html">
<link rel="import" href="/components/paper-styles/paper-styles.html">
<link rel="import" href="/components/paper-card/paper-card.html">
<link rel="import" href="/components/paper-button/paper-button.html">
<link rel="import" href="/components/paper-input/paper-textarea.html">
<link rel="import" href="/components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="/components/paper-dialog/paper-dialog.html">
<link rel="import" href="/components/paper-fab/paper-fab.html">
<link rel="import" href="/components/paper-tooltip/paper-tooltip.html">
<style is="custom-style">
.center-column {
margin-top: 100px;
}
.field-container {
text-align: left;
}
paper-card {
display: block;
width: 100%;
background: #424242;
margin-top: 20px;
--paper-card-header-color: white;
--paper-card-header-text: {font-weight: normal;}
}
paper-card#send-token-via {
display: none;
}
paper-input, paper-textarea, paper-dropdown-menu {
--paper-input-container-focus-color: #1094F7;
--paper-input-container-input-color: white
}
paper-button {
background: #009688;
color: white;
}
paper-button.dialog-button {
background: #2193ED;
font-size: 14px;
margin-top: 0px;
margin-bottom: 20px;
border: 0px;
}
.library-button {
margin: 10px 0px;
width: 100%;
}
iron-icon {
margin-right: 10px;
color: #676767;
}
paper-toolbar {
--paper-toolbar-background: #111111
}
paper-fab{
--paper-fab-background: #2193ED;
display: inline-block;
vertical-align: middle;
}
paper-fab.progress-fab {
margin-left: 10px;
}
paper-dialog {
--paper-dialog-background-color: #424242;
color: white;
--paper-dialog-title: {font-size: 24px; font-weight: 300; margin-top: 10px}
}
paper-dialog#status-dialog {
--paper-dialog-background-color: #303030;
}
#status-dialog {
height: 200px;
width: 500px;
}
#status-details {
color: red;
}
</style>
</head>
<body>
<div>
<?php require_once __DIR__.'/navbar.php';?>
</div>
<div class="center-column">
<div id="left-column">
<form is="iron-form" id="recruiting-company-form">
<paper-card id="company-info" heading="Email Credentials">
<div class="field-container">
<i>
Instructions:
<a href="https://blog.gosizzle.io/version-1-10-0-release-7417eb683d62" target="_blank">
Gmail
</a>
</i>
<paper-input
label="Username"
id="credential-email"
name="credential_email"
required>
</paper-input>
<paper-button
id="show-password-button"
class="pull-right"
raised
onclick="showPassword()">
SHOW
</paper-button>
<paper-button
id="hide-password-button"
class="pull-right"
raised
onclick="hidePassword()"
hidden>
HIDE
</paper-button>
<paper-input
label="Password"
id="credential-password"
name="credential_password"
type="password"
required>
</paper-input>
<paper-input
label="SMTP Host"
id="credential-host"
name="credential_host"
required>
</paper-input>
<paper-input
label="SMTP Port"
id="credential-port"
name="credential_port"
required>
</paper-input>
<br />
<i>
Currently only SMTP TLS authentication is supported. If you have
any questions please contact
<a href="mailto:support@GoSizzle.io">support@GoSizzle.io</a>.
</i>
</div>
</paper-card>
</form>
</div>
<div id="right-column" class="pull-right">
<div class="button-container">
<paper-button raised onclick="backToSend('<?php echo $_GET['referrer'] ?? '';?>')">BACK</paper-button>
<paper-button raised onclick="saveCredentials()">SAVE</paper-button>
</div>
</div>
</div>
<paper-dialog class="recruiting-dialog" id="status-dialog" modal>
<p id="status-message"></p>
<p id="status-details"></p>
<div class="button-container">
<paper-button raised onclick="dismissStatusDialog()">DISMISS</paper-button>
</div>
</paper-dialog>
<?php require_once __DIR__.'/footer.php';?>
<!-- JavaScript -->
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
crossorigin="anonymous"></script>
<script>
/**
* Attempts to upload the email credentials to the ajax endpoint & closes dialog
*/
function saveCredentials() {
$.ajax({
url: '/ajax/email/credential/add/',
type: 'post',
data: {
username: $('#credential-email').val(),
password: $('#credential-password').val(),
smtp_host: $('#credential-host').val(),
smtp_port: $('#credential-port').val(),
},
dataType: 'json',
success: function(data, textStatus){
var message = data.data.message+'<br />';
if(data.success === 'true') {
$('#status-message').html('Email credentials saved');
$('#status-details').html('');
$('#status-dialog')[0].open();
} else {
$('#status-message').html('Failed to save email credentials');
var height = 200;
var errors = '';
$.each(data.data.errors, function(i, v) {
errors += v+'<br/>';
height += 15;
});
$('#status-dialog').css('height', height+'px');
$('#status-details').html(errors);
$('#status-dialog')[0].open();
}
}
}).fail(function() {
$('#status-message').html('Failed to save email credentials');
$('#status-dialog')[0].open();
});
}
/**
* Redirects user back to token send page from email list edit page
*
* @param {String} longId The long_id of the token
*/
function backToSend(longId) {
window.location = '/send_recruiting?id='+longId;
}
/**
* Closes the Status Dialog
*/
function dismissStatusDialog() {
$('#status-dialog')[0].close();
}
/**
* Shows the password
*/
function showPassword() {
$('#credential-password').removeAttr('type');
$('#hide-password-button').removeAttr('hidden');
$('#show-password-button').attr('hidden', 'hidden');
}
/**
* Hides the password
*/
function hidePassword() {
$('#credential-password').attr('type', 'password');
$('#show-password-button').removeAttr('hidden');
$('#hide-password-button').attr('hidden', 'hidden');
}
</script>
</body>
</html>