示例#1
0
$TagID = Utils::SafeIntFromQS('tag_id');
$DeleteTag = array_key_exists('hidTagToDelete', $_POST) && $TagID && $_POST['hidTagToDelete'] == $TagID;
$Tags = Tag::GetTags();
$Tag = Tag::Filter($Tags, $TagID);
$Tag = $TagID && $Tag ? $Tag[0] : new Tag();
$Tagcount = 0;
$TagList = NULL;
$DisableControls = $DeleteTag || !$CurrentUser->hasPermission(RIGHT_TAG_EDIT) && !is_null($TagID) || !$CurrentUser->hasPermission(RIGHT_TAG_ADD) && is_null($TagID);
$DisableDefaultButton = !$CurrentUser->hasPermission(RIGHT_TAG_DELETE) && !is_null($TagID) && $DeleteTag || !$CurrentUser->hasPermission(RIGHT_TAG_EDIT) && !is_null($TagID) && !$DeleteTag || !$CurrentUser->hasPermission(RIGHT_TAG_ADD) && is_null($TagID);
if (array_key_exists('hidAction', $_POST) && $_POST['hidAction'] == 'TagView') {
    $Tag->setName(Utils::NullIfEmpty($_POST['txtName']));
    if ($Tag->getID()) {
        if ($DeleteTag) {
            if ($CurrentUser->hasPermission(RIGHT_TAG_DELETE) && Tag::Delete($Tag, $CurrentUser)) {
                $t2as = Tag2All::GetTag2Alls(new Tag2AllSearchParameters($Tag->getID()));
                Tag2All::DeleteMulti($t2as, $CurrentUser);
                header('location:' . $_SERVER['PHP_SELF']);
                exit;
            }
        } else {
            if ($CurrentUser->hasPermission(RIGHT_TAG_EDIT) && Tag::Update($Tag, $CurrentUser)) {
                header('location:' . $_SERVER['PHP_SELF']);
                exit;
            }
        }
    } else {
        if ($CurrentUser->hasPermission(RIGHT_TAG_ADD) && Tag::Insert($Tag, $CurrentUser)) {
            header('location:' . $_SERVER['PHP_SELF']);
            exit;
        }
    }