From 1d527097e116d130fdeb58871f040e6a30449ef2 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 7 Jan 2011 02:50:45 +0000 Subject: cleaned up the group profile git-svn-id: http://code.elgg.org/elgg/trunk@7853 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/groups/groupprofile.php | 97 +++++++-------- .../views/default/groups/activity_latest.php | 35 ------ .../views/default/groups/closedmembership.php | 16 --- mod/groups/views/default/groups/forum_latest.php | 34 ------ mod/groups/views/default/groups/groupprofile.php | 135 --------------------- mod/groups/views/default/groups/members.php | 18 --- .../default/groups/profile/activity_widget.php | 35 ++++++ .../views/default/groups/profile/buttons.php | 53 ++++++++ .../default/groups/profile/closed_membership.php | 16 +++ .../views/default/groups/profile/forum_widget.php | 51 ++++++++ .../views/default/groups/profile/profile_block.php | 82 +++++++++++++ .../views/default/groups/profile/widgets.php | 30 +++++ mod/groups/views/default/groups/profileitems.php | 30 ----- .../views/default/groups/sidebar/members.php | 18 +++ 14 files changed, 327 insertions(+), 323 deletions(-) delete mode 100644 mod/groups/views/default/groups/activity_latest.php delete mode 100644 mod/groups/views/default/groups/closedmembership.php delete mode 100644 mod/groups/views/default/groups/forum_latest.php delete mode 100644 mod/groups/views/default/groups/groupprofile.php delete mode 100644 mod/groups/views/default/groups/members.php create mode 100644 mod/groups/views/default/groups/profile/activity_widget.php create mode 100644 mod/groups/views/default/groups/profile/buttons.php create mode 100644 mod/groups/views/default/groups/profile/closed_membership.php create mode 100644 mod/groups/views/default/groups/profile/forum_widget.php create mode 100644 mod/groups/views/default/groups/profile/profile_block.php create mode 100644 mod/groups/views/default/groups/profile/widgets.php delete mode 100644 mod/groups/views/default/groups/profileitems.php create mode 100644 mod/groups/views/default/groups/sidebar/members.php (limited to 'mod/groups') diff --git a/mod/groups/groupprofile.php b/mod/groups/groupprofile.php index 43473e261..1c35163ad 100644 --- a/mod/groups/groupprofile.php +++ b/mod/groups/groupprofile.php @@ -1,56 +1,43 @@ name; - - // Hide some items from closed groups when the user is not logged in. - $view_all = true; - - $groupaccess = group_gatekeeper(false); - if (!$groupaccess) - $view_all = false; - - $area2 .= elgg_view_entity($group, TRUE); - - if ($view_all) { - //group profile 'items' - these are not real widgets, just contents to display - $area2 .= elgg_view('groups/profileitems',array('entity' => $group)); - - //group members - $area3 = elgg_view('groups/members',array('entity' => $group)); - } else { - $area2 .= elgg_view('groups/closedmembership', array('entity' => $group, 'user' => get_loggedin_user(), 'full' => true)); - } - - $content = $area1 . $area2; - $params = array( - 'content' => $content, - 'sidebar' => $area3 - ); - $body = elgg_view_layout('one_column_with_sidebar', $params); - } else { - $title = elgg_echo('groups:notfound'); - - $area2 = elgg_view_title($title); - $area2 .= "

".elgg_echo('groups:notfound:details')."

"; - - $body = elgg_view_layout('one_column_with_sidebar', array('content' => $area2)); - } - - // Finally draw the page - echo elgg_view_page($title, $body); -?> \ No newline at end of file +/** + * Profile of a group + * + * @package ElggGroups + */ + +$guid = get_input('group_guid'); +elgg_set_context('groups'); + +elgg_set_page_owner_guid($guid); + +// can the user see all content +$group_access = group_gatekeeper(false); + +// turn this into a core function +global $autofeed; +$autofeed = true; + +$group = get_entity($guid); + +elgg_push_breadcrumb(elgg_echo('groups:all'), elgg_get_site_url() . "pg/groups/world"); +elgg_push_breadcrumb($group->name); + +$sidebar = ''; +$content = elgg_view('groups/profile/profile_block', array('entity' => $group)); +if (group_gatekeeper(false)) { + $content .= elgg_view('groups/profile/widgets', array('entity' => $group)); + $sidebar = elgg_view('groups/sidebar/members', array('entity' => $group)); +} else { + $content .= elgg_view('groups/profile/closed_membership'); +} + +$params = array( + 'content' => $content, + 'sidebar' => $sidebar, + 'title' => $group->name, + 'buttons' => elgg_view('groups/profile/buttons', array('entity' => $group)), + 'filter' => '', +); +$body = elgg_view_layout('content', $params); + +echo elgg_view_page($title, $body); diff --git a/mod/groups/views/default/groups/activity_latest.php b/mod/groups/views/default/groups/activity_latest.php deleted file mode 100644 index 3ac385553..000000000 --- a/mod/groups/views/default/groups/activity_latest.php +++ /dev/null @@ -1,35 +0,0 @@ - -"> -

-guid; - $limit = 5; - - $offset = (int) get_input('offset', 0); - - // Sanitise variables -- future proof in case they get sourced elsewhere - $limit = (int) $limit; - $offset = (int) $offset; - $group_guid = (int) $group_guid; - - $sql = "SELECT {$CONFIG->dbprefix}river.id, {$CONFIG->dbprefix}river.type, {$CONFIG->dbprefix}river.subtype, {$CONFIG->dbprefix}river.action_type, {$CONFIG->dbprefix}river.access_id, {$CONFIG->dbprefix}river.view, {$CONFIG->dbprefix}river.subject_guid, {$CONFIG->dbprefix}river.object_guid, {$CONFIG->dbprefix}river.posted FROM {$CONFIG->dbprefix}river INNER JOIN {$CONFIG->dbprefix}entities AS entities1 ON {$CONFIG->dbprefix}river.object_guid = entities1.guid INNER JOIN {$CONFIG->dbprefix}entities AS entities2 ON entities1.container_guid = entities2.guid WHERE entities2.guid = $group_guid OR {$CONFIG->dbprefix}river.object_guid = $group_guid ORDER BY posted DESC limit {$offset},{$limit}"; - - $items = get_data($sql); - - if (count($items) > 0) { - $river_items = elgg_view('river/item/list',array( - 'limit' => $limit, - 'offset' => $offset, - 'items' => $items - )); - } - echo $river_items; - -?> diff --git a/mod/groups/views/default/groups/closedmembership.php b/mod/groups/views/default/groups/closedmembership.php deleted file mode 100644 index d5abe1e09..000000000 --- a/mod/groups/views/default/groups/closedmembership.php +++ /dev/null @@ -1,16 +0,0 @@ - -

- -

diff --git a/mod/groups/views/default/groups/forum_latest.php b/mod/groups/views/default/groups/forum_latest.php deleted file mode 100644 index 9b6f292e0..000000000 --- a/mod/groups/views/default/groups/forum_latest.php +++ /dev/null @@ -1,34 +0,0 @@ -forum_enable != 'no'){ -?> -"> -

- 'object', 'subtypes' => 'groupforumtopic', 'container_guid' => $vars['entity']->guid, 'limit' => 6)); - - if($forum){ - foreach($forum as $f){ - - $count_annotations = $f->countAnnotations("generic_comment"); - - echo "
"; - echo "
" . elgg_view('profile/icon',array('entity' => $f->getOwnerEntity(), 'size' => 'tiny')) . "
"; - echo "

guid}&group_guid={$vars['entity']->guid}\">" . $f->title . "

"; - echo "

".elgg_echo('comments').": " . $count_annotations . "

"; - echo "
"; - } - } else { - if(elgg_get_page_owner()->isMember(get_loggedin_user())){ - $create_discussion = elgg_get_site_url() . "mod/groups/addtopic.php?group_guid=" . elgg_get_page_owner_guid(); - echo "

".elgg_echo("groups:addtopic")."

"; - }else{ - echo "

". elgg_echo("grouptopic:notcreated") . "

"; - } - } - -}//end of forum active check \ No newline at end of file diff --git a/mod/groups/views/default/groups/groupprofile.php b/mod/groups/views/default/groups/groupprofile.php deleted file mode 100644 index a21985bea..000000000 --- a/mod/groups/views/default/groups/groupprofile.php +++ /dev/null @@ -1,135 +0,0 @@ - label -$actions = array(); - -if ($vars['entity']->canEdit()) { - // breadcrumb trail - elgg_push_breadcrumb(elgg_echo('groups:yours'), elgg_get_site_url()."pg/groups/member/{$user->username}"); - - // edit and invite - $url = elgg_get_site_url() . "mod/groups/edit.php?group_guid={$vars['entity']->getGUID()}"; - $actions[$url] = elgg_echo('groups:edit'); - $url = elgg_get_site_url() . "mod/groups/invite.php?group_guid={$vars['entity']->getGUID()}"; - $actions[$url] = elgg_echo('groups:invite'); -} - -if ($vars['entity']->isMember($user)) { - // breadcrumb trail - elgg_push_breadcrumb(elgg_echo('groups:yours'), elgg_get_site_url()."pg/groups/member/{$user->username}"); - - // leave - $url = elgg_get_site_url() . "action/groups/leave?group_guid={$vars['entity']->getGUID()}"; - $url = elgg_add_action_tokens_to_url($url); - $actions[$url] = elgg_echo('groups:leave'); -} else { - // join - // admins can always join. - if ($vars['entity']->isPublicMembership() || $vars['entity']->canEdit()) { - $url = elgg_get_site_url() . "action/groups/join?group_guid={$vars['entity']->getGUID()}"; - $url = elgg_add_action_tokens_to_url($url); - $actions[$url] = elgg_echo('groups:join'); - } else { - // request membership - $url = elgg_get_site_url() . "action/groups/joinrequest?group_guid={$vars['entity']->getGUID()}"; - $url = elgg_add_action_tokens_to_url($url); - $actions[$url] = elgg_echo('groups:joinrequest'); - } -} - - -// build action buttons -$action_buttons = ''; -if (!empty($actions)) { - $action_buttons = '
'; - foreach ($actions as $url => $action) { - $action_buttons .= "$action"; - } - $action_buttons .= '
'; -} - -// display breadcrumb -elgg_push_breadcrumb($vars['entity']->name); -echo elgg_view('navigation/breadcrumbs'); - -// build and display header -echo <<<__HTML -
-
-

{$vars['entity']->name}

-
- $action_buttons -
-__HTML; - -?> -
-
-
- $vars['entity'], - 'size' => 'large', - )); - ?> -
- -
- " . elgg_echo("groups:owner") . ": owner_guid)->getURL() . "\">" . get_user($vars['entity']->owner_guid)->name . "

"; - ?> -

getMembers(0, 0, TRUE); - echo elgg_echo('groups:members') . ": " . $count; - - ?>

-
-
- -
- group) && sizeof($vars['config']->group) > 0){ - - foreach($vars['config']->group as $shortname => $valtype) { - if ($shortname != "name") { - $value = $vars['entity']->$shortname; - - if (!empty($value)) { - //This function controls the alternating class - $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; - } - - echo "

"; - echo ""; - echo elgg_echo("groups:{$shortname}"); - echo ": "; - - $options = array( - 'value' => $vars['entity']->$shortname - ); - - if ($valtype == 'tags') { - $options['tag_names'] = $shortname; - } - - echo elgg_view("output/{$valtype}", $options); - - echo "

"; - } - } - } - } - ?> -
-
diff --git a/mod/groups/views/default/groups/members.php b/mod/groups/views/default/groups/members.php deleted file mode 100644 index b4e9199af..000000000 --- a/mod/groups/views/default/groups/members.php +++ /dev/null @@ -1,18 +0,0 @@ -getMembers(10); -foreach ($members as $mem) { - $body .= "
getURL() . "\">" . elgg_view("profile/icon", array('entity' => $mem, 'size' => 'tiny', 'override' => 'true')) . "
"; -} - -echo elgg_view('layout/objects/module', array( - 'title' => elgg_echo("groups:members"), - 'body' => $body, - 'class' => 'elgg-aside-module', -)); diff --git a/mod/groups/views/default/groups/profile/activity_widget.php b/mod/groups/views/default/groups/profile/activity_widget.php new file mode 100644 index 000000000..3ac385553 --- /dev/null +++ b/mod/groups/views/default/groups/profile/activity_widget.php @@ -0,0 +1,35 @@ + +"> +

+guid; + $limit = 5; + + $offset = (int) get_input('offset', 0); + + // Sanitise variables -- future proof in case they get sourced elsewhere + $limit = (int) $limit; + $offset = (int) $offset; + $group_guid = (int) $group_guid; + + $sql = "SELECT {$CONFIG->dbprefix}river.id, {$CONFIG->dbprefix}river.type, {$CONFIG->dbprefix}river.subtype, {$CONFIG->dbprefix}river.action_type, {$CONFIG->dbprefix}river.access_id, {$CONFIG->dbprefix}river.view, {$CONFIG->dbprefix}river.subject_guid, {$CONFIG->dbprefix}river.object_guid, {$CONFIG->dbprefix}river.posted FROM {$CONFIG->dbprefix}river INNER JOIN {$CONFIG->dbprefix}entities AS entities1 ON {$CONFIG->dbprefix}river.object_guid = entities1.guid INNER JOIN {$CONFIG->dbprefix}entities AS entities2 ON entities1.container_guid = entities2.guid WHERE entities2.guid = $group_guid OR {$CONFIG->dbprefix}river.object_guid = $group_guid ORDER BY posted DESC limit {$offset},{$limit}"; + + $items = get_data($sql); + + if (count($items) > 0) { + $river_items = elgg_view('river/item/list',array( + 'limit' => $limit, + 'offset' => $offset, + 'items' => $items + )); + } + echo $river_items; + +?> diff --git a/mod/groups/views/default/groups/profile/buttons.php b/mod/groups/views/default/groups/profile/buttons.php new file mode 100644 index 000000000..68cd2591a --- /dev/null +++ b/mod/groups/views/default/groups/profile/buttons.php @@ -0,0 +1,53 @@ +canEdit()) { + // edit and invite + $url = elgg_get_site_url() . "mod/groups/edit.php?group_guid={$vars['entity']->getGUID()}"; + $actions[$url] = elgg_echo('groups:edit'); + $url = elgg_get_site_url() . "mod/groups/invite.php?group_guid={$vars['entity']->getGUID()}"; + $actions[$url] = elgg_echo('groups:invite'); +} + +// group members +if ($vars['entity']->isMember($user)) { + // leave + $url = elgg_get_site_url() . "action/groups/leave?group_guid={$vars['entity']->getGUID()}"; + $url = elgg_add_action_tokens_to_url($url); + $actions[$url] = elgg_echo('groups:leave'); +} else { + // join - admins can always join. + if ($vars['entity']->isPublicMembership() || $vars['entity']->canEdit()) { + $url = elgg_get_site_url() . "action/groups/join?group_guid={$vars['entity']->getGUID()}"; + $url = elgg_add_action_tokens_to_url($url); + $actions[$url] = elgg_echo('groups:join'); + } else { + // request membership + $url = elgg_get_site_url() . "action/groups/joinrequest?group_guid={$vars['entity']->getGUID()}"; + $url = elgg_add_action_tokens_to_url($url); + $actions[$url] = elgg_echo('groups:joinrequest'); + } +} + +// display action buttons +if ($actions) { + foreach ($actions as $url => $action) { + echo elgg_view('output/url', array( + 'text' => $action, + 'href' => $url, + 'class' => 'elgg-action-button', + )); + } +} diff --git a/mod/groups/views/default/groups/profile/closed_membership.php b/mod/groups/views/default/groups/profile/closed_membership.php new file mode 100644 index 000000000..f80103711 --- /dev/null +++ b/mod/groups/views/default/groups/profile/closed_membership.php @@ -0,0 +1,16 @@ + +

+ +

diff --git a/mod/groups/views/default/groups/profile/forum_widget.php b/mod/groups/views/default/groups/profile/forum_widget.php new file mode 100644 index 000000000..265926fb5 --- /dev/null +++ b/mod/groups/views/default/groups/profile/forum_widget.php @@ -0,0 +1,51 @@ +forum_enable == 'no') { + return true; +} + +$group = $vars['entity']; + + +$all_link = elgg_view('output/url', array( + 'href' => "pg/groups/forum/$group->guid", + 'text' => elgg_echo('link:view:all'), +)); + +$header = "$all_link"; +$header .= '

' . elgg_echo('groups:latestdiscussion') . '

'; + + +elgg_push_context('widgets'); +$options = array( + 'type' => 'object', + 'subtype' => 'groupforumtopic', + 'container_guid' => $group->getGUID(), + 'limit' => 6, + 'full_view' => false, + 'pagination' => false, +); +$content = elgg_list_entities($options); +elgg_pop_context(); + +if (!$content) { + $content = '

' . elgg_echo('grouptopic:notcreated') . '

'; +} + +$new_link = elgg_view('output/url', array( + 'href' => "mod/groups/addtopic.php?group_guid=" . $group->getGUID(), + 'text' => elgg_echo('groups:addtopic'), +)); +$content .= "$new_link"; + + +$params = array( + 'header' => $header, + 'body' => $content, +); +echo elgg_view('layout/objects/module', $params); diff --git a/mod/groups/views/default/groups/profile/profile_block.php b/mod/groups/views/default/groups/profile/profile_block.php new file mode 100644 index 000000000..98595ad07 --- /dev/null +++ b/mod/groups/views/default/groups/profile/profile_block.php @@ -0,0 +1,82 @@ +getOwnerEntity(); + +$profile_fields = elgg_get_config('group'); + +?> +
+
+
+ $group, + 'size' => 'large', + )); + ?> +
+
+

+ : + $owner->name, + 'value' => $owner->getURL(), + )); + ?> +

+

+ getMembers(0, 0, TRUE); + ?> +

+
+
+ +
+ 0) { + + $even_odd = 'odd'; + foreach ($profile_fields as $key => $valtype) { + // do not show the name + if ($key == 'name') { + continue; + } + + $value = $group->$key; + if (empty($value)) { + continue; + } + + $options = array('value' => $group->$key); + if ($valtype == 'tags') { + $options['tag_names'] = $key; + } + + echo "

"; + echo ""; + echo elgg_echo("groups:$key"); + echo ": "; + echo elgg_view("output/$valtype", $options); + echo "

"; + + $even_odd = ($even_odd == 'even') ? 'odd' : 'even'; + } +} +?> +
+
diff --git a/mod/groups/views/default/groups/profile/widgets.php b/mod/groups/views/default/groups/profile/widgets.php new file mode 100644 index 000000000..af558c90d --- /dev/null +++ b/mod/groups/views/default/groups/profile/widgets.php @@ -0,0 +1,30 @@ +"; + + // activity latest + echo "
"; + echo elgg_view("groups/profile/activity_widget", array('entity' => $vars['entity'])); + echo "
"; + + // forum latest + //echo "
"; + echo elgg_view("groups/profile/forum_widget", array('entity' => $vars['entity'])); + //echo "
"; + + // enable tools to extend this area + echo elgg_view("groups/tool_latest", array('entity' => $vars['entity'])); + +echo ""; +?> + diff --git a/mod/groups/views/default/groups/profileitems.php b/mod/groups/views/default/groups/profileitems.php deleted file mode 100644 index 6f5fa32ce..000000000 --- a/mod/groups/views/default/groups/profileitems.php +++ /dev/null @@ -1,30 +0,0 @@ -"; - - // activity latest - echo "
"; - echo elgg_view("groups/activity_latest",array('entity' => $vars['entity'])); - echo "
"; - - // forum latest - echo "
"; - echo elgg_view("groups/forum_latest",array('entity' => $vars['entity'])); - echo "
"; - - // enable tools to extend this area - echo elgg_view("groups/tool_latest",array('entity' => $vars['entity'])); - -echo ""; -?> - diff --git a/mod/groups/views/default/groups/sidebar/members.php b/mod/groups/views/default/groups/sidebar/members.php new file mode 100644 index 000000000..b4e9199af --- /dev/null +++ b/mod/groups/views/default/groups/sidebar/members.php @@ -0,0 +1,18 @@ +getMembers(10); +foreach ($members as $mem) { + $body .= "
getURL() . "\">" . elgg_view("profile/icon", array('entity' => $mem, 'size' => 'tiny', 'override' => 'true')) . "
"; +} + +echo elgg_view('layout/objects/module', array( + 'title' => elgg_echo("groups:members"), + 'body' => $body, + 'class' => 'elgg-aside-module', +)); -- cgit v1.2.3