Cik sakarīga būtu šāda permisiju sistēma lapā?
<?php
function checkPerm($userID, $action, $isAuthor, $isOwner) {
$permQuery = $db->query("SELECT * FROM `permissions_default`, `permissions_moderation`, `permissions_administration` WHERE `permissions_default`.`user_id` = '$userID'");
$perm = $permQuery->fetch_object();
if ($perm->overrideAll == '1') {
return 1;
}
else {
switch($action) {
case 'editArticle':
if ($isAuthor == 1) { return $perm->editArticle_own; }
else { return $perm->canEditArticle; }
break;
case 'editThread':
if ($isAuthor == 1) { return $perm->editThread_own; }
else { return $perm->canEditThread; }
break;
case 'editComment':
if ($isAuthor == 1) { return $perm->editComment_own; }
else { return $perm->canEditComment; }
break;
case 'createArticle':
return $perm->createArticle;
break;
case 'createThread':
return $perm->createThread;
break;
case 'addComment':
return $perm->addComment;
break;
case 'deleteArticle':
if ($isAuthor == 1) { return $perm->delArticle_own; }
else { return $perm->canDeleteArticle; }
break;
case 'deleteThread':
if ($isAuthor == 1) { return $perm->delThread_own; }
else { return $perm->canDeleteThread; }
break;
case 'deleteComment':
if ($isAuthor == 1) { return $perm->delComment_own; }
else { return $perm->canDeleteComment; }
break;
case 'hideCommentFromOthers':
if ($isAuthor == 1) { return $perm->hideComment_fromOthers; }
else { return $perm->canHideComment; }
break;
case 'hideComment':
if ($isOwner == 1) { return $perm->hideComment_ownArticle; }
else { return $perm->canHideComment; }
break;
case 'unhideCommentFromOthers':
if ($isAuthor == 1) { return $perm->unhideComment_fromOthers; }
else { return $perm->canUnhideComment; }
break;
case 'unhideComment':
if ($isOwner == 1) { return $perm->unhideComment_ownArticle; }
else { return $perm->canUnhideComment; }
break;
}
}
}
?>
S J miniblogs
- -1
S J 04.04.2013. 20:09
Ielogojies vai izveido profilu, lai komentētu!