aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--languages/en.php2
-rw-r--r--mod/groups/actions/addtogroup.php113
-rw-r--r--mod/groups/actions/edit.php9
-rw-r--r--mod/groups/edit.php2
-rw-r--r--mod/groups/invite.php27
-rw-r--r--mod/groups/languages/en.php4
-rw-r--r--mod/groups/start.php3
-rw-r--r--mod/groups/views/default/forms/groups/invite.php29
-rw-r--r--mod/groups/views/default/groups/groupprofile.php1
-rw-r--r--mod/groups/views/default/groups/icon.php30
-rw-r--r--mod/groups/views/default/groups/menu/actions.php17
-rw-r--r--mod/groups/views/default/sharing/invite.php41
12 files changed, 184 insertions, 94 deletions
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 @@
+<?php
+ /**
+ * Invite users to groups
+ *
+ * @package ElggGroups
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+ gatekeeper();
+
+ $group_guid = get_input('group_guid');
+ $group = get_entity($group_guid);
+
+ if (($group) && ($group->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 @@
+<?php
+ /**
+ * Elgg groups plugin
+ *
+ * @package ElggGroups
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $group = $vars['entity'];
+ $owner = get_entity($vars['entity']->owner_guid);
+ $forward_url = $group->getURL();
+
+
+?>
+<h2><?php echo sprintf(elgg_echo('groups:inviteto'), $group->title); ?></h2>
+<form action="<?php echo $vars['url']; ?>action/groups/addtogroup" method="post">
+
+ <?php
+
+ echo elgg_view('sharing/invite',array('shares' => $shares, 'owner' => $owner, 'group' => $group));
+
+ ?>
+ <input type="hidden" name="forward_url" value="<?php echo $forward_url; ?>" />
+ <input type="hidden" name="group_guid" value="<?php echo $group->guid; ?>" />
+ <input type="submit" value="<?php echo elgg_echo('invite'); ?>" />
+</form> \ 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 @@
?>
<a href="<?php echo $vars['url']; ?>mod/groups/edit.php?group_guid=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("edit"); ?></a>
+
<?php
diff --git a/mod/groups/views/default/groups/icon.php b/mod/groups/views/default/groups/icon.php
index 0a3ce74a4..26c6b622d 100644
--- a/mod/groups/views/default/groups/icon.php
+++ b/mod/groups/views/default/groups/icon.php
@@ -32,37 +32,9 @@
$icontime = "default";
}
- $name = htmlentities($vars['entity']->title);
-
-
- $username = $vars['entity']->username; // TODO : How do i do an icon when we have no username?
?>
<div class="groupicon">
-<div class="avatar_menu_button"><img src="<?php echo $vars['url']; ?>_graphics/avatar_menu_arrow.gif" width="15" height="15" class="arrow" /></div>
-
- <div class="sub_menu">
- <a href="<?php echo $vars['entity']->getURL(); ?>"><h3><?php echo $vars['entity']->title; ?></h3></a>
- <?php
- if (isloggedin()) {
- $actions = elgg_view('groups/menu/actions',$vars);
- if (!empty($actions)) {
-
- echo "<div class=\"item_line\">{$actions}</div>";
-
- }
- 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);
- }
-
- ?>
-
- </div>
- <a href="<?php echo $vars['entity']->getURL(); ?>" class="icon" ><img src="<?php echo $vars['url']; ?>pg/icon/<?php echo $username; ?>/<?php echo $vars['size']; ?>/<?php echo $icontime; ?>.jpg" border="0" <?php echo $align; ?> title="<?php echo $name; ?>" <?php echo $vars['js']; ?> /></a>
+<a href="<?php echo $vars['entity']->getURL(); ?>" class="icon" ><img src="<?php echo $vars['url']; ?>pg/icon/<?php echo $username; ?>/<?php echo $vars['size']; ?>/<?php echo $icontime; ?>.jpg" border="0" <?php echo $align; ?> title="<?php echo $name; ?>" <?php echo $vars['js']; ?> /></a>
</div> \ 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']))
{
-?>
- <p><a href="<?php echo $vars['url']; ?>action/groups/leave?group_guid=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("groups:leave"); ?></a></p>
-<?php
+ ?><p><a href="<?php echo $vars['url']; ?>action/groups/leave?group_guid=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("groups:leave"); ?></a></p><?php
}
else
{
if ($vars['entity']->access_id == 2)
{
-?>
- <p><a href="<?php echo $vars['url']; ?>action/groups/join?group_guid=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("groups:join"); ?></a></p>
-<?php
+ ?><p><a href="<?php echo $vars['url']; ?>action/groups/join?group_guid=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("groups:join"); ?></a></p><?php
}
else
{
-?>
- <p><a href="<?php echo $vars['url']; ?>action/groups/joinrequest?group_guid=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("groups:joinrequest"); ?></a></p>
-<?php
+ ?><p><a href="<?php echo $vars['url']; ?>action/groups/joinrequest?group_guid=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("groups:joinrequest"); ?></a></p><?php
}
}
-
+ if ($vars['entity']->canEdit())
+ {
+ ?><p><a href="<?php echo $vars['url']; ?>mod/groups/invite.php?group_guid=<?php echo $vars['entity']->getGUID(); ?>"><?php echo elgg_echo("groups:invite"); ?></a></p><?php
+ }
}
?> \ 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 @@
+<?php
+ /**
+ * Elgg groups plugin
+ *
+ * @package ElggGroups
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.com/
+ */
+
+ $owner = $vars['owner'];
+ $group = $vars['group'];
+
+ if ($friends = get_entities_from_relationship('friend',$owner->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