예제 #1
0
 function get_league()
 {
     if (!$this->league) {
         $this->league = League::load(array('league_id' => $this->game->league_id));
         league_add_to_menu($this->league);
     }
     return $this->league;
 }
예제 #2
0
 function __construct($id)
 {
     $this->league = League::load(array('league_id' => $id));
     if (!$this->league) {
         error_exit("That league does not exist");
     }
     league_add_to_menu($this->league);
 }
예제 #3
0
function menu_build()
{
    global $lr_session, $CONFIG;
    menu_add_child('', '_root', 'Root of Menus');
    menu_add_child('_root', 'help', 'Help', array('link' => "docs/help", 'weight' => -25));
    if (!$lr_session->is_valid()) {
        menu_add_child('_root', 'login', 'Log In', array('link' => 'logout', 'weight' => '20'));
        return;
    }
    menu_add_child('_root', 'logout', 'Log Out', array('link' => 'logout', 'weight' => '20'));
    menu_add_child('_root', 'home', 'Home', array('link' => 'home', 'weight' => '-20'));
    menu_add_child('_root', 'season', 'Seasons');
    menu_add_child('season', 'season/list', 'list seasons', array('link' => 'season/list'));
    if ($lr_session->is_admin()) {
        # Notes
        menu_add_child('_root', 'note', 'Notes');
        # Handler/settings.php
        menu_add_child('_root', 'settings', 'Settings');
        menu_add_child('settings', 'settings/global', 'global settings', array('link' => 'settings/global'));
        menu_add_child('settings', 'settings/feature', 'feature settings', array('link' => 'settings/feature'));
        menu_add_child('settings', 'settings/rss', 'rss settings', array('link' => 'settings/rss'));
        # Seasons
        if ($lr_session->has_permission('season', 'create')) {
            menu_add_child('season', 'season/create', "create season", array('link' => "season/create", 'weight' => 1));
        }
        # Handler/statistics.php
        menu_add_child('_root', 'statistics', 'Statistics');
    }
    # Handler/field.php
    menu_add_child('_root', 'field', 'Fields');
    menu_add_child('field', 'field/list', 'list fields', array('link' => 'field/list'));
    if ($lr_session->has_permission('field', 'create')) {
        menu_add_child('field', 'field/create', 'create field', array('weight' => 6, 'link' => 'field/create'));
    }
    if ($lr_session->has_permission('field', 'view reports')) {
        menu_add_child('field', 'fieldreport/day', 'field reports', array('weight' => 5, 'link' => 'fieldreport/day'));
    }
    # Handler/league.php
    if ($lr_session->is_player()) {
        menu_add_child('_root', 'league', 'Leagues');
        menu_add_child('league', 'league/list', 'list leagues', array('link' => 'league/list'));
        if ($lr_session->is_valid()) {
            while (list(, $league) = each($lr_session->user->leagues)) {
                league_add_to_menu($league);
            }
            reset($lr_session->user->leagues);
        }
        if ($lr_session->has_permission('league', 'create')) {
            menu_add_child('league', 'league/create', "create league", array('link' => "league/create", 'weight' => 1));
        }
    }
    # Handler/event.php
    if (variable_get('registration', 0)) {
        if ($lr_session->has_permission('event', 'list')) {
            menu_add_child('_root', 'event', 'Registration');
            menu_add_child('event', 'event/list', 'list events', array('link' => 'event/list'));
        }
        if ($lr_session->has_permission('event', 'create')) {
            menu_add_child('event', 'event/create', 'create event', array('weight' => 5, 'link' => 'event/create'));
        }
    }
    # Handler/person.php
    $id = $lr_session->attr_get('user_id');
    menu_add_child('_root', 'myaccount', 'My Account', array('weight' => -10, 'link' => "person/view/{$id}"));
    menu_add_child('myaccount', 'myaccount/edit', 'edit account', array('weight' => -10, 'link' => "person/edit/{$id}"));
    menu_add_child('myaccount', 'myaccount/pass', 'change password', array('link' => "person/changepassword/{$id}"));
    menu_add_child('myaccount', 'myaccount/signwaiver', 'view/sign player waiver', array('link' => "person/signwaiver", 'weight' => 3));
    if (variable_get('dog_questions', 1) && $lr_session->attr_get('has_dog') == 'Y') {
        menu_add_child('myaccount', 'myaccount/signdogwaiver', 'view/sign dog waiver', array('link' => "person/signdogwaiver", 'weight' => 4));
    }
    if ($lr_session->is_player()) {
        menu_add_child('_root', 'person', "Players", array('weight' => -9));
        if ($lr_session->has_permission('person', 'list')) {
            menu_add_child('person', 'person/search', "search players", array('link' => 'person/search'));
        }
        if ($lr_session->is_admin()) {
            $newUsers = Person::count(array('status' => 'new'));
            if ($newUsers) {
                menu_add_child('person', 'person/listnew', "approve new accounts ({$newUsers} pending)", array('link' => "person/listnew"));
            }
            menu_add_child('person', 'person/create', "create account", array('link' => "person/create", 'weight' => 1));
            # Admin menu
            menu_add_child('settings', 'settings/person', 'user settings', array('link' => 'settings/person'));
            menu_add_child('statistics', 'statistics/person', 'player statistics', array('link' => 'statistics/person'));
        }
    }
    # Handler/registration.php
    if (variable_get('registration', 0)) {
        if ($lr_session->has_permission('registration', 'history')) {
            menu_add_child('event', 'registration/history/' . $lr_session->user->user_id, 'view history', array('link' => 'registration/history/' . $lr_session->user->user_id));
        }
        if ($lr_session->is_admin()) {
            menu_add_child('settings', 'settings/registration', 'registration settings', array('link' => 'settings/registration'));
            menu_add_child('event', 'registration/downloadall', 'download all registrations', array('link' => 'registration/downloadall'));
            menu_add_child('event', 'registration/unpaid', 'unpaid registrations', array('link' => 'registration/unpaid'));
        }
    }
    # Handler/team.php
    if ($lr_session->is_player()) {
        menu_add_child('_root', 'team', 'Teams', array('weight' => -8));
        menu_add_child('team', 'team/list', 'list teams', array('link' => 'team/list'));
        menu_add_child('team', 'team/create', 'create team', array('link' => 'team/create', 'weight' => 1));
        if ($lr_session->is_valid()) {
            while (list(, $team) = each($lr_session->user->teams)) {
                team_add_to_menu($team);
            }
            reset($lr_session->user->teams);
        }
        if ($lr_session->has_permission('team', 'statistics')) {
            menu_add_child('statistics', 'statistics/team', 'team statistics', array('link' => 'statistics/team'));
        }
    }
}