Example #1
0
 protected function importCoverPhoto()
 {
     $cover = $this->profileLibrary->getCoverPhoto($this->socialId);
     if (!$cover) {
         return false;
     }
     $data = SCSocialUtilities::getRemoteContent($cover->get('url'));
     $tmpImgName = 'sccover_' . $this->network . $this->socialId . '_pic_tmp.jpg';
     JFile::write($this->getAvatarPath() . '/' . $tmpImgName, $data);
     $cover->set('path', $this->getAvatarPath() . '/' . $tmpImgName);
     list($width, $height, $type) = getimagesize($cover->get('path'));
     // Resize to the offsets provided if non-0
     if ($type != 2 || $cover->get('offsetX') != 0 || $cover->get('offsetY') != 0) {
         $image_p = imagecreatetruecolor($width - $cover->get('offsetX'), $height - $cover->get('offsetY'));
         $origImage = imagecreatefromstring($data);
         imagecopyresampled($image_p, $origImage, 0, 0, $cover->get('offsetX'), $cover->get('offsetY'), $width, $height, $width, $height);
         if (!imagejpeg($image_p, $this->getAvatarPath() . '/' . $tmpImgName, 100)) {
             return false;
         }
     }
     $cover->set('type', "image/jpeg");
     return $this->setCoverPhoto($cover);
 }
Example #2
0
 function migrateSocialAvatarToProfile($joomlaId, $socialUserId)
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.utilities.utility');
     $avatarURL = $this->getAvatarURL($socialUserId, true);
     if ($avatarURL == null) {
         $this->setDefaultAvatar($joomlaId);
         return false;
     }
     $data = SCSocialUtilities::getRemoteContent($avatarURL);
     if ($data) {
         $baseImgPath = $this->getAvatarPath();
         $tmpImgName = 'scprofile_' . $joomlaId . '_pic_tmp.jpg';
         JFile::write($baseImgPath . '/' . $tmpImgName, $data);
         if ($this->updateAvatar($tmpImgName, $joomlaId, $socialUserId)) {
             return true;
         }
     }
     # there was a problem adding the avatar, use the default
     $this->setDefaultAvatar($joomlaId);
     return false;
 }