2018-07-07 01:32:09 +00:00
|
|
|
<?php
|
2018-10-04 20:30:55 +00:00
|
|
|
require_once '../../misuzu.php';
|
2018-07-07 01:32:09 +00:00
|
|
|
|
2018-10-02 22:34:05 +00:00
|
|
|
$changelogPerms = perms_get_user(MSZ_PERMS_CHANGELOG, user_session_current('user_id', 0));
|
2018-07-07 01:32:09 +00:00
|
|
|
|
|
|
|
switch ($_GET['v'] ?? null) {
|
2018-07-10 01:04:44 +00:00
|
|
|
default:
|
2018-07-07 01:32:09 +00:00
|
|
|
case 'changes':
|
2018-08-18 02:31:46 +00:00
|
|
|
if (!perms_check($changelogPerms, MSZ_PERM_CHANGELOG_MANAGE_CHANGES)) {
|
2018-07-07 23:24:34 +00:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
2018-07-07 01:32:09 +00:00
|
|
|
|
2018-10-06 23:30:48 +00:00
|
|
|
$changesCount = (int)db_query('
|
2018-07-07 01:32:09 +00:00
|
|
|
SELECT COUNT(`change_id`)
|
|
|
|
FROM `msz_changelog_changes`
|
|
|
|
')->fetchColumn();
|
|
|
|
|
2019-01-03 00:33:02 +00:00
|
|
|
$changelogPagination = pagination_create($changesCount, 30);
|
|
|
|
$changelogOffset = pagination_offset($changelogPagination, pagination_param());
|
|
|
|
|
|
|
|
if (!pagination_is_valid_offset($changelogOffset)) {
|
|
|
|
echo render_error(404);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-10-06 23:30:48 +00:00
|
|
|
$getChanges = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
SELECT
|
|
|
|
c.`change_id`, c.`change_log`, c.`change_created`,
|
|
|
|
a.`action_name`, a.`action_colour`, a.`action_class`,
|
|
|
|
u.`user_id`, u.`username`,
|
2018-08-16 17:26:16 +00:00
|
|
|
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`,
|
|
|
|
DATE(`change_created`) as `change_date`,
|
|
|
|
!ISNULL(c.`change_text`) as `change_has_text`
|
2018-07-07 01:32:09 +00:00
|
|
|
FROM `msz_changelog_changes` as c
|
|
|
|
LEFT JOIN `msz_changelog_actions` as a
|
|
|
|
ON a.`action_id` = c.`action_id`
|
|
|
|
LEFT JOIN `msz_users` as u
|
|
|
|
ON u.`user_id` = c.`user_id`
|
|
|
|
LEFT JOIN `msz_roles` as r
|
|
|
|
ON r.`role_id` = u.`display_role`
|
|
|
|
ORDER BY c.`change_id` DESC
|
|
|
|
LIMIT :offset, :take
|
|
|
|
');
|
2019-01-03 00:33:02 +00:00
|
|
|
$getChanges->bindValue('take', $changelogPagination['range']);
|
|
|
|
$getChanges->bindValue('offset', $changelogOffset);
|
2019-01-09 19:06:02 +00:00
|
|
|
$changes = db_fetch_all($getChanges);
|
2018-07-07 01:32:09 +00:00
|
|
|
|
2018-10-06 23:30:48 +00:00
|
|
|
$getTags = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
SELECT
|
|
|
|
t.`tag_id`, t.`tag_name`, t.`tag_description`
|
|
|
|
FROM `msz_changelog_change_tags` as ct
|
|
|
|
LEFT JOIN `msz_changelog_tags` as t
|
|
|
|
ON t.`tag_id` = ct.`tag_id`
|
|
|
|
WHERE ct.`change_id` = :change_id
|
|
|
|
');
|
|
|
|
|
|
|
|
// grab tags
|
|
|
|
for ($i = 0; $i < count($changes); $i++) {
|
|
|
|
$getTags->bindValue('change_id', $changes[$i]['change_id']);
|
2019-01-09 19:06:02 +00:00
|
|
|
$changes[$i]['tags'] = db_fetch_all($getTags);
|
2018-07-07 01:32:09 +00:00
|
|
|
}
|
|
|
|
|
2018-08-15 01:12:58 +00:00
|
|
|
echo tpl_render('manage.changelog.changes', [
|
2018-07-07 01:32:09 +00:00
|
|
|
'changelog_changes' => $changes,
|
|
|
|
'changelog_changes_count' => $changesCount,
|
2019-01-03 00:33:02 +00:00
|
|
|
'changelog_pagination' => $changelogPagination,
|
2018-07-07 01:32:09 +00:00
|
|
|
]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'change':
|
2018-08-18 02:31:46 +00:00
|
|
|
if (!perms_check($changelogPerms, MSZ_PERM_CHANGELOG_MANAGE_CHANGES)) {
|
2018-07-07 23:24:34 +00:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-07-07 01:32:09 +00:00
|
|
|
$changeId = (int)($_GET['c'] ?? 0);
|
|
|
|
|
2018-10-02 19:16:42 +00:00
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && csrf_verify('changelog_add', $_POST['csrf'] ?? '')) {
|
2018-07-07 01:32:09 +00:00
|
|
|
if (!empty($_POST['change']) && is_array($_POST['change'])) {
|
|
|
|
if ($changeId > 0) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$postChange = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
UPDATE `msz_changelog_changes`
|
|
|
|
SET `change_log` = :log,
|
|
|
|
`change_text` = :text,
|
|
|
|
`action_id` = :action,
|
|
|
|
`user_id` = :user,
|
|
|
|
`change_created` = :created
|
|
|
|
WHERE `change_id` = :change_id
|
|
|
|
');
|
|
|
|
$postChange->bindValue('change_id', $changeId);
|
|
|
|
} else {
|
2018-10-06 23:30:48 +00:00
|
|
|
$postChange = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
INSERT INTO `msz_changelog_changes`
|
2018-07-10 16:37:13 +00:00
|
|
|
(
|
|
|
|
`change_log`, `change_text`, `action_id`,
|
2018-07-11 20:03:43 +00:00
|
|
|
`user_id`, `change_created`
|
2018-07-10 16:37:13 +00:00
|
|
|
)
|
2018-07-07 01:32:09 +00:00
|
|
|
VALUES
|
|
|
|
(:log, :text, :action, :user, :created)
|
|
|
|
');
|
|
|
|
}
|
|
|
|
|
|
|
|
$postChange->bindValue('log', $_POST['change']['log']);
|
|
|
|
$postChange->bindValue('action', $_POST['change']['action']);
|
|
|
|
$postChange->bindValue('text', strlen($_POST['change']['text'])
|
|
|
|
? $_POST['change']['text']
|
|
|
|
: null);
|
|
|
|
$postChange->bindValue('user', is_numeric($_POST['change']['user'])
|
|
|
|
? $_POST['change']['user']
|
|
|
|
: null);
|
|
|
|
$postChange->bindValue('created', strlen($_POST['change']['created'])
|
|
|
|
? $_POST['change']['created']
|
|
|
|
: null);
|
|
|
|
$postChange->execute();
|
|
|
|
|
|
|
|
if ($changeId < 1) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$changeId = db_last_insert_id();
|
2018-12-15 18:46:48 +00:00
|
|
|
audit_log(MSZ_AUDIT_CHANGELOG_ENTRY_CREATE, user_session_current('user_id', 0), [$changeId]);
|
2018-07-17 17:17:57 +00:00
|
|
|
header('Location: ?v=change&c=' . $changeId);
|
2018-07-07 01:32:09 +00:00
|
|
|
return;
|
2018-07-17 17:17:57 +00:00
|
|
|
} else {
|
2018-12-15 18:46:48 +00:00
|
|
|
audit_log(MSZ_AUDIT_CHANGELOG_ENTRY_EDIT, user_session_current('user_id', 0), [$changeId]);
|
2018-07-07 01:32:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($_POST['add_tag']) && is_numeric($_POST['add_tag'])) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$addTag = db_prepare('REPLACE INTO `msz_changelog_change_tags` VALUES (:change_id, :tag_id)');
|
2018-07-07 01:32:09 +00:00
|
|
|
$addTag->bindValue('change_id', $changeId);
|
|
|
|
$addTag->bindValue('tag_id', $_POST['add_tag']);
|
2018-07-17 17:17:57 +00:00
|
|
|
|
|
|
|
if ($addTag->execute()) {
|
2018-12-15 18:46:48 +00:00
|
|
|
audit_log(MSZ_AUDIT_CHANGELOG_TAG_ADD, user_session_current('user_id', 0), [
|
2018-07-17 17:17:57 +00:00
|
|
|
$changeId,
|
|
|
|
$_POST['add_tag']
|
|
|
|
]);
|
|
|
|
}
|
2018-07-07 01:32:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($_POST['remove_tag']) && is_numeric($_POST['remove_tag'])) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$removeTag = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
DELETE FROM `msz_changelog_change_tags`
|
|
|
|
WHERE `change_id` = :change_id
|
|
|
|
AND `tag_id` = :tag_id
|
|
|
|
');
|
|
|
|
$removeTag->bindValue('change_id', $changeId);
|
|
|
|
$removeTag->bindValue('tag_id', $_POST['remove_tag']);
|
2018-07-17 17:17:57 +00:00
|
|
|
|
|
|
|
if ($removeTag->execute()) {
|
2018-12-15 18:46:48 +00:00
|
|
|
audit_log(MSZ_AUDIT_CHANGELOG_TAG_REMOVE, user_session_current('user_id', 0), [
|
2018-07-17 17:17:57 +00:00
|
|
|
$changeId,
|
|
|
|
$_POST['remove_tag']
|
|
|
|
]);
|
|
|
|
}
|
2018-07-07 01:32:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-06 23:30:48 +00:00
|
|
|
$actions = db_query('
|
2018-07-07 01:32:09 +00:00
|
|
|
SELECT `action_id`, `action_name`
|
|
|
|
FROM `msz_changelog_actions`
|
|
|
|
')->fetchAll(PDO::FETCH_ASSOC);
|
2018-08-15 01:12:58 +00:00
|
|
|
tpl_var('changelog_actions', $actions);
|
2018-07-07 01:32:09 +00:00
|
|
|
|
|
|
|
if ($changeId > 0) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$getChange = db_prepare('
|
2018-07-10 16:37:13 +00:00
|
|
|
SELECT
|
|
|
|
`change_id`, `change_log`, `change_text`, `user_id`,
|
|
|
|
`action_id`, `change_created`
|
2018-07-07 01:32:09 +00:00
|
|
|
FROM `msz_changelog_changes`
|
|
|
|
WHERE `change_id` = :change_id
|
|
|
|
');
|
|
|
|
$getChange->bindValue('change_id', $changeId);
|
2019-01-09 19:06:02 +00:00
|
|
|
$change = db_fetch($getChange);
|
2018-07-07 01:32:09 +00:00
|
|
|
|
|
|
|
if ($change) {
|
2018-08-15 01:12:58 +00:00
|
|
|
tpl_var('edit_change', $change);
|
2018-07-07 01:32:09 +00:00
|
|
|
|
2018-10-06 23:30:48 +00:00
|
|
|
$assignedTags = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
SELECT `tag_id`, `tag_name`
|
|
|
|
FROM `msz_changelog_tags`
|
|
|
|
WHERE `tag_id` IN (
|
|
|
|
SELECT `tag_id`
|
|
|
|
FROM `msz_changelog_change_tags`
|
|
|
|
WHERE `change_id` = :change_id
|
|
|
|
)
|
|
|
|
');
|
|
|
|
$assignedTags->bindValue('change_id', $change['change_id']);
|
2019-01-09 19:06:02 +00:00
|
|
|
$assignedTags = db_fetch_all($assignedTags);
|
2018-07-07 01:32:09 +00:00
|
|
|
|
2018-10-06 23:30:48 +00:00
|
|
|
$availableTags = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
SELECT `tag_id`, `tag_name`
|
|
|
|
FROM `msz_changelog_tags`
|
2018-07-07 14:06:36 +00:00
|
|
|
WHERE `tag_archived` IS NULL
|
|
|
|
AND `tag_id` NOT IN (
|
2018-07-07 01:32:09 +00:00
|
|
|
SELECT `tag_id`
|
|
|
|
FROM `msz_changelog_change_tags`
|
|
|
|
WHERE `change_id` = :change_id
|
|
|
|
)
|
|
|
|
');
|
|
|
|
$availableTags->bindValue('change_id', $change['change_id']);
|
2019-01-09 19:06:02 +00:00
|
|
|
$availableTags = db_fetch_all($availableTags);
|
2018-07-07 01:32:09 +00:00
|
|
|
|
2018-08-15 01:12:58 +00:00
|
|
|
tpl_vars([
|
2018-07-07 01:32:09 +00:00
|
|
|
'edit_change_assigned_tags' => $assignedTags,
|
|
|
|
'edit_change_available_tags' => $availableTags,
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
header('Location: ?v=changes');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-15 01:12:58 +00:00
|
|
|
echo tpl_render('manage.changelog.change_edit');
|
2018-07-07 01:32:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'tags':
|
2018-08-18 02:31:46 +00:00
|
|
|
$canManageTags = perms_check($changelogPerms, MSZ_PERM_CHANGELOG_MANAGE_TAGS);
|
|
|
|
$canManageActions = perms_check($changelogPerms, MSZ_PERM_CHANGELOG_MANAGE_ACTIONS);
|
2018-08-16 17:26:16 +00:00
|
|
|
|
|
|
|
if (!$canManageTags && !$canManageActions) {
|
2018-07-07 23:24:34 +00:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-08-16 17:26:16 +00:00
|
|
|
if ($canManageActions) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$getActions = db_prepare('
|
2018-08-16 17:26:16 +00:00
|
|
|
SELECT
|
|
|
|
a.`action_id`, a.`action_name`, a.`action_colour`,
|
|
|
|
(
|
|
|
|
SELECT COUNT(c.`action_id`)
|
|
|
|
FROM `msz_changelog_changes` as c
|
|
|
|
WHERE c.`action_id` = a.`action_id`
|
|
|
|
) as `action_count`
|
|
|
|
FROM `msz_changelog_actions` as a
|
|
|
|
ORDER BY a.`action_id` ASC
|
|
|
|
');
|
2019-01-09 19:06:02 +00:00
|
|
|
tpl_var('changelog_actions', db_fetch_all($getActions));
|
2018-08-16 17:26:16 +00:00
|
|
|
}
|
2018-07-07 01:32:09 +00:00
|
|
|
|
2018-08-16 17:26:16 +00:00
|
|
|
if ($canManageTags) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$getTags = db_prepare('
|
2018-08-16 17:26:16 +00:00
|
|
|
SELECT
|
|
|
|
t.`tag_id`, t.`tag_name`, t.`tag_description`, t.`tag_created`,
|
|
|
|
(
|
|
|
|
SELECT COUNT(ct.`change_id`)
|
|
|
|
FROM `msz_changelog_change_tags` as ct
|
|
|
|
WHERE ct.`tag_id` = t.`tag_id`
|
|
|
|
) as `tag_count`
|
|
|
|
FROM `msz_changelog_tags` as t
|
|
|
|
ORDER BY t.`tag_id` ASC
|
|
|
|
');
|
2019-01-09 19:06:02 +00:00
|
|
|
tpl_var('changelog_tags', db_fetch_all($getTags));
|
2018-08-16 17:26:16 +00:00
|
|
|
}
|
2018-07-07 01:32:09 +00:00
|
|
|
|
2018-08-16 17:26:16 +00:00
|
|
|
echo tpl_render('manage.changelog.actions_tags');
|
2018-07-07 01:32:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'tag':
|
2018-08-18 02:31:46 +00:00
|
|
|
if (!perms_check($changelogPerms, MSZ_PERM_CHANGELOG_MANAGE_TAGS)) {
|
2018-07-07 23:24:34 +00:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-07-07 01:32:09 +00:00
|
|
|
$tagId = (int)($_GET['t'] ?? 0);
|
|
|
|
|
2018-10-02 19:16:42 +00:00
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && csrf_verify('changelog_tag', $_POST['csrf'] ?? '')) {
|
2018-07-07 01:32:09 +00:00
|
|
|
if (!empty($_POST['tag']) && is_array($_POST['tag'])) {
|
|
|
|
if ($tagId > 0) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$updateTag = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
UPDATE `msz_changelog_tags`
|
|
|
|
SET `tag_name` = :name,
|
|
|
|
`tag_description` = :description,
|
|
|
|
`tag_archived` = :archived
|
|
|
|
WHERE `tag_id` = :id
|
|
|
|
');
|
|
|
|
$updateTag->bindValue('id', $tagId);
|
|
|
|
} else {
|
2018-10-06 23:30:48 +00:00
|
|
|
$updateTag = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
INSERT INTO `msz_changelog_tags`
|
|
|
|
(`tag_name`, `tag_description`, `tag_archived`)
|
|
|
|
VALUES
|
|
|
|
(:name, :description, :archived)
|
|
|
|
');
|
|
|
|
}
|
|
|
|
|
|
|
|
$updateTag->bindValue('name', $_POST['tag']['name']);
|
|
|
|
$updateTag->bindValue('description', $_POST['tag']['description']);
|
2018-07-07 14:06:36 +00:00
|
|
|
// this is fine, after being archived there shouldn't be any other changes being made
|
|
|
|
$updateTag->bindValue('archived', empty($_POST['tag']['archived']) ? null : date('Y-m-d H:i:s'));
|
2018-07-07 01:32:09 +00:00
|
|
|
$updateTag->execute();
|
|
|
|
|
|
|
|
if ($tagId < 1) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$tagId = db_last_insert_id();
|
2018-12-15 18:46:48 +00:00
|
|
|
audit_log(MSZ_AUDIT_CHANGELOG_TAG_EDIT, user_session_current('user_id', 0), [$tagId]);
|
2018-07-17 17:17:57 +00:00
|
|
|
header('Location: ?v=tag&t=' . $tagId);
|
2018-07-07 01:32:09 +00:00
|
|
|
return;
|
2018-07-17 17:17:57 +00:00
|
|
|
} else {
|
2018-12-15 18:46:48 +00:00
|
|
|
audit_log(MSZ_AUDIT_CHANGELOG_TAG_CREATE, user_session_current('user_id', 0), [$tagId]);
|
2018-07-07 01:32:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($tagId > 0) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$getTag = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
SELECT `tag_id`, `tag_name`, `tag_description`, `tag_archived`, `tag_created`
|
|
|
|
FROM `msz_changelog_tags`
|
|
|
|
WHERE `tag_id` = :tag_id
|
|
|
|
');
|
|
|
|
$getTag->bindValue('tag_id', $tagId);
|
2019-01-09 19:06:02 +00:00
|
|
|
$tag = db_fetch($getTag);
|
2018-07-07 01:32:09 +00:00
|
|
|
|
|
|
|
if ($tag) {
|
2018-08-15 01:12:58 +00:00
|
|
|
tpl_var('edit_tag', $tag);
|
2018-07-07 01:32:09 +00:00
|
|
|
} else {
|
|
|
|
header('Location: ?v=tags');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-15 01:12:58 +00:00
|
|
|
echo tpl_render('manage.changelog.tag_edit');
|
2018-07-07 01:32:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'action':
|
2018-08-18 02:31:46 +00:00
|
|
|
if (!perms_check($changelogPerms, MSZ_PERM_CHANGELOG_MANAGE_ACTIONS)) {
|
2018-07-07 23:24:34 +00:00
|
|
|
echo render_error(403);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-07-07 01:32:09 +00:00
|
|
|
$actionId = (int)($_GET['a'] ?? 0);
|
|
|
|
|
2018-10-02 19:16:42 +00:00
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && csrf_verify('changelog_action', $_POST['csrf'] ?? '')) {
|
2018-07-07 01:32:09 +00:00
|
|
|
if (!empty($_POST['action']) && is_array($_POST['action'])) {
|
|
|
|
if ($actionId > 0) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$updateAction = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
UPDATE `msz_changelog_actions`
|
|
|
|
SET `action_name` = :name,
|
|
|
|
`action_colour` = :colour,
|
|
|
|
`action_class` = :class
|
|
|
|
WHERE `action_id` = :id
|
|
|
|
');
|
|
|
|
$updateAction->bindValue('id', $actionId);
|
|
|
|
} else {
|
2018-10-06 23:30:48 +00:00
|
|
|
$updateAction = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
INSERT INTO `msz_changelog_actions`
|
|
|
|
(`action_name`, `action_colour`, `action_class`)
|
|
|
|
VALUES
|
|
|
|
(:name, :colour, :class)
|
|
|
|
');
|
|
|
|
}
|
|
|
|
|
|
|
|
$actionColour = colour_create();
|
|
|
|
|
|
|
|
if (!empty($_POST['action']['colour']['inherit'])) {
|
|
|
|
colour_set_inherit($actionColour);
|
|
|
|
} else {
|
|
|
|
colour_set_red($actionColour, $_POST['action']['colour']['red']);
|
|
|
|
colour_set_green($actionColour, $_POST['action']['colour']['green']);
|
|
|
|
colour_set_blue($actionColour, $_POST['action']['colour']['blue']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$updateAction->bindValue('name', $_POST['action']['name']);
|
|
|
|
$updateAction->bindValue('colour', $actionColour);
|
|
|
|
$updateAction->bindValue('class', $_POST['action']['class']);
|
|
|
|
$updateAction->execute();
|
|
|
|
|
|
|
|
if ($actionId < 1) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$actionId = db_last_insert_id();
|
2018-12-15 18:46:48 +00:00
|
|
|
audit_log(MSZ_AUDIT_CHANGELOG_ACTION_CREATE, user_session_current('user_id', 0), [$actionId]);
|
2018-07-17 17:17:57 +00:00
|
|
|
header('Location: ?v=action&a=' . $actionId);
|
2018-07-07 01:32:09 +00:00
|
|
|
return;
|
2018-07-17 17:17:57 +00:00
|
|
|
} else {
|
2018-12-15 18:46:48 +00:00
|
|
|
audit_log(MSZ_AUDIT_CHANGELOG_ACTION_EDIT, user_session_current('user_id', 0), [$actionId]);
|
2018-07-07 01:32:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($actionId > 0) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$getAction = db_prepare('
|
2018-07-07 01:32:09 +00:00
|
|
|
SELECT `action_id`, `action_name`, `action_colour`, `action_class`
|
|
|
|
FROM `msz_changelog_actions`
|
|
|
|
WHERE `action_id` = :action_id
|
|
|
|
');
|
|
|
|
$getAction->bindValue('action_id', $actionId);
|
2019-01-09 19:06:02 +00:00
|
|
|
$action = db_fetch($getAction);
|
2018-07-07 01:32:09 +00:00
|
|
|
|
|
|
|
if ($action) {
|
2018-08-15 01:12:58 +00:00
|
|
|
tpl_var('edit_action', $action);
|
2018-07-07 01:32:09 +00:00
|
|
|
} else {
|
|
|
|
header('Location: ?v=actions');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-15 01:12:58 +00:00
|
|
|
echo tpl_render('manage.changelog.action_edit');
|
2018-07-07 01:32:09 +00:00
|
|
|
break;
|
|
|
|
}
|