YaWK  24.1
Yet another WebKit
blog-comments.php
Go to the documentation of this file.
1 <?php
2 include '../system/plugins/blog/classes/blog.php';
3 // check if blog object is set
4 if (!isset($blog)) { $blog = new \YAWK\PLUGINS\BLOG\blog(); }
5 // check if language is set
6 if (!isset($language) || (!isset($lang)))
7 { // inject (add) language tags to core $lang array
8  $lang = \YAWK\language::inject(@$lang, "../system/plugins/blog/language/");
9 }
10 
11 // TOGGLE COMMENT ON/OFF
12 if (isset($_GET['toggle']))
13 { // check if published state and id are sent
14  if (isset($_GET['published']) && (isset($_GET['id'])))
15  { // check and switch state
16  if ($_GET['published'] === '1')
17  { $_GET['published'] = 0; $status = "offline"; }
18  else
19  { $_GET['published'] = 1; $status = "online"; }
20  // finally: toggle the comment state
21  if ($blog->toggleCommentOffline($db, $_GET['id'], $_GET['published']))
22  { // success, notify user
23  print \YAWK\alert::draw("success", "Comment is now $status.", "Comment is now $status", "", 800);
24  }
25  else
26  { // toggle did not work, throw error
27  print \YAWK\alert::draw("danger", "Error: Could not toggle comment status.", "Comment is still $status", "", 5800);
28  }
29  }
30 }
31 
32 // DELETE COMMENT
33 if (isset($_GET['deletecomment']))
34 { // delete, if true
35  if ($_GET['deletecomment'] === "true") {
36  // check vars
37  if (isset($_GET['commentid']) && (isset($_GET['itemid']) && (isset($_GET['blogid'])))) {
38  // ok, do it...
39  if ($blog->deleteComment($db, $_GET['blogid'], $_GET['itemid'], $_GET['commentid'])) {
40  \YAWK\alert::draw("success", "Success! ", "Comment deleted.", "","800");
41  }
42  else
43  { // throw error
44  \YAWK\alert::draw("danger", "Error: ", "Could not delete comment ID: " . $_GET['commentid'] . " from Blog: ".$_GET['blogid']." ", "","5800");
45  }
46  }
47  }
48 }
49 
50 if (isset($_GET['blogid'])) {
51  $blog->id = $_GET['blogid'];
52  if (isset($_GET['itemid'])){
53  $blog->itemid = $_GET['itemid'];
54  $sqlAddon = "AND itemid = ".$blog->itemid."";
55  $refreshBtnAddon = "&itemid=".$blog->itemid."";
56  } else {
57  $sqlAddon = '';
58  $refreshBtnAddon = '';
59  }
60 } else {
61  $blog->id = 1;
62 }
63 
64 // set blog object properties
65 $blog->name = $blog->getBlogProperty($db, $blog->id, "name");
66 $blog->icon = $blog->getBlogProperty($db, $blog->id, "icon");
67 
68 ?>
69 <script type="text/javascript">
70  $(document).ready(function () {
71  $('#table-sort').dataTable({
72  "bPaginate": false,
73  "bLengthChange": false,
74  "bFilter": true,
75  "bSort": true,
76  "bInfo": true,
77  "bAutoWidth": false
78  });
79  });
80 </script>
81 <?php
82 // TEMPLATE WRAPPER - HEADER & breadcrumbs
83 echo "
84  <!-- Content Wrapper. Contains page content -->
85  <div class=\"content-wrapper\" id=\"content-FX\">
86  <!-- Content Header (Page header) -->
87  <section class=\"content-header\">";
88 /* draw Title on top */
89 \YAWK\PLUGINS\BLOG\blog::getBlogTitle($lang['COMMENTS'], "$lang[IN_BLOG] $blog->name", $blog->icon);
90 echo"<ol class=\"breadcrumb\">
91  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
92  <li><a href=\"index.php?page=plugins\" title=\"$lang[PLUGINS]\"> $lang[PLUGINS]</a></li>
93  <li><a href=\"index.php?plugin=blog\" title=\"$lang[BLOG]\"> $lang[BLOG]</a></li>
94  <li class=\"active\"><a href=\"index.php?plugin=&pluginpage=blog-comments\" title=\"$lang[COMMENTS]\"> $lang[COMMENTS]</a></li>
95  </ol>
96  </section>
97  <!-- Main content -->
98  <section class=\"content\">";
99 /* page content start here */
100 ?>
101 <div class="box box-default">
102  <div class="box-body">
103 
104 <a class="btn btn-success" href="index.php?plugin=blog&pluginpage=blog-comments<?php echo $refreshBtnAddon; ?>&blogid=<?php echo $blog->id; ?>" style="float:right;">
105 <i class="glyphicon glyphicon-repeat"></i> &nbsp;<?php print $lang['REFRESH']; ?></a>
106 <a class="btn btn-default" href="index.php?plugin=blog" style="float:right;">
107 <i class="glyphicon glyphicon-backward"></i> &nbsp;<?php print $lang['BACK']; ?></a>
108 
109 <table width="100%" cellpadding="4" cellspacing="0" border="0" class="table table-hover" id="table-sort">
110  <thead>
111  <tr>
112  <td width="3%"><strong>&nbsp;</strong></td>
113  <td width="3%" class=\"text-left\"><strong><?php echo $lang['GROUP']; ?></strong></td>
114  <td width="13%" class=\"text-left\"><strong><?php echo $lang['USER']; ?></strong></td>
115  <td width="14%" class=\"text-center\"><strong><?php echo $lang['DATE']; ?></strong></td>
116  <td width="57%"><strong><?php echo $lang['COMMENT']; ?></strong></td>
117  <td width="5%" class=\"text-center\"><strong><?php echo $lang['ID']; ?></strong></td>
118  <td width="5%" class=\"text-center\"><strong><?php echo $lang['ACTIONS']; ?></strong></td>
119  </tr>
120  </thead>
121  <tbody>
122  <?php
123 /*
124  $res = mysqli_query($connection, "SELECT ci.*, cu.username as username, cg.value as gid FROM " . $dbprefix . "blog_comments as ci
125  INNER JOIN " . $dbprefix . "users as cu on ci.uid = cu.id
126  INNER JOIN " . $dbprefix . "user_groups as cg on ci.gid = cg.id WHERE blogid = '" . $blog->id . "'".$sqlAddon." ORDER BY date_created DESC");
127 */
128 
129  $res = $db->query("SELECT * FROM {blog_comments}
130  WHERE blogid = '".$blog->id."' ".$sqlAddon." ORDER BY date_created DESC");
131  while ($row = mysqli_fetch_assoc($res)) {
132 
133  if ($row['uid'] === '0' && ($row['gid'] === '0')){
134  $comment_user = $row['name'];
135  }
136  else {
137  if (!isset($user))
138  {
139  $user = new \YAWK\user($db);
140  }
141  $comment_user = $user->getProperty($db, $row['uid'], "username");
142  }
143 
144  // on / off badge logic
145  switch ($row['published']) {
146  case 0:
147  $pub = "danger";
148  $pubtext = "$lang[OFFLINE]";
149  break;
150  case 1:
151  $pub = "success";
152  $pubtext = "$lang[ONLINE]";
153  break;
154  }
155 
156  // group id badge logic
157  switch ($row['gid']) {
158  case "1":
159  $color = "success";
160  $label = "public";
161  break;
162  case "2":
163  $color = "warning";
164  $label = "user";
165  break;
166  case "3":
167  $color = "info";
168  $label = "author";
169  break;
170  case "4":
171  $color = "info";
172  $label = "admin";
173  break;
174  case "5":
175  $color = "danger";
176  $label = "root";
177  break;
178  default:
179  $color = "success";
180  $label = "public";
181  break;
182  }
183  // draw table and badges
184  echo "<tr>
185  <td class=\"text-left\">
186  <a href=\"index.php?plugin=blog&pluginpage=blog-comments&toggle=1&published=" . $row['published'] . "&blogid=" . $blog->id . "&id=" . $row['id'] . "\">
187  <span class=\"label label-$pub\">".$pubtext."</span></a>&nbsp;</td>
188 
189  <td class=\"text-leftcleft>
190  <span class=\"label label-$color\">".$label."</span></td>
191 
192  <td class=\"text-center\">".$comment_user."</td>
193 
194  <td><a href=\"index.php?plugin=blog&pluginpage=blog-edit&itemid=" . $row['id'] . "&blogid=" . $blog->id . "\"><div style=\"width:100%\">" . $row['date_created'] . "</div></a></td>
195  <td><a href=\"index.php?plugin=blog&pluginpage=blog-edit&itemid=" . $row['id'] . "&blogid=" . $blog->id . "\" style=\"color: #7A7376;\"><div style=\"width:100%\">" . $row['comment'] . "</div></a></td>
196 
197  <td>" . $row['id'] . "</td>
198 
199  <td class=\"text-center\">
200 
201  <a class=\"icon icon-trash\" data-confirm=\"$lang[DEL_COMMENT] &laquo;" . $comment_user . " - " . $row['comment'] . "&raquo;\" title=\"DELETE " . $row['id'] . "\" href=\"index.php?plugin=blog&pluginpage=blog-deletecomment&item=kill&commentid=".$row['id']."&blogid=".$blog->id."&itemid=".$row['itemid']."&delete=true\">
202  </a>
203 
204  <a class=\"fa fa-trash-o\" role=\"dialog\" data-confirm=\"$lang[DEL_ENTRY] &laquo;" . $row['id'] . " / " . $row['comment'] . "&raquo;\"
205  title=\"" . $lang['DEL'] . "\" href=\"index.php?plugin=blog&pluginpage=blog-comments&blogid=" . $blog->id . "&commentid=" . $row['id'] . "&itemid=" . $row['itemid'] . "&deletecomment=true\">
206  </a>
207  </td>
208  </tr>";
209  }
210  ?>
211  </tbody>
212 </table>
213  </div>
214 </div>
$blog
Definition: blog.php:122
print $lang['REFRESH']
print $blog blogid
Definition: blog-edit.php:376
$blog gid
Definition: blog-setup.php:139
static draw($type, $title, $text, $redirect, $delay)
Definition: alert.php:30
static inject(array $lang, string $pathToFile)
allow plugins to inject language tags to $lang array
Definition: language.php:439
FuckAdBlock prototype on
Definition: fuckAdBlock.js:227
function a
Definition: browser.js:14
c jPlayer warning
type
Definition: menu-new.php:35
print $_GET['id']
Definition: page-edit.php:357
function i(e, t)
Definition: plyr.js:1
<!-- backend language -->< h3 >< i class="fa fa-language"></i > & nbsp
document ready(function() { $('a[data-confirm]').click(function(ev) { modal='#dataConfirmModal';var href=$(this).attr('href');var title=$(this).attr('title');var icon=$(this).attr('data-icon');if(!icon) { icon='fa fa-trash-o';} if(!$(modal).length) { $('body').append('< div id="dataConfirmModal" class="modal fade" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true">< div class="modal-dialog">< div class="modal-content">< div class="modal-header">< button type="button" class="close" data-dismiss="modal" aria-hidden="true">< i class="fa fa-times"></i ></button >< br >< div class="col-md-1">< h3 class="modal-title">< i class="'+icon+'"></i ></h3 ></div >< div class="col-md-11">< h3 class="modal-title" id="dataConfirmLabel">'+title+'</h3 ></div ></h3 ></div >< div class="modal-body"></div >< div class="modal-footer">< button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">Abbrechen</button >< a type="button" class="btn btn-danger" id="dataConfirmOK">< i class="'+icon+'"></i > L &ouml;schen</a ></div ></div ></div ></div >');} $(modal).find('.modal-body').text($(this).attr('data-confirm'));$('#dataConfirmOK').attr('href', href);$(modal).modal({show:true});return false;});$('#terminateUser').click(function() { var terminate=window.confirm("ACHTUNG!\nDas wird Deinen Account permanent deaktivieren.\n"+"Bist Du Dir sicher, dass Du das tun willst?");if(terminate===true) { var terminateUser=window.confirm("Bist Du Dir wirklich ganz sicher?\n"+"Diese Aktion kann nicht rueckgaengig gemacht werden.");if(terminateUser===true) { $.get('system/templates/YaWK-bootstrap3/js/terminate-user.php', function(data) { if(data==="true") { setTimeout("window.location='logout.html'", 0);} else { alert("Fehler: "+data);} });} } });function dismissNotifications() { $.ajax({ url:'js/dismiss-notifications.php', type:'POST', success:function(data) { if(!data) { alert('Something went wrong!');return false;} } });$("#bell-label").fadeOut();$('#notification-header').html('You have 0 notifications');$('#notification-menu').fadeOut();} $("#dismiss").click(function() { dismissNotifications();});function disableButtons(delay) { $('#loginButton').removeClass().addClass('btn btn-success disabled').attr('id', 'LOGIN_FORBIDDEN');$('#resetPasswordButton').removeClass().addClass('btn btn-danger disabled');setTimeout(function() { $('#LOGIN_FORBIDDEN').attr('id', 'loginButton').removeClass().addClass('btn btn-success');$('#resetPasswordButton').removeClass().addClass('btn btn-danger');}, delay);} $("#loginButton").click(function(){ if($('#loginButton').length > 0) { if($('#loginButton').hasClass('btn') &&$('#loginButton').hasClass('btn-success') &&$('#loginButton').hasClass('disabled')) { } else { $("#loginForm").submit();disableButtons(10000);} } else if($('#LOGIN_FORBIDDEN').length > 0) { if($('#LOGIN_FORBIDDEN').hasClass('btn') &&$('#LOGIN_FORBIDDEN').hasClass('btn-success') &&$('#LOGIN_FORBIDDEN').hasClass('disabled')) { } else { } } });$("#blockedBtn").hover(function() { $("#blockedBtn").hide();$("#askBtn").fadeIn(820);});})