/**
  * 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))));
 }
 function OnPreRender()
 {
     /* @var $o_top_level Category */
     $review_item = $this->o_topic->GetReviewItem();
     $s_suggested_title = urlencode(StringFormatter::PlainText(trim($review_item->GetTitle())));
     $s_page = urlencode($_SERVER['REQUEST_URI']);
     $s_subscribe_link = '/play/subscribe.php?type=' . $review_item->GetType() . '&item=' . $review_item->GetId() . '&title=' . $s_suggested_title . '&page=' . $s_page;
     $s_subscribe_title = 'Get an email alert every time there are new comments on this page';
     $this->AddControl('<div class="forumSubscribe"><a href="' . $s_subscribe_link . '" title="' . $s_subscribe_title . '">Subscribe to comments</a></div>');
     if (!$this->authentication_manager->GetUser()->Permissions()->HasPermission(PermissionType::ForumAddMessage())) {
         $add = $this->o_topic->GetCount() ? 'Add your comments' : 'Be the first to add your comments!';
         $this->AddControl('<div class="forumPost"><a href="' . Html::Encode($this->authentication_manager->GetPermissionUrl()) . urlencode('#forumMessageForm') . '">' . $add . '</a></div>');
     }
 }
 /**
  * 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";
     }
 }
 private function DisplayComments()
 {
     # Display review topic listing
     require_once 'forums/forum-topic-listing.class.php';
     require_once 'forums/forum-comments-topic-navbar.class.php';
     if (!isset($this->topic)) {
         $this->topic = new ForumTopic($this->GetSettings());
     }
     $this->topic->SetReviewItem($this->review_item);
     $signed_in = AuthenticationManager::GetUser()->IsSignedIn();
     echo '<div id="comments-topic"';
     if ($signed_in) {
         echo ' class="signed-in"';
     }
     echo '>';
     if ($this->topic->GetCount() or !$signed_in) {
         echo '<h2>Comments</h2>';
     }
     $navbar = new ForumCommentsTopicNavbar($this->topic, $this->GetAuthenticationManager());
     echo $navbar;
     $o_review_topic = new ForumTopicListing($this->GetSettings(), AuthenticationManager::GetUser(), $this->topic);
     echo $o_review_topic;
     if ($this->topic->GetCount() and !$signed_in) {
         echo $navbar;
     }
     # Add comment
     if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::ForumAddMessage())) {
         # create form
         $this->LoadClientScript("/scripts/tiny_mce/jquery.tinymce.js");
         $this->LoadClientScript("/scripts/tinymce.js");
         require_once 'forums/forum-message-form.class.php';
         $o_form = new ForumMessageForm();
         echo $o_form->GetForm();
     }
     echo '</div>';
 }