function render() { switch ($this->view) { case "public": // default PA view break; case 'user': if (empty($this->uid)) { return "user_id is required"; } break; default: return "Unknown RelationsModule view: {$this->view}"; } $extra = array(); if (isset(PA::$network_info->extra)) { $extra = unserialize(PA::$network_info->extra); } $this->isfriend = FALSE; $relations = Relation::get_all_relations((int) $this->uid); foreach ($relations as $i => $rel) { $relations[$i]['no_of_relations'] = count(Relation::get_relations($rel['user_id'], APPROVED)); if ($rel['status'] == PENDING) { $this->pending_relations[] = $rel; unset($relations[$i]); } } $this->links = $this->relations = $relations; if (!empty(PA::$login_user->user_id)) { // get the relation between page user and loged in user $my_relations = Relation::get_all_relations(PA::$login_user->user_id); foreach ($my_relations as $i => $rel) { if ($rel['user_id'] == $this->uid) { $this->isfriend = $rel['status']; } } // get the friend requests $this->myfriends = Relation::get_all_user_ids(PA::$login_user->user_id); $this->to_confirm = array(); foreach ($this->myfriends as $i => $rel) { $rel['no_of_relations'] = count(Relation::get_relations($rel['user_id'], APPROVED)); if ($rel['user_id'] == $this->uid) { $this->isfriend = $rel['status']; } if ($rel['status'] == PENDING) { $this->to_confirm[] = $rel; unset($this->myfriends[$i]); } } } if (count($this->relations) > 0) { $this->view_all_url = "{$base_url}/view_all_members.php?view_type=relations&uid={$uid}"; } $this->inner_HTML = $this->generate_inner_html(); $content = parent::render(); return $content; }
function setup_module($column, $module, $obj) { global $is_member, $is_admin, $group_data, $gid; $obj->gid = $gid; switch ($module) { case 'MembersFacewallModule': $group = new Group(); $group->collection_id = $gid; $group->is_active = ACTIVE; $members = $group->get_members($cnt = FALSE, 5, 1, 'created', 'DESC', FALSE); if (is_array($members)) { $count = count($members); $group_members = members_to_array($members); $users_data = array(); foreach ($members as $member) { $count_relations = Relation::get_relations($member['user_id'], APPROVED, PA::$network_info->network_id); $user = new User(); $user->load((int) $member['user_id']); $login_name = $user->login_name; $user_picture = $user->picture; $users_data[] = array('user_id' => $member['user_id'], 'picture' => $user_picture, 'login_name' => $login_name, 'no_of_relations' => count($count_relations)); } $users = array('users_data' => $users_data, 'total_users' => $count); } $obj->links = $users; $obj->gid = $gid; break; case 'ImagesModule': $obj->block_type = 'Gallery'; $obj->page = 'grouppage'; $obj->title = 'Group Gallery'; $obj->group_details['collection_id'] = $group_data->collection_id; break; case 'GroupForumModule': if ($group_data->reg_type == REG_INVITE) { if (!$is_member && !$is_admin) { return "skip"; } } $obj->is_member = $is_member; $obj->is_admin = $is_admin; $obj->group_details = $group_data; break; case 'RecentPostModule': $obj->type = 'group'; $obj->gid = $_REQUEST['gid']; break; } }
/** * The default constructor for MembersFacewallModule class. * It initializes the default values of vars */ function __construct() { $this->title = __("Members"); $this->html_block_id = "members"; $this->view_all_url = 'view_all_members.php'; $users = Network::get_members(array('page' => 1, 'show' => 5, 'network_id' => PA::$network_info->network_id)); $total_users = count($users['users_data']); // counting no of relation of each user for ($i = 0; $i < $total_users; $i++) { $count_relations = Relation::get_relations($users['users_data'][$i]['user_id']); $users['users_data'][$i]['no_of_relations'] = count($count_relations); } $this->links = $users; $this->sort_by = TRUE; }
public function initializeModule($request_method, $request_data) { if (!empty($this->shared_data['group_info'])) { $sort = $this->sort_by == 'last_login' ? 'last_login' : 'created'; $group = $this->shared_data['group_info']; $this->gid = $group->collection_id; $users = $group->get_members($cnt = FALSE, 5, 1, $sort, 'DESC', FALSE); $total_users = count($users); } else { $this->title = __('Members'); $net_params = array('page' => 1, 'show' => 5, 'network_id' => PA::$network_info->network_id); if ($this->sort_by == 'last_login') { $sort = array('sort_by' => 'U.last_login'); $net_params = array_merge($net_params, $sort); } $users = Network::get_members($net_params); $total_users = count($users['users_data']); } $users_data = array(); $status = null; if (!empty(PA::$extra['reciprocated_relationship']) && PA::$extra['reciprocated_relationship'] == NET_YES) { $status = APPROVED; } if (!empty($users)) { if (!empty($this->shared_data['group_info'])) { foreach ($users as $user) { $count_relations = Relation::get_relations($user['user_id'], $status, PA::$network_info->network_id); $group_member = new User(); $group_member->load((int) $user['user_id']); $users_data[] = array('user_id' => $user['user_id'], 'picture' => $group_member->picture, 'login_name' => $group_member->login_name, 'display_name' => $group_member->display_name, 'no_of_relations' => count($count_relations)); } $users = array('users_data' => $users_data, 'total_users' => $total_users); } else { // counting no of relation of each user for ($i = 0; $i < $total_users; $i++) { $count_relations = Relation::get_relations($users['users_data'][$i]['user_id'], $status, PA::$network_info->network_id); $curr_user_relations = $count_relations; $users['users_data'][$i]['no_of_relations'] = count($count_relations); } } $this->links = $users; $this->sort_by = TRUE; } else { $this->do_skip = TRUE; } }
public function render() { $status = null; if (!empty(PA::$extra['reciprocated_relationship']) && PA::$extra['reciprocated_relationship'] == NET_YES) { $status = APPROVED; } $relations = Relation::get_all_relations((int) PA::$uid, 6, FALSE, 'ALL', 0, 'created', 'DESC', 'internal', $status, PA::$network_info->network_id); for ($i = 0; $i < count($relations); $i++) { $count_relations = Relation::get_relations($relations[$i]['user_id'], $status, PA::$network_info->network_id); $relations[$i]['no_of_relations'] = count($count_relations); } $this->links = $relations; if (!empty($this->links)) { $this->view_all_url = PA::$url . '/' . FILE_VIEW_ALL_MEMBERS . '?view_type=relations&uid=' . PA::$uid; } $this->inner_HTML = $this->generate_inner_html(); $content = parent::render(); return $content; }
function render() { $extra = unserialize(PA::$network_info->extra); $status = null; if (@$extra['reciprocated_relationship'] == NET_YES) { $status = APPROVED; } // moved this line down so that $status is actially defined --Martin $this->links = Relation::get_all_user_ids((int) $this->uid, 5, $cnt = FALSE, $show = 'ALL', $page = 0, $sort_by = 'created', $direction = 'DESC', $status); for ($i = 0; $i < count($this->links); $i++) { $count_relations = Relation::get_relations($this->links[$i]['user_id'], $status); $this->links[$i]['no_of_relations'] = count($count_relations); } $this->inner_HTML = $this->generate_inner_html(); if (count($this->links) > 0) { $this->view_all_url = PA::$url . "/view_all_members.php?view_type=in_relations&uid={$this->uid}"; } $content = parent::render(); return $content; }
function render() { $extra = unserialize(PA::$network_info->extra); $status = null; if (@$extra['reciprocated_relationship'] == NET_YES) { $status = APPROVED; } //fix by Z.Hron: Show reciprocated relationship only for members of this network $added_by = Relation::get_all_user_ids((int) $this->uid, 5, $cnt = FALSE, $show = 'ALL', $page = 0, $sort_by = 'created', $direction = 'DESC', $status, PA::$network_info->network_id); $this->links = $added_by; foreach ($this->links as &$_link) { $count_relations = Relation::get_relations($_link['user_id'], $status, PA::$network_info->network_id); $_link['no_of_relations'] = count($count_relations); } $this->inner_HTML = $this->generate_inner_html(); if (count($this->links) > 0) { $this->view_all_url = PA::$url . "/view_all_members.php?view_type=in_relations&uid={$this->uid}"; } $content = parent::render(); return $content; }
function setup_module($column, $module, $obj) { global $group_data, $gid, $request_info, $is_edit, $edit_data, $member_type; $obj->gid = $gid; switch ($module) { case 'MembersFacewallModule': $group = new Group(); $group->collection_id = $gid; $group->is_active = 1; $members = $group->get_members($cnt = FALSE, 5, 1, 'created', 'DESC', FALSE); if (is_array($members)) { $count = count($members); foreach ($members as $member) { $count_relations = Relation::get_relations($member['user_id']); $user = new User(); $user->load((int) $member['user_id']); $login_name = $user->login_name; $user_picture = $user->picture; $users_data[] = array('user_id' => $member['user_id'], 'picture' => $user_picture, 'login_name' => $login_name, 'no_of_relations' => count($count_relations)); } $users = array('users_data' => $users_data, 'total_users' => $count); } $obj->links = $users; $obj->gid = $gid; break; case 'ImagesModule': $obj->block_type = 'Gallery'; $obj->page = 'grouppage'; $obj->title = 'Group Gallery'; break; case 'CreateForumTopicModule': if (!$is_edit) { return 'skip'; } $obj->edit_data = $edit_data; $obj->is_edit = $is_edit; break; } }
/** * Method to load information of selected profile. * order by can be applied like $order_by => 'seq' or 'seq DESC' or 'seq ASC' */ public static function load_user_profile($user_id, $my_user_id, $information_type = null, $order_by = null) { Logger::log("Enter: User::load_user_profile"); $relations = array(); $user_profile_data = array(); $i = 0; if (is_null($information_type)) { $sql = 'SELECT * FROM {user_profile_data} WHERE user_id = ? '; $data = array($user_id); } else { $sql = 'SELECT * FROM {user_profile_data} WHERE user_id = ? AND field_type = ?'; $data = array($user_id, $information_type); } //added for gurpreet if (!empty($order_by)) { $sql .= ' ORDER BY ' . $order_by; } $res = Dal::query($sql, $data); if ($res->numRows() > 0) { while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $array_of_data[$i]['uid'] = $row->user_id; $array_of_data[$i]['name'] = $row->field_name; $array_of_data[$i]['value'] = $row->field_value; $array_of_data[$i]['type'] = $row->field_type; $array_of_data[$i]['perm'] = $row->field_perm; $array_of_data[$i]['seq'] = $row->seq ? (int) $row->seq : NULL; $i++; } } if (!empty($array_of_data)) { // Getting degree 1 friendlist $relations = Relation::get_relations($user_id, null, PA::$network_info->network_id); if ($user_id == $my_user_id) { //Logged in user is viewing its own blog. $user_profile_data = $array_of_data; } else { if (in_array($my_user_id, $relations)) { //some from user's relations is viewing its blog //check whether relation is in user's family $in_family = Relation::is_relation_in_family($user_id, $my_user_id); foreach ($array_of_data as $user_data) { //user data viewable to family members. if ($user_data['perm'] == IN_FAMILY && $in_family) { $user_profile_data[] = $user_data; } if ($user_data['perm'] == WITH_IN_DEGREE_1 || $user_data['perm'] == ANYONE) { $user_profile_data[] = $user_data; } } //end for } else { //user data viewable to user which is not in relation wth given user. foreach ($array_of_data as $user_data) { if ($user_data['perm'] == ANYONE) { $user_profile_data[] = $user_data; } } } } } //end outer if Logger::log("Exit: User::load_user_profile"); return $user_profile_data; }
/** 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; }
$group_details['category_id'] = $group->category_id; $cat_obj = new Category(); $cat_obj->set_category_id($group->category_id); $cat_obj->load(); $cat_name = stripslashes($cat_obj->name); $cat_description = stripslashes($cat_obj->description); $group_details['category_name'] = $cat_name; $group_details['category_description'] = $cat_description; $group_details['members'] = Group::get_member_count($gid); $group_details['access_type'] = $access_type; $group_details['is_admin'] = $is_admin; //////////////////get details of group EOF if (is_array($members)) { $count = count($members); foreach ($members as $member) { $count_relations = Relation::get_relations($member['user_id'], APPROVED, PA::$network_info->network_id); $user = new User(); $user->load((int) $member['user_id']); $login_name = $user->login_name; $user_picture = $user->picture; $users_data[] = array('user_id' => $member['user_id'], 'picture' => $user_picture, 'login_name' => $login_name, 'no_of_relations' => count($count_relations)); } $final_array = array('users_data' => $users_data, 'total_users' => $count); } $users = $final_array; if (isset($_SESSION['user']['id']) && Group::member_exists((int) $group->collection_id, (int) $_SESSION['user']['id'])) { $is_member = TRUE; } $group_details['is_member'] = $is_member; //..get details of group ends }
public static function load_recent_media_image($user_id = 0, $my_user_id = 0) { Logger::log("Enter: Image::load_recent_media_image | Arg: \$user_id = {$user_id}"); Logger::log("Calling: Content::load | Param: \$my_user_id = {$my_user_id}"); $i = 0; if ($user_id == 0) { $sql = "SELECT * FROM {contents} AS C, {images} as I,{recent_media_track} as R WHERE C.content_id = I.content_id AND I.content_id=R.cid AND R.type = ? AND I.image_perm = ? AND C.is_active = ? ORDER by C.created DESC "; $data = array(IMAGE, ANYONE, 1); } else { $sql = "SELECT * FROM {contents} AS C, {images} as I , {recent_media_track} as R WHERE C.content_id = I.content_id AND I.content_id=R.cid AND R.type = ? AND C.author_id = ? AND C.is_active = ? ORDER by C.created DESC "; $data = array(IMAGE, $user_id, 1); } $res = Dal::query($sql, $data); if ($res->numRows() > 0) { while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $image_data[$i]['content_id'] = $row->content_id; $image_data[$i]['image_file'] = $row->image_file; $image_data[$i]['caption'] = $row->title; $image_data[$i]['title'] = $row->title; $image_data[$i]['body'] = $row->body; $image_data[$i]['created'] = $row->created; $image_data[$i]['collection_id'] = $row->collection_id; $image_data[$i]['perm'] = $row->image_perm; $image_data[$i]['author_id'] = $row->author_id; $i++; } } $user_image_data = array(); if (!empty($image_data) && $my_user_id != 0) { // getting degree 1 friendlist $relations = Relation::get_relations($my_user_id); if ($user_id == $my_user_id) { $user_image_data = $image_data; } elseif (in_array($my_user_id, $relations)) { foreach ($image_data as $user_data) { if ($user_data['perm'] == WITH_IN_DEGREE_1 || $user_data['perm'] == ANYONE) { $user_image_data[] = $user_data; } } } elseif ($my_user_id == 0) { foreach ($image_data as $user_data) { if ($user_data['perm'] == WITH_IN_DEGREE_1 || $user_data['perm'] == ANYONE) { $user_image_data[] = $user_data; } } } else { foreach ($image_data as $user_data) { if ($user_data['perm'] == ANYONE) { $user_image_data[] = $user_data; } } } } else { if ($user_id == $my_user_id && $my_user_id != 0) { $user_image_data = $image_data; } else { if ($my_user_id == 0 && !empty($image_data)) { foreach ($image_data as $user_data) { if ($user_data['perm'] == ANYONE) { $user_image_data[] = $user_data; } } } } } Logger::log("Exit: Image::load_recent_media_image"); return $user_image_data; }
$sorting_options[] = array('caption' => __('Last Login'), 'value' => 'last_login'); $sorting_options[] = array('caption' => __('Latest Registered'), 'value' => 'latest_registered'); if (CURRENT_NETWORK_URL_PREFIX != 'www' && CURRENT_NETWORK_URL_PREFIX != '') { $network = new Network(); $where = "address = '" . CURRENT_NETWORK_URL_PREFIX . "'"; $netinfo = $network->get(NULL, $where); $params = array('page' => 1, 'show' => 5); if ($sort_by == 'last_login') { $a = array('sort_by' => 'U.last_login'); $params = array_merge($params, $a); } $users = Network::get_network_members($netinfo[0]->network_id, $params); } else { if ($sort_by == 'last_login') { $users = User::allUsers(10, 'last_login', 5); } else { if ($sort_by == 'latest_registered') { $users = User::allUsers(10, 'latest', 5); } } for ($i = 0; $i < count($users['users_data']); $i++) { $count_relations = Relation::get_relations($users['users_data'][$i]['user_id']); $users['users_data'][$i]['no_of_relations'] = count($count_relations); } } $obj = new MembersFacewallModule(); $obj->mode = $obj->sort_by = SORT_BY; $obj->links = $users; $obj->sorting_options = $sorting_options; $obj->selected_option = $selected_option; echo $obj->render();
/** !! * This generates the page specific html to be passed on to the render function. * It uses the standard templates to achieve this. It also determines the * type of activity that each data is, depending on what type of page * it is and the type of activity being reported. * * @return string $inner_html The aforementioned page specific html */ function generate_inner_html() { $params = array('limit' => $this->limit); $conditions = array(); switch ($this->page_type) { case 'group': $params['activity_type'] = array('group_joined', 'group_image_upload', 'group_video_upload', 'group_audio_upload', 'group_post_a_blog', 'group_settings_updated'); $conditions['object'] = $this->subject; $this->selected = 1; break; case 'user_public': $conditions['subject'] = $this->subject; $this->selected = 3; break; case 'user_private': case 'user_friends': $params['relation_ids'] = Relation::get_relations(PA::$login_uid, APPROVED, PA::$network_info->network_id); if (count($params['relation_ids']) == 0) { $this->do_skip = TRUE; return '<div style="margin:8px">No Feeds</div>'; } $this->selected = 2; break; } $conditions['status'] = 'new'; $tmp_file = PA::$blockmodule_path . '/' . get_class($this) . '/side_inner_public.tpl'; $inner_html_gen = new Template($tmp_file); $list = Activities::get_activities($params, $conditions); if (empty($list)) { $this->do_skip = TRUE; return '<div style="margin:8px">No Feeds</div>'; } $inner_html_gen->set('list', $list); $inner_html_gen->set('options', $this->sel_options); $inner_html_gen->set('selected_option', $this->selected); $inner_html_gen->set('ajax_url', $this->ajax_url); $inner_html_gen->set('block_name', $this->html_block_id); $inner_html_gen->set('request_method', $this->request_method); $inner_html = $inner_html_gen->fetch(); return $inner_html; }
function get_users() { if ($this->mode == 'alphabetical') { $this->sort_by = 'UP.field_value'; $sorting_direction = 'ASC'; } else { $this->sort_by = 'U.created'; $sorting_direction = 'DESC'; } $this->search = array('field_type' => $this->skin, 'field_name' => 'login_name'); if (@$this->q) { $this->search['operator'] = 'LIKE'; $this->search['value'] = "%{$this->q}%"; } $users = array(); if ($this->mode == 'friends') { $this->users = Relation::get_all_relations((int) $this->uid); foreach ($relations as $i => $rel) { $relations[$i]['no_of_relations'] = count(Relation::get_relations($rel['user_id'], APPROVED)); } foreach ($this->users as $i => $u) { if ($u['status'] == PENDING) { unset($this->users[$i]); } else { // we make Object of Array $r = NULL; foreach ($u as $k => $v) { $r->{$k} = $v; } $this->users[$i] = $r; $this->users[$i]->pa_id = $r->user_id; } } $this->user_count = count($this->users); if (!$this->user_count) { // this user has no friends $this->mode = 'newest'; } } if (!$this->user_count) { // load users on the basis of the search parameters. $this->users = ShadowUser::search($this->search, $this->show, $this->page, $this->sort_by, $sorting_direction); $this->user_count = ShadowUser::search($this->search, "COUNT"); } if ($this->user_count) { // prepare paging info $this->n_pages = (int) ceil($this->user_count / $this->show); } }
$cat_obj->load(); $cat_name = stripslashes($cat_obj->name); $cat_description = stripslashes($cat_obj->description); $group_details['category_name'] = $cat_name; $group_details['category_description'] = $cat_description; $group_details['members'] = Group::get_member_count($gid); $group_details['access_type'] = $access_type; $group_details['is_admin'] = $is_admin; $group_tags = Tag::load_tags_for_content_collection((int) $group->collection_id); $group_details['tag_entry'] = Tag::tag_array_to_html($group_tags, 1); //////////////////get details of group EOF if (is_array($members)) { $count = count($members); $users_data = array(); foreach ($members as $member) { $count_relations = Relation::get_relations($member['user_id']); $group_member = new User(); $group_member->load((int) $member['user_id']); $login_name = $group_member->login_name; $user_picture = $group_member->picture; $users_data[] = array('user_id' => $member['user_id'], 'picture' => $user_picture, 'login_name' => $login_name, 'no_of_relations' => count($count_relations)); } $final_array = array('users_data' => $users_data, 'total_users' => $count); } $users = $final_array; //p($users); if (Group::member_exists((int) $group->collection_id, (int) $login_uid)) { $is_member = TRUE; $header->is_member = TRUE; } $is_admin_member = FALSE;
function pageLoadGroup($group) { $access = $group->access_type; $skip_group_modules = FALSE; $is_admin = FALSE; if ($group->access_type == $group->ACCESS_PRIVATE) { if (PA::$login_uid) { //if private group if (GROUP::member_exists($group->collection_id, PA::$login_uid)) { $skip_group_modules = FALSE; } else { // haha no way for non member of group $skip_group_modules = TRUE; } } else { //haha no way for anonymous user $skip_group_modules = TRUE; } $access_type = 'Private'; } else { $access_type = 'Public'; } if ($group->reg_type == $group->REG_OPEN) { $access_type .= ' Open'; } else { $access_type .= ' Moderated'; } if (Group::is_admin((int) $group->collection_id, (int) PA::$login_uid)) { $is_admin = TRUE; } $members = $group->get_members($cnt = FALSE, 5, 1, 'created', 'DESC', FALSE); $group_details = array(); $group_details['collection_id'] = $group->collection_id; $group_details['type'] = $group->type; $group_details['author_id'] = $group->author_id; $user = new User(); $user->load((int) $group->author_id); $login_name = $user->login_name; $first_name = $user->first_name; $last_name = $user->last_name; $group_details['author_name'] = $login_name; $group_details['author_picture'] = $user->picture; $group_details['title'] = $group->title; $group_details['description'] = $group->description; $group_details['is_active'] = $group->is_active; $group_details['picture'] = $group->picture; $group_details['desktop_picture'] = @$group->desktop_picture; $group_details['created'] = PA::datetime($group->created, 'long', 'short'); // date("F d, Y h:i A", $group->created); $group_details['changed'] = $group->changed; $group_details['category_id'] = $group->category_id; $cat_obj = new Category(); $cat_obj->set_category_id($group->category_id); $cat_obj->load(); $cat_name = stripslashes($cat_obj->name); $cat_description = stripslashes($cat_obj->description); $group_details['category_name'] = $cat_name; $group_details['category_description'] = $cat_description; $group_details['members'] = Group::get_member_count($group->collection_id); $group_details['access_type'] = $access_type; $group_details['is_admin'] = $is_admin; //////////////////get details of group EOF if (is_array($members)) { $count = count($members); foreach ($members as $member) { $count_relations = Relation::get_relations($member['user_id'], APPROVED, PA::$network_info->network_id); $user = new User(); $user->load((int) $member['user_id']); $login_name = $user->login_name; $user_picture = $user->picture; $users_data[] = array('user_id' => $member['user_id'], 'picture' => $user_picture, 'login_name' => $login_name, 'no_of_relations' => count($count_relations)); } $final_array = array('users_data' => $users_data, 'total_users' => $count); } $users = $final_array; $is_member = Group::member_exists((int) $group->collection_id, (int) PA::$login_uid) ? TRUE : FALSE; $group_details['is_member'] = $is_member; $group_details['skip_group_modules'] = $skip_group_modules; $group_details['users'] = $users; return $group_details; }
public static function can_see($persona_id, $owner_uid, $viewer_uid) { Logger::log("Enter: function PersonaHelper::can_see() persona_id: {$persona_id}, owner_uid; {$owner_uid}, viewer_uid: {$viewer_uid}"); // load the persona to see it's privacy data try { $persona = new Persona(); $persona->load($persona_id); } catch (PAException $e) { Logger::Log($e->getMessage()); Logger::log("Exit: function PersonaHelper::can_see() with NULL"); return null; // no persona! } $data = $persona->get_configuration_data(); $perm = intval($data->perm); if ($viewer_uid == 0) { // anon users don't have relations $relation = 0; // and are definetly not family $in_family = 0; } else { if ($owner_uid == $viewer_uid) { $relation = 2; $in_family = 1; } else { // $relation = Relation::get_relation($owner_uid, $viewer_uid); $relations = Relation::get_relations($owner_uid); $relation = in_array($viewer_uid, $relations); $in_family = Relation::is_relation_in_family($owner_uid, $viewer_uid); } } Logger::log("PersonaHelper::can_see() perm: {$perm}, relation: {$relation}, in_family: {$in_family}"); if (!$perm) { // permissions weren't set or are 0 == nobody Logger::log("Exit: function PersonaHelper::can_see() with NULL"); return null; } else { if ($perm == 1) { // show to world (everybody) Logger::log("Exit: function PersonaHelper::can_see() with Persona"); return $persona; } else { if ($perm == 2) { // show to relations if ($relation) { Logger::log("Exit: function PersonaHelper::can_see() with Persona"); return $persona; } } else { if ($perm == 3) { // show to family if ($in_family) { Logger::log("Exit: function PersonaHelper::can_see() with Persona"); return $persona; } } else { Logger::log("Exit: function PersonaHelper::can_see() with NULL"); return null; } } } } }
function generate_inner_html() { global $current_theme_path, $base_url; switch ($this->mode) { default: $tmp_file = dirname(__FILE__) . '/center_inner_public.tpl'; } $inner_html_gen =& new Template($tmp_file, $this); $inner_html_gen->set('current_theme_path', $current_theme_path); $inner_html_gen->set('base_url', $base_url); if (!empty($this->mid)) { $message = Message::load_message(null, $this->mid); } //getting the relations of user. //TODO: Sorting relations alphabetically. $relations = Relation::get_relations($this->uid); $friends = array(); if (count($relations)) { foreach ($relations as $relation) { $User = new User(); $relation = (int) $relation; $User->load($relation); //$friends[] = array('id'=>$relation, 'login_name'=>$User->login_name); $friends[$User->login_name] = $relation; } //key of the array will the login_name and value will be the login_id //sorting the array on the basis of login_name ksort($friends); } $subject = $body = $to = null; $in_reply_to = 0; switch ($this->action) { case 'reply': $in_reply_to = $this->mid; $sender = new User(); $sender->load((int) $message['sender_id']); $subject = 'Re: ' . $message['subject']; $body = "\n\n\n" . $sender->login_name . " wrote >> \n--------------------------------------\n" . $message['body']; $to = $sender->login_name; $cancel_link = $base_url . '/view_message.php?mid=' . $this->mid; break; case 'forward': $subject = 'Fwd: ' . $message['subject']; $body = $message['body']; $cancel_link = $base_url . '/view_message.php?mid=' . $this->mid; break; case 'new': default: $subject = $body = $to = null; $cancel_link = $base_url . '/mymessage.php'; } // if page_uid is set then TO will be set with the login name corresponding with page_uid. if (!empty($this->page_uid)) { $User = new User(); $User->load((int) $this->page_uid); $to = $User->login_name; } $folders = Message::get_user_folders($this->uid); $inner_html_gen->set('cancel_link', $cancel_link); $inner_html_gen->set('friends', $friends); $inner_html_gen->set('to', $to); $inner_html_gen->set('in_reply_to', $in_reply_to); $inner_html_gen->set('subject', $subject); $inner_html_gen->set('body', $body); $inner_html_gen->set('folders', $folders); $inner_html = $inner_html_gen->fetch(); return $inner_html; }
public function render() { $groups = Group::get_user_groups(PA::$login_uid, FALSE, 'ALL'); $groups_count = count($groups); for ($i = 0; $i < $groups_count; $i++) { $this->user_groups[] = array('gid' => $groups[$i]['gid'], 'name' => stripslashes($groups[$i]['name'])); } //getting the relations of user. $relations = Relation::get_relations(PA::$login_uid, APPROVED, PA::$network_info->network_id); $friends = array(); if (count($relations)) { foreach ($relations as $relation) { $User = new User(); $relation = (int) $relation; $User->load($relation); //$friends[] = array('id'=>$relation, 'login_name'=>$User->login_name); $friends[$User->display_name] = $User->login_name; } //key of the array will the login_name and value will be the login_id //sorting the array on the basis of login_name ksort($friends); } $this->user_friends = $friends; $this->inner_HTML = $this->generate_inner_html(); $content = parent::render(); return $content; }
/** * Load all Videos of user gallery with its data for a single user. * @param $user_id, the user id of the user whose videos to be loaded. * @param $limit, limit how many videos should be loaded. If no limit is given then it will load all videos. * @param $user_id user id of the person who is accessing data * @param $my_user_id user id of the person whose data is loading * @return $video_data, an associative array, having content_id, video_file, title, body in it for each video. */ public static function load_user_gallery_video($user_id = 0, $limit = 0, $my_user_id = 0) { Logger::log("Enter: Video::load_user_gallery_video"); $i = 0; if ($user_id == 0) { $sql = "SELECT * FROM {contents} AS C, {videos} as V, {contentcollections}\n as CC WHERE C.content_id = V.content_id AND CC.collection_id =\n C.collection_id AND V.video_perm = ? AND C.is_active =? AND CC.type = ?\n ORDER by C.created DESC "; if ($limit != 0) { $sql .= "LIMIT {$limit}"; } $res = Dal::query($sql, array(ANYONE, ACTIVE, ALBUM_COLLECTION_TYPE)); } else { $sql = "SELECT * FROM {contents} AS C, {videos} as V, {contentcollections}\n as CC WHERE C.content_id = V.content_id AND CC.collection_id =\n C.collection_id AND C.author_id = ? AND C.is_active = ? AND CC.type = ?\n ORDER by C.created DESC "; if ($limit != 0) { $sql .= "LIMIT {$limit}"; } $res = Dal::query($sql, array($user_id, ACTIVE, ALBUM_COLLECTION_TYPE)); } $video_data = array(); if ($res->numRows() > 0) { while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $video_data[$i]['content_id'] = $row->content_id; $video_data[$i]['video_file'] = $row->video_file; $video_data[$i]['caption'] = $row->title; $video_data[$i]['title'] = $row->title; $video_data[$i]['body'] = $row->body; $video_data[$i]['created'] = $row->created; $video_data[$i]['collection_id'] = $row->collection_id; $video_data[$i]['perm'] = $row->video_perm; $i++; } } $user_video_data = array(); if (!empty($video_data) && $my_user_id != 0) { // getting degree 1 friendlist $relations = Relation::get_relations($my_user_id, APPROVED, PA::$network_info->network_id); if ($user_id == $my_user_id) { $user_video_data = $video_data; } elseif (in_array($my_user_id, $relations)) { foreach ($video_data as $user_data) { if ($user_data['perm'] == WITH_IN_DEGREE_1 || $user_data['perm'] == ANYONE) { $user_video_data[] = $user_data; } } } elseif ($my_user_id == 0) { foreach ($video_data as $user_data) { if ($user_data['perm'] == WITH_IN_DEGREE_1 || $user_data['perm'] == ANYONE) { $user_video_data[] = $user_data; } } } else { foreach ($video_data as $user_data) { if ($user_data['perm'] == ANYONE) { $user_video_data[] = $user_data; } } } } else { if ($user_id == $my_user_id && $my_user_id != 0) { $user_video_data = $video_data; } else { if ($my_user_id == 0 && !empty($video_data)) { foreach ($video_data as $user_data) { if ($user_data['perm'] == ANYONE) { $user_video_data[] = $user_data; } } } } } Logger::log("Exit: Video::load_user_gallery_video"); return $user_video_data; }
/** !! * This takes the template and sets it up depending on what the * action being executed it. * * @return string $inner_html The html that is module specific. */ public function generate_inner_html() { switch ($this->mode) { default: $tmp_file = PA::$blockmodule_path . '/' . get_class($this) . '/center_inner_public.tpl'; } $inner_html_gen = new Template($tmp_file, $this); $inner_html_gen->set('current_theme_path', PA::$theme_url); if (!empty($this->mid)) { $message = Message::load_message(null, $this->mid); } //getting the relations of user. $relations = Relation::get_relations($this->uid, APPROVED, PA::$network_info->network_id); $friends = array(); if (count($relations)) { foreach ($relations as $relation) { $User = new User(); $relation = (int) $relation; $User->load($relation); //$friends[] = array('id'=>$relation, 'login_name'=>$User->login_name); $friends[$User->display_name] = $User->login_name; } //key of the array will the login_name and value will be the login_id //sorting the array on the basis of login_name ksort($friends); } $subject = $body = $to = null; $in_reply_to = 0; switch ($this->action) { case 'reply': $in_reply_to = $this->mid; $sender = new User(); $sender->load((int) $message['sender_id']); $subject = 'Re: ' . $message['subject']; $body = "\n\n\n" . $sender->login_name . " wrote >> \n--------------------------------------\n" . $message['body']; $to = $sender->login_name; $to_display = $sender->display_name; $cancel_link = PA::$url . '/' . FILE_VIEW_MESSAGE . '?mid=' . $this->mid; break; case 'forward': $subject = 'Fwd: ' . $message['subject']; $body = $message['body']; $cancel_link = PA::$url . '/' . FILE_VIEW_MESSAGE . '?mid=' . $this->mid; break; case 'new': default: $subject = $body = $to = null; $cancel_link = PA::$url . PA_ROUTE_MYMESSAGE; } // if page_uid is set then TO will be set with the login name corresponding with page_uid. if (!empty($this->page_uid)) { $User = new User(); $User->load((int) $this->page_uid); $to = $User->login_name; $to_display = $User->display_name; } $folders = Message::get_user_folders($this->uid); $inner_html_gen->set('cancel_link', $cancel_link); $inner_html_gen->set('friends', $friends); $inner_html_gen->set('to', $to); $inner_html_gen->set('to_display', @$to_display); $inner_html_gen->set('in_reply_to', $in_reply_to); $inner_html_gen->set('subject', $subject); $inner_html_gen->set('body', $body); $inner_html_gen->set('folders', $folders); $inner_html = $inner_html_gen->fetch(); return $inner_html; }
/** 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; }
/** * this is the method to get the Graph of the nodes to be travelled for calculatin degree of seperation, this * convert myfriends into associative array -- - called in shortest_path() * @return $neighbors the global array having all immediate relations for each user id */ private function set_graph() { Logger::log("Enter: Relation::set_graph"); global $neighbors; $sql = 'SELECT user_id FROM {users} WHERE is_active = ?'; $data = array(1); $res = Dal::query($sql, $data); while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $immediate_relations = Relation::get_relations($row->user_id); for ($i = 0; $i < count($immediate_relations); $i++) { $neighbors[$row->user_id][$immediate_relations[$i]] = 1; } } Logger::log("Exit: Relation::set_graph"); return $neighbors; }