diff options
author | Kevin Jardine <kevinjardine@yahoo.com> | 2011-09-26 12:42:11 +0200 |
---|---|---|
committer | Kevin Jardine <kevinjardine@yahoo.com> | 2011-09-26 12:42:11 +0200 |
commit | 804dfcf6c4b5b6380d607c8ec6b843d56ac82247 (patch) | |
tree | cc81ecb76a5f1422100d521b9fe3b93166fcdf3e /actions/event_calendar/toggle_personal_calendar.php | |
parent | 6b20e80c9d577a3eeeb570a6d9fd706fe619709b (diff) | |
download | elgg-804dfcf6c4b5b6380d607c8ec6b843d56ac82247.tar.gz elgg-804dfcf6c4b5b6380d607c8ec6b843d56ac82247.tar.bz2 |
major changes for Elgg 1.8
Diffstat (limited to 'actions/event_calendar/toggle_personal_calendar.php')
-rw-r--r-- | actions/event_calendar/toggle_personal_calendar.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/actions/event_calendar/toggle_personal_calendar.php b/actions/event_calendar/toggle_personal_calendar.php new file mode 100644 index 000000000..26192953f --- /dev/null +++ b/actions/event_calendar/toggle_personal_calendar.php @@ -0,0 +1,32 @@ +<?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()); +$other = get_input('other',''); +if ($other) { + $remove_response = elgg_echo('event_calendar:added_to_the_calendar'); + $add_response = elgg_echo('event_calendar:removed_from_the_calendar'); + $add_error = elgg_echo('event_calendar:add_to_the_calendar_error'); +} else { + $remove_response = elgg_echo('event_calendar:remove_from_my_calendar_response'); + $add_response = elgg_echo('event_calendar:add_to_my_calendar_response'); + $add_error = elgg_echo('event_calendar:add_to_my_calendar_error'); +} +// three character prefix to indicate success or failure + +if (event_calendar_has_personal_event($event_guid,$user_guid)) { + $button_text = elgg_echo('event_calendar:add_to_the_calendar'); + event_calendar_remove_personal_event($event_guid,$user_guid); + $response = array('success'=>TRUE, 'message' => $remove_response, 'button_text'=>$button_text); +} else { + if (event_calendar_add_personal_event($event_guid,$user_guid)) { + $button_text = elgg_echo('event_calendar:remove_from_the_calendar_button'); + $response = array('success'=>TRUE, 'message' => $add_response, 'button_text'=>$button_text); + } else { + $response = array('success'=>FALSE, 'message' =>$add_error); + } +} + +echo json_encode($response); + +exit; |