Skip to content

Commit

Permalink
First impressions of web GUI for authmgr #10
Browse files Browse the repository at this point in the history
  • Loading branch information
nicwaller committed Jun 2, 2013
1 parent 433b50d commit 1977912
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion authmgr/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,42 @@ function authmgr_add_page() {
}

function authmgr_display_page() {
echo "Get option content and render page here!";
if ( count( $_POST ) > 0 ) {
$rolenames = $_POST['rolenames'];
$roledefs = array();
foreach ($rolenames as $role) {
$roledefs[$role] = $_POST['role-'.$role];
}
yourls_update_option( 'authmgr_roles', json_encode( $roledefs ) );
echo '<b>Updated authmgr roles</b>';
}

$roles = json_decode( yourls_get_option( 'authmgr_roles' ), true );

echo '<form name="roles" method="POST" action="plugins.php?page=authmgr">';
echo '<table border="1">';
$allcaps = AuthmgrCapability::all();
echo '<tr> <th></th>';
foreach ($allcaps as $cap) {
echo "<th>$cap</th>";
}
echo '</tr>';
foreach ($roles as $role => $selcaps) {
echo '<input type="hidden" name="rolenames[]" value="'.$role.'">';
echo '<tr>';
echo "<th>$role</th>";
foreach ($allcaps as $cap) {
echo '<td>';
$active = in_array( $cap, $selcaps );
$selstr = ( $active ? 'checked' : '' );
echo '<input type="checkbox" name="role-'.$role.'[]" value="'.$cap.'" '.$selstr.'>';
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
echo '<input type="submit" value="Update Roles">';
echo '</form>';
}

/**************** CAPABILITY TEST/ENUMERATION ****************/
Expand Down

0 comments on commit 1977912

Please sign in to comment.