/**
  * Creates a PermissionsEditor
  *
  * @param SiteSettings $settings
  * @param DataEditControl $controlling_editor
  * @param string $s_id
  * @param string $s_title
  */
 public function __construct(SiteSettings $settings, DataEditControl $controlling_editor, $s_id, $s_title)
 {
     $this->SetDataObjectClass('IdValue');
     $this->SetDataObjectMethods('GetId', '', '');
     parent::__construct($settings, $controlling_editor, $s_id, $s_title, array("Permission", "Resource URI"));
     # initialise arrays
     $this->permissions = array(new IdValue(PermissionType::ViewPage(), ucfirst(PermissionType::Text(PermissionType::ViewPage()))), new IdValue(PermissionType::ForumAddMessage(), ucfirst(PermissionType::Text(PermissionType::ForumAddMessage()))), new IdValue(PermissionType::EditPersonalInfo(), ucfirst(PermissionType::Text(PermissionType::EditPersonalInfo()))), new IdValue(PermissionType::MANAGE_CATEGORIES, ucfirst(PermissionType::Text(PermissionType::MANAGE_CATEGORIES))), new IdValue(PermissionType::MANAGE_USERS_AND_PERMISSIONS, ucfirst(PermissionType::Text(PermissionType::MANAGE_USERS_AND_PERMISSIONS))), new IdValue(PermissionType::PageSubscribe(), ucfirst(PermissionType::Text(PermissionType::PageSubscribe()))), new IdValue(PermissionType::MANAGE_URLS, ucfirst(PermissionType::Text(PermissionType::MANAGE_URLS))), new IdValue(PermissionType::MANAGE_SEARCH, ucfirst(PermissionType::Text(PermissionType::MANAGE_SEARCH))), new IdValue(PermissionType::VIEW_ADMINISTRATION_PAGE, ucfirst(PermissionType::Text(PermissionType::VIEW_ADMINISTRATION_PAGE))), new IdValue(PermissionType::VIEW_WORDPRESS_LOGIN, ucfirst(PermissionType::Text(PermissionType::VIEW_WORDPRESS_LOGIN))), new IdValue(PermissionType::EXCLUDE_FROM_ANALYTICS, ucfirst(PermissionType::Text(PermissionType::EXCLUDE_FROM_ANALYTICS))), new IdValue(PermissionType::MANAGE_TEAMS, ucfirst(PermissionType::Text(PermissionType::MANAGE_TEAMS))), new IdValue(PermissionType::MANAGE_COMPETITIONS, ucfirst(PermissionType::Text(PermissionType::MANAGE_COMPETITIONS))), new IdValue(PermissionType::MANAGE_GROUNDS, ucfirst(PermissionType::Text(PermissionType::MANAGE_GROUNDS))), new IdValue(PermissionType::ADD_MATCH, ucfirst(PermissionType::Text(PermissionType::ADD_MATCH))), new IdValue(PermissionType::EDIT_MATCH, ucfirst(PermissionType::Text(PermissionType::EDIT_MATCH))), new IdValue(PermissionType::DELETE_MATCH, ucfirst(PermissionType::Text(PermissionType::DELETE_MATCH))), new IdValue(PermissionType::MANAGE_MATCHES, ucfirst(PermissionType::Text(PermissionType::MANAGE_MATCHES))), new IdValue(PermissionType::MANAGE_PLAYERS, ucfirst(PermissionType::Text(PermissionType::MANAGE_PLAYERS))), new IdValue(PermissionType::MANAGE_STATISTICS, ucfirst(PermissionType::Text(PermissionType::MANAGE_STATISTICS))));
 }
 /**
  * Gets a description of a permission
  * @param int $type
  * @return string
  */
 public static function Text($type)
 {
     switch ($type) {
         case PermissionType::ViewPage():
             return 'view a page';
         case PermissionType::ForumAddMessage():
             return "post a forum message";
         case PermissionType::EditPersonalInfo():
             return "edit own profile";
         case PermissionType::MANAGE_CATEGORIES:
             return "manage categories";
         case PermissionType::MANAGE_USERS_AND_PERMISSIONS:
             return "manage users and permissions";
         case PermissionType::PageSubscribe():
             return "subscribe to alerts for comments on pages";
         case PermissionType::MANAGE_URLS:
             return "manage URLs";
         case PermissionType::MANAGE_SEARCH:
             return "manage search";
         case PermissionType::VIEW_ADMINISTRATION_PAGE:
             return "view the admin menu";
         case PermissionType::VIEW_WORDPRESS_LOGIN:
             return "view the WordPress login link";
         case PermissionType::EXCLUDE_FROM_ANALYTICS:
             return "opt out of Google Analytics";
         case PermissionType::MANAGE_TEAMS:
             return "manage teams and clubs";
         case PermissionType::MANAGE_COMPETITIONS:
             return "manage competitions and seasons";
         case PermissionType::MANAGE_GROUNDS:
             return "manage grounds";
         case PermissionType::ADD_MATCH:
             return 'add matches';
         case PermissionType::EDIT_MATCH:
             return "edit own matches, and results of any match";
         case PermissionType::DELETE_MATCH:
             return "delete own matches";
         case PermissionType::MANAGE_MATCHES:
             return "manage matches";
         case PermissionType::MANAGE_PLAYERS:
             return "manage players";
         case PermissionType::MANAGE_STATISTICS:
             return "manage match statistics";
     }
 }
            echo "<p>There aren't any statistics for " . htmlentities($this->match->GetTitle(), ENT_QUOTES, "UTF-8", false) . ' yet.</p>
            <p>To find out how to add them, see <a href="/play/manage/website/matches-and-results-why-you-should-add-yours/">Matches and results - why you should add yours</a>.</p>';
        } else {
            ?>
            <div class="statsColumns">
                <div class="statsColumn">
            <div class="chart-js-template" id="worm-chart"></div>
            </div>
                <div class="statsColumn">
            <div class="chart-js-template" id="run-rate-chart"></div>
            </div>
            </div>
            <div class="statsColumns manhattan">
            <h2>Scores in each over</h2>
                <div class="statsColumn">
                    <div class="chart-js-template" id="manhattan-chart-first-innings"></div>
                </div>
                <div class="statsColumn">
                    <div class="chart-js-template" id="manhattan-chart-second-innings"></div>
                </div>
            </div>
            <?php 
        }
        ?>
        </div>
        </div>
        <?php 
    }
}
new CurrentPage(new StoolballSettings(), PermissionType::ViewPage(), false);
                $o_message->AddControl(new XhtmlElement('p', $s_message));
            } else {
                echo '<h1>Check your email to confirm your registration</h1>';
                $o_message->AddControl(new XhtmlElement('p', 'Thanks for registering with ' . Html::Encode($this->GetSettings()->GetSiteName()) . '.'));
                $s_message = "We've sent you an email. Please check your inbox now, and click on the link in the email to confirm your registration.";
                $o_message->AddControl(new XhtmlElement('p', $s_message));
            }
            echo $o_message;
        } else {
            if ($this->b_success) {
                ?>
                <h1>Confirmation successful</h1>
                <p>Welcome to <?php 
                echo Html::Encode($this->GetSettings()->GetSiteName());
                ?>
!</p>
                <p>We've activated your account, and sent you an email confirming your sign in details.</p>
          
                <p><strong>Please <a href="/you">sign in</a> using your email address and your new password.</strong></p>
           
                <?php 
            } else {
                echo new XhtmlElement('h1', 'Confirmation failed');
                echo new XhtmlElement('p', 'Sorry, your registration for ' . Html::Encode($this->GetSettings()->GetSiteName()) . ' could not be confirmed.');
                echo new XhtmlElement('p', 'Please check that you used the exact address in the email you received, or try to <a href="' . Html::Encode($this->GetSettings()->GetUrl('AccountCreate')) . '">register again</a>.');
            }
        }
    }
}
new ActivationPage(new StoolballSettings(), PermissionType::ViewPage(), false);
                    $s_email_status = $email_success ? '' : '&email=no';
                    $this->Redirect($this->GetSettings()->GetUrl('AccountActivate') . '?action=request' . $s_email_status);
                }
            } else {
                # email not in db, so sign up a new user
                $new_user = $authentication_manager->RegisterUser($new_user);
                # add activation request
                $s_hash = $authentication_manager->SaveRequest($new_user->GetId());
                # send email requesting activation - validates email address
                $email_success = $authentication_manager->SendActivationEmail($new_user, $s_hash);
                # redirect to sign-in page
                $s_email_status = $email_success ? '' : '&email=no';
                $this->Redirect($this->GetSettings()->GetUrl('AccountActivate') . '?action=request' . $s_email_status);
            }
        }
    }
    function OnPrePageLoad()
    {
        $this->SetPageTitle('Register with ' . $this->GetSettings()->GetSiteName());
        $this->SetContentConstraint(StoolballPage::ConstrainText());
    }
    function OnPageLoad()
    {
        echo '<h1>' . Html::Encode($this->GetPageTitle()) . '</h1>';
        $new_user = is_object($this->new_user) ? $this->new_user : new User();
        $this->form->SetDataObject($new_user);
        echo $this->form;
    }
}
new SignUpPage(new StoolballSettings(), PermissionType::ViewPage(), false);
 /**
  * Ensures there is a user object available with view permissions even if no user is signed in
  *
  * @return void
  */
 public static function EnsureUser()
 {
     if (!isset($_SESSION['user'])) {
         $_SESSION['user'] = new User();
     }
     $_SESSION['user']->Permissions()->AddPermission(PermissionType::ViewPage());
 }