File indexing completed on 2024-12-29 05:24:49
0001 <?php 0002 /** 0003 * ocs-webserver 0004 * 0005 * Copyright 2016 by pling GmbH. 0006 * 0007 * This file is part of ocs-webserver. 0008 * 0009 * This program is free software: you can redistribute it and/or modify 0010 * it under the terms of the GNU Affero General Public License as 0011 * published by the Free Software Foundation, either version 3 of the 0012 * License, or (at your option) any later version. 0013 * 0014 * This program is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 * GNU Affero General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU Affero General Public License 0020 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 **/ 0022 ?> 0023 0024 <style type="text/css"> 0025 0026 0027 div.jtable-main-container table.jtable tbody > tr > td{ 0028 vertical-align: top; 0029 border-left:0px; 0030 border-right:0px; 0031 font-size: small; 0032 } 0033 div.jtable-main-container table.jtable{ 0034 border: 0px; 0035 } 0036 div.jtable-main-container table.jtable th{ 0037 border: 0px; 0038 background: none; 0039 font-weight: bold; 0040 } 0041 0042 #TableContainer 0043 { 0044 padding: 20px; 0045 } 0046 #titleheader{ 0047 padding-left: 20px; 0048 padding-top: 100px; 0049 } 0050 0051 a.btn-xs 0052 { 0053 line-height: 12px; 0054 padding: 3px 5px; 0055 border-radius: 2px; 0056 margin: 2px; 0057 float: right; 0058 } 0059 0060 0061 div.jtable-main-container table.jtable .tooltipuser{ 0062 color: #2673b0; 0063 cursor: pointer; 0064 } 0065 0066 div.jtable-main-container img.avatar{ 0067 width: 50px; 0068 border: 1px solid #dbdbdb; 0069 -webkit-border-radius: 999px; 0070 -moz-border-radius: 999px; 0071 border-radius: 999px; 0072 -webkit-background-clip: padding-box; 0073 -moz-background-clip: padding; 0074 background-clip: padding-box; 0075 display: block; 0076 } 0077 0078 a.removeuser{ 0079 display: block; 0080 } 0081 0082 .aligncenter 0083 { 0084 text-align: center; 0085 } 0086 0087 0088 </style> 0089 0090 <link href="/theme/backend/lib/jquery-ui/themes/smoothness/jquery-ui.min.css" rel="stylesheet"> 0091 <link href="/theme/backend/lib/jtable/themes/jqueryui/jtable_jqueryui.min.css" rel="stylesheet"> 0092 <script src="/theme/backend/lib/jquery-ui/jquery-ui.min.js"></script> 0093 <script src="/theme/backend/lib/jtable/jquery.jtable.min.js"></script> 0094 0095 <div class="messages"> 0096 0097 </div> 0098 <div class="tooltip_templates" style="display:none"> 0099 <span id="tooltip_content"> 0100 <i class="fa fa-spinner"></i> 0101 </span> 0102 </div> 0103 <div id="titleheader"> <h1>Table of comments </h1></div> 0104 0105 <div id="filter" style="padding:10px 20px;"> 0106 Pick year: <select id="filter_year" name="filter_year"> 0107 <?php 0108 $currentyear = date("Y"); 0109 $startyear = 2001; 0110 for ($i = $currentyear; $i >= 2001; $i--) { 0111 echo '<option>'.$i.'</option>'; 0112 } 0113 ?> 0114 </select> 0115 </div> 0116 <div id="TableContainer"></div> 0117 <div id="dialog-form" title="Object Details"></div> 0118 <div id="dialog-confirm" title="Confirm"></div> 0119 <script type="text/javascript"> 0120 $(document).ready(function () { 0121 $('#TableContainer').jtable({ 0122 jqueryuiTheme: true, 0123 paging: true, 0124 sorting: true, 0125 actions: { 0126 listAction: '/spam/commentslist', 0127 /*deleteAction: '/spam/deletecomment' */ 0128 }, 0129 recordsLoaded: function (event, data) { 0130 TooltipUser.setup("tooltipuser","right"); 0131 }, 0132 rowInserted: function (event, data) { 0133 if (data.record.cntComments==1) { 0134 data.row.css("background", "#F7F7E1"); 0135 } 0136 }, 0137 fields: { 0138 comment_id: { 0139 key: true, 0140 title: 'comment id', 0141 create: false, 0142 edit: false, 0143 list: false 0144 }, 0145 comment_target_id: { 0146 title: 'project id', 0147 width: '5%', 0148 edit: false, 0149 display:function(data){ 0150 var html='<a target="_blank" href="/p/'+data.record.comment_target_id+'">'+data.record.comment_target_id+'</a>'; 0151 return html; 0152 } 0153 }, 0154 aboutme: { 0155 title: 'aboutme', 0156 width: '20%', 0157 create: false, 0158 edit: false 0159 }, 0160 comment_created_at: { 0161 title: 'created', 0162 width: '10%', 0163 create: false, 0164 edit: false 0165 }, 0166 comment_member_id: { 0167 title: 'by', 0168 width: '5%', 0169 edit: false, 0170 display:function(data){ 0171 var html = '<a href="/u/'+data.record.username+'" target="_blank" class="tooltipuser" data-tooltip-content="#tooltip_content" data-user="'+data.record.comment_member_id+'" >'; 0172 html=html+'<img class="avatar" src="'+data.record.avatar+'"/>'+data.record.username+'</a>'; 0173 0174 return html; 0175 } 0176 }, 0177 member_since: { 0178 title: 'member since', 0179 create: false, 0180 edit: false, 0181 list: true, 0182 sorting:false 0183 }, 0184 cntComments: { 0185 title: '#comments', 0186 create: false, 0187 width: '3%', 0188 edit: false, 0189 list: true, 0190 listClass: 'aligncenter' 0191 }, 0192 cntProjects: { 0193 title: '#projects', 0194 width: '3%', 0195 create: false, 0196 edit: false, 0197 listClass: 'aligncenter' 0198 }, 0199 comment_text: { 0200 title: 'text', 0201 width: '30%', 0202 sorting:false 0203 }, 0204 0205 reportedby:{ 0206 title: 'reported by', 0207 0208 create: false, 0209 edit: false, 0210 display:function(data){ 0211 var reportedby = data.record.reportedby; 0212 var html=''; 0213 if(reportedby) 0214 { 0215 var array = reportedby.split(','); 0216 if(array.length>5){ array = array.slice(0, 5);} 0217 $(array).each(function( index, element ) { 0218 html = html+'<a class="tooltipuser" data-tooltip-content="#tooltip_content" data-user="'+element+'" >'+element+'</a><br/>'; 0219 }); 0220 } 0221 return html; 0222 } 0223 }, 0224 cntreport: { 0225 title: '#', 0226 width: '5%', 0227 create: false, 0228 edit: false, 0229 listClass: 'aligncenter', 0230 display:function(data){ 0231 var cnt = data.record.cntreport; 0232 var html=''; 0233 if(cnt>0) html=cnt; 0234 return html; 0235 } 0236 }, 0237 hide: { 0238 title: '', 0239 width: '1%', 0240 sorting: false, 0241 create: false, 0242 edit: false, 0243 list: true, 0244 display: function (data) { 0245 if (data.record.cntreport>0) { 0246 return '<a role="button" class="btn btn-warning btn-xs removecomment pull-right" style="color:white;" data-record="' + data.record.comment_id + '"><span>Remove Comment</span></a><a role="button" class="btn btn-warning btn-xs removereports pull-right" style="color:white;" data-record="' + data.record.comment_id + '"><span>Remove Reports</span></a><a role="button" class="btn btn-warning btn-xs removeuser pull-right" style="color:white;" data-record="' + data.record.comment_member_id + '"><span>Remove User</span></a>' 0247 ; 0248 } 0249 } 0250 } 0251 0252 } 0253 }); 0254 0255 //$('#TableContainer').jtable('load'); 0256 $('#TableContainer').jtable('load', {},function(){ 0257 //TooltipUser.setup("tooltipuser","right"); 0258 }); 0259 0260 $("#dialog-form").dialog({ 0261 autoOpen: false, 0262 //height: 350, 0263 width: 600, 0264 modal: true, 0265 buttons: { 0266 Close: function () { 0267 $(this).dialog("close"); 0268 } 0269 } 0270 }); 0271 0272 0273 0274 $('body').on("click", 'a.removecomment', function (event) { 0275 event.preventDefault(); 0276 event.stopImmediatePropagation(); 0277 0278 //$("#dialog-confirm").html('are you sure to delete this comment ?').dialog('open'); 0279 var elementRecord = $(this).data("record"); 0280 0281 $("#dialog-confirm").html('are you sure to delete this comment ?').dialog({ 0282 autoOpen: true, 0283 html: 'are you sure to delete this comment ?', 0284 width: 600, 0285 modal: true, 0286 buttons: { 0287 "Confirm" : function() { 0288 jQuery.ajax({ 0289 data: {'comment_id': elementRecord}, 0290 url: '/spam/deletecomment', 0291 type: 'post', 0292 error: function () { 0293 alert("<span class='error'>Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error.</span>"); 0294 return false; 0295 }, 0296 success: function (results) { 0297 $("#dialog-confirm").dialog("close"); 0298 $('#TableContainer').jtable('reload'); 0299 return false; 0300 } 0301 }); 0302 }, 0303 "Cancel" : function() { 0304 $(this).dialog("close"); 0305 } 0306 } 0307 }); 0308 0309 return false; 0310 0311 }); 0312 0313 0314 $('body').on("click", 'a.removereports', function (event) { 0315 event.preventDefault(); 0316 event.stopImmediatePropagation(); 0317 0318 var elementRecord = $(this).data("record"); 0319 0320 $("#dialog-confirm").html('are you sure to delete this reports ?').dialog({ 0321 autoOpen: true, 0322 html: 'are you sure to delete this reports ?', 0323 width: 600, 0324 modal: true, 0325 buttons: { 0326 "Confirm" : function() { 0327 jQuery.ajax({ 0328 data: {'comment_id': elementRecord}, 0329 url: '/spam/deletereports', 0330 type: 'post', 0331 error: function () { 0332 alert("<span class='error'>Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. <br/>Find out why you may have encountered this error.</span>"); 0333 return false; 0334 }, 0335 success: function (results) { 0336 $("#dialog-confirm").dialog("close"); 0337 $('#TableContainer').jtable('reload'); 0338 return false; 0339 } 0340 }); 0341 }, 0342 "Cancel" : function() { 0343 $(this).dialog("close"); 0344 } 0345 } 0346 }); 0347 0348 0349 0350 return false; 0351 }); 0352 0353 $('body').on("click", 'a.removeuser', function (event) { 0354 event.preventDefault(); 0355 event.stopImmediatePropagation(); 0356 0357 var elementRecord = $(this).data("record"); 0358 alert(elementRecord); 0359 $("#dialog-confirm").html('Delete this member and all his products and comments? ?').dialog({ 0360 autoOpen: true, 0361 html: 'Delete this member and all his products and comments? ?', 0362 width: 600, 0363 modal: true, 0364 buttons: { 0365 "Confirm" : function() { 0366 jQuery.ajax({ 0367 data: {'member_id': elementRecord}, 0368 url: '/backend/user/delete', 0369 type: 'post', 0370 error: function () { 0371 alert("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue. Find out why you may have encountered this error."); 0372 return false; 0373 }, 0374 success: function (results) { 0375 $("#dialog-confirm").dialog("close"); 0376 $('#TableContainer').jtable('reload'); 0377 return false; 0378 } 0379 }); 0380 }, 0381 "Cancel" : function() { 0382 $(this).dialog("close"); 0383 } 0384 } 0385 }); 0386 0387 0388 0389 return false; 0390 }); 0391 0392 0393 //Re-load records when user click 'load records' button. 0394 $('#filter_year').on('change',function (e) { 0395 e.preventDefault(); 0396 $('#TableContainer').jtable('load', { 0397 filter_year: $('#filter_year').val(), 0398 }); 0399 }); 0400 }); 0401 </script>