diff options
-rw-r--r-- | actions/event_calendar/add_personal.php | 2 | ||||
-rw-r--r-- | actions/event_calendar/addtocalendar.php | 2 | ||||
-rw-r--r-- | actions/event_calendar/killrequest.php | 2 | ||||
-rw-r--r-- | languages/en.php | 14 | ||||
-rw-r--r-- | models/model.php | 38 | ||||
-rw-r--r-- | start.php | 5 | ||||
-rw-r--r-- | views/default/forms/event_calendar/edit.php | 30 | ||||
-rw-r--r-- | views/default/plugins/event_calendar/settings.php | 16 | ||||
-rw-r--r-- | views/default/widgets/event_calendar/content.php | 39 |
9 files changed, 120 insertions, 28 deletions
diff --git a/actions/event_calendar/add_personal.php b/actions/event_calendar/add_personal.php index fd6f6cee2..ed4eb3092 100644 --- a/actions/event_calendar/add_personal.php +++ b/actions/event_calendar/add_personal.php @@ -14,4 +14,4 @@ if (elgg_instanceof($event,'object','event_calendar')) { } } -forward(REFERER);
\ No newline at end of file +forward(REFERER); diff --git a/actions/event_calendar/addtocalendar.php b/actions/event_calendar/addtocalendar.php index e5b689d73..0144dfba1 100644 --- a/actions/event_calendar/addtocalendar.php +++ b/actions/event_calendar/addtocalendar.php @@ -11,7 +11,7 @@ $event = get_entity($event_guid); if (elgg_instanceof($event, 'object', 'event_calendar') && elgg_instanceof($user, 'user') - && event_calendar_personal_can_manage($event,$user_guid) + && $event->canEdit() && check_entity_relationship($user_guid, 'event_calendar_request', $event_guid)) { if (event_calendar_add_personal_event($event_guid,$user_guid)) { diff --git a/actions/event_calendar/killrequest.php b/actions/event_calendar/killrequest.php index b58e804cd..f4f3c3135 100644 --- a/actions/event_calendar/killrequest.php +++ b/actions/event_calendar/killrequest.php @@ -11,7 +11,7 @@ $event = get_entity($event_guid); if (elgg_instanceof($event, 'object', 'event_calendar') && elgg_instanceof($user, 'user') - && event_calendar_personal_can_manage($event,$user_guid) + && $event->canEdit() && check_entity_relationship($user_guid, 'event_calendar_request', $event_guid)) { remove_entity_relationship($user->guid, 'event_calendar_request', $event_guid); diff --git a/languages/en.php b/languages/en.php index 621387103..b3caefcf2 100644 --- a/languages/en.php +++ b/languages/en.php @@ -160,8 +160,11 @@ 'event_calendar:settings:region_list_handles:title' => "The region strings above are string handles. Use the Elgg translation system to resolve them.", 'event_calendar:settings:type_list_handles:title' => "The type strings above are string handles. Use the Elgg translation system to resolve them.", - 'event_calendar:settings:personal_manage:title' => "Allow users to add/remove any event they can see to/from their personal calendars. (If no, only admins and the event creator can add/remove them).", - + 'event_calendar:settings:personal_manage:title' => "Calendar permissions", + 'event_calendar:settings:personal_manage:description' => "Determines whether people can add events to their personal calendars (open), " + ."need to request the event creator to do so (closed), have no option at all (private), or allow event creators to determine this for each event (by event). " + ."Note if you set this to private you should probably activate the option above to allow event creators and site admins to " + ."add their events to other personal calendars.", 'event_calendar:strapline' => "Posted %s by %s", 'event_calendar:request_event_response' => "Your request to be added to this event has been sent.", @@ -242,6 +245,13 @@ You can manage calendar requests for this event here: 'event_calendar:manage_subscribers:success' => "Personal calendars updated.", 'event_calendar:manage_subscribers:error' => "Error: could not update personal calendars.", + 'event_calendar:personal_manage:open' => "open", + 'event_calendar:personal_manage:closed' => "closed", + 'event_calendar:personal_manage:private' => "private", + 'event_calendar:personal_manage:by_event' => "by event", + 'event_calendar:personal_manage:label' => "Calendar permission", + 'event_calendar:personal_manage:description' => "Determines whether people can add this event to their calendars (open), " + ."need to apply to do so (closed) or have no option at all (private - so only you or a site admin can add the event to calendars).", /** * Event calendar river diff --git a/models/model.php b/models/model.php index 7ef49ff25..66091ba67 100644 --- a/models/model.php +++ b/models/model.php @@ -31,6 +31,7 @@ function event_calendar_set_event_from_form($event_guid,$group_guid) { $event_calendar_spots_display = elgg_get_plugin_setting('spots_display', 'event_calendar'); $event_calendar_hide_end = elgg_get_plugin_setting('hide_end', 'event_calendar'); $event_calendar_more_required = elgg_get_plugin_setting('more_required', 'event_calendar'); + $event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar'); if ($event_calendar_more_required == 'yes') { $required_fields = array('title','venue','start_date', @@ -116,6 +117,9 @@ function event_calendar_set_event_from_form($event_guid,$group_guid) { if ($event_calendar_type_display == 'yes') { $event->event_type = get_input('event_type'); } + if ($event_calendar_personal_manage == 'by_event') { + $event->personal_manage = get_input('personal_manage'); + } $event->fees = get_input('fees'); $event->contact = get_input('contact'); $event->organiser = get_input('organiser'); @@ -1078,23 +1082,29 @@ function event_calendar_view_entity_list($entities, $count, $offset, $limit, $fu return $html; } +// returns open, closed or private for the given event and user function event_calendar_personal_can_manage($event,$user_id) { - $authorised = FALSE; + $status = 'private'; $event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar'); - if ($event_calendar_personal_manage != 'no') { - $authorised = TRUE; + if (!$event_calendar_personal_manage + || $event_calendar_personal_manage == 'open' + || $event_calendar_personal_manage == 'yes' + || (($event_calendar_personal_manage == 'by_event' && (!$event->personal_manage || ($event->personal_manage == 'open'))))) { + $status = 'open'; } else { + // in this case only admins or event owners can manage events on their personal calendars if(elgg_is_admin_logged_in()) { - $authorised = TRUE; - } else { - // load the event from the database - if ($event && ($event->owner_guid == $user_id)) { - $authorised = TRUE; - } + $status = 'open'; + } else if ($event && ($event->owner_guid == $user_id)) { + $status = 'open'; + } else if (($event_calendar_personal_manage == 'closed') + || ($event_calendar_personal_manage == 'no') + || (($event_calendar_personal_manage == 'by_event') && ($event->personal_manage == 'closed'))) { + $status = 'closed'; } } - return $authorised; + return $status; } function event_calendar_send_event_request($event,$user_guid) { @@ -1280,6 +1290,7 @@ function event_calendar_prepare_edit_form_vars($event = NULL) { 'contact' => NULL, 'organiser' => NULL, 'tags' => NULL, + 'personal_manage' => NULL, 'long_description' => NULL, 'access_id' => ACCESS_DEFAULT, 'group_guid' => NULL, @@ -1653,9 +1664,8 @@ function event_calendar_get_page_content_review_requests($event_guid) { } elgg_push_breadcrumb($event->title,$event->getURL()); elgg_push_breadcrumb(elgg_echo('event_calendar:review_requests_menu_title')); - $user_guid = elgg_get_logged_in_user_guid(); - if (event_calendar_personal_can_manage($event,$user_guid)) { + if ($event->canEdit()) { $requests = elgg_get_entities_from_relationship( array( 'relationship' => 'event_calendar_request', @@ -1680,8 +1690,10 @@ function event_calendar_get_page_content_review_requests($event_guid) { } function event_calendar_handle_menu($event_guid) { + $event = get_entity($event_guid); $event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar'); - if ($event_calendar_personal_manage == 'no') { + if ((($event_calendar_personal_manage == 'by_event') && ($event->personal_manage == 'closed')) + || (($event_calendar_personal_manage == 'closed') || ($event_calendar_personal_manage == 'no'))) { $url = "event_calendar/review_requests/$event_guid"; $item = new ElggMenuItem('event-calendar-0review_requests', elgg_echo('event_calendar:review_requests_menu_title'), $url); $item->setSection('event_calendar'); @@ -278,7 +278,8 @@ function event_calendar_entity_menu_setup($hook, $type, $return, $params) { } $user_guid = elgg_get_logged_in_user_guid(); if ($user_guid) { - if (event_calendar_personal_can_manage($entity,$user_guid)) { + $calendar_status = event_calendar_personal_can_manage($entity,$user_guid); + if ($calendar_status == 'open') { if (event_calendar_has_personal_event($entity->guid,$user_guid)) { $options = array( 'name' => 'personal_calendar', @@ -299,7 +300,7 @@ function event_calendar_entity_menu_setup($hook, $type, $return, $params) { ); $return[] = ElggMenuItem::factory($options); } } - } else { + } else if ($calendar_status == 'closed') { if (!event_calendar_has_personal_event($entity->guid,$user_guid) && !check_entity_relationship($user_guid, 'event_calendar_request', $entity->guid)) { $options = array( 'name' => 'personal_calendar', diff --git a/views/default/forms/event_calendar/edit.php b/views/default/forms/event_calendar/edit.php index a84a79407..1830ef168 100644 --- a/views/default/forms/event_calendar/edit.php +++ b/views/default/forms/event_calendar/edit.php @@ -2,6 +2,12 @@ $event = $vars['event']; $fd = $vars['form_data']; +$personal_manage_options = array( + elgg_echo('event_calendar:personal_manage:open') => 'open', + elgg_echo('event_calendar:personal_manage:closed') => 'closed', + elgg_echo('event_calendar:personal_manage:private') => 'private', +); + $event_calendar_times = elgg_get_plugin_setting('times', 'event_calendar'); $event_calendar_region_display = elgg_get_plugin_setting('region_display', 'event_calendar'); $event_calendar_type_display = elgg_get_plugin_setting('type_display', 'event_calendar'); @@ -10,6 +16,7 @@ $event_calendar_spots_display = elgg_get_plugin_setting('spots_display', 'event_ $event_calendar_hide_access = elgg_get_plugin_setting('hide_access', 'event_calendar'); $event_calendar_hide_end = elgg_get_plugin_setting('hide_end', 'event_calendar'); $event_calendar_more_required = elgg_get_plugin_setting('more_required', 'event_calendar'); +$event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar'); if ($event_calendar_more_required == 'yes') { $required_fields = array('title','venue','start_date','start_time', @@ -20,7 +27,8 @@ if ($event_calendar_more_required == 'yes') { } $all_fields = array('title','venue','start_time','start_date','end_time','end_date', 'brief_description','region','event_type','fees','contact','organiser','event_tags', - 'long_description','spots'); + 'long_description','spots','personal_manage'); + $prefix = array(); foreach ($all_fields as $fn) { if (in_array($fn,$required_fields)) { @@ -64,6 +72,12 @@ if ($event) { $start_time = $event->start_time; $end_time = $event->end_time; } + if ($event_calendar_personal_manage == 'by_event') { + $personal_manage = $event->personal_manage; + if (!$personal_manage) { + $personal_manage = 'open'; + } + } $event_action = 'manage_event'; $event_guid = $event->guid; } else { @@ -91,6 +105,9 @@ if ($event) { $start_time = $fd['start_time']; $end_time = $fd['end_time']; } + if ($event_calendar_personal_manage == 'by_event') { + $personal_manage = $fd['personal_manage']; + } $event_action = 'add_event'; $event_guid = 0; } @@ -175,7 +192,7 @@ if ($event_calendar_region_display == 'yes') { } } $body .= '<p><label>'.elgg_echo("event_calendar:region_label").'<br />'; - $body .= elgg_view("input/pulldown",array('name' => 'region','value'=>$region,'options_values'=>$options)); + $body .= elgg_view("input/dropdown",array('name' => 'region','value'=>$region,'options_values'=>$options)); $body .= '</label></p>'; $body .= '<p class="description">'.$prefix['region'].elgg_echo('event_calendar:region_description').'</p>'; } @@ -199,7 +216,7 @@ if ($event_calendar_type_display == 'yes') { } } $body .= '<p><label>'.elgg_echo("event_calendar:type_label").'<br />'; - $body .= elgg_view("input/pulldown",array('name' => 'event_type','value'=>$event_type,'options_values'=>$options)); + $body .= elgg_view("input/dropdown",array('name' => 'event_type','value'=>$event_type,'options_values'=>$options)); $body .= '</label></p>'; $body .= '<p class="description">'.$prefix['event_type'].elgg_echo('event_calendar:type_description').'</p>'; } @@ -220,6 +237,13 @@ $body .= elgg_view("input/text",array('name' => 'organiser','value'=>$organiser) $body .= '</label></p>'; $body .= '<p class="description">'.$prefix['organiser'].elgg_echo('event_calendar:organiser_description').'</p>'; +if ($event_calendar_personal_manage == 'by_event') { + $body .= '<p><label>'.elgg_echo('event_calendar:personal_manage:label').'<br />'; + $body .= elgg_view("input/radio",array('name' => 'personal_manage','value'=>$personal_manage,'options'=>$personal_manage_options)); + $body .= '</label></p>'; + $body .= '<p class="description">'.$prefix['personal_manage'].elgg_echo('event_calendar:personal_manage:description').'</p>'; +} + $body .= '<p><label>'.elgg_echo("event_calendar:event_tags_label").'<br />'; $body .= elgg_view("input/tags",array('name' => 'tags','value'=>$event_tags)); $body .= '</label></p>'; diff --git a/views/default/plugins/event_calendar/settings.php b/views/default/plugins/event_calendar/settings.php index 54ff5c1c3..963f64549 100644 --- a/views/default/plugins/event_calendar/settings.php +++ b/views/default/plugins/event_calendar/settings.php @@ -3,6 +3,13 @@ $yn_options = array(elgg_echo('event_calendar:settings:yes')=>'yes', elgg_echo('event_calendar:settings:no')=>'no', ); +$membership_options = array( + elgg_echo('event_calendar:personal_manage:open') => 'open' , + elgg_echo('event_calendar:personal_manage:closed') => 'closed', + elgg_echo('event_calendar:personal_manage:private') => 'private', + elgg_echo('event_calendar:personal_manage:by_event') => 'by_event', +); + $access_options = array( ACCESS_PRIVATE => elgg_echo("PRIVATE"), ACCESS_LOGGED_IN => elgg_echo("LOGGED_IN"), ACCESS_PUBLIC => elgg_echo("PUBLIC")); @@ -222,15 +229,14 @@ $body .= elgg_view('input/radio',array('name'=>'params[add_users_notify]','value $body .= '<br />'; $event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar'); -if (!$event_calendar_personal_manage) { - $event_calendar_personal_manage = 'yes'; +if (!$event_calendar_personal_manage && $personal_manage == 'yes') { + $event_calendar_personal_manage = 'open'; } $body .= elgg_echo('event_calendar:settings:personal_manage:title'); $body .= '<br />'; -$body .= elgg_view('input/radio',array('name'=>'params[personal_manage]','value'=>$event_calendar_personal_manage,'options'=>$yn_options)); - -$body .= '<br />'; +$body .= elgg_view('input/radio',array('name'=>'params[personal_manage]','value'=>$event_calendar_personal_manage,'options'=>$membership_options)); +$body .= '<p>'.elgg_echo('event_calendar:settings:personal_manage:description').'</p>'; $event_calendar_spots_display = elgg_get_plugin_setting('spots_display', 'event_calendar'); if (!$event_calendar_spots_display) { diff --git a/views/default/widgets/event_calendar/content.php b/views/default/widgets/event_calendar/content.php new file mode 100644 index 000000000..329046cb0 --- /dev/null +++ b/views/default/widgets/event_calendar/content.php @@ -0,0 +1,39 @@ +<?php + +/** + * Elgg event calendar widget + * + * @package event_calendar + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Kevin Jardine <kevin@radagast.biz> + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + */ + + // Load event calendar model + elgg_load_library('elgg:event_calendar'); + + //the number of events to display + $num = (int) $vars['entity']->num_display; + if (!$num) + $num = 5; + + // Get the events + + $events = event_calendar_get_personal_events_for_user(elgg_get_page_owner_guid(),$num); + + // If there are any events to view, view them + if (is_array($events) && sizeof($events) > 0) { + + echo "<div id=\"widget_calendar\">"; + + foreach($events as $event) { + echo elgg_view("object/event_calendar",array('entity' => $event)); + } + + echo "</div>"; + + } + +?>
\ No newline at end of file |