1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,334 @@ |
1 |
+/** |
|
2 |
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
3 |
+ * |
|
4 |
+ * @author Double Bastion LLC |
|
5 |
+ * |
|
6 |
+ * @license GNU AGPL version 3 or any later version |
|
7 |
+ * |
|
8 |
+ * This program is free software; you can redistribute it and/or |
|
9 |
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
10 |
+ * License as published by the Free Software Foundation; either |
|
11 |
+ * version 3 of the License, or any later version. |
|
12 |
+ * |
|
13 |
+ * This program is distributed in the hope that it will be useful, |
|
14 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
17 |
+ * |
|
18 |
+ * You should have received a copy of the GNU Affero General Public |
|
19 |
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
+ * |
|
21 |
+ */ |
|
22 |
+ |
|
23 |
+$(document).ready(function() { |
|
24 |
+ |
|
25 |
+ var userid = "<?php p($userId); ?>"; |
|
26 |
+ |
|
27 |
+ // Delete from the database all the received messages older than the specified period |
|
28 |
+ $("#delOldrecSMS").on("click", function() { |
|
29 |
+ |
|
30 |
+ var oldrecInterval = $("#oldrecSmsInterval").val(); |
|
31 |
+ var procoldrecint = oldrecInterval.replace(/[^0-9]/g, ""); |
|
32 |
+ var finaloldrecint = parseInt(procoldrecint); |
|
33 |
+ |
|
34 |
+ if (finaloldrecint == "" || !$.isNumeric(finaloldrecint)) { |
|
35 |
+ showAlert("Please enter the number of days in the box from above !"); |
|
36 |
+ } else { |
|
37 |
+ |
|
38 |
+ var getRecUrl = OC.generateUrl("/apps/sms_relentless/user/getreceivedtablefordel"); |
|
39 |
+ $('#smstables').addClass('icon-loading'); |
|
40 |
+ |
|
41 |
+ $.ajax({ |
|
42 |
+ url: getRecUrl + '/' + userid, |
|
43 |
+ method: "GET", |
|
44 |
+ dataType:'text', |
|
45 |
+ success: function(recinfoFromDB) { |
|
46 |
+ |
|
47 |
+ var parsedinfo = $.parseJSON(recinfoFromDB); |
|
48 |
+ |
|
49 |
+ if (parsedinfo == "not permitted") { |
|
50 |
+ |
|
51 |
+ showAlert("Only admins can remove old messages using this option!"); |
|
52 |
+ $('#smstables').removeClass('icon-loading'); |
|
53 |
+ return; |
|
54 |
+ |
|
55 |
+ } else { |
|
56 |
+ |
|
57 |
+ var recmessagedbIDs = []; |
|
58 |
+ var oldrecRows = []; |
|
59 |
+ oldrecRows.push("id,user_id,message_id,date,from,to,message,author_displayname,internal_sender\r\n"); |
|
60 |
+ |
|
61 |
+ var targetdate = new Date(new Date().setDate(new Date().getDate() - finaloldrecint)); |
|
62 |
+ |
|
63 |
+ for (var j = 0; j < parsedinfo.length; j++) { |
|
64 |
+ var firstdate = parsedinfo[j].date; |
|
65 |
+ var secdate = firstdate.split(" "); |
|
66 |
+ var thirddate = secdate[0].split("-"); |
|
67 |
+ var fourthdate = secdate[1].split(":"); |
|
68 |
+ var pastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
69 |
+ |
|
70 |
+ if (pastdate < targetdate) { |
|
71 |
+ recmessagedbIDs.push(parsedinfo[j].id); |
|
72 |
+ |
|
73 |
+ // Check if the message contains characters that must be escaped in the final CSV file |
|
74 |
+ if ((parsedinfo[j].message.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedinfo[j].message)) && parsedinfo[j].message.indexOf('"') === -1) { |
|
75 |
+ var messageproc = '"'+ parsedinfo[j].message + '"'; |
|
76 |
+ } else if (parsedinfo[j].message.indexOf('"') > -1) { |
|
77 |
+ var messageproc = '"'+ parsedinfo[j].message.replace(/"/g,'""') + '"'; |
|
78 |
+ } |
|
79 |
+ |
|
80 |
+ oldrecRows.push(parsedinfo[j].id + ',' + parsedinfo[j].user_id + ',' + parsedinfo[j].message_id + ',' + parsedinfo[j].date + ',' + parsedinfo[j].from + ',' + parsedinfo[j].to + ',' + messageproc + ',' + parsedinfo[j].author_displayname + ',' + parsedinfo[j].internal_sender + '\r\n'); |
|
81 |
+ } |
|
82 |
+ } |
|
83 |
+ |
|
84 |
+ |
|
85 |
+ if (oldrecRows.length == 1) { |
|
86 |
+ |
|
87 |
+ showAlert("No messages will be deleted since there are no messages older than " + finaloldrecint + " days."); |
|
88 |
+ |
|
89 |
+ // Save in a '.csv' file all the received messages that will be deleted from the database, then delete them |
|
90 |
+ } else { |
|
91 |
+ |
|
92 |
+ confirmAlert("Are you sure you want to delete all the received messages older than " + finaloldrecint + " days ?"); |
|
93 |
+ |
|
94 |
+ $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
95 |
+ |
|
96 |
+ $("#confirmOk").click(function() { |
|
97 |
+ |
|
98 |
+ $("#alertMsgOverlay").remove(); |
|
99 |
+ $("#alertConfMessage").remove(); |
|
100 |
+ |
|
101 |
+ var deloldrecRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldrecrows"); |
|
102 |
+ |
|
103 |
+ $.ajax({ |
|
104 |
+ url: deloldrecRowsUrl + '/' + userid, |
|
105 |
+ method: "POST", |
|
106 |
+ dataType:'text', |
|
107 |
+ data: { oldrecRows: oldrecRows }, |
|
108 |
+ success: function(savecheck) { |
|
109 |
+ |
|
110 |
+ // Delete received messages from the database |
|
111 |
+ var delrecDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removerecrows"); |
|
112 |
+ |
|
113 |
+ if (savecheck == 1) { |
|
114 |
+ |
|
115 |
+ $.ajax({ |
|
116 |
+ url: delrecDbSmsUrl + '/' + userid, |
|
117 |
+ method: "POST", |
|
118 |
+ dataType:'text', |
|
119 |
+ data: { recmessagedbIDs: recmessagedbIDs }, |
|
120 |
+ success: function() { |
|
121 |
+ showAlert((oldrecRows.length - 1)+" rows have been successfully saved in the 'SMS_relentless/removed_received_messages' directory and then deleted from the database !"); |
|
122 |
+ $('#smstables').removeClass('icon-loading'); |
|
123 |
+ }, |
|
124 |
+ error: function() { |
|
125 |
+ showAlert("There was an error while deleting the messages older than the specified period!"); |
|
126 |
+ $('#smstables').removeClass('icon-loading'); |
|
127 |
+ } |
|
128 |
+ }); |
|
129 |
+ |
|
130 |
+ } else { showAlert("There was an error while saving the messages older than the specified period!"); } |
|
131 |
+ |
|
132 |
+ $('#smstables').removeClass('icon-loading'); |
|
133 |
+ }, |
|
134 |
+ error: function() { |
|
135 |
+ showAlert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
136 |
+ $('#smstables').removeClass('icon-loading'); |
|
137 |
+ } |
|
138 |
+ }); |
|
139 |
+ }); |
|
140 |
+ } |
|
141 |
+ } |
|
142 |
+ }, |
|
143 |
+ error: function() { |
|
144 |
+ showAlert("An error occurred while getting data from the database!"); |
|
145 |
+ $('#smstables').removeClass('icon-loading'); |
|
146 |
+ } |
|
147 |
+ }); |
|
148 |
+ |
|
149 |
+ } |
|
150 |
+ |
|
151 |
+ }); |
|
152 |
+ |
|
153 |
+ |
|
154 |
+ // Delete from the database all the sent messages older than the specified period |
|
155 |
+ $("#delOldsentSMS").on("click", function() { |
|
156 |
+ |
|
157 |
+ var oldsentInterval = $("#oldsentSmsInterval").val(); |
|
158 |
+ var procoldsentint = oldsentInterval.replace(/[^0-9]/g, ""); |
|
159 |
+ var finaloldsentint = parseInt(procoldsentint); |
|
160 |
+ |
|
161 |
+ if (finaloldsentint == "" || !$.isNumeric(finaloldsentint)) { |
|
162 |
+ showAlert("Please enter the number of days in the box above !"); |
|
163 |
+ } else { |
|
164 |
+ |
|
165 |
+ var getSentUrl = OC.generateUrl("/apps/sms_relentless/user/getsenttablefordel"); |
|
166 |
+ $('#smstables').addClass('icon-loading'); |
|
167 |
+ |
|
168 |
+ $.ajax({ |
|
169 |
+ url: getSentUrl + '/' + userid, |
|
170 |
+ method: "GET", |
|
171 |
+ dataType:'text', |
|
172 |
+ success: function(sentinfoFromDB) { |
|
173 |
+ |
|
174 |
+ var parsedsentinfo = $.parseJSON(sentinfoFromDB); |
|
175 |
+ |
|
176 |
+ if (parsedsentinfo == "not permitted") { |
|
177 |
+ |
|
178 |
+ showAlert("Only admins can remove old messages using this option!"); |
|
179 |
+ $('#smstables').removeClass('icon-loading'); |
|
180 |
+ return; |
|
181 |
+ |
|
182 |
+ } else { |
|
183 |
+ |
|
184 |
+ var sentmessagedbIDs = []; |
|
185 |
+ var oldsentRows = []; |
|
186 |
+ oldsentRows.push("id,user_id,message_id,date,from,to,network,price,status,deliveryreceipt,message,author_displayname\r\n"); |
|
187 |
+ |
|
188 |
+ var senttargetdate = new Date(new Date().setDate(new Date().getDate() - finaloldsentint)); |
|
189 |
+ |
|
190 |
+ for (var j = 0; j < parsedsentinfo.length; j++) { |
|
191 |
+ var firstdate = parsedsentinfo[j].date; |
|
192 |
+ var secdate = firstdate.split(" "); |
|
193 |
+ var thirddate = secdate[0].split("-"); |
|
194 |
+ var fourthdate = secdate[1].split(":"); |
|
195 |
+ var sentpastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
196 |
+ |
|
197 |
+ if (sentpastdate < senttargetdate) { |
|
198 |
+ sentmessagedbIDs.push(parsedsentinfo[j].id); |
|
199 |
+ |
|
200 |
+ // Check if the message contains characters that must be escaped in the final CSV file |
|
201 |
+ if ((parsedsentinfo[j].message.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].message)) && parsedsentinfo[j].message.indexOf('"') === -1) { |
|
202 |
+ var messageproc = '"'+ parsedsentinfo[j].message + '"'; |
|
203 |
+ } else if (parsedsentinfo[j].message.indexOf('"') > -1) { |
|
204 |
+ var messageproc = '"'+ parsedsentinfo[j].message.replace(/"/g,'""') + '"'; |
|
205 |
+ } |
|
206 |
+ |
|
207 |
+ if ((parsedsentinfo[j].network.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].network)) && parsedsentinfo[j].network.indexOf('"') === -1) { |
|
208 |
+ var networkproc = '"'+ parsedsentinfo[j].network + '"'; |
|
209 |
+ } else if (parsedsentinfo[j].network.indexOf('"') > -1) { |
|
210 |
+ var networkproc = '"'+ parsedsentinfo[j].network.replace(/"/g,'""') + '"'; |
|
211 |
+ } |
|
212 |
+ |
|
213 |
+ if ((parsedsentinfo[j].status.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].status)) && parsedsentinfo[j].status.indexOf('"') === -1) { |
|
214 |
+ var statusproc = '"'+ parsedsentinfo[j].status + '"'; |
|
215 |
+ } else if (parsedsentinfo[j].status.indexOf('"') > -1) { |
|
216 |
+ var statusproc = '"'+ parsedsentinfo[j].status.replace(/"/g,'""') + '"'; |
|
217 |
+ } |
|
218 |
+ |
|
219 |
+ oldsentRows.push(parsedsentinfo[j].id + ',' + parsedsentinfo[j].user_id + ',' + parsedsentinfo[j].message_id + ',' + parsedsentinfo[j].date + ',' + parsedsentinfo[j].from + ',' + parsedsentinfo[j].to + ',' + networkproc + ',' + parsedsentinfo[j].price + ',' + statusproc + ',' + parsedsentinfo[j].deliveryreceipt + ',' + messageproc + ',' + parsedsentinfo[j].author_displayname + '\r\n'); |
|
220 |
+ } |
|
221 |
+ } |
|
222 |
+ |
|
223 |
+ |
|
224 |
+ if (oldsentRows.length == 1) { |
|
225 |
+ |
|
226 |
+ showAlert("No messages will be deleted since there are no messages older than " + finaloldsentint + " days."); |
|
227 |
+ |
|
228 |
+ // Save in a '.csv' file all the sent messages that will be deleted from the database, then delete them |
|
229 |
+ } else { |
|
230 |
+ |
|
231 |
+ confirmAlert("Are you sure you want to delete all the sent messages older than " + finaloldsentint + " days ?"); |
|
232 |
+ |
|
233 |
+ $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
234 |
+ |
|
235 |
+ $("#confirmOk").click(function() { |
|
236 |
+ |
|
237 |
+ $("#alertMsgOverlay").remove(); |
|
238 |
+ $("#alertConfMessage").remove(); |
|
239 |
+ |
|
240 |
+ var deloldsentRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldsentrows"); |
|
241 |
+ |
|
242 |
+ $.ajax({ |
|
243 |
+ url: deloldsentRowsUrl + '/' + userid, |
|
244 |
+ method: "POST", |
|
245 |
+ dataType:'text', |
|
246 |
+ data: { oldsentRows: oldsentRows }, |
|
247 |
+ success: function(savesentcheck) { |
|
248 |
+ |
|
249 |
+ // Delete sent messages from the database |
|
250 |
+ var delsentDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removesentrows"); |
|
251 |
+ |
|
252 |
+ if (savesentcheck == 1) { |
|
253 |
+ |
|
254 |
+ $.ajax({ |
|
255 |
+ url: delsentDbSmsUrl + '/' + userid, |
|
256 |
+ method: "POST", |
|
257 |
+ dataType:'text', |
|
258 |
+ data: { sentmessagedbIDs: sentmessagedbIDs }, |
|
259 |
+ success: function() { |
|
260 |
+ showAlert((oldsentRows.length - 1) + " rows have been successfully saved in the 'SMS_relentless/removed_sent_messages' directory and then deleted from the database !"); |
|
261 |
+ $('#smstables').removeClass('icon-loading'); |
|
262 |
+ }, |
|
263 |
+ error: function() { |
|
264 |
+ showAlert("There was an error while deleting the messages older than the specified period!"); |
|
265 |
+ $('#smstables').removeClass('icon-loading'); |
|
266 |
+ } |
|
267 |
+ }); |
|
268 |
+ |
|
269 |
+ } else { showAlert("There was an error while saving the messages older than the specified period!"); } |
|
270 |
+ |
|
271 |
+ $('#smstables').removeClass('icon-loading'); |
|
272 |
+ }, |
|
273 |
+ error: function() { |
|
274 |
+ showAlert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
275 |
+ $('#smstables').removeClass('icon-loading'); |
|
276 |
+ } |
|
277 |
+ }); |
|
278 |
+ }); |
|
279 |
+ } |
|
280 |
+ } |
|
281 |
+ |
|
282 |
+ }, |
|
283 |
+ error: function() { |
|
284 |
+ showAlert("An error occurred while getting data from the database!"); |
|
285 |
+ $('#smstables').removeClass('icon-loading'); |
|
286 |
+ } |
|
287 |
+ }); |
|
288 |
+ } |
|
289 |
+ |
|
290 |
+ }); |
|
291 |
+ |
|
292 |
+ function showAlert(alertText) { |
|
293 |
+ |
|
294 |
+ let alertwnd = "<div id='alertMessage'>"; |
|
295 |
+ alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>"; |
|
296 |
+ alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>"; |
|
297 |
+ alertwnd += "<input type='submit' id='alertOk' value='OK'>"; |
|
298 |
+ alertwnd += "</div>"; |
|
299 |
+ |
|
300 |
+ $("#content").append("<div id='alertMsgOverlay'></div>"); |
|
301 |
+ $("#content").append(alertwnd); |
|
302 |
+ |
|
303 |
+ let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px"; |
|
304 |
+ let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px"; |
|
305 |
+ $("#alertMessage").css({ "top" : topDist, "left" : leftDist }); |
|
306 |
+ |
|
307 |
+ $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
308 |
+ $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
309 |
+ $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
310 |
+ } |
|
311 |
+ |
|
312 |
+ function confirmAlert(alertText) { |
|
313 |
+ |
|
314 |
+ $("#alertMsgOverlay").remove(); |
|
315 |
+ $("#alertConfMessage").remove(); |
|
316 |
+ |
|
317 |
+ let alertwndcf = "<div id='alertConfMessage'>"; |
|
318 |
+ alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>"; |
|
319 |
+ alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>"; |
|
320 |
+ alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>"; |
|
321 |
+ alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>"; |
|
322 |
+ alertwndcf += "</div>"; |
|
323 |
+ |
|
324 |
+ $("#content").append("<div id='alertMsgOverlay'></div>"); |
|
325 |
+ $("#content").append(alertwndcf); |
|
326 |
+ |
|
327 |
+ let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px"; |
|
328 |
+ let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px"; |
|
329 |
+ $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist }); |
|
330 |
+ |
|
331 |
+ $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
332 |
+ $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
333 |
+ } |
|
334 |
+}); |
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,331 +0,0 @@ |
1 |
-/** |
|
2 |
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
3 |
- * |
|
4 |
- * @author Double Bastion LLC |
|
5 |
- * |
|
6 |
- * @license GNU AGPL version 3 or any later version |
|
7 |
- * |
|
8 |
- * This program is free software; you can redistribute it and/or |
|
9 |
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
10 |
- * License as published by the Free Software Foundation; either |
|
11 |
- * version 3 of the License, or any later version. |
|
12 |
- * |
|
13 |
- * This program is distributed in the hope that it will be useful, |
|
14 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
17 |
- * |
|
18 |
- * You should have received a copy of the GNU Affero General Public |
|
19 |
- * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
- * |
|
21 |
- */ |
|
22 |
- |
|
23 |
-$(document).ready(function() { |
|
24 |
- |
|
25 |
- var userid = "<?php p($userId); ?>"; |
|
26 |
- |
|
27 |
- // Delete from the database all the received messages older than the specified period |
|
28 |
- $("#delOldrecSMS").on("click", function() { |
|
29 |
- |
|
30 |
- var oldrecInterval = $("#oldrecSmsInterval").val(); |
|
31 |
- var procoldrecint = oldrecInterval.replace(/[^0-9]/g, ""); |
|
32 |
- var finaloldrecint = parseInt(procoldrecint); |
|
33 |
- |
|
34 |
- if (finaloldrecint == "" || !$.isNumeric(finaloldrecint)) { |
|
35 |
- showAlert("Please enter the number of days in the box from above !"); |
|
36 |
- } else { |
|
37 |
- |
|
38 |
- var getRecUrl = OC.generateUrl("/apps/sms_relentless/user/getreceivedtablefordel"); |
|
39 |
- $('#smstables').addClass('icon-loading'); |
|
40 |
- |
|
41 |
- $.ajax({ |
|
42 |
- url: getRecUrl + '/' + userid, |
|
43 |
- method: "GET", |
|
44 |
- dataType:'text', |
|
45 |
- success: function(recinfoFromDB) { |
|
46 |
- |
|
47 |
- var parsedinfo = $.parseJSON(recinfoFromDB); |
|
48 |
- |
|
49 |
- if (parsedinfo == "not permitted") { |
|
50 |
- |
|
51 |
- showAlert("Only admins can remove old messages using this option!"); |
|
52 |
- $('#smstables').removeClass('icon-loading'); |
|
53 |
- return; |
|
54 |
- |
|
55 |
- } else { |
|
56 |
- |
|
57 |
- var recmessagedbIDs = []; |
|
58 |
- var oldrecRows = []; |
|
59 |
- oldrecRows.push("id,user_id,message_id,date,from,to,message,author_displayname,internal_sender\r\n"); |
|
60 |
- |
|
61 |
- var targetdate = new Date(new Date().setDate(new Date().getDate() - finaloldrecint)); |
|
62 |
- |
|
63 |
- for (var j = 0; j < parsedinfo.length; j++) { |
|
64 |
- var firstdate = parsedinfo[j].date; |
|
65 |
- var secdate = firstdate.split(" "); |
|
66 |
- var thirddate = secdate[0].split("-"); |
|
67 |
- var fourthdate = secdate[1].split(":"); |
|
68 |
- var pastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
69 |
- |
|
70 |
- if (pastdate < targetdate) { |
|
71 |
- recmessagedbIDs.push(parsedinfo[j].id); |
|
72 |
- |
|
73 |
- // Check if the message contains characters that must be escaped in the final CSV file |
|
74 |
- if ((parsedinfo[j].message.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedinfo[j].message)) && parsedinfo[j].message.indexOf('"') === -1) { |
|
75 |
- var messageproc = '"'+ parsedinfo[j].message + '"'; |
|
76 |
- } else if (parsedinfo[j].message.indexOf('"') > -1) { |
|
77 |
- var messageproc = '"'+ parsedinfo[j].message.replace(/"/g,'""') + '"'; |
|
78 |
- } |
|
79 |
- |
|
80 |
- oldrecRows.push(parsedinfo[j].id + ',' + parsedinfo[j].user_id + ',' + parsedinfo[j].message_id + ',' + parsedinfo[j].date + ',' + parsedinfo[j].from + ',' + parsedinfo[j].to + ',' + messageproc + ',' + parsedinfo[j].author_displayname + ',' + parsedinfo[j].internal_sender + '\r\n'); |
|
81 |
- } |
|
82 |
- } |
|
83 |
- |
|
84 |
- |
|
85 |
- if (oldrecRows.length == 1) { |
|
86 |
- |
|
87 |
- showAlert("No messages will be deleted since there are no messages older than " + finaloldrecint + " days."); |
|
88 |
- |
|
89 |
- // Save in a '.csv' file all the received messages that will be deleted from the database, then delete them |
|
90 |
- } else { |
|
91 |
- |
|
92 |
- confirmAlert("Are you sure you want to delete all the received messages older than " + finaloldrecint + " days ?"); |
|
93 |
- |
|
94 |
- $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
95 |
- |
|
96 |
- $("#confirmOk").click(function() { |
|
97 |
- |
|
98 |
- $("#alertMsgOverlay").remove(); |
|
99 |
- $("#alertConfMessage").remove(); |
|
100 |
- |
|
101 |
- var deloldrecRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldrecrows"); |
|
102 |
- |
|
103 |
- $.ajax({ |
|
104 |
- url: deloldrecRowsUrl + '/' + userid, |
|
105 |
- method: "POST", |
|
106 |
- dataType:'text', |
|
107 |
- data: { oldrecRows: oldrecRows }, |
|
108 |
- success: function(savecheck) { |
|
109 |
- |
|
110 |
- // Delete received messages from the database |
|
111 |
- var delrecDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removerecrows"); |
|
112 |
- |
|
113 |
- if (savecheck == 1) { |
|
114 |
- |
|
115 |
- $.ajax({ |
|
116 |
- url: delrecDbSmsUrl + '/' + userid, |
|
117 |
- method: "POST", |
|
118 |
- dataType:'text', |
|
119 |
- data: { recmessagedbIDs: recmessagedbIDs }, |
|
120 |
- success: function() { |
|
121 |
- showAlert((oldrecRows.length - 1)+" rows have been successfully saved in the 'SMS_relentless/removed_received_messages' directory and then deleted from the database !"); |
|
122 |
- $('#smstables').removeClass('icon-loading'); |
|
123 |
- }, |
|
124 |
- error: function() { |
|
125 |
- showAlert("There was an error while deleting the messages older than the specified period!"); |
|
126 |
- $('#smstables').removeClass('icon-loading'); |
|
127 |
- } |
|
128 |
- }); |
|
129 |
- |
|
130 |
- } else { showAlert("There was an error while saving the messages older than the specified period!"); } |
|
131 |
- |
|
132 |
- $('#smstables').removeClass('icon-loading'); |
|
133 |
- }, |
|
134 |
- error: function() { |
|
135 |
- showAlert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
136 |
- $('#smstables').removeClass('icon-loading'); |
|
137 |
- } |
|
138 |
- }); |
|
139 |
- }); |
|
140 |
- } |
|
141 |
- } |
|
142 |
- }, |
|
143 |
- error: function() { |
|
144 |
- showAlert("An error occurred while getting data from the database!"); |
|
145 |
- $('#smstables').removeClass('icon-loading'); |
|
146 |
- } |
|
147 |
- }); |
|
148 |
- |
|
149 |
- } |
|
150 |
- |
|
151 |
- }); |
|
152 |
- |
|
153 |
- |
|
154 |
- // Delete from the database all the sent messages older than the specified period |
|
155 |
- $("#delOldsentSMS").on("click", function() { |
|
156 |
- |
|
157 |
- var oldsentInterval = $("#oldsentSmsInterval").val(); |
|
158 |
- var procoldsentint = oldsentInterval.replace(/[^0-9]/g, ""); |
|
159 |
- var finaloldsentint = parseInt(procoldsentint); |
|
160 |
- |
|
161 |
- if (finaloldsentint == "" || !$.isNumeric(finaloldsentint)) { |
|
162 |
- showAlert("Please enter the number of days in the box above !"); |
|
163 |
- } else { |
|
164 |
- |
|
165 |
- var getSentUrl = OC.generateUrl("/apps/sms_relentless/user/getsenttablefordel"); |
|
166 |
- $('#smstables').addClass('icon-loading'); |
|
167 |
- |
|
168 |
- $.ajax({ |
|
169 |
- url: getSentUrl + '/' + userid, |
|
170 |
- method: "GET", |
|
171 |
- dataType:'text', |
|
172 |
- success: function(sentinfoFromDB) { |
|
173 |
- |
|
174 |
- var parsedsentinfo = $.parseJSON(sentinfoFromDB); |
|
175 |
- |
|
176 |
- if (parsedsentinfo == "not permitted") { |
|
177 |
- |
|
178 |
- showAlert("Only admins can remove old messages using this option!"); |
|
179 |
- $('#smstables').removeClass('icon-loading'); |
|
180 |
- return; |
|
181 |
- |
|
182 |
- } else { |
|
183 |
- |
|
184 |
- var sentmessagedbIDs = []; |
|
185 |
- var oldsentRows = []; |
|
186 |
- oldsentRows.push("id,user_id,message_id,date,from,to,network,price,status,deliveryreceipt,message,author_displayname\r\n"); |
|
187 |
- |
|
188 |
- var senttargetdate = new Date(new Date().setDate(new Date().getDate() - finaloldsentint)); |
|
189 |
- |
|
190 |
- for (var j = 0; j < parsedsentinfo.length; j++) { |
|
191 |
- var firstdate = parsedsentinfo[j].date; |
|
192 |
- var secdate = firstdate.split(" "); |
|
193 |
- var thirddate = secdate[0].split("-"); |
|
194 |
- var fourthdate = secdate[1].split(":"); |
|
195 |
- var sentpastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
196 |
- |
|
197 |
- if (sentpastdate < senttargetdate) { |
|
198 |
- sentmessagedbIDs.push(parsedsentinfo[j].id); |
|
199 |
- |
|
200 |
- // Check if the message contains characters that must be escaped in the final CSV file |
|
201 |
- if ((parsedsentinfo[j].message.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].message)) && parsedsentinfo[j].message.indexOf('"') === -1) { |
|
202 |
- var messageproc = '"'+ parsedsentinfo[j].message + '"'; |
|
203 |
- } else if (parsedsentinfo[j].message.indexOf('"') > -1) { |
|
204 |
- var messageproc = '"'+ parsedsentinfo[j].message.replace(/"/g,'""') + '"'; |
|
205 |
- } |
|
206 |
- |
|
207 |
- if ((parsedsentinfo[j].network.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].network)) && parsedsentinfo[j].network.indexOf('"') === -1) { |
|
208 |
- var networkproc = '"'+ parsedsentinfo[j].network + '"'; |
|
209 |
- } else if (parsedsentinfo[j].network.indexOf('"') > -1) { |
|
210 |
- var networkproc = '"'+ parsedsentinfo[j].network.replace(/"/g,'""') + '"'; |
|
211 |
- } |
|
212 |
- |
|
213 |
- if ((parsedsentinfo[j].status.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].status)) && parsedsentinfo[j].status.indexOf('"') === -1) { |
|
214 |
- var statusproc = '"'+ parsedsentinfo[j].status + '"'; |
|
215 |
- } else if (parsedsentinfo[j].status.indexOf('"') > -1) { |
|
216 |
- var statusproc = '"'+ parsedsentinfo[j].status.replace(/"/g,'""') + '"'; |
|
217 |
- } |
|
218 |
- |
|
219 |
- oldsentRows.push(parsedsentinfo[j].id + ',' + parsedsentinfo[j].user_id + ',' + parsedsentinfo[j].message_id + ',' + parsedsentinfo[j].date + ',' + parsedsentinfo[j].from + ',' + parsedsentinfo[j].to + ',' + networkproc + ',' + parsedsentinfo[j].price + ',' + statusproc + ',' + parsedsentinfo[j].deliveryreceipt + ',' + messageproc + ',' + parsedsentinfo[j].author_displayname + '\r\n'); |
|
220 |
- } |
|
221 |
- } |
|
222 |
- |
|
223 |
- |
|
224 |
- if (oldsentRows.length == 1) { |
|
225 |
- |
|
226 |
- showAlert("No messages will be deleted since there are no messages older than " + finaloldsentint + " days."); |
|
227 |
- |
|
228 |
- // Save in a '.csv' file all the sent messages that will be deleted from the database, then delete them |
|
229 |
- } else { |
|
230 |
- |
|
231 |
- confirmAlert("Are you sure you want to delete all the sent messages older than " + finaloldsentint + " days ?"); |
|
232 |
- |
|
233 |
- $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
234 |
- |
|
235 |
- $("#confirmOk").click(function() { |
|
236 |
- |
|
237 |
- $("#alertMsgOverlay").remove(); |
|
238 |
- $("#alertConfMessage").remove(); |
|
239 |
- |
|
240 |
- var deloldsentRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldsentrows"); |
|
241 |
- |
|
242 |
- $.ajax({ |
|
243 |
- url: deloldsentRowsUrl + '/' + userid, |
|
244 |
- method: "POST", |
|
245 |
- dataType:'text', |
|
246 |
- data: { oldsentRows: oldsentRows }, |
|
247 |
- success: function(savesentcheck) { |
|
248 |
- |
|
249 |
- // Delete sent messages from the database |
|
250 |
- var delsentDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removesentrows"); |
|
251 |
- |
|
252 |
- if (savesentcheck == 1) { |
|
253 |
- |
|
254 |
- $.ajax({ |
|
255 |
- url: delsentDbSmsUrl + '/' + userid, |
|
256 |
- method: "POST", |
|
257 |
- dataType:'text', |
|
258 |
- data: { sentmessagedbIDs: sentmessagedbIDs }, |
|
259 |
- success: function() { |
|
260 |
- showAlert((oldsentRows.length - 1) + " rows have been successfully saved in the 'SMS_relentless/removed_sent_messages' directory and then deleted from the database !"); |
|
261 |
- $('#smstables').removeClass('icon-loading'); |
|
262 |
- }, |
|
263 |
- error: function() { |
|
264 |
- showAlert("There was an error while deleting the messages older than the specified period!"); |
|
265 |
- $('#smstables').removeClass('icon-loading'); |
|
266 |
- } |
|
267 |
- }); |
|
268 |
- |
|
269 |
- } else { showAlert("There was an error while saving the messages older than the specified period!"); } |
|
270 |
- |
|
271 |
- $('#smstables').removeClass('icon-loading'); |
|
272 |
- }, |
|
273 |
- error: function() { |
|
274 |
- showAlert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
275 |
- $('#smstables').removeClass('icon-loading'); |
|
276 |
- } |
|
277 |
- }); |
|
278 |
- }); |
|
279 |
- } |
|
280 |
- } |
|
281 |
- |
|
282 |
- }, |
|
283 |
- error: function() { |
|
284 |
- showAlert("An error occurred while getting data from the database!"); |
|
285 |
- $('#smstables').removeClass('icon-loading'); |
|
286 |
- } |
|
287 |
- }); |
|
288 |
- } |
|
289 |
- |
|
290 |
- }); |
|
291 |
- |
|
292 |
- function showAlert(alertText) { |
|
293 |
- |
|
294 |
- let alertwnd = "<div id='alertMessage'>"; |
|
295 |
- alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>"; |
|
296 |
- alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>"; |
|
297 |
- alertwnd += "<input type='submit' id='alertOk' value='OK'>"; |
|
298 |
- alertwnd += "</div>"; |
|
299 |
- |
|
300 |
- $("#content").append("<div id='alertMsgOverlay'></div>"); |
|
301 |
- $("#content").append(alertwnd); |
|
302 |
- |
|
303 |
- let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px"; |
|
304 |
- let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px"; |
|
305 |
- $("#alertMessage").css({ "top" : topDist, "left" : leftDist }); |
|
306 |
- |
|
307 |
- $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
308 |
- $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
309 |
- $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
310 |
- } |
|
311 |
- |
|
312 |
- function confirmAlert(alertText) { |
|
313 |
- |
|
314 |
- let alertwndcf = "<div id='alertConfMessage'>"; |
|
315 |
- alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>"; |
|
316 |
- alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>"; |
|
317 |
- alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>"; |
|
318 |
- alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>"; |
|
319 |
- alertwndcf += "</div>"; |
|
320 |
- |
|
321 |
- $("#content").append("<div id='alertMsgOverlay'></div>"); |
|
322 |
- $("#content").append(alertwndcf); |
|
323 |
- |
|
324 |
- let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px"; |
|
325 |
- let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px"; |
|
326 |
- $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist }); |
|
327 |
- |
|
328 |
- $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
329 |
- $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
330 |
- } |
|
331 |
-}); |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,331 @@ |
1 |
+/** |
|
2 |
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
3 |
+ * |
|
4 |
+ * @author Double Bastion LLC |
|
5 |
+ * |
|
6 |
+ * @license GNU AGPL version 3 or any later version |
|
7 |
+ * |
|
8 |
+ * This program is free software; you can redistribute it and/or |
|
9 |
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
10 |
+ * License as published by the Free Software Foundation; either |
|
11 |
+ * version 3 of the License, or any later version. |
|
12 |
+ * |
|
13 |
+ * This program is distributed in the hope that it will be useful, |
|
14 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
17 |
+ * |
|
18 |
+ * You should have received a copy of the GNU Affero General Public |
|
19 |
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
+ * |
|
21 |
+ */ |
|
22 |
+ |
|
23 |
+$(document).ready(function() { |
|
24 |
+ |
|
25 |
+ var userid = "<?php p($userId); ?>"; |
|
26 |
+ |
|
27 |
+ // Delete from the database all the received messages older than the specified period |
|
28 |
+ $("#delOldrecSMS").on("click", function() { |
|
29 |
+ |
|
30 |
+ var oldrecInterval = $("#oldrecSmsInterval").val(); |
|
31 |
+ var procoldrecint = oldrecInterval.replace(/[^0-9]/g, ""); |
|
32 |
+ var finaloldrecint = parseInt(procoldrecint); |
|
33 |
+ |
|
34 |
+ if (finaloldrecint == "" || !$.isNumeric(finaloldrecint)) { |
|
35 |
+ showAlert("Please enter the number of days in the box from above !"); |
|
36 |
+ } else { |
|
37 |
+ |
|
38 |
+ var getRecUrl = OC.generateUrl("/apps/sms_relentless/user/getreceivedtablefordel"); |
|
39 |
+ $('#smstables').addClass('icon-loading'); |
|
40 |
+ |
|
41 |
+ $.ajax({ |
|
42 |
+ url: getRecUrl + '/' + userid, |
|
43 |
+ method: "GET", |
|
44 |
+ dataType:'text', |
|
45 |
+ success: function(recinfoFromDB) { |
|
46 |
+ |
|
47 |
+ var parsedinfo = $.parseJSON(recinfoFromDB); |
|
48 |
+ |
|
49 |
+ if (parsedinfo == "not permitted") { |
|
50 |
+ |
|
51 |
+ showAlert("Only admins can remove old messages using this option!"); |
|
52 |
+ $('#smstables').removeClass('icon-loading'); |
|
53 |
+ return; |
|
54 |
+ |
|
55 |
+ } else { |
|
56 |
+ |
|
57 |
+ var recmessagedbIDs = []; |
|
58 |
+ var oldrecRows = []; |
|
59 |
+ oldrecRows.push("id,user_id,message_id,date,from,to,message,author_displayname,internal_sender\r\n"); |
|
60 |
+ |
|
61 |
+ var targetdate = new Date(new Date().setDate(new Date().getDate() - finaloldrecint)); |
|
62 |
+ |
|
63 |
+ for (var j = 0; j < parsedinfo.length; j++) { |
|
64 |
+ var firstdate = parsedinfo[j].date; |
|
65 |
+ var secdate = firstdate.split(" "); |
|
66 |
+ var thirddate = secdate[0].split("-"); |
|
67 |
+ var fourthdate = secdate[1].split(":"); |
|
68 |
+ var pastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
69 |
+ |
|
70 |
+ if (pastdate < targetdate) { |
|
71 |
+ recmessagedbIDs.push(parsedinfo[j].id); |
|
72 |
+ |
|
73 |
+ // Check if the message contains characters that must be escaped in the final CSV file |
|
74 |
+ if ((parsedinfo[j].message.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedinfo[j].message)) && parsedinfo[j].message.indexOf('"') === -1) { |
|
75 |
+ var messageproc = '"'+ parsedinfo[j].message + '"'; |
|
76 |
+ } else if (parsedinfo[j].message.indexOf('"') > -1) { |
|
77 |
+ var messageproc = '"'+ parsedinfo[j].message.replace(/"/g,'""') + '"'; |
|
78 |
+ } |
|
79 |
+ |
|
80 |
+ oldrecRows.push(parsedinfo[j].id + ',' + parsedinfo[j].user_id + ',' + parsedinfo[j].message_id + ',' + parsedinfo[j].date + ',' + parsedinfo[j].from + ',' + parsedinfo[j].to + ',' + messageproc + ',' + parsedinfo[j].author_displayname + ',' + parsedinfo[j].internal_sender + '\r\n'); |
|
81 |
+ } |
|
82 |
+ } |
|
83 |
+ |
|
84 |
+ |
|
85 |
+ if (oldrecRows.length == 1) { |
|
86 |
+ |
|
87 |
+ showAlert("No messages will be deleted since there are no messages older than " + finaloldrecint + " days."); |
|
88 |
+ |
|
89 |
+ // Save in a '.csv' file all the received messages that will be deleted from the database, then delete them |
|
90 |
+ } else { |
|
91 |
+ |
|
92 |
+ confirmAlert("Are you sure you want to delete all the received messages older than " + finaloldrecint + " days ?"); |
|
93 |
+ |
|
94 |
+ $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
95 |
+ |
|
96 |
+ $("#confirmOk").click(function() { |
|
97 |
+ |
|
98 |
+ $("#alertMsgOverlay").remove(); |
|
99 |
+ $("#alertConfMessage").remove(); |
|
100 |
+ |
|
101 |
+ var deloldrecRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldrecrows"); |
|
102 |
+ |
|
103 |
+ $.ajax({ |
|
104 |
+ url: deloldrecRowsUrl + '/' + userid, |
|
105 |
+ method: "POST", |
|
106 |
+ dataType:'text', |
|
107 |
+ data: { oldrecRows: oldrecRows }, |
|
108 |
+ success: function(savecheck) { |
|
109 |
+ |
|
110 |
+ // Delete received messages from the database |
|
111 |
+ var delrecDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removerecrows"); |
|
112 |
+ |
|
113 |
+ if (savecheck == 1) { |
|
114 |
+ |
|
115 |
+ $.ajax({ |
|
116 |
+ url: delrecDbSmsUrl + '/' + userid, |
|
117 |
+ method: "POST", |
|
118 |
+ dataType:'text', |
|
119 |
+ data: { recmessagedbIDs: recmessagedbIDs }, |
|
120 |
+ success: function() { |
|
121 |
+ showAlert((oldrecRows.length - 1)+" rows have been successfully saved in the 'SMS_relentless/removed_received_messages' directory and then deleted from the database !"); |
|
122 |
+ $('#smstables').removeClass('icon-loading'); |
|
123 |
+ }, |
|
124 |
+ error: function() { |
|
125 |
+ showAlert("There was an error while deleting the messages older than the specified period!"); |
|
126 |
+ $('#smstables').removeClass('icon-loading'); |
|
127 |
+ } |
|
128 |
+ }); |
|
129 |
+ |
|
130 |
+ } else { showAlert("There was an error while saving the messages older than the specified period!"); } |
|
131 |
+ |
|
132 |
+ $('#smstables').removeClass('icon-loading'); |
|
133 |
+ }, |
|
134 |
+ error: function() { |
|
135 |
+ showAlert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
136 |
+ $('#smstables').removeClass('icon-loading'); |
|
137 |
+ } |
|
138 |
+ }); |
|
139 |
+ }); |
|
140 |
+ } |
|
141 |
+ } |
|
142 |
+ }, |
|
143 |
+ error: function() { |
|
144 |
+ showAlert("An error occurred while getting data from the database!"); |
|
145 |
+ $('#smstables').removeClass('icon-loading'); |
|
146 |
+ } |
|
147 |
+ }); |
|
148 |
+ |
|
149 |
+ } |
|
150 |
+ |
|
151 |
+ }); |
|
152 |
+ |
|
153 |
+ |
|
154 |
+ // Delete from the database all the sent messages older than the specified period |
|
155 |
+ $("#delOldsentSMS").on("click", function() { |
|
156 |
+ |
|
157 |
+ var oldsentInterval = $("#oldsentSmsInterval").val(); |
|
158 |
+ var procoldsentint = oldsentInterval.replace(/[^0-9]/g, ""); |
|
159 |
+ var finaloldsentint = parseInt(procoldsentint); |
|
160 |
+ |
|
161 |
+ if (finaloldsentint == "" || !$.isNumeric(finaloldsentint)) { |
|
162 |
+ showAlert("Please enter the number of days in the box above !"); |
|
163 |
+ } else { |
|
164 |
+ |
|
165 |
+ var getSentUrl = OC.generateUrl("/apps/sms_relentless/user/getsenttablefordel"); |
|
166 |
+ $('#smstables').addClass('icon-loading'); |
|
167 |
+ |
|
168 |
+ $.ajax({ |
|
169 |
+ url: getSentUrl + '/' + userid, |
|
170 |
+ method: "GET", |
|
171 |
+ dataType:'text', |
|
172 |
+ success: function(sentinfoFromDB) { |
|
173 |
+ |
|
174 |
+ var parsedsentinfo = $.parseJSON(sentinfoFromDB); |
|
175 |
+ |
|
176 |
+ if (parsedsentinfo == "not permitted") { |
|
177 |
+ |
|
178 |
+ showAlert("Only admins can remove old messages using this option!"); |
|
179 |
+ $('#smstables').removeClass('icon-loading'); |
|
180 |
+ return; |
|
181 |
+ |
|
182 |
+ } else { |
|
183 |
+ |
|
184 |
+ var sentmessagedbIDs = []; |
|
185 |
+ var oldsentRows = []; |
|
186 |
+ oldsentRows.push("id,user_id,message_id,date,from,to,network,price,status,deliveryreceipt,message,author_displayname\r\n"); |
|
187 |
+ |
|
188 |
+ var senttargetdate = new Date(new Date().setDate(new Date().getDate() - finaloldsentint)); |
|
189 |
+ |
|
190 |
+ for (var j = 0; j < parsedsentinfo.length; j++) { |
|
191 |
+ var firstdate = parsedsentinfo[j].date; |
|
192 |
+ var secdate = firstdate.split(" "); |
|
193 |
+ var thirddate = secdate[0].split("-"); |
|
194 |
+ var fourthdate = secdate[1].split(":"); |
|
195 |
+ var sentpastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
196 |
+ |
|
197 |
+ if (sentpastdate < senttargetdate) { |
|
198 |
+ sentmessagedbIDs.push(parsedsentinfo[j].id); |
|
199 |
+ |
|
200 |
+ // Check if the message contains characters that must be escaped in the final CSV file |
|
201 |
+ if ((parsedsentinfo[j].message.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].message)) && parsedsentinfo[j].message.indexOf('"') === -1) { |
|
202 |
+ var messageproc = '"'+ parsedsentinfo[j].message + '"'; |
|
203 |
+ } else if (parsedsentinfo[j].message.indexOf('"') > -1) { |
|
204 |
+ var messageproc = '"'+ parsedsentinfo[j].message.replace(/"/g,'""') + '"'; |
|
205 |
+ } |
|
206 |
+ |
|
207 |
+ if ((parsedsentinfo[j].network.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].network)) && parsedsentinfo[j].network.indexOf('"') === -1) { |
|
208 |
+ var networkproc = '"'+ parsedsentinfo[j].network + '"'; |
|
209 |
+ } else if (parsedsentinfo[j].network.indexOf('"') > -1) { |
|
210 |
+ var networkproc = '"'+ parsedsentinfo[j].network.replace(/"/g,'""') + '"'; |
|
211 |
+ } |
|
212 |
+ |
|
213 |
+ if ((parsedsentinfo[j].status.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].status)) && parsedsentinfo[j].status.indexOf('"') === -1) { |
|
214 |
+ var statusproc = '"'+ parsedsentinfo[j].status + '"'; |
|
215 |
+ } else if (parsedsentinfo[j].status.indexOf('"') > -1) { |
|
216 |
+ var statusproc = '"'+ parsedsentinfo[j].status.replace(/"/g,'""') + '"'; |
|
217 |
+ } |
|
218 |
+ |
|
219 |
+ oldsentRows.push(parsedsentinfo[j].id + ',' + parsedsentinfo[j].user_id + ',' + parsedsentinfo[j].message_id + ',' + parsedsentinfo[j].date + ',' + parsedsentinfo[j].from + ',' + parsedsentinfo[j].to + ',' + networkproc + ',' + parsedsentinfo[j].price + ',' + statusproc + ',' + parsedsentinfo[j].deliveryreceipt + ',' + messageproc + ',' + parsedsentinfo[j].author_displayname + '\r\n'); |
|
220 |
+ } |
|
221 |
+ } |
|
222 |
+ |
|
223 |
+ |
|
224 |
+ if (oldsentRows.length == 1) { |
|
225 |
+ |
|
226 |
+ showAlert("No messages will be deleted since there are no messages older than " + finaloldsentint + " days."); |
|
227 |
+ |
|
228 |
+ // Save in a '.csv' file all the sent messages that will be deleted from the database, then delete them |
|
229 |
+ } else { |
|
230 |
+ |
|
231 |
+ confirmAlert("Are you sure you want to delete all the sent messages older than " + finaloldsentint + " days ?"); |
|
232 |
+ |
|
233 |
+ $("#confirmCancel").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
234 |
+ |
|
235 |
+ $("#confirmOk").click(function() { |
|
236 |
+ |
|
237 |
+ $("#alertMsgOverlay").remove(); |
|
238 |
+ $("#alertConfMessage").remove(); |
|
239 |
+ |
|
240 |
+ var deloldsentRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldsentrows"); |
|
241 |
+ |
|
242 |
+ $.ajax({ |
|
243 |
+ url: deloldsentRowsUrl + '/' + userid, |
|
244 |
+ method: "POST", |
|
245 |
+ dataType:'text', |
|
246 |
+ data: { oldsentRows: oldsentRows }, |
|
247 |
+ success: function(savesentcheck) { |
|
248 |
+ |
|
249 |
+ // Delete sent messages from the database |
|
250 |
+ var delsentDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removesentrows"); |
|
251 |
+ |
|
252 |
+ if (savesentcheck == 1) { |
|
253 |
+ |
|
254 |
+ $.ajax({ |
|
255 |
+ url: delsentDbSmsUrl + '/' + userid, |
|
256 |
+ method: "POST", |
|
257 |
+ dataType:'text', |
|
258 |
+ data: { sentmessagedbIDs: sentmessagedbIDs }, |
|
259 |
+ success: function() { |
|
260 |
+ showAlert((oldsentRows.length - 1) + " rows have been successfully saved in the 'SMS_relentless/removed_sent_messages' directory and then deleted from the database !"); |
|
261 |
+ $('#smstables').removeClass('icon-loading'); |
|
262 |
+ }, |
|
263 |
+ error: function() { |
|
264 |
+ showAlert("There was an error while deleting the messages older than the specified period!"); |
|
265 |
+ $('#smstables').removeClass('icon-loading'); |
|
266 |
+ } |
|
267 |
+ }); |
|
268 |
+ |
|
269 |
+ } else { showAlert("There was an error while saving the messages older than the specified period!"); } |
|
270 |
+ |
|
271 |
+ $('#smstables').removeClass('icon-loading'); |
|
272 |
+ }, |
|
273 |
+ error: function() { |
|
274 |
+ showAlert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
275 |
+ $('#smstables').removeClass('icon-loading'); |
|
276 |
+ } |
|
277 |
+ }); |
|
278 |
+ }); |
|
279 |
+ } |
|
280 |
+ } |
|
281 |
+ |
|
282 |
+ }, |
|
283 |
+ error: function() { |
|
284 |
+ showAlert("An error occurred while getting data from the database!"); |
|
285 |
+ $('#smstables').removeClass('icon-loading'); |
|
286 |
+ } |
|
287 |
+ }); |
|
288 |
+ } |
|
289 |
+ |
|
290 |
+ }); |
|
291 |
+ |
|
292 |
+ function showAlert(alertText) { |
|
293 |
+ |
|
294 |
+ let alertwnd = "<div id='alertMessage'>"; |
|
295 |
+ alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>"; |
|
296 |
+ alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>"; |
|
297 |
+ alertwnd += "<input type='submit' id='alertOk' value='OK'>"; |
|
298 |
+ alertwnd += "</div>"; |
|
299 |
+ |
|
300 |
+ $("#content").append("<div id='alertMsgOverlay'></div>"); |
|
301 |
+ $("#content").append(alertwnd); |
|
302 |
+ |
|
303 |
+ let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px"; |
|
304 |
+ let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px"; |
|
305 |
+ $("#alertMessage").css({ "top" : topDist, "left" : leftDist }); |
|
306 |
+ |
|
307 |
+ $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
308 |
+ $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
309 |
+ $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
310 |
+ } |
|
311 |
+ |
|
312 |
+ function confirmAlert(alertText) { |
|
313 |
+ |
|
314 |
+ let alertwndcf = "<div id='alertConfMessage'>"; |
|
315 |
+ alertwndcf += "<a id='closeAlertWndcf' title='Close this window'></a>"; |
|
316 |
+ alertwndcf += "<div id='alertTextWrap'>"+ alertText +"</div>"; |
|
317 |
+ alertwndcf += "<div id='cancelOkWrap'><input type='submit' id='confirmCancel' value='Cancel'>"; |
|
318 |
+ alertwndcf += "<input type='submit' id='confirmOk' value='OK'></div>"; |
|
319 |
+ alertwndcf += "</div>"; |
|
320 |
+ |
|
321 |
+ $("#content").append("<div id='alertMsgOverlay'></div>"); |
|
322 |
+ $("#content").append(alertwndcf); |
|
323 |
+ |
|
324 |
+ let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px"; |
|
325 |
+ let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px"; |
|
326 |
+ $("#alertConfMessage").css({ "top" : topDist, "left" : leftDist }); |
|
327 |
+ |
|
328 |
+ $("#closeAlertWndcf").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
329 |
+ $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertConfMessage").remove(); }); |
|
330 |
+ } |
|
331 |
+}); |
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,298 +0,0 @@ |
1 |
-/** |
|
2 |
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
3 |
- * |
|
4 |
- * @author Double Bastion LLC |
|
5 |
- * |
|
6 |
- * @license GNU AGPL version 3 or any later version |
|
7 |
- * |
|
8 |
- * This program is free software; you can redistribute it and/or |
|
9 |
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
10 |
- * License as published by the Free Software Foundation; either |
|
11 |
- * version 3 of the License, or any later version. |
|
12 |
- * |
|
13 |
- * This program is distributed in the hope that it will be useful, |
|
14 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
17 |
- * |
|
18 |
- * You should have received a copy of the GNU Affero General Public |
|
19 |
- * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
- * |
|
21 |
- */ |
|
22 |
- |
|
23 |
-$(document).ready(function() { |
|
24 |
- |
|
25 |
- var userid = "<?php p($userId); ?>"; |
|
26 |
- |
|
27 |
- // Delete from the database all the received messages older than the specified period |
|
28 |
- $("#delOldrecSMS").on("click", function() { |
|
29 |
- |
|
30 |
- var oldrecInterval = $("#oldrecSmsInterval").val(); |
|
31 |
- var procoldrecint = oldrecInterval.replace(/[^0-9]/g, ""); |
|
32 |
- var finaloldrecint = parseInt(procoldrecint); |
|
33 |
- |
|
34 |
- if (finaloldrecint == "" || !$.isNumeric(finaloldrecint)) { |
|
35 |
- showAlert("Please enter the number of days in the box from above !"); |
|
36 |
- } else { |
|
37 |
- |
|
38 |
- var getRecUrl = OC.generateUrl("/apps/sms_relentless/user/getreceivedtablefordel"); |
|
39 |
- $('#smstables').addClass('icon-loading'); |
|
40 |
- |
|
41 |
- $.ajax({ |
|
42 |
- url: getRecUrl + '/' + userid, |
|
43 |
- method: "GET", |
|
44 |
- dataType:'text', |
|
45 |
- success: function(recinfoFromDB) { |
|
46 |
- |
|
47 |
- var parsedinfo = $.parseJSON(recinfoFromDB); |
|
48 |
- |
|
49 |
- if (parsedinfo == "not permitted") { |
|
50 |
- |
|
51 |
- showAlert("Only admins can remove old messages using this option!"); |
|
52 |
- $('#smstables').removeClass('icon-loading'); |
|
53 |
- return; |
|
54 |
- |
|
55 |
- } else { |
|
56 |
- |
|
57 |
- var recmessagedbIDs = []; |
|
58 |
- var oldrecRows = []; |
|
59 |
- oldrecRows.push("id,user_id,message_id,date,from,to,message,author_displayname,internal_sender\r\n"); |
|
60 |
- |
|
61 |
- var targetdate = new Date(new Date().setDate(new Date().getDate() - finaloldrecint)); |
|
62 |
- |
|
63 |
- for (var j = 0; j < parsedinfo.length; j++) { |
|
64 |
- var firstdate = parsedinfo[j].date; |
|
65 |
- var secdate = firstdate.split(" "); |
|
66 |
- var thirddate = secdate[0].split("-"); |
|
67 |
- var fourthdate = secdate[1].split(":"); |
|
68 |
- var pastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
69 |
- |
|
70 |
- if (pastdate < targetdate) { |
|
71 |
- recmessagedbIDs.push(parsedinfo[j].id); |
|
72 |
- |
|
73 |
- // Check if the message contains characters that must be escaped in the final CSV file |
|
74 |
- if ((parsedinfo[j].message.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedinfo[j].message)) && parsedinfo[j].message.indexOf('"') === -1) { |
|
75 |
- var messageproc = '"'+ parsedinfo[j].message + '"'; |
|
76 |
- } else if (parsedinfo[j].message.indexOf('"') > -1) { |
|
77 |
- var messageproc = '"'+ parsedinfo[j].message.replace(/"/g,'""') + '"'; |
|
78 |
- } |
|
79 |
- |
|
80 |
- oldrecRows.push(parsedinfo[j].id + ',' + parsedinfo[j].user_id + ',' + parsedinfo[j].message_id + ',' + parsedinfo[j].date + ',' + parsedinfo[j].from + ',' + parsedinfo[j].to + ',' + messageproc + ',' + parsedinfo[j].author_displayname + ',' + parsedinfo[j].internal_sender + '\r\n'); |
|
81 |
- } |
|
82 |
- } |
|
83 |
- |
|
84 |
- |
|
85 |
- if (oldrecRows.length == 1) { |
|
86 |
- |
|
87 |
- showAlert("No messages will be deleted since there are no messages older than " + finaloldrecint + " days."); |
|
88 |
- |
|
89 |
- // Save in a '.csv' file all the received messages that will be deleted from the database, then delete them |
|
90 |
- } else { |
|
91 |
- |
|
92 |
- if (confirm("Are you sure you want to delete all the received messages older than " + finaloldrecint + " days ?")) { |
|
93 |
- |
|
94 |
- var deloldrecRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldrecrows"); |
|
95 |
- |
|
96 |
- $.ajax({ |
|
97 |
- url: deloldrecRowsUrl + '/' + userid, |
|
98 |
- method: "POST", |
|
99 |
- dataType:'text', |
|
100 |
- data: { oldrecRows: oldrecRows }, |
|
101 |
- success: function(savecheck) { |
|
102 |
- |
|
103 |
- // Delete received messages from the database |
|
104 |
- var delrecDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removerecrows"); |
|
105 |
- |
|
106 |
- if (savecheck == 1) { |
|
107 |
- |
|
108 |
- $.ajax({ |
|
109 |
- url: delrecDbSmsUrl + '/' + userid, |
|
110 |
- method: "POST", |
|
111 |
- dataType:'text', |
|
112 |
- data: { recmessagedbIDs: recmessagedbIDs }, |
|
113 |
- success: function() { |
|
114 |
- showAlert((oldrecRows.length - 1)+" rows have been successfully saved in the 'SMS_relentless/removed_received_messages' directory and then deleted from the database !"); |
|
115 |
- $('#smstables').removeClass('icon-loading'); |
|
116 |
- }, |
|
117 |
- error: function() { |
|
118 |
- showAlert("There was an error while deleting the messages older than the specified period!"); |
|
119 |
- $('#smstables').removeClass('icon-loading'); |
|
120 |
- } |
|
121 |
- }); |
|
122 |
- |
|
123 |
- } else { showAlert("There was an error while saving the messages older than the specified period!"); } |
|
124 |
- |
|
125 |
- $('#smstables').removeClass('icon-loading'); |
|
126 |
- }, |
|
127 |
- error: function() { |
|
128 |
- showAlert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
129 |
- $('#smstables').removeClass('icon-loading'); |
|
130 |
- } |
|
131 |
- }); |
|
132 |
- } |
|
133 |
- } |
|
134 |
- } |
|
135 |
- }, |
|
136 |
- error: function() { |
|
137 |
- showAlert("An error occurred while getting data from the database!"); |
|
138 |
- $('#smstables').removeClass('icon-loading'); |
|
139 |
- } |
|
140 |
- }); |
|
141 |
- |
|
142 |
- } |
|
143 |
- |
|
144 |
- }); |
|
145 |
- |
|
146 |
- |
|
147 |
- // Delete from the database all the sent messages older than the specified period |
|
148 |
- $("#delOldsentSMS").on("click", function() { |
|
149 |
- |
|
150 |
- var oldsentInterval = $("#oldsentSmsInterval").val(); |
|
151 |
- var procoldsentint = oldsentInterval.replace(/[^0-9]/g, ""); |
|
152 |
- var finaloldsentint = parseInt(procoldsentint); |
|
153 |
- |
|
154 |
- if (finaloldsentint == "" || !$.isNumeric(finaloldsentint)) { |
|
155 |
- showAlert("Please enter the number of days in the box above !"); |
|
156 |
- } else { |
|
157 |
- |
|
158 |
- var getSentUrl = OC.generateUrl("/apps/sms_relentless/user/getsenttablefordel"); |
|
159 |
- $('#smstables').addClass('icon-loading'); |
|
160 |
- |
|
161 |
- $.ajax({ |
|
162 |
- url: getSentUrl + '/' + userid, |
|
163 |
- method: "GET", |
|
164 |
- dataType:'text', |
|
165 |
- success: function(sentinfoFromDB) { |
|
166 |
- |
|
167 |
- var parsedsentinfo = $.parseJSON(sentinfoFromDB); |
|
168 |
- |
|
169 |
- if (parsedsentinfo == "not permitted") { |
|
170 |
- |
|
171 |
- showAlert("Only admins can remove old messages using this option!"); |
|
172 |
- $('#smstables').removeClass('icon-loading'); |
|
173 |
- return; |
|
174 |
- |
|
175 |
- } else { |
|
176 |
- |
|
177 |
- var sentmessagedbIDs = []; |
|
178 |
- var oldsentRows = []; |
|
179 |
- oldsentRows.push("id,user_id,message_id,date,from,to,network,price,status,deliveryreceipt,message,author_displayname\r\n"); |
|
180 |
- |
|
181 |
- var senttargetdate = new Date(new Date().setDate(new Date().getDate() - finaloldsentint)); |
|
182 |
- |
|
183 |
- for (var j = 0; j < parsedsentinfo.length; j++) { |
|
184 |
- var firstdate = parsedsentinfo[j].date; |
|
185 |
- var secdate = firstdate.split(" "); |
|
186 |
- var thirddate = secdate[0].split("-"); |
|
187 |
- var fourthdate = secdate[1].split(":"); |
|
188 |
- var sentpastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
189 |
- |
|
190 |
- if (sentpastdate < senttargetdate) { |
|
191 |
- sentmessagedbIDs.push(parsedsentinfo[j].id); |
|
192 |
- |
|
193 |
- // Check if the message contains characters that must be escaped in the final CSV file |
|
194 |
- if ((parsedsentinfo[j].message.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].message)) && parsedsentinfo[j].message.indexOf('"') === -1) { |
|
195 |
- var messageproc = '"'+ parsedsentinfo[j].message + '"'; |
|
196 |
- } else if (parsedsentinfo[j].message.indexOf('"') > -1) { |
|
197 |
- var messageproc = '"'+ parsedsentinfo[j].message.replace(/"/g,'""') + '"'; |
|
198 |
- } |
|
199 |
- |
|
200 |
- if ((parsedsentinfo[j].network.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].network)) && parsedsentinfo[j].network.indexOf('"') === -1) { |
|
201 |
- var networkproc = '"'+ parsedsentinfo[j].network + '"'; |
|
202 |
- } else if (parsedsentinfo[j].network.indexOf('"') > -1) { |
|
203 |
- var networkproc = '"'+ parsedsentinfo[j].network.replace(/"/g,'""') + '"'; |
|
204 |
- } |
|
205 |
- |
|
206 |
- if ((parsedsentinfo[j].status.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].status)) && parsedsentinfo[j].status.indexOf('"') === -1) { |
|
207 |
- var statusproc = '"'+ parsedsentinfo[j].status + '"'; |
|
208 |
- } else if (parsedsentinfo[j].status.indexOf('"') > -1) { |
|
209 |
- var statusproc = '"'+ parsedsentinfo[j].status.replace(/"/g,'""') + '"'; |
|
210 |
- } |
|
211 |
- |
|
212 |
- oldsentRows.push(parsedsentinfo[j].id + ',' + parsedsentinfo[j].user_id + ',' + parsedsentinfo[j].message_id + ',' + parsedsentinfo[j].date + ',' + parsedsentinfo[j].from + ',' + parsedsentinfo[j].to + ',' + networkproc + ',' + parsedsentinfo[j].price + ',' + statusproc + ',' + parsedsentinfo[j].deliveryreceipt + ',' + messageproc + ',' + parsedsentinfo[j].author_displayname + '\r\n'); |
|
213 |
- } |
|
214 |
- } |
|
215 |
- |
|
216 |
- |
|
217 |
- if (oldsentRows.length == 1) { |
|
218 |
- |
|
219 |
- showAlert("No messages will be deleted since there are no messages older than " + finaloldsentint + " days."); |
|
220 |
- |
|
221 |
- // Save in a '.csv' file all the sent messages that will be deleted from the database, then delete them |
|
222 |
- } else { |
|
223 |
- |
|
224 |
- if (confirm("Are you sure you want to delete all the sent messages older than " + finaloldsentint + " days ?")) { |
|
225 |
- |
|
226 |
- var deloldsentRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldsentrows"); |
|
227 |
- |
|
228 |
- $.ajax({ |
|
229 |
- url: deloldsentRowsUrl + '/' + userid, |
|
230 |
- method: "POST", |
|
231 |
- dataType:'text', |
|
232 |
- data: { oldsentRows: oldsentRows }, |
|
233 |
- success: function(savesentcheck) { |
|
234 |
- |
|
235 |
- // Delete sent messages from the database |
|
236 |
- var delsentDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removesentrows"); |
|
237 |
- |
|
238 |
- if (savesentcheck == 1) { |
|
239 |
- |
|
240 |
- $.ajax({ |
|
241 |
- url: delsentDbSmsUrl + '/' + userid, |
|
242 |
- method: "POST", |
|
243 |
- dataType:'text', |
|
244 |
- data: { sentmessagedbIDs: sentmessagedbIDs }, |
|
245 |
- success: function() { |
|
246 |
- showAlert((oldsentRows.length - 1) + " rows have been successfully saved in the 'SMS_relentless/removed_sent_messages' directory and then deleted from the database !"); |
|
247 |
- $('#smstables').removeClass('icon-loading'); |
|
248 |
- }, |
|
249 |
- error: function() { |
|
250 |
- showAlert("There was an error while deleting the messages older than the specified period!"); |
|
251 |
- $('#smstables').removeClass('icon-loading'); |
|
252 |
- } |
|
253 |
- }); |
|
254 |
- |
|
255 |
- } else { showAlert("There was an error while saving the messages older than the specified period!"); } |
|
256 |
- |
|
257 |
- $('#smstables').removeClass('icon-loading'); |
|
258 |
- }, |
|
259 |
- error: function() { |
|
260 |
- showAlert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
261 |
- $('#smstables').removeClass('icon-loading'); |
|
262 |
- } |
|
263 |
- }); |
|
264 |
- } |
|
265 |
- } |
|
266 |
- } |
|
267 |
- |
|
268 |
- }, |
|
269 |
- error: function() { |
|
270 |
- showAlert("An error occurred while getting data from the database!"); |
|
271 |
- $('#smstables').removeClass('icon-loading'); |
|
272 |
- } |
|
273 |
- }); |
|
274 |
- } |
|
275 |
- |
|
276 |
- }); |
|
277 |
- |
|
278 |
- function showAlert(alertText) { |
|
279 |
- |
|
280 |
- let alertwnd = "<div id='alertMessage'>"; |
|
281 |
- alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>"; |
|
282 |
- alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>"; |
|
283 |
- alertwnd += "<input type='submit' id='alertOk' value='OK'>"; |
|
284 |
- alertwnd += "</div>"; |
|
285 |
- |
|
286 |
- $("#content").append("<div id='alertMsgOverlay'></div>"); |
|
287 |
- $("#content").append(alertwnd); |
|
288 |
- |
|
289 |
- let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px"; |
|
290 |
- let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px"; |
|
291 |
- $("#alertMessage").css({ "top" : topDist, "left" : leftDist }); |
|
292 |
- |
|
293 |
- $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
294 |
- $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
295 |
- $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
296 |
- } |
|
297 |
- |
|
298 |
-}); |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,298 @@ |
1 |
+/** |
|
2 |
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
3 |
+ * |
|
4 |
+ * @author Double Bastion LLC |
|
5 |
+ * |
|
6 |
+ * @license GNU AGPL version 3 or any later version |
|
7 |
+ * |
|
8 |
+ * This program is free software; you can redistribute it and/or |
|
9 |
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
10 |
+ * License as published by the Free Software Foundation; either |
|
11 |
+ * version 3 of the License, or any later version. |
|
12 |
+ * |
|
13 |
+ * This program is distributed in the hope that it will be useful, |
|
14 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
17 |
+ * |
|
18 |
+ * You should have received a copy of the GNU Affero General Public |
|
19 |
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
+ * |
|
21 |
+ */ |
|
22 |
+ |
|
23 |
+$(document).ready(function() { |
|
24 |
+ |
|
25 |
+ var userid = "<?php p($userId); ?>"; |
|
26 |
+ |
|
27 |
+ // Delete from the database all the received messages older than the specified period |
|
28 |
+ $("#delOldrecSMS").on("click", function() { |
|
29 |
+ |
|
30 |
+ var oldrecInterval = $("#oldrecSmsInterval").val(); |
|
31 |
+ var procoldrecint = oldrecInterval.replace(/[^0-9]/g, ""); |
|
32 |
+ var finaloldrecint = parseInt(procoldrecint); |
|
33 |
+ |
|
34 |
+ if (finaloldrecint == "" || !$.isNumeric(finaloldrecint)) { |
|
35 |
+ showAlert("Please enter the number of days in the box from above !"); |
|
36 |
+ } else { |
|
37 |
+ |
|
38 |
+ var getRecUrl = OC.generateUrl("/apps/sms_relentless/user/getreceivedtablefordel"); |
|
39 |
+ $('#smstables').addClass('icon-loading'); |
|
40 |
+ |
|
41 |
+ $.ajax({ |
|
42 |
+ url: getRecUrl + '/' + userid, |
|
43 |
+ method: "GET", |
|
44 |
+ dataType:'text', |
|
45 |
+ success: function(recinfoFromDB) { |
|
46 |
+ |
|
47 |
+ var parsedinfo = $.parseJSON(recinfoFromDB); |
|
48 |
+ |
|
49 |
+ if (parsedinfo == "not permitted") { |
|
50 |
+ |
|
51 |
+ showAlert("Only admins can remove old messages using this option!"); |
|
52 |
+ $('#smstables').removeClass('icon-loading'); |
|
53 |
+ return; |
|
54 |
+ |
|
55 |
+ } else { |
|
56 |
+ |
|
57 |
+ var recmessagedbIDs = []; |
|
58 |
+ var oldrecRows = []; |
|
59 |
+ oldrecRows.push("id,user_id,message_id,date,from,to,message,author_displayname,internal_sender\r\n"); |
|
60 |
+ |
|
61 |
+ var targetdate = new Date(new Date().setDate(new Date().getDate() - finaloldrecint)); |
|
62 |
+ |
|
63 |
+ for (var j = 0; j < parsedinfo.length; j++) { |
|
64 |
+ var firstdate = parsedinfo[j].date; |
|
65 |
+ var secdate = firstdate.split(" "); |
|
66 |
+ var thirddate = secdate[0].split("-"); |
|
67 |
+ var fourthdate = secdate[1].split(":"); |
|
68 |
+ var pastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
69 |
+ |
|
70 |
+ if (pastdate < targetdate) { |
|
71 |
+ recmessagedbIDs.push(parsedinfo[j].id); |
|
72 |
+ |
|
73 |
+ // Check if the message contains characters that must be escaped in the final CSV file |
|
74 |
+ if ((parsedinfo[j].message.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedinfo[j].message)) && parsedinfo[j].message.indexOf('"') === -1) { |
|
75 |
+ var messageproc = '"'+ parsedinfo[j].message + '"'; |
|
76 |
+ } else if (parsedinfo[j].message.indexOf('"') > -1) { |
|
77 |
+ var messageproc = '"'+ parsedinfo[j].message.replace(/"/g,'""') + '"'; |
|
78 |
+ } |
|
79 |
+ |
|
80 |
+ oldrecRows.push(parsedinfo[j].id + ',' + parsedinfo[j].user_id + ',' + parsedinfo[j].message_id + ',' + parsedinfo[j].date + ',' + parsedinfo[j].from + ',' + parsedinfo[j].to + ',' + messageproc + ',' + parsedinfo[j].author_displayname + ',' + parsedinfo[j].internal_sender + '\r\n'); |
|
81 |
+ } |
|
82 |
+ } |
|
83 |
+ |
|
84 |
+ |
|
85 |
+ if (oldrecRows.length == 1) { |
|
86 |
+ |
|
87 |
+ showAlert("No messages will be deleted since there are no messages older than " + finaloldrecint + " days."); |
|
88 |
+ |
|
89 |
+ // Save in a '.csv' file all the received messages that will be deleted from the database, then delete them |
|
90 |
+ } else { |
|
91 |
+ |
|
92 |
+ if (confirm("Are you sure you want to delete all the received messages older than " + finaloldrecint + " days ?")) { |
|
93 |
+ |
|
94 |
+ var deloldrecRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldrecrows"); |
|
95 |
+ |
|
96 |
+ $.ajax({ |
|
97 |
+ url: deloldrecRowsUrl + '/' + userid, |
|
98 |
+ method: "POST", |
|
99 |
+ dataType:'text', |
|
100 |
+ data: { oldrecRows: oldrecRows }, |
|
101 |
+ success: function(savecheck) { |
|
102 |
+ |
|
103 |
+ // Delete received messages from the database |
|
104 |
+ var delrecDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removerecrows"); |
|
105 |
+ |
|
106 |
+ if (savecheck == 1) { |
|
107 |
+ |
|
108 |
+ $.ajax({ |
|
109 |
+ url: delrecDbSmsUrl + '/' + userid, |
|
110 |
+ method: "POST", |
|
111 |
+ dataType:'text', |
|
112 |
+ data: { recmessagedbIDs: recmessagedbIDs }, |
|
113 |
+ success: function() { |
|
114 |
+ showAlert((oldrecRows.length - 1)+" rows have been successfully saved in the 'SMS_relentless/removed_received_messages' directory and then deleted from the database !"); |
|
115 |
+ $('#smstables').removeClass('icon-loading'); |
|
116 |
+ }, |
|
117 |
+ error: function() { |
|
118 |
+ showAlert("There was an error while deleting the messages older than the specified period!"); |
|
119 |
+ $('#smstables').removeClass('icon-loading'); |
|
120 |
+ } |
|
121 |
+ }); |
|
122 |
+ |
|
123 |
+ } else { showAlert("There was an error while saving the messages older than the specified period!"); } |
|
124 |
+ |
|
125 |
+ $('#smstables').removeClass('icon-loading'); |
|
126 |
+ }, |
|
127 |
+ error: function() { |
|
128 |
+ showAlert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
129 |
+ $('#smstables').removeClass('icon-loading'); |
|
130 |
+ } |
|
131 |
+ }); |
|
132 |
+ } |
|
133 |
+ } |
|
134 |
+ } |
|
135 |
+ }, |
|
136 |
+ error: function() { |
|
137 |
+ showAlert("An error occurred while getting data from the database!"); |
|
138 |
+ $('#smstables').removeClass('icon-loading'); |
|
139 |
+ } |
|
140 |
+ }); |
|
141 |
+ |
|
142 |
+ } |
|
143 |
+ |
|
144 |
+ }); |
|
145 |
+ |
|
146 |
+ |
|
147 |
+ // Delete from the database all the sent messages older than the specified period |
|
148 |
+ $("#delOldsentSMS").on("click", function() { |
|
149 |
+ |
|
150 |
+ var oldsentInterval = $("#oldsentSmsInterval").val(); |
|
151 |
+ var procoldsentint = oldsentInterval.replace(/[^0-9]/g, ""); |
|
152 |
+ var finaloldsentint = parseInt(procoldsentint); |
|
153 |
+ |
|
154 |
+ if (finaloldsentint == "" || !$.isNumeric(finaloldsentint)) { |
|
155 |
+ showAlert("Please enter the number of days in the box above !"); |
|
156 |
+ } else { |
|
157 |
+ |
|
158 |
+ var getSentUrl = OC.generateUrl("/apps/sms_relentless/user/getsenttablefordel"); |
|
159 |
+ $('#smstables').addClass('icon-loading'); |
|
160 |
+ |
|
161 |
+ $.ajax({ |
|
162 |
+ url: getSentUrl + '/' + userid, |
|
163 |
+ method: "GET", |
|
164 |
+ dataType:'text', |
|
165 |
+ success: function(sentinfoFromDB) { |
|
166 |
+ |
|
167 |
+ var parsedsentinfo = $.parseJSON(sentinfoFromDB); |
|
168 |
+ |
|
169 |
+ if (parsedsentinfo == "not permitted") { |
|
170 |
+ |
|
171 |
+ showAlert("Only admins can remove old messages using this option!"); |
|
172 |
+ $('#smstables').removeClass('icon-loading'); |
|
173 |
+ return; |
|
174 |
+ |
|
175 |
+ } else { |
|
176 |
+ |
|
177 |
+ var sentmessagedbIDs = []; |
|
178 |
+ var oldsentRows = []; |
|
179 |
+ oldsentRows.push("id,user_id,message_id,date,from,to,network,price,status,deliveryreceipt,message,author_displayname\r\n"); |
|
180 |
+ |
|
181 |
+ var senttargetdate = new Date(new Date().setDate(new Date().getDate() - finaloldsentint)); |
|
182 |
+ |
|
183 |
+ for (var j = 0; j < parsedsentinfo.length; j++) { |
|
184 |
+ var firstdate = parsedsentinfo[j].date; |
|
185 |
+ var secdate = firstdate.split(" "); |
|
186 |
+ var thirddate = secdate[0].split("-"); |
|
187 |
+ var fourthdate = secdate[1].split(":"); |
|
188 |
+ var sentpastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
189 |
+ |
|
190 |
+ if (sentpastdate < senttargetdate) { |
|
191 |
+ sentmessagedbIDs.push(parsedsentinfo[j].id); |
|
192 |
+ |
|
193 |
+ // Check if the message contains characters that must be escaped in the final CSV file |
|
194 |
+ if ((parsedsentinfo[j].message.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].message)) && parsedsentinfo[j].message.indexOf('"') === -1) { |
|
195 |
+ var messageproc = '"'+ parsedsentinfo[j].message + '"'; |
|
196 |
+ } else if (parsedsentinfo[j].message.indexOf('"') > -1) { |
|
197 |
+ var messageproc = '"'+ parsedsentinfo[j].message.replace(/"/g,'""') + '"'; |
|
198 |
+ } |
|
199 |
+ |
|
200 |
+ if ((parsedsentinfo[j].network.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].network)) && parsedsentinfo[j].network.indexOf('"') === -1) { |
|
201 |
+ var networkproc = '"'+ parsedsentinfo[j].network + '"'; |
|
202 |
+ } else if (parsedsentinfo[j].network.indexOf('"') > -1) { |
|
203 |
+ var networkproc = '"'+ parsedsentinfo[j].network.replace(/"/g,'""') + '"'; |
|
204 |
+ } |
|
205 |
+ |
|
206 |
+ if ((parsedsentinfo[j].status.indexOf(',') > -1 || /\r|\n|\r\n/.exec(parsedsentinfo[j].status)) && parsedsentinfo[j].status.indexOf('"') === -1) { |
|
207 |
+ var statusproc = '"'+ parsedsentinfo[j].status + '"'; |
|
208 |
+ } else if (parsedsentinfo[j].status.indexOf('"') > -1) { |
|
209 |
+ var statusproc = '"'+ parsedsentinfo[j].status.replace(/"/g,'""') + '"'; |
|
210 |
+ } |
|
211 |
+ |
|
212 |
+ oldsentRows.push(parsedsentinfo[j].id + ',' + parsedsentinfo[j].user_id + ',' + parsedsentinfo[j].message_id + ',' + parsedsentinfo[j].date + ',' + parsedsentinfo[j].from + ',' + parsedsentinfo[j].to + ',' + networkproc + ',' + parsedsentinfo[j].price + ',' + statusproc + ',' + parsedsentinfo[j].deliveryreceipt + ',' + messageproc + ',' + parsedsentinfo[j].author_displayname + '\r\n'); |
|
213 |
+ } |
|
214 |
+ } |
|
215 |
+ |
|
216 |
+ |
|
217 |
+ if (oldsentRows.length == 1) { |
|
218 |
+ |
|
219 |
+ showAlert("No messages will be deleted since there are no messages older than " + finaloldsentint + " days."); |
|
220 |
+ |
|
221 |
+ // Save in a '.csv' file all the sent messages that will be deleted from the database, then delete them |
|
222 |
+ } else { |
|
223 |
+ |
|
224 |
+ if (confirm("Are you sure you want to delete all the sent messages older than " + finaloldsentint + " days ?")) { |
|
225 |
+ |
|
226 |
+ var deloldsentRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldsentrows"); |
|
227 |
+ |
|
228 |
+ $.ajax({ |
|
229 |
+ url: deloldsentRowsUrl + '/' + userid, |
|
230 |
+ method: "POST", |
|
231 |
+ dataType:'text', |
|
232 |
+ data: { oldsentRows: oldsentRows }, |
|
233 |
+ success: function(savesentcheck) { |
|
234 |
+ |
|
235 |
+ // Delete sent messages from the database |
|
236 |
+ var delsentDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removesentrows"); |
|
237 |
+ |
|
238 |
+ if (savesentcheck == 1) { |
|
239 |
+ |
|
240 |
+ $.ajax({ |
|
241 |
+ url: delsentDbSmsUrl + '/' + userid, |
|
242 |
+ method: "POST", |
|
243 |
+ dataType:'text', |
|
244 |
+ data: { sentmessagedbIDs: sentmessagedbIDs }, |
|
245 |
+ success: function() { |
|
246 |
+ showAlert((oldsentRows.length - 1) + " rows have been successfully saved in the 'SMS_relentless/removed_sent_messages' directory and then deleted from the database !"); |
|
247 |
+ $('#smstables').removeClass('icon-loading'); |
|
248 |
+ }, |
|
249 |
+ error: function() { |
|
250 |
+ showAlert("There was an error while deleting the messages older than the specified period!"); |
|
251 |
+ $('#smstables').removeClass('icon-loading'); |
|
252 |
+ } |
|
253 |
+ }); |
|
254 |
+ |
|
255 |
+ } else { showAlert("There was an error while saving the messages older than the specified period!"); } |
|
256 |
+ |
|
257 |
+ $('#smstables').removeClass('icon-loading'); |
|
258 |
+ }, |
|
259 |
+ error: function() { |
|
260 |
+ showAlert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
261 |
+ $('#smstables').removeClass('icon-loading'); |
|
262 |
+ } |
|
263 |
+ }); |
|
264 |
+ } |
|
265 |
+ } |
|
266 |
+ } |
|
267 |
+ |
|
268 |
+ }, |
|
269 |
+ error: function() { |
|
270 |
+ showAlert("An error occurred while getting data from the database!"); |
|
271 |
+ $('#smstables').removeClass('icon-loading'); |
|
272 |
+ } |
|
273 |
+ }); |
|
274 |
+ } |
|
275 |
+ |
|
276 |
+ }); |
|
277 |
+ |
|
278 |
+ function showAlert(alertText) { |
|
279 |
+ |
|
280 |
+ let alertwnd = "<div id='alertMessage'>"; |
|
281 |
+ alertwnd += "<a id='closeAlertWnd' title='Close this window'></a>"; |
|
282 |
+ alertwnd += "<div id='alertTextWrap'>"+ alertText +"</div>"; |
|
283 |
+ alertwnd += "<input type='submit' id='alertOk' value='OK'>"; |
|
284 |
+ alertwnd += "</div>"; |
|
285 |
+ |
|
286 |
+ $("#content").append("<div id='alertMsgOverlay'></div>"); |
|
287 |
+ $("#content").append(alertwnd); |
|
288 |
+ |
|
289 |
+ let topDist = parseInt((window.innerHeight / 2).toFixed(2) - 152) +"px"; |
|
290 |
+ let leftDist = parseInt((window.innerWidth / 2).toFixed(2) - 150) +"px"; |
|
291 |
+ $("#alertMessage").css({ "top" : topDist, "left" : leftDist }); |
|
292 |
+ |
|
293 |
+ $("#closeAlertWnd").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
294 |
+ $("#alertMsgOverlay").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
295 |
+ $("#alertOk").click(function() { $("#alertMsgOverlay").remove(); $("#alertMessage").remove(); }); |
|
296 |
+ } |
|
297 |
+ |
|
298 |
+}); |
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,250 +0,0 @@ |
1 |
-/** |
|
2 |
- * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
3 |
- * |
|
4 |
- * @author Double Bastion LLC |
|
5 |
- * |
|
6 |
- * @license GNU AGPL version 3 or any later version |
|
7 |
- * |
|
8 |
- * This program is free software; you can redistribute it and/or |
|
9 |
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
10 |
- * License as published by the Free Software Foundation; either |
|
11 |
- * version 3 of the License, or any later version. |
|
12 |
- * |
|
13 |
- * This program is distributed in the hope that it will be useful, |
|
14 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
17 |
- * |
|
18 |
- * You should have received a copy of the GNU Affero General Public |
|
19 |
- * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
- * |
|
21 |
- */ |
|
22 |
- |
|
23 |
-$(document).ready(function() { |
|
24 |
- |
|
25 |
- var userid = "<?php p($userId); ?>"; |
|
26 |
- |
|
27 |
- // Delete from the database all the received messages older than the specified period |
|
28 |
- $("#delOldrecSMS").on("click", function() { |
|
29 |
- |
|
30 |
- var oldrecInterval = $("#oldrecSmsInterval").val(); |
|
31 |
- var procoldrecint = oldrecInterval.replace(/[^0-9]/g, ""); |
|
32 |
- var finaloldrecint = parseInt(procoldrecint); |
|
33 |
- |
|
34 |
- if (finaloldrecint == "" || !$.isNumeric(finaloldrecint)) { |
|
35 |
- alert("Please enter the number of days in the box from above !"); |
|
36 |
- } else { |
|
37 |
- |
|
38 |
- var getRecUrl = OC.generateUrl("/apps/sms_relentless/user/getreceivedtablefordel"); |
|
39 |
- $('#smstables').addClass('icon-loading'); |
|
40 |
- |
|
41 |
- $.ajax({ |
|
42 |
- url: getRecUrl + '/' + userid, |
|
43 |
- method: "GET", |
|
44 |
- dataType:'text', |
|
45 |
- success: function(recinfoFromDB) { |
|
46 |
- |
|
47 |
- var parsedinfo = $.parseJSON(recinfoFromDB); |
|
48 |
- |
|
49 |
- if (parsedinfo == "not permitted") { |
|
50 |
- |
|
51 |
- alert("Only admins can remove old messages using this option!"); |
|
52 |
- $('#smstables').removeClass('icon-loading'); |
|
53 |
- return; |
|
54 |
- |
|
55 |
- } else { |
|
56 |
- |
|
57 |
- var recmessagedbIDs = []; |
|
58 |
- var oldrecRows = []; |
|
59 |
- oldrecRows.push("id,user_id,message_id,date,from,to,message\r\n"); |
|
60 |
- |
|
61 |
- var targetdate = new Date(new Date().setDate(new Date().getDate() - finaloldrecint)); |
|
62 |
- |
|
63 |
- for (var j = 0; j < parsedinfo.length; j++) { |
|
64 |
- var firstdate = parsedinfo[j].date; |
|
65 |
- var secdate = firstdate.split(" "); |
|
66 |
- var thirddate = secdate[0].split("-"); |
|
67 |
- var fourthdate = secdate[1].split(":"); |
|
68 |
- var pastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
69 |
- |
|
70 |
- if (pastdate < targetdate) { |
|
71 |
- recmessagedbIDs.push(parsedinfo[j].id); |
|
72 |
- oldrecRows.push(parsedinfo[j].id + "," + parsedinfo[j].user_id + "," + parsedinfo[j].message_id + "," + parsedinfo[j].date + "," + parsedinfo[j].from + "," + parsedinfo[j].to + "," + parsedinfo[j].message + "\r\n"); |
|
73 |
- } |
|
74 |
- } |
|
75 |
- |
|
76 |
- |
|
77 |
- if (oldrecRows.length == 1) { |
|
78 |
- |
|
79 |
- alert("No messages will be deleted since there are no messages older than " + finaloldrecint + " days."); |
|
80 |
- |
|
81 |
- // Save in a '.csv' file all the received messages that will be deleted from the database, then delete them |
|
82 |
- } else { |
|
83 |
- |
|
84 |
- if (confirm("Are you sure you want to delete all the received messages older than " + finaloldrecint + " days ?")) { |
|
85 |
- |
|
86 |
- var deloldrecRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldrecrows"); |
|
87 |
- |
|
88 |
- $.ajax({ |
|
89 |
- url: deloldrecRowsUrl + '/' + userid, |
|
90 |
- method: "POST", |
|
91 |
- dataType:'text', |
|
92 |
- data: { oldrecRows: oldrecRows }, |
|
93 |
- success: function(savecheck) { |
|
94 |
- |
|
95 |
- // Delete received messages from the database |
|
96 |
- var delrecDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removerecrows"); |
|
97 |
- |
|
98 |
- if (savecheck == 1) { |
|
99 |
- |
|
100 |
- $.ajax({ |
|
101 |
- url: delrecDbSmsUrl + '/' + userid, |
|
102 |
- method: "POST", |
|
103 |
- dataType:'text', |
|
104 |
- data: {recmessagedbIDs: recmessagedbIDs}, |
|
105 |
- success: function() { |
|
106 |
- alert((oldrecRows.length - 1)+" rows have been successfully saved in the 'SMS_relentless/removed_received_messages' directory and then deleted from the database !"); |
|
107 |
- $('#smstables').removeClass('icon-loading'); |
|
108 |
- }, |
|
109 |
- error: function() { |
|
110 |
- alert("There was an error while deleting the messages older than the specified period!"); |
|
111 |
- $('#smstables').removeClass('icon-loading'); |
|
112 |
- } |
|
113 |
- }); |
|
114 |
- |
|
115 |
- } else { alert("There was an error while saving the messages older than the specified period!"); } |
|
116 |
- |
|
117 |
- $('#smstables').removeClass('icon-loading'); |
|
118 |
- }, |
|
119 |
- error: function() { |
|
120 |
- alert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
121 |
- $('#smstables').removeClass('icon-loading'); |
|
122 |
- } |
|
123 |
- }); |
|
124 |
- } |
|
125 |
- } |
|
126 |
- } |
|
127 |
- }, |
|
128 |
- error: function() { |
|
129 |
- alert("An error occurred while getting data from the database!"); |
|
130 |
- $('#smstables').removeClass('icon-loading'); |
|
131 |
- } |
|
132 |
- }); |
|
133 |
- |
|
134 |
- } |
|
135 |
- |
|
136 |
- }); |
|
137 |
- |
|
138 |
- |
|
139 |
- // Delete from the database all the sent messages older than the specified period |
|
140 |
- $("#delOldsentSMS").on("click", function() { |
|
141 |
- |
|
142 |
- var oldsentInterval = $("#oldsentSmsInterval").val(); |
|
143 |
- var procoldsentint = oldsentInterval.replace(/[^0-9]/g, ""); |
|
144 |
- var finaloldsentint = parseInt(procoldsentint); |
|
145 |
- |
|
146 |
- if (finaloldsentint == "" || !$.isNumeric(finaloldsentint)) { |
|
147 |
- alert("Please enter the number of days in the box above !"); |
|
148 |
- } else { |
|
149 |
- |
|
150 |
- var getSentUrl = OC.generateUrl("/apps/sms_relentless/user/getsenttablefordel"); |
|
151 |
- $('#smstables').addClass('icon-loading'); |
|
152 |
- |
|
153 |
- $.ajax({ |
|
154 |
- url: getSentUrl + '/' + userid, |
|
155 |
- method: "GET", |
|
156 |
- dataType:'text', |
|
157 |
- success: function(sentinfoFromDB) { |
|
158 |
- |
|
159 |
- var parsedsentinfo = $.parseJSON(sentinfoFromDB); |
|
160 |
- |
|
161 |
- if (parsedsentinfo == "not permitted") { |
|
162 |
- |
|
163 |
- alert("Only admins can remove old messages using this option!"); |
|
164 |
- $('#smstables').removeClass('icon-loading'); |
|
165 |
- return; |
|
166 |
- |
|
167 |
- } else { |
|
168 |
- |
|
169 |
- var sentmessagedbIDs = []; |
|
170 |
- var oldsentRows = []; |
|
171 |
- oldsentRows.push("id,user_id,message_id,date,from,to,network,price,status,deliveryreceipt,message\r\n"); |
|
172 |
- |
|
173 |
- var senttargetdate = new Date(new Date().setDate(new Date().getDate() - finaloldsentint)); |
|
174 |
- |
|
175 |
- for (var j = 0; j < parsedsentinfo.length; j++) { |
|
176 |
- var firstdate = parsedsentinfo[j].date; |
|
177 |
- var secdate = firstdate.split(" "); |
|
178 |
- var thirddate = secdate[0].split("-"); |
|
179 |
- var fourthdate = secdate[1].split(":"); |
|
180 |
- var sentpastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
181 |
- |
|
182 |
- if (sentpastdate < senttargetdate) { |
|
183 |
- sentmessagedbIDs.push(parsedsentinfo[j].id); |
|
184 |
- oldsentRows.push(parsedsentinfo[j].id + "," + parsedsentinfo[j].user_id + "," + parsedsentinfo[j].message_id + "," + parsedsentinfo[j].date + "," + parsedsentinfo[j].from + "," + parsedsentinfo[j].to + "," + parsedsentinfo[j].network + "," + parsedsentinfo[j].price + "," + parsedsentinfo[j].status + "," + parsedsentinfo[j].deliveryreceipt + "," + parsedsentinfo[j].message + "\r\n"); |
|
185 |
- } |
|
186 |
- } |
|
187 |
- |
|
188 |
- |
|
189 |
- if (oldsentRows.length == 1) { |
|
190 |
- |
|
191 |
- alert("No messages will be deleted since there are no messages older than " + finaloldsentint + " days."); |
|
192 |
- |
|
193 |
- // Save in a '.csv' file all the sent messages that will be deleted from the database, then delete them |
|
194 |
- } else { |
|
195 |
- |
|
196 |
- if (confirm("Are you sure you want to delete all the sent messages older than " + finaloldsentint + " days ?")) { |
|
197 |
- |
|
198 |
- var deloldsentRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldsentrows"); |
|
199 |
- |
|
200 |
- $.ajax({ |
|
201 |
- url: deloldsentRowsUrl + '/' + userid, |
|
202 |
- method: "POST", |
|
203 |
- dataType:'text', |
|
204 |
- data: { oldsentRows: oldsentRows }, |
|
205 |
- success: function(savesentcheck) { |
|
206 |
- |
|
207 |
- // Delete sent messages from the database |
|
208 |
- var delsentDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removesentrows"); |
|
209 |
- |
|
210 |
- if (savesentcheck == 1) { |
|
211 |
- |
|
212 |
- $.ajax({ |
|
213 |
- url: delsentDbSmsUrl + '/' + userid, |
|
214 |
- method: "POST", |
|
215 |
- dataType:'text', |
|
216 |
- data: { sentmessagedbIDs: sentmessagedbIDs }, |
|
217 |
- success: function() { |
|
218 |
- alert((oldsentRows.length - 1) + " rows have been successfully saved in the 'SMS_relentless/removed_sent_messages' directory and then deleted from the database !"); |
|
219 |
- $('#smstables').removeClass('icon-loading'); |
|
220 |
- }, |
|
221 |
- error: function() { |
|
222 |
- alert("There was an error while deleting the messages older than the specified period!"); |
|
223 |
- $('#smstables').removeClass('icon-loading'); |
|
224 |
- } |
|
225 |
- }); |
|
226 |
- |
|
227 |
- } else { alert("There was an error while saving the messages older than the specified period!"); } |
|
228 |
- |
|
229 |
- $('#smstables').removeClass('icon-loading'); |
|
230 |
- }, |
|
231 |
- error: function() { |
|
232 |
- alert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
233 |
- $('#smstables').removeClass('icon-loading'); |
|
234 |
- } |
|
235 |
- }); |
|
236 |
- } |
|
237 |
- } |
|
238 |
- |
|
239 |
- } |
|
240 |
- |
|
241 |
- }, |
|
242 |
- error: function() { |
|
243 |
- alert("An error occurred while getting data from the database!"); |
|
244 |
- $('#smstables').removeClass('icon-loading'); |
|
245 |
- } |
|
246 |
- }); |
|
247 |
- } |
|
248 |
- |
|
249 |
- }); |
|
250 |
-}); |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,250 @@ |
1 |
+/** |
|
2 |
+ * @copyright 2021 Double Bastion LLC <www.doublebastion.com> |
|
3 |
+ * |
|
4 |
+ * @author Double Bastion LLC |
|
5 |
+ * |
|
6 |
+ * @license GNU AGPL version 3 or any later version |
|
7 |
+ * |
|
8 |
+ * This program is free software; you can redistribute it and/or |
|
9 |
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE |
|
10 |
+ * License as published by the Free Software Foundation; either |
|
11 |
+ * version 3 of the License, or any later version. |
|
12 |
+ * |
|
13 |
+ * This program is distributed in the hope that it will be useful, |
|
14 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details. |
|
17 |
+ * |
|
18 |
+ * You should have received a copy of the GNU Affero General Public |
|
19 |
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
+ * |
|
21 |
+ */ |
|
22 |
+ |
|
23 |
+$(document).ready(function() { |
|
24 |
+ |
|
25 |
+ var userid = "<?php p($userId); ?>"; |
|
26 |
+ |
|
27 |
+ // Delete from the database all the received messages older than the specified period |
|
28 |
+ $("#delOldrecSMS").on("click", function() { |
|
29 |
+ |
|
30 |
+ var oldrecInterval = $("#oldrecSmsInterval").val(); |
|
31 |
+ var procoldrecint = oldrecInterval.replace(/[^0-9]/g, ""); |
|
32 |
+ var finaloldrecint = parseInt(procoldrecint); |
|
33 |
+ |
|
34 |
+ if (finaloldrecint == "" || !$.isNumeric(finaloldrecint)) { |
|
35 |
+ alert("Please enter the number of days in the box from above !"); |
|
36 |
+ } else { |
|
37 |
+ |
|
38 |
+ var getRecUrl = OC.generateUrl("/apps/sms_relentless/user/getreceivedtablefordel"); |
|
39 |
+ $('#smstables').addClass('icon-loading'); |
|
40 |
+ |
|
41 |
+ $.ajax({ |
|
42 |
+ url: getRecUrl + '/' + userid, |
|
43 |
+ method: "GET", |
|
44 |
+ dataType:'text', |
|
45 |
+ success: function(recinfoFromDB) { |
|
46 |
+ |
|
47 |
+ var parsedinfo = $.parseJSON(recinfoFromDB); |
|
48 |
+ |
|
49 |
+ if (parsedinfo == "not permitted") { |
|
50 |
+ |
|
51 |
+ alert("Only admins can remove old messages using this option!"); |
|
52 |
+ $('#smstables').removeClass('icon-loading'); |
|
53 |
+ return; |
|
54 |
+ |
|
55 |
+ } else { |
|
56 |
+ |
|
57 |
+ var recmessagedbIDs = []; |
|
58 |
+ var oldrecRows = []; |
|
59 |
+ oldrecRows.push("id,user_id,message_id,date,from,to,message\r\n"); |
|
60 |
+ |
|
61 |
+ var targetdate = new Date(new Date().setDate(new Date().getDate() - finaloldrecint)); |
|
62 |
+ |
|
63 |
+ for (var j = 0; j < parsedinfo.length; j++) { |
|
64 |
+ var firstdate = parsedinfo[j].date; |
|
65 |
+ var secdate = firstdate.split(" "); |
|
66 |
+ var thirddate = secdate[0].split("-"); |
|
67 |
+ var fourthdate = secdate[1].split(":"); |
|
68 |
+ var pastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
69 |
+ |
|
70 |
+ if (pastdate < targetdate) { |
|
71 |
+ recmessagedbIDs.push(parsedinfo[j].id); |
|
72 |
+ oldrecRows.push(parsedinfo[j].id + "," + parsedinfo[j].user_id + "," + parsedinfo[j].message_id + "," + parsedinfo[j].date + "," + parsedinfo[j].from + "," + parsedinfo[j].to + "," + parsedinfo[j].message + "\r\n"); |
|
73 |
+ } |
|
74 |
+ } |
|
75 |
+ |
|
76 |
+ |
|
77 |
+ if (oldrecRows.length == 1) { |
|
78 |
+ |
|
79 |
+ alert("No messages will be deleted since there are no messages older than " + finaloldrecint + " days."); |
|
80 |
+ |
|
81 |
+ // Save in a '.csv' file all the received messages that will be deleted from the database, then delete them |
|
82 |
+ } else { |
|
83 |
+ |
|
84 |
+ if (confirm("Are you sure you want to delete all the received messages older than " + finaloldrecint + " days ?")) { |
|
85 |
+ |
|
86 |
+ var deloldrecRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldrecrows"); |
|
87 |
+ |
|
88 |
+ $.ajax({ |
|
89 |
+ url: deloldrecRowsUrl + '/' + userid, |
|
90 |
+ method: "POST", |
|
91 |
+ dataType:'text', |
|
92 |
+ data: { oldrecRows: oldrecRows }, |
|
93 |
+ success: function(savecheck) { |
|
94 |
+ |
|
95 |
+ // Delete received messages from the database |
|
96 |
+ var delrecDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removerecrows"); |
|
97 |
+ |
|
98 |
+ if (savecheck == 1) { |
|
99 |
+ |
|
100 |
+ $.ajax({ |
|
101 |
+ url: delrecDbSmsUrl + '/' + userid, |
|
102 |
+ method: "POST", |
|
103 |
+ dataType:'text', |
|
104 |
+ data: {recmessagedbIDs: recmessagedbIDs}, |
|
105 |
+ success: function() { |
|
106 |
+ alert((oldrecRows.length - 1)+" rows have been successfully saved in the 'SMS_relentless/removed_received_messages' directory and then deleted from the database !"); |
|
107 |
+ $('#smstables').removeClass('icon-loading'); |
|
108 |
+ }, |
|
109 |
+ error: function() { |
|
110 |
+ alert("There was an error while deleting the messages older than the specified period!"); |
|
111 |
+ $('#smstables').removeClass('icon-loading'); |
|
112 |
+ } |
|
113 |
+ }); |
|
114 |
+ |
|
115 |
+ } else { alert("There was an error while saving the messages older than the specified period!"); } |
|
116 |
+ |
|
117 |
+ $('#smstables').removeClass('icon-loading'); |
|
118 |
+ }, |
|
119 |
+ error: function() { |
|
120 |
+ alert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
121 |
+ $('#smstables').removeClass('icon-loading'); |
|
122 |
+ } |
|
123 |
+ }); |
|
124 |
+ } |
|
125 |
+ } |
|
126 |
+ } |
|
127 |
+ }, |
|
128 |
+ error: function() { |
|
129 |
+ alert("An error occurred while getting data from the database!"); |
|
130 |
+ $('#smstables').removeClass('icon-loading'); |
|
131 |
+ } |
|
132 |
+ }); |
|
133 |
+ |
|
134 |
+ } |
|
135 |
+ |
|
136 |
+ }); |
|
137 |
+ |
|
138 |
+ |
|
139 |
+ // Delete from the database all the sent messages older than the specified period |
|
140 |
+ $("#delOldsentSMS").on("click", function() { |
|
141 |
+ |
|
142 |
+ var oldsentInterval = $("#oldsentSmsInterval").val(); |
|
143 |
+ var procoldsentint = oldsentInterval.replace(/[^0-9]/g, ""); |
|
144 |
+ var finaloldsentint = parseInt(procoldsentint); |
|
145 |
+ |
|
146 |
+ if (finaloldsentint == "" || !$.isNumeric(finaloldsentint)) { |
|
147 |
+ alert("Please enter the number of days in the box above !"); |
|
148 |
+ } else { |
|
149 |
+ |
|
150 |
+ var getSentUrl = OC.generateUrl("/apps/sms_relentless/user/getsenttablefordel"); |
|
151 |
+ $('#smstables').addClass('icon-loading'); |
|
152 |
+ |
|
153 |
+ $.ajax({ |
|
154 |
+ url: getSentUrl + '/' + userid, |
|
155 |
+ method: "GET", |
|
156 |
+ dataType:'text', |
|
157 |
+ success: function(sentinfoFromDB) { |
|
158 |
+ |
|
159 |
+ var parsedsentinfo = $.parseJSON(sentinfoFromDB); |
|
160 |
+ |
|
161 |
+ if (parsedsentinfo == "not permitted") { |
|
162 |
+ |
|
163 |
+ alert("Only admins can remove old messages using this option!"); |
|
164 |
+ $('#smstables').removeClass('icon-loading'); |
|
165 |
+ return; |
|
166 |
+ |
|
167 |
+ } else { |
|
168 |
+ |
|
169 |
+ var sentmessagedbIDs = []; |
|
170 |
+ var oldsentRows = []; |
|
171 |
+ oldsentRows.push("id,user_id,message_id,date,from,to,network,price,status,deliveryreceipt,message\r\n"); |
|
172 |
+ |
|
173 |
+ var senttargetdate = new Date(new Date().setDate(new Date().getDate() - finaloldsentint)); |
|
174 |
+ |
|
175 |
+ for (var j = 0; j < parsedsentinfo.length; j++) { |
|
176 |
+ var firstdate = parsedsentinfo[j].date; |
|
177 |
+ var secdate = firstdate.split(" "); |
|
178 |
+ var thirddate = secdate[0].split("-"); |
|
179 |
+ var fourthdate = secdate[1].split(":"); |
|
180 |
+ var sentpastdate = new Date(thirddate[0],(thirddate[1]-1),thirddate[2],fourthdate[0],fourthdate[1],fourthdate[2]); |
|
181 |
+ |
|
182 |
+ if (sentpastdate < senttargetdate) { |
|
183 |
+ sentmessagedbIDs.push(parsedsentinfo[j].id); |
|
184 |
+ oldsentRows.push(parsedsentinfo[j].id + "," + parsedsentinfo[j].user_id + "," + parsedsentinfo[j].message_id + "," + parsedsentinfo[j].date + "," + parsedsentinfo[j].from + "," + parsedsentinfo[j].to + "," + parsedsentinfo[j].network + "," + parsedsentinfo[j].price + "," + parsedsentinfo[j].status + "," + parsedsentinfo[j].deliveryreceipt + "," + parsedsentinfo[j].message + "\r\n"); |
|
185 |
+ } |
|
186 |
+ } |
|
187 |
+ |
|
188 |
+ |
|
189 |
+ if (oldsentRows.length == 1) { |
|
190 |
+ |
|
191 |
+ alert("No messages will be deleted since there are no messages older than " + finaloldsentint + " days."); |
|
192 |
+ |
|
193 |
+ // Save in a '.csv' file all the sent messages that will be deleted from the database, then delete them |
|
194 |
+ } else { |
|
195 |
+ |
|
196 |
+ if (confirm("Are you sure you want to delete all the sent messages older than " + finaloldsentint + " days ?")) { |
|
197 |
+ |
|
198 |
+ var deloldsentRowsUrl = OC.generateUrl("/apps/sms_relentless/user/saveoldsentrows"); |
|
199 |
+ |
|
200 |
+ $.ajax({ |
|
201 |
+ url: deloldsentRowsUrl + '/' + userid, |
|
202 |
+ method: "POST", |
|
203 |
+ dataType:'text', |
|
204 |
+ data: { oldsentRows: oldsentRows }, |
|
205 |
+ success: function(savesentcheck) { |
|
206 |
+ |
|
207 |
+ // Delete sent messages from the database |
|
208 |
+ var delsentDbSmsUrl = OC.generateUrl("/apps/sms_relentless/user/removesentrows"); |
|
209 |
+ |
|
210 |
+ if (savesentcheck == 1) { |
|
211 |
+ |
|
212 |
+ $.ajax({ |
|
213 |
+ url: delsentDbSmsUrl + '/' + userid, |
|
214 |
+ method: "POST", |
|
215 |
+ dataType:'text', |
|
216 |
+ data: { sentmessagedbIDs: sentmessagedbIDs }, |
|
217 |
+ success: function() { |
|
218 |
+ alert((oldsentRows.length - 1) + " rows have been successfully saved in the 'SMS_relentless/removed_sent_messages' directory and then deleted from the database !"); |
|
219 |
+ $('#smstables').removeClass('icon-loading'); |
|
220 |
+ }, |
|
221 |
+ error: function() { |
|
222 |
+ alert("There was an error while deleting the messages older than the specified period!"); |
|
223 |
+ $('#smstables').removeClass('icon-loading'); |
|
224 |
+ } |
|
225 |
+ }); |
|
226 |
+ |
|
227 |
+ } else { alert("There was an error while saving the messages older than the specified period!"); } |
|
228 |
+ |
|
229 |
+ $('#smstables').removeClass('icon-loading'); |
|
230 |
+ }, |
|
231 |
+ error: function() { |
|
232 |
+ alert("There was an error while saving and/or deleting the messages older than the specified period!"); |
|
233 |
+ $('#smstables').removeClass('icon-loading'); |
|
234 |
+ } |
|
235 |
+ }); |
|
236 |
+ } |
|
237 |
+ } |
|
238 |
+ |
|
239 |
+ } |
|
240 |
+ |
|
241 |
+ }, |
|
242 |
+ error: function() { |
|
243 |
+ alert("An error occurred while getting data from the database!"); |
|
244 |
+ $('#smstables').removeClass('icon-loading'); |
|
245 |
+ } |
|
246 |
+ }); |
|
247 |
+ } |
|
248 |
+ |
|
249 |
+ }); |
|
250 |
+}); |