if (isset($_GET['add'])) {
            $user_to_add = mysqli_real_escape_string($_GET['add']);
            addToGroup($group, $user_to_add);
        } else {
            if (isset($_GET['remove'])) {
                $user_to_remove = mysqli_real_escape_string($_GET['remove']);
                removeFromGroup($group, $user_to_remove);
            }
        }
        //If group is private, add the "add/remove" user dialogue here.
        if (checkGroupPrivate($group)) {
            $output .= file_get_contents("templates/add-remove-users.html");
        }
        $output .= "<form name='leave-group' method='post' action=''><label>Set new group admin:</label><input type='text' name='newowner'><input type='submit' value='Leave Group' name='setowner'></form>";
    } else {
        if (getGroupMember($username, $group)) {
            //Everyone else then sees...
            $output .= "<form name='leave-group' method='post' action=''><input type='submit' text='Leave Group'></form>";
        }
    }
    //Group is private?
    if (checkGroupPrivate($group) && $_SESSION['admin'] == false) {
        header("Location: {$host}/403");
        //No permission to view this
    } else {
        //Getting, prettifying and printing entries WITHOUT edit functionality. User currently must do that via landing page.
        $output .= encaseResults(getEntries($group, true));
    }
} else {
    //TODO - List all of the groups the user is a member of.
    if ($_SESSION['admin']) {
 public function members()
 {
     $gid = (int) $_GET['id'];
     //redirect if isnt group
     if (!$gid || !getGroupInfo($gid)) {
         $this->redirect('', '', 'home');
     }
     //get group info
     $groupInfo = getGroupInfo($gid);
     $this->assign('groupInfo', $groupInfo);
     //get members
     $groupMember = getGroupMember($gid);
     /*
      * check access
      */
     if (empty($groupMember)) {
         if (empty($this->userId)) {
             $this->redirect('', '', 'index');
         } else {
             $this->redirect('', '', 'home');
         }
     } else {
         if (empty($this->userId)) {
             $this->redirect('', '', 'index');
         } else {
             $isMember = false;
             foreach ($groupMember as $key) {
                 if ($this->userId == $key['uid']) {
                     $isMember = true;
                     break;
                 }
             }
             if (!$isMember && $groupInfo['privacy'] != 'OPEN') {
                 $this->redirect('', '', 'home');
             }
         }
     }
     /*
      * edit group member list
      */
     $i = 0;
     $j = 1;
     foreach ($groupMember as &$key) {
         $key = $key + array('key' => $i);
         $key = $key + array('id' => $j);
         $j++;
         if ($i == 9) {
             $i = 0;
         } else {
             $i++;
         }
     }
     $this->assign('groupMember', $groupMember);
     //get member count
     $memberCount = count($groupMember);
     $this->assign('memberCount', $memberCount);
     /*
      * get header
      */
     $name = '<a href="' . url('', '', 'group', '', array('id' => $gid)) . '">' . $groupInfo['name'] . '</a>';
     $pageHeader = sprintf(L('_members_header'), $name);
     $pageSubheader = sprintf(L('_members_subheader'), $name, $memberCount);
     $this->assign('pageHeader', $pageHeader);
     $this->assign('pageSubheader', $pageSubheader);
     $this->display();
 }