Browse Source

set News posts to add a new thread to announcement forum

ElectraHeart 7 years ago
parent
commit
7d61dca49d
3 changed files with 19 additions and 8 deletions
  1. 1
    0
      gazelle.sql
  2. 6
    2
      sections/index/private.php
  3. 12
    6
      sections/tools/index.php

+ 1
- 0
gazelle.sql View File

574
   `UserID` int(10) unsigned NOT NULL,
574
   `UserID` int(10) unsigned NOT NULL,
575
   `Title` varchar(255) NOT NULL,
575
   `Title` varchar(255) NOT NULL,
576
   `Body` text,
576
   `Body` text,
577
+  `ThreadID` int(10) unsigned DEFAULT NULL,
577
   `Time` datetime,
578
   `Time` datetime,
578
   PRIMARY KEY (`ID`),
579
   PRIMARY KEY (`ID`),
579
   KEY `UserID` (`UserID`),
580
   KEY `UserID` (`UserID`),

+ 6
- 2
sections/index/private.php View File

8
       ID,
8
       ID,
9
       Title,
9
       Title,
10
       Body,
10
       Body,
11
+      ThreadID,
11
       Time
12
       Time
12
     FROM news
13
     FROM news
13
     ORDER BY Time DESC
14
     ORDER BY Time DESC
501
 }
502
 }
502
 $Count = 0;
503
 $Count = 0;
503
 foreach ($News as $NewsItem) {
504
 foreach ($News as $NewsItem) {
504
-  list($NewsID, $Title, $Body, $NewsTime) = $NewsItem;
505
+  list($NewsID, $Title, $Body, $ThreadID, $NewsTime) = $NewsItem;
505
   if (strtotime($NewsTime) > time()) {
506
   if (strtotime($NewsTime) > time()) {
506
     continue;
507
     continue;
507
   }
508
   }
514
 <?  } ?>
515
 <?  } ?>
515
       <span class="float_right"><a data-toggle-target="#newsbody<?=$NewsID?>" data-toggle-replace="Show" class="brackets">Hide</a></span>
516
       <span class="float_right"><a data-toggle-target="#newsbody<?=$NewsID?>" data-toggle-replace="Show" class="brackets">Hide</a></span>
516
       </div>
517
       </div>
517
-      <div id="newsbody<?=$NewsID?>" class="pad"><?=Text::full_format($Body)?></div>
518
+      <div id="newsbody<?=$NewsID?>" class="pad">
519
+		<?=Text::full_format($Body)?>
520
+		<div class="news_link_to_forum"><a href="forums.php?action=viewthread&amp;threadid=<?=$ThreadID?>">Discuss this post in the forums</a></div>
521
+	  </div>
518
     </div>
522
     </div>
519
 <?
523
 <?
520
   if (++$Count > ($NewsCount - 1)) {
524
   if (++$Count > ($NewsCount - 1)) {

+ 12
- 6
sections/tools/index.php View File

171
       error(403);
171
       error(403);
172
     }
172
     }
173
 
173
 
174
-    $DB->query("
175
-      INSERT INTO news (UserID, Title, Body, Time)
176
-      VALUES ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', NOW())");
177
-    $Cache->delete_value('news_latest_id');
178
-    $Cache->delete_value('news_latest_title');
179
-    $Cache->delete_value('news');
174
+	$ThreadID = Misc::create_thread(ANNOUNCEMENT_FORUM_ID, $LoggedUser['ID'], $_POST['title'], $_POST['body']);
175
+	if ($ThreadID < 1) {
176
+	  error(0);
177
+	} else {
178
+		$DB->query("
179
+	      INSERT INTO news (UserID, Title, Body, ThreadID, Time)
180
+	      VALUES ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', 
181
+		  $ThreadID, NOW())");
182
+	    $Cache->delete_value('news_latest_id');
183
+	    $Cache->delete_value('news_latest_title');
184
+	    $Cache->delete_value('news');
185
+	}
180
 
186
 
181
     header('Location: index.php');
187
     header('Location: index.php');
182
     break;
188
     break;

Loading…
Cancel
Save