First sketch of a user administration

This commit is contained in:
Jakob Sack 2011-04-16 14:59:10 +02:00
parent 8465f76e7e
commit 4c74029489
7 changed files with 82 additions and 31 deletions

View File

@ -5,8 +5,10 @@ if( OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' ))
{ {
OC_APP::addNavigationEntry( array( "id" => "admin_index", "order" => 1, "href" => OC_HELPER::linkTo( "admin", "index.php" ), "icon" => OC_HELPER::imagePath( "admin", "navicon.png" ), "name" => "Administration" )); OC_APP::addNavigationEntry( array( "id" => "admin_index", "order" => 1, "href" => OC_HELPER::linkTo( "admin", "index.php" ), "icon" => OC_HELPER::imagePath( "admin", "navicon.png" ), "name" => "Administration" ));
} }
OC_APP::addAdminPage( array( "order" => 1, "href" => OC_HELPER::linkTo( "admin", "system.php" ), "name" => "System settings" )); OC_APP::addAdminPage( array( "id" => "core_basic", "order" => 1, "href" => OC_HELPER::linkTo( "admin", "basic.php" ), "name" => "Basic Settings" ));
OC_APP::addAdminPage( array( "order" => 2, "href" => OC_HELPER::linkTo( "admin", "users.php" ), "name" => "Users" )); OC_APP::addAdminPage( array( "id" => "core_system", "order" => 2, "href" => OC_HELPER::linkTo( "admin", "system.php" ), "name" => "System settings" ));
OC_APP::addAdminPage( array( "order" => 3, "href" => OC_HELPER::linkTo( "admin", "plugins.php" ), "name" => "Plugins" )); OC_APP::addAdminPage( array( "id" => "core_users", "order" => 3, "href" => OC_HELPER::linkTo( "admin", "users.php" ), "name" => "Users" ));
OC_APP::addAdminPage( array( "id" => "core_apps", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "apps.php" ), "name" => "Apps" ));
OC_APP::addAdminPage( array( "id" => "core_plugins", "order" => 5, "href" => OC_HELPER::linkTo( "admin", "plugins.php" ), "name" => "Plugins" ));
?> ?>

View File

@ -28,15 +28,21 @@ if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin'
exit(); exit();
} }
$adminpages = array(); $apppages = array();
$syspages = array();
foreach( OC_APP::getAdminPages() as $i ){ foreach( OC_APP::getAdminPages() as $i ){
// Do some more work here soon if( substr( $i["id"], 0, 5 ) == "core_" ){
$adminpages[] = $i; $syspages[] = $i;
}
else{
$apppages[] = $i;
}
} }
$tmpl = new OC_TEMPLATE( "admin", "index", "admin" ); $tmpl = new OC_TEMPLATE( "admin", "index", "admin" );
$tmpl->assign( "adminpages", $adminpages ); $tmpl->assign( "apppages", $apppages );
$tmpl->assign( "syspages", $syspages );
$tmpl->printPage(); $tmpl->printPage();
?> ?>

View File

@ -5,8 +5,15 @@
?> ?>
<h1>Administration</h1> <h1>Administration</h1>
<h2>System</h2>
<ul> <ul>
<?php foreach($_["adminpages"] as $i): ?> <?php foreach($_["syspages"] as $i): ?>
<li><a href="<?php echo $i["href"]; ?>"><?php echo $i["name"]; ?></a></li>
<?php endforeach; ?>
</ul>
<h2>Applications</h2>
<ul>
<?php foreach($_["apppages"] as $i): ?>
<li><a href="<?php echo $i["href"]; ?>"><?php echo $i["name"]; ?></a></li> <li><a href="<?php echo $i["href"]; ?>"><?php echo $i["name"]; ?></a></li>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>

View File

@ -9,23 +9,26 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th></th>
<th>Name</th> <th>Name</th>
<th>Groups</th> <th>Groups</th>
<th></th>
</tr> </tr>
<thead> <thead>
<tbody> <tbody>
<?php foreach($_["users"] as $user): ?> <?php foreach($_["users"] as $user): ?>
<tr> <tr>
<td><input type="checkbox"></td>
<td><?php echo $user["name"]; ?></td> <td><?php echo $user["name"]; ?></td>
<td><?php echo $user["groups"]; ?></td> <td><?php echo $user["groups"]; ?></td>
<td><a href="" class="edituser-button">edit</a> | <a class="removeuser-button" href="">remove</a></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<a id="adduser-button" href="">New user</a>
<h2>Groups</h2> <h2>Groups</h2>
<form>
<table> <table>
<thead> <thead>
<tr> <tr>
@ -36,9 +39,41 @@
<tbody> <tbody>
<?php foreach($_["groups"] as $group): ?> <?php foreach($_["groups"] as $group): ?>
<tr> <tr>
<td><?php echo $group["name"]; ?></td> <td><?php echo $group["name"] ?></td>
<td>remove</td> <td><a class="removegroup-button" href="">remove</a></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<tr>
<td><input type="text" name="name" /></td>
<td><input type="submit" /></td>
</tr>
</tbody> </tbody>
</table> </table>
</form>
<a id="addgroup-button" href="">Add group</a>
<div id="adduser-form" title="Add user">
<form>
User name<br>
<input type="text" name="name" /><br>
Password<br>
<input type="password" name="password" />
</form>
</div>
<div id="edituser-form" title="Force new password">
<form>
New password for $user<br>
<input type="password" name="password" />
</form>
</div>
<div id="removeuser-form" title="Remove user">
Do you really want to delete user $user?
</div>
<div id="removegroup-form" title="Remove Group">
Do you really want to delete group $group?
</div>

View File

@ -28,21 +28,24 @@ if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin'
exit(); exit();
} }
// We have some javascript foo!
OC_UTIL::addScript( "admin", "users" );
$users = array(); $users = array();
$groups = array(); $groups = array();
foreach( OC_USER::getUsers() as $i ){ foreach( OC_USER::getUsers() as $i ){
// Do some more work here soon // Do some more work here soon
$ingroups = array(); $ingroups = array();
foreach( OC_USER::getUserGroups( $i ) as $userGroup){ foreach( OC_GROUP::getUserGroups( $i ) as $userGroup ){
$ingroup[] = OC_USER::getGroupName( $userGroup ); $ingroups[] = $userGroup;
} }
$users[] = array( "name" => $i, "groups" => join( ",", $ingroups )); $users[] = array( "name" => $i, "groups" => join( ",", $ingroups ));
} }
foreach( OC_USER::getGroups() as $i ){ foreach( OC_GROUP::getGroups() as $i ){
// Do some more work here soon // Do some more work here soon
$groups[] = array( "name" => $i ); $groups[] = array( "name" => $i["gid"] );
} }
$tmpl = new OC_TEMPLATE( "admin", "users", "admin" ); $tmpl = new OC_TEMPLATE( "admin", "users", "admin" );

View File

@ -24,8 +24,6 @@
require_once( 'lib/base.php' ); require_once( 'lib/base.php' );
require_once( 'appconfig.php' ); require_once( 'appconfig.php' );
require_once( 'template.php' ); require_once( 'template.php' );
var_dump( $_SESSION );
//exit;
if( OC_USER::isLoggedIn()){ if( OC_USER::isLoggedIn()){
if( $_GET["logout"] ){ if( $_GET["logout"] ){
OC_USER::logout(); OC_USER::logout();

View File

@ -119,7 +119,7 @@ class OC_GROUP_DATABASE extends OC_GROUP_BACKEND {
$groups = array(); $groups = array();
while( $row = $result->fetchRow()){ while( $row = $result->fetchRow()){
$groups[] = $row; $groups[] = $row["gid"];
} }
return $groups; return $groups;