function uihelper_generate_center_content_permalink($cid, $show = 0) { global $app; $image_media_gallery = FALSE; $back_page = PA::$url . $app->current_route; $content = CNContent::load_content((int) $cid, (int) PA::$login_uid); // filter content fields for output $content->title = _out($content->title); $content->body = _out($content->body); if (strstr($back_page, PA_ROUTE_CONTENT) || strstr($back_page, PA_ROUTE_PERMALINK)) { if ($content->parent_collection_id > 0) { $collection = ContentCollection::load_collection((int) $content->parent_collection_id, PA::$login_uid); if ($collection->type == GROUP_COLLECTION_TYPE) { $back_page = PA::$url . PA_ROUTE_GROUP . "/gid=" . $content->parent_collection_id; } else { $back_page = PA::$url . PA_ROUTE_MEDIA_GALLEY_IMAGES . "/uid=" . $content->author_id; } // IF permalink content is a group content redirect to group homepage } else { //if coming from permalink page then redirect to user page $back_page = PA::$url . PA_ROUTE_USER_PRIVATE; } } $moderateduser = Group::is_admin((int) $content->parent_collection_id, (int) PA::$login_uid) ? 1 : 0; $back_page = urlencode($back_page); if (!$content->is_html) { $content->body = nl2br($content->body); } $media_gallery_content = NULL; $media_gallery_content = in_array(trim($content->type), array('Image', 'Audio', 'Video')); $editable = PA::$login_uid == $content->author_id || $moderateduser; $comments = Comment::get_comment_for_content($cid, '', 'ASC'); $number_of_comments = count($comments); $content->no_of_comments = $number_of_comments; $trackback = CNContent::get_trackbacks_for_content($cid); $number_of_trackbacks = count($trackback); $content->no_of_trackbacks = $number_of_trackbacks; $content->trackback_url = PA::$url . "/pa_trackback.php?cid=" . $cid; $content_user = new User(); $content_user->load((int) $content->author_id); $content->create_time = PA::date($content->changed, 'long'); // date("l, F d, Y", $content->changed); $tags = Tag::load_tags_for_content($cid); if ($tags) { $t = array(); for ($i = 0; $i < count($tags); $i++) { $name = _out($tags[$i]['name']); $uid = PA::$login_uid; $url = PA::$url . '/' . FILE_TAG_SEARCH . '?name_string=content_tag&keyword=' . $tags[$i]["name"]; $t[] = "<a href={$url}>" . $name . "</a>"; } $tag_string = "<b>Tags : </b>" . implode(", ", $t); } else { $tag_string = ""; } $content->tag_entry = $tag_string; if (property_exists($content, 'sbname')) { if (substr($content->sbname, 0, 5) == 'event') { $content->type = 'SBEvent'; } elseif (substr($content->sbname, 0, 6) == 'review') { $content->type = 'Review'; } elseif (substr($content->sbname, 0, 11) == 'media/audio') { $content->type = 'Audio'; } elseif (substr($content->sbname, 0, 11) == 'media/video') { $content->type = 'Video'; } elseif (substr($content->sbname, 0, 11) == 'media/image') { $content->type = 'Image'; } elseif (substr($content->sbname, 0, 14) == 'showcase/group') { $content->type = 'GroupShowCase'; } elseif (substr($content->sbname, 0, 15) == 'showcase/person') { $content->type = 'PersonShowCase'; } } // replace magic strings $content->replace_percent_strings(PA::$url); $type = $content->type; $type = $type . 'Permalink'; // comments $comments_list_tpl = new Template(CURRENT_THEME_FSPATH . "/cncontent_comments.php"); $comments_list_tpl->set('current_theme_path', PA::$theme_url); $comments_list_tpl->set('comments', $comments); $comments_list_tpl->set('author_id', $content->author_id); // Setting the variable for the abuse form ... $comments_list = $comments_list_tpl->fetch(); //comment form $cnform_comment_tpl = new Template(CURRENT_THEME_FSPATH . "/cnform_comment.php"); $cnform_comment_tpl->set('current_theme_path', PA::$theme_url); if (isset(PA::$login_uid)) { $user = new User(); $user->load((int) PA::$login_uid); $login_name = $user->login_name; $cnform_comment_tpl->set('name', $login_name); $cnform_comment_tpl->set('login_name', $user->login_name); } $cnform_comment_tpl->set('cid', $cid); if ($content->parent_collection_id > 0) { $cnform_comment_tpl->set('ccid', $content->parent_collection_id); } // abuse form $cnform_abuse_tpl = new Template(CURRENT_THEME_FSPATH . "/cnform_abuse.php"); /* Permalink and edit links for content */ if ($content->parent_collection_id != -1) { $perma_link = PA::$url . PA_ROUTE_PERMALINK . "/cid=" . $content->content_id . '&ccid=' . $content->parent_collection_id; } else { $perma_link = PA::$url . PA_ROUTE_PERMALINK . "/cid=" . $content->content_id; } $params = array('permissions' => 'edit_content', 'uid' => PA::$login_uid, 'cid' => $content->content_id); if (PermissionsHandler::can_user(PA::$login_uid, $params)) { if ($media_gallery_content) { $edit_link = PA::$url . '/edit_media.php?cid=' . $content->content_id; } else { $edit_link = PA::$url . "/cncontent_blog.php?cid=" . $content->content_id; } $delete_link = PA::$url . PA_ROUTE_CONTENT . "?action=deleteContent&cid=" . $content->content_id . '&back_page=' . $back_page; // handle Event separately if ($type == "EventPermalink") { $edit_link = PA::$url . '/calendar.php?cid=' . $content->content_id; $delete_link = $edit_link . "&delete=1" . '&back_page=' . $back_page; } } else { $edit_link = $delete_link = NULL; } $user_link = PA::$url . PA_ROUTE_USER_PUBLIC . '/' . $content->author_id; /* Code for Approval and Denial links for a content */ if ($moderateduser && $content->is_active == 2) { $approval_link = PA::$url . PA_ROUTE_PERMALINK . '/cid=' . $content->content_id . '&ccid=' . $content->parent_collection_id . '&apv=1'; $denial_link = PA::$url . PA_ROUTE_PERMALINK . '/cid=' . $content->content_id . '&ccid=' . $content->parent_collection_id . '&dny=1'; } else { $approval_link = $denial_link = NULL; } // Show comments form to logged in users, only if comments enabled. global $comments_disabled; // fix by Z.Hron; if group content - only members of group can comment it $can_user_comment = true; if (isset($_GET['gid']) && isset(PA::$login_uid)) { $can_user_comment = Group::member_exists((int) $_GET['gid'], PA::$login_uid); } if (!$comments_disabled && !empty(PA::$login_uid) && $can_user_comment) { $cnform_comment = $cnform_comment_tpl->fetch(); $cnform_abuse = $cnform_abuse_tpl->fetch(); } else { $cnform_comment = $cnform_abuse = NULL; } if (getShadowedPath(CURRENT_THEME_FSPATH . "/{$type}.php")) { $middle_content = new Template(getShadowedPath(CURRENT_THEME_FSPATH . "/{$type}.php")); $middle_content->set_object('contents', $content); $middle_content->set('editable', $editable); $middle_content->set('picture_name', $content_user->picture); // to set picture name for diplaying in contets $middle_content->set('user_id', $content_user->user_id); $middle_content->set('user_name', $content_user->first_name . ' ' . $content_user->last_name); $middle_content->set('current_theme_path', PA::$theme_url); $middle_content->set('back_page', $back_page); $middle_content->set('comments', $comments_list); $middle_content->set('cnform_comment', $cnform_comment); $middle_content->set('cnform_abuse', $cnform_abuse); $middle_content->set('media_gallery_content', $media_gallery_content); if ($show == 1) { $middle_content->set('show', $show); } $middle_content->set('permalink', $perma_link); $middle_content->set('edit_link', $edit_link); $middle_content->set('approval_link', $approval_link); $middle_content->set('denial_link', $denial_link); $middle_content->set('delete_link', $delete_link); $middle_content->set('user_link', $user_link); $return_content = $middle_content->fetch(); } else { $return_content = '<p>Content does not have a display template.</p><p>Create a ' . $type . '.php file to display this content type.</p>'; } return $return_content; }
private function can_edit_content($params, $type) { $available_permiss = $this->get_available_permiss_by_type($params, $type); if (in_array('edit_content', $available_permiss)) { return true; } if (!empty($params['cid'])) { //Loading content $content_obj = CNContent::load_content((int) $params['cid'], $this->uid); //author of the content can perform the action if ($content_obj->author_id == $this->uid) { return true; } // content is a part of some collection if ($content_obj->parent_collection_id != -1) { // Loading collection $collection_obj = ContentCollection::load_collection((int) $content_obj->parent_collection_id, $this->uid); // owner of collection can also edit the content if ($collection_obj->author_id == $this->uid) { return true; } } } return false; }
/** 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 = CNContent::load_content($_GET['cid'], $this->get_uid()); } catch (CNException $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 CNException("", "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_CONFIGURE: 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 = CNContent::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 (CNException $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; }
case 'CNBlogPost': default: $post_saved = CNBlogPost::save_blogpost(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 = CNContent::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 load_data($error_msg = '') { $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 = CNContent::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->blog_type = stripslashes($content->type); $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); } } }
require_once "web/includes/authorize.inc.php"; $permission_to_post = $task_perm;//set from authorize.inc.php */ $user = get_user(); $_GET = url_decode_all($_GET); $_POST = url_decode_all($_POST); $_REQUEST = url_decode_all($_REQUEST); //filter_all_post($_POST); // check to see if we are here for edit and user has permissions to do it if ($cid = $_REQUEST['cid']) { $params = array('permissions' => 'edit_content', 'uid' => PA::$login_uid, 'cid' => $cid); if (!PermissionsHandler::can_user(PA::$login_uid, $params)) { header("Location: " . PA::$url . PA_ROUTE_HOME_PAGE . "/msg=" . urlencode('Error: You are not authorized to access this page.')); exit; } $obj_content_type = CNContent::load_content((int) $cid, PA::$login_uid); // this content will be used for edit mode if ($obj_content_type->type == 'CNBlogPost') { unset($_REQUEST["sb_mc_type"]); } //tells edit mode $is_edit = 1; $parent_collection_id = $obj_content_type->parent_collection_id; } else { //tells create first time mode $cid = 0; $is_edit = 0; } //take care of content collection in case of ccid //right now a user can come from groups.php page to create post in that group // Then it will have ccid associated with it.
public static function save_blogpost($cid, $uid, $title, $body, $track, $tags, $ccid = 0, $is_active = 1, $display_on = 0, $is_default_content = FALSE) { $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 = CNContent::load_content($cid, $uid); // ignore $ccid passed to function if the post already exists // - we don't allow users to move posts between // CNContentCollections. $ccid = (int) $post->parent_collection_id; } else { $post = new CNBlogPost(); $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); } return array("cid" => (int) $post->content_id, "moderation_required" => $g ? $g->is_moderated == 1 && $g->author_id != $uid : FALSE, "errors" => $errors); }