/** !! * This is the function responsible for setting up the data to be displayed * in the form. If this is a new group, it gives it a title and nothing * else. If it is a group that is being modified, then it loads the old * data and displays it. When the form has been submitted, it fills in * the form with the data from $global_form_data * @param string $error_message The error from the submit. * @param array $request_data Used to determine what is being created. */ function load_data($error_msg = '', $request_data = NULL) { global $global_form_data; $array_tmp = array(); $this->categories = Category::build_root_list(); if (is_array($this->categories)) { foreach ($this->categories as $category) { $array_tmp[] = array('category_id' => $category->category_id, 'name' => $category->name); } $this->categories = $array_tmp; } if (!empty($error_msg)) { $this->error_msg = $error_msg; } if ($this->id == 0) { $this->title = __('Create Group'); } else { $this->title = __('Change Group Settings'); $group = ContentCollection::load_collection((int) $this->id, PA::$login_uid); $group_tags = Tag::load_tags_for_content_collection((int) $this->id); $this->collection_id = (int) $this->id; $this->groupname = stripslashes($group->title); $this->body = stripslashes($group->description); $this->access = $group->access_type; $this->reg_type = $group->reg_type; $this->is_moderated = $group->is_moderated; $this->group_category = $group->category_id; $this->display_header_image = $group->display_header_image; $this->group_type = $group->group_type; $this->tag_entry = NULL; if (count($group_tags)) { foreach ($group_tags as $tag) { $out[] = $tag['name']; } $this->tag_entry = implode(', ', $out); } if ($group->picture) { $this->group_photo = $group->picture; $this->upfile = $group->picture; } if ($group->header_image) { $this->header_image = $group->header_image; $this->upfile = $group->picture; $this->header_image_action = $group->header_image_action; } } // end else (existing group) if (!empty($global_form_data['addgroup'])) { $this->collection_id = (int) $this->id; $this->groupname = $global_form_data['groupname']; $this->body = $global_form_data['groupdesc']; $this->access = @$global_form_data['groupaccess']; $this->reg_type = $global_form_data['reg_type']; $this->is_moderated = @$global_form_data['is_mod']; $this->group_category = $global_form_data['group_category']; $this->tag_entry = $global_form_data['group_tags']; $this->display_header_image = @$global_form_data['display_header_image']; $this->group_type = @$global_form_data['group_type']; } $this->tag_entry = str_replace('"', '"', @$this->tag_entry); if (!empty(PA::$config->useTypedGroups)) { require_once 'web/includes/classes/CNDynamicFormFields.php'; $this->gid = $this->id; $this->availTypes = TypedGroupEntity::get_avail_types(); $this->selectTypes = array(); foreach ($this->availTypes as $k => $l) { $this->selectTypes[] = array('label' => $l, 'value' => $k); } $this->entity = NULL; $type = ''; $params = array(); if (!empty($request_data['entityType'])) { $type = $request_data['entityType']; } if (!empty($request_data['type'])) { $type = $request_data['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; $this->entity = $typedEntity; $params = $this->entity->attributes; } else { if (!empty($type) && !empty($this->availTypes[$type])) { $params['type'] = $type; } } $this->dynFields = new CNDynamicFormFields($params); $classname = ucfirst($type) . "TypedGroupEntity"; include_once "api/CNEntity/CN{$classname}.php"; if (class_exists($classname)) { $instance = new $classname(); } else { // just get default $instance = new TypedGroupEntity(); } $this->profilefields = $instance->get_profile_fields(); } return; }
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; } }
/** !! * Loads and initializes teh data if the user is in a group or not. */ function load_data($error_msg = '', $request_data = NULL) { global $global_form_data; $array_tmp = array(); if ($this->id > 0) { $this->title = __('Change Family Settings'); $group = ContentCollection::load_collection((int) $this->id, PA::$login_uid); $group_tags = Tag::load_tags_for_content_collection((int) $this->id); $this->collection_id = (int) $this->id; $this->groupname = stripslashes($group->title); $this->body = stripslashes($group->description); $this->access = $group->access_type; $this->reg_type = $group->reg_type; $this->is_moderated = $group->is_moderated; $this->group_category = $group->category_id; $this->display_header_image = $group->display_header_image; $this->group_type = $group->group_type; $this->tag_entry = NULL; if (count($group_tags)) { foreach ($group_tags as $tag) { $out[] = $tag['name']; } $this->tag_entry = implode(', ', $out); } if ($group->picture) { $this->group_photo = $group->picture; $this->upfile = $group->picture; } if ($group->header_image) { $this->header_image = $group->header_image; // $this->upfile = $group->picture; $this->header_image_action = $group->header_image_action; } } // end (existing group) if (!empty($global_form_data['addgroup'])) { $this->collection_id = (int) $this->id; $this->groupname = $global_form_data['groupname']; $this->body = $global_form_data['groupdesc']; $this->access = @$global_form_data['groupaccess']; $this->reg_type = $global_form_data['reg_type']; $this->is_moderated = @$global_form_data['is_mod']; $this->group_category = $global_form_data['group_category']; $this->tag_entry = $global_form_data['group_tags']; $this->display_header_image = @$global_form_data['display_header_image']; $this->group_type = @$global_form_data['group_type']; } $this->tag_entry = str_replace('"', '"', @$this->tag_entry); $this->gid = $this->id; $this->availTypes = TypedGroupEntity::get_avail_types(); $this->selectTypes = array(); foreach ($this->availTypes as $k => $l) { $this->selectTypes[] = array('label' => $l, 'value' => $k); } $this->entity = NULL; $type = 'family'; $params = array(); if ($typedEntity = TypedGroupEntity::load_for_group($this->gid)) { $this->entity = $typedEntity; // get info about what profile fields this has $type = $this->entity->entity_type; $this->entity = $typedEntity; $params = $this->entity->attributes; } $this->dynFields = new DynamicFormFields($params); $classname = ucfirst($type) . "TypedGroupEntity"; $instance = new $classname(); $this->profilefields = $instance->get_profile_fields(); return; }