Esempio n. 1
0
function display_event()
{
    global $vars;
    if (!empty($vars['contentType']) && $vars['contentType'] == 'json') {
        return display_event_json();
    }
    if (isset($vars['oid'])) {
        return display_event_by_oid($vars['oid']);
    }
    if (isset($vars['eid'])) {
        return display_event_by_eid($vars['eid']);
    }
    // If we get here, we did something wrong
    soft_error(__("Invalid arguments."));
}
Esempio n. 2
0
function display_event()
{
    global $vars, $phpcdb, $phpc_year, $phpc_month, $phpc_day, $phpc_cal;
    if (!empty($vars['content']) && $vars['content'] == 'json') {
        return display_event_json();
    }
    if (isset($vars['oid'])) {
        $entry = $phpcdb->get_event_by_oid($vars['oid']);
        if (!$entry) {
            return tag('p', __('There is no event for that OID.'));
        }
        $event = new PhpcEvent($entry);
    } elseif (isset($vars['eid'])) {
        $entry = $phpcdb->get_event_by_eid($vars['eid']);
        if (!$entry) {
            return tag('p', __('There is no event with that EID.'));
        }
        $event = new PhpcEvent($entry);
    }
    if (!isset($event)) {
        soft_error(__("Invalid arguments."));
    }
    if (!$event->can_read()) {
        return tag('p', __("You do not have permission to read this event."));
    }
    $event_header = tag('div', attributes('class="phpc-event-header"'), tag('div', __('created by') . ' ', tag('cite', $event->get_author()), ' ' . __('on') . ' ' . $event->get_ctime_string()));
    if (!empty($event->mtime)) {
        $event_header->add(tag('div', __('Last modified on '), $event->get_mtime_string()));
    }
    $category = $event->get_category();
    if (!empty($category)) {
        $event_header->add(tag('div', __('Category') . ': ' . $category));
    }
    // Add modify/delete links if this user has access to this event.
    $event_menu = '';
    if ($event->can_modify()) {
        $event_menu = tag('div', attrs('class="phpc-bar ui-widget-content"'), create_event_link(__('Modify'), 'event_form', $event->get_eid()), "\n", create_event_link(__('Delete'), 'event_delete', $event->get_eid(), attrs('class="phpc-confirm"')));
    }
    $desc_tag = tag('div', attributes('class="phpc-desc"'), tag('h3', __("Description")), tag('p', $event->get_desc()));
    $occurrences_tag = tag('ul');
    $occurrences = $phpcdb->get_occurrences_by_eid($event->get_eid());
    $set_date = false;
    foreach ($occurrences as $occurrence) {
        if (!$set_date) {
            $phpc_year = $occurrence->get_start_year();
            $phpc_month = $occurrence->get_start_month();
            $phpc_day = $occurrence->get_start_day();
        }
        $oid = $occurrence->get_oid();
        $occ_tag = tag('li', attrs('class="ui-widget-content"'), $occurrence->get_date_string() . ' ' . __('at') . ' ' . $occurrence->get_time_span_string());
        if ($event->can_modify()) {
            $occ_tag->add(" ", create_occurrence_link(__('Edit'), 'occur_form', $oid), " ", create_occurrence_link(__('Remove'), 'occurrence_delete', $oid, attrs('class="phpc-confirm-occ"')));
        }
        $occurrences_tag->add($occ_tag);
    }
    // Add occurrence link if this user has access to this event.
    $occurrences_menu = '';
    if ($event->can_modify()) {
        $occurrences_menu = tag('div', attrs('class="phpc-bar ui-widget-content"'), create_event_link(__('Add Occurrence'), 'occur_form', $event->get_eid()));
    }
    foreach ($event->get_fields() as $field) {
        $def = $phpc_cal->get_field($field['fid']);
        $event_header->add(tag('div', $def['name'] . ": " . $field['value']));
    }
    $dialog = tag('div', attrs('id="phpc-dialog"', 'title="' . __("Confirmation required") . '"'), __("Permanently delete this event?"));
    $dialog2 = tag('div', attrs('id="phpc-dialog-occ"', 'title="' . __("Confirmation required") . '"'), __("Permanently delete this occurrence?"));
    return tag('div', attributes('class="phpc-main phpc-event"'), $dialog, $dialog2, $event_menu, tag('h2', $event->get_subject()), $event_header, $desc_tag, tag('div', attrs('class="phpc-occ"'), tag('h3', __('Occurrences')), $occurrences_menu, $occurrences_tag));
}