aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/event_calendar/add_personal.php17
-rw-r--r--actions/event_calendar/delete.php21
-rw-r--r--actions/event_calendar/edit.php51
-rw-r--r--actions/event_calendar/remove_personal.php12
-rw-r--r--actions/event_calendar/request_personal_calendar.php16
-rw-r--r--actions/manage.php105
-rw-r--r--actions/request_personal_calendar.php18
7 files changed, 117 insertions, 123 deletions
diff --git a/actions/event_calendar/add_personal.php b/actions/event_calendar/add_personal.php
new file mode 100644
index 000000000..fd6f6cee2
--- /dev/null
+++ b/actions/event_calendar/add_personal.php
@@ -0,0 +1,17 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+
+$event_guid = get_input('guid',0);
+$event = get_entity($event_guid);
+if (elgg_instanceof($event,'object','event_calendar')) {
+ $user_guid = elgg_get_logged_in_user_guid();
+ if (!event_calendar_has_personal_event($event_guid,$user_guid)) {
+ if (event_calendar_add_personal_event($event_guid,$user_guid)) {
+ system_message(elgg_echo('event_calendar:add_to_my_calendar_response'));
+ } else {
+ register_error(elgg_echo('event_calendar:add_to_my_calendar_error'));
+ }
+ }
+}
+
+forward(REFERER); \ No newline at end of file
diff --git a/actions/event_calendar/delete.php b/actions/event_calendar/delete.php
new file mode 100644
index 000000000..dd8a7ef22
--- /dev/null
+++ b/actions/event_calendar/delete.php
@@ -0,0 +1,21 @@
+<?php
+$event_guid = get_input('guid',0);
+$event = get_entity($event_guid);
+if (elgg_instanceof($event,'object','event_calendar') && $event->canEdit()) {
+ if (get_input('cancel','')) {
+ system_message(elgg_echo('event_calendar:delete_cancel_response'));
+ } else {
+ $container = get_entity($event->container_guid);
+ $event->delete();
+ system_message(elgg_echo('event_calendar:delete_response'));
+ if (elgg_instanceof($container,'group')) {
+ forward('event_calendar/group/'.$container->guid);
+ } else {
+ forward('event_calendar/list');
+ }
+ }
+} else {
+ register_error(elgg_echo('event_calendar:error_delete'));
+}
+
+forward(REFERER); \ No newline at end of file
diff --git a/actions/event_calendar/edit.php b/actions/event_calendar/edit.php
new file mode 100644
index 000000000..2365d3965
--- /dev/null
+++ b/actions/event_calendar/edit.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * Edit action
+ *
+ * @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/
+ *
+ */
+
+elgg_load_library('elgg:event_calendar');
+
+// start a new sticky form session in case of failure
+elgg_make_sticky_form('event_calendar');
+
+$event_guid = get_input('event_guid',0);
+$group_guid = get_input('group_guid',0);
+$event = event_calendar_set_event_from_form($event_guid,$group_guid);
+if ($event) {
+ // remove sticky form entries
+ elgg_clear_sticky_form('event_calendar');
+ $user_guid = elgg_get_logged_in_user_guid();
+ if ($event_guid) {
+ add_to_river('river/object/event_calendar/update','update',$user_guid,$event_guid);
+ system_message(elgg_echo('event_calendar:manage_event_response'));
+ } else {
+ $event_calendar_autopersonal = elgg_get_plugin_setting('autopersonal', 'event_calendar');
+ if (!$event_calendar_autopersonal || ($event_calendar_autopersonal == 'yes')) {
+ event_calendar_add_personal_event($event_guid,$user_guid);
+ }
+ add_to_river('river/object/event_calendar/create','create',$user_guid,$event_guid);
+ system_message(elgg_echo('event_calendar:add_event_response'));
+ }
+
+ forward($event->getURL());
+} else {
+ // redisplay form with error message
+ register_error(elgg_echo('event_calendar:manage_event_error'));
+ if ($event_guid) {
+ forward('event_calendar/edit/'.$event_guid);
+ } else {
+ if ($group_guid) {
+ forward('event_calendar/add/'.$group_guid);
+ } else {
+ forward('event_calendar/add/');
+ }
+ }
+}
diff --git a/actions/event_calendar/remove_personal.php b/actions/event_calendar/remove_personal.php
new file mode 100644
index 000000000..1308b17e9
--- /dev/null
+++ b/actions/event_calendar/remove_personal.php
@@ -0,0 +1,12 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+
+$event_guid = get_input('guid',0);
+$event = get_entity($event_guid);
+if (elgg_instanceof($event,'object','event_calendar')) {
+ $user_guid = elgg_get_logged_in_user_guid();
+ event_calendar_remove_personal_event($event_guid,$user_guid);
+ system_message(elgg_echo('event_calendar:remove_from_my_calendar_response'));
+}
+
+forward(REFERER);
diff --git a/actions/event_calendar/request_personal_calendar.php b/actions/event_calendar/request_personal_calendar.php
new file mode 100644
index 000000000..68c96e364
--- /dev/null
+++ b/actions/event_calendar/request_personal_calendar.php
@@ -0,0 +1,16 @@
+<?php
+// asks the event owner to add you to the event
+elgg_load_library('elgg:event_calendar');
+
+$event_guid = get_input('guid',0);
+$user_guid = elgg_get_logged_in_user_guid();
+$event = get_entity($event_guid);
+if (elgg_instanceof($event,'object','event_calendar')) {
+ if (event_calendar_send_event_request($event,$user_guid)) {
+ system_message(elgg_echo('event_calendar:request_event_response'));
+ } else {
+ register_error(elgg_echo('event_calendar:request_event_error'));
+ }
+}
+
+forward(REFERER);
diff --git a/actions/manage.php b/actions/manage.php
deleted file mode 100644
index 5acf5c279..000000000
--- a/actions/manage.php
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-
-/**
- * Manage actions
- *
- * @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 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/request_personal_calendar.php b/actions/request_personal_calendar.php
deleted file mode 100644
index 4160326a6..000000000
--- a/actions/request_personal_calendar.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-// asks the event owner to add you to the event
-$event_id = get_input('event_id',0);
-$user_id = get_loggedin_userid();
-$event = get_entity($event_id);
-if ($event && ($event->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();