Skip to content

Commit

Permalink
added: option for group admins to show group widgets to non members in
Browse files Browse the repository at this point in the history
case of a closed group
  • Loading branch information
jeabakker committed Dec 5, 2011
1 parent cdc7e3e commit 1e99e23
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 1 deletion.
28 changes: 28 additions & 0 deletions actions/profile_widgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

gatekeeper();

$group_guid = (int) get_input("group_guid");
$profile_widgets = get_input("profile_widgets", "no");

$forward_url = REFERER;

if(!empty($group_guid) && ($group = get_entity($group_guid))){
if(($group instanceof ElggGroup) && $group->canEdit()){
$group->profile_widgets = $profile_widgets;

if($group->save()){
$forward_url = $group->getURL();

system_message(elgg_echo("group_tools:action:success"));
} else {
register_error(elgg_echo("group_tools:action:error:save"));
}
} else {
register_error(elgg_echo("group_tools:action:error:entity"));
}
} else {
register_error(elgg_echo("group_tools:action:error:input"));
}

forward($forward_url);
7 changes: 7 additions & 0 deletions languages/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@

'group_tools:multiple_admin:group_tool_option' => "Enable group admins to assign other group admins",

// group profile widgets
'group_tools:profile_widgets:title' => "Show group profile widgets to non members",
'group_tools:profile_widgets:description' => "This is a closed group. Default no widgets are shown to non members. Here you can configure if you whish to change that.",
'group_tools:profile_widgets:option' => "Allow non members to view widgets on the group profile page:",

// group kick
'group_tools:group_kick:profile_actions:kick' => "Kick from group",

Expand Down Expand Up @@ -157,6 +162,8 @@
'group_tools:action:error:entities' => "The given GUIDs didn't result in the correct entities",
'group_tools:action:error:entity' => "The given GUID didn't result in a correct entity",
'group_tools:action:error:edit' => "You don't have access to the given entity",
'group_tools:action:error:save' => "There was an error while saving the settings",
'group_tools:action:success' => "The settings where saved successfully",

// admin transfer - action
'group_tools:action:admin_transfer:error:access' => "You're not allowed to transfer ownership of this group",
Expand Down
5 changes: 5 additions & 0 deletions languages/nl.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?php
$language = array (
'group_tools:profile_widgets:title' => 'Toon groep widgets aan niet leden',
'group_tools:profile_widgets:description' => 'Dit is een besloten groep. Standaard worden er geen widgets getoond aan niet leden. Hier kan kan je deze instelling aanpassen',
'group_tools:profile_widgets:option' => 'Mogen niet leden de widgets zien op de groep profiel pagina:',
'group_tools:action:error:save' => 'Er is een fout opgetreden tijdens het opslaan van de instellingen',
'group_tools:action:success' => 'De instellingen zijn succesvol opgeslagen',
'group_tools:groups:sorting:open' => 'Open',
'group_tools:groups:sorting:closed' => 'Besloten',
'widgets:group_river_widget:view:noactivity' => 'Geen activiteit gevonden.',
Expand Down
1 change: 1 addition & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ ToDo
Version History
====================
x.x:
- added: option for group admins to show group widgets to non members in case of a closed group
- changed: activity filter in group river widget (now more advanced)
- changed: group status (open/closed) CSS
Expand Down
7 changes: 6 additions & 1 deletion start.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ function group_tools_init(){
// show group edit as tabbed
elgg_extend_view("forms/groups/edit", "group_tools/group_edit_tabbed", 1);

// show group profile widgets - edit form
elgg_extend_view("forms/groups/edit", "group_tools/forms/profile_widgets", 400);

// show group status in owner block
elgg_extend_view("owner_block/extend", "group_tools/owner_block");
// show group status in stats (on group profile)
Expand Down Expand Up @@ -175,8 +178,10 @@ function group_tools_version_1_3(){
register_action("group_tools/toggle_admin", false, dirname(__FILE__) . "/actions/toggle_admin.php");
register_action("group_tools/kick", false, dirname(__FILE__) . "/actions/kick.php");
register_action("group_tools/mail", false, dirname(__FILE__) . "/actions/mail.php");
register_action("group_tools/profile_widgets", false, dirname(__FILE__) . "/actions/profile_widgets.php");

register_action("group_tools/toggle_auto_join", false, dirname(__FILE__) . "/actions/toggle_auto_join.php", true);
register_action("group_tools/fix_auto_join", false, dirname(__FILE__) . "/actions/fix_auto_join.php", true);
register_action("groups/email_invitation", false, dirname(__FILE__) . "/actions/groups/email_invitation.php");

register_action("groups/email_invitation", false, dirname(__FILE__) . "/actions/groups/email_invitation.php");

34 changes: 34 additions & 0 deletions views/default/group_tools/forms/profile_widgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

$group = $vars["entity"];

if(!empty($group) && ($group instanceof ElggGroup) && $group->canEdit()){
if($group->membership != ACCESS_PUBLIC){
// closed membership, so extend options
$noyes_options = array(
"no" => elgg_echo("option:no"),
"yes" => elgg_echo("option:yes")
);

// build form
$form_body = "<h3 class='settings'>" . elgg_echo("group_tools:profile_widgets:title") . "</h3>";
$form_body .= "<div>" . elgg_echo("group_tools:profile_widgets:description") . "</div>";

$form_body .= "<br />";

$form_body .= "<div>";
$form_body .= elgg_echo("group_tools:profile_widgets:option");
$form_body .= "&nbsp;" . elgg_view("input/pulldown", array("internalname" => "profile_widgets", "options_values" => $noyes_options, "value" => $group->profile_widgets));
$form_body .= "</div>";

$form_body .= "<div>";
$form_body .= elgg_view("input/hidden", array("internalname" => "group_guid", "value" => $group->getGUID()));
$form_body .= elgg_view("input/submit", array("value" => elgg_echo("submit")));
$form_body .= "</div>";

$form = elgg_view("input/form", array("body" => $form_body,
"action" => $vars["url"] . "action/group_tools/profile_widgets"));

echo elgg_view("page_elements/contentwrapper", array("body" => $form));
}
}
27 changes: 27 additions & 0 deletions views/default/groups/closedmembership.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Elgg groups plugin full profile view (for a closed group you haven't joined).
*
* @package ElggGroups
*/

$group = $vars["entity"];

?>
<div id="groups_closed_membership">
<p>
<?php
echo elgg_echo('groups:closedgroup');
if (isloggedin()) {
echo ' ' . elgg_echo('groups:closedgroup:request');
}
?>
</p>
</div>

<?php
if(!empty($group) && ($group instanceof ElggGroup)){
if(($group->membership != ACCESS_PUBLIC) && ($group->profile_widgets == yes)){
echo elgg_view("groups/profileitems", $vars);
}
}

0 comments on commit 1e99e23

Please sign in to comment.