示例#1
0
<?php

require_once 'cls/clsAlbum.php';
require_once 'cls/clsComment.php';
require_once 'cls/clsPicture.php';
$objComment = new clsComment();
$objComment->getFromRequest();
$objComment->load();
$objPicture = new clsPicture();
$objPicture->getFromRequest();
$objPicture->load();
$objAlbum = new clsAlbum($objPicture->get('album_id'));
if ($strSubAction == 'edit') {
    if ($objComment->isNew() && !$objAlbum->canPostComment($objUser)) {
        throw new Exception('exception_accessdenied');
    }
    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'));
示例#2
0
        $objCommentTemplate = new clsTemplate('comment');
        $objCommentTemplate->setText('TITLE', $objComment->get('title') . ' ' . $objComment->getNewIcon($objUser));
        $objCommentTemplate->setText('USERNAME', $objComment->getUsername());
        $objCommentTemplate->setText('DATE', time_to_text(strtotime($objComment->get('date'))));
        $objCommentTemplate->setText('TEXT', bbcode_format($objComment->get('text')));
        if ($objComment->canEdit($objUser)) {
            $objCommentTemplate->setText('TITLE', "<span class='editdelete'> [<a href='index.php?action=comment&subaction=edit&" . $objPicture->getIDPair() . "&" . $objComment->getIDPair() . "'>edit</a>]</span>");
        }
        if ($objComment->canDelete($objUser)) {
            $objCommentTemplate->setText('TITLE', "<span class='editdelete'> [<a href='index.php?action=comment&subaction=delete&" . $objPicture->getIDPair() . "&" . $objComment->getIDPair() . "'>delete</a>]</span>");
        }
        $objPictureTemplate->setText('COMMENTS', $objCommentTemplate->get());
        /* Mark the comment as viewed */
        $objComment->setViewed($objUser);
    }
    if ($objAlbum->canPostComment($objUser)) {
        $objPictureTemplate->setText('POSTCOMMENT1', "<a href='index.php?action=comment&subaction=edit&" . $objPicture->getIDPair() . "' class='smalllink'>Post Comment</a>");
        if (sizeof($arrComments) != 0) {
            $objPictureTemplate->setText('POSTCOMMENT2', "<a href='index.php?action=comment&subaction=edit&" . $objPicture->getIDPair() . "' class='smalllink'>Post Comment</a>");
        }
    }
    if (sizeof($arrComments) == 0) {
        $objPictureTemplate->setText('COMMENTS', "No comments on this picture!");
    }
    print $objPictureTemplate->get();
} else {
    if ($strSubAction == 'delete') {
        if (!$objAlbum->canDeletePicture($objUser)) {
            throw new Exception('exception_accessdenied');
        }
        $objPicture->delete();