Browse code

added changed files to make app compatible with Nextcloud 34

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

removed js/settings.js js/adminsettings.js js/sendsms.js js/showsmstables.js js/deleteoldsms.js js/arrowup.js css/style.css lib/AppInfo/Application.php lib/Controller/PageController.php lib/Controller/SmsrelentlessController.php lib/Controller/AuthorApiController.php lib/Service/SmsrelentlessService.php lib/Notification/Notifier.php templates/index.php templates/settings/admin.php templates/settings/personal.php templates/navigation/index.php templates/content/index.php

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

added appinfo/info.xml appinfo/signature.json CHANGELOG.txt js/adminsettings.js js/deleteoldsms.js css/style.css templates/settings/admin.php lib/Service/SmsrelentlessService.php lib/Controller/SmsrelentlessController.php

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

removed appinfo/info.xml appinfo/signature.json CHANGELOG.txt js/adminsettings.js js/deleteoldsms.js css/style.css templates/settings/admin.php lib/Service/SmsrelentlessService.php lib/Controller/SmsrelentlessController.php

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

added appinfo/info.xml appinfo/signature.json appinfo/routes.php CHANGELOG.txt lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php templates/settings/admin.php templates/navigation/index.php js/adminsettings.js js/settings.js js/deleteoldsms.js js/sendsms.js js/showsmstables.js css/style.css

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

removed appinfo/info.xml appinfo/signature.json appinfo/routes.php CHANGELOG.txt lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php templates/settings/admin.php templates/navigation/index.php js/adminsettings.js js/settings.js js/deleteoldsms.js js/sendsms.js js/showsmstables.js css/style.css

DoubleBastionAdmin authored on 06/03/2025 14:01:22
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,334 +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,
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,
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,
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,
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,
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,
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
-});
Browse code

added appinfo/info.xml appinfo/signature.json appinfo/routes.php CHANGELOG.txt lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php js/adminsettings.js js/settings.js js/deleteoldsms.js js/sendsms.js js/showsmstables.js

DoubleBastionAdmin authored on 31/01/2025 18:32:12
Showing 1 changed files
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,
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,
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,
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,
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,
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,
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
+});
Browse code

removed appinfo/info.xml appinfo/signature.json appinfo/routes.php CHANGELOG.txt lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php js/adminsettings.js js/settings.js js/deleteoldsms.js js/sendsms.js js/showsmstables.js

DoubleBastionAdmin authored on 31/01/2025 18:11:48
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,334 +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
-       $("#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
-});
Browse code

added CHANGELOG.txt appinfo/info.xml appinfo/signature.json appinfo/routes.php css/style.css js/adminsettings.js js/deleteoldsms.js js/sendsms.js js/settings.js js/showsmstables.js lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php providers/Telnyx/lib/ApiResource.php

DoubleBastionAdmin authored on 15/07/2023 22:05:06
Showing 1 changed files
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
+});
Browse code

removed CHANGELOG.txt appinfo/info.xml appinfo/signature.json appinfo/routes.php css/style.css js/adminsettings.js js/deleteoldsms.js js/sendsms.js js/settings.js js/showsmstables.js lib/Controller/AuthorApiController.php lib/Controller/SmsrelentlessController.php lib/Service/SmsrelentlessService.php providers/Telnyx/lib/ApiResource.php

DoubleBastionAdmin authored on 15/07/2023 21:56:42
Showing 1 changed files
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
-});
Browse code

added CHANGELOG.txt appinfo/info.xml appinfo/signature.json css/style.css img/closewnd.svg js/adminsettings.js js/deleteoldsms.js ...

DoubleBastionAdmin authored on 23/05/2023 19:00:54
Showing 1 changed files
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
+});
Browse code

removed CHANGELOG.txt appinfo/info.xml appinfo/signature.json css/style.css img/closewnd.svg ...

DoubleBastionAdmin authored on 23/05/2023 18:50:19
Showing 1 changed files
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
-});
Browse code

added files to implement pop-up windows, etc.

DoubleBastionAdmin authored on 20/05/2023 01:06:57
Showing 1 changed files
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
+});
Browse code

removed files to implement auto-reply fix, etc.

DoubleBastionAdmin authored on 20/05/2023 00:46:30
Showing 1 changed files
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
-});
Browse code

Created repository.

DoubleBastionAdmin authored on 01/03/2022 23:47:00
Showing 1 changed files
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
+});