<?php

// A non-admin / non-event-creator only sees the button if they have the event on his/her personal calendar
// and it is at most 15 minutes before the conference starts.
// The button is removed for everyone (even admins) one day after the conference ends.
$conf = $vars['conf'];
if ($conf && $conf->application == 'bbb') {
    elgg_load_library('elgg:sched_conf');
    elgg_load_library('elgg:event_calendar');
    $user_guid = elgg_get_logged_in_user_guid();
    $event = sched_conf_get_event_for_conference($conf->guid);
    $termination_time = $event->real_end_time + 60 * 60 * 24;
    if ($termination_time < time()) {
        $in_time_window = FALSE;
    } else {
        if ($conf->canEdit()) {
            $in_time_window = TRUE;
        } else {
            if (event_calendar_has_personal_event($event->guid, $user_guid) && $event->start_date - 15 * 60 >= time()) {
                $in_time_window = TRUE;
            } else {
                $in_time_window = FALSE;
            }
        }
    }
    if ($in_time_window) {
        $button = elgg_view('output/url', array('href' => sched_conf_get_join_bbb_url($conf), 'text' => elgg_echo('sched_conf:join_conf_button'), 'class' => 'elgg-button elgg-button-action', 'target' => '_blank'));
        echo '<div class="sched-conf-join-button">' . $button . '</div>';
    }
}
Ejemplo n.º 2
0
function sched_conf_entity_menu_setup($hook, $type, $return, $params)
{
    if (elgg_in_context('widgets')) {
        return $return;
    }
    elgg_load_library('elgg:sched_conf');
    $entity = $params['entity'];
    $entity = sched_conf_get_event_for_conference($entity->guid);
    $handler = elgg_extract('handler', $params, false);
    if ($handler != 'sched_conf') {
        return $return;
    }
    $user_guid = elgg_get_logged_in_user_guid();
    if (event_calendar_personal_can_manage($entity, $user_guid)) {
        if (event_calendar_has_personal_event($entity->guid, $user_guid)) {
            $options = array('name' => 'personal_calendar', 'text' => elgg_echo('event_calendar:remove_from_the_calendar_menu_text'), 'title' => elgg_echo('event_calendar:remove_from_my_calendar'), 'href' => elgg_add_action_tokens_to_url("action/event_calendar/remove_personal?guid={$entity->guid}"), 'priority' => 150);
            $return[] = ElggMenuItem::factory($options);
        } else {
            if (!event_calendar_is_full($entity->guid) && !event_calendar_has_collision($entity->guid, $user_guid)) {
                $options = array('name' => 'personal_calendar', 'text' => elgg_echo('event_calendar:add_to_the_calendar_menu_text'), 'title' => elgg_echo('event_calendar:add_to_my_calendar'), 'href' => elgg_add_action_tokens_to_url("action/event_calendar/add_personal?guid={$entity->guid}"), 'priority' => 150);
                $return[] = ElggMenuItem::factory($options);
            }
        }
    } else {
        if (!event_calendar_has_personal_event($entity->guid, $user_guid) && !check_entity_relationship($user_guid, 'event_calendar_request', $entity->guid)) {
            $options = array('name' => 'personal_calendar', 'text' => elgg_echo('event_calendar:make_request_title'), 'title' => elgg_echo('event_calendar:make_request_title'), 'href' => elgg_add_action_tokens_to_url("action/event_calendar/request_personal_calendar?guid={$entity->guid}"), 'priority' => 150);
            $return[] = ElggMenuItem::factory($options);
        }
    }
    $count = event_calendar_get_users_for_event($entity->guid, 0, 0, true);
    if ($count == 1) {
        $calendar_text = elgg_echo('event_calendar:personal_event_calendars_link_one');
    } else {
        $calendar_text = elgg_echo('event_calendar:personal_event_calendars_link', array($count));
    }
    $options = array('name' => 'calendar_listing', 'text' => $calendar_text, 'title' => elgg_echo('event_calendar:users_for_event_menu_title'), 'href' => "event_calendar/display_users/{$entity->guid}", 'priority' => 150);
    $return[] = ElggMenuItem::factory($options);
    /*if (elgg_is_admin_logged_in() && (elgg_get_plugin_setting('allow_featured', 'event_calendar') == 'yes')) {
    		if ($event->featured) {
    			add_submenu_item(elgg_echo('event_calendar:unfeature'), $CONFIG->url . "action/event_calendar/unfeature?event_id=".$event_id.'&'.event_calendar_security_fields(), 'eventcalendaractions');
    		} else {
    			add_submenu_item(elgg_echo('event_calendar:feature'), $CONFIG->url . "action/event_calendar/feature?event_id=".$event_id.'&'.event_calendar_security_fields(), 'eventcalendaractions');
    		}
    	}*/
    return $return;
}
Ejemplo n.º 3
0
function sched_conf_set_event_from_form($conf_guid = 0, $group_guid = 0)
{
    // TODO - save conf, create associated event and add the current user to the event
    $fields = array('title', 'description', 'application', 'immediate', 'start_date', 'tags', 'access_id', 'group_guid');
    $user_guid = elgg_get_logged_in_user_guid();
    $required_fields = array('title', 'application');
    if ($conf_guid) {
        $conf = get_entity($conf_guid);
        if (!elgg_instanceof($conf, 'object', 'conference')) {
            // do nothing because this is a bad conference guid
            return FALSE;
        }
    } else {
        $conf = new ElggObject();
        $conf->subtype = 'conference';
        $conf->owner_guid = $user_guid;
        if ($group_guid) {
            $conf->container_guid = $group_guid;
        } else {
            $conf->container_guid = $user_guid;
        }
    }
    $missing_fields = FALSE;
    foreach ($fields as $fn) {
        $value = trim(get_input($fn, ''));
        if ($value === '' && in_array($fn, $required_fields)) {
            $missing_fields = TRUE;
            break;
        }
        $conf->{$fn} = $value;
    }
    if (!$missing_fields) {
        $sh = get_input('start_time_h', '');
        $sm = get_input('start_time_m', '');
        if (is_numeric($sh) && is_numeric($sm)) {
            // workaround for pulldown zero value bug
            $sh--;
            $sm--;
            $conf->start_time = $sh * 60 + $sm;
        } else {
            $conf->start_time = '';
        }
        if (is_numeric($conf->start_time)) {
            // Set start date to the Unix start time, if set.
            // This allows sorting by date *and* time.
            $conf->start_date += $conf->start_time * 60;
        }
        if ($conf->immediate === '' && (!$conf->start_date || !$conf->start_time)) {
            $missing_fields = TRUE;
        }
    }
    // handle the immediate case
    // set start date and start time to now
    if ($conf->immediate !== '') {
        $conf->start_date = time();
        $today = date('Y-m-d', $conf->start_date);
        $midnight = strtotime($today);
        $conf->start_time = (int) (($conf->start_date - $midnight) / (60 * 5)) * 5;
    }
    if (!$missing_fields && $conf->save()) {
        if ($conf_guid) {
            $event = sched_conf_get_event_for_conference($conf_guid);
            sched_conf_sync_event_for_conference($conf, $event);
        } else {
            $event = sched_conf_sync_event_for_conference($conf);
            add_entity_relationship($conf->guid, 'conference_has_event', $event->guid);
            if (elgg_plugin_exists('event_calendar')) {
                elgg_load_library('elgg:event_calendar');
                event_calendar_add_personal_event($event->guid, $user_guid);
            }
        }
        return $conf;
    }
    return FALSE;
}