} else { $lockdown = ''; // anyone can see the groups homepage. } $POD = new PeoplePod(array('debug' => 0, 'lockdown' => $lockdown, 'authSecret' => @$_COOKIE['pp_auth'])); if (!$POD->libOptions('enable_core_groups')) { header("Location: " . $POD->siteRoot(false)); exit; } $max = 10; $offset = 0; if (isset($_GET['offset'])) { $offset = $_GET['offset']; } if ($_POST) { $group = $POD->getGroup(); $group->set('groupname', $_POST['groupname']); $group->set('description', $_POST['description']); $group->set('type', $_POST['type']); $group->save(); if (!$group->success()) { $POD->addMessage("Your group was not created! " . $group->error()); } else { $POD->addMessage("Your new group, " . $group->permalink('groupname', true) . " is ready! "); } } if (isset($_GET['q'])) { $header = "Group Search"; $groups = $POD->getGroups(array('or' => array('groupname:like' => '%' . $_GET['q'] . '%', 'description:like' => '%' . $_GET['q'] . '%')), 'g.date DESC', $max, $offset); } else { if ($POD->isAuthenticated()) {
} // create a temporary empty user to output the form $p = $POD->getPerson(); $redirect = null; if (@$_POST['redirect'] || @$_GET['redirect']) { $redirect = $_POST['redirect'] ? $_POST['redirect'] : $_GET['redirect']; $p->set('redirect', $redirect); } $invite_code = null; if (@$_POST['code'] || @$_GET['code']) { $invite_code = $_POST['code'] ? $_POST['code'] : $_GET['code']; if ($invite_deets = $POD->isValidInvite($invite_code)) { $p->set('code', $invite_code, false); $p->set('invited_by', $POD->getPerson(array('id' => $invite_deets['userId'])), false); if ($invite_deets['groupId']) { $p->set('invited_to_group', $POD->getGroup(array('id' => $invite_deets['groupId'])), false); } } else { $POD->addMessage("Sorry, but the invite code you used has expired."); } } if ($redir) { // if we logged in correctly, we redirect to the homepage of the site, or to any url passed in as a parameter if ($redirect) { print header("Location: " . $redirect); } else { print header("Location: " . $POD->siteRoot(false)); } } $POD->header("Create an account"); $p->output('join');
function Test_relationship_functions() { $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 test_tags headline'); $content->set('type', 'this is the type'); $content->save(); $new_content = $POD->getContent(); $new_content->set('headline', 'new child document'); $new_content->set('type', 'post'); $new_content->set('parentId', $content->get('id')); $new_content->save(); //Below tests parent(), and child() //test that the new content's id is set to it's parent's id $this->assertIdentical($new_content->get('parentId'), $content->get('id')); $this->assertIsA($content->children(), 'Stack'); //$this->assertIdentical($new_content->parent()->get('id'), $content->get('id')); //$this->assertFalse(is_string($new_content->parent()->get('id'))); //**Note** $new_content->'id' is either getting set, cashed, or returned as a string. While the parent content is set to an integer $this->assertEqual($new_content->parent()->get('id'), $content->get('id')); $this->assertFalse(is_string($content->get('id'))); //below tests comments() $content->addComment('first comment'); $content->addComment('second comment'); $content->addComment('third comment'); $content_comments = $content->comments(); $this->assertIsA($content_comments, 'Stack'); $first = $content_comments->getNext(); $this->assertEqual($first->comment, 'first comment'); $first = $content_comments->getNext(); $first = $content_comments->getNext(); // this should be the 'third comment' $this->assertEqual($first->comment, 'third comment'); $first = $content_comments->getNext(); // this should return null $this->assertNull($first); $content_comments->reset(); $first = $content_comments->getNext(); $this->assertEqual($first->comment, 'first comment'); //below tests files() $img_file = $content->files(); $this->assertNotNull($img_file); //below tests group() $group = $POD->getGroup(); $group->set('groupname', 'group 1'); $group->set('description', 'this is the group'); $group->save(); $this->assertTrue($group->success()); $content->setGroup($group->get('id')); $this->assertTrue($content->success()); $this->assertEqual($group->get('id'), $content->get('groupId')); $this->assertIsA($content->group(), 'Group'); // below tests tag() $string = "foo bar baz"; $content->tagsFromString($string); $tag_stack = $content->tags(); $this->assertIsA($tag_stack, 'Stack'); $tag = $tag_stack->getNext(); $this->assertIsA($tag, 'Tag'); $this->assertEqual($tag->value, 'foo'); $group->delete(); $new_content->delete(); $content->delete(); $user->delete(); }
<?php include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('lockdown' => 'adminUser', 'authSecret' => @$_COOKIE['pp_auth'])); $POD->changeTheme('admin'); $group = $_GET['group']; $doc = $_GET['doc']; $action = 'add'; if ($_GET['action']) { $action = $_GET['action']; } // load parent $parent = $POD->getGroup(array('id' => $group)); if ($parent->success()) { // load child $child = $POD->getContent(array('id' => $doc)); if ($child->success()) { if ($action == 'add') { $parent->addContent($child); } else { if ($action == 'remove') { $parent->removeContent($child); } } if ($parent->success()) { // refill the children stack $parent->content()->fill(); } else { echo "Could not add to group! " . $parent->error(); } } else {
if ($method == "removeFriend") { if ($POD->isAuthenticated()) { $newfriend = $POD->getPerson(array('id' => $_GET['id'])); $POD->currentUser()->removeFriend($newfriend); if ($POD->currentUser()->success()) { echo json_encode($newfriend->asArray()); } else { echo json_encode(array('error' => $POD->currentUser()->error(), 'id' => $_GET['id'])); } } else { echo json_encode(array('error' => 'PERMISSION DENIED', 'id' => $_GET['id'])); } } if ($method == "removeMember") { if ($POD->isAuthenticated()) { $group = $POD->getGroup(array('id' => $_GET['group'])); if (!$group->success()) { echo json_encode(array('error' => $group->error(), 'id' => $_GET['id'])); return; } $member = $POD->getPerson(array('id' => $_GET['id'])); if (!$member->success()) { echo json_encode(array('error' => $member->error(), 'id' => $_GET['id'])); return; } $group->removeMember($member); if ($group->success()) { echo json_encode($member->asArray()); } else { echo json_encode(array('error' => $group->error(), 'id' => $_GET['id'])); }
include_once("../../PeoplePods.php"); if ($_POST || isset($_GET['command'])) { $lockdown = 'verified'; } else { $lockdown = null; } $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);
<?php include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('lockdown' => 'adminUser', 'authSecret' => @$_COOKIE['pp_auth'])); $POD->changeTheme('admin'); if ($_GET['id'] && $_GET['action'] == "") { // load a Group for editing $group = $POD->getGroup(array('id' => $_GET['id'])); if (!$group->success()) { $message = $group->error(); } } else { if ($_GET['id'] && $_GET['action'] == "delete") { // load a document for editing $group = $POD->getGroup(array('id' => $_GET['id'])); if (!$group->success()) { $message = $doc->error(); } else { $group->delete(); if (!$group->success()) { $message = $doc->error(); } else { header("Location: search.php?msg=Group+deleted!"); } } } else { if ($_POST['action'] == "update") { if ($_POST['id']) { $group = $POD->getGroup(array('id' => $_POST['id'])); } else { $group = $POD->getGroup();
function testGroupContentPrivacy() { $POD = new PeoplePod(); $user = $POD->getPerson(); $user->email = '*****@*****.**'; //create user $user->password = '******'; $user->set('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(); $content2 = $POD->getContent(); $content2->set('headline', 'for friends'); $content2->set('type', 'Friends only'); $content2->set('privacy', 'friends_only'); $content2->save(); $content3 = $POD->getContent(); $content3->set('headline', 'Group members only!'); $content3->set('type', 'private'); $content3->save(); $group = $POD->getGroup(); $group->set('groupname', 'Music Learning Club Austin'); $group->set('description', 'A club where Austin people learn music.'); $group->save(); $group->addContent($content); $group->addContent($content2); $group->addContent($content3); $content3->set('privacy', 'group_only'); $content3->save(); $get_contents = $group->content(); $this->assertEqual($get_contents->count(), 3); //$user should have access to all three contents $user2 = $POD->getPerson(); $user2->email = '*****@*****.**'; //create user $user2->password = '******'; $user2->set('nick', 'test2'); $user2->save(); $POD->changeActor(array('id' => $user2->id)); $group->POD->changeActor(array('id' => $user2->id)); // $user2->addFriend($user); //at this point $user is in $user2's friendlist, but not in the group $get_contents = $group->content()->fill(); $this->assertEqual($get_contents->count(), 1); while ($check = $get_contents->getNext()) { $this->assertNotEqual($check->get('headline'), 'Group members only!'); $this->assertNotEqual($check->get('headline'), 'for friends'); } $POD->changeActor(array('id' => $user->id)); $group->delete(); $user->delete(); $POD->changeActor(array('id' => $user2->id)); $user2->delete(); }