[Pkg-owncloud-commits] [owncloud] 325/394: offer change password only when the action is supported by the user backend
David Prévot
taffit at alioth.debian.org
Fri Nov 8 23:12:41 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v4.5.10
in repository owncloud.
commit 503a84c2252056c45765811b888f0e6993ae0742
Author: Arthur Schiwon <blizzz at owncloud.com>
Date: Tue Feb 5 14:58:35 2013 +0100
offer change password only when the action is supported by the user backend
---
lib/user.php | 18 ++++++++++++++++++
settings/personal.php | 1 +
settings/templates/personal.php | 7 ++++++-
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/lib/user.php b/lib/user.php
index 42116fa..6cea4ef 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -345,6 +345,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
* @param $password The password
diff --git a/settings/personal.php b/settings/personal.php
index 2031edd..fd8a255 100644
--- a/settings/personal.php
+++ b/settings/personal.php
@@ -55,6 +55,7 @@ $tmpl->assign('total_space', OC_Helper::humanFileSize($total));
$tmpl->assign('usage_relative', $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());
diff --git a/settings/templates/personal.php b/settings/templates/personal.php
index 55ff24b..5926037 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -13,7 +13,9 @@
<a class="button" href="http://owncloud.org/sync-clients/" target="_blank"><?php echo $l->t('Download');?></a>
</div>
-
+<?php
+if($_['passwordChangeSupported']) {
+?>
<form id="passwordform">
<fieldset class="personalblock">
<div id="passwordchanged"><?php echo $l->t('Your password was changed');?></div>
@@ -24,6 +26,9 @@
<input id="passwordbutton" type="submit" value="<?php echo $l->t('Change password');?>" />
</fieldset>
</form>
+<?php
+}
+?>
<form id="lostpassword">
<fieldset class="personalblock">
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list