Ejemplo n.º 1
0
 /**
  * @param OCP\Image $image
  */
 public function setImage(\OCP\Image $image)
 {
     if (!$image->valid()) {
         throw new \InvalidArgumentException(__METHOD__ . ' The image resource is not valid.');
     }
     $this->image = $image;
     $this->addHeader('Content-Type', $image->mimeType());
     return $this;
 }
Ejemplo n.º 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);
     }
     $avatar = $this->avatarManager->getAvatar($this->uid);
     $avatar->set($this->image);
 }
Ejemplo n.º 3
0
 /**
  * @brief sets an image as ownCloud avatar
  * @return null
  */
 private function setOwnCloudAvatar()
 {
     if (!$this->image->valid()) {
         $this->log->log('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('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']);
     }
 }
Ejemplo n.º 4
0
 /**
  * Whether this image is valied
  *
  * @return bool
  */
 public function isValid()
 {
     return $this->image instanceof Image && $this->image->valid();
 }