From d6cff8692b6829c8c68ebf61ace42c680c25544a Mon Sep 17 00:00:00 2001 From: Stefan Brannfjell Date: Fri, 4 Apr 2014 11:12:00 +0200 Subject: [PATCH] Improved player reports, adding changelog system. --- admin_news.php | 2 +- admin_reports.php | 43 ++++++++++++++++++++++++++++++++++++- changelog.php | 28 ++++++++++++++++++++++++ engine/database/connect.php | 9 ++++++++ layout/menu.php | 3 ++- onlinelist.php | 3 ++- 6 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 changelog.php diff --git a/admin_news.php b/admin_news.php index bff73b4..3a01be9 100644 --- a/admin_news.php +++ b/admin_news.php @@ -72,7 +72,7 @@ if (empty($_POST) === false) { if ($action === 's') { echo 'News successfully updated!'; list($title, $text) = array(mysql_znote_escape_string($_POST['title']), mysql_znote_escape_string($_POST['text'])); - mysql_update("UPDATE `znote_news` SET `title`='$title',`text`='$text' WHERE `id`='$id';") or die("FUCK!"); + mysql_update("UPDATE `znote_news` SET `title`='$title',`text`='$text' WHERE `id`='$id';"); $cache = new Cache('engine/cache/news'); $news = fetchAllNews(); $cache->setContent($news); diff --git a/admin_reports.php b/admin_reports.php index 77d7017..df8b3fb 100644 --- a/admin_reports.php +++ b/admin_reports.php @@ -12,6 +12,9 @@ $statusTypes = array( 4 => 'Rejected', 5 => 'Fixed' ); +// Which status IDs should give option to add to changelog? +$statusChangeLog = array(0,5); + // Autohide rows that have these status IDs: $hideStatus = array(3, 4, 5); @@ -37,10 +40,16 @@ if (!empty($_POST)) { $customPoints = getValue($_POST['customPoints']); $reportId = getValue($_POST['id']); + $changelogReportId = getValue($_POST['changelogReportId']); + $changelogValue = getValue($_POST['changelogValue']); + $changelogText = getValue($_POST['changelogText']); + $changelogStatus = ($changelogReportId !== false && $changelogValue === '2' && $changelogText !== false) ? true : false; + if ($customPoints !== false) $price = (int)($price + $customPoints); // Update SQL mysql_update("UPDATE `znote_player_reports` SET `status`='$status' WHERE `id`='$reportId' LIMIT 1;"); + echo "

Report status updated to ".$statusTypes[(int)$status] ."!

"; // Update local array representation foreach ($reports as $sid => $sa) foreach ($sa as $rid => $ra) @@ -50,6 +59,24 @@ if (!empty($_POST)) { unset($reports[$sid][$rid]); } + // If we should do anything with changelog: + if ($changelogStatus) { + $time = time(); + // Check if changelog exist (`id`, `text`, `time`, `report_id`, `status`) + $changelog = mysql_select_single("SELECT * FROM `znote_changelog` WHERE `report_id`='$changelogReportId' LIMIT 1;"); + // If changelog exist + if ($changelog !== false) { + // Update it + mysql_update("UPDATE `znote_changelog` SET `text`='$changelogText', `time`='$time' WHERE `id`='".$changelog['id']."' LIMIT 1;"); + echo "

Changelog message updated!

"; + } else { + // Create it + mysql_insert("INSERT INTO `znote_changelog` (`text`, `time`, `report_id`, `status`) + VALUES ('$changelogText', '$time', '$changelogReportId', '$status');"); + echo "

Changelog message created!

"; + } + + } // If we should give user price if ($price > 0) { $account = mysql_select_single("SELECT `a`.`id`, `a`.`email` FROM `accounts` AS `a` @@ -104,7 +131,21 @@ if (!empty($_POST)) { echo ""; } ?> - +

+ +
+ +
+ + Add / update changelog message?
+ + +
diff --git a/changelog.php b/changelog.php new file mode 100644 index 0000000..b30f3e3 --- /dev/null +++ b/changelog.php @@ -0,0 +1,28 @@ + + +

Changelog

+ + + + + + + + + + +
Changelogs

+ + + \ No newline at end of file diff --git a/engine/database/connect.php b/engine/database/connect.php index 1acb262..b64ae59 100644 --- a/engine/database/connect.php +++ b/engine/database/connect.php @@ -107,6 +107,15 @@ CREATE TABLE IF NOT EXISTS `znote_player_reports` ( PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; +CREATE TABLE IF NOT EXISTS `znote_changelog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `text` VARCHAR(255) NOT NULL, + `time` INT(11) NOT NULL, + `report_id` INT(11) NOT NULL, + `status` TINYINT(3) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + CREATE TABLE IF NOT EXISTS `znote_shop` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type` int(11) NOT NULL, diff --git a/layout/menu.php b/layout/menu.php index c276a77..15d6b2e 100644 --- a/layout/menu.php +++ b/layout/menu.php @@ -5,6 +5,7 @@
  • Community
  • - +
  • Changelog
  • \ No newline at end of file diff --git a/onlinelist.php b/onlinelist.php index 52585aa..b6efd08 100644 --- a/onlinelist.php +++ b/onlinelist.php @@ -14,7 +14,8 @@ if ($array) { '; + $url = url("characterprofile.php?name=". $value['name']); + echo ''; echo ''. $value['name'] .''; echo ''. $value['level'] .''; echo ''. vocation_id_to_name($value['vocation']) .'';