Skip to content

Commit b53de24

Browse files
committed
Added Locked Topics
1 parent 118df65 commit b53de24

File tree

9 files changed

+198
-44
lines changed

9 files changed

+198
-44
lines changed

core/classAction.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ public function validAdmin()
131131
case 'topicsticky':
132132
$this->adm->topicsticky();
133133
break;
134+
case 'topiclock':
135+
$this->adm->topiclock();
136+
break;
134137
default:
135138
$this->adm->adminhome();
136139
break;

core/classAdmin.php

Lines changed: 125 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public function adminhome()
4545
<form class="link" method="post">
4646
<input class="link" type="submit" value="Sticky Topics">
4747
<input type="hidden" name="act" value="topicsticky">
48+
</form><br>
49+
<form class="link" method="post">
50+
<input class="link" type="submit" value="Lock Topics">
51+
<input type="hidden" name="act" value="topiclock">
4852
</form><br><br>
4953
<form class="link" method="post">
5054
<input class="link" type="submit" value="Delete Post">
@@ -206,9 +210,11 @@ public function postdelete()
206210

207211
$this->pdo->exec("DELETE FROM posts WHERE pid=".$pid);
208212

209-
$sql = "SELECT pid, p_uid, p_uname, p_time FROM posts WHERE p_tid=$tid ORDER BY p_time DESC LIMIT 1;";
213+
$sql = "SELECT pid, p_uid, p_uname, p_time FROM posts
214+
WHERE p_tid=$tid ORDER BY p_time DESC LIMIT 1;";
210215
$last = $this->pdo->querySQL($sql)->fetch();
211-
$sql = "UPDATE topics SET t_lastpid=$last->pid, t_lastpuid=$last->p_uid, t_lastpuname='$last->p_uname', t_lastptime=$last->p_time WHERE tid=$tid;";
216+
$sql = "UPDATE topics SET t_lastpid=$last->pid, t_lastpuid=$last->p_uid,
217+
t_lastpuname='$last->p_uname', t_lastptime=$last->p_time WHERE tid=$tid;";
212218
$this->pdo->exec($sql);
213219
}
214220

@@ -233,7 +239,11 @@ public function postdelete()
233239
foreach($ret as $row) {
234240
?>
235241
<tr class="frame"><td class="posttop" colspan="2"></td></tr>
236-
<tr class="frame"><td class="postleft"><?php echo utf8_encode(strftime($this->datetime, $row->p_time)) ?><br><?php echo $row->p_uname ?><br>
242+
<tr class="frame"><td class="postleft">
243+
<?php
244+
echo utf8_encode(strftime($this->datetime, $row->p_time));
245+
?>
246+
<br><?php echo $row->p_uname ?><br>
237247
<?php
238248
if ($delflag) {
239249
?>
@@ -265,20 +275,32 @@ public function postdelete()
265275
<tr><td class="tnewtop" colspan="3"></td></tr>
266276
<?php
267277

268-
$sql = "SELECT tid, t_fid, t_subject, t_lastptime FROM topics
269-
ORDER BY t_lastptime DESC LIMIT 30;";
278+
$sql = "SELECT tid, t_fid, t_subject, t_lastptime, t_sticky, t_lock
279+
FROM topics ORDER BY t_lastptime DESC LIMIT 30;";
270280
$ret = $this->pdo->querySQL($sql);
271281
foreach($ret as $row) {
272282
$sql = "SELECT f_name FROM forums WHERE fid=$row->t_fid;";
273283
$fname = $this->pdo->querySQL($sql)->fetchColumn();
274284
?>
275285
<tr>
276-
<td class="tnewleft"><?php echo utf8_encode(strftime($this->datetime, $row->t_lastptime)) ?></td>
286+
<td class="tnewleft">
287+
<?php
288+
echo utf8_encode(strftime($this->datetime, $row->t_lastptime));
289+
?>
290+
</td>
277291
<td class="tnewbody">
292+
<?php
293+
if ($row->t_sticky) {
294+
echo '<span class="sticky">Sticky</span>';
295+
}
296+
if ($row->t_lock) {
297+
echo '<img class="locked" src="data/lock.png" title="Topic Locked">';
298+
}
299+
?>
278300
<form class="link" method="post">
279-
<input class="link left" type="submit" value="<?php echo $row->t_subject ?>">
280-
<input type="hidden" name="act" value="postdelete">
281-
<input type="hidden" name="tid" value="<?php echo $row->tid ?>">
301+
<input class="link left" type="submit" value="<?php echo $row->t_subject ?>">
302+
<input type="hidden" name="act" value="postdelete">
303+
<input type="hidden" name="tid" value="<?php echo $row->tid ?>">
282304
</form>
283305
</td>
284306
<td class="tnewright2"><span class="boldy"><?php echo $fname ?></span></td>
@@ -311,16 +333,28 @@ public function topicdelete()
311333
<table id="topicsnew">
312334
<tr><td class="tnewtop" colspan="3"></td></tr>
313335
<?php
314-
$sql = "SELECT tid, t_fid, t_subject, t_lastptime FROM topics
336+
$sql = "SELECT tid, t_fid, t_subject, t_lastptime, t_sticky, t_lock FROM topics
315337
ORDER BY t_lastptime DESC LIMIT 30;";
316338
$ret = $this->pdo->querySQL($sql);
317339
foreach($ret as $row) {
318340
$sql = "SELECT f_name FROM forums WHERE fid=$row->t_fid;";
319341
$fname = $this->pdo->querySQL($sql)->fetchColumn();
320342
?>
321343
<tr>
322-
<td class="tnewleft"><?php echo utf8_encode(strftime($this->datetime, $row->t_lastptime)) ?></td>
344+
<td class="tnewleft">
345+
<?php
346+
echo utf8_encode(strftime($this->datetime, $row->t_lastptime));
347+
?>
348+
</td>
323349
<td class="tnewbody">
350+
<?php
351+
if ($row->t_sticky) {
352+
echo '<span class="sticky">Sticky</span>';
353+
}
354+
if ($row->t_lock) {
355+
echo '<img class="locked" src="data/lock.png" title="Topic Locked">';
356+
}
357+
?>
324358
<form class="link" method="post">
325359
<input class="link left" type="submit" value="<?php echo $row->t_subject ?>">
326360
<input type="hidden" name="act" value="topicdelete">
@@ -354,20 +388,27 @@ public function topicsticky()
354388
<table id="topicsnew">
355389
<tr><td class="tnewtop" colspan="3"></td></tr>
356390
<?php
357-
$sql = "SELECT tid, t_fid, t_subject, t_lastptime, t_sticky FROM topics
391+
$sql = "SELECT tid, t_fid, t_subject, t_lastptime, t_sticky, t_lock FROM topics
358392
ORDER BY t_lastptime DESC LIMIT 30;";
359393
$ret = $this->pdo->querySQL($sql);
360394
foreach($ret as $row) {
361395
$sql = "SELECT f_name FROM forums WHERE fid=$row->t_fid;";
362396
$fname = $this->pdo->querySQL($sql)->fetchColumn();
363397
?>
364398
<tr>
365-
<td class="tnewleft"><?php echo utf8_encode(strftime($this->datetime, $row->t_lastptime)) ?></td>
399+
<td class="tnewleft">
400+
<?php
401+
echo utf8_encode(strftime($this->datetime, $row->t_lastptime));
402+
?>
403+
</td>
366404
<td class="tnewbody">
367405
<?php
368406
if ($row->t_sticky) {
369407
echo '<span class="sticky">Sticky</span>';
370408
}
409+
if ($row->t_lock) {
410+
echo '<img class="locked" src="data/lock.png" title="Topic Locked">';
411+
}
371412
?>
372413
<form class="link" method="post">
373414
<input class="link left" type="submit" value="<?php echo $row->t_subject ?>">
@@ -385,6 +426,61 @@ public function topicsticky()
385426
<?php
386427
}
387428

429+
public function topiclock()
430+
{
431+
if (isset($_POST['lockedtid'])) {
432+
433+
$tid = $_POST['lockedtid'];
434+
$sql = "SELECT t_lock FROM topics WHERE tid=$tid";
435+
$lock = $this->pdo->querySQL($sql)->fetchColumn();
436+
if ($lock) $new = '0';
437+
else $new = '1';
438+
$this->pdo->exec("UPDATE topics SET t_lock=$new WHERE tid=$tid");
439+
}
440+
?>
441+
<span class="boldy">Lock Topics</span><br>
442+
Click topic to change <b>Lock</b>:
443+
<table id="topicsnew">
444+
<tr><td class="tnewtop" colspan="3"></td></tr>
445+
<?php
446+
$sql = "SELECT tid, t_fid, t_subject, t_lastptime, t_sticky, t_lock FROM topics
447+
ORDER BY t_lastptime DESC LIMIT 30;";
448+
$ret = $this->pdo->querySQL($sql);
449+
foreach($ret as $row) {
450+
$sql = "SELECT f_name FROM forums WHERE fid=$row->t_fid;";
451+
$fname = $this->pdo->querySQL($sql)->fetchColumn();
452+
?>
453+
<tr>
454+
<td class="tnewleft">
455+
<?php
456+
echo utf8_encode(strftime($this->datetime, $row->t_lastptime));
457+
?>
458+
</td>
459+
<td class="tnewbody">
460+
<?php
461+
if ($row->t_sticky) {
462+
echo '<span class="sticky">Sticky</span>';
463+
}
464+
if ($row->t_lock) {
465+
echo '<img class="locked" src="data/lock.png" title="Topic Locked">';
466+
}
467+
?>
468+
<form class="link" method="post">
469+
<input class="link left" type="submit" value="<?php echo $row->t_subject ?>">
470+
<input type="hidden" name="act" value="topiclock">
471+
<input type="hidden" name="lockedtid" value="<?php echo $row->tid ?>">
472+
</form>
473+
</td>
474+
<td class="tnewright2"><span class="boldy"><?php echo $fname ?></span></td>
475+
</tr>
476+
<?php
477+
}
478+
?>
479+
</table>
480+
<div id="topicsspacer"></div>
481+
<?php
482+
}
483+
388484
public function forumdelete()
389485
{
390486
if (isset($_POST['delfid'])) {
@@ -415,11 +511,11 @@ public function forumdelete()
415511
<tr><td class="forumtop" colspan="3"></td></tr>
416512
<tr class="frame">
417513
<td class="forumleft">
418-
<form class="link" method="post">
419-
<input class="link left" type="submit" value="<?php echo $row->f_name ?>">
420-
<input type="hidden" name="act" value="forumdelete">
421-
<input type="hidden" name="delfid" value="<?php echo $row->fid ?>">
422-
</form>
514+
<form class="link" method="post">
515+
<input class="link left" type="submit" value="<?php echo $row->f_name ?>">
516+
<input type="hidden" name="act" value="forumdelete">
517+
<input type="hidden" name="delfid" value="<?php echo $row->fid ?>">
518+
</form>
423519
</td>
424520
<td class="forummiddle">
425521
<?php echo $row->f_desc ?>
@@ -564,13 +660,13 @@ public function forumrename()
564660
<tr><td class="forumtop" colspan="3"></td></tr>
565661
<tr class="frame">
566662
<td class="forumleft">
567-
<form class="link" method="post">
568-
<input class="link left" type="submit" value="<?php echo $row->f_name ?>">
569-
<input type="hidden" name="act" value="forumrename">
570-
<input type="hidden" name="renfid" value="<?php echo $row->fid ?>">
571-
<input type="hidden" name="fname" value="<?php echo $row->f_name ?>">
572-
<input type="hidden" name="fdesc" value="<?php echo $row->f_desc ?>">
573-
</form>
663+
<form class="link" method="post">
664+
<input class="link left" type="submit" value="<?php echo $row->f_name ?>">
665+
<input type="hidden" name="act" value="forumrename">
666+
<input type="hidden" name="renfid" value="<?php echo $row->fid ?>">
667+
<input type="hidden" name="fname" value="<?php echo $row->f_name ?>">
668+
<input type="hidden" name="fdesc" value="<?php echo $row->f_desc ?>">
669+
</form>
574670
</td>
575671
<td class="forummiddle">
576672
<?php echo $row->f_desc ?>
@@ -626,7 +722,8 @@ public function languages()
626722
{
627723
if (isset($_POST['newlang'])) {
628724

629-
$sql = "UPDATE settings SET setvalue='".$_POST['newlang']."' WHERE setkey='language';";
725+
$sql = "UPDATE settings SET setvalue='".$_POST['newlang'].
726+
"' WHERE setkey='language';";
630727
$ret = $this->pdo->querySQL($sql);
631728
header('location:./admin.php');
632729
exit();
@@ -662,7 +759,8 @@ public function timezones()
662759
{
663760
if (isset($_POST['newtimezone'])) {
664761

665-
$sql = "UPDATE settings SET setvalue='".$_POST['newtimezone']."' WHERE setkey='timezone';";
762+
$sql = "UPDATE settings SET setvalue='".$_POST['newtimezone']."'
763+
WHERE setkey='timezone';";
666764
$ret = $this->pdo->querySQL($sql);
667765
header('location:./admin.php');
668766
exit();

core/classDatabase.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ public function editPostUp($message, $pid)
244244
public function addTopic($fid, $fname, $subj, $uid, $uname, $time)
245245
{
246246
$sql = "INSERT INTO topics (t_fid, t_fname, t_subject, t_uid, t_uname,
247-
t_time, t_lastpuid, t_lastpuname, t_lastptime, t_sticky)
247+
t_time, t_lastpuid, t_lastpuname, t_lastptime, t_sticky, t_lock)
248248
VALUES ($fid, '$fname', '$subj', $uid, '$uname',
249-
$time, $uid, '$uname', $time, '0')";
249+
$time, $uid, '$uname', $time, '0', '0')";
250250
$ret = $this->querySQL($sql);
251251

252252
return $this->lastInsertId;
@@ -274,9 +274,8 @@ public function addTopicUpTopic($pid, $tid)
274274

275275
public function getTopicsNew($timelimit)
276276
{
277-
$sql = "SELECT tid, t_fid, t_subject, t_lastpuname, t_lastptime
278-
FROM topics
279-
WHERE t_lastptime>$timelimit ORDER BY t_lastptime DESC LIMIT 12";
277+
$sql = "SELECT * FROM topics WHERE t_lastptime>$timelimit
278+
ORDER BY t_lastptime DESC LIMIT 20";
280279
$ret = $this->querySQL($sql);
281280

282281
return $ret->fetchAll();
@@ -288,6 +287,14 @@ public function getSettings()
288287
$ret = $this->querySQL($sql);
289288

290289
return $ret->fetchAll();
291-
}
290+
}
291+
292+
public function getLock($tid)
293+
{
294+
$sql = "SELECT t_lock FROM topics WHERE tid=$tid";
295+
$ret = $this->querySQL($sql);
296+
297+
return $ret->fetchColumn();
298+
}
292299

293300
}

0 commit comments

Comments
 (0)