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;
 }
 public function initializeModule($request_method, $request_data)
 {
     if (empty($this->shared_data['group_info'])) {
         return "skip";
     }
     switch ($this->column) {
         case 'middle':
         case "toprow":
             $this->outer_template = 'outer_public_center_module.tpl';
             $this->inner_template = PA::$blockmodule_path . '/' . get_class($this) . '/center_inner.tpl.php';
             $this->title = NULL;
             break;
         case 'left':
         case 'right':
             $this->outer_template = 'outer_public_side_module.tpl';
             $this->inner_template = PA::$blockmodule_path . '/' . get_class($this) . '/side_inner.tpl.php';
             break;
         default:
     }
     $this->is_in_family = $this->may_see_details = false;
     $sort = 'created';
     $group = $this->shared_data['group_info'];
     $this->gid = $group->collection_id;
     $users = $group->get_members($cnt = FALSE, 'ALL', 1, $sort, 'DESC', FALSE);
     $total_users = count($users);
     $users_data = array();
     foreach ($users as $user) {
         $group_member = new User();
         $group_member->load((int) $user['user_id']);
         // see if we have a special relation of this user to the group
         list($relType, $membertype) = TypedGroupEntityRelation::get_relation_to_group($user['user_id'], (int) $this->gid);
         $users_data[] = array('user_id' => $user['user_id'], 'picture' => $group_member->picture, 'login_name' => $group_member->login_name, 'display_name' => $group_member->display_name, 'family_status' => $membertype);
         if (PA::$login_uid == $user['user_id']) {
             $this->is_in_family = $this->may_see_details = true;
         }
     }
     $users = array('users_data' => $users_data, 'total_users' => $total_users);
     $this->links = $users;
     $this->sort_by = false;
 }
 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&amp;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&amp;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&amp;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&amp;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 . '&amp;action=leave'));
             } else {
                 $group_specific = $group_specific + array('join' => array('caption' => __('Join'), 'url' => $this->base_url . PA_ROUTE_GROUP . '/gid=' . $group_id . '&amp;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;
 }
 function initializeModule($request_method, $request_data)
 {
     $this->action = !empty($request_data['faction']) ? $request_data['faction'] : null;
     $this->module = !empty($request_data['module']) ? $request_data['module'] : null;
     $this->page = empty($request_data['page']) ? 1 : (int) $request_data['page'];
     $this->category = empty($request_data['category']) ? null : $request_data['category'];
     $this->criteria = array('network_id' => PA::$network_info->network_id);
     $this->categories = PointsEntity::get_cetegories();
     $this->renderer->add_header_css('/' . PA::$theme_rel . '/points_directory.css');
     $this->relType = 'guest';
     if (!empty($request_data['fid']) || !empty($request_data['gid'])) {
         if (!empty($request_data['fid'])) {
             $this->criteria['family_id'] = $request_data['fid'];
         } else {
             if (!empty($request_data['gid'])) {
                 $this->criteria['family_id'] = $request_data['gid'];
             }
         }
         $this->fid = !empty($this->criteria['family_id']) ? $this->criteria['family_id'] : null;
         list($relType, $relLabel) = TypedGroupEntityRelation::get_relation_to_group(PA::$login_uid, (int) $this->fid);
         if (empty($relType)) {
             $relType = 'member';
         }
         $this->relType = $relType;
         $this->familly = ContentCollection::load_collection((int) $this->fid, PA::$login_uid);
         $this->fam_members = $this->get_familly_members($this->familly);
         $this->edit_perm = $this->check_edit_perm();
         $this->sub_title = sprintf(__('%s Points'), $this->familly->title . ' Family');
         // this string should be replaced with $family->name
     }
     if (!empty($request_data['uid'])) {
         $this->user_id = $request_data['uid'];
         $this->sub_title = sprintf(__('Points for %s'), PA::$user->display_name);
         $this->criteria['user_id'] = $request_data['uid'];
     }
     if (!empty($this->category)) {
         $this->sub_title = sprintf(__('Search results for \'%s\' Category'), $this->category);
         $this->criteria['category'] = $this->category;
     }
     switch ($this->page_id) {
         case PAGE_FAMILY:
             $this->url_base = PA::$url . PA_ROUTE_FAMILY . "?gid={$this->fid}";
             break;
         case PAGE_FAMILY_DIRECTORY:
             $this->url_base = PA::$url . PA_ROUTE_FAMILY_DIRECTORY;
             break;
         case PAGE_POINTS_DIRECTORY:
             if (isset($this->fid)) {
                 $this->url_base = PA::$url . PA_ROUTE_FAMILY . "?gid={$this->fid}";
             } else {
                 $this->url_base = PA::$url . PA_ROUTE_POINTS_DIRECTORY . "?uid={$this->user_id}";
             }
             break;
     }
     if ($request_method == 'GET') {
         //echo "Action: " . $this->action . "Module: " . $this->module . "clname: " . $this->class_name; die();
         if (!empty($this->action) && $this->module == $this->class_name) {
             switch ($this->action) {
                 case 'newPoints':
                     $this->view_mode = 'new';
                     $this->sub_title = __('Add Points');
                     $this->set_inner_template('edit_points_form.tpl.php');
                     $this->renderer->add_header_css('/' . PA::$theme_rel . '/modal.css');
                     $this->renderer->add_page_js('/' . PA::$theme_rel . '/javascript/forms.js');
                     $this->renderer->add_page_js('/' . PA::$theme_rel . '/javascript/jquery.validate.js');
                     $this->renderer->add_page_js('/' . PA::$theme_rel . '/javascript/attach_media_modal.js');
                     $this->renderer->add_page_js('/' . PA::$theme_rel . '/javascript/points_directory.js');
                     break;
                 case 'editPoints':
                     $this->view_mode = 'edit';
                     $this->sub_title = __('Edit Points');
                     $this->set_inner_template('edit_points_form.tpl.php');
                     $this->renderer->add_header_css('/' . PA::$theme_rel . '/modal.css');
                     $this->renderer->add_page_js('/' . PA::$theme_rel . '/javascript/forms.js');
                     $this->renderer->add_page_js('/' . PA::$theme_rel . '/javascript/jquery.validate.js');
                     $this->renderer->add_page_js('/' . PA::$theme_rel . '/javascript/attach_media_modal.js');
                     $this->renderer->add_page_js('/' . PA::$theme_rel . '/javascript/points_directory.js');
                     break;
                 case 'deletePoints':
                     $this->view_mode = 'list';
                     break;
                 default:
             }
         } else {
             $this->view_mode = 'list';
             $this->set_inner_template('center_inner_public.tpl.php');
             $this->showPointsDirectory($request_data);
         }
     }
 }
 private function handleGET_delete($request_data)
 {
     global $error_msg;
     if (PA::$login_uid && !empty($this->shared_data['group_info']) && @$_POST['content_type'] != 'media') {
         $group = $this->shared_data['group_info'];
         $user = PA::$login_user;
         if (Group::is_admin((int) $request_data['gid'], (int) PA::$login_uid)) {
             $group->delete();
             // Deleting all the activities of this group from activities table for rivers of people module
             Activities::delete_for_group($request_data['gid']);
             if (!empty(PA::$config->useTypedGroups)) {
                 require_once 'api/Entity/TypedGroupEntity.php';
                 require_once "api/Entity/TypedGroupEntityRelation.php";
                 TypedGroupEntityRelation::delete_all_relations($request_data['gid']);
                 TypedGroupEntity::delete_for_group($request_data['gid']);
             }
             $this->controller->redirect(PA::$url . PA_ROUTE_GROUPS . "?error_msg=" . __("Group sucessfully deleted."));
         }
     }
 }
 function render()
 {
     if ($this->view_type == 'all') {
         $this->Paging["count"] = Network::get_members(array('network_id' => $this->network_info->network_id, 'cnt' => TRUE));
         $param = array('show' => $this->Paging["show"], 'page' => $this->Paging["page"], 'network_id' => $this->network_info->network_id);
         $users_info = Network::get_members($param);
         $this->links = $users_info['users_data'];
     } else {
         if ($this->view_type == 'relations' || $this->view_type == 'in_relations') {
             $extra = unserialize($this->network_info->extra);
             $this->reciprocated_relationship_set = FALSE;
             $this->relations = FALSE;
             if (@$extra['reciprocated_relationship'] == NET_YES) {
                 $this->reciprocated_relationship_set = TRUE;
                 $this->relations = TRUE;
             }
             $users_info = Relation::get_all_user_relations($this->uid, $no_of_relations = 0, FALSE, $this->Paging["show"], $this->Paging["page"], 'created', 'DESC', 'internal', null, PA::$network_info->network_id);
             $this->Paging["count"] = count($users_info);
             $this->title = __("View all ");
             if ($_SESSION['user']['id'] == $this->uid) {
                 $this->title .= "my";
             } else {
                 $this->title .= $this->page_user . ' \'s';
             }
             $this->title .= " friends";
             $this->sub_title = $this->title;
             $this->links = $users_info;
         }
     }
     if ($this->gid) {
         $group = ContentCollection::load_collection((int) $this->gid, @PA::$login_uid);
         $this->Paging["count"] = $group->get_members(TRUE);
         $members = $group->get_members(FALSE, $this->Paging["show"], $this->Paging["page"]);
         $this->title = sprintf(__("View All %s Members"), __(PA::$group_noun));
         if (is_array($members)) {
             foreach ($members as $member) {
                 // load user info
                 $user = new User();
                 $user->load((int) $member['user_id']);
                 $u = array('user_id' => $user->user_id, 'user_id' => $user->user_id, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'display_name' => $user->display_name, 'email' => $user->email, 'picture' => $user->picture, 'login_name' => $user->login_name, 'created' => $user->created);
                 if (!empty(PA::$config->useTypedGroups)) {
                     require_once 'api/Entity/TypedGroupEntityRelation.php';
                     // see if we have a special relation of this user to the group
                     list($relType, $u['membertype']) = TypedGroupEntityRelation::get_relation_to_group($member['user_id'], (int) $this->gid);
                 }
                 $tmp_arr[] = $u;
             }
             $this->links = $tmp_arr;
         }
     }
     $this->inner_HTML = $this->generate_inner_html();
     $content = parent::render();
     return $content;
 }
 function initializeModule($request_method, $request_data)
 {
     if (empty($this->shared_data['group_info'])) {
         return 'skip';
     }
     $this->gid = $this->shared_data['group_info']->collection_id;
     if (empty(PA::$config->useTypedGroups)) {
         return 'skip';
     }
     $this->shared_data['member_type'] = $member_type = Group::get_user_type(PA::$login_uid, (int) $this->gid);
     $this->is_member = $member_type == MEMBER ? TRUE : FALSE;
     if ($member_type == OWNER) {
         $this->is_member = TRUE;
         $this->is_admin = TRUE;
     }
     $acl = new Access();
     // check for moderation of group permissions
     $gp_access = $acl->acl_check('action', 'edit', 'users', $member_type, 'group', 'all');
     if (PA::$login_uid == SUPER_USER_ID || $member_type == 'moderator') {
         $gp_access = 1;
     }
     $this->is_admin = $this->shared_data['moderation_permissions'] = $gp_access;
     $this->group_details = $this->shared_data['group_info'];
     if (!$this->is_member) {
         if ((!empty($this->group_details) ? $this->group_details->reg_type : NULL) && $this->group_details->reg_type == REG_MODERATED) {
             $this->join_this_group_string = __('Request to follow this organization as');
         } else {
             $this->join_this_group_string = __('Follow This Org As');
         }
     } else {
         // get the relationType for this user
         list($relType, $relLabel) = TypedGroupEntityRelation::get_relation_to_group(PA::$login_uid, (int) $this->gid);
         if (empty($relType)) {
             $relType = 'member';
             $relLabel = __('Member');
         }
         $this->relationType = $relType;
         $this->relationTypeString = sprintf(__("You are a %s"), $relLabel);
     }
     $this->availTypes = TypedGroupEntity::get_avail_types();
     $this->selectTypes = array();
     foreach ($this->availTypes as $k => $l) {
         $this->selectTypes[] = array('label' => $l, 'value' => $k);
     }
     // Do we already have a bound Entity?
     // we need to load the generic parent class, as we do noot yet know the type
     if ($typedEntity = TypedGroupEntity::load_for_group($this->gid)) {
         $this->entity = $typedEntity;
         // get info about what profile fields this has
         $type = $this->entity->entity_type;
         $classname = ucfirst($type) . "TypedGroupEntity";
         @(include_once "api/Entity/{$classname}.php");
         if (class_exists($classname)) {
             $instance = new $classname();
         } else {
             // just get default
             $instance = new TypedGroupEntity();
         }
         $this->profilefields = $instance->get_profile_fields();
         $this->availRelations = $instance->get_avail_relations();
         $this->selectRelations = array();
         foreach ($this->availRelations as $k => $l) {
             $this->selectRelations[] = array('label' => $l, 'value' => $k);
         }
         // does the admin want to edit it?
         if ($this->shared_data['moderation_permissions'] && !empty($request_data['edit_enityprofile'])) {
             //$this->title = sprintf(__("Edit %s profile"), $typedEntity->attributes['name']['value']);
             $this->inner_template = PA::$blockmodule_path . '/' . get_class($this) . "/edit_typedgroup_profile.tpl.php";
             // load into form
             $this->dynFields = new DynamicFormFields($this->entity->attributes);
         } else {
             // display only
             //$this->title = sprintf(__("%s profile"), $typedEntity->attributes['name']['value']);
             $this->inner_template = PA::$blockmodule_path . '/' . get_class($this) . "/typedgroup_profile.tpl.php";
         }
         $this->title = '';
     } else {
         return 'skip';
         /*
         // moderators only
         if(!$this->shared_data['moderation_permissions']) {
         	return 'skip';
         }
         */
     }
     switch ($this->column) {
         case 'middle':
             break;
         case 'left':
         case 'right':
         default:
             break;
     }
 }
 /** !!
  * Iterates over $this->profilefields, doing some data parsing
  *  and then saves it back.
  *
  * @param array $request_data POST/GET data of changed information.
  */
 private function handleEntity($request_data)
 {
     $this->err = '';
     // $data = $this->filter($request_data);
     $data = array();
     // use the profile_fields object for some processing
     foreach ($this->profilefields as $i => $d) {
         $k = $d['name'];
         switch ($d['type']) {
             case 'dateselect':
                 $day = @$request_data[$k . '_day'];
                 $month = @$request_data[$k . '_month'];
                 $year = @$request_data[$k . '_year'];
                 if ($day && $month && $year) {
                     $data[$k . '_day'] = $day;
                     $data[$k . '_month'] = $month;
                     $data[$k . '_year'] = $year;
                     $data[$k] = sprintf("%04d-%02d-%02d", $year, $month, $day);
                 }
                 break;
             default:
                 if (!empty($request_data[$k])) {
                     $data[$k] = $request_data[$k];
                 }
                 break;
         }
     }
     $data['type'] = 'family';
     $data['name'] = $request_data['groupname'];
     $data['group_id'] = $this->gid;
     if (empty($data['name'])) {
         $this->err .= __("Please supply a name.") . "<br/>";
     }
     if (empty($this->err)) {
         // sync it
         FamilyTypedGroupEntity::sync($data);
         if (empty($request_data['gid'])) {
             // also add the creator of this family as a parent!
             require_once "api/Entity/TypedGroupEntityRelation.php";
             try {
                 TypedGroupEntityRelation::set_relation(PA::$login_uid, $this->gid, 'parent');
             } catch (PAException $e) {
                 $error_msg = $e->getMessage();
             }
         }
     }
 }
 /**
     Get data for moderation option ie group moderation
    **/
 private function get_links()
 {
     $this->Paging["querystring"] = "view=members&gid={$this->set_id}";
     $this->Paging["count"] = $this->family->get_members($cnt = TRUE, '', '', '', '', FALSE);
     $members = $this->family->get_members($cnt = FALSE, $this->Paging["show"], $this->Paging["page"], '', '', FALSE);
     $User = new User();
     foreach ($members as $membersDetails) {
         if ($membersDetails["user_type"] != 'owner') {
             $User->load((int) $membersDetails["user_id"]);
             // get the relationType for this user
             list($relType, $relLabel) = TypedGroupEntityRelation::get_relation_to_group((int) $membersDetails["user_id"], (int) $this->set_id);
             if (empty($relType)) {
                 $relType = 'member';
                 $relLabel = __('Member');
             }
             $this->members_data[] = array('user_id' => $membersDetails["user_id"], 'first_name' => $User->first_name, 'last_name' => $User->last_name, 'email' => $User->email, 'created' => $membersDetails['join_date'], 'picture' => $User->picture, 'user_type' => $membersDetails["user_type"], 'login_name' => $User->login_name, 'relType' => $relType);
         }
     }
     //    echo "<pre>".print_r($this->members_data,1)."</pre>";
     return;
 }