Ejemplo n.º 1
0
 function testCommentFunctions()
 {
     $POD = new PeoplePod();
     $user = $POD->getPerson();
     $user->email = '*****@*****.**';
     //create user
     $user->password = '******';
     $user->nick = 'test';
     $user->save();
     $POD->changeActor(array('id' => $user->id));
     $content = $POD->getContent();
     $content->set('headline', 'this is the headline');
     $content->set('type', 'this is the type');
     $content->save();
     $comment = $content->addComment('amazing!');
     $comment->type = 'rating';
     $comment2 = $content->addComment('blah');
     $comment->type = 'rating';
     $this->assertEqual($comment->author()->get('id'), $user->id);
     $this->assertEqual($comment->parent()->id, $content->id);
     $comment_stack = $content->comments();
     $this->assertEqual($comment_stack->count(), 2);
     $next_comm = $comment_stack->getNext();
     $this->assertIsA($next_comm, 'Comment');
     $pod_comm_stack = $POD->getComments();
     $pod_comm = $pod_comm_stack->getNext();
     $this->assertIsA($pod_comm, 'Comment');
     //test getComment to return a specific comment
     $pull_comm = $POD->getComment(array('id' => $comment2->id));
     $this->assertEqual($pull_comm->comment, 'blah');
     //test getComment to create a comment and associate it with a person and content obj
     $new_comment = $POD->getComment();
     $new_comment->set('comment', 'This comment sucks!');
     $new_comment->set('userId', $user->id);
     $new_comment->set('contentId', $content->get('id'));
     $new_comment->save();
     $comment_stack = $POD->getComments(array('userId' => $user->id));
     $this->assertEqual($comment_stack->count(), 3);
     $comment->delete();
     $content->delete();
     $user->delete();
 }
Ejemplo n.º 2
0
<?php

include_once "../../PeoplePods.php";
$POD = new PeoplePod(array('debug' => 0, 'lockdown' => 'adminUser', 'authSecret' => @$_COOKIE['pp_auth']));
$POD->changeTheme('admin');
if (isset($_GET['delete'])) {
    // delete this comment
    $comment = $POD->getComment(array('id' => $_GET['delete']));
    if ($comment->success()) {
        $comment->delete();
        if (!$comment->success()) {
            $msg = $comment->error();
        } else {
            $msg = "Comment deleted.";
        }
    } else {
        $msg = $comment->error();
    }
}
$types = array();
$sql = "SELECT DISTINCT type FROM comments";
$res = mysql_query($sql, $POD->DATABASE);
if (mysql_num_rows($res) > 0) {
    while ($type = mysql_fetch_row($res)) {
        if ($type[0] == '') {
            $type[0] = 'comment';
        }
        array_push($types, $type[0]);
    }
}
$POD->header('Comments');
Ejemplo n.º 3
0
                     $comment->output();
                 }
             }
             $data['comments_as_html'] = ob_get_contents();
             ob_end_clean();
         } else {
             $data['error'] = $doc->error();
         }
     } else {
         $data['error'] = 'PERMISSION DENIED';
     }
     echo json_encode($data);
 }
 if ($method == "removeComment") {
     if ($POD->isAuthenticated()) {
         $comment = $POD->getComment(array('id' => $_GET['comment']));
         $comment->delete();
         if ($comment->success()) {
             echo json_encode(array('id' => $_GET['comment']));
         } else {
             echo json_encode(array('error' => $comment->error(), 'id' => $_GET['comment']));
         }
     } else {
         echo json_encode(array('error' => 'PERMISSION DENIED', 'id' => $_GET['comment']));
     }
 }
 if ($method == "deleteDocument") {
     $doc = $POD->getContent(array('id' => $_GET['id']));
     if ($doc->success()) {
         $doc->delete();
         if ($doc->success()) {
Ejemplo n.º 4
0
<?php

include_once "../../PeoplePods.php";
$POD = new PeoplePod(array('lockdown' => 'adminUser', 'authSecret' => @$_COOKIE['pp_auth']));
$POD->changeTheme('admin');
$commentId = $_GET['id'];
if ($commentId != '') {
    $comment = $POD->getComment(array('id' => $commentId));
    if ($comment->success()) {
        // get parent so we can output the comment list
        $parent = $comment->parent();
        $comment->delete();
        if ($comment->success()) {
            // now we can just iterate through the parent comment loop.  we haven't accessed it yet,
            // so it will load fresh and NOT include the deleted comment.
            if ($parent->comments()->count() > 0) {
                while ($c = $parent->comments()->getNext()) {
                    $c->output('comment_edit');
                }
            } else {
                echo '<p class="column_padding">This post has no comments</p>';
            }
        } else {
            // comment failed to delete
            echo '<p class="column_padding">Error: ' . $comment->error . '</p>';
        }
    } else {
        // comment failed to load
        echo '<p class="column_padding">Error: ' . $comment->error . '</p>';
    }
} else {