Make sure Avatar is set from LDAP upon first login, not later, but also not before due to missing user folder

This commit is contained in:
Arthur Schiwon 2013-11-26 12:57:39 +01:00
parent 03375d6c52
commit 69518b9013
1 changed files with 14 additions and 2 deletions

View File

@ -76,8 +76,11 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
* @return void * @return void
*/ */
private function updateAvatar($uid, $dn) { private function updateAvatar($uid, $dn) {
$lastChecked = \OCP\Config::getUserValue($uid, 'user_ldap', 'lastJpegPhotoLookup', 0); $hasLoggedIn = \OCP\Config::getUserValue($uid, 'user_ldap',
if((time() - $lastChecked) < 86400 ) { 'firstLoginAccomplished', 0);
$lastChecked = \OCP\Config::getUserValue($uid, 'user_ldap',
'lastJpegPhotoLookup', 0);
if(($hasLoggedIn !== '1') || (time() - intval($lastChecked)) < 86400 ) {
//update only once a day //update only once a day
return; return;
} }
@ -105,6 +108,11 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
\OCP\Util::ERROR); \OCP\Util::ERROR);
return; return;
} }
if(!\OC\Files\Filesystem::$loaded) {
\OC_Util::setupFS($uid);
}
$avatarManager = \OC::$server->getAvatarManager(); $avatarManager = \OC::$server->getAvatarManager();
$avatar = $avatarManager->getAvatar($uid); $avatar = $avatarManager->getAvatar($uid);
$avatar->set($image); $avatar->set($image);
@ -160,6 +168,10 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
return false; return false;
} }
\OCP\Config::setUserValue($ocname, 'user_ldap',
'firstLoginAccomplished', 1);
$this->updateAvatar($ocname, $dn);
//give back the display name //give back the display name
return $ocname; return $ocname;
} }