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); }
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.")); } } }
/** !! * This takes the data from the form and checks it * for the purposes of creating an entity, then * syncs the data to the entity. * @param $request_data The data to be added to the entity */ 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'] = !empty($this->entity_type) ? $this->entity_type : $request_data['type']; $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 TypedGroupEntity::sync($data); } }
private function handleEdit($request_data) { $this->err = ''; $data = $this->filter($request_data); // handle photo upload if (!empty($_FILES)) { foreach ($_FILES as $field_name => $file_info) { if (!empty($file_info['name'])) { $uploadfile = PA::$upload_path . basename($_FILES[$field_name]['name']); $myUploadobj = new FileUploader(); $file = $myUploadobj->upload_file(PA::$upload_path, $field_name, true, true, 'image'); if ($file == false) { $msg = $myUploadobj->error; $this->err .= sprintf(__('Please upload a valid Game Image in %s'), ucfirst($field_name)) . "<br/>"; continue; } else { Storage::link($file, array("role" => "game_image", "user" => PA::$login_user->user_id)); $data[$field_name] = $file; } } else { if (!empty($this->entity->attributes[$field_name])) { $data[$field_name] = $this->entity->attributes[$field_name]; } } } } if (empty($data['name'])) { $this->err .= __("Please supply a name.") . "<br/>"; } if (empty($this->err)) { // sync it TypedGroupEntity::sync($data); } }
/** !! * 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; }
function initializeModule($request_method, $request_data) { if (empty(PA::$config->useTypedGroups)) { return 'skip'; } $this->availTypes = TypedGroupentity::get_avail_types(); $this->directoryType = NULL; $this->groupCount = array(); if (!empty($request_data['type'])) { if (!empty($this->availTypes[$request_data['type']])) { // we have been passed a valid TypedGroupEntity type $this->directoryType = $request_data['type']; } } if ($this->directoryType) { $this->title = sprintf(__("%s directory"), $this->availTypes[$this->directoryType]); $this->inner_template = PA::$blockmodule_path . '/' . get_class($this) . "/cnmodule_directory.php"; $classname = ucfirst($this->directoryType) . "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(); if (!empty($_REQUEST['sort_by'])) { $this->sort_by = $_REQUEST['sort_by']; } else { $this->sort_by = 'name'; } $this->sortFields = array(array('name' => 'name', 'label' => __('Name'))); foreach ($this->profilefields as $i => $field) { if (!empty($field['sort'])) { $this->sortFields[] = array('name' => $field['name'], 'label' => $field['label']); } } // get TypedGroupEntities for this type and build paging etc if (!empty($request_data['page'])) { $this->page = (int) $request_data['page']; } $this->Paging['page'] = $this->page; $this->Paging['show'] = $this->show; $this->groupCount[$this->directoryType] = TypedGroupentity::get_count($this->directoryType); // load list of entities $this->typedGroupEntities = TypedGroupentity::get_entities($this->directoryType, $this->sort_by, $this->page, $this->show); $this->Paging['count'] = $this->groupCount[$this->directoryType]; $CNPagination = new CNPagination(); $CNPagination->setPaging($this->Paging); $this->page_first = $CNPagination->getFirstPage(); $this->page_last = $CNPagination->getLastPage(); $this->page_links = $CNPagination->getPageLinks(); } else { foreach ($this->availTypes as $type => $label) { $this->groupCount[$type] = TypedGroupentity::get_count($type); } } switch ($this->column) { case 'middle': break; case 'left': case 'right': default: break; } }
public static function save_new_org($ccid, $uid, $title, $body, $picture, $group_tags, $group_category, $access = 0, $reg = 0, $is_mod = 0, $header_image = "", $header_image_action = NULL, $display_header_image = NULL, $extra = NULL, $group_type = 'organization') { // save a new group $groupID = self::save_new_group($ccid, $uid, $title, $body, $picture, $group_tags, $group_category, $access, $reg, $is_mod, $header_image, $header_image_action, $display_header_image, $extra); // change it's type to an org TypedGroupEntity::sync(array('type' => $group_type, 'name' => $title, 'group_id' => $groupID)); return $groupID; }