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;
}
Esempio n. 2
0
/**
 * Add particular event calendar links/info to entity menu
 */
function event_calendar_entity_menu_setup($hook, $type, $return, $params)
{
    if (elgg_in_context('widgets')) {
        return $return;
    }
    $entity = $params['entity'];
    $handler = elgg_extract('handler', $params, false);
    if ($handler != 'event_calendar') {
        return $return;
    }
    if (elgg_is_active_plugin('event_poll') && $entity->canEdit() && $entity->schedule_type == 'poll') {
        $options = array('name' => 'schedule', 'text' => elgg_echo('event_poll:schedule_button'), 'title' => elgg_echo('event_poll:schedule_button'), 'href' => 'event_poll/vote/' . $entity->guid, 'priority' => 150);
        $return[] = ElggMenuItem::factory($options);
    }
    $user_guid = elgg_get_logged_in_user_guid();
    if ($user_guid) {
        $calendar_status = event_calendar_personal_can_manage($entity, $user_guid);
        if ($calendar_status == 'open') {
            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 ($calendar_status == 'closed') {
                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_get_plugin_setting('ical_import_export', 'event_calendar') == "yes") {
            $url = elgg_get_site_url() . 'action/event_calendar/export?filter=' . $entity->guid;
            $options = array('name' => 'ical_export', 'text' => elgg_view('output/img', array('src' => elgg_get_simplecache_url('event_calendar/ics.png'))), 'href' => elgg_add_action_tokens_to_url($url), 'priority' => 1000);
            $return[] = ElggMenuItem::factory($options);
        }
    }
    return $return;
}