本文整理汇总了PHP中Content::load_content方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::load_content方法的具体用法?PHP Content::load_content怎么用?PHP Content::load_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Content
的用法示例。
在下文中一共展示了Content::load_content方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_suggestion
public static function save_suggestion($cid, $uid, $title, $body, $track, $tags, $ccid = 0, $is_active = 1, $display_on = 0, $is_default_content = FALSE)
{
// global var $path_prefix has been removed - please, use PA::$path static variable
$errors = array();
// ensure integers here
$cid = (int) $cid;
$uid = (int) $uid;
$ccid = (int) $ccid;
// if a new post, make one, otherwise load the existing one
if ($cid) {
$post = Content::load_content($cid, $uid);
// ignore $ccid passed to function if the post already exists
// - we don't allow users to move posts between
// ContentCollections.
$ccid = (int) $post->parent_collection_id;
} else {
$post = new Suggestion();
$post->author_id = $uid;
if ($ccid) {
$post->parent_collection_id = $ccid;
}
}
if ($ccid && $ccid != -1) {
$g = ContentCollection::load_collection($ccid, $uid);
$g->assert_user_access($uid);
} else {
$g = NULL;
}
$post->title = $title;
$post->body = $body;
$post->allow_comments = 1;
$post->is_active = $is_active;
$post->display_on = $display_on;
$post->trackbacks = '';
if ($track) {
$post->trackbacks = implode(",", $track);
}
$post->is_default_content = $is_default_content;
$post->save();
//if ($tags) {
Tag::add_tags_to_content($post->content_id, $tags);
//}
if ($track) {
foreach ($track as $t) {
if (!$post->send_trackback($t)) {
$errors[] = array("code" => "trackback_failed", "msg" => "Failed to send trackback", "url" => $t);
}
}
}
if ($g && !$cid) {
// new post - post it to the group as well
$g->post_content($post->content_id, $uid);
}
if (!$cid) {
// add to suggestion queue automatically if not editing
ModerationQueue::moderate_suggestion($post->content_id);
}
return array("cid" => (int) $post->content_id, "moderation_required" => $g ? $g->is_moderated == 1 && $g->author_id != $uid : FALSE, "errors" => $errors);
}
示例2: get_moderation_queue
function get_moderation_queue()
{
$Group = new Group();
$Group->collection_id = $this->set_id;
$Group->is_active = 1;
$this->Paging["count"] = $Group->get_moderation_queue('content', $cnt = TRUE);
$contentIdArray = $Group->get_moderation_queue('content', $cnt = FALSE, $this->Paging["show"], $this->Paging["page"]);
for ($counter = 0; $counter < count($contentIdArray); $counter++) {
$cid = $contentIdArray[$counter];
$content = Content::load_content((int) $cid, (int) $_SESSION['user']['id']);
$this->content_data[] = array('content_id' => $cid, 'author_id' => $content->author_id, 'title' => $content->title, 'created' => date("M - d - Y", $content->created));
}
}
示例3: get_links
/**
Get all the links of different group of given search String
**/
private function get_links()
{
global $login_uid;
$links = array();
if (@$this->name_string) {
$tag_var = new Tag();
switch ($this->name_string) {
case 'group_tag':
$this->Paging["count"] = $tag_var->get_associated_contentcollectionids($this->keyword, $cnt = TRUE);
$tag_list = $tag_var->get_associated_contentcollectionids($this->keyword, $cnt = FALSE, $this->Paging["show"], $this->Paging["page"]);
$cnt = count($tag_list);
if ($cnt > 0) {
for ($i = 0; $i < $cnt; $i++) {
$link[$i] = Group::load_group($tag_list[$i]['id']);
}
$links['group_info'] = objtoarray($link);
}
break;
case 'network_tag':
// at present we are not using this
break;
case 'user_tag':
$this->Paging["count"] = $tag_var->get_associated_userids($this->keyword, $cnt = TRUE);
$tag_list = $tag_var->get_associated_userids($this->keyword, $cnt = FALSE, $this->Paging["show"], $this->Paging["page"]);
$cnt = count($tag_list);
$link = array();
if ($cnt > 0) {
for ($i = 0; $i < $cnt; $i++) {
$usr = new User();
$usr->load((int) $tag_list[$i]['id']);
$link[$i] = $usr;
}
}
$links['user_info'] = objtoarray($link);
break;
case 'content_tag':
$this->Paging["count"] = $tag_var->get_associated_content_ids($this->keyword, $cnt = TRUE);
$tag_list = $tag_var->get_associated_content_ids($this->keyword, $cnt = FALSE, $this->Paging["show"], $this->Paging["page"]);
$cnt = count($tag_list);
$link = array();
if ($cnt > 0) {
for ($i = 0; $i < $cnt; $i++) {
$link[$i] = Content::load_content($tag_list[$i]['id'], $login_uid);
}
}
$links['content_info'] = objtoarray($link);
break;
}
}
return $links;
}
示例4: render
function render()
{
$links = array();
if ($this->page_id == PAGE_USER_PUBLIC) {
$links = Comment::get_comment_for_user(PA::$page_uid, 5);
} else {
if ($this->page_id == PAGE_USER_PRIVATE) {
$relations_ids = Relation::get_all_relations((int) PA::$login_uid, 0, FALSE, 'ALL', 0, 'created', 'DESC', 'internal', APPROVED, PA::$network_info->network_id);
$tmp_links = array();
foreach ($relations_ids as $relation) {
$tmp_links[] = Comment::get_comment_for_user((int) $relation['user_id'], 5);
}
$cnt = 0;
$links = array();
$link_cnts = array();
do {
foreach ($tmp_links as $idx => $rel_links) {
if (empty($link_cnts[$idx])) {
$link_cnts[$idx] = 0;
}
if (isset($rel_links[$link_cnts[$idx]])) {
$links[] = $rel_links[$link_cnts[$idx]++];
$cnt++;
}
if ($cnt >= 5) {
break;
}
}
} while ($cnt++ <= 5);
} else {
$links = Comment::get_comment_for_content(NULL, $count = 5, 'DESC', TRUE);
}
}
foreach ($links as &$link) {
if (!empty($link['content_id'])) {
$post = Content::load_content((int) $link['content_id'], PA::$login_uid);
$link['post_title'] = $post->title;
} else {
$link['post_title'] = __('No title');
}
}
$this->inner_HTML = $this->generate_inner_html($links);
$content = parent::render();
return $content;
}
示例5: strip_tags
require_once "web/includes/functions/user_page_functions.php";
// for query count
global $query_count_on_page;
$query_count_on_page = 0;
$show_media = NULL;
$error_msg = NULL;
if (!empty($_GET['cid'])) {
if (!empty($_POST['rptabuse'])) {
// if an abuse is reported
require_once "web/includes/blocks/submit_abuse.php";
if (isset($_GET['err'])) {
$error_msg = strip_tags(urldecode($_GET['err']));
}
}
$cid = $_GET['cid'];
if ($content_info = Content::load_content($cid, $login_uid)) {
$info = ContentCollection::get_collection_type($content_info->parent_collection_id);
if ($content_info->type == 'Image') {
$show_media = new Image();
} else {
if ($content_info->type == 'Audio') {
$show_media = new Audio();
} else {
if ($content_info->type == 'TekVideo') {
$show_media = new TekVideo();
} else {
die("Content ID {$cid} is non-media (not image, audio, or video)");
}
}
}
$show_media->load($cid);
示例6: __construct
/**
Purpose : this function is used to get navigation links for the whole page.
Scope : public
@param - it needs no direct input. But works only on the basis of current page initialized in __construct()
@return - array of links
**/
public function get_links($optional = NULL)
{
//initialization
global $page_uid, $login_uid;
if (isset($_SESSION['user']['id'])) {
$extra = unserialize($this->network_info->extra);
if (@$extra['reciprocated_relationship'] == NET_YES) {
$status = APPROVED;
} else {
$status = FALSE;
}
$relations_ids = Relation::get_relations((int) $_SESSION['user']['id'], $status);
$user_groups = Group::get_user_groups((int) $_SESSION['user']['id']);
/* $gid isn't defined in this function, so the following call
* will probably always return FALSE. To get rid of the warning
* under E_ALL, I've replaced the following expression with
* FALSE. Maybe $gid should be get_group_id()? */
$is_owner_of_group = FALSE;
//Group::is_admin($gid,(int)$_SESSION['user']['id']) ;
}
if (isset($relations_ids) && sizeof($relations_ids)) {
$this->set_friend_uid($relations_ids[0]);
}
if (isset($user_groups) && sizeof($user_groups)) {
$this->users_first_group_id($user_groups[0]['gid']);
}
if ($login_uid) {
$this->set_uid($login_uid);
} else {
$this->set_anonymous();
}
$is_group_content = FALSE;
if (@$_GET['gid']) {
$this->set_group_id($_GET['gid']);
} else {
if ((FILE_FORUM_MESSAGES == $this->current_page || FILE_CONTENT == $this->current_page) && !empty($_REQUEST['ccid'])) {
$this->set_group_id($_REQUEST['ccid']);
$is_group_content = TRUE;
} else {
if (FILE_CONTENT == $this->current_page && !empty($_GET['cid'])) {
try {
$content_data = Content::load_content($_GET['cid'], $this->get_uid());
} catch (PAException $e) {
if ($e->getCode() != CONTENT_NOT_FOUND) {
throw $e;
}
}
if (isset($content_data)) {
if ($content_data->parent_collection_id > 0) {
$content_collection_data = ContentCollection::load_collection($content_data->parent_collection_id, $this->get_uid());
if ($content_collection_data->type == GROUP_COLLECTION_TYPE) {
$this->set_group_id($content_data->parent_collection_id);
$is_group_content = TRUE;
}
}
}
}
}
}
//test
//$this->current_page='test.php';
// make links for current page
$this->make_links();
$level_1 = $this->get_level_1();
$level_2 = $this->get_level_2();
$level_3 = NULL;
$left_user_public_links = NULL;
if (Network::is_admin($this->network_info->network_id, (int) @$_SESSION['user']['id'])) {
$level_3 = $this->get_level_3('network');
} else {
if (!$this->network_info && $_SESSION['user']['id'] == SUPERUSER) {
$level_3 = $this->get_level_3('network');
}
}
$level_3 = NULL;
switch ($this->current_page) {
/*----------------------------------------------------*/
case FILE_HOMEPAGE:
$level_3 = NULL;
$level_2['highlight'] = 'home';
break;
case FILE_LOGIN:
$level_2['highlight'] = 'home';
break;
case FILE_SEARCH_HOME:
$level_2['highlight'] = 'search';
break;
case FILE_TAG_SEARCH:
$level_2['highlight'] = 'tag_search';
break;
/*----------------------------------------------------*/
/*----------------------------------------------------*/
case FILE_USER:
case FILE_USER_BLOG:
//.........这里部分代码省略.........
示例7: count
}
if (Group::is_admin((int) $group->collection_id, (int) $_SESSION['user']['id'])) {
$is_admin = TRUE;
if ($group->is_moderated || $group->reg_type == $group->REG_MODERATED) {
$total_in_mod_queue = count($group->get_moderation_queue('content')) + count($group->get_moderation_queue('user'));
}
}
$members = count($group->get_members());
$contents = $group->get_moderation_queue("content");
$mod_users = $group->get_moderation_queue("user");
$content_details = array();
$user_details = array();
if ($group->is_moderated) {
$i = 0;
foreach ($contents as $con) {
$c = Content::load_content((int) $con, $_SESSION['user']['id']);
$tags = Tag::load_tags_for_content((int) $con);
if ($tags) {
$t = array();
for ($j = 0; $j < count($tags); $j++) {
$tid = $tags[$j]['id'];
$uid = $_SESSION['user']['id'];
$t[] = "<a href=\"tags.php?uid={$uid}&tagid={$tid}\">" . $tags[$j]['name'] . "</a>";
}
$content_details[$i]['tag_entry'] = "<b>Tags : </b>" . implode(", ", $t);
} else {
$content_details[$i]['tag_entry'] = "";
}
$u = new User();
$u->load((int) $c->author_id);
$content_details[$i]['content_id'] = $c->content_id;
示例8: route2groups
function route2groups()
{
global $user, $is_edit;
$extra = unserialize(PA::$network_info->extra);
$tags = preg_split('/\\s*,\\s*/', strtolower($_POST['tags']));
$tags = array_unique($tags);
$net_owner = new User();
$net_owner->load((int) PA::$network_info->owner_id);
$valid_post_types = array('BlogPost', 'Contribution', 'Suggestion');
$type = isset($_POST) && isset($_POST['blog_type']) && in_array($_POST['blog_type'], $valid_post_types) ? $_POST['blog_type'] : 'BlogPost';
//find tag entry
$terms = array();
foreach ($tags as $term) {
$tr = trim($term);
if ($tr) {
$terms[] = $tr;
}
}
if (!empty($_POST['route_to_pa_home']) && $_POST['route_to_pa_home'] == 1) {
$display_on_homepage = DISPLAY_ON_HOMEPAGE;
//its zero
} else {
$display_on_homepage = NO_DISPLAY_ON_HOMEPAGE;
//This will not show up on homepage - flag has opposite values
}
if (is_array($_POST['route_targets_group'])) {
if (in_array(-2, $_POST['route_targets_group'])) {
//-2 means Select none of group
// no need to post in any group
} elseif (in_array(-1, $_POST['route_targets_group'])) {
//-1 means select all the groups
// post in all the groups
$group_array = explode(',', $_POST['Allgroups']);
foreach ($group_array as $gid) {
// post to all the groups
$_group = Group::load_group_by_id((int) $gid);
$login_required_str = null;
if ($_group->access_type == ACCESS_PRIVATE) {
$login_required_str = '&login_required=true';
}
switch ($type) {
case 'BlogPost':
default:
$res = BlogPost::save_blogpost(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
break;
case 'Contribution':
$res = Contribution::save_contribution(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
break;
case 'Suggestion':
$res = Suggetion::save_suggestion(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
break;
}
$permalink_cid = $res['cid'];
// NOTE: would this notification message be sent for each group ???
$content_obj = Content::load_content((int) $permalink_cid);
PANotify::send("content_posted", PA::$network_info, $user, $content_obj);
// notify network owner (maybe group owner would be better?)
if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) {
PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj);
}
//-------
//for rivers of people
$activity = 'group_post_a_blog';
$activity_extra['info'] = $user->first_name . 'posted a new blog';
$activity_extra['blog_name'] = $_POST["blog_title"];
$activity_extra['blog_id'] = $permalink_cid;
$activity_extra['blog_url'] = PA::$url . PA_ROUTE_CONTENT . '/cid=' . $permalink_cid . $login_required_str;
$extra = serialize($activity_extra);
$object = $gid;
// update status to unverified
$group = ContentCollection::load_collection((int) $gid, PA::$login_uid);
if ($group->reg_type == REG_MODERATED) {
Network::moderate_network_content((int) $gid, $permalink_cid);
} else {
if ($extra['network_content_moderation'] == NET_YES && $is_edit == 0 && PA::$network_info->owner_id != $user->user_id) {
Network::moderate_network_content($gid, $permalink_cid);
}
}
if (!PA::is_moderated_content() && $group->reg_type != REG_MODERATED) {
//Write to activity log only when moderation is off
Activities::save($user->user_id, $activity, $object, $extra);
}
}
} else {
// post in selected groups
foreach ($_POST['route_targets_group'] as $gid) {
//only send to selected groups
$_group = Group::load_group_by_id((int) $gid);
$login_required_str = null;
if ($_group->access_type == ACCESS_PRIVATE) {
$login_required_str = '&login_required=true';
}
switch ($type) {
case 'BlogPost':
default:
$res = BlogPost::save_blogpost(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
break;
case 'Contribution':
$res = Contribution::save_contribution(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
break;
//.........这里部分代码省略.........
示例9: moderate_content
/**
* flag a content to be moderated
* @access public
* @param int content_id ID of content to be moderated
*/
public function moderate_content($content_id)
{
Logger::log("Enter: Group::moderate_content() | Args: \$content_id = {$content_id}");
$c = Content::load_content($content_id, $_SESSION['user']['id']);
if (!Group::is_admin($this->collection_id, $c->author_id)) {
ModerationQueue::moderate_content($content_id, $this->collection_id);
} else {
$this->approve($content_id, 'content');
}
Logger::log("Exit: Group::moderate_content()");
return;
}
示例10: user_can
/**
* function used to check permissions for user to do an activity
* @param $params is array of parameters like $params['action'], $param['uid']..
*/
function user_can($params)
{
global $network_info, $login_uid;
$action = $params['action'];
switch ($action) {
case 'edit_content':
case 'delete_content':
if ($params['uid'] && $params['cid']) {
//super admin can edit/ delete any content
if ($params['uid'] == SUPER_USER_ID) {
return true;
}
// network owner can edit / delete any content in a network
if (Network::is_admin($network_info->network_id, $params['uid'])) {
return true;
}
//Loading content
$content_obj = Content::load_content((int) $params['cid'], $params['uid']);
//author of the content can perform the action
if ($content_obj->author_id == $params['uid']) {
return true;
}
if ($content_obj->parent_collection_id != -1) {
// content is a part of some collection
// Loading collection
$collection_obj = ContentCollection::load_collection((int) $content_obj->parent_collection_id, $params['uid']);
// owner of collection can also edit the content
if ($collection_obj->author_id == $params['uid']) {
return true;
}
}
}
break;
case 'delete_comment':
//network owner can delete any comment
$comment = $params['comment_info'];
//array having the comment details
if ($login_uid == SUPER_USER_ID) {
//Super user can delete any comment
return true;
} else {
if ($network_info->owner_id == $login_uid) {
//Network owner can delete the comment
return true;
} else {
if ($comment['user_id'] == $login_uid) {
//Author of comment can delete the comment
return true;
} else {
if ($comment['recipient_id'] == $login_uid) {
return true;
}
}
}
}
$content = Content::load_content((int) $comment['content_id'], $login_uid);
if ($content->author_id == $login_uid) {
//Author of the content can delete the comment.
return true;
} else {
if ($content->parent_collection_id != -1) {
// means content belongs to some collection
$collection = ContentCollection::load_collection($content->parent_collection_id, $login_id);
if ($collection->author_id == $login_uid) {
//If content on which comment has been posted belongs to some collection then author of that collection can delete the comment
return true;
}
}
}
return false;
// return false in all the other cases
break;
case 'edit_forum':
$perm_array = array($network_info->owner_id, SUPER_USER_ID, $params['group_owner'], $params['forum_owner']);
return in_array($login_uid, $perm_array);
break;
case 'delete_rep':
// Delete the Replies of forum
$perm_array = array($network_info->owner_id, SUPER_USER_ID, $params['group_owner'], $params['forum_owner'], $params['rep_owner']);
return in_array($login_uid, $perm_array);
break;
case 'view_group_content':
if ($params['allow_anonymous']) {
return true;
}
$perm_array = array($network_info->owner_id, SUPER_USER_ID, $params['group_owner']);
$member_type = array(MEMBER, MODERATOR, OWNER);
if (in_array($login_uid, $perm_array) || in_array($params['member_type'], $member_type)) {
return true;
}
break;
case 'view_abuse_report_form':
if (empty($login_uid)) {
return false;
}
$extra = unserialize($network_info->extra);
//.........这里部分代码省略.........
示例11: User
// global var $path_prefix has been removed - please, use PA::$path static variable
require_once "api/Content/Content.php";
require_once "api/Tag/Tag.php";
require_once "api/Comment/Comment.php";
require_once "api/Group/Group.php";
require_once "api/Category/Category.php";
require_once "api/Network/Network.php";
require_once "web/includes/functions/user_page_functions.php";
$header = 'header_user.tpl';
// by default we are setting header as user's header
$media_gallery = 'homepage';
/**
when collection type is not a Group
*/
$setting_data = ModuleSetting::load_setting(PAGE_PERMALINK, $uid);
$content = Content::load_content((int) $_REQUEST['cid'], (int) PA::$login_uid);
// apply output filtering
$content->title = _out($content->title);
$author = new User();
$author->load((int) $content->author_id);
$is_group_content = FALSE;
/**
If Collection Type is a Group than left and right module will be the same as Group page
*/
$gid = @$_REQUEST['ccid'];
$content_id = @$_REQUEST['cid'];
$error_message = '';
$authorized_users = array($content->author_id, PA::$network_info->owner_id);
$extra = unserialize(PA::$network_info->extra);
if (@$extra['network_content_moderation'] == NET_YES && Network::item_exists_in_moderation($content_id, $content->parent_collection_id, 'content') && !in_array(PA::$login_uid, $authorized_users)) {
$error_message = 1001;
示例12: testAddDeleteContentComments
function testAddDeleteContentComments()
{
// Dal::register_query_callback("explain_query");
echo "getting a user\n";
$user = Test::get_test_user();
echo "test user = {$user->first_name} {$user->last_name}\n";
echo "adding some content\n";
$post = new BlogPost();
$post->author_id = $user->user_id;
$post->parent_collection_id = -1;
$post->title = "Test blog post (from testAddDeleteContentComments)";
$post->body = "<p>This is the post body!</p><p>Foo <b>foo</b> foo</p>";
$post->allow_comments = 1;
$post->is_active = 1;
$post->display_on = DISPLAY_ON_HOMEPAGE;
$post->save();
echo "... saved as content_id={$post->content_id}\n";
echo "testing that it is retrievable\n";
$post_retr = Content::load_content($post->content_id, $user->user_id);
$this->assertEquals($post_retr->content_id, $post->content_id);
$this->assertEquals($post_retr->title, $post->title);
$this->assertEquals($post_retr->body, $post->body);
$this->assertEquals($post_retr->author_id, $user->user_id);
$this->assertEquals($post_retr->is_active, 1);
echo "posting a comment\n";
$cmt = new Comment();
$cmt->content_id = $post->content_id;
$cmt_comment = "This is an automatic comment - on an autogenerated post";
$cmt->comment = $cmt_comment;
$cmt->user_id = $user->user_id;
$cmt->name = $cmt->email = $cmt->homepage = '';
$cmt->ip_addr = '127.0.0.1';
$cmt->referrer = 'http://example.com/';
$cmt->user_agent = 'phpunit auto-test';
$cmt->save();
echo "... saved as comment_id={$cmt->comment_id}\n";
echo "testing that the comment is retrievable\n";
$cmt_retr = new Comment();
$cmt_retr->load($cmt->comment_id);
$this->assertEquals($cmt_retr->comment_id, $cmt->comment_id);
$this->assertEquals($cmt_retr->content_id, $post->content_id);
$this->assertEquals($cmt_retr->comment, $cmt_comment);
$this->assertEquals($cmt_retr->is_active, 1);
echo "testing that we see one comment on the post\n";
$comments = Comment::get_comment_for_content($post->content_id);
echo count($comments) . " comments\n";
//var_dump($comments);
$this->assertEquals(count($comments), 1);
echo "testing that we have no trackbacks on the post\n";
$trackbacks = Content::get_trackbacks_for_content($post->content_id);
echo count($trackbacks) . " trackbacks\n";
//var_dump($trackbacks);
$this->assertEquals(count($trackbacks), 0);
echo "posting ANOTHER comment\n";
$cmt2 = new Comment();
$cmt2->content_id = $post->content_id;
$cmt2_comment = "This is ANOTHER automatic comment - on the same autogenerated post";
$cmt2->comment = $cmt_comment;
$cmt2->user_id = $user->user_id;
$cmt2->name = $cmt2->email = $cmt2->homepage = '';
$cmt2->ip_addr = '127.0.0.1';
$cmt2->referrer = 'http://example.com/';
$cmt2->user_agent = 'phpunit auto-test';
$cmt2->save();
echo "... saved as comment_id={$cmt2->comment_id}\n";
echo "testing that we see two comments on the post\n";
$comments = Comment::get_comment_for_content($post->content_id);
$this->assertEquals(count($comments), 2);
echo "deleting the first comment\n";
$cmt_retr->delete();
echo "testing that we see one comment on the post again (not seeing the deleted one)\n";
$comments = Comment::get_comment_for_content($post->content_id);
$this->assertEquals(count($comments), 1);
echo "testing that the first comment (now deleted) is not retrievable\n";
$cmt_retr_fail = new Comment();
try {
$cmt_retr_fail->load($cmt->comment_id);
$this->assertTrue(FALSE);
// shouldn't get here
} catch (PAException $e) {
$this->assertEquals($e->getCode(), COMMENT_NOT_EXIST);
}
echo "deleting the post\n";
Content::delete_by_id($post->content_id);
echo "testing that the post is not retrievable\n";
try {
$post_retr_fail = Content::load_content($post->content_id, $user->user_id);
$this->assertTrue(FALSE);
// shouldn't get here
} catch (PAException $e) {
$this->assertEquals($e->getCode(), CONTENT_NOT_FOUND);
}
echo "testing that the last comment is not retrievable\n";
$cmt_retr_fail = new Comment();
try {
$cmt_retr_fail->load($cmt->comment_id);
$this->assertTrue(FALSE);
// shouldn't get here
} catch (PAException $e) {
$this->assertEquals($e->getCode(), COMMENT_NOT_EXIST);
//.........这里部分代码省略.........
示例13: load_data
function load_data($error_msg = '')
{
global $base_url;
global $current_theme_path;
$this->categories = Category::build_all_category_list();
if (!empty($error_msg)) {
$this->error_msg = $error_msg;
}
if ($this->id == 0) {
$this->title = 'Add Blog Post';
return;
} else {
$this->title = '';
$content = Content::load_content((int) $this->id, $_SESSION['user']['id']);
$content_tags = Tag::load_tags_for_content((int) $this->id);
$this->blog_title = stripslashes($content->title);
$this->body = stripslashes($content->body);
$this->trackback = $content->trackbacks;
$this->collection_id = @$content->collection_id;
if (count($content_tags)) {
foreach ($content_tags as $tag) {
$out[] = $tag['name'];
}
$this->tag_entry = implode(', ', $out);
}
}
}
示例14: peopleaggregator_deleteFile
function peopleaggregator_deleteFile($args)
{
$user = User::from_auth_token($args['authToken']);
$file_id = api_extract_id("file", $args['id']);
// load file
$f = Content::load_content($file_id, $user->user_id);
// are we the author?
if ($f->author_id != $user->user_id) {
throw new PAException(USER_ACCESS_DENIED, "You can only delete your own files");
}
// delete it!
$f->delete();
return array("success" => TRUE);
}
示例15: urlencode
break;
case 'Suggestion':
$post_saved = Suggestion::save_suggestion(0, PA::$login_uid, $_POST["blog_title"], $_POST["description"], NULL, $terms, $ccid, 1, $display_on_homepage);
break;
}
$permalink_cid = $post_saved['cid'];
if (PA::is_moderated_content() && PA::$network_info->owner_id != $user->user_id) {
Network::moderate_network_content(-1, $permalink_cid);
// -1 for contents; not a part of any collection
$error_msg = "&err=" . urlencode(MessagesHandler::get_message(1004));
}
$login_required_str = null;
if (PA::is_moderated_content()) {
$login_required_str = '&login_required=true';
}
$content_obj = Content::load_content((int) $permalink_cid);
PANotify::send("content_posted", PA::$network_info, $user, $content_obj);
if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) {
PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj);
}
//for rivers of people
$activity = 'user_post_a_blog';
$activity_extra['info'] = $user->first_name . 'posted a new blog';
$activity_extra['blog_name'] = $_POST["blog_title"];
$activity_extra['blog_id'] = $permalink_cid;
$activity_extra['blog_url'] = PA::$url . PA_ROUTE_CONTENT . '/cid=' . $permalink_cid . $login_required_str;
$extra = serialize($activity_extra);
$object = $permalink_cid;
if (!PA::is_moderated_content()) {
//Write to activity log only when moderation is off
Activities::save($user->user_id, $activity, $object, $extra);