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;
 }
 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);
         }
     }
 }
 function initializeModule($request_method, $request_data)
 {
     if (empty($this->shared_data['group_info'])) {
         return 'skip';
     }
     $this->gid = $this->shared_data['group_info']->collection_id;
     $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 join this family as');
         } else {
             $this->join_this_group_string = __('Join This family 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";
         }
     } 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;
     }
 }
 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;
 }
 /**
     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;
 }