99}
1010require_once $ global ['systemRootPath ' ] . 'objects/comment.php ' ;
1111$ userCanUpload = User::canUpload ();
12+ $ userIsAdmin = User::isAdmin ();
1213$ _page = new Page (array ('My Comments ' ));
1314$ commentTemplate = json_encode (file_get_contents ($ global ['systemRootPath ' ] . 'view/videoComments_template.php ' ));
1415?>
120121 </h3>
121122 </div>
122123 <div class="panel-body">
123- <?php if ($ userCanUpload ) { ?>
124+ <?php if ($ userCanUpload || $ userIsAdmin ) { ?>
124125 <ul class="nav nav-tabs" role="tablist">
125126 <li role="presentation" class="active">
126127 <a href="#postedTab" aria-controls="postedTab" role="tab" data-toggle="tab">
129130 <span class="badge" id="postedBadge" style="display:none;"></span>
130131 </a>
131132 </li>
133+ <?php if ($ userCanUpload ) { ?>
132134 <li role="presentation">
133135 <a href="#receivedTab" aria-controls="receivedTab" role="tab" data-toggle="tab">
134136 <i class="fas fa-inbox"></i>
135137 <?php echo __ ('Comments on My Videos ' ); ?>
136138 <span class="badge" id="receivedBadge" style="display:none;"></span>
137139 </a>
138140 </li>
141+ <?php } ?>
142+ <?php if ($ userIsAdmin ) { ?>
143+ <li role="presentation">
144+ <a href="#allTab" aria-controls="allTab" role="tab" data-toggle="tab">
145+ <i class="fas fa-list"></i>
146+ <?php echo __ ('All Comments ' ); ?>
147+ <span class="badge" id="allBadge" style="display:none;"></span>
148+ </a>
149+ </li>
150+ <?php } ?>
139151 </ul>
140152 <?php } ?>
141153 <div class="tab-content">
157169 </div>
158170 </div>
159171 <?php } ?>
172+ <?php if ($ userIsAdmin ) { ?>
173+ <div role="tabpanel" class="tab-pane" id="allTab">
174+ <div id="allCommentsArea" class="myCommentsTabArea canComment userLogged"></div>
175+ <div class="text-center" style="margin-top: 10px;">
176+ <button class="btn btn-link" onclick="loadAllComments(0, lastAllPage + 1);" id="allLoadMoreBtn" style="display:none;">
177+ <i class="fas fa-chevron-down"></i> <?php echo __ ('Load More ' ); ?>
178+ </button>
179+ </div>
180+ </div>
181+ <?php } ?>
160182 </div>
161183 </div>
162184 </div>
165187 var commentTemplate = <?php echo $ commentTemplate ; ?> ;
166188 var lastPostedPage = 0;
167189 var lastReceivedPage = 0;
190+ var lastAllPage = 0;
168191 var receivedLoaded = false;
192+ var allLoaded = false;
169193
170194 function mcGetCommentTemplate(itemsArray) {
171195 var template = commentTemplate;
@@ -384,10 +408,64 @@ function loadReceivedComments(comments_id, page) {
384408 });
385409 }
386410
411+ function loadAllComments(comments_id, page) {
412+ var url = webSiteRootURL + 'objects/myComments.json.php?type=all';
413+ url = addQueryStringParameter(url, 'comments_id', comments_id);
414+ url = addQueryStringParameter(url, 'current', page);
415+ lastAllPage = page;
416+ if (empty(comments_id) && page <= 1 && typeof avideoSetContainerLoading === 'function') {
417+ avideoSetContainerLoading('allCommentsArea', true, {clear: true, items: 4});
418+ }
419+ modal.showPleaseWait();
420+ $.ajax({
421+ url: url,
422+ success: function(response) {
423+ modal.hidePleaseWait();
424+ if (empty(comments_id) && typeof avideoSetContainerLoading === 'function') {
425+ avideoSetContainerLoading('allCommentsArea', false);
426+ }
427+ if (response.error) {
428+ avideoAlertError(response.msg);
429+ } else {
430+ if (empty(comments_id) && page <= 1) {
431+ $('#allCommentsArea').empty();
432+ }
433+ if (response.rows && response.rows.length > 0) {
434+ $.each(response.rows, function(i, row) {
435+ mcAddComment(row, '#allCommentsArea', 0, true);
436+ });
437+ } else if (page <= 1) {
438+ $('#allCommentsArea').html('<div class="my-comments-empty"><i class="fas fa-comments fa-2x"></i><?php echo __ ('No comments found. ' ); ?> </div>');
439+ }
440+ if (response.rows && response.rows.length > 0 && (response.current * response.rowCount) < response.total) {
441+ $('#allLoadMoreBtn').show();
442+ } else {
443+ $('#allLoadMoreBtn').hide();
444+ }
445+ if (page <= 1) {
446+ $('#allBadge').text(response.total).show();
447+ }
448+ }
449+ },
450+ error: function() {
451+ modal.hidePleaseWait();
452+ if (empty(comments_id) && typeof avideoSetContainerLoading === 'function') {
453+ avideoSetContainerLoading('allCommentsArea', false);
454+ }
455+ avideoAlertError(<?php printJSString ('Error loading comments ' ) ?> );
456+ }
457+ });
458+ }
459+
387460 function openDownloadCommentsModal() {
388461 // detect active tab
389462 var activeTab = $('#myCommentsPanel .nav-tabs li.active a').attr('href');
390- var type = (activeTab === '#receivedTab') ? 'received' : 'posted';
463+ var type = 'posted';
464+ if (activeTab === '#receivedTab') {
465+ type = 'received';
466+ } else if (activeTab === '#allTab') {
467+ type = 'all';
468+ }
391469 $('#downloadCommentsType').val(type);
392470 $('#downloadCommentsModal').modal('show');
393471 }
@@ -414,6 +492,12 @@ function doDownloadComments() {
414492 loadReceivedComments(0, 1);
415493 }
416494 });
495+ $('a[href="#allTab"]').on('shown.bs.tab', function() {
496+ if (!allLoaded) {
497+ allLoaded = true;
498+ loadAllComments(0, 1);
499+ }
500+ });
417501 });
418502</script>
419503
@@ -435,6 +519,9 @@ function doDownloadComments() {
435519 <?php if ($ userCanUpload ): ?>
436520 <option value="received"><?php echo __ ('Comments on My Videos ' ); ?> </option>
437521 <?php endif ; ?>
522+ <?php if ($ userIsAdmin ): ?>
523+ <option value="all"><?php echo __ ('All Comments ' ); ?> </option>
524+ <?php endif ; ?>
438525 </select>
439526 </div>
440527 <div class="form-group">
0 commit comments