private function get_families() { $userfamilies = TypedGroupEntityRelation::get_relation_for_user($this->uid, 'family'); $family_details = array(); foreach ($userfamilies as $i => $fam) { $group = ContentCollection::load_collection((int) $fam->object_id, PA::$login_uid); $member_exist = Group::member_exists((int) $fam->object_id, $this->uid); $picture = $group->picture; $cnt = Group::get_member_count($group->collection_id); $family_details[$i]['id'] = $group->collection_id; $family_details[$i]['title'] = stripslashes($group->title); $desc = stripslashes($group->description); $desc = substr($desc, 0, 100); $family_details[$i]['desc'] = $desc; $family_details[$i]['picture'] = $picture; $family_details[$i]['members'] = $cnt; $family_details[$i]['access'] = $group->access_type; } return $family_details; }
static function in_same_family($user_id1, $user_id2) { $in_same_family = array(); // get all families for each user $user_1_families = TypedGroupEntityRelation::get_relation_for_user($user_id1, 'family', false); $user_2_families = TypedGroupEntityRelation::get_relation_for_user($user_id2, 'family', false); $fam1 = array(); $fam2 = array(); foreach ($user_1_families as $i => $fam) { // we make a real string of the id here, so we don't get confusion with integer indices $fam1["family_" . $fam->object_id] = $fam->relation_type; } foreach ($user_2_families as $i => $fam) { // we make a real string of the id here, so we don't get confusion with integer indices $fam2["family_" . $fam->object_id] = $fam->relation_type; } foreach ($fam1 as $id => $relation) { if (!empty($fam2[$id])) { $in_same_family[] = $id; } } return $in_same_family; }
/** Purpose : this function is core funtion of this Navigation class. It is used to make links level_1,level_2,level_3 Some links need extra parameters append them here but first set them in their methods e.g. public function set_group_id($group_id){ $this->group_id = $group_id; } public function get_group_id() { return $this->group_id(); } Scope : public @param - it needs no direct input @return - it sets class variables level_1,level_2,level_3 which can be used further. **/ function make_links() { $user_id = isset($_SESSION['user']['id']) ? $_SESSION['user']['id'] : 0; ////These are level 1 links shown in top navigation bar $level_1 = array('home_network' => array('caption' => __('Return to home network'), 'url' => $this->mothership_info['url'])); // Display network directory, if network operation is enabled. if (PA::$network_capable) { $level_1['networks_directory'] = array('caption' => __('Network directory'), 'url' => $this->base_url . '/' . FILE_NETWORKS_HOME); } $owner = Network::is_admin($this->network_info->network_id, $user_id); //is_member will be true when user is registered member of the nework. $is_member = Network::member_exists($this->network_info->network_id, $this->get_uid()); if (!$this->is_anonymous && $this->network_info && !$is_member && $this->network_info->type != MOTHER_NETWORK_TYPE) { $level_1['join_network'] = array('caption' => __('JOIN Network'), 'url' => $this->base_url . '/' . FILE_NETWORK_ACTION . '?action=join&nid=' . $this->network_info->network_id . '&cid=' . $this->network_info->category_id); } else { if (!$this->is_anonymous && $is_member && !$owner && $this->network_info->type != MOTHER_NETWORK_TYPE) { $level_1['unjoin_network'] = array('caption' => __('Unjoin Network'), 'url' => $this->base_url . '/' . FILE_NETWORK_ACTION . '?action=leave&nid=' . $this->network_info->network_id . '&cid=' . $this->network_info->category_id); } else { if (Network::is_admin($this->network_info->network_id, (int) $user_id)) { $level_1['configure_network'] = array('caption' => __('Configure'), 'url' => $this->base_url . PA_ROUTE_CONFIGURE_NETWORK); } } } if ($this->network_info->type == MOTHER_NETWORK_TYPE) { unset($level_1['home_network']); } if (PA::$config->enable_network_spawning) { $level_1['create_network'] = array('caption' => __('Create a network'), 'url' => $this->mothership_info['extra']['links']['create_network']); } ////END OF These are level 1 links shown in top navigation bar ////These are level 2 links shown in second navigation bar $level_2 = array('home' => array('caption' => __('Home'), 'url' => $this->base_url . PA_ROUTE_HOME_PAGE), 'user' => array('caption' => __(PA::$mypage_noun), 'url' => $this->base_url . PA_ROUTE_USER_PRIVATE), 'people' => array('caption' => __(PA::$people_noun), 'url' => $this->base_url . PA_ROUTE_PEOPLES_PAGE), 'groups' => array('caption' => __(PA::$group_noun_plural), 'url' => $this->base_url . PA_ROUTE_GROUPS)); if (!empty(PA::$config->useTypedGroups)) { $level_2 = $level_2 + array('directory' => array('caption' => __('Orgs'), 'url' => $this->base_url . PA_ROUTE_TYPED_DIRECTORY)); if (!empty(PA::$config->simple['use_families'])) { $level_2 = $level_2 + array('families' => array('caption' => __('Neighbors'), 'url' => $this->base_url . PA_ROUTE_FAMILY_DIRECTORY)); } } $level_2 = $level_2 + array('forum' => array('caption' => __('Forum'), 'url' => $this->base_url . PA_ROUTE_FORUMS . "/network_id=" . $this->network_info->network_id), 'search' => array('caption' => __('Search'), 'url' => $this->base_url . PA_ROUTE_SEARCH_HOME . '/btn_searchContent=Search+Content')); ////END OF These are level 2 links shown in second navigation bar /// children of user 2nd level link $uid = $this->get_uid(); //we need uid for some links $user_children = array(); $user_children = $user_children + array('user_private' => array('caption' => __('My Page'), 'url' => $this->base_url . PA_ROUTE_USER_PRIVATE)); $user_children = $user_children + array('user_widgets' => array('caption' => __('My Widgets'), 'url' => $this->base_url . '/' . FILE_WIDGET)); $user_children = $user_children + array('messages' => array('caption' => __('My Messages'), 'url' => $this->base_url . PA_ROUTE_MYMESSAGE)); $user_children = $user_children + array('my_gallery' => array('caption' => __('My Gallery'), 'url' => $this->base_url . PA_ROUTE_MEDIA_GALLEY_IMAGES . "/uid={$uid}")); $user_children = $user_children + array('my_events' => array('caption' => __('My Events'), 'url' => $this->base_url . '/' . FILE_USER_CALENDAR), 'my_friends' => array('caption' => __('My Friends'), 'url' => $this->base_url . "/view_all_members.php?view_type=in_relations&uid={$uid}")); $user_children = $user_children + array('my_forum' => array('caption' => __('My Forum'), 'url' => $this->base_url . PA_ROUTE_FORUMS . "/network_id=" . $this->network_info->network_id . '&user_id=' . $uid)); $user_children = $user_children + array('my_points' => array('caption' => __('My Points'), 'url' => $this->base_url . PA_ROUTE_POINTS_DIRECTORY . "?uid={$uid}")); if (!empty(PA::$config->simple['use_families'])) { // get this users Family or Families require_once "api/Entity/TypedGroupEntityRelation.php"; $userfamilyRelations = TypedGroupEntityRelation::get_relation_for_user($uid, 'family'); if (count($userfamilyRelations) == 1) { $user_children = $user_children + array('my_family' => array('caption' => __('My Family'), 'url' => $this->base_url . PA_ROUTE_FAMILY . "?gid=" . $userfamilyRelations[0]->object_id)); } else { $html = "<ul>"; foreach ($userfamilyRelations as $i => $relation) { $group = ContentCollection::load_collection((int) $relation->object_id, PA::$login_uid); $html .= "<li>"; $html .= "<a href=\"" . $this->base_url . PA_ROUTE_FAMILY . "?gid=" . $relation->object_id . "\">" . $group->title . "</a>"; $html .= "</li>"; } $html .= "</ul>"; $user_children = $user_children + array('my_family' => array('caption' => __('My Families'), 'html' => $html)); } } // end of !empty(PA::$config->simple['use_families']) $user_children = $user_children + array('settings' => array('caption' => __('Edit My Account'), 'url' => $this->base_url . PA_ROUTE_EDIT_PROFILE)); $user_children = $user_children + array('customize_ui' => array('caption' => __('Themes'), 'url' => $this->base_url . PA_ROUTE_CUSTOMIZE_USER_GUI . "/theme/uid={$uid}")); if ($this->is_anonymous) { //these links are not for anonymous unset($user_children); } ///END OF children of user 2nd level link /// children of people 2nd level link //required friend id in some places $friend_id = $this->get_friend_uid(); $people_children = array('find_people' => array('caption' => sprintf(__('Find %s'), __(PA::$people_noun)), 'url' => $this->base_url . PA_ROUTE_PEOPLES_PAGE), 'my_friends' => array('caption' => __('My friends'), 'url' => $this->base_url . '/' . FILE_VIEW_ALL_MEMBERS . '?view_type=relations&uid=' . $uid), 'friends_gallery' => array('caption' => __('Friends gallery'), 'url' => $this->base_url . PA_ROUTE_MEDIA_GALLEY_IMAGES . "/uid={$friend_id}&view=friends")); if ($this->is_anonymous) { //these links are not for anonymous unset($people_children); } ///EOF children of people 2nd level link $family_children = array('neighbors' => array('caption' => __("Neighbors"), 'url' => $this->base_url . PA_ROUTE_FAMILY_DIRECTORY), 'family_home' => array('caption' => __("Family Homepage"), 'url' => $this->base_url . PA_ROUTE_FAMILY . "/gid=" . $this->group_id), 'family_members' => array('caption' => __("Family Members"), 'url' => $this->base_url . PA_ROUTE_FAMILY_MEMBERS . "/gid=" . $this->group_id)); /// group general children // $users_first_group_id = $this->get_users_first_group_id(); $groups_general = array('find_groups' => array('caption' => sprintf(__('Find %s'), __(PA::$group_noun_plural)), 'url' => $this->base_url . PA_ROUTE_GROUPS), 'create_group' => array('caption' => __('Create'), 'url' => $this->base_url . '/' . FILE_ADDGROUP), 'invite' => array('caption' => __('Invite'), 'url' => $this->base_url . '/' . FILE_GROUP_INVITATION)); if ($this->is_anonymous) { //these links are not for anonymous unset($groups_general['create_group']); unset($groups_general['invite']); unset($groups_general['group_media_gallery']); } /// EOF group general children ///group specific menu children $gid = $group_id = $this->get_group_id(); $group_specific = array('group_home' => array('caption' => sprintf(__('%s Home'), __(PA::$group_noun)), 'url' => $this->base_url . PA_ROUTE_GROUP . '/gid=' . $group_id), 'group_forum' => array('caption' => sprintf(__('%s Forum'), __(PA::$group_noun)), 'url' => $this->base_url . PA_ROUTE_FORUMS . "/network_id=" . $this->network_info->network_id . '&gid=' . $group_id), 'group_members' => array('caption' => sprintf(__('%s Members'), __(PA::$group_noun)), 'url' => $this->base_url . '/' . FILE_VIEW_ALL_MEMBERS . '?gid=' . $group_id), 'group_gallery' => array('caption' => sprintf(__('%s Gallery'), __(PA::$group_noun)), 'url' => $this->base_url . PA_ROUTE_MEDIA_GALLEY_IMAGES . '/view=groups_media&gid=' . $group_id), 'group_events' => array('caption' => sprintf(__('%s Events'), __(PA::$group_noun)), 'url' => $this->base_url . '/' . FILE_GROUP_CALENDAR . '?gid=' . $group_id)); $group_member = FALSE; $group_may_post = FALSE; $group_may_invite = FALSE; $group_moderator = FALSE; $group_manange_ads = FALSE; $group_owner = FALSE; if (PA::$login_uid) { if (Group::member_exists($gid, PA::$login_uid)) { $group_member = TRUE; // TODO: split this out to it's own perm check $group_may_post = TRUE; $group_may_invite = TRUE; } if (PermissionsHandler::can_group_user(PA::$login_uid, $gid, array('permissions' => 'manage_groups, manage_roles')) || Group::is_admin($gid, PA::$login_uid)) { $group_owner = TRUE; $group_moderator = TRUE; } else { if (PermissionsHandler::can_group_user(PA::$login_uid, $gid, array('permissions' => 'manage_groups'))) { $group_moderator = TRUE; } } // network level ad manager? $group_manange_ads = PermissionsHandler::can_user(PA::$login_uid, array('permissions' => 'manage_ads')); // check for manageads of group permissions if (!$group_manange_ads) { // we do this check only if the user is not already permitted to manage ads $group_manange_ads = PermissionsHandler::can_group_user(PA::$login_uid, $gid, array('permissions' => 'manage_ads')); } if ($group_may_invite) { $group_specific = array('invite' => array('caption' => __("Invite a Friend"), 'url' => PA::$url . PA_ROUTE_GROUP_INVITE . '/gid=' . $gid)) + $group_specific; } if ($group_may_post) { // member get's a 'Create Post' link on top $group_specific = array('create_post' => array('caption' => __("Create post"), 'url' => PA::$url . '/post_content.php?ccid=' . $gid)) + $group_specific; } // admin / owner if ($group_owner) { $group_specific = $group_specific + array('settings' => array('caption' => __("Group Settings"), 'url' => PA::$url . '/addgroup.php?gid=' . $gid), 'group_poll_select' => array('caption' => sprintf(__('%s Poll Select'), __(PA::$group_noun)), 'url' => $this->base_url . '/group_poll.php?gid=' . $group_id . '&type=select'), 'group_poll_create' => array('caption' => sprintf(__('%s Poll Create'), __(PA::$group_noun)), 'url' => $this->base_url . '/group_poll.php?gid=' . $group_id . '&type=create')); } // admin / moderator if ($group_moderator) { $group_specific = $group_specific + array('bulletin' => array('caption' => __("Group Bulletin"), 'url' => PA::$url . PA_ROUTE_GROUP_BULLETINS . '?gid=' . $gid), 'moderate' => array('caption' => __("Moderate"), 'url' => PA::$url . PA_ROUTE_GROUP_MODERATION . '/view=members&gid=' . $gid), 'manage_members' => array('caption' => __("Manage Content"), 'url' => PA::$url . '/manage_group_content.php?gid=' . $gid), 'group_customize_ui' => array('caption' => __('Group Appearance'), 'url' => $this->base_url . PA_ROUTE_CUSTOMIZE_GROUP_GUI . '/theme/gid=' . $group_id)); } // ads if ($group_manange_ads) { $group_specific = $group_specific + array('ads' => array('caption' => __("Manage Ads"), 'url' => PA::$url . PA_ROUTE_GROUP_AD_CENTER . '?gid=' . $gid)); } // the join/unjoin/delete go last if ($group_owner) { // only the owner can delete $group_specific = $group_specific + array('delete_group' => array('caption' => __('Delete'), 'url' => $this->base_url . PA_ROUTE_GROUP . '/action=delete&gid=' . $group_id, 'extra' => ' onclick ="return delete_confirmation_msg(\'' . __('Are you sure you want to delete this group') . '?\') "')); } else { // anyone else if ($group_member) { $group_specific = $group_specific + array('unjoin' => array('caption' => __('Unjoin'), 'url' => $this->base_url . PA_ROUTE_GROUP . '/gid=' . $group_id . '&action=leave')); } else { $group_specific = $group_specific + array('join' => array('caption' => __('Join'), 'url' => $this->base_url . PA_ROUTE_GROUP . '/gid=' . $group_id . '&action=join')); } } } ///EOF group specific menu children /// children of group $groups_children = array('groups_general' => $groups_general, 'group_specific' => $group_specific); ///EOF children of group //for network option at 3 level $network = array('configure_network' => array('caption' => __('Configure'), 'url' => $this->base_url . PA_ROUTE_CONFIGURE_NETWORK)) + $level_2; $network_notify = array('email_notification' => array('caption' => __('Email Notification'), 'url' => $this->base_url . '/' . FILE_EMAIL_NOTIFICATION), 'network_bulletins' => array('caption' => __('Bulletins'), 'url' => $this->base_url . '/' . FILE_NETWORK_BULLETINS)); $network_setting = array('network_feature' => array('caption' => __('Set Feature Network'), 'url' => $this->base_url . '/' . FILE_NETWORK_FEATURE), 'manage_emblem' => array('caption' => __('Manage Emblem'), 'url' => $this->base_url . '/' . FILE_MANAGE_EMBLEM), 'manage_taketour' => array('caption' => __('Personalized Video'), 'url' => $this->base_url . '/' . FILE_MANAGE_TAKETOUR), 'splash_page' => array('caption' => __('Configure Splash Page'), 'url' => $this->base_url . '/' . FILE_CONFIGURE_SPLASH_PAGE), 'top_bar' => array('caption' => __('Top Bar Enable/Disable'), 'url' => '#')); $network_default = array('new_user_by_admin' => array('caption' => __('Create User'), 'url' => $this->base_url . '/' . FILE_NEW_USER_BY_ADMIN), 'user_defaults' => array('caption' => __('User Defaults'), 'url' => $this->base_url . '/' . FILE_NETWORK_USER_DEFAULTS), 'relationship_settings' => array('caption' => __('Relationships'), 'url' => $this->base_url . '/' . FILE_RELATIONSHIP_SETTINGS)); $manage_network = array('manage_user' => array('caption' => __('Manage Users'), 'url' => $this->base_url . '/' . FILE_NETWORK_MANAGE_USER), 'manage_content' => array('caption' => __('Manage Contents'), 'url' => $this->base_url . '/' . FILE_NETWORK_MANAGE_CONTENT), 'manage_links' => array('caption' => __('Manage Links'), 'url' => $this->base_url . '/' . FILE_NETWORK_LINKS)); $network_stats = array('statistics' => array('caption' => __('General'), 'url' => $this->base_url . PA_ROUTE_CONFIGURE_NETWORK), 'customize_ui' => array('caption' => __('Customize UI'), 'url' => $this->base_url . '/' . FILE_NETWORK_CUSTOMIZE_UI_PAGE)); $network_module_selector = array('home_page_id' => array('caption' => __('Home Page'), 'url' => $this->base_url . '/' . FILE_MODULE_SELECTOR . '?page_id=home_page_id'), 'user_default_page_id' => array('caption' => __('User Default Page'), 'url' => $this->base_url . '/' . FILE_MODULE_SELECTOR . '?page_id=user_default_page_id'), 'group_directory_page_id' => array('caption' => __('Group Directory Page'), 'url' => $this->base_url . '/' . FILE_MODULE_SELECTOR . '?page_id=group_directory_page_id'), 'network_directory_page_id' => array('caption' => __('Network Directory Page'), 'url' => $this->base_url . '/' . FILE_MODULE_SELECTOR . '?page_id=network_directory_page_id')); if ($this->network_info->type != MOTHER_NETWORK_TYPE) { unset($network['meta_network']); } if ($this->network_info->type != MOTHER_NETWORK_TYPE) { unset($network['manage_taketour']); unset($network['manage_emblem']); } //end /// second level menu for network $level_3 = array('user' => @$user_children, 'people' => @$people_children, 'family' => @$family_children, 'groups' => $groups_children, 'network' => $network, 'network_notify' => $network_notify, 'network_module_selector' => $network_module_selector, 'network_setting' => $network_setting, 'network_default' => $network_default, 'manage_network' => $manage_network, 'network_stats' => $network_stats); ///EOF second level menu children ///set level menu items $this->level_1 = $level_1; $this->level_2 = $level_2; $this->level_3 = $level_3; }