2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
authorize();
|
|
|
|
|
2013-05-27 08:00:58 +00:00
|
|
|
include(SERVER_ROOT.'/classes/validate.class.php');
|
2011-03-28 14:21:28 +00:00
|
|
|
$Val = new VALIDATE;
|
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!is_number($_POST['id']) || $_POST['id'] == '') {
|
|
|
|
error(0);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
$Val->SetFields('title', '1','string','The title must be between 3 and 100 characters',array('maxlength'=>100, 'minlength'=>3));
|
|
|
|
$Err = $Val->ValidateForm($_POST);
|
2013-04-20 08:01:01 +00:00
|
|
|
$ArticleID = $_POST['id'];
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($Err) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error($Err);
|
|
|
|
}
|
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
$P = array();
|
|
|
|
$P = db_array($_POST);
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
$Article = $Alias->article($ArticleID);
|
|
|
|
list($Revision, $Title, $Body, $CurRead, $CurEdit, $Date, $Author) = array_shift($Article);
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($CurEdit > $LoggedUser['EffectiveClass']) {
|
|
|
|
error(403);
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
if (check_perms('admin_manage_wiki')) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$Read=$_POST['minclassread'];
|
|
|
|
$Edit=$_POST['minclassedit'];
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!is_number($Read)) {
|
|
|
|
error(0); //int?
|
|
|
|
}
|
|
|
|
if (!is_number($Edit)) {
|
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
if ($Edit > $LoggedUser['EffectiveClass']) {
|
|
|
|
error('You can\'t restrict articles above your own level.');
|
|
|
|
}
|
|
|
|
if ($Edit < $Read) {
|
|
|
|
$Edit = $Read; //Human error fix.
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
$MyRevision = $_POST['revision'];
|
|
|
|
if ($MyRevision != $Revision) {
|
|
|
|
error('This article has already been modified from its original version.');
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
$DB->query("INSERT INTO wiki_revisions (ID, Revision, Title, Body, Date, Author) VALUES ('".db_string($ArticleID)."', '".db_string($Revision)."', '".db_string($Title)."', '".db_string($Body)."', '".db_string($Date)."', '".db_string($Author)."')");
|
|
|
|
$SQL = "UPDATE wiki_articles SET
|
2013-04-20 08:01:01 +00:00
|
|
|
Revision='".db_string($Revision + 1)."',
|
2011-03-28 14:21:28 +00:00
|
|
|
Title='$P[title]',
|
|
|
|
Body='$P[body]',";
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($Read && $Edit) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$SQL .= "MinClassRead='$Read',
|
|
|
|
MinClassEdit='$Edit',";
|
|
|
|
}
|
|
|
|
$SQL .= "Date='".sqltime()."',
|
|
|
|
Author='$LoggedUser[ID]'
|
|
|
|
WHERE ID='$P[id]'";
|
|
|
|
$DB->query($SQL);
|
|
|
|
$Cache->delete_value('wiki_article_'.$ArticleID);
|
|
|
|
header('Location: wiki.php?action=article&id='.$ArticleID);
|
|
|
|
?>
|