Browse Source

added feature: stick/unstick topic

master
Piotr Dergun 9 years ago
parent
commit
9bae4628a0
9 changed files with 40 additions and 4 deletions
  1. +4
    -0
      config.php
  2. +21
    -0
      inc/controllers/MainController.class.php
  3. +1
    -1
      inc/models/ForumsModel.class.php
  4. +8
    -1
      inc/models/PostsModel.class.php
  5. BIN
      templates/images/stick.gif
  6. BIN
      templates/images/unstick.gif
  7. +1
    -1
      templates/styles.css
  8. +2
    -1
      templates/viewforum.tpl.php
  9. +3
    -0
      templates/viewtopic.tpl.php

+ 4
- 0
config.php View File

@ -17,4 +17,8 @@ define('FORUM_PATH', '/uf2');
define('HTTP_PORT', 81);
define('HTTPS_PORT', 443);
define('USE_HTTPS', true);
define('RANDOM_STRING', 'oVadvzFdxAezvuknUNXdQLoQMkQwrQuAbFPYfLIKfPWzbciVNkOfTWAdWKXexYZpZycXoxJmAXkRGsoZzwijGUQcdtYTwxtzWLiQjMpfAQgMLUeoTvkYUMmxvVPLmKJDsCFwhqWIGBLAqRnDnUOwCTEKvLvdzOyc');
define('SALT_LENGTH', 20);
?>

+ 21
- 0
inc/controllers/MainController.class.php View File

@ -164,6 +164,7 @@ class MainController extends Controller
{
case 'deletetopic':
case 'locktopic':
case 'sticktopic':
case 'movetopic':
$t = $this->getModel('PostsModel')->getTopic($_GET['id']);
@ -232,6 +233,19 @@ class MainController extends Controller
}
$lockv = true;
break;
case 'sticktopic':
if ($t['topic_sticky'] == false)
{
$this->getModel('PostsModel')->stickTopic($_GET['id']);
$this->getView('MainView')->forum_message('Topic sticked. Redirecting...', buildURL('index.php?mode=viewtopic&id='.$_GET['id']));
}
else
{
$this->getModel('PostsModel')->stickTopic($_GET['id'], false);
$this->getView('MainView')->forum_message('Topic unsticked. Redirecting...', buildURL('index.php?mode=viewtopic&id='.$_GET['id']));
}
$lockv = true;
break;
case 'movetopic':
if ($this->getModel('ForumsModel')->getForum($_POST['forum_id']) == null)
$this->getView('MainView')->forum_message('Forum does not exist!', buildURL('index.php?mode=viewtopic&id='.$_GET['id']));
@ -251,6 +265,7 @@ class MainController extends Controller
{
case 'deletetopic':
case 'locktopic':
case 'sticktopic':
case 'movetopic':
$this->forward(buildURL('index.php?mode=viewtopic&id='.$_GET['id']));
break;
@ -276,6 +291,12 @@ class MainController extends Controller
else
$this->getView('MainView')->confirm_action('Do you want unlock topic <span style="font-weight: bold">#'.$_GET['id'].'</span>?');
break;
case 'sticktopic':
if ($t['topic_sticky'] == false)
$this->getView('MainView')->confirm_action('Do you want stick topic <span style="font-weight: bold">#'.$_GET['id'].'</span>?');
else
$this->getView('MainView')->confirm_action('Do you want unstick topic <span style="font-weight: bold">#'.$_GET['id'].'</span>?');
break;
case 'movetopic':
$this->getView('MainView')->putExistingModel('PostsModel', $this->getModel('PostsModel'));
$this->getView('MainView')->move_topic();

+ 1
- 1
inc/models/ForumsModel.class.php View File

@ -45,7 +45,7 @@ class ForumsModel extends Model
public function getTopics($forum_id)
{
$out = $this->select(TOPICS_VIEW, '*', 'forum_id=\''.$forum_id.'\'', 'lastpost_post_id DESC');
$out = $this->select(TOPICS_VIEW, '*', 'forum_id=\''.$forum_id.'\'', 'sticky DESC,lastpost_post_id DESC');
if (count($out) > 0)
return $out;
else

+ 8
- 1
inc/models/PostsModel.class.php View File

@ -18,7 +18,7 @@ class PostsModel extends Model
{
$query = '
SELECT
t.topic_id as topic_id, t.title as topic_title, t.locked as topic_locked, t.forum_id as forum_id, f.name as forum_name, f.locked as forum_locked, pc.post_count as post_count
t.topic_id as topic_id, t.title as topic_title, t.sticky as topic_sticky, t.locked as topic_locked, t.forum_id as forum_id, f.name as forum_name, f.locked as forum_locked, pc.post_count as post_count
FROM '.TOPICS_TABLE.' t
LEFT JOIN '.FORUMS_TABLE.' f ON f.forum_id = t.forum_id
LEFT JOIN '.TOPICS_PC_VIEW.' pc ON pc.topic_id = t.topic_id
@ -82,6 +82,13 @@ class PostsModel extends Model
$this->db->query($query);
}
public function stickTopic($topic_id, $sticky = true)
{
$query = 'UPDATE '.TOPICS_TABLE.' SET sticky=\''.$sticky.'\' WHERE topic_id=\''.$topic_id.'\';';
$this->db->query($query);
}
public function moveTopic($topic_id, $forum_id)
{
$query = 'UPDATE '.TOPICS_TABLE.' SET forum_id=\''.$forum_id.'\' WHERE topic_id=\''.$topic_id.'\';';

BIN
templates/images/stick.gif View File

Before After
Width: 19  |  Height: 18  |  Size: 1.0 KiB

BIN
templates/images/unstick.gif View File

Before After
Width: 15  |  Height: 19  |  Size: 1.1 KiB

+ 1
- 1
templates/styles.css View File

@ -380,7 +380,7 @@ hr {
}
.topic_mod {
width: 80px;
width: 100px;
float: right;
}
.p_uinfo {

+ 2
- 1
templates/viewforum.tpl.php View File

@ -25,7 +25,8 @@
for ($i=0; $i<count($this->TPL['topics_list']); $i++)
{
echo '<div class="row">'."\n";
echo "\t\t\t".'<div class="tc1"><a href="index.php?mode=viewtopic&amp;id='.$this->TPL['topics_list'][$i]['topic_id'].'" class="sect">'.$this->TPL['topics_list'][$i]['topic_title'].'</a></div>'."\n";
$sticky = ($this->TPL['topics_list'][$i]['sticky']) ? '<span style="font-weight: bold">Sticky</span>: ' : '';
echo "\t\t\t".'<div class="tc1"><a href="index.php?mode=viewtopic&amp;id='.$this->TPL['topics_list'][$i]['topic_id'].'">'.$sticky.$this->TPL['topics_list'][$i]['topic_title'].'</a></div>'."\n";
echo "\t\t\t".'<div class="tc2" style="width: 150px">';
if ($this->TPL['topics_list'][$i]['user_id'] != null)
echo '<a href="index.php?mode=viewprofile&amp;id='.$this->TPL['topics_list'][$i]['user_id'].'">'.$this->colorRank($this->TPL['topics_list'][$i]['user_nick'], $this->TPL['topics_list'][$i]['user_rank']).'</a>';

+ 3
- 0
templates/viewtopic.tpl.php View File

@ -108,6 +108,9 @@
</div>
<div class="row">
<div class="tc1 tc4">
<a href="index.php?mode=moderate&amp;submode=sticktopic&amp;id=<?= $_GET['id']; ?>">
<img src="templates/images/<? if ($this->TPL['topic_info']['topic_sticky']) echo 'un'; ?>stick.gif" alt="stick">
</a>
<a href="index.php?mode=moderate&amp;submode=deletetopic&amp;id=<?= $_GET['id']; ?>">
<img src="templates/images/delete.gif" alt="delete">
</a>

Loading…
Cancel
Save