aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Jardine <kevinjardine@yahoo.com>2012-01-02 15:09:06 +0100
committerKevin Jardine <kevinjardine@yahoo.com>2012-01-02 15:09:06 +0100
commitaa04adce03438348c52477eacbd611c83d3caf68 (patch)
treee9ab59edf8fdd4685e7779ca6a9250d6396dc31d
parent52326aa6023bea7efc6208ce80f3e78797a3fcc9 (diff)
downloadelgg-aa04adce03438348c52477eacbd611c83d3caf68.tar.gz
elgg-aa04adce03438348c52477eacbd611c83d3caf68.tar.bz2
added new userpicker for site-wide event user management
-rw-r--r--actions/event_calendar/manage_subscribers.php17
-rw-r--r--languages/en.php5
-rw-r--r--models/model.php30
-rw-r--r--start.php1
-rw-r--r--views/default/forms/event_calendar/manage_subscribers.php14
5 files changed, 51 insertions, 16 deletions
diff --git a/actions/event_calendar/manage_subscribers.php b/actions/event_calendar/manage_subscribers.php
new file mode 100644
index 000000000..212150082
--- /dev/null
+++ b/actions/event_calendar/manage_subscribers.php
@@ -0,0 +1,17 @@
+<?php
+$event_guid = get_input('event_guid');
+$event = get_entity($event_guid);
+if (elgg_instanceof($event,'object','event_calendar') && $event->canEdit()) {
+ $members = get_input('members');
+ // clear the event from all personal calendars
+ remove_entity_relationships($event_guid, 'personal_event', TRUE);
+ // add event to personal calendars
+ foreach ($members as $user_guid) {
+ add_entity_relationship($user_guid,'personal_event',$event_guid);
+ }
+ system_message(elgg_echo('event_calendar:manage_subscribers:success'));
+ forward($event->getURL());
+} else {
+ register_error(elgg_echo('event_calendar:manage_subscribers:error'));
+ forward();
+}
diff --git a/languages/en.php b/languages/en.php
index 285392e62..d16085994 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -230,7 +230,7 @@ You can manage calendar requests for this event here:
'event_calendar:listing_title:friends' => "Friends' calendars",
'event_calendar:manage_users:title' => "Manage subscribers for \"%s\"",
'event_calendar:manage_users:breadcrumb' => "Manage subscribers",
- 'event_calendar:manage_users:description' => "You can add or remove events from personal calendars using the buttons below.",
+ 'event_calendar:manage_users:description' => "Add or remove events from personal calendars.",
'event_calendar:manage_users:unauthorized' => "Error: you are not authorised to manage personal calendars for this event.",
'event_calendar:add_to_group_members:success' => "This event has been added to the personal calendars of all group members.",
'event_calendar:add_to_group_members:error' => "Error: could not add this event to the personal calendars of group members.",
@@ -239,6 +239,9 @@ You can manage calendar requests for this event here:
'event_calendar:add_to_group_members:button' => "Add to all",
'event_calendar:remove_from_group_members:button' => "Remove from all",
+ 'event_calendar:manage_subscribers:success' => "Personal calendars updated.",
+ 'event_calendar:manage_subscribers:error' => "Error: could not update personal calendars.",
+
/**
* Event calendar river
**/
diff --git a/models/model.php b/models/model.php
index db2bdf95d..65a9215af 100644
--- a/models/model.php
+++ b/models/model.php
@@ -1561,8 +1561,6 @@ function event_calendar_get_page_content_manage_users($event_guid) {
elgg_push_context('groups');
elgg_set_page_owner_guid($event->container_guid);
elgg_push_breadcrumb(elgg_echo('event_calendar:group_breadcrumb'), 'event_calendar/group/'.$event->container_guid);
- $users = $event_container->getMembers($limit,$offset);
- $count = $event_container->getMembers($limit,$offset,TRUE);
elgg_register_menu_item('title', array(
'name' => 'remove_from_group_members',
'href' => elgg_add_action_tokens_to_url('action/event_calendar/remove_from_group_members?event_guid='.$event_guid),
@@ -1575,24 +1573,26 @@ function event_calendar_get_page_content_manage_users($event_guid) {
'text' => elgg_echo('event_calendar:add_to_group_members:button'),
'class' => 'elgg-button elgg-button-action',
));
+ $users = $event_container->getMembers($limit,$offset);
+ $count = $event_container->getMembers($limit,$offset,TRUE);
+ elgg_extend_view('user/default','event_calendar/calendar_toggle');
+ $options = array(
+ 'full_view' => FALSE,
+ 'list_type_toggle' => FALSE,
+ 'limit'=>$limit,
+ 'event_calendar_event'=>$event,
+ 'pagination' => TRUE,
+ 'count'=>$count,
+ );
+ $content .= elgg_view_entity_list($users,$options,$offset,$limit);
} else {
elgg_push_breadcrumb(elgg_echo('event_calendar:show_events_title'),'event_calendar/list');
- $users = elgg_get_entities(array('type'=>'user','limit'=>$limit,'offset'=>$offset));
- $count = elgg_get_entities(array('type'=>'user','count'=>TRUE));
+ $content = '<p>'.elgg_echo('event_calendar:manage_users:description').'</p>';
+ $content .= elgg_view_form('event_calendar/manage_subscribers',array(),array('event'=>$event));
}
elgg_push_breadcrumb($event->title,$event->getURL());
elgg_push_breadcrumb(elgg_echo('event_calendar:manage_users:breadcrumb'));
- $options = array(
- 'full_view' => FALSE,
- 'list_type_toggle' => FALSE,
- 'limit'=>$limit,
- 'event_calendar_event'=>$event,
- 'pagination' => TRUE,
- 'count'=>$count,
- );
- elgg_extend_view('user/default','event_calendar/calendar_toggle');
- $content = '<p>'.elgg_echo('event_calendar:manage_users:description').'</p>';
- $content .= elgg_view_entity_list($users,$options,$offset,$limit);
+
} else {
$content = elgg_echo('event_calendar:manage_users:unauthorized');
}
diff --git a/start.php b/start.php
index b8c79ca37..5cfc9fd3a 100644
--- a/start.php
+++ b/start.php
@@ -99,6 +99,7 @@ function event_calendar_init() {
elgg_register_action("event_calendar/remove_from_group","$action_path/remove_from_group.php");
elgg_register_action("event_calendar/add_to_group_members","$action_path/add_to_group_members.php");
elgg_register_action("event_calendar/remove_from_group_members","$action_path/remove_from_group_members.php");
+ elgg_register_action("event_calendar/manage_subscribers","$action_path/manage_subscribers.php");
}
diff --git a/views/default/forms/event_calendar/manage_subscribers.php b/views/default/forms/event_calendar/manage_subscribers.php
new file mode 100644
index 000000000..8039c5015
--- /dev/null
+++ b/views/default/forms/event_calendar/manage_subscribers.php
@@ -0,0 +1,14 @@
+<?php
+$event = $vars['event'];
+$users = event_calendar_get_users_for_event($event->guid,0);
+$guids = array();
+foreach($users as $user) {
+ $guids[] = $user->guid;
+}
+// TODO: if the event container is a group need to restrict user picker to the members of the group?
+$content = elgg_view('input/userpicker_plus',array('value'=> $guids));
+$content .= '<br /><br />';
+$content .= elgg_view('input/hidden',array('name'=>'event_guid','value'=>$event->guid));
+$content .= elgg_view('input/submit',array('value'=>elgg_echo('submit'),'name'=>'submit_manage_subscribers','id'=>'submit-manage-subscribers'));
+
+echo $content;