aboutsummaryrefslogtreecommitdiff
path: root/mod/event_calendar/actions
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2013-11-09 16:24:39 +0100
committerSem <sembrestels@riseup.net>2013-11-09 16:24:39 +0100
commita9ac4c861335e60373c1e99b61372e6e0d6ac9f4 (patch)
tree84e660ad22367aab1697a1f910125f520243b882 /mod/event_calendar/actions
parent1f40407cb2d2f0edfc4cc5346f332f5c6adab022 (diff)
parentb011a80767e1062a394b7bbbc3be3d2959a5f773 (diff)
downloadelgg-a9ac4c861335e60373c1e99b61372e6e0d6ac9f4.tar.gz
elgg-a9ac4c861335e60373c1e99b61372e6e0d6ac9f4.tar.bz2
Add 'mod/event_calendar/' from commit 'b011a80767e1062a394b7bbbc3be3d2959a5f773'
git-subtree-dir: mod/event_calendar git-subtree-mainline: 1f40407cb2d2f0edfc4cc5346f332f5c6adab022 git-subtree-split: b011a80767e1062a394b7bbbc3be3d2959a5f773
Diffstat (limited to 'mod/event_calendar/actions')
-rw-r--r--mod/event_calendar/actions/event_calendar/add_personal.php17
-rw-r--r--mod/event_calendar/actions/event_calendar/add_to_group.php10
-rw-r--r--mod/event_calendar/actions/event_calendar/add_to_group_members.php15
-rw-r--r--mod/event_calendar/actions/event_calendar/addtocalendar.php33
-rw-r--r--mod/event_calendar/actions/event_calendar/delete.php21
-rw-r--r--mod/event_calendar/actions/event_calendar/edit.php55
-rw-r--r--mod/event_calendar/actions/event_calendar/join_conference.php20
-rw-r--r--mod/event_calendar/actions/event_calendar/killrequest.php23
-rw-r--r--mod/event_calendar/actions/event_calendar/manage_subscribers.php26
-rw-r--r--mod/event_calendar/actions/event_calendar/modify_full_calendar.php24
-rw-r--r--mod/event_calendar/actions/event_calendar/remove_from_group.php8
-rw-r--r--mod/event_calendar/actions/event_calendar/remove_from_group_members.php15
-rw-r--r--mod/event_calendar/actions/event_calendar/remove_personal.php12
-rw-r--r--mod/event_calendar/actions/event_calendar/request_personal_calendar.php16
-rw-r--r--mod/event_calendar/actions/event_calendar/toggle_personal_calendar.php40
15 files changed, 335 insertions, 0 deletions
diff --git a/mod/event_calendar/actions/event_calendar/add_personal.php b/mod/event_calendar/actions/event_calendar/add_personal.php
new file mode 100644
index 000000000..ed4eb3092
--- /dev/null
+++ b/mod/event_calendar/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);
diff --git a/mod/event_calendar/actions/event_calendar/add_to_group.php b/mod/event_calendar/actions/event_calendar/add_to_group.php
new file mode 100644
index 000000000..b5eae4693
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/add_to_group.php
@@ -0,0 +1,10 @@
+<?php
+$event_id = get_input("event_id",0);
+$group_id = get_input("group_id",0);
+$event = get_entity($event_id);
+$group = get_entity($group_id);
+if ($group && $group->canEdit()) {
+ add_entity_relationship($event_id, "display_on_group", $group_id );
+ system_message(elgg_echo('event_calendar:add_to_group:success'));
+}
+forward($event->getUrl());
diff --git a/mod/event_calendar/actions/event_calendar/add_to_group_members.php b/mod/event_calendar/actions/event_calendar/add_to_group_members.php
new file mode 100644
index 000000000..d0d555b12
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/add_to_group_members.php
@@ -0,0 +1,15 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+$event_guid = get_input("event_guid",0);
+$event = get_entity($event_guid);
+$group = get_entity($event->container_guid);
+if (elgg_instanceof($group,'group') && elgg_instanceof($event,'object','event_calendar') && $group->canEdit()) {
+ $members = $group->getMembers(0,0);
+ foreach($members as $member) {
+ event_calendar_add_personal_event($event->guid,$member->guid);
+ }
+ system_message(elgg_echo('event_calendar:add_to_group_members:success'));
+} else {
+ register_error(elgg_echo('event_calendar:add_to_group_members:error'));
+}
+forward("event_calendar/manage_users/$event_guid");
diff --git a/mod/event_calendar/actions/event_calendar/addtocalendar.php b/mod/event_calendar/actions/event_calendar/addtocalendar.php
new file mode 100644
index 000000000..0144dfba1
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/addtocalendar.php
@@ -0,0 +1,33 @@
+<?php
+// this action allows an admin or event owner to approve a calendar request
+
+elgg_load_library('elgg:event_calendar');
+
+$user_guid = get_input('user_guid', elgg_get_logged_in_user_guid());
+$event_guid = get_input('event_guid');
+
+$user = get_entity($user_guid);
+$event = get_entity($event_guid);
+
+if (elgg_instanceof($event, 'object', 'event_calendar')
+ && elgg_instanceof($user, 'user')
+ && $event->canEdit()
+ && check_entity_relationship($user_guid, 'event_calendar_request', $event_guid)) {
+
+ if (event_calendar_add_personal_event($event_guid,$user_guid)) {
+ remove_entity_relationship($user_guid, 'event_calendar_request', $event_guid);
+ notify_user($user_guid, $CONFIG->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:approve'));
+}
+
+forward(REFERER);
diff --git a/mod/event_calendar/actions/event_calendar/delete.php b/mod/event_calendar/actions/event_calendar/delete.php
new file mode 100644
index 000000000..dd8a7ef22
--- /dev/null
+++ b/mod/event_calendar/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/mod/event_calendar/actions/event_calendar/edit.php b/mod/event_calendar/actions/event_calendar/edit.php
new file mode 100644
index 000000000..aef1a59cc
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/edit.php
@@ -0,0 +1,55 @@
+<?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'));
+ }
+
+ if ($event->schedule_type == 'poll') {
+ forward('event_poll/add/'.$event->guid);
+ }
+
+ 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/mod/event_calendar/actions/event_calendar/join_conference.php b/mod/event_calendar/actions/event_calendar/join_conference.php
new file mode 100644
index 000000000..9eb8f0da9
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/join_conference.php
@@ -0,0 +1,20 @@
+<?php
+// extended logic for BBB
+elgg_load_library('elgg:event_calendar');
+
+$event_guid = get_input('event_guid');
+$event = get_entity($event_guid);
+if (elgg_instanceof($event,'object','event_calendar')) {
+ // make sure that the conference still exists, and if not, try recreating it
+ if (event_calendar_conference_exists($event)) {
+ event_calendar_join_conference($event);
+ } else if (event_calendar_create_bbb_conf($event)) {
+ event_calendar_join_conference($event);
+ } else {
+ register_error(elgg_echo('event_calendar:couldnotjoin'));
+ forward($event->getURL());
+ }
+} else {
+ register_error(elgg_echo('event_calendar:error_nosuchevent'));
+ forward('event_calendar/list');
+}
diff --git a/mod/event_calendar/actions/event_calendar/killrequest.php b/mod/event_calendar/actions/event_calendar/killrequest.php
new file mode 100644
index 000000000..f4f3c3135
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/killrequest.php
@@ -0,0 +1,23 @@
+<?php
+// this action allows an admin or event owner to reject a calendar request
+
+elgg_load_library('elgg:event_calendar');
+
+$user_guid = get_input('user_guid', elgg_get_logged_in_user_guid());
+$event_guid = get_input('event_guid');
+
+$user = get_entity($user_guid);
+$event = get_entity($event_guid);
+
+if (elgg_instanceof($event, 'object', 'event_calendar')
+ && elgg_instanceof($user, 'user')
+ && $event->canEdit()
+ && check_entity_relationship($user_guid, 'event_calendar_request', $event_guid)) {
+
+ remove_entity_relationship($user->guid, 'event_calendar_request', $event_guid);
+ system_message(elgg_echo('event_calendar:requestkilled'));
+} else {
+ register_error(elgg_echo('event_calendar:review_requests:error:reject'));
+}
+
+forward(REFERER);
diff --git a/mod/event_calendar/actions/event_calendar/manage_subscribers.php b/mod/event_calendar/actions/event_calendar/manage_subscribers.php
new file mode 100644
index 000000000..079c3628f
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/manage_subscribers.php
@@ -0,0 +1,26 @@
+<?php
+$event_guid = get_input('event_guid');
+$event = get_entity($event_guid);
+$event_calendar_add_users = elgg_get_plugin_setting('add_users', 'event_calendar');
+if (($event_calendar_add_users == 'yes') && elgg_instanceof($event,'object','event_calendar') && $event->canEdit()) {
+ $members = get_input('members');
+ // clear the event from all personal calendars
+ remove_entity_relationships($event_guid, 'personal_event', TRUE);
+ // add event to personal calendars
+ $event_calendar_add_users_notify = elgg_get_plugin_setting('add_users_notify', 'event_calendar');
+ $site_guid = elgg_get_site_entity()->guid;
+ foreach ($members as $user_guid) {
+ add_entity_relationship($user_guid,'personal_event',$event_guid);
+ if ($event_calendar_add_users_notify == 'yes') {
+ $subject = elgg_echo('event_calendar:add_users_notify:subject');
+ $user = get_user($user_guid);
+ $message = elgg_echo('event_calendar:add_users_notify:body',array($user->name,$event->title,$event->getURL()));
+ notify_user($user_guid, $site_guid, $subject, $message, NULL, 'email');
+ }
+ }
+ system_message(elgg_echo('event_calendar:manage_subscribers:success'));
+ forward($event->getURL());
+} else {
+ register_error(elgg_echo('event_calendar:manage_subscribers:error'));
+ forward();
+}
diff --git a/mod/event_calendar/actions/event_calendar/modify_full_calendar.php b/mod/event_calendar/actions/event_calendar/modify_full_calendar.php
new file mode 100644
index 000000000..1e0bd3a01
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/modify_full_calendar.php
@@ -0,0 +1,24 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+$event_guid = get_input('event_guid',0);
+$day_delta = get_input('dayDelta');
+$minute_delta = get_input('minuteDelta','');
+$start_time = get_input('startTime','');
+$resend = get_input('resend','');
+$minutes = get_input('minutes');
+$iso_date = get_input('iso_date');
+$result = event_calendar_modify_full_calendar($event_guid,$day_delta,$minute_delta,$start_time,$resend,$minutes,$iso_date);
+if ($result) {
+ $response = array('success'=>TRUE);
+ // special handling for event polls
+ if (is_array($result)) {
+ $response['minutes'] = $result['minutes'];
+ $response['iso_date'] = $result['iso_date'];
+ }
+} else {
+ $response = array('success'=>FALSE, 'message' =>elgg_echo('event_calendar:modify_full_calendar:error'));
+}
+
+echo json_encode($response);
+
+exit;
diff --git a/mod/event_calendar/actions/event_calendar/remove_from_group.php b/mod/event_calendar/actions/event_calendar/remove_from_group.php
new file mode 100644
index 000000000..4a7185245
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/remove_from_group.php
@@ -0,0 +1,8 @@
+<?php
+$event_id = get_input("event_id",0);
+$group_id = get_input("group_id",0);
+$event = get_entity($event_id);
+remove_entity_relationship($event_id, "display_on_group", $group_id );
+system_message(elgg_echo('event_calendar:remove_from_group:success'));
+forward($event->getUrl());
+?> \ No newline at end of file
diff --git a/mod/event_calendar/actions/event_calendar/remove_from_group_members.php b/mod/event_calendar/actions/event_calendar/remove_from_group_members.php
new file mode 100644
index 000000000..a15b66c97
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/remove_from_group_members.php
@@ -0,0 +1,15 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+$event_guid = get_input("event_guid",0);
+$event = get_entity($event_guid);
+$group = get_entity($event->container_guid);
+if (elgg_instanceof($group,'group') && elgg_instanceof($event,'object','event_calendar') && $group->canEdit()) {
+ $members = $group->getMembers(0,0);
+ foreach($members as $member) {
+ event_calendar_remove_personal_event($event->guid,$member->guid);
+ }
+ system_message(elgg_echo('event_calendar:remove_from_group_members:success'));
+} else {
+ register_error(elgg_echo('event_calendar:remove_from_group_members:error'));
+}
+forward("event_calendar/manage_users/$event_guid");
diff --git a/mod/event_calendar/actions/event_calendar/remove_personal.php b/mod/event_calendar/actions/event_calendar/remove_personal.php
new file mode 100644
index 000000000..1308b17e9
--- /dev/null
+++ b/mod/event_calendar/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/mod/event_calendar/actions/event_calendar/request_personal_calendar.php b/mod/event_calendar/actions/event_calendar/request_personal_calendar.php
new file mode 100644
index 000000000..68c96e364
--- /dev/null
+++ b/mod/event_calendar/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/mod/event_calendar/actions/event_calendar/toggle_personal_calendar.php b/mod/event_calendar/actions/event_calendar/toggle_personal_calendar.php
new file mode 100644
index 000000000..8eb20e6b9
--- /dev/null
+++ b/mod/event_calendar/actions/event_calendar/toggle_personal_calendar.php
@@ -0,0 +1,40 @@
+<?php
+elgg_load_library('elgg:event_calendar');
+$event_guid = get_input('event_guid',0);
+$user_guid = get_input('user_guid',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');
+}
+
+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)) {
+ $event_calendar_add_users_notify = elgg_get_plugin_setting('add_users_notify', 'event_calendar');
+ if ($event_calendar_add_users_notify == 'yes') {
+ $subject = elgg_echo('event_calendar:add_users_notify:subject');
+ $user = get_user($user_guid);
+ $event = get_entity($event_guid);
+ $site_guid = elgg_get_site_entity()->guid;
+ $message = elgg_echo('event_calendar:add_users_notify:body',array($user->name,$event->title,$event->getURL()));
+ notify_user($user_guid, $site_guid, $subject, $message, NULL, 'email');
+ }
+ $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;