From 83aa919f302dfd00295defd03a089e0619bf9406 Mon Sep 17 00:00:00 2001 From: marcus Date: Fri, 4 Jul 2008 16:53:04 +0000 Subject: Refs #109: Invite support added git-svn-id: https://code.elgg.org/elgg/trunk@1298 36083f99-b078-4883-b0ff-0f9b5a30f544 --- languages/en.php | 2 + mod/groups/actions/addtogroup.php | 113 ++++++++++++----------- mod/groups/actions/edit.php | 9 ++ mod/groups/edit.php | 2 +- mod/groups/invite.php | 27 ++++++ mod/groups/languages/en.php | 4 + mod/groups/start.php | 3 +- mod/groups/views/default/forms/groups/invite.php | 29 ++++++ mod/groups/views/default/groups/groupprofile.php | 1 + mod/groups/views/default/groups/icon.php | 30 +----- mod/groups/views/default/groups/menu/actions.php | 17 ++-- mod/groups/views/default/sharing/invite.php | 41 ++++++++ 12 files changed, 184 insertions(+), 94 deletions(-) create mode 100644 mod/groups/invite.php create mode 100644 mod/groups/views/default/forms/groups/invite.php create mode 100644 mod/groups/views/default/sharing/invite.php diff --git a/languages/en.php b/languages/en.php index c833b327c..fc5a9eb48 100644 --- a/languages/en.php +++ b/languages/en.php @@ -379,6 +379,8 @@ 'enable' => "Enable", 'disable' => "Disable", + 'invite' => "Invite", + 'resetpassword' => "Reset password", 'makeadmin' => "Make admin", diff --git a/mod/groups/actions/addtogroup.php b/mod/groups/actions/addtogroup.php index 9ce42d523..b60892012 100644 --- a/mod/groups/actions/addtogroup.php +++ b/mod/groups/actions/addtogroup.php @@ -15,75 +15,84 @@ gatekeeper(); + $forward_url = get_input('forward_url', $_SERVER['HTTP_REFERER']); $user_guid = get_input('user_guid'); + if (!is_array($user_guid)) + $user_guid = array($user_guid); $group_guid = get_input('group_guid'); - $user = get_entity($user_guid); - $group = get_entity($group_guid); - - if ($_SESSION['user']->getGUID() == $group->owner_guid) + + foreach ($user_guid as $u_id) { - $requests = $user->group_join_request; - - if ($requests) + $requested = false; + $user = get_entity($u_id); + $group = get_entity($group_guid); + + if ($_SESSION['user']->getGUID() == $group->owner_guid) { - foreach ($requests as $request) + $requests = $user->group_join_request; + + if ($requests) { - if ($request == $group->getGUID()) + foreach ($requests as $request) { - - // User has requested to join this group previously, so we can safely add them - - // add them - if ((!$group->isMember($user)) && ($group->join($user))) + if ($request == $group->getGUID()) { - // send welcome email - notify_user($user->getGUID(), $group->owner_guid, - sprintf(elgg_echo('groups:welcome:subject'), $group->title), - sprintf(elgg_echo('groups:welcome:body'), $user->name, $group->title, $group->getURL()), - NULL, "email"); + // User has requested to join this group previously, so we can safely add them + + // add them + if ((!$group->isMember($user)) && ($group->join($user))) + { - system_message(elgg_echo('groups:addedtogroup')); + // send welcome email + notify_user($user->getGUID(), $group->owner_guid, + sprintf(elgg_echo('groups:welcome:subject'), $group->title), + sprintf(elgg_echo('groups:welcome:body'), $user->name, $group->title, $group->getURL()), + NULL, "email"); + + system_message(elgg_echo('groups:addedtogroup')); + + } + else + system_message(elgg_echo("groups:cantjoin")); + $requested = true; } + } + } + + if (!$requested) + { + // Not found in request array, so send an invite and set invite flag + $methods = $user->group_invite; + if (($methods) && (!is_array($methods))) + $methods = array($methods); + if (!$methods) $methods=array(); + $methods[] = $group->getGUID(); + $methods = array_unique($methods); + + // Set invite flag + //if (!$user->setMetaData('group_invite', $group->getGUID(), "", true)) + if (!$user->group_invite = $methods) + system_message(elgg_echo("groups:usernotinvited")); + else + { + // Send email + if (notify_user($user->getGUID(), $group->owner_guid, + sprintf(elgg_echo('groups:invite:subject'), $user->name, $group->title), + sprintf(elgg_echo('groups:invite:body'), $user->name, $group->title, "{$CONFIG->url}action/groups/join?user_guid={$user->guid}&group_guid={$group->guid}"), + NULL, "email")) + system_message(elgg_echo("groups:userinvited")); else - system_message(elgg_echo("groups:cantjoin")); - - forward($_SERVER['HTTP_REFERER']); - exit; + system_message(elgg_echo("groups:usernotinvited")); } } } - - // Not found in request array, so send an invite and set invite flag - $methods = $user->group_invite; - if (($methods) && (!is_array($methods))) - $methods = array($methods); - if (!$methods) $methods=array(); - $methods[] = $group->getGUID(); - $methods = array_unique($methods); - - // Set invite flag - //if (!$user->setMetaData('group_invite', $group->getGUID(), "", true)) - if (!$user->group_invite = $methods) - system_message(elgg_echo("groups:usernotinvited")); else - { - // Send email - if (notify_user($user->getGUID(), $group->owner_guid, - sprintf(elgg_echo('groups:invite:subject'), $user->name, $group->title), - sprintf(elgg_echo('groups:invite:body'), $user->name, $group->title, "{$CONFIG->url}action/groups/join?user_guid={$user->guid}&group_guid={$group->guid}"), - NULL, "email")) - system_message(elgg_echo("groups:userinvited")); - else - system_message(elgg_echo("groups:usernotinvited")); - } - + system_message(elgg_echo("groups:notowner")); } - else - system_message(elgg_echo("groups:notowner")); - - forward($_SERVER['HTTP_REFERER']); + + forward($forward_url); exit; ?> \ No newline at end of file diff --git a/mod/groups/actions/edit.php b/mod/groups/actions/edit.php index 4e9cdf99e..c8eebbd84 100644 --- a/mod/groups/actions/edit.php +++ b/mod/groups/actions/edit.php @@ -45,6 +45,15 @@ } } + // Validate create + if (!$group->title) + { + system_message(elgg_echo("groups:notitle")); + + forward($_SERVER['HTTP_REFERER']); + exit; + } + // Get access $group->access_id = get_input('access_id', 0); diff --git a/mod/groups/edit.php b/mod/groups/edit.php index dcd6db98d..41f43c007 100644 --- a/mod/groups/edit.php +++ b/mod/groups/edit.php @@ -20,7 +20,7 @@ $body = elgg_view_layout('one_column', elgg_view("forms/groups/edit", array('entity' => $group))); } else { - $area1 = elgg_echo("groups:noaccess"); + $body = elgg_echo("groups:noaccess"); } page_draw(elgg_echo("groups:new"), $body); diff --git a/mod/groups/invite.php b/mod/groups/invite.php new file mode 100644 index 000000000..c3af86397 --- /dev/null +++ b/mod/groups/invite.php @@ -0,0 +1,27 @@ +canEdit())) + { + $body = elgg_view_layout('one_column', elgg_view("forms/groups/invite", array('entity' => $group))); + + } else { + $body = elgg_echo("groups:noaccess"); + } + + page_draw(elgg_echo("groups:invite"), $body); +?> \ No newline at end of file diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php index cd89c54da..d286835d5 100644 --- a/mod/groups/languages/en.php +++ b/mod/groups/languages/en.php @@ -36,9 +36,13 @@ 'groups:joinrequest' => 'Request membership', 'groups:join' => 'Join group', 'groups:leave' => 'Leave group', + 'groups:invite' => 'Invite friends', + 'groups:inviteto' => "Invite friends to '%s'", + 'groups:nofriends' => "You have no friends left who have not been invited to this group.", 'groups:privategroup' => 'This group is private, requesting membership.', + 'groups:notitle' => 'Groups must have a title', 'groups:cantjoin' => 'Can not join group', 'groups:cantleave' => 'Could not leave group', 'groups:addedtogroup' => 'Successfully added the user to the group', diff --git a/mod/groups/start.php b/mod/groups/start.php index 30d93facc..509533999 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -123,8 +123,7 @@ set_input('username',$page[1]); include($CONFIG->pluginspath . "groups/index.php"); - break; - + break; default: set_input('group_guid', $page[0]); include($CONFIG->pluginspath . "groups/groupprofile.php"); diff --git a/mod/groups/views/default/forms/groups/invite.php b/mod/groups/views/default/forms/groups/invite.php new file mode 100644 index 000000000..055bb738b --- /dev/null +++ b/mod/groups/views/default/forms/groups/invite.php @@ -0,0 +1,29 @@ +owner_guid); + $forward_url = $group->getURL(); + + +?> +

title); ?>

+
+ + $shares, 'owner' => $owner, 'group' => $group)); + + ?> + + + +
\ No newline at end of file diff --git a/mod/groups/views/default/groups/groupprofile.php b/mod/groups/views/default/groups/groupprofile.php index 6eb403bb5..923c07b3e 100644 --- a/mod/groups/views/default/groups/groupprofile.php +++ b/mod/groups/views/default/groups/groupprofile.php @@ -113,6 +113,7 @@ ?> + title); - - - $username = $vars['entity']->username; // TODO : How do i do an icon when we have no username? ?>
-
- - "; - - } - if ($vars['entity']->owner_guid == $vars['user']->getGUID()) { - echo elgg_view('groups/menu/ownerlinks',$vars); - } else { - echo elgg_view('groups/menu/links',$vars); - } - } else { - echo elgg_view('groups/menu/links',$vars); - } - - ?> - -
- title="" /> + title="" /> \ No newline at end of file diff --git a/mod/groups/views/default/groups/menu/actions.php b/mod/groups/views/default/groups/menu/actions.php index 2c686fd95..8e1130871 100644 --- a/mod/groups/views/default/groups/menu/actions.php +++ b/mod/groups/views/default/groups/menu/actions.php @@ -13,26 +13,23 @@ if ($vars['entity']->isMember($_SESSION['user'])) { -?> -

-

access_id == 2) { -?> -

-

-

-

canEdit()) + { + ?>

\ No newline at end of file diff --git a/mod/groups/views/default/sharing/invite.php b/mod/groups/views/default/sharing/invite.php new file mode 100644 index 000000000..2194c80bc --- /dev/null +++ b/mod/groups/views/default/sharing/invite.php @@ -0,0 +1,41 @@ +getGUID(),false,'user','')) { + + foreach($friends as $friend) { + + if (!$group->isMember($friend)) + { + $label = elgg_view("profile/icon",array('entity' => $friend, 'size' => 'tiny')); + $label .= "{$friend->name}"; + $options[$label] = $friend->getGUID(); + } + } + + if ($options) + { + echo elgg_view('input/checkboxes',array( + + 'internalname' => 'user_guid', + 'options' => $options, + + )); + } + else + { + echo elgg_echo('groups:nofriends'); + } + } +?> \ No newline at end of file -- cgit v1.2.3