From 29792a9858484266952a53268e4fd0dd29b2f4a5 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Tue, 28 Jun 2011 18:12:41 -0400 Subject: moved the code into the base directory so that it is easier to work with --- actions/add_to_group.php | 11 ++++ actions/addtocalendar.php | 36 ++++++++++++ actions/killrequest.php | 23 ++++++++ actions/manage.php | 105 ++++++++++++++++++++++++++++++++++ actions/remove_from_group.php | 8 +++ actions/request_personal_calendar.php | 18 ++++++ actions/toggle_personal_calendar.php | 30 ++++++++++ 7 files changed, 231 insertions(+) create mode 100644 actions/add_to_group.php create mode 100644 actions/addtocalendar.php create mode 100644 actions/killrequest.php create mode 100644 actions/manage.php create mode 100644 actions/remove_from_group.php create mode 100644 actions/request_personal_calendar.php create mode 100644 actions/toggle_personal_calendar.php (limited to 'actions') diff --git a/actions/add_to_group.php b/actions/add_to_group.php new file mode 100644 index 000000000..b8c18ebb0 --- /dev/null +++ b/actions/add_to_group.php @@ -0,0 +1,11 @@ +canEdit()) { + add_entity_relationship($event_id, "display_on_group", $group_id ); + system_message(elgg_echo('event_calendar:add_to_group:success')); +} +forward($event->getUrl()); +?> \ No newline at end of file diff --git a/actions/addtocalendar.php b/actions/addtocalendar.php new file mode 100644 index 000000000..cb83aab88 --- /dev/null +++ b/actions/addtocalendar.php @@ -0,0 +1,36 @@ +site->guid, elgg_echo('event_calendar:add_users_notify:subject'), + sprintf( + elgg_echo('event_calendar:add_users_notify:body'), + $user->name, + $event->title, + $event->getURL() + ) + ); + system_message(elgg_echo('event_calendar:request_approved')); + + } +} else { + register_error(elgg_echo('event_calendar:review_requests_error')); +} + +forward($_SERVER['HTTP_REFERER']); diff --git a/actions/killrequest.php b/actions/killrequest.php new file mode 100644 index 000000000..66257230c --- /dev/null +++ b/actions/killrequest.php @@ -0,0 +1,23 @@ +guid, 'event_calendar_request', $event->guid)) + { + remove_entity_relationship($user->guid, 'event_calendar_request', $event->guid); + system_message(elgg_echo('event_calendar:requestkilled')); + } + + forward($_SERVER['HTTP_REFERER']); + +?> \ No newline at end of file diff --git a/actions/manage.php b/actions/manage.php new file mode 100644 index 000000000..5acf5c279 --- /dev/null +++ b/actions/manage.php @@ -0,0 +1,105 @@ + + * @copyright Radagast Solutions 2008 + * @link http://radagast.biz/ + * + */ + +// Load RIBA event model +require_once(dirname(dirname(__FILE__)) . "/models/model.php"); + +gatekeeper(); + +$event_action = get_input('event_action',''); +if ($event_action == 'add_event' || $event_action == 'manage_event') { + $result = event_calendar_set_event_from_form(); + if ($result->success) { + if ($event_action == 'manage_event') { + add_to_river('river/object/event_calendar/update','update',$_SESSION['user']->guid,$result->event->guid); + system_message(elgg_echo('event_calendar:manage_event_response')); + } else { + $event_calendar_autopersonal = get_plugin_setting('autopersonal', 'event_calendar'); + if (!$event_calendar_autopersonal || ($event_calendar_autopersonal == 'yes')) { + event_calendar_add_personal_event($result->event->guid,$_SESSION['user']->guid); + } + add_to_river('river/object/event_calendar/create','create',$_SESSION['user']->guid,$result->event->guid); + system_message(elgg_echo('event_calendar:add_event_response')); + } + + forward($result->event->getURL()); + } else { + // redisplay form with error message + register_error(elgg_echo('event_calendar:manage_event_error')); + $group_guid = (int) get_input('group_guid',0); + + if ($result->form_data->event_id) { + $event = get_entity($result->form_data->event_id); + if (!$event) { + register_error(elgg_echo('event_calendar:no_such_event_edit_error')); + forward(); + } else { + set_page_owner($event->container_guid); + if (page_owner_entity() instanceof ElggGroup) { + set_context('groups'); + } + } + + $title = elgg_echo('event_calendar:manage_event_title'); + } else { + $title = elgg_echo('event_calendar:add_event_title'); + if ($group_guid && $group = get_entity($group_guid)) { + // redefine context + set_context('groups'); + set_page_owner($group_guid); + } + } + $body = elgg_view('event_calendar/forms/manage_event', array('event'=>$result->form_data,'event_id'=>$result->form_data->event_id,'group_guid'=>$group_guid)); + + page_draw($title,elgg_view_layout("two_column_left_sidebar", '', elgg_view_title($title) . $body)); + } +} else if ($event_action == 'delete_event') { + $event_id = get_input('event_id',0); + if (($event_id = get_input('event_id',0)) && ($event = get_entity($event_id)) && $event->canEdit()) { + if (get_input('cancel','')) { + system_message(elgg_echo('event_calendar:delete_cancel_response')); + forward($event->getUrl()); + } else { + $container = get_entity($event->container_guid); + $event->delete(); + system_message(elgg_echo('event_calendar:delete_response')); + forward($container->getUrl()); + } + } else { + register_error(elgg_echo('event_calendar:error_delete')); + } +} else if ($event_action == 'add_personal') { + $event_id = get_input('event_id',0); + if (($event_id = get_input('event_id',0)) && ($event = get_entity($event_id))) { + $user_id = $_SESSION['user']->getGUID(); + if (!event_calendar_has_personal_event($event_id,$user_id)) { + if (event_calendar_add_personal_event($event_id,$user_id)) { + system_message(elgg_echo('event_calendar:add_to_my_calendar_response')); + } else { + register_error(elgg_echo('event_calendar:add_to_my_calendar_error')); + } + forward($event->getUrl()); + } + } +} else if ($event_action == 'remove_personal') { + $event_id = get_input('event_id',0); + if (($event_id = get_input('event_id',0)) && ($event = get_entity($event_id))) { + event_calendar_remove_personal_event($event_id,$_SESSION['user']->getGUID()); + system_message(elgg_echo('event_calendar:remove_from_my_calendar_response')); + forward($event->getUrl()); + } +} + +forward(); + +?> \ No newline at end of file diff --git a/actions/remove_from_group.php b/actions/remove_from_group.php new file mode 100644 index 000000000..4a7185245 --- /dev/null +++ b/actions/remove_from_group.php @@ -0,0 +1,8 @@ +getUrl()); +?> \ No newline at end of file diff --git a/actions/request_personal_calendar.php b/actions/request_personal_calendar.php new file mode 100644 index 000000000..4160326a6 --- /dev/null +++ b/actions/request_personal_calendar.php @@ -0,0 +1,18 @@ +getSubtype() == 'event_calendar')) { + if (event_calendar_send_event_request($event,$user_id)) { + system_message(elgg_echo('event_calendar:request_event_response')); + } else { + register_error(elgg_echo('event_calendar:request_event_error')); + } + + forward($event->getUrl()); + + exit; +} + +forward(); diff --git a/actions/toggle_personal_calendar.php b/actions/toggle_personal_calendar.php new file mode 100644 index 000000000..f36b5836f --- /dev/null +++ b/actions/toggle_personal_calendar.php @@ -0,0 +1,30 @@ + \ No newline at end of file -- cgit v1.2.3