Example #1
0
 /**
  * @brief sets an image as ownCloud avatar
  * @return null
  */
 private function setOwnCloudAvatar()
 {
     if (!$this->image->valid()) {
         $this->log->log('user_ldap', 'jpegPhoto data invalid for ' . $this->dn, \OCP\Util::ERROR);
         return;
     }
     //make sure it is a square and not bigger than 128x128
     $size = min(array($this->image->width(), $this->image->height(), 128));
     if (!$this->image->centerCrop($size)) {
         $this->log->log('user_ldap', 'croping image for avatar failed for ' . $this->dn, \OCP\Util::ERROR);
         return;
     }
     if (!$this->fs->isLoaded()) {
         $this->fs->setup($this->uid);
     }
     $avatar = $this->avatarManager->getAvatar($this->uid);
     $avatar->set($this->image);
 }
Example #2
0
 /**
  * @brief sets an image as ownCloud avatar
  * @return null
  */
 private function setOwnCloudAvatar()
 {
     if (!$this->image->valid()) {
         $this->log->log('user_ldap', 'jpegPhoto data invalid for ' . $this->dn, \OCP\Util::ERROR);
         return;
     }
     //make sure it is a square and not bigger than 128x128
     $size = min(array($this->image->width(), $this->image->height(), 128));
     if (!$this->image->centerCrop($size)) {
         $this->log->log('user_ldap', 'croping image for avatar failed for ' . $this->dn, \OCP\Util::ERROR);
         return;
     }
     if (!$this->fs->isLoaded()) {
         $this->fs->setup($this->uid);
     }
     try {
         $avatar = $this->avatarManager->getAvatar($this->uid);
         $avatar->set($this->image);
     } catch (\Exception $e) {
         \OC::$server->getLogger()->notice('Could not set avatar for ' . $this->dn . ', because: ' . $e->getMessage(), ['app' => 'user_ldap']);
     }
 }