function test_File_fields() { $POD = new PeoplePod(); $user = $POD->getPerson(array('nick' => 'admin')); $POD->changeActor(array('id' => $user->id)); $most_recent = $POD->getFiles(array('userId' => $user->get('id'))); $file = $most_recent->getNext(); $this->assertIsA($file, 'File'); $this->assertTrue($file->isImage()); $creator = $file->creator(); $this->assertIsA($creator, 'Person'); $owner = $file->owner(); $this->assertIsA($owner, 'Person'); $this->assertTrue($file->get('userId'), $user->id); $this->assertEqual($file->get('extension'), 'jpg'); $this->assertNotNull($file->get('id')); $this->assertNotNull($file->get('contentId')); $this->assertEqual($file->get('original_name'), 'darwin.jpg'); $this->assertNull($file->get('description')); //should this be initialized to null? $this->assertEqual($file->get('mime_type'), 'image/jpeg'); $this->assertNotNull($file->get('date')); $this->assertNotNull($file->get('minutes')); $parent_content = $file->parent(); $this->assertIsA($parent_content, 'Content'); $this->assertEqual($parent_content->get('headline'), 'Darwin'); //now attempt to get a file by means of getFile() $new_file = $POD->getFile(array('id' => $file->get('id'))); $this->assertIsA($new_file, 'File'); }
/*********************************************** * This file is part of PeoplePods * (c) xoxco, inc * http://peoplepods.net http://xoxco.com * * core_files/index.php * Handles simple requests to /download * Allows files to be downloaded with their original file name * * Documentation for this pod can be found here: * http://peoplepods.net/readme /**********************************************/ include_once "../../PeoplePods.php"; error_reporting(0); $POD = new PeoplePod(array('debug' => 0)); // no parameters, we want the most basic pod we can get to serve images if (!$POD->libOptions('enable_core_files')) { header("Location: " . $POD->siteRoot(false)); exit; } $f = $POD->getFile(array('id' => $_GET['id'])); if (!$f->success()) { header("Status: 404 Not Found"); echo "404 Not Found"; exit; } $f->download($_GET['size']); if (!$f->success()) { header("Status: 404 Not Found"); echo "Download Failed"; }
} if (@$_GET['comment']) { if (is_numeric($_GET['comment'])) { $comment = $POD->getComment(array('id' => $_GET['comment'])); if (!$comment->success()) { echo results(array('error' => $comment->error())); exit; } $data['comment'] = $comment->asArray(); } else { // if not a comment id, a comment parameter meant for an addComment call. } } if (@$_GET['file']) { if (is_numeric($_GET['file'])) { $file = $POD->getFile(array('id' => $_GET['file'])); } if (!$file->success()) { echo results(array('error' => $file->error())); exit; } $data['file'] = $file->asArray(); } if (@$_GET['alert']) { if (is_numeric($_GET['alert'])) { $alert = $POD->getAlert(array('id' => $_GET['alert'])); } if (!$alert->success()) { echo results(array('error' => $alert->error())); exit; }
<?php include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('debug' => 0, 'lockdown' => 'adminUser', 'authSecret' => @$_COOKIE['pp_auth'])); $POD->changeTheme('admin'); if (isset($_GET['id'])) { $file = $POD->getFile(array('id' => $_GET['id'])); if (!$file->success()) { $message = $file->error(); } else { if ($file->parent()) { $content = $file->parent(); } else { if ($file->group()) { $group = $file->group(); } else { $user = $file->author(); } } } $POD->header(); include_once "tools.php"; if (isset($message)) { ?> <div class="info"> <?php echo $message; ?> </div>