File indexing completed on 2025-05-04 05:29:02

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 <style>
0024     .jtable-toolbar-item-add-record {
0025         display: none !important;
0026     }
0027 </style>
0028 <div class="messages">
0029     <?php foreach (Zend_Controller_Action_HelperBroker::getStaticHelper('flashMessenger')
0030                        ->getCurrentMessages() as $message) : ?>
0031         <p><?php echo $this->escape($message); ?></p>
0032     <?php endforeach; ?>
0033 </div>
0034 <div id="TableContainer"></div>
0035 <div id="dialog-form" title="Object Details"></div>
0036 <script type="text/javascript">
0037     $(document).ready(function () {
0038         $('#TableContainer').jtable({
0039             jqueryuiTheme: true,
0040             paging: true,
0041             title: 'Table of comments',
0042             actions: {
0043                 listAction: '/backend/comments/list',
0044                 createAction: '/backend/comments/create',
0045                 updateAction: '/backend/comments/update',
0046                 deleteAction: '/backend/comments/delete'
0047             },
0048             fields: {
0049                 comment_id: {
0050                     key: true,
0051                     create: false,
0052                     edit: false,
0053                     list: false
0054                 },
0055                 comment_type: {
0056                     title: 'type',
0057                     width: '5%',
0058                     edit: false
0059                 },
0060                 comment_parent_id: {
0061                     title: 'parent id',
0062                     width: '5%',
0063                     edit: false
0064                 },
0065                 comment_target_id: {
0066                     title: 'project id',
0067                     width: '5%',
0068                     edit: false
0069                 },
0070                 comment_member_id: {
0071                     title: 'member id',
0072                     width: '5%',
0073                     edit: false
0074                 },
0075                 comment_text: {
0076                     title: 'text',
0077                     width: '50%',
0078                     input: function (data) {
0079                         if (data.record) {
0080                             return '<textarea name="comment_text" rows="10" cols="50">' + data.record.comment_text + '</textarea>';
0081                         } else {
0082                             return '<input type="text" name="comment_text" style="width:200px" value="enter text here" />';
0083                         }
0084                     }
0085                 },
0086                 comment_created_at: {
0087                     title: 'created',
0088                     width: '10%',
0089                     type: 'date',
0090                     create: false,
0091                     edit: false
0092                 },
0093                 comment_active: {
0094                     title: 'active',
0095                     width: '5%',
0096                     create: false,
0097                     edit: false
0098                 },
0099                 source_id: {
0100                     title: 'source id',
0101                     width: '5%',
0102                     create: false,
0103                     edit: false
0104                 },
0105                 hide: {
0106                     title: '',
0107                     width: '1%',
0108                     sorting: false,
0109                     create: false,
0110                     edit: false,
0111                     list: true,
0112                     display: function (data) {
0113                         if (data.record.comment_active) {
0114                             if (data.record.comment_active == 0) {
0115                                 btn_title = 'activate';
0116                             } else {
0117                                 btn_title = 'deactivate';
0118                             }
0119                             return '<a role="button" title="' + btn_title + ' this comment" class="btn btn-warning btn-xs toggle-status pull-right" style="color:white;"  data-record="' + data.record.comment_id + '"><span>' + btn_title + '</span></a>'
0120                                 ;
0121                         }
0122                     }
0123                 }
0124 
0125             }
0126         });
0127 
0128         $('#TableContainer').jtable('load');
0129 
0130         $("#dialog-form").dialog({
0131             autoOpen: false,
0132             //height: 350,
0133             width: 600,
0134             modal: true,
0135             buttons: {
0136                 Close: function () {
0137                     $(this).dialog("close");
0138                 }
0139             }
0140         });
0141 
0142         $('body').on("click", 'a.member-info', function (event) {
0143             event.preventDefault();
0144             event.stopImmediatePropagation();
0145 
0146             var elementRecord = $(this).data("record");
0147 
0148             jQuery.ajax({
0149                 data: {'member_id': elementRecord},
0150                 url: '/backend/user/memberinfo/',
0151                 type: 'post',
0152                 error: function () {
0153                     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>");
0154                     return false;
0155                 },
0156                 success: function (results) {
0157                     $('#dialog-form').html(results.ViewRecord).dialog('open');
0158                     return false;
0159                 }
0160             });
0161 
0162             return false;
0163         });
0164 
0165         $('body').on("click", 'a.toggle-status', function (event) {
0166             event.preventDefault();
0167             event.stopImmediatePropagation();
0168 
0169             var elementRecord = $(this).data("record");
0170 
0171             jQuery.ajax({
0172                 data: {'c': elementRecord},
0173                 url: '/backend/comments/status/',
0174                 type: 'post',
0175                 error: function () {
0176                     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>");
0177                     return false;
0178                 },
0179                 success: function (results) {
0180                     $('#TableContainer').jtable('reload');
0181                     return false;
0182                 }
0183             });
0184 
0185             return false;
0186         });
0187 
0188     });
0189 </script>