diff options
author | Frank Karlitschek <frank@owncloud.org> | 2013-01-30 14:36:17 +0100 |
---|---|---|
committer | Frank Karlitschek <frank@owncloud.org> | 2013-01-30 14:36:17 +0100 |
commit | 66cab77b6d83980d260cd35556d2759089d2971b (patch) | |
tree | ccf3767afba89f90ea82bd0805f23eb189956b53 /settings/ajax | |
parent | 389c4e84153893a04310876ef70943cad53ee3e7 (diff) | |
parent | 5761bd771f4142394a00083712b63e77f8976946 (diff) | |
download | nextcloud-server-66cab77b6d83980d260cd35556d2759089d2971b.tar.gz nextcloud-server-66cab77b6d83980d260cd35556d2759089d2971b.zip |
merge master
Merge branch 'master' into improved_appsmanagement
Conflicts:
settings/apps.php
settings/templates/apps.php
Diffstat (limited to 'settings/ajax')
-rw-r--r-- | settings/ajax/changedisplayname.php | 28 | ||||
-rw-r--r-- | settings/ajax/changepassword.php | 6 | ||||
-rw-r--r-- | settings/ajax/createuser.php | 4 | ||||
-rw-r--r-- | settings/ajax/removeuser.php | 2 | ||||
-rw-r--r-- | settings/ajax/setquota.php | 2 | ||||
-rw-r--r-- | settings/ajax/togglegroups.php | 8 | ||||
-rw-r--r-- | settings/ajax/userlist.php | 2 |
7 files changed, 37 insertions, 15 deletions
diff --git a/settings/ajax/changedisplayname.php b/settings/ajax/changedisplayname.php new file mode 100644 index 00000000000..f80ecb7a0c9 --- /dev/null +++ b/settings/ajax/changedisplayname.php @@ -0,0 +1,28 @@ +<?php
+// Check if we are a user
+OCP\JSON::callCheck();
+OC_JSON::checkLoggedIn();
+
+$username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser();
+$displayName = $_POST["displayName"];
+
+$userstatus = null;
+if(OC_User::isAdminUser(OC_User::getUser())) {
+ $userstatus = 'admin';
+}
+if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) {
+ $userstatus = 'subadmin';
+}
+
+if(is_null($userstatus)) {
+ OC_JSON::error( array( "data" => array( "message" => "Authentication error" )));
+ exit();
+}
+
+// Return Success story
+if( OC_User::setDisplayName( $username, $displayName )) {
+ OC_JSON::success(array("data" => array( "username" => $username )));
+}
+else{
+ OC_JSON::error(array("data" => array( "message" => "Unable to change display name" )));
+}
\ No newline at end of file diff --git a/settings/ajax/changepassword.php b/settings/ajax/changepassword.php index b2db2611518..8d45e62e4d8 100644 --- a/settings/ajax/changepassword.php +++ b/settings/ajax/changepassword.php @@ -9,7 +9,7 @@ $password = $_POST["password"]; $oldPassword=isset($_POST["oldpassword"])?$_POST["oldpassword"]:''; $userstatus = null; -if(OC_Group::inGroup(OC_User::getUser(), 'admin')) { +if(OC_User::isAdminUser(OC_User::getUser())) { $userstatus = 'admin'; } if(OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) { @@ -30,10 +30,6 @@ if(is_null($userstatus)) { exit(); } -if($userstatus === 'admin' || $userstatus === 'subadmin') { - OC_JSON::verifyUser(); -} - // Return Success story if( OC_User::setPassword( $username, $password )) { OC_JSON::success(array("data" => array( "username" => $username ))); diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php index addae78517a..09ef25d92fa 100644 --- a/settings/ajax/createuser.php +++ b/settings/ajax/createuser.php @@ -3,9 +3,7 @@ OCP\JSON::callCheck(); OC_JSON::checkSubAdminUser(); -$isadmin = OC_Group::inGroup(OC_User::getUser(), 'admin')?true:false; - -if($isadmin) { +if(OC_User::isAdminUser(OC_User::getUser())) { $groups = array(); if( isset( $_POST["groups"] )) { $groups = $_POST["groups"]; diff --git a/settings/ajax/removeuser.php b/settings/ajax/removeuser.php index 9ffb32a0b23..bf3a34f1472 100644 --- a/settings/ajax/removeuser.php +++ b/settings/ajax/removeuser.php @@ -10,7 +10,7 @@ if(OC_User::getUser() === $username) { exit; } -if(!OC_Group::inGroup(OC_User::getUser(), 'admin') && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) { +if(!OC_User::isAdminUser(OC_User::getUser()) && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) { $l = OC_L10N::get('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php index 845f8ea408c..356466c0c00 100644 --- a/settings/ajax/setquota.php +++ b/settings/ajax/setquota.php @@ -10,7 +10,7 @@ OCP\JSON::callCheck(); $username = isset($_POST["username"])?$_POST["username"]:''; -if(($username == '' && !OC_Group::inGroup(OC_User::getUser(), 'admin')) || (!OC_Group::inGroup(OC_User::getUser(), 'admin') && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username))) { +if(($username == '' && !OC_User::isAdminUser(OC_User::getUser()))|| (!OC_User::isAdminUser(OC_User::getUser()) && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username))) { $l = OC_L10N::get('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); diff --git a/settings/ajax/togglegroups.php b/settings/ajax/togglegroups.php index 83d455550ae..9bba9c5269d 100644 --- a/settings/ajax/togglegroups.php +++ b/settings/ajax/togglegroups.php @@ -7,13 +7,13 @@ $success = true; $username = $_POST["username"]; $group = $_POST["group"]; -if($username == OC_User::getUser() && $group == "admin" && OC_Group::inGroup($username, 'admin')) { +if($username == OC_User::getUser() && $group == "admin" && OC_User::isAdminUser($username)) { $l = OC_L10N::get('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Admins can\'t remove themself from the admin group')))); exit(); } -if(!OC_Group::inGroup(OC_User::getUser(), 'admin') && (!OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username) || !OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group))) { +if(!OC_User::isAdminUser(OC_User::getUser()) && (!OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username) || !OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group))) { $l = OC_L10N::get('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') ))); exit(); @@ -31,8 +31,8 @@ $action = "add"; // Toggle group if( OC_Group::inGroup( $username, $group )) { $action = "remove"; - $error = $l->t("Unable to remove user from group %s", $group); - $success = OC_Group::removeFromGroup( $username, $group ); + $error = $l->t("Unable to remove user from group %s", $group); + $success = OC_Group::removeFromGroup( $username, $group ); $usersInGroup=OC_Group::usersInGroup($group); if(count($usersInGroup)==0) { OC_Group::deleteGroup($group); diff --git a/settings/ajax/userlist.php b/settings/ajax/userlist.php index eaeade60a39..9bbff80ea0c 100644 --- a/settings/ajax/userlist.php +++ b/settings/ajax/userlist.php @@ -28,7 +28,7 @@ if (isset($_GET['offset'])) { $offset = 0; } $users = array(); -if (OC_Group::inGroup(OC_User::getUser(), 'admin')) { +if (OC_User::isAdminUser(OC_User::getUser())) { $batch = OC_User::getUsers('', 10, $offset); foreach ($batch as $user) { $users[] = array( |