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); }
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)); } }
/** 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; }
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; }
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);
/** 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: if (!$page_uid && !$login_uid) { throw new PAException("", "Invalid page access"); } if ($page_uid) { //uid get variable set //these links are to be added in front $relation_already_exists_links = array('send_message' => array('caption' => 'Send a message', 'url' => $this->base_url . '/' . FILE_ADDMESSAGE . '?uid=' . $page_uid), 'change_relationship' => array('caption' => 'Change Relationship', 'url' => $this->base_url . '/' . FILE_EDIT_RELATIONS . '?uid=' . $page_uid . '&action=change'), 'delete_relationship' => array('caption' => 'Delete Relationship', 'url' => $this->base_url . '/' . FILE_EDIT_RELATIONS . '?action=delete&uid=' . $page_uid . '', 'extra' => ' onclick ="return delete_confirmation_msg(\'Are you sure you want to delete this Relationship?\') "'), 'send_testimonial' => array('caption' => 'Write Testimonial', 'url' => $this->base_url . '/' . FILE_WRITE_TESTIMONIAL . '?uid=' . $page_uid), 'user_comment' => array('caption' => 'Write Comment', 'url' => $this->base_url . '/' . FILE_WRITE_USER_COMMENT . '?uid=' . $page_uid)); $relation_does_not_exists_links = array('send_message' => array('caption' => 'Send a message', 'url' => $this->base_url . '/' . FILE_ADDMESSAGE . '?uid=' . $page_uid), 'make_connection' => array('caption' => 'Add a Relationship', 'url' => $this->base_url . '/' . FILE_EDIT_RELATIONS . '?uid=' . $page_uid . '&action=add'), 'send_testimonial' => array('caption' => 'Write Testimonial', 'url' => $this->base_url . '/' . FILE_WRITE_TESTIMONIAL . '?uid=' . $page_uid), 'user_comment' => array('caption' => 'Write Comment', 'url' => $this->base_url . '/' . FILE_WRITE_USER_COMMENT . '?uid=' . $page_uid)); if ($page_uid == $login_uid) { //login and get uid same means user's public page $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); } else { // make left and right links //user's public page requires different link rendering if (!empty($relations_ids)) { if (in_array($page_uid, $relations_ids)) { $left_user_public_links = $relation_already_exists_links; } else { $left_user_public_links = $relation_does_not_exists_links; } } else { $left_user_public_links = $relation_does_not_exists_links; } } } else { //means user's private page $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'user_private'; } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_PEOPLES: $level_2['highlight'] = 'people'; $level_3 = $this->get_level_3('people'); $level_3['highlight'] = 'find_people'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_VIEW_ALL_MEMBERS: if (@$_GET['gid']) { $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'group_members'; } else { $level_2['highlight'] = 'people'; if ($page_uid == $login_uid) { $level_3 = $this->get_level_3('people'); if (!empty($_GET['view_type']) && $_GET['view_type'] == 'relations') { $level_3['highlight'] = 'my_friends'; } else { if (!empty($_GET['view_type']) && $_GET['view_type'] == 'in_relations') { $level_3['highlight'] = 'people_who_call_me_friend'; } else { $level_3['highlight'] = 'find_people'; } } } } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_INVITATION: $level_2['highlight'] = 'people'; $level_3 = $this->get_level_3('people'); $level_3['highlight'] = 'invite'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_UPLOAD_MEDIA: case FILE_MEDIA_GALLERY: if ($login_uid) { if (isset($_GET['view']) && 'friends' == $_GET['view']) { //user is viewing his friends gallery $level_2['highlight'] = 'people'; $level_3 = $this->get_level_3('people'); $level_3['highlight'] = 'friends_gallery'; } else { if ($page_uid != $login_uid && $page_uid != '') { //user is viewing his private page gallery $level_2['highlight'] = 'people'; } else { if ($page_uid == $login_uid || !$page_uid) { $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'my_gallery'; } } } } else { if (!empty($page_uid)) { // for anonymous user $level_2['highlight'] = 'people'; } } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_CUSTOMIZE_UI: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'customize_ui'; break; case FILE_USER_CALENDAR: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'my_events'; break; case FILE_EDIT_PROFILE: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'settings'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_EDIT_RELATIONS: $level_2['highlight'] = 'people'; $level_3 = $this->get_level_3('people'); $level_3['highlight'] = 'find_people'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_GROUPS_HOME: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); $level_3['highlight'] = 'find_groups'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_GROUPS_CATEGORY: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); $level_3['highlight'] = 'find_groups'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_ADDGROUP: $level_2['highlight'] = 'groups'; if (!empty($_GET['gid'])) { $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'edit_group'; } else { $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); $level_3['highlight'] = 'create_group'; } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_GROUP: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'group_home'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_FORUM_MESSAGES: case FILE_FORUM_HOME: case FILE_CREATE_FORUM: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'group_forum'; break; case FILE_GROUP_CALENDAR: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'group_events'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_GROUP_INVITATION: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); $level_3['highlight'] = 'invite'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_GROUP_MEDIA_GALLERY: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'group_gallery'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_EDIT_FORUM: case FILE_FORUM_MESSAGES: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_WIDGET: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'user_widgets'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_MYMESSAGE: case FILE_ADDMESSAGE: case FILE_VIEW_MESSAGE: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'messages'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_POST_CONTENT: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'create_post'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_CONTENT_MANAGEMENT: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'manage_posts'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_ADDGROUP: $level_2['highlight'] = 'group'; if ($_GET['gid']) { $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'edit_group'; } else { $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); $level_3['highlight'] = 'create_group'; } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_GROUP_MODERATION: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); if ('members' == $_GET['view']) { $level_3['highlight'] = 'moderate_users'; } if ('content' == $_GET['view']) { $level_3['highlight'] = 'moderate_posts'; } if ('users' == $_GET['view']) { $level_3['highlight'] = 'moderate_membership_requests'; } break; case FILE_MANAGE_GROUP_CONTENTS: $level_1['highlight'] = 'networks_directory'; $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'manage_group_content'; break; case FILE_CUSTOMIZE_GROUP: $level_1['highlight'] = 'networks_directory'; $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'group_customize_ui'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_NETWORKS_HOME: case FILE_NETWORKS_CATEGORY: $level_1['highlight'] = 'networks_directory'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_NETWORK_USER_DEFAULTS: case FILE_RELATIONSHIP_SETTINGS: case FILE_EMAIL_NOTIFICATION: case FILE_MANAGE_TAKETOUR: case FILE_MANAGE_EMBLEM: case FILE_CONFIGURE_SPLASH_PAGE: case FILE_NETWORK_FEATURE: case FILE_NETWORK_CUSTOMIZE_UI_PAGE: case FILE_NETWORK_STATS: case FILE_NETWORK_LINKS: case FILE_NEW_USER_BY_ADMIN: case FILE_NETWORK_MANAGE_CONTENT: case FILE_MODULE_SELECTOR: case FILE_NETWORK_BULLETINS: case FILE_NETWORK_MANAGE_USER: case FILE_NETWORK_CALENDAR: case FILE_MANAGE_AD_CENTER: case FILE_MANAGE_GROUP_FORUM: case FILE_MANAGE_COMMENTS: case FILE_RANKING: case FILE_MISREPORTS: case FILE_ROLES: case FILE_ASSIGN_TASK: $level_2 = $this->get_level_3('network'); // $level_3 = $this->get_level_3('manage_network'); $level_1['highlight'] = 'configure_network'; $level_2['highlight'] = 'configure_network'; /* $level_3['highlight'] = 'manage_user'*/ break; case FILE_CREATENETWORK: $level_1['highlight'] = 'create_network'; $level_3['highlight'] = 'statistics'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_SHOWCONTENT: if ($_GET['gid']) { $level_2['highlight'] = groups; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_LINKS_MANAGEMENT: $level_2['highlight'] = 'user'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_MEDIA_FULL_VIEW: if (!empty($_GET['gid'])) { $level_2['highlight'] = groups; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); } else { $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); } break; case FILE_REGISTER: $level_2['highlight'] = 'home'; break; case FILE_EDIT_MEDIA: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'my_gallery'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_EDITNETWORK: case FILE_CONTENT: if ($is_group_content == TRUE) { if ($this->get_uid()) { $is_group_content = FALSE; $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'group_home'; } else { $is_group_content = FALSE; $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); $level_3['highlight'] = 'group_home'; } } elseif (!empty($_GET['cid'])) { try { $content_data = Content::load_content($_GET['cid'], $this->get_uid()); if ($content_data->parent_collection_id != -1 && $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->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); } } else { $level_3 = $this->get_level_3('user'); } } catch (PAException $e) { } } break; /*----------------------------------------------------*/ } //--end of switch $menu = array('level_1' => $level_1, 'level_2' => $level_2, 'level_3' => $level_3, 'left_user_public_links' => $left_user_public_links); return $menu; }
} 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;
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; case 'Suggestion': $res = Suggestion::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']; $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); } } } } return TRUE; }
/** * 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; }
/** * 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); $pram = $extra['notify_owner']['report_abuse_on_content']['value']; if (isset($pram) && $pram > 0) { return true; } return false; break; case 'delete_comment_authorization': $perm_array = array($network_info->owner_id, SUPER_USER_ID, $params['group_owner'], $params['content_owner'], $params['comment_owner']); return in_array($login_uid, $perm_array); break; } return false; }
// 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;
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); } // summarize_timed_queries(); }
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); } } }
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); }
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);
function render_for_ajax() { $op = $this->params["op"]; $this->gid = @$this->params['blog_id']; if ($op != 'paging' && empty(PA::$login_user)) { return __("Login required"); } switch ($op) { case "save_post": // $this->note = "Save piost goes here."; // validation // return "<pre>".print_r($this->params,1)."</pre>"; $post = $this->params; $this->cid = @$post['cid']; $errmsg = ''; $err = FALSE; if (empty($post['title'])) { $errmsg .= __("Please add a title."); $err = TRUE; } else { $post['title'] = $this->html($post['title']); } if (empty($post['body'])) { $errmsg .= __("Please add some text."); $err = TRUE; } else { $post['body'] = $this->html($post['body']); } if ($err) { $this->err = $errmsg; foreach ($post as $k => $v) { $this->content->{$k} = $v; } $this->inner_template = 'newpost.tpl'; } else { $tags = array(); if (!empty($post['tags'])) { foreach (explode(',', $post['tags']) as $term) { $tr = trim($term); if ($tr) { $tags[] = $tr; } } } $post_saved = BlogPost::save_blogpost($this->cid, PA::$login_user->user_id, $post["title"], $post["body"], NULL, $tags, $this->gid); if (empty($post_saved['cid'])) { $this->note = "<pre>" . print_r($this, 1) . "</pre>"; $this->err = "<pre>" . print_r($post_saved['errors'], 1) . "</pre>"; foreach ($post as $k => $v) { $this->content->{$k} = $v; } $this->inner_template = 'newpost.tpl'; } } break; case "new_post": $this->inner_template = 'newpost.tpl'; break; case "edit_post": $this->inner_template = 'newpost.tpl'; $this->cid = @$this->params['cid']; $this->content = NULL; if ($this->cid) { $this->content = Content::load_content((int) $this->cid, (int) PA::$login_uid); } break; case "delete_post": $post = $this->params; // owner check would go here try { Content::delete_by_id($post['cid']); $this->note = __("Post was deleted successfully."); unset($this->params['cid']); // or we'd have a permalink to a post we no longer have } catch (PAException $e) { $this->err = __("There was an error deleting this post: ") . $e->getMessage(); } break; case "remove_author": // the group is not loaded at this point soo we do it here $g = ContentCollection::load_collection($this->gid, PA::$login_user->user_id); // unjoin user to group if ($g->leave($this->params['pa_id'])) { $this->note = "Successfully removed author."; } else { $this->err = "Couldn't remove author."; } break; case "add_author": // the group is not loaded at this point soo we do it here $g = ContentCollection::load_collection($this->gid, PA::$login_user->user_id); // find real PA user_id $su = new ShadowUser($this->skin); try { $su->load($this->params['remote_id']); if ($su->user_id) { // join user to group if ($g->join($su->user_id)) { $this->note = "Successfully removed author."; unset($this->params['remote_id']); } else { $this->err = "Couldn't add author."; } } else { $this->err = "Couldn't add author with UserID " . $this->params['remote_id'] . " no such user."; } } catch (PAException $e) { $this->err = "There was an error adding author: " . $e->getMessage(); } break; default: break; } return $this->render(); }
/** This function is used for loading the information from the get variables Usage:on forum page for message board **/ function load_info() { $request_info = array(); if (!empty($_REQUEST['gid'])) { $request_info['parent_id'] = $_REQUEST['gid']; $request_info['parent_name_hidden'] = 'gid'; $request_info['parent_type'] = PARENT_TYPE_COLLECTION; $obj = new Group(); $obj->load($_REQUEST['gid']); $request_info['header_title'] = stripslashes($obj->title); } else { if (!empty($_REQUEST['mid'])) { $request_info['parent_id'] = $_REQUEST['mid']; $request_info['parent_name_hidden'] = 'mid'; $request_info['parent_type'] = PARENT_TYPE_MESSAGE; $obj = new MessageBoard(); $data = $obj->get_by_id($_REQUEST['mid']); $request_info['header_title'] = stripslashes($data['title']); } else { if (!empty($_REQUEST['cid'])) { $content = Content::load_content((int) $_REQUEST['cid'], (int) PA::$login_uid); $ccid = $content->parent_collection_id; if ($ccid != 0 && $ccid != -1) { //here parent collection 0 is for deleted content and -1 is for home page routed thus checking that its not a group id $content_collection = ContentCollection::load_collection((int) $ccid, PA::$login_uid); if ($content_collection->type == GROUP_COLLECTION_TYPE) { $request_info['parent_id'] = $ccid; $request_info['parent_name_hidden'] = 'gid'; $request_info['parent_type'] = PARENT_TYPE_COLLECTION; } } } else { return false; } } } return $request_info; }
private function can_delete_comment($params, $type) { $available_permiss = $this->get_available_permiss_by_type($params, $type); if (in_array('delete_comment', $available_permiss)) { return true; } if (!empty($params['comment_info'])) { $comment = $params['comment_info']; //array having the comment details if (isset($comment['user_id']) and $comment['user_id'] == $this->uid) { //Author of comment can delete the comment return true; } else { if (isset($comment['recipient_id']) and $comment['recipient_id'] == $this->uid) { return true; } } $content = Content::load_content((int) $comment['content_id'], $this->uid); if ($content->author_id == $this->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, $this->uid); if ($collection->author_id == $this->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 }
/** * 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)) { $res = Dal::query("INSERT INTO {moderation_queue} (collection_id, item_id, type) VALUES (?, ?, ?)", array($this->collection_id, $content_id, "content")); Content::update_content_status($content_id, 2); } else { $this->approve($content_id, 'content'); } Logger::log("Exit: Group::moderate_content()"); return; }
global $network_info; require_once "{$path_prefix}/api/Theme/Template.php"; require_once "{$path_prefix}/api/Relation/Relation.php"; require_once "{$path_prefix}/api/Content/Content.php"; require_once "{$path_prefix}/api/Comment/Comment.php"; $cid = $_REQUEST['cid']; //Takes care of url manipulation if (empty($cid)) { $redirect_msg = "Required parameters missing in URL."; $back_to_page = $base_url . '/homepage.php'; header("Location: {$base_url}/generic_error.php?msg={$redirect_msg}&back_to_page={$back_to_page}"); exit; } //..eof Takes care of url manipulation try { $content = Content::load_content((int) $cid, (int) $_SESSION['user']['id']); } catch (PAException $e) { if ($e->code == CONTENT_NOT_FOUND) { $redirect_msg = "Content you are looking for does not exist."; $back_to_page = $base_url . '/homepage.php'; header("Location: {$base_url}/generic_error.php?msg={$redirect_msg}&back_to_page={$back_to_page}"); exit; } } $parameter = js_includes("generic"); html_header('', $parameter); if ($_SESSION['user']['id']) { $admin = new User(); $admin->load($_SESSION['user']['id']); } if ($_SESSION['user']['id'] == $content->author_id || $admin->role == 2) {
html_header("Media Gallery - {$network_info->name}", $parameter); if (!$_GET['uid']) { $uid = $_SESSION['user']['id']; } else { $uid = $_GET['uid']; } /* Check for the content author id */ if (!empty($_REQUEST["cid"])) { $cid = $_REQUEST["cid"]; $params = array('action' => 'edit_content', 'uid' => $login_uid, 'cid' => $cid); if (!user_can($params)) { header("Location: {$base_url}/homepage.php?&msg=" . urlencode('Error: You are not authorized to access this page.')); exit; } // It will give the content type whether its an SB Content or a Blogpost $obj_content_type = Content::load_content($cid, $uid); if ($obj_content_type->type == 'SBMicroContent') { $location = $base_url . "/post_content.php?cid=" . $cid; header("Location: {$location}"); exit; } } if ($_GET['cid']) { $cid = $_GET['cid']; if ($obj_content_type->type) { switch ($obj_content_type->type) { case 'Image': $show_media = new Image(); break; case 'Audio': $show_media = new Audio();
try { $post_subject = "Network's owner bulletin - " . $_POST['title']; $post_message = $_POST['bulletin_body']; switch ($type) { case 'Suggestion': $res = Suggestion::save_suggestion(0, $from, $post_subject, $post_message, '', $terms, 0, $is_active = ACTIVE, $user->email); break; case 'BlogPost': $res = BlogPost::save_blogpost(0, $from, $post_subject, $post_message, '', $terms, 0, $is_active = ACTIVE, $user->email); break; } } catch (PAException $e) { $error_msg .= $e->message; } if (!empty($res['cid'])) { $content_obj = Content::load_content((int) $res['cid']); PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj); } } if ($no_reg_user == TRUE) { $error_msg .= "No registered member in this network"; } else { $error_msg .= " Bulletin has been sent "; } } else { if (!empty($_POST['send_to_me_only'])) { // test send to admin user if (!$error_msg) { // if no errors $subject = $_POST['title']; $bull_message = $_POST['bulletin_body'];
$extra = serialize($activity_extra); $object = $upload['album_id']; Activities::save(PA::$login_uid, $activity, $object, $extra); $gallery_link = PA::$url . PA_ROUTE_MEDIA_GALLEY_VIDEOS . "/uid=" . PA::$login_uid . $album; break; } } } if (!empty($error_msg)) { _error_msg($error_msg); } else { $cid = (int)$upload['content_id']; $content_info = Content::load_content($cid, PA::$login_uid); switch ($content_info->type) { case 'Image': $show_media = new Image(); break; case 'Audio': $show_media = new Audio(); break; case 'TekVideo': $show_media = new TekVideo(); break; default: die("Content ID $cid is non-media (not image, audio, or video)"); break; }
/** 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 $dynamic_page; 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, PA::$network_info->network_id); $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 (PA::$login_uid) { $this->set_uid(PA::$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']) && $_REQUEST['ccid'] > 0) { $this->set_group_id($_REQUEST['ccid']); $is_group_content = TRUE; } else { if (PAGE_PERMALINK == $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 PAGE_HOMEPAGE: $level_3 = NULL; $level_2['highlight'] = 'home'; break; case FILE_LOGIN: $level_2['highlight'] = 'home'; break; case PAGE_SEARCH: //fix by Zoran Hron: constants FILE_SEARCH_HOME and FILE_SHOWCONTENT points to the same value !!! if (!empty($_GET['gid'])) { $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); } else { if (!empty($_GET['btn_searchContent'])) { $level_2['highlight'] = 'search'; } else { $level_3 = NULL; $level_2['highlight'] = 'home'; } } break; case FILE_TAG_SEARCH: $level_2['highlight'] = 'tag_search'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case PAGE_USER_PRIVATE: global $app; $app->setRequestParam('uid', PA::$login_uid, 'POST'); case PAGE_USER_PUBLIC: case PAGE_USER_PRIVATE: if (!PA::$page_uid && !PA::$login_uid) { throw new PAException("", "Invalid page access"); } if (PA::$page_uid) { //uid get variable set //these links are to be added in front $def_relations_term = 'Friend'; if (isset($extra['relationship_show_mode']['term'])) { $def_relations_term = $extra['relationship_show_mode']['term']; } $relation_already_exists_links = array('send_message' => array('caption' => __('Send a message'), 'url' => $this->base_url . PA_ROUTE_ADDMESSAGE . '/uid=' . PA::$page_uid), 'change_relationship' => array('caption' => __('Change Relation'), 'url' => $this->base_url . PA_ROUTE_EDIT_RELATIONS . '/uid=' . PA::$page_uid . '&do=change&action=EditRelation'), 'delete_relationship' => array('caption' => sprintf(__('Delete as %s'), __($def_relations_term)), 'url' => $this->base_url . PA_ROUTE_EDIT_RELATIONS . '/do=delete&uid=' . PA::$page_uid . '&action=EditRelation', 'extra' => ' onclick ="return delete_confirmation_msg(\'' . __('Are you sure you want to delete this Relationship?') . '\') "')); $relation_does_not_exists_links = array('send_message' => array('caption' => __('Send a message'), 'url' => $this->base_url . PA_ROUTE_ADDMESSAGE . '/uid=' . PA::$page_uid), 'make_connection' => array('caption' => sprintf(__('Add as %s'), __($def_relations_term)), 'url' => $this->base_url . PA_ROUTE_EDIT_RELATIONS . '/uid=' . PA::$page_uid . '&do=add&action=EditRelation')); if (PA::$page_uid == PA::$login_uid) { //login and get uid same means user's public page $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); } else { // make left and right links //user's public page requires different link rendering if (!empty($relations_ids)) { if (in_array(PA::$page_uid, $relations_ids)) { $left_user_public_links = $relation_already_exists_links; } else { $left_user_public_links = $relation_does_not_exists_links; } } else { $left_user_public_links = $relation_does_not_exists_links; } } } else { //means user's private page $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'user_private'; } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case PAGE_PEOPLES: $level_2['highlight'] = 'people'; $level_3 = $this->get_level_3('people'); $level_3['highlight'] = 'find_people'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case PAGE_FAMILY: case PAGE_FAMILY_EDIT: $level_3 = $this->get_level_3('family'); break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_VIEW_ALL_MEMBERS: if (@$_GET['gid']) { $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'group_members'; } else { $level_2['highlight'] = 'people'; if (PA::$page_uid == PA::$login_uid) { $level_3 = $this->get_level_3('people'); if (!empty($_GET['view_type']) && $_GET['view_type'] == 'relations') { $level_3['highlight'] = 'my_friends'; } else { if (!empty($_GET['view_type']) && $_GET['view_type'] == 'in_relations') { $level_3['highlight'] = 'people_who_call_me_friend'; } else { $level_3['highlight'] = 'find_people'; } } } } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_INVITATION: $level_2['highlight'] = 'people'; $level_3 = $this->get_level_3('people'); $level_3['highlight'] = 'invite'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_UPLOAD_MEDIA: case PAGE_MEDIA_GALLERY: if (PA::$login_uid) { if (isset($_GET['view']) && 'groups_media' == $_GET['view']) { //user is viewing group gallery $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'group_gallery'; } else { if (isset($_GET['view']) && 'friends' == $_GET['view']) { //user is viewing his friends gallery $level_2['highlight'] = 'people'; $level_3 = $this->get_level_3('people'); $level_3['highlight'] = 'friends_gallery'; } else { if (PA::$page_uid != PA::$login_uid && PA::$page_uid != '') { //user is viewing his private page gallery $level_2['highlight'] = 'people'; } else { if (PA::$page_uid == PA::$login_uid || !PA::$page_uid) { $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'my_gallery'; } } } } } else { if (!empty(PA::$page_uid)) { // for anonymous user $level_2['highlight'] = 'people'; } } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case PAGE_USER_CUSTOMIZE_UI: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'customize_ui'; break; case FILE_USER_CALENDAR: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'my_events'; break; case PAGE_EDIT_PROFILE: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'settings'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_EDIT_RELATIONS: $level_2['highlight'] = 'people'; $level_3 = $this->get_level_3('people'); $level_3['highlight'] = 'find_people'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case PAGE_GROUPS_HOME: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); $level_3['highlight'] = 'find_groups'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_GROUPS_CATEGORY: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); $level_3['highlight'] = 'find_groups'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_ADDGROUP: $level_2['highlight'] = 'groups'; if (!empty($_GET['gid'])) { $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'edit_group'; } else { $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); $level_3['highlight'] = 'create_group'; } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case PAGE_GROUP: case PAGE_GROUP_AD_CENTER: case FILE_GROUP_MEDIA_GALLERY: case FILE_GROUP_CALENDAR: case FILE_GROUP_INVITATION: case PAGE_GROUP_THEME: case PAGE_GROUP_MODERATION: case FILE_MANAGE_GROUP_CONTENTS: $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); break; case FILE_ADDGROUP: $level_2['highlight'] = 'group'; if ($_GET['gid']) { $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'edit_group'; } else { $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); $level_3['highlight'] = 'create_group'; } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_WIDGET: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'user_widgets'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case PAGE_MESSAGE: case PAGE_ADDMESSAGE: case PAGE_VIEW_MESSAGE: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'messages'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_POST_CONTENT: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'create_post'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_CONTENT_MANAGEMENT: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'manage_posts'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_NETWORKS_HOME: case FILE_NETWORKS_CATEGORY: $level_1['highlight'] = 'networks_directory'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_NETWORK_USER_DEFAULTS: case FILE_RELATIONSHIP_SETTINGS: case FILE_EMAIL_NOTIFICATION: case FILE_MANAGE_TAKETOUR: case FILE_MANAGE_EMBLEM: case FILE_CONFIGURE_SPLASH_PAGE: case FILE_NETWORK_FEATURE: case FILE_NETWORK_CUSTOMIZE_UI_PAGE: case FILE_NETWORK_STATS: case FILE_NETWORK_LINKS: case FILE_NEW_USER_BY_ADMIN: case FILE_NETWORK_MANAGE_CONTENT: case FILE_MODULE_SELECTOR: case FILE_NETWORK_BULLETINS: case FILE_NETWORK_MANAGE_USER: case FILE_NETWORK_CALENDAR: case FILE_MANAGE_AD_CENTER: case FILE_MANAGE_GROUP_FORUM: case FILE_MANAGE_COMMENTS: case FILE_RANKING: case FILE_MISREPORTS: case PAGE_ROLE_MANAGE: case FILE_ASSIGN_TASK: $level_2 = $this->get_level_3('network'); $level_1['highlight'] = 'configure_network'; $level_2['highlight'] = 'configure_network'; break; case FILE_CREATENETWORK: $level_1['highlight'] = 'create_network'; $level_3['highlight'] = 'statistics'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_SHOWCONTENT: // remark by Zoran Hron: this never will be executed because // constants FILE_SEARCH_HOME and FILE_SHOWCONTENT points to the same value !!! if (!empty($_GET['gid'])) { $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); } break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_LINKS_MANAGEMENT: $level_2['highlight'] = 'user'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_MEDIA_FULL_VIEW: if (!empty($_GET['gid'])) { $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); } else { $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); } break; case FILE_REGISTER: $level_2['highlight'] = 'home'; break; case FILE_EDIT_MEDIA: $level_2['highlight'] = 'user'; $level_3 = $this->get_level_3('user'); $level_3['highlight'] = 'my_gallery'; break; /*----------------------------------------------------*/ /*----------------------------------------------------*/ case FILE_EDITNETWORK: case PAGE_PERMALINK: if ($is_group_content == TRUE) { if ($this->get_uid()) { $is_group_content = FALSE; $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); $level_3['highlight'] = 'group_home'; } else { $is_group_content = FALSE; $level_2['highlight'] = 'groups'; $level_3 = $this->get_level_3(array('type' => 'groups', 'sub_type' => 'groups_general')); $level_3['highlight'] = 'group_home'; } } elseif (!empty($_GET['cid'])) { try { $content_data = Content::load_content($_GET['cid'], $this->get_uid()); if ($content_data->parent_collection_id != -1 && $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->get_level_3(array('type' => 'groups', 'sub_type' => 'group_specific')); } } else { $level_3 = $this->get_level_3('user'); } } catch (PAException $e) { } } break; default: break; } //--end of switch /* moved this code outside of the switch statement... we wabt this to run in any case, so that xml files can override default navigation! -Martin */ if (isset($dynamic_page) && !empty($dynamic_page->navigation_code)) { if (false == eval($dynamic_page->navigation_code . "return true;")) { echo "<b>Evaluation of navigation links code for page ID={$dynamic_page->page_name} failed" . "Please check your dynamic page configuration file. Page ID: {$dynamic_page->page_id}"; } } /* ------- */ $menu = array('level_1' => $level_1, 'level_2' => $level_2, 'level_3' => $level_3, 'left_user_public_links' => $left_user_public_links); // echo '<pre>'.print_r($menu,1).'</pre>'; return $menu; }
include "includes/page.php"; require_once "{$path_prefix}/api/Cache/Cache.php"; require_once "{$path_prefix}/ext/SBMicroContent/SBMicroContent.php"; require_once "./includes/classes/SbHelper.php"; require_once "{$path_prefix}/destination/OutputThis/OutputThis.php"; require_once "{$path_prefix}/ext/Album/Album.php"; require_once "{$path_prefix}/web/includes/functions/auto_email_notify.php"; $user = get_user(); // check to see if we are here for edit and user has permissions to do it if ($cid = @$_REQUEST['cid']) { $params = array('action' => 'edit_content', 'uid' => $login_uid, 'cid' => $cid); if (!user_can($params)) { header("Location: {$base_url}/homepage.php?&msg=" . urlencode('Error: You are not authorized to access this page.')); exit; } $obj_content_type = Content::load_content((int) $cid, $login_uid); // this content will be used for edit mode if ($obj_content_type->type == 'SBMicroContent') { $_REQUEST["sb_mc_type"] = $obj_content_type->sbname; //$content_type = 'SBMicroContent'; } else { if ($obj_content_type->type == 'BlogPost') { unset($_REQUEST["sb_mc_type"]); } } //tells edit mode $is_edit = 1; } else { //tells create first time mode $cid = 0; $is_edit = 0;