diff --git a/config.php b/config.php index a2aeb21..e23c2d5 100644 --- a/config.php +++ b/config.php @@ -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); + ?> diff --git a/inc/controllers/MainController.class.php b/inc/controllers/MainController.class.php index 45117a2..c3fb9a5 100644 --- a/inc/controllers/MainController.class.php +++ b/inc/controllers/MainController.class.php @@ -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 #'.$_GET['id'].'?'); break; + case 'sticktopic': + if ($t['topic_sticky'] == false) + $this->getView('MainView')->confirm_action('Do you want stick topic #'.$_GET['id'].'?'); + else + $this->getView('MainView')->confirm_action('Do you want unstick topic #'.$_GET['id'].'?'); + break; case 'movetopic': $this->getView('MainView')->putExistingModel('PostsModel', $this->getModel('PostsModel')); $this->getView('MainView')->move_topic(); diff --git a/inc/models/ForumsModel.class.php b/inc/models/ForumsModel.class.php index e22edb7..30ed5a8 100644 --- a/inc/models/ForumsModel.class.php +++ b/inc/models/ForumsModel.class.php @@ -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 diff --git a/inc/models/PostsModel.class.php b/inc/models/PostsModel.class.php index b78c5c2..7b8552a 100644 --- a/inc/models/PostsModel.class.php +++ b/inc/models/PostsModel.class.php @@ -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.'\';'; diff --git a/templates/images/stick.gif b/templates/images/stick.gif new file mode 100644 index 0000000..a1073bb Binary files /dev/null and b/templates/images/stick.gif differ diff --git a/templates/images/unstick.gif b/templates/images/unstick.gif new file mode 100644 index 0000000..e78a19d Binary files /dev/null and b/templates/images/unstick.gif differ diff --git a/templates/styles.css b/templates/styles.css index 4b82569..1db1dea 100644 --- a/templates/styles.css +++ b/templates/styles.css @@ -380,7 +380,7 @@ hr { } .topic_mod { - width: 80px; + width: 100px; float: right; } .p_uinfo { diff --git a/templates/viewforum.tpl.php b/templates/viewforum.tpl.php index 99a136d..b84e8c7 100755 --- a/templates/viewforum.tpl.php +++ b/templates/viewforum.tpl.php @@ -25,7 +25,8 @@ for ($i=0; $iTPL['topics_list']); $i++) { echo '
'."\n"; - echo "\t\t\t".''."\n"; + $sticky = ($this->TPL['topics_list'][$i]['sticky']) ? 'Sticky: ' : ''; + echo "\t\t\t".''."\n"; echo "\t\t\t".'
'; if ($this->TPL['topics_list'][$i]['user_id'] != null) echo ''.$this->colorRank($this->TPL['topics_list'][$i]['user_nick'], $this->TPL['topics_list'][$i]['user_rank']).''; diff --git a/templates/viewtopic.tpl.php b/templates/viewtopic.tpl.php index 80cc530..c98cf36 100755 --- a/templates/viewtopic.tpl.php +++ b/templates/viewtopic.tpl.php @@ -108,6 +108,9 @@