Permalink
Browse files

webui php now uses libAurora.php for news management (groups as news …

…sources)
  • Loading branch information...
1 parent d6394c9 commit 9ee8d15eac5563116b90736044a96a50aebb322d @SignpostMarv committed Apr 10, 2012
Binary file not shown.
@@ -1,16 +1,16 @@
<?php
+use Aurora\Addon\WebUI\Configs;
if(!isset($_SESSION['ADMINID'])){
header('Location: ' . SYSURL . 'index.php?page=home');
exit;
}
-if(isset($_POST['insert']) && $_POST['insert'] == '1') {
- $DbLink = new DB;
- $DbLink->query("INSERT INTO " . C_NEWS_TBL . " SET title='" . cleanQuery($_POST['title']) . "',message='" . cleanQuery($_POST['message']) . "', time='" . time() . "', user='" . cleanQuery($_SESSION['NAME']) . "'");
- $DbLink->close();
+if(isset($_POST['group'], $_POST['title'], $_POST['message'])){
+ $noticeID = Configs::d()->AddGroupNotice($_POST['group'], $_SESSION['ADMINID'], $_POST['title'], $_POST['message']);
- header('Location: ' . SYSURL . 'index.php?page=adminnewsmanager');
+ header('Location: ' . SYSURL . 'index.php?page=adminnewsmanager#' . $noticeID);
exit;
}
+$newsSources = Configs::d()->GetNewsSources();
?>
<div id="content">
@@ -19,28 +19,28 @@
<div id="ContentHeaderRight"><h5><?php echo $webui_admin_create_news; ?></h5></div>
<div id="createnews">
<div id="info"><p><?php echo $webui_admin_create_news_info ?></p></div>
-
-<?php
-$DbLink = new DB;
-$DbLink->query("SELECT id,title,message from " . C_NEWS_TBL . " WHERE id = '" . cleanQuery($_GET[editid]) . "'");
-
-if ($DbLink->num_rows() != 0) {
- list($id, $title, $message) = $DbLink->next_record();
-}
-$DbLink->clean_results();
-$DbLink->close();
-?>
<form name="update" method="post" action="index.php?page=news_add">
- <input type='hidden' name='insert' value='1'>
- <input type='hidden' name='id' value='<?php echo $id; ?>'>
<table width="90%" align="center" cellpadding="2" cellspacing="3">
+
<tr>
- <td><font color="#fff"><b> <?php echo $webui_admin_news_title; ?>:<br /><input name="title" value="<?php echo $title; ?>" style="width:100%" type="text" maxlength="255" /></b></font>
+ <td><font color="#fff"><b> <?php echo $webui_admin_news_title; ?>:<br /><input name="title" value="" style="width:100%" type="text" maxlength="255" /></b></font>
+ <td><label for="news-source">Group: </label><br /><?php # note: as of the time of writing, the word Group is not listed in the language files so this needs to be fixed at a later date. ?>
+
+<?php if($newsSources->count() > 0){ ?>
+ <select id="news-source" name="group">
+<?php foreach($newsSources as $group){ ?>
+ <option value="<?php echo $group->GroupID(); ?>" <?php if($newsSources->count() === 1){ ?>selected <?php } ?>><?php echo htmlentities($group->GroupName()); ?></option>
+
+<?php } ?>
+ </select>
+
+<?php }else{ ?>
+ <p class="error">There are no groups as news sources, type <code>webui add group as news source</code> into the Aurora-Sim console to add a group.</p><?php # as with the word Group, this hasn't been translated yet. ?>
+
+<?php } ?>
</tr>
- </table>
- <table>
<tr>
- <td><textarea name="message" style="width:100%; height:350px;"><?php echo $message; ?></textarea></td>
+ <td colspan="2"><textarea name="message" style="width:100%; height:350px;"></textarea></td>
</tr>
</table>
<div align="center"><button id="create_news_button" type="Submit" name="Submit"><?php echo $webui_admin_create_news; ?></button>
@@ -1,33 +1,42 @@
<?php
+use Aurora\Addon\WebUI\Configs;
if(!isset($_SESSION['ADMINID'])){
header('Location: ' . SYSURL . 'index.php?page=home');
exit;
}
+$error = null;
if(isset($_POST['update']) && $_POST['update'] == '1'){
- $DbLink = new DB;
- $DbLink->query("UPDATE " . C_NEWS_TBL . " SET title='" . cleanQuery($_POST['title']) . "',message='" . cleanQuery($_POST['message']) . "' WHERE id='" . cleanQuery($_POST['id']) . "'");
- $DbLink->close();
-
- header('Location: ' . SYSURL . 'index.php?page=adminnewsmanager');
- exit;
+ if(Configs::d()->EditGroupNotice($_POST['id'], $_POST['title'], $_POST['message'])){
+ header('Location: ' . SYSURL . 'index.php?page=adminnewsmanager');
+ exit;
+ }else{
+ $error = 'Failed to update group notice.';
+ }
}
?>
<div id="content">
<div id="ContentHeaderLeft"><h5><?php echo SYSNAME; ?></h5></div>
<div id="ContentHeaderCenter"></div>
<div id="ContentHeaderRight"><h5><?php echo $webui_admin_edit_news; ?></h5></div>
<div id="createnews">
- <div id="info"><p><?php echo $webui_admin_edit_news_info ?></p></div>
<?php
-$DbLink = new DB;
-$DbLink->query("SELECT id,title,message from " . C_NEWS_TBL . " WHERE id = '" . cleanQuery($_GET['editid']) . "'");
-if($DbLink->num_rows() != 0){
- list($id, $title, $message) = $DbLink->next_record();
+try{
+ $newsItem = Configs::d()->GetGroupNotice($_GET['editid']);
+}catch(Aurora\Addon\Exception $e){
+?>
+ <div id="info"><p><?php echo $e->getMessage(); ?></p></div>
+ </div>
+</div>
+
+<?php
+ return;
}
-$DbLink->clean_results();
-$DbLink->close();
+$id = $newsItem->NoticeID();
+$title = $newsItem->Subject();
+$message = $newsItem->Message();
?>
+ <div id="info"><p><?php echo $webui_admin_edit_news_info ?></p><?php if(isset($error)){ ?><p><?php echo $error; ?></p><?php } ?></div>
<form name="update" method="post" action="index.php?page=news_edit">
<input type='hidden' name='update' value='1'>
<input type='hidden' name='id' value='<?php echo $id; ?>'>
@@ -1,13 +1,21 @@
<?php
+use Aurora\Addon\WebUI\Configs;
if(!isset($_SESSION['ADMINID'])){
header('Location: ' . SYSURL . 'index.php?page=home');
exit;
}
-$DbLink = new DB;
+$error = null;
if(isset($_GET['delete']) && $_GET['delete'] == 1){
- $DbLink->query("DELETE from " . C_NEWS_TBL . " WHERE (id = '" . cleanQuery($_GET['id']) . "')");
+ try{
+ $notice = Configs::d()->GetGroupNotice($_GET['id']);
+ if(!Configs::d()->RemoveGroupNotice($notice->GroupID(), $notice->NoticeID())){
+ $error = sprintf('Group notice with id %s was not deleted.', $notice->NoticeID());
+ }
+ }catch(Aurora\Addon\Exception $e){
+ $error = $e->getMessage();
+ }
}
?>
<div id="content">
@@ -21,30 +29,45 @@
<div id="ContentNewsRight"><a href="index.php?page=news_add"><?php echo $webui_admin_create_news ?></a></div>
<div class="clear"></div>
<div id="news_online">
+<?php if(isset($error)){ ?>
+ <div id="info"><p><?php echo htmlentities($error); ?></p></div>
+
+<?php } ?>
<table>
<tr>
<td><b><?php echo $webui_admin_news_title ?></b></td>
<td><b><?php echo $webui_admin_news_date ?></b></td>
<td colspan=2></td>
</tr>
<?php
-$DbLink->query("SELECT id,title,time from " . C_NEWS_TBL . " ORDER BY time DESC");
-while (list($id, $title, $TIME) = $DbLink->next_record()){
- if (strlen($title) > 67){
- $title = substr($title, 0, 32) . '...';
- }
+$news = Configs::d()->NewsFromGroupNotices(0,1);
+if($news->count() >= 1){
+ foreach(Configs::d()->NewsFromGroupNotices(0, $news->count()) as $newsItem){
+ $id = $newsItem->NoticeID();
+ $title = $newsItem->Subject();
+ $TIME = $newsItem->Timestamp();
+ if (strlen($title) > 67){
+ $title = substr($title, 0, 32) . '...';
+ }
?>
<tr><td colspan="4"></td></tr>
<tr><td colspan="4"></td></tr>
<tr><td colspan="4"></td></tr>
<tr>
<td><b><?php echo date("l M d Y", $TIME); ?></b></td>
<td><?php echo $title ?></td>
- <td><a href=index.php?page=news_edit&editid=<?php echo $id; ?>><?php echo $webui_admin_news_edit ?></a></td>
- <td><a href=index.php?page=adminloginscreen&delete=1&id=<?php echo $id; ?>><?php echo $webui_admin_news_delete ?></a></td>
+ <td><a href="index.php?page=news_edit&editid=<?php echo $id; ?>"><?php echo $webui_admin_news_edit ?></a></td>
+ <td><a href="index.php?page=adminnewsmanager&delete=1&id=<?php echo $id; ?>"><?php echo $webui_admin_news_delete ?></a></td>
</tr>
<tr><td colspan="4"><hr /></td></tr>
-<?php } ?>
+<?php
+ }
+}else{
+?>
+ <tr><td colspan="4">There is no news.</td></tr>
+<?php
+}
+?>
</table>
</div>
</div>

0 comments on commit 9ee8d15

Please sign in to comment.