Empty commit

This commit is contained in:
Git 2012-12-11 08:00:18 +00:00
parent 5625f727e8
commit 0ade9fcc52
5 changed files with 114 additions and 35 deletions

View File

@ -35,7 +35,7 @@ function to_id($Alias) {
return $ArticleID;
}
*/
function article($ArticleID) {
function article($ArticleID, $Error = true) {
global $Cache, $DB;
$Contents = $Cache->get_value('wiki_article_'.$ArticleID);
if(!$Contents){
@ -55,7 +55,7 @@ function article($ArticleID) {
LEFT JOIN users_main AS u ON u.ID=w.Author
WHERE w.ID='$ArticleID'
GROUP BY w.ID");
if(!$DB->record_count()) { error(404); }
if(!$DB->record_count() && $Error) { error(404); }
$Contents = $DB->to_array();
$Cache->cache_value('wiki_article_'.$ArticleID, $Contents, 3600*24*14);
}

View File

@ -104,12 +104,16 @@
case 'votefavorite':
require(SERVER_ROOT . '/sections/ajax/takevote.php');
break;
case 'wiki':
require(SERVER_ROOT . '/sections/ajax/wiki.php');
break;
default:
// If they're screwing around with the query string
print json_encode(array('status' => 'failure'));
}
function pullmediainfo($Array) {
function pullmediainfo($Array)
{
$NewArray = array();
foreach ($Array as $Item) {
$NewArray[] = array(

65
sections/ajax/wiki.php Normal file
View File

@ -0,0 +1,65 @@
<?
include(SERVER_ROOT . '/classes/class_text.php');
include(SERVER_ROOT . '/classes/class_alias.php');
$Text = new TEXT(true);
$Alias = new ALIAS;
if (!empty($_GET['id']) && is_number($_GET['id'])) { //Visiting article via ID
$ArticleID = $_GET['id'];
} elseif ($_GET['name'] != '') { //Retrieve article ID via alias.
$ArticleID = $Alias->to_id($_GET['name']);
} else {
print json_encode(
array(
'status' => 'error',
)
);
die();
}
if (!$ArticleID) { //No article found
print json_encode(
array(
'status' => 'not found',
)
);
die();
}
$Article = $Alias->article($ArticleID, false);
if (!$Article) {
print json_encode(
array(
'status' => 'not found',
)
);
die();
}
list($Revision, $Title, $Body, $Read, $Edit, $Date, $AuthorID, $AuthorName, $Aliases, $UserIDs) = array_shift($Article);
if ($Read > $LoggedUser['EffectiveClass']) {
print json_encode(
array(
'status' => 'You must be a higher user class to view this wiki article',
)
);
die();
}
$TextBody = $Text->full_format($Body, false);
print json_encode(
array(
'status' => 'success',
'response' => array(
'title' => $Title,
'bbBody' => $Body,
'body' => $TextBody,
'aliases' => $Aliases,
'authorID' => (int)$AuthorID,
'authorName' => $AuthorName,
'date' => $Date,
'revision' => (int)$Revision
)
));
?>

View File

@ -210,7 +210,7 @@
<tr>
<td colspan="2">
<? if ($ClaimerID) { ?>
Claimed by <?=Users::format_username($ClaimerID, false, false, false, false)?>
<span id="claimed_<?=$ReportID?>">Claimed by <?=Users::format_username($ClaimerID, false, false, false, false)?></span>
<? } else { ?>
<a href="#" id="claim_<?=$ReportID?>" onclick="claim(<?=$ReportID?>); return false;"; return false;">Claim</a>
<? } ?>
@ -231,7 +231,7 @@
<input type="hidden" name="reportid" value="<?=$ReportID?>"/>
<input type="hidden" name="action" value="takeresolve"/>
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>"/>
<input type="submit" name="submit" value="Resolve"/>
<input type="submit" onclick="return resolve(<?=$ReportID?>)" name="submit" value="Resolve"/>
</td>
</tr>
<? } ?>

View File

@ -35,3 +35,13 @@ function claim(id) {
});
}
function resolve(id) {
if ($('#claimed_' + id).raw()) {
var answer = confirm("This is a claimed report, are you sure you want to resolve it?");
if (answer)
return true;
else
return false;
}
return true;
}