function testPeoplePodsCreateUser() { $POD = new PeoplePod(); $user = $POD->getPerson(); $this->assertIsA($user, 'Person'); $this->assertNull($user->id); $user->email = '*****@*****.**'; $user->password = '******'; $user->nick = 'test'; $user->save(); $this->assertTrue($user->success()); $this->assertNotNull($user->id); $POD->changeActor(array('id' => $user->id)); $this->assertTrue($POD->isAuthenticated()); $user->delete(); }
if (isset($_POST['id'])) { $doc = $POD->getContent(array('id' => $_POST['id'])); } } } if (!$doc->success()) { header("Status: 404 Not Found"); echo "404 Not Found"; exit; } if (isset($_POST['comment'])) { // this is a request to post a comment $comment = $doc->addComment($_POST['comment']); if (!$comment || !$comment->success()) { $POD->addMessage("Couldn't add comment! " . $doc->error()); } else { header("Location: " . $doc->get('permalink') . "#" . $comment->get('id')); exit; } } if (isset($_GET['vote'])) { // this is a request to vote if ($POD->isAuthenticated()) { if (!$POD->currentUser()->getVote($doc)) { $doc->vote($_GET['vote']); } } } $POD->header($doc->get('headline')); $doc->output($output_template); $POD->footer();
* (c) xoxco, inc * http://peoplepods.net http://xoxco.com * * core_api_simple/index.php * Handles simple requests to /api * * Documentation for this pod can be found here: * http://peoplepods.net/readme /**********************************************/ include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('authSecret' => @$_COOKIE['pp_auth'], 'debug' => 2)); if ($POD->libOptions('enable_core_api_simple')) { $method = $_GET['method']; $POD->tolog("API CALL METHOD: {$method}"); if ($method == "alert.markAsRead") { if ($POD->isAuthenticated()) { $alert = $POD->getAlert(array('id' => $_GET['id'])); $alert->markAsRead(); if ($alert->success()) { echo json_encode($alert->asArray()); } else { echo json_encode(array('error' => $alert->error(), 'id' => $_GET['id'])); } } else { echo json_encode(array('error' => 'PERMISSION DENIED', 'id' => $_GET['docId'])); } } if ($method == "markAsRead") { if ($POD->isAuthenticated()) { $doc = $POD->getContent(array('id' => $_GET['docId'])); if ($doc->success()) {
function TestVoting() { $POD = new PeoplePod(); $POD->debug(1); $user = $POD->getPerson(); $user->email = '*****@*****.**'; //create user $user->password = '******'; $user->nick = 'test'; $user->save(); $POD->changeActor(array('id' => $user->id)); //log in as user $content = $POD->getContent(); $content->set('headline', 'this is the headline'); $content->set('type', 'this is the type'); $content->save(); for ($i = 0; $i < 3; $i++) { //Test all vote fields initialized to zero $this->assertEqual($content->yes_votes, 0); $this->assertEqual($content->no_votes, 0); $this->assertEqual($content->yes_percent, 0); $this->assertEqual($content->no_percent, 0); ////// begin yes_vote tests ////////// //upvote $content->vote('y'); $this->assertEqual($content->yes_votes, 1); //attempts to upvote twice $content->vote('y'); $this->assertEqual($content->yes_votes, 1); //Test upvote percent $this->assertEqual($content->yes_percent, 100); //vote('n')should return false because it was not unvoted. There cannot be both a yes & no vote on one contentObj // yes_vote should be unaffected $content->vote('n'); $this->assertEqual($content->no_votes, 1); //downvote should not count $this->assertEqual($content->yes_votes, 0); //upvote should remain unchanged $this->assertEqual($content->yes_percent, 0); //upvote % should be unchanged $this->assertEqual($content->no_percent, 100); //upvote % should be unchanged //test unvote $content->unvote(); $this->assertEqual($content->yes_votes, 0); //upvote should clear $this->assertEqual($content->yes_percent, 0); //percent should return to 0 $this->assertEqual($content->no_votes, 0); //no_votes should stil be 0 $this->assertEqual($content->no_percent, 0); //no percent should be 0 ////// begin no_vote tests // same test sequence as above, but using no_votes $content->vote('n'); $this->assertEqual($content->no_votes, 1); //attempt to add two no_votes $content->vote('n'); $this->assertEqual($content->no_votes, 1); $this->assertEqual($content->no_percent, 100); //attempt to add upvote on top of no_vote. Should not be allowed $content->vote('y'); $this->assertEqual($content->yes_votes, 1); $this->assertEqual($content->yes_percent, 100); $this->assertEqual($content->no_percent, 0); //remove vote $content->unvote(); $this->assertEqual($content->yes_votes, 0); $this->assertEqual($content->yes_percent, 0); $this->assertEqual($content->no_votes, 0); $this->assertEqual($content->no_percent, 0); //unvote empty vote set $content->unvote(); $this->assertEqual($content->yes_votes, 0); $this->assertEqual($content->yes_percent, 0); $this->assertEqual($content->no_votes, 0); $this->assertEqual($content->no_percent, 0); } /// content-votes are all set to zero, now users will be added to vote and test %'s $content->vote('y'); //start with one upvote //create a new user $user2 = $POD->getPerson(); $user2->email = '*****@*****.**'; //create user $user2->password = '******'; $user2->nick = 'test2'; $user2->save(); $this->assertTrue($user2->success()); $this->assertNotNull($user2->id); $POD->changeActor(array('id' => $user2->id)); $this->assertTrue($POD->isAuthenticated()); $this->assertEqual($POD->currentUser()->nick, $user2->nick); $content->vote('y'); $this->assertEqual($content->yes_votes, 2); //check to make sure up_votes are incremented $this->assertEqual($content->yes_percent, 100); $content->unvote(); $content->vote('n'); $this->assertEqual($content->yes_percent, 50); $this->assertEqual($content->no_percent, 50); //create yet another user to test %'s with a decimal value $user3 = $POD->getPerson(); $user3->email = '*****@*****.**'; //create user $user3->password = '******'; $user3->nick = 'test3'; $user3->save(); $POD->changeActor(array('id' => $user3->id)); $this->assertTrue($POD->isAuthenticated()); $this->assertEqual($POD->currentUser()->nick, $user3->nick); $content->vote('y'); //there should now be 2 upvotes and 1 down $this->assertEqual($content->yes_votes, 2); $this->assertEqual($content->no_votes, 1); $this->assertEqual($content->yes_percent, 66); $this->assertEqual($content->no_percent, 33); error_log("------------------------------------------------------"); error_log("END VOTE TESTS"); // clean up $content->delete(); $user3->delete(); $POD->changeActor(array('id' => $user2->id)); $user2->delete(); $POD->changeActor(array('id' => $user->id)); $user->delete(); }
$POD = new PeoplePod(array('debug'=>0,'lockdown'=>$lockdown,'authSecret'=>@$_COOKIE['pp_auth'])); if (!$POD->libOptions('enable_core_groups')) { header("Location: " . $POD->siteRoot(false)); exit; } $group = $POD->getGroup(array('stub'=>$_GET['stub'])); if (!$group->success()) { header("Status: 404 Not Found"); echo "404 Not Found"; exit; } if ($group->get('type')=="private") { if (!$POD->isAuthenticated() || !$group->isMember($POD->currentUser())) { header("Status: 404 Not Found"); echo "404 Not Found"; exit; } } if ($POD->isAuthenticated()) { $POD->currentUser()->expireAlertsAbout($group); } $template = "output"; if (isset($_GET['command'])) { // do something here. // join // quit
if (!$POD->libOptions("enable_contenttype_{$content_type}_list")) { header("Location: " . $POD->siteRoot(false)); exit; } $offset = 0; if (isset($_GET['offset'])) { $offset = $_GET['offset']; } $wikis = $POD->getContents(array('type' => $content_type)); $POD->header('List of supported wikis!'); ?> <div class="column_8"> <? if ($POD->libOptions("enable_contenttype_wiki_add")) if($POD->isAuthenticated() && $POD->currentUser()->get('adminUser')){ ?> <p>Add a new wiki now! <a href="<? $POD->siteRoot(); echo $edit_pattern; ?>">Click here!</a></p> <? } else { ?><p>This software is under developement. Adding new wikis by users will be enabled in coming releases inshalla!</p><? } ?><p>To connect your account on one of the wikis below, please add it <a href="wikiman">here</a></p><? $wikis->output('short_wiki','header','pager','List of supported wikis','Nothing has been posted on this site yet. Wow, it must be brand new!'); ?> </div> <div class="column_4 structure_only"> <? $POD->output('sidebars/search'); ?>
<?php include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('debug' => 0, 'authSecret' => @$_COOKIE['pp_auth'])); // this page is only available to facebook users. if (!$POD->isAuthenticated() || !$POD->currentUser()->facebook_token) { header("Location: /facebook"); exit; } $POD->header("Facebook Friends"); $friends = $POD->currentUser()->getFacebookFriends(); $friends->output('short', 'header', 'footer', 'Facebook Friends', 'None of your Facebook friends are members of this site.'); $POD->footer();
if (!($key && $secret)) { $POD->header('Configuration Required'); echo '<div class="info">Configuration required!</div>'; echo '<p>To enable Facebook login, please set the Facebook API key and secret via the PeoplePods command center.</p>'; echo '<P>To obtain the necessary details from Facebook, <a href="http://www.facebook.com/developers/">register your app</a>.</p>'; $POD->footer(); exit; } $user = null; if (isset($_GET['code'])) { $code = $_GET['code']; $oauth_token = file_get_contents("https://graph.facebook.com/oauth/access_token?client_id=" . $key . "&redirect_uri=" . $POD->siteRoot(false) . "/facebook&client_secret=" . urlencode($secret) . "&code=" . urlencode($code)); list($junk, $oauth_token) = explode("=", $oauth_token); // if authenticated, add to user // if not, new user time! if ($POD->isAuthenticated() && !$POD->currentUser()->facebook_token) { $user = $POD->currentUser(); $test = $POD->getPeople(array('facebook_token' => $oauth_token)); if ($test->count() == 0) { $user->addMeta('facebook_token', $oauth_token); $json = $user->getFacebookInfo(); $user->set('fbuid', $json->id); $POD->addMessage("You have successfully connected your Facebook account."); } else { $POD->addMessage("Another account is already connected to the Facebook account you chose."); } } else { // is there a person with this facebook info already in the db? if so, log her in! $user = $POD->getPeople(array('facebook_token' => $oauth_token)); if ($user->count() == 1) { $user = $user->getNext();
<?php include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('debug' => 0, 'authSecret' => @$_COOKIE['pp_auth'])); // this page is only available to facebook users. if (!$POD->isAuthenticated() || !$POD->currentUser()->twitter_token) { header("Location: /twitter"); exit; } $POD->header("Twitter Friends"); $friends = $POD->currentUser()->getTwitterFriends(); $friends->output('short', 'header', 'footer', 'Twitter Friends', 'None of your Twitter friends are members of this site.'); $POD->footer();