summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/ajax/creategroup.php34
-rw-r--r--admin/ajax/createuser.php34
-rw-r--r--admin/js/users.js37
-rw-r--r--admin/system.php10
-rw-r--r--admin/templates/users.php39
-rw-r--r--files/ajax/upload.php4
-rw-r--r--files/js/files.js2
7 files changed, 129 insertions, 31 deletions
diff --git a/admin/ajax/creategroup.php b/admin/ajax/creategroup.php
new file mode 100644
index 00000000000..ab99d2a5bee
--- /dev/null
+++ b/admin/ajax/creategroup.php
@@ -0,0 +1,34 @@
+<?php
+
+// Init owncloud
+require_once('../../lib/base.php');
+
+// We send json data
+header( "Content-Type: application/jsonrequest" );
+
+// Check if we are a user
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
+ exit();
+}
+
+$groups = array();
+if( isset( $_POST["groups"] )){
+ $groups = $_POST["groups"];
+}
+$username = $_POST["username"];
+$password = $_POST["password"];
+
+foreach( $groups as $i ){
+ OC_GROUP::addToGroup( $username, $i );
+}
+
+// Return Success story
+if( OC_USER::createUser( $username, $password )){
+ echo json_encode( array( "status" => "success", "data" => array( "username" => $username, "groups" => implode( ", ", $groups ))));
+}
+else{
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to add user" )));
+}
+
+?>
diff --git a/admin/ajax/createuser.php b/admin/ajax/createuser.php
new file mode 100644
index 00000000000..ab99d2a5bee
--- /dev/null
+++ b/admin/ajax/createuser.php
@@ -0,0 +1,34 @@
+<?php
+
+// Init owncloud
+require_once('../../lib/base.php');
+
+// We send json data
+header( "Content-Type: application/jsonrequest" );
+
+// Check if we are a user
+if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
+ exit();
+}
+
+$groups = array();
+if( isset( $_POST["groups"] )){
+ $groups = $_POST["groups"];
+}
+$username = $_POST["username"];
+$password = $_POST["password"];
+
+foreach( $groups as $i ){
+ OC_GROUP::addToGroup( $username, $i );
+}
+
+// Return Success story
+if( OC_USER::createUser( $username, $password )){
+ echo json_encode( array( "status" => "success", "data" => array( "username" => $username, "groups" => implode( ", ", $groups ))));
+}
+else{
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to add user" )));
+}
+
+?>
diff --git a/admin/js/users.js b/admin/js/users.js
index 6d59a2efb7c..0713cf8e5dc 100644
--- a/admin/js/users.js
+++ b/admin/js/users.js
@@ -1,4 +1,7 @@
$(document).ready(function(){
+ // Vars we need
+ var uid = "";
+ var gid = "";
// Dialog for adding users
$( "#adduser-form" ).dialog({
autoOpen: false,
@@ -7,6 +10,13 @@ $(document).ready(function(){
modal: true,
buttons: {
"Create an account": function() {
+ var post = $( "#createuserdata" ).serialize();
+ $.post( 'ajax/createuser.php', post, function(data){
+ var newrow = '<tr><td>' + data.data.username + '</td>';
+ newrow = newrow + '<td>' + data.data.groups + '</td>';
+ newrow = newrow + '<td><a href="" class="edituser-button">edit</a> | <a class="removeuser-button" href="">remove</a></td></tr>';
+ $("#userstable").append( newrow );
+ });
$( this ).dialog( "close" );
},
Cancel: function() {
@@ -14,7 +24,7 @@ $(document).ready(function(){
}
},
close: function() {
- allFields.val( "" ).removeClass( "ui-state-error" );
+ true;
}
});
@@ -39,13 +49,15 @@ $(document).ready(function(){
}
},
close: function() {
- allFields.val( "" ).removeClass( "ui-state-error" );
+ true;
}
});
$( ".edituser-button" )
- .click(function() {
- $( "#edituser-form" ).dialog( "open" );
+ .click(function(){
+ uid = $( this ).parent().attr( 'x-uid' );
+ $("#edituserusername").html(uid);
+ $("#edituser-form").dialog("open");
return false;
});
@@ -70,6 +82,8 @@ $(document).ready(function(){
$( ".removeuser-button" )
.click(function() {
+ uid = $( this ).parent().attr( 'x-uid' );
+ $("#deleteuserusername").html(uid);
$( "#removeuser-form" ).dialog( "open" );
return false;
});
@@ -81,21 +95,28 @@ $(document).ready(function(){
width: 350,
modal: true,
buttons: {
- "Remove group": function() {
+ "Remove group": function(){
+ var post = $( "#deletegroupdata" ).serialize();
+ $.post( 'ajax/deletegroup.php', post, function(data){
+ $( "a[x-gid='"+gid+"']" ).parent().remove();
+ });
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
- close: function() {
+ close: function(){
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
$( ".removegroup-button" )
- .click(function() {
- $( "#removegroup-form" ).dialog( "open" );
+ .click(function(){
+ gid = $( this ).parent().attr( 'x-gid' );
+ $("#deletegroupgroupname").html(gid);
+ $("#deletegroupnamefield").val(gid);
+ $("#removegroup-form").dialog( "open" );
return false;
});
} );
diff --git a/admin/system.php b/admin/system.php
index 8abef287098..de62b133f85 100644
--- a/admin/system.php
+++ b/admin/system.php
@@ -28,15 +28,7 @@ if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin'
exit();
}
-$adminpages = array();
-
-foreach( OC_APP::getAdminPages() as $i ){
- // Do some more work here soon
- $adminpages[] = $i;
-}
-
-$tmpl = new OC_TEMPLATE( "admin", "index", "admin" );
-$tmpl->assign( "adminpages", $adminpages );
+$tmpl = new OC_TEMPLATE( "admin", "system", "admin" );
$tmpl->printPage();
?>
diff --git a/admin/templates/users.php b/admin/templates/users.php
index 88edc01aef2..ce78ffac775 100644
--- a/admin/templates/users.php
+++ b/admin/templates/users.php
@@ -6,20 +6,20 @@
<h1>Administration</h1>
<h2>Users</h2>
-<table>
+<table id="userstable">
<thead>
<tr>
<th>Name</th>
<th>Groups</th>
<th></th>
</tr>
- <thead>
+ </thead>
<tbody>
<?php foreach($_["users"] as $user): ?>
<tr>
<td><?php echo $user["name"]; ?></td>
<td><?php echo $user["groups"]; ?></td>
- <td><a href="" class="edituser-button">edit</a> | <a class="removeuser-button" href="">remove</a></td>
+ <td x-uid="<?php echo $user["name"] ?>"><a href="" class="edituser-button">edit</a> | <a class="removeuser-button" href="">remove</a></td>
</tr>
<?php endforeach; ?>
</tbody>
@@ -29,18 +29,18 @@
<h2>Groups</h2>
<form>
- <table>
+ <table id="groupstable">
<thead>
<tr>
<th>Name</th>
<th></th>
</tr>
- <thead>
+ </thead>
<tbody>
<?php foreach($_["groups"] as $group): ?>
<tr>
<td><?php echo $group["name"] ?></td>
- <td><a class="removegroup-button" href="">remove</a></td>
+ <td x-gid="<?php echo $group["name"]; ?>"><a class="removegroup-button" href="">remove</a></td>
</tr>
<?php endforeach; ?>
<tr>
@@ -55,25 +55,40 @@
<div id="adduser-form" title="Add user">
- <form>
+ <form id="createuserdata">
+ <fieldset>
User name<br>
- <input type="text" name="name" /><br>
+ <input type="text" name="username" /><br>
Password<br>
<input type="password" name="password" />
+ </fieldset>
+ <fieldset id="usergroups">
+ groups<br>
+ <?php foreach($_["groups"] as $i): ?>
+ <input type="checkbox" name="groups[]" value="<? echo $i["name"]; ?>" /><? echo $i["name"]; ?><br>
+ <?php endforeach; ?>
+ </fieldset>
</form>
</div>
<div id="edituser-form" title="Force new password">
- <form>
- New password for $user<br>
+ <form id="edituserdata">
+ New password for <span id="edituserusername">$user</span><br>
<input type="password" name="password" />
+ <input type="hidden" name="username" value="">
</form>
</div>
<div id="removeuser-form" title="Remove user">
- Do you really want to delete user $user?
+ <form id="removeuserdata">
+ Do you really want to delete user <span id="deleteuserusername">$user</span>?
+ <input type="hidden" name="username" value="">
+ </form>
</div>
<div id="removegroup-form" title="Remove Group">
- Do you really want to delete group $group?
+ <form id="removeuserdata">
+ Do you really want to delete group <span id="deletegroupgroupname">$group</span>?
+ <input id="deletegroupnamefield" type="hidden" name="username" value="">
+ </form>
</div>
diff --git a/files/ajax/upload.php b/files/ajax/upload.php
index b3facf96723..79b6c0b284c 100644
--- a/files/ajax/upload.php
+++ b/files/ajax/upload.php
@@ -27,6 +27,8 @@ and $_SESSION['username'] and strpos($dir,'..') === false){
}
}
-echo json_encode(array( "status" => "error"));
+$error = $_FILES['file']['error'];
+
+echo json_encode(array( 'status' => 'error', 'data' => array('error' => $error)));
?>
diff --git a/files/js/files.js b/files/js/files.js
index ba08e254349..9eeeb7f6bfd 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -53,7 +53,7 @@ function uploadFinished() {
result = $('#file_upload_target').contents().text();
result = eval("(" + result + ");");
if(result.status == "error") {
- alert('An error occcured, upload failed.');
+ alert('An error occcured, upload failed.\nError code: ' + result.data.error);
} else {
location.href = 'index.php?dir=' + $('#dir').val();
}