Example #1
0
 /**
  * RSVP to the event
  *
  * @param string  $type          type of the rsvp
  * @param number  $user_guid     guid of the user for whom the rsvp is changed
  * @param boolean $reset_program does the program need a reset with this rsvp
  * @param boolean $add_to_river  add an event to the river
  *
  * @return boolean
  */
 public function rsvp($type = EVENT_MANAGER_RELATION_UNDO, $user_guid = 0, $reset_program = true, $add_to_river = true)
 {
     global $EVENT_MANAGER_UNDO_REGISTRATION;
     $user_guid = sanitise_int($user_guid, false);
     if (empty($user_guid)) {
         $user_guid = elgg_get_logged_in_user_guid();
     }
     if (empty($user_guid)) {
         return false;
     }
     // check if it is a user
     $user_entity = get_user($user_guid);
     $event_guid = $this->getGUID();
     // remove registrations
     if ($type == EVENT_MANAGER_RELATION_UNDO) {
         if (empty($user_entity)) {
             // make sure we can remove the registration object
             $EVENT_MANAGER_UNDO_REGISTRATION = true;
             $registration_object = get_entity($user_guid);
             $registration_object->delete();
             // undo overrides
             $EVENT_MANAGER_UNDO_REGISTRATION = false;
         } else {
             if ($reset_program) {
                 if ($this->with_program) {
                     $this->relateToAllSlots(false, $user_guid);
                 }
                 $this->clearRegistrations($user_guid);
             }
         }
     }
     // remove current relationships
     delete_data("DELETE FROM " . elgg_get_config("dbprefix") . "entity_relationships WHERE guid_one={$event_guid} AND guid_two={$user_guid}");
     // remove river events
     if ($user_entity) {
         $params = array("subject_guid" => $user_guid, "object_guid" => $event_guid, "action_type" => "event_relationship");
         elgg_delete_river($params);
     }
     // add the new relationship
     if ($type && $type != EVENT_MANAGER_RELATION_UNDO && in_array($type, event_manager_event_get_relationship_options())) {
         $result = $this->addRelationship($user_guid, $type);
         if ($result && $add_to_river) {
             if ($user_entity) {
                 // add river events
                 if ($type != "event_waitinglist" && $type != "event_pending") {
                     elgg_create_river_item(array('view' => 'river/event_relationship/create', 'action_type' => 'event_relationship', 'subject_guid' => $user_guid, 'object_guid' => $event_guid));
                 }
             }
         }
     } else {
         if ($this->hasEventSpotsLeft() || $this->hasSlotSpotsLeft()) {
             $this->generateNewAttendee();
         }
         $result = true;
     }
     if ($this->notify_onsignup && $type !== EVENT_MANAGER_RELATION_ATTENDING_PENDING) {
         $this->notifyOnRsvp($type, $user_guid);
     }
     return $result;
 }
Example #2
0
<?php

$event = $vars["entity"];
$event_relationship_options = event_manager_event_get_relationship_options();
if (elgg_is_logged_in()) {
    if ($event->openForRegistration()) {
        $user_relation = $event->getRelationshipByUser();
        echo "<span class='event_manager_event_actions'>";
        if ($user_relation) {
            echo "<b>" . elgg_echo("event_manager:event:rsvp") . "</b>";
        } else {
            echo elgg_echo("event_manager:event:rsvp");
        }
        echo "</span>";
        echo "<ul class='event_manager_event_actions_drop_down event_manager_event_select_relationship'>";
        foreach ($event_relationship_options as $rel) {
            if ($rel == EVENT_MANAGER_RELATION_ATTENDING || $event->{$rel}) {
                if ($rel == EVENT_MANAGER_RELATION_ATTENDING) {
                    if (!$event->hasEventSpotsLeft() && !$event->waiting_list_enabled) {
                        continue;
                    }
                }
                if ($rel == $user_relation) {
                    echo "<li class='selected'>" . elgg_echo('event_manager:event:relationship:' . $rel) . "</li>";
                } else {
                    if ($rel != EVENT_MANAGER_RELATION_ATTENDING_WAITINGLIST) {
                        echo "<li>" . elgg_view("output/url", array("is_action" => true, "href" => "action/event_manager/event/rsvp?guid=" . $event->getGUID() . "&type=" . $rel, "text" => elgg_echo('event_manager:event:relationship:' . $rel))) . "</li>";
                    }
                }
            }
        }
Example #3
0
 /**
  * RSVP to the event
  *
  * @param string  $type           type of the rsvp
  * @param number  $user_guid      guid of the user for whom the rsvp is changed
  * @param boolean $reset_program  does the program need a reset with this rsvp
  * @param boolean $add_to_river   add an event to the river
  * @param boolean $notify_on_rsvp control if a (potential)notification is send
  *
  * @return boolean
  */
 public function rsvp($type = EVENT_MANAGER_RELATION_UNDO, $user_guid = 0, $reset_program = true, $add_to_river = true, $notify_on_rsvp = true)
 {
     $user_guid = sanitise_int($user_guid, false);
     if (empty($user_guid)) {
         $user_guid = elgg_get_logged_in_user_guid();
     }
     if (empty($user_guid)) {
         return false;
     }
     // check if it is a user
     $user_entity = get_user($user_guid);
     $event_guid = $this->getGUID();
     // remove registrations
     if ($type == EVENT_MANAGER_RELATION_UNDO) {
         $this->undoRegistration($user_guid, $reset_program);
     }
     // remove current relationships
     delete_data("DELETE FROM " . elgg_get_config("dbprefix") . "entity_relationships WHERE guid_one={$event_guid} AND guid_two={$user_guid}");
     // remove river events
     if ($user_entity) {
         elgg_delete_river(['subject_guid' => $user_guid, 'object_guid' => $event_guid, 'action_type' => 'event_relationship']);
     }
     // add the new relationship
     if ($type && $type != EVENT_MANAGER_RELATION_UNDO && in_array($type, event_manager_event_get_relationship_options())) {
         $result = $this->addRelationship($user_guid, $type);
         if ($result && $add_to_river) {
             if ($user_entity) {
                 // add river events
                 if ($type != 'event_waitinglist' && $type != 'event_pending') {
                     elgg_create_river_item(['view' => 'river/event_relationship/create', 'action_type' => 'event_relationship', 'subject_guid' => $user_guid, 'object_guid' => $event_guid]);
                 }
             }
         }
     } else {
         if ($this->hasEventSpotsLeft() || $this->hasSlotSpotsLeft()) {
             $this->generateNewAttendee();
         }
         $result = true;
     }
     if ($notify_on_rsvp) {
         $this->notifyOnRsvp($type, $user_guid);
     }
     return $result;
 }