function initializeModule($request_method, $request_data)
 {
     if (!empty($this->shared_data['group_info'])) {
         $this->gid = $this->shared_data['group_info']->collection_id;
         $this->view_type = "all";
         if ($this->shared_data['group_info']->group_type == "typedgroup") {
             PA::$config->useTypedGroups = true;
             require_once 'api/Entity/TypedGroupEntity.php';
             $this->entity = TypedGroupEntity::load_for_group((int) $this->gid);
             $this->entity_type = $this->entity->entity_type;
             PA::$group_noun = $this->entity->entity_type;
             // echo "<pre>".print_r($this->entity, 1)."</pre>";exit;
         }
     }
     $this->network_info = PA::$network_info;
     global $paging;
     $this->Paging["page"] = $paging["page"];
     $this->Paging["show"] = $paging["show"];
     $this->page_user = NULL;
     if (PA::$page_uid && PA::$page_uid != PA::$login_uid) {
         $user = new User();
         $user->load(PA::$page_uid);
         $this->page_user = $user->get_name();
     }
 }
 public static function get_all_entities($sort_by = null, $page = 1, $show = null)
 {
     $result = Entity::search(array('entity_service' => 'typedGroup'), null, '=', $sort_by, $page, $show);
     $entities = array();
     foreach ($result as $i => $entity_result) {
         if ($entity = TypedGroupEntity::load_for_group($entity_result['entity_id'])) {
             $entities[$i] = $entity;
         }
     }
     return $entities;
 }
 public static function get_relation_to_group($uid, $gid)
 {
     // we need more info about the entity
     $entity_info = TypedGroupEntity::load_for_group($gid, false);
     $relation = array('subject_service' => 'internal', 'subject_type' => 'user', 'subject_id' => $uid, 'object_service' => 'typedGroup', 'object_type' => $entity_info['entity_type'], 'object_id' => $gid);
     $match = parent::load_match($relation);
     if (!empty($match[0])) {
         // get info about what profile fields this has
         $type = $match[0]->object_type;
         $classname = ucfirst($type) . "TypedGroupEntity";
         @(include_once "api/Entity/{$classname}.php");
         if (!class_exists($classname)) {
             $classname = "TypedGroupEntity";
         }
         $instance = new $classname();
         $label = !empty($availRelations[$match[0]->relation_type]) ? $availRelations[$match[0]->relation_type] : ucfirst($match[0]->relation_type);
         $availRelations = $instance->get_avail_relations();
         return array($match[0]->relation_type, $label);
     }
     return NULL;
 }
    function render()
    {
        $data = unserialize(ModuleData::get('showcase'));
        $u = $data['featured_user_name'];
        $upage = PA::$url . '/user/' . $u;
        $up = $data['auto_user_picture_url'];
        $g = TypedGroupEntity::load_for_group($data['featured_group_id']);
        $gname = $g->attributes["name"]["value"];
        $gpage = PA::$url . '/group/gid=' . $data['featured_group_id'];
        $gp = $g->attributes["logo"]["value"];
        //PUT VIDEO STUFF HERE
        $b = TypedGroupEntity::load_for_group($data['featured_business_id']);
        $bname = $b->attributes["name"]["value"];
        $bpage = PA::$url . '/group/gid=' . $data['featured_business_id'];
        $bp = $b->attributes["logo"]["value"];
        $table = '<table width="100%%" border="0" cellpadding="0" cellspacing="0" style="background-color:#fff; padding-top:3px; padding-bottom:10px; ">
					  <tr>
						<th colspan="4" align="center" style="background-color:#999; color:#dfe2e3; padding:4px 0 4px 0;" scope="col">Featured Bar</th>
					  </tr>
					  <tr style="color:#000;">
						<td align="center"><b>User</b></td>
						<td align="center"><b>Group</b></td>
						<td align="center"><b>Video</b></td>
						<td align="center"><b>Business</b></td>
					  </tr>
					  <tr>
						<td align="center">%s</td>
						<td align="center">%s</td>
						<td align="center">%s</td>
						<td align="center">%s</td>
					  </tr>
					</table>';
        $user = "******" . $upage . "'>" . uihelper_resize_mk_img($up, 100, 100, 'images/default.png', 'alt=PeopleAggregator') . "</a><h4>" . $data['featured_user_name'] . "</h4>";
        $group = "<a href='" . $gpage . "'>" . uihelper_resize_mk_img($gp, 100, 100, 'images/default.png', 'alt=PeopleAggregator') . "</a><h4>" . $gname . "</h4>";
        $video = "<a href='http://www.people.tdooner.com/'>" . uihelper_resize_mk_img('images/default.png', 100, 100, 'images/default.png', 'alt=PeopleAggregator') . "</a>";
        $business = "<a href='" . $bpage . "'>" . uihelper_resize_mk_img($bp, 100, 100, 'images/default.png', 'alt=PeopleAggregator') . "</a><h4>" . $bname . "</h4>";
        return sprintf($table, $user, $group, $video, $business);
    }
 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;
     }
 }
 /** !!
  * 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('"', '&quot;', @$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;
 }
 /** !!
  * 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('"', '&quot;', @$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;
 }