コード例 #1
0
ファイル: functions.php プロジェクト: hypeJunction/events_ui
/**
 * Register title menu items for an event
 *
 * @param Event $event
 * @return void
 */
function register_event_title_menu($event, $ts = null, $calendar = null)
{
    if (!$event instanceof Event) {
        return;
    }
    $calendar_count = 0;
    if (elgg_is_logged_in()) {
        $calendar_count = Calendar::getCalendars(elgg_get_logged_in_user_entity(), true);
    }
    if ($calendar_count) {
        // may be different than the calendar being viewed
        // make the add/remove button work for the current calendar if they own it
        // or their default calendar if they're viewing another calendar
        if ($calendar->owner_guid == elgg_get_logged_in_user_guid()) {
            $mycalendar = $calendar;
        } else {
            $mycalendar = Calendar::getPublicCalendar(elgg_get_logged_in_user_entity());
        }
        $text = elgg_echo('events:add_to_calendar:default');
        $add_remove_calendar = $mycalendar->guid;
        if ($mycalendar->hasEvent($event)) {
            $text = elgg_echo('events:remove_from_calendar:default');
            $add_remove_calendar = '';
        }
        elgg_register_menu_item('title', array('name' => 'add_to_calendar', 'href' => elgg_http_add_url_query_elements('action/calendar/add_event', array('event_guid' => $event->guid, 'calendars[]' => $add_remove_calendar)), 'is_action' => true, 'data-object-event' => true, 'data-guid' => $event->guid, 'text' => $text, 'data-calendar-count' => $calendar_count, 'link_class' => 'elgg-button elgg-button-action events-ui-event-action-addtocalendar', 'priority' => 100));
    }
    if ($event->canEdit()) {
        elgg_register_menu_item('title', array('name' => 'delete', 'text' => elgg_echo('events_ui:cancel'), 'href' => 'action/events/cancel?guid=' . $event->guid . '&ts=' . $ts, 'is_action' => true, 'link_class' => 'elgg-button elgg-button-delete elgg-requires-confirmation events-ui-event-action-cancel', 'data-object-event' => true, 'data-guid' => $event->guid, 'priority' => 300));
    }
    if ($event->canEdit() && $event->isRecurring()) {
        elgg_register_menu_item('title', array('name' => 'delete_all', 'text' => elgg_echo('events_ui:cancel:all'), 'href' => 'action/events/delete?guid=' . $event->guid, 'is_action' => true, 'link_class' => 'elgg-button elgg-button-delete elgg-requires-confirmation events-ui-event-action-cancel-all', 'rel' => elgg_echo('events_ui:cancel:all:confirm'), 'data-object-event' => true, 'data-guid' => $event->guid, 'priority' => 400));
    }
}
コード例 #2
0
ファイル: picker.php プロジェクト: hypeJunction/events_ui
<?php

namespace Events\UI;

use Events\API\Calendar;
if (!elgg_is_logged_in()) {
    return;
}
$calendars = Calendar::getCalendars(elgg_get_logged_in_user_entity());
$options = array();
$value = array();
foreach ($calendars as $c) {
    /* @var $c Calendar */
    $title = $c->getDisplayName();
    $options[$title] = $c->guid;
    if ($c->hasEvent($vars['entity'])) {
        $value[] = $c->guid;
    }
}
$body .= elgg_view('output/longtext', array('value' => elgg_echo('events:calendar:picker:help'), 'class' => 'elgg-subtext'));
$body .= elgg_view('input/checkboxes', array('name' => 'calendars', 'value' => $value, 'options' => $options));
$body .= '<div class="elgg-foot mtm">';
$body .= elgg_view('input/hidden', array('name' => 'event_guid', 'value' => $vars['guid']));
$body .= elgg_view('input/submit', array('value' => elgg_echo('submit')));
$body .= '</div>';
$form = elgg_view('input/form', array('action' => 'action/calendar/add_event', 'method' => 'post', 'body' => $body, 'class' => 'elgg-form-calendar-add-event'));
$title = elgg_echo('events:calendar:picker:title');
echo elgg_view_module('info', $title, $form);