]> source.dussan.org Git - nextcloud-server.git/commitdiff
offer change password only when the action is supported by the user backend
authorArthur Schiwon <blizzz@owncloud.com>
Tue, 5 Feb 2013 13:58:35 +0000 (14:58 +0100)
committerArthur Schiwon <blizzz@owncloud.com>
Tue, 5 Feb 2013 18:26:00 +0000 (19:26 +0100)
lib/user.php
settings/personal.php
settings/templates/personal.php

index 38259bceea5ac238491b86b8b6cf8ab07d78e9b4..f953d22154301f6122a1238ac317f59225026c3b 100644 (file)
@@ -419,6 +419,24 @@ class OC_User {
                }
        }
 
+       /**
+        * @brief Check whether user can change his password
+        * @param $uid The username
+        * @returns true/false
+        *
+        * Check whether a specified user can change his password
+        */
+       public static function canUserChangePassword($uid) {
+               foreach(self::$_usedBackends as $backend) {
+                       if($backend->implementsActions(OC_USER_BACKEND_SET_PASSWORD)) {
+                               if($backend->userExists($uid)) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
        /**
         * @brief Check if the password is correct
         * @param $uid The username
index 4624bda839786960ff79c603fdaddf0217f5a0f2..a2e510a6d3cb0d611826f612c267c7df36918ef6 100644 (file)
@@ -47,6 +47,7 @@ $tmpl->assign('total_space', OC_Helper::humanFileSize($storageInfo['total']));
 $tmpl->assign('usage_relative', $storageInfo['relative']);
 $tmpl->assign('email', $email);
 $tmpl->assign('languages', $languages);
+$tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser()));
 
 $forms=OC_App::getForms('personal');
 $tmpl->assign('forms', array());
index 0e1677bdea8cdc536268f9cc5dfc3366182b69c7..b1cc67139235c8d6d08a82e2e9435d0c37068b40 100644 (file)
@@ -15,7 +15,9 @@
        <a class="button" href="https://itunes.apple.com/us/app/owncloud/id543672169?mt=8" target="_blank"><?php echo $l->t('Download iOS Client');?></a>
 </fieldset>
 
-
+<?php
+if($_['passwordChangeSupported']) {
+?>
 <form id="passwordform">
        <fieldset class="personalblock">
                <legend><strong><?php echo $l->t('Password');?></strong></legend>
@@ -27,6 +29,9 @@
                <input id="passwordbutton" type="submit" value="<?php echo $l->t('Change password');?>" />
        </fieldset>
 </form>
+<?php
+}
+?>
 
 <form id="lostpassword">
        <fieldset class="personalblock">