Exemplo n.º 1
0
    }
    if (!$objComment->canEdit($objUser)) {
        throw new Exception('exception_accessdenied');
    }
    $objAlbum->addBreadcrumbs($objBreadcrumbs);
    $objBreadcrumbs->add($objPicture->get('name'), 'index.php?action=picture&' . $objPicture->getIDPair());
    $objBreadcrumbs->add('Post comment', 'comment.php?action=edit&' . $objPicture->getIDPair() . '&' . $objComment->getIDPair());
    $objCommentTemplate = new clsTemplate('editcomment');
    $objCommentTemplate->setText('HIDDEN', $objComment->getHiddenField('id'));
    $objCommentTemplate->setText('HIDDEN', $objPicture->getHiddenField('id'));
    $objCommentTemplate->setText('HIDDEN', "<input type='hidden' name='action' value='comment'>");
    $objCommentTemplate->setText('HIDDEN', "<input type='hidden' name='subaction' value='save'>");
    if ($objUser) {
        $objCommentTemplate->setText('NAME', '<strong>' . $objUser->get('username') . '</strong>');
    } else {
        $objCommentTemplate->setText('NAME', $objComment->getTextField('username'));
    }
    /* Set a default title if it's not present. */
    if (!$objComment->exists('title')) {
        $objComment->set('title', 'Re: ' . $objPicture->get('title'), false);
    }
    $objCommentTemplate->setText('TITLE', $objComment->getTextField('title'));
    $objCommentTemplate->setText('COMMENT', $objComment->getTextArea('text', 5, 60));
    $objCommentTemplate->setText('SUBMIT', $objComment->getSubmit('Save'));
    print $objCommentTemplate->get();
} else {
    if ($strSubAction == 'save') {
        if ($objComment->isNew() && !$objAlbum->canPostComment($objUser)) {
            throw new Exception('exception_accessdenied');
        }
        if (!$objComment->canEdit($objUser)) {