Gazelle/sections/tools/managers/change_log.php

111 lines
3.0 KiB
PHP
Raw Normal View History

2013-06-15 08:00:45 +00:00
<?
$PerPage = POSTS_PER_PAGE;
list($Page, $Limit) = Format::page_limit($PerPage);
$CanEdit = check_perms('users_mod');
if ($CanEdit && isset($_POST['perform'])) {
authorize();
2013-10-30 08:01:19 +00:00
if ($_POST['perform'] === 'add' && !empty($_POST['message'])) {
2013-06-15 08:00:45 +00:00
$Message = db_string($_POST['message']);
$Author = db_string($_POST['author']);
2013-12-25 08:01:15 +00:00
$Date = db_string($_POST['date']);
if (!is_valid_date($Date)) {
$Date = sqltime();
}
2013-06-15 08:00:45 +00:00
$DB->query("
INSERT INTO changelog (Message, Author, Time)
2013-12-25 08:01:15 +00:00
VALUES ('$Message', '$Author', '$Date')");
2013-07-28 08:00:53 +00:00
$ID = $DB->inserted_id();
2013-10-30 08:01:19 +00:00
// SiteHistory::add_event(sqltime(), "Change log $ID", "tools.php?action=change_log", 1, 3, "", $Message, $LoggedUser['ID']);
2013-07-28 08:00:53 +00:00
2013-06-15 08:00:45 +00:00
}
2013-10-30 08:01:19 +00:00
if ($_POST['perform'] === 'remove' && !empty($_POST['change_id'])) {
$ID = (int)$_POST['change_id'];
2013-06-15 08:00:45 +00:00
$DB->query("
DELETE FROM changelog
WHERE ID = '$ID'");
}
}
$DB->query("
SELECT
SQL_CALC_FOUND_ROWS
ID,
Message,
Author,
2013-12-25 08:01:15 +00:00
Date(Time) as Time2
2013-06-15 08:00:45 +00:00
FROM changelog
2013-12-25 08:01:15 +00:00
ORDER BY Time DESC
2013-06-15 08:00:45 +00:00
LIMIT $Limit");
$ChangeLog = $DB->to_array();
$DB->query('SELECT FOUND_ROWS()');
list($NumResults) = $DB->next_record();
2013-12-25 08:01:15 +00:00
View::show_header('Gazelle Change Log', 'datetime_picker', 'datetime_picker');
2013-06-15 08:00:45 +00:00
?>
<div class="thin">
<h2>Gazelle Change Log</h2>
<div class="linkbox">
<?
$Pages = Format::get_pages($Page, $NumResults, $PerPage, 11);
echo "\t\t$Pages\n";
?>
</div>
2013-10-13 08:01:01 +00:00
<? if ($CanEdit) { ?>
2013-06-17 08:01:02 +00:00
<div class="box box2 edit_changelog">
2013-06-16 08:01:11 +00:00
<div class="head">
<strong>Manually submit a new change to the change log</strong>
</div>
<div class="pad">
2013-10-13 08:01:01 +00:00
<form method="post" action="">
2013-06-16 08:01:11 +00:00
<input type="hidden" name="perform" value="add" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<div class="field_div" id="cl_message">
2013-10-13 08:01:01 +00:00
<span class="label">Commit message:</span>
<br />
<textarea name="message" rows="2"></textarea>
2013-06-16 08:01:11 +00:00
</div>
2013-12-25 08:01:15 +00:00
<div class="field_div" id="cl_date">
<span class="label">Date:</span>
<br />
<input type="text" class="date_picker" name="date" />
</div>
2013-06-16 08:01:11 +00:00
<div class="field_div" id="cl_author">
2013-10-13 08:01:01 +00:00
<span class="label">Author:</span>
<br />
2013-06-16 08:01:11 +00:00
<input type="text" name="author" value="<?=$LoggedUser['Username']?>" />
2013-06-15 08:00:45 +00:00
</div>
2013-06-16 08:01:11 +00:00
<div class="submit_div" id="cl_submit">
2013-06-15 08:00:45 +00:00
<input type="submit" value="Submit" />
</div>
2013-06-16 08:01:11 +00:00
</form>
</div>
</div>
2013-10-13 08:01:01 +00:00
<?
}
2013-06-15 08:00:45 +00:00
2013-10-13 08:01:01 +00:00
foreach ($ChangeLog as $Change) {
?>
2013-10-26 08:00:58 +00:00
<div class="box box2 change_log_entry">
2013-06-16 08:01:11 +00:00
<div class="head">
2013-12-25 08:01:15 +00:00
<span><?=$Change['Time2']?> by <?=$Change['Author']?></span>
2013-10-13 08:01:01 +00:00
<? if ($CanEdit) { ?>
<span style="float: right;">
<form id="delete_<?=$Change['ID']?>" method="post" action="">
<input type="hidden" name="perform" value="remove" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="change_id" value="<?=$Change['ID']?>" />
</form>
2013-06-16 08:01:11 +00:00
<a href="#" onclick="$('#delete_<?=$Change['ID']?>').raw().submit(); return false;" class="brackets">Delete</a>
2013-10-13 08:01:01 +00:00
</span>
<? } ?>
2013-06-15 08:00:45 +00:00
</div>
2013-06-16 08:01:11 +00:00
<div class="pad">
<?=$Change['Message']?>
</div>
2013-06-15 08:00:45 +00:00
</div>
2013-10-13 08:01:01 +00:00
<? } ?>
2013-06-15 08:00:45 +00:00
</div>
<? View::show_footer(); ?>