aboutsummaryrefslogtreecommitdiff
path: root/trunk/actions
diff options
context:
space:
mode:
authorKevin Jardine <kevinjardine@yahoo.com>2011-06-27 12:49:05 +0200
committerKevin Jardine <kevinjardine@yahoo.com>2011-06-27 12:49:05 +0200
commitc07218b9c7b256e998f0a31c0226b3bd6d8011d7 (patch)
treeb13c83d01bf4cb488a783a4b65cdfc9837bdc514 /trunk/actions
parent446a0679509f2206cbf26f4a795fe0468b715f64 (diff)
downloadelgg-c07218b9c7b256e998f0a31c0226b3bd6d8011d7.tar.gz
elgg-c07218b9c7b256e998f0a31c0226b3bd6d8011d7.tar.bz2
added main code
Diffstat (limited to 'trunk/actions')
-rw-r--r--trunk/actions/add_to_group.php11
-rw-r--r--trunk/actions/addtocalendar.php36
-rw-r--r--trunk/actions/killrequest.php23
-rw-r--r--trunk/actions/manage.php105
-rw-r--r--trunk/actions/remove_from_group.php8
-rw-r--r--trunk/actions/request_personal_calendar.php18
-rw-r--r--trunk/actions/toggle_personal_calendar.php30
7 files changed, 231 insertions, 0 deletions
diff --git a/trunk/actions/add_to_group.php b/trunk/actions/add_to_group.php
new file mode 100644
index 000000000..b8c18ebb0
--- /dev/null
+++ b/trunk/actions/add_to_group.php
@@ -0,0 +1,11 @@
+<?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());
+?> \ No newline at end of file
diff --git a/trunk/actions/addtocalendar.php b/trunk/actions/addtocalendar.php
new file mode 100644
index 000000000..cb83aab88
--- /dev/null
+++ b/trunk/actions/addtocalendar.php
@@ -0,0 +1,36 @@
+<?php
+
+// this action allows an admin or event owner to approve a calendar request
+
+// Load configuration
+global $CONFIG;
+
+gatekeeper();
+
+$user_guid = get_input('user_guid', get_loggedin_userid());
+$event_id = get_input('event_id');
+
+$user = get_entity($user_guid);
+$event = get_entity($event_id);
+
+// If join request made
+if (event_calendar_personal_can_manage($event,$user_guid)
+ && check_entity_relationship($user_guid, 'event_calendar_request', $event_id)) {
+ if (event_calendar_add_personal_event($event_id,$user_guid)) {
+ remove_entity_relationship($user_guid, 'event_calendar_request', $event_id);
+ 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'));
+}
+
+forward($_SERVER['HTTP_REFERER']);
diff --git a/trunk/actions/killrequest.php b/trunk/actions/killrequest.php
new file mode 100644
index 000000000..66257230c
--- /dev/null
+++ b/trunk/actions/killrequest.php
@@ -0,0 +1,23 @@
+<?php
+
+ // Load configuration
+ global $CONFIG;
+
+ gatekeeper();
+
+ $user_guid = get_input('user_guid', get_loggedin_userid());
+ $event_id = get_input('event_id');
+
+ $user = get_entity($user_guid);
+ $event = get_entity($event_id);
+
+ // If join request made
+ if (event_calendar_personal_can_manage($event,$user_guid) && 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'));
+ }
+
+ forward($_SERVER['HTTP_REFERER']);
+
+?> \ No newline at end of file
diff --git a/trunk/actions/manage.php b/trunk/actions/manage.php
new file mode 100644
index 000000000..5acf5c279
--- /dev/null
+++ b/trunk/actions/manage.php
@@ -0,0 +1,105 @@
+<?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/trunk/actions/remove_from_group.php b/trunk/actions/remove_from_group.php
new file mode 100644
index 000000000..4a7185245
--- /dev/null
+++ b/trunk/actions/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/trunk/actions/request_personal_calendar.php b/trunk/actions/request_personal_calendar.php
new file mode 100644
index 000000000..4160326a6
--- /dev/null
+++ b/trunk/actions/request_personal_calendar.php
@@ -0,0 +1,18 @@
+<?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();
diff --git a/trunk/actions/toggle_personal_calendar.php b/trunk/actions/toggle_personal_calendar.php
new file mode 100644
index 000000000..f36b5836f
--- /dev/null
+++ b/trunk/actions/toggle_personal_calendar.php
@@ -0,0 +1,30 @@
+<?php
+$event_id = get_input('event_id',0);
+$user_id = get_input('user_id',get_loggedin_userid());
+$other = get_input('other','');
+$success = '@s@';
+$failure = '@f@';
+if ($other) {
+ $remove_response = elgg_echo('event_calendar:add_to_the_calendar');
+ $add_response = elgg_echo('event_calendar:remove_from_the_calendar');
+ $add_error = elgg_echo('event_calendar:add_to_the_calendar_error');
+} else {
+ $remove_response = $success.elgg_echo('event_calendar:remove_from_my_calendar_response');
+ $add_response = $success.elgg_echo('event_calendar:add_to_my_calendar_response');
+ $add_error = $failure.elgg_echo('event_calendar:add_to_my_calendar_error');
+}
+// three character prefix to indicate success or failure
+
+if (event_calendar_has_personal_event($event_id,$user_id)) {
+ event_calendar_remove_personal_event($event_id,$user_id);
+ echo $remove_response;
+} else {
+ if (event_calendar_add_personal_event($event_id,$user_id)) {
+ echo $success.$add_response;
+ } else {
+ echo $failure.$add_error;
+ }
+}
+
+exit;
+?> \ No newline at end of file