diff options
author | Kevin Jardine <kevinjardine@yahoo.com> | 2011-10-19 11:23:52 +0200 |
---|---|---|
committer | Kevin Jardine <kevinjardine@yahoo.com> | 2011-10-19 11:23:52 +0200 |
commit | e40bd05afc559335bc9b326f4ae2400043104818 (patch) | |
tree | 6dbd25f155a9b73f64b90cbca46f6f64e1ec87bb | |
parent | 3b6f9d887fea4a97ae9b948922a8679496862bbf (diff) | |
download | elgg-e40bd05afc559335bc9b326f4ae2400043104818.tar.gz elgg-e40bd05afc559335bc9b326f4ae2400043104818.tar.bz2 |
fixes personal calendar toggle bug and adds the ability to add any site member to a site event and any group member to a group event
-rw-r--r-- | actions/event_calendar/toggle_personal_calendar.php | 3 | ||||
-rw-r--r-- | languages/en.php | 6 | ||||
-rw-r--r-- | models/model.php | 62 | ||||
-rw-r--r-- | start.php | 3 | ||||
-rw-r--r-- | views/default/event_calendar/calendar_toggle.php | 18 |
5 files changed, 77 insertions, 15 deletions
diff --git a/actions/event_calendar/toggle_personal_calendar.php b/actions/event_calendar/toggle_personal_calendar.php index f2341a91a..977355d78 100644 --- a/actions/event_calendar/toggle_personal_calendar.php +++ b/actions/event_calendar/toggle_personal_calendar.php @@ -1,8 +1,9 @@ <?php elgg_load_library('elgg:event_calendar'); $event_guid = get_input('event_guid',0); -$user_guid = get_input('user_id',elgg_get_logged_in_user_guid()); +$user_guid = get_input('user_guid',elgg_get_logged_in_user_guid()); $other = get_input('other',''); +error_log("in toggle_personal_calendar: $event_guid, $user_guid, $other"); if ($other) { $remove_response = elgg_echo('event_calendar:added_to_the_calendar'); $add_response = elgg_echo('event_calendar:removed_from_the_calendar'); diff --git a/languages/en.php b/languages/en.php index da055c6e5..3239e07bc 100644 --- a/languages/en.php +++ b/languages/en.php @@ -226,7 +226,11 @@ You can manage calendar requests for this event here: 'event_calendar:listing_title:all' => "All events", 'event_calendar:listing_title:open' => "Open events", 'event_calendar:listing_title:mine' => "My calendar", - 'event_calendar:listing_title:friends' => "Friends' calendars", + '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:unauthorized' => "Error: you are not authorised to manage personal calendars for this event.", /** * Event calendar river diff --git a/models/model.php b/models/model.php index 446415e4b..378eeacce 100644 --- a/models/model.php +++ b/models/model.php @@ -701,9 +701,9 @@ function event_calendar_has_personal_event($event_guid,$user_guid) { // use old method for now $annotations = get_annotations($event_guid, "object", "event_calendar", "personal_event", (int) $user_guid, $user_guid); if ($annotations && count($annotations) > 0) { - return true; + return TRUE; } else { - return false; + return FALSE; } } } @@ -1532,6 +1532,59 @@ function event_calendar_get_page_content_display_users($event_guid) { return elgg_view_page($title,$body); } +// display a list of all the members of the container of $event_guid and allowing +// adding or removing them + +function event_calendar_get_page_content_manage_users($event_guid) { + // TODO: make this an optional feature, toggled off + elgg_load_js('elgg.event_calendar'); + $event = get_entity($event_guid); + $limit = 10; + $offset = get_input('offset', 0); + + if (!elgg_instanceof($event, 'object', 'event_calendar')) { + $content = elgg_echo('event_calendar:error_nosuchevent'); + $title = elgg_echo('event_calendar:generic_error_title'); + } else { + event_calendar_handle_menu($event_guid); + $title = elgg_echo('event_calendar:manage_users:title',array($event->title)); + $event_container = get_entity($event->container_guid); + if ($event_container->canEdit()) { + if (elgg_instanceof($event_container, 'group')) { + 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); + } 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)); + } + 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'); + } + } + $params = array('title' => $title, 'content' => $content,'filter' => ''); + + $body = elgg_view_layout("content", $params); + + return elgg_view_page($title,$body); +} + function event_calendar_get_page_content_review_requests($event_guid) { $event = get_entity($event_guid); @@ -1581,10 +1634,13 @@ function event_calendar_handle_menu($event_guid) { $event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar'); if ($event_calendar_personal_manage == 'no') { $url = "event_calendar/review_requests/$event_guid"; - $item = new ElggMenuItem('event-calendar-menu', elgg_echo('event_calendar:review_requests_menu_title'), $url); + $item = new ElggMenuItem('event-calendar-0review_requests', elgg_echo('event_calendar:review_requests_menu_title'), $url); elgg_register_menu_item('page', $item); //add_submenu_item(elgg_echo('event_calendar:review_requests_title'), $CONFIG->wwwroot . "pg/event_calendar/review_requests/".$event_id, '0eventcalendaradmin'); } + $url = "event_calendar/manage_users/$event_guid"; + $item = new ElggMenuItem('event-calendar-1manage_users', elgg_echo('event_calendar:manage_users:breadcrumb'), $url); + elgg_register_menu_item('page', $item); } function event_calendar_get_secret_key() { $key_file_name = elgg_get_plugin_setting('ical_auth_file_name','event_calendar'); @@ -174,6 +174,9 @@ function event_calendar_page_handler($page) { case 'display_users': echo event_calendar_get_page_content_display_users($page[1]); break; + case 'manage_users': + echo event_calendar_get_page_content_manage_users($page[1]); + break; case 'add': if (isset($page[1])) { group_gatekeeper(); diff --git a/views/default/event_calendar/calendar_toggle.php b/views/default/event_calendar/calendar_toggle.php index 7180dec75..30de15cf2 100644 --- a/views/default/event_calendar/calendar_toggle.php +++ b/views/default/event_calendar/calendar_toggle.php @@ -2,19 +2,17 @@ $event = $vars['event_calendar_event']; $user = $vars['entity']; $container = get_entity($event->container_guid); +if (event_calendar_has_personal_event($event->guid, $user->guid)) { + $label = elgg_echo('event_calendar:remove_from_the_calendar_button'); +} else { + $label = elgg_echo('event_calendar:add_to_the_calendar'); +} -if ($container->canEdit()) { - $link = '<p class="event-calendar-personal-calendar-toggle"><a href="javascript:void(0);" '; - $link .= 'onclick="javascript:event_calendar_personal_toggle('.$event->guid.','.$vars['entity']->guid.'); return false;" '; - $link .= ' >'; - $link .= '<span id="event_calendar_user_data_'.$vars['entity']->guid.'">'.elgg_echo('event_calendar:remove_from_the_calendar').'</span>'; - $link .= '</a></p>'; - +if ($container->canEdit()) { $button = elgg_view('input/button',array( 'id'=>'event_calendar_user_data_'.$event->guid.'_'.$user->guid, 'class' => "event-calendar-personal-calendar-toggle", - 'value' => elgg_echo('event_calendar:remove_from_the_calendar_button'), + 'value' => $label, )); + echo '<div class="event-calendar-personal-calendar-toggle-wrapper">'.$button.'<div>'; } - -echo '<div class="event-calendar-personal-calendar-toggle-wrapper">'.$button.'<div>'; |