Example #1
0
    $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)) {
            throw new Exception('exception_accessdenied');
        }
        $objComment->getFromRequest(array('id', 'username', 'title', 'text'));
        $objComment->set('picture_id', $objPicture->get('id'));
        $objComment->set('date', date('Y-m-d H:i:s'));
        if ($objUser) {
            $objComment->set('user_id', $objUser->get('id'));
            $objComment->set('username', $objUser->get('username'));