Properly unlink all old avatars when deleting/uploading a new
We're also now using $config['image']['jpegquality'] to determine the quality setting for resized images. To set Avatar max size, adjust $config['avatar']['maxsize'] The getAvatar call now throws exceptions too. Related changes applied. Now let's move Profile->avatarUrl to the Avatar class!
This commit is contained in:
parent
a7e748479c
commit
b0dfc70a54
|
@ -129,7 +129,6 @@ class AllrssAction extends Rss10Action
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
return $avatar ? $avatar->url : null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,6 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$profile = $this->user->getProfile();
|
$profile = $this->user->getProfile();
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
$title = sprintf(
|
$title = sprintf(
|
||||||
|
@ -120,15 +119,10 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
|
||||||
$profile->getBestName(),
|
$profile->getBestName(),
|
||||||
$this->user->nickname
|
$this->user->nickname
|
||||||
);
|
);
|
||||||
$logo = !empty($avatar)
|
|
||||||
? $avatar->displayUrl()
|
|
||||||
: Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
$link = common_local_url(
|
|
||||||
'showfavorites',
|
|
||||||
array('nickname' => $this->user->nickname)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
$logo = $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
|
$link = common_local_url('showfavorites',
|
||||||
|
array('nickname' => $this->user->nickname));
|
||||||
$self = $this->getSelfUri();
|
$self = $this->getSelfUri();
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
|
|
|
@ -200,7 +200,6 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$profile = $this->user->getProfile();
|
$profile = $this->user->getProfile();
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
// TRANS: Title of API timeline for a user and friends.
|
// TRANS: Title of API timeline for a user and friends.
|
||||||
// TRANS: %s is a username.
|
// TRANS: %s is a username.
|
||||||
|
@ -215,17 +214,11 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
|
||||||
$sitename
|
$sitename
|
||||||
);
|
);
|
||||||
|
|
||||||
$link = common_local_url(
|
$logo = $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
'all',
|
$link = common_local_url('all',
|
||||||
array('nickname' => $this->user->nickname)
|
array('nickname' => $this->user->nickname));
|
||||||
);
|
|
||||||
|
|
||||||
$self = $this->getSelfUri();
|
$self = $this->getSelfUri();
|
||||||
|
|
||||||
$logo = (!empty($avatar))
|
|
||||||
? $avatar->displayUrl()
|
|
||||||
: Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->showXmlTimeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
|
|
|
@ -105,7 +105,6 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$profile = $this->user->getProfile();
|
$profile = $this->user->getProfile();
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
// TRANS: Timeline title for user and friends. %s is a user nickname.
|
// TRANS: Timeline title for user and friends. %s is a user nickname.
|
||||||
$title = sprintf(_("%s and friends"), $this->user->nickname);
|
$title = sprintf(_("%s and friends"), $this->user->nickname);
|
||||||
|
@ -118,17 +117,11 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
|
||||||
$this->user->nickname, $sitename
|
$this->user->nickname, $sitename
|
||||||
);
|
);
|
||||||
|
|
||||||
$link = common_local_url(
|
$logo = $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
'all',
|
$link = common_local_url('all',
|
||||||
array('nickname' => $this->user->nickname)
|
array('nickname' => $this->user->nickname));
|
||||||
);
|
|
||||||
|
|
||||||
$self = $this->getSelfUri();
|
$self = $this->getSelfUri();
|
||||||
|
|
||||||
$logo = (!empty($avatar))
|
|
||||||
? $avatar->displayUrl()
|
|
||||||
: Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
$this->showXmlTimeline($this->notices);
|
$this->showXmlTimeline($this->notices);
|
||||||
|
|
|
@ -104,7 +104,6 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$profile = $this->user->getProfile();
|
$profile = $this->user->getProfile();
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
$title = sprintf(
|
$title = sprintf(
|
||||||
|
@ -115,11 +114,10 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
|
||||||
);
|
);
|
||||||
$taguribase = TagURI::base();
|
$taguribase = TagURI::base();
|
||||||
$id = "tag:$taguribase:Mentions:" . $this->user->id;
|
$id = "tag:$taguribase:Mentions:" . $this->user->id;
|
||||||
$link = common_local_url(
|
|
||||||
'replies',
|
|
||||||
array('nickname' => $this->user->nickname)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
$logo = $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
|
$link = common_local_url('replies',
|
||||||
|
array('nickname' => $this->user->nickname));
|
||||||
$self = $this->getSelfUri();
|
$self = $this->getSelfUri();
|
||||||
|
|
||||||
$subtitle = sprintf(
|
$subtitle = sprintf(
|
||||||
|
@ -129,7 +127,6 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
|
||||||
_('%1$s updates that reply to updates from %2$s / %3$s.'),
|
_('%1$s updates that reply to updates from %2$s / %3$s.'),
|
||||||
$sitename, $this->user->nickname, $profile->getBestName()
|
$sitename, $this->user->nickname, $profile->getBestName()
|
||||||
);
|
);
|
||||||
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
|
|
|
@ -90,12 +90,7 @@ class ApiUserProfileImageAction extends ApiPrivateAuthAction
|
||||||
}
|
}
|
||||||
|
|
||||||
$size = $this->avatarSize();
|
$size = $this->avatarSize();
|
||||||
$avatar = $profile->getAvatar($size);
|
$url = $profile->avatarUrl($size);
|
||||||
if ($avatar) {
|
|
||||||
$url = $avatar->displayUrl();
|
|
||||||
} else {
|
|
||||||
$url = Avatar::defaultImage($size);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't actually output JSON or XML data -- redirect!
|
// We don't actually output JSON or XML data -- redirect!
|
||||||
common_redirect($url, 302);
|
common_redirect($url, 302);
|
||||||
|
|
|
@ -28,19 +28,18 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve user avatar by nickname action class.
|
* Retrieve user avatar by nickname action class.
|
||||||
*
|
*
|
||||||
* @category Action
|
* @category Action
|
||||||
* @package StatusNet
|
* @package GNUSocial
|
||||||
* @author Evan Prodromou <evan@status.net>
|
* @author Evan Prodromou <evan@status.net>
|
||||||
* @author Robin Millette <millette@status.net>
|
* @author Robin Millette <millette@status.net>
|
||||||
|
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
||||||
* @link http://status.net/
|
* @link http://www.gnu.org/software/social/
|
||||||
*/
|
*/
|
||||||
class AvatarbynicknameAction extends Action
|
class AvatarbynicknameAction extends Action
|
||||||
{
|
{
|
||||||
|
@ -51,55 +50,38 @@ class AvatarbynicknameAction extends Action
|
||||||
*
|
*
|
||||||
* @return boolean false if nickname or user isn't found
|
* @return boolean false if nickname or user isn't found
|
||||||
*/
|
*/
|
||||||
function handle($args)
|
protected function handle()
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle();
|
||||||
$nickname = $this->trimmed('nickname');
|
$nickname = $this->trimmed('nickname');
|
||||||
if (!$nickname) {
|
if (!$nickname) {
|
||||||
// TRANS: Client error displayed trying to get an avatar without providing a nickname.
|
// TRANS: Client error displayed trying to get an avatar without providing a nickname.
|
||||||
$this->clientError(_('No nickname.'));
|
$this->clientError(_('No nickname.'));
|
||||||
return;
|
|
||||||
}
|
|
||||||
$size = $this->trimmed('size');
|
|
||||||
if (!$size) {
|
|
||||||
// TRANS: Client error displayed trying to get an avatar without providing an avatar size.
|
|
||||||
$this->clientError(_('No size.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$size = strtolower($size);
|
|
||||||
if (!in_array($size, array('original', '96', '48', '24'))) {
|
|
||||||
// TRANS: Client error displayed trying to get an avatar providing an invalid avatar size.
|
|
||||||
$this->clientError(_('Invalid size.'));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
$size = $this->trimmed('size') ?: 'original';
|
||||||
|
|
||||||
$user = User::getKV('nickname', $nickname);
|
$user = User::getKV('nickname', $nickname);
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
// TRANS: Client error displayed trying to get an avatar for a non-existing user.
|
// TRANS: Client error displayed trying to get an avatar for a non-existing user.
|
||||||
$this->clientError(_('No such user.'));
|
$this->clientError(_('No such user.'));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
// TRANS: Error message displayed when referring to a user without a profile.
|
// TRANS: Error message displayed when referring to a user without a profile.
|
||||||
$this->clientError(_('User has no profile.'));
|
$this->clientError(_('User has no profile.'));
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($size == 'original') {
|
|
||||||
$avatar = $profile->getOriginal();
|
|
||||||
} else {
|
|
||||||
$avatar = $profile->getAvatar($size+0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($avatar) {
|
if ($size === 'original') {
|
||||||
|
try {
|
||||||
|
$avatar = Avatar::getOriginal($profile);
|
||||||
$url = $avatar->url;
|
$url = $avatar->url;
|
||||||
} else {
|
} catch (Exception $e) {
|
||||||
if ($size == 'original') {
|
|
||||||
$url = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
$url = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$url = Avatar::defaultImage($size+0);
|
$url = $profile->avatarUrl($size);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
common_redirect($url, 302);
|
common_redirect($url, 302);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,9 +140,8 @@ class AvatarsettingsAction extends SettingsAction
|
||||||
// No original avatar found!
|
// No original avatar found!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
|
||||||
if ($avatar) {
|
|
||||||
$this->elementStart('li', array('id' => 'avatar_preview',
|
$this->elementStart('li', array('id' => 'avatar_preview',
|
||||||
'class' => 'avatar_view'));
|
'class' => 'avatar_view'));
|
||||||
// TRANS: Header on avatar upload page for thumbnail of to be used rendition of uploaded avatar (h2).
|
// TRANS: Header on avatar upload page for thumbnail of to be used rendition of uploaded avatar (h2).
|
||||||
|
@ -158,6 +157,8 @@ class AvatarsettingsAction extends SettingsAction
|
||||||
$this->submit('delete', _m('BUTTON','Delete'));
|
$this->submit('delete', _m('BUTTON','Delete'));
|
||||||
}
|
}
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// No previously uploaded avatar to preview.
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->elementStart('li', array ('id' => 'settings_attach'));
|
$this->elementStart('li', array ('id' => 'settings_attach'));
|
||||||
|
@ -354,7 +355,7 @@ class AvatarsettingsAction extends SettingsAction
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function cropAvatar()
|
public function cropAvatar()
|
||||||
{
|
{
|
||||||
$filedata = $_SESSION['FILEDATA'];
|
$filedata = $_SESSION['FILEDATA'];
|
||||||
|
|
||||||
|
@ -371,7 +372,7 @@ class AvatarsettingsAction extends SettingsAction
|
||||||
$dest_y = $this->arg('avatar_crop_y') ? $this->arg('avatar_crop_y'):0;
|
$dest_y = $this->arg('avatar_crop_y') ? $this->arg('avatar_crop_y'):0;
|
||||||
$dest_w = $this->arg('avatar_crop_w') ? $this->arg('avatar_crop_w'):$file_d;
|
$dest_w = $this->arg('avatar_crop_w') ? $this->arg('avatar_crop_w'):$file_d;
|
||||||
$dest_h = $this->arg('avatar_crop_h') ? $this->arg('avatar_crop_h'):$file_d;
|
$dest_h = $this->arg('avatar_crop_h') ? $this->arg('avatar_crop_h'):$file_d;
|
||||||
$size = min($dest_w, $dest_h, MAX_ORIGINAL);
|
$size = floor(min($dest_w, $dest_h, MAX_ORIGINAL));
|
||||||
|
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
|
@ -146,11 +146,13 @@ class FoafAction extends Action
|
||||||
$this->elementStart('img');
|
$this->elementStart('img');
|
||||||
$this->elementStart('Image', array('rdf:about' => $avatar->url));
|
$this->elementStart('Image', array('rdf:about' => $avatar->url));
|
||||||
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
|
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
|
||||||
$scaled = $this->profile->getAvatar($size);
|
try {
|
||||||
if (!$scaled->original) { // sometimes the original has one of our scaled sizes
|
$scaled = Avatar::getOriginal($this->profile);
|
||||||
$this->elementStart('thumbnail');
|
$this->elementStart('thumbnail');
|
||||||
$this->element('Image', array('rdf:about' => $scaled->url));
|
$this->element('Image', array('rdf:about' => $scaled->url));
|
||||||
$this->elementEnd('thumbnail');
|
$this->elementEnd('thumbnail');
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// This avatar did not exist
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->elementEnd('Image');
|
$this->elementEnd('Image');
|
||||||
|
|
|
@ -78,13 +78,8 @@ class RepliesrssAction extends Rss10Action
|
||||||
|
|
||||||
function getImage()
|
function getImage()
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
$profile = $this->user->getProfile();
|
||||||
$profile = $user->getProfile();
|
return $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
if (!$profile) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
return ($avatar) ? $avatar->url : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isReadOnly($args)
|
function isReadOnly($args)
|
||||||
|
|
|
@ -102,7 +102,11 @@ class ShownoticeAction extends Action
|
||||||
|
|
||||||
$this->user = User::getKV('id', $this->profile->id);
|
$this->user = User::getKV('id', $this->profile->id);
|
||||||
|
|
||||||
|
try {
|
||||||
$this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->avatar = null;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -317,10 +321,7 @@ class ShownoticeAction extends Action
|
||||||
'title'=>'oEmbed'),null);
|
'title'=>'oEmbed'),null);
|
||||||
|
|
||||||
// Extras to aid in sharing notices to Facebook
|
// Extras to aid in sharing notices to Facebook
|
||||||
$avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$avatarUrl = $this->profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
$avatarUrl = ($avatar) ?
|
|
||||||
$avatar->displayUrl() :
|
|
||||||
Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
|
||||||
$this->element('meta', array('property' => 'og:image',
|
$this->element('meta', array('property' => 'og:image',
|
||||||
'content' => $avatarUrl));
|
'content' => $avatarUrl));
|
||||||
$this->element('meta', array('property' => 'og:description',
|
$this->element('meta', array('property' => 'og:description',
|
||||||
|
|
|
@ -107,8 +107,8 @@ class TagprofileAction extends Action
|
||||||
// TRANS: Header in list form.
|
// TRANS: Header in list form.
|
||||||
$this->element('h2', null, _('User profile'));
|
$this->element('h2', null, _('User profile'));
|
||||||
|
|
||||||
$avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$avatarUrl = $this->profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
$this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE),
|
$this->element('img', array('src' => $avatarUrl,
|
||||||
'class' => 'photo avatar entity_depiction',
|
'class' => 'photo avatar entity_depiction',
|
||||||
'width' => AVATAR_PROFILE_SIZE,
|
'width' => AVATAR_PROFILE_SIZE,
|
||||||
'height' => AVATAR_PROFILE_SIZE,
|
'height' => AVATAR_PROFILE_SIZE,
|
||||||
|
|
|
@ -102,14 +102,12 @@ class UserrssAction extends Rss10Action
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
if (!$profile) {
|
try {
|
||||||
common_log_db_error($user, 'SELECT', __FILE__);
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
// TRANS: Error message displayed when referring to a user without a profile.
|
return $avatar->url;
|
||||||
$this->serverError(_('User has no profile.'));
|
} catch (Exception $e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
return ($avatar) ? $avatar->url : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// override parent to add X-SUP-ID URL
|
// override parent to add X-SUP-ID URL
|
||||||
|
|
|
@ -49,8 +49,8 @@ class Avatar extends Managed_DataObject
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// We clean up the file, too
|
|
||||||
|
|
||||||
|
// We clean up the file, too
|
||||||
function delete()
|
function delete()
|
||||||
{
|
{
|
||||||
$filename = $this->filename;
|
$filename = $this->filename;
|
||||||
|
@ -59,11 +59,26 @@ class Avatar extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function deleteFromProfile(Profile $target) {
|
/*
|
||||||
$avatars = Avatar::getProfileAvatars($target->id);
|
* Deletes all avatars (but may spare the original) from a profile.
|
||||||
|
*
|
||||||
|
* @param Profile $target The profile we're deleting avatars of.
|
||||||
|
* @param boolean $original Whether original should be removed or not.
|
||||||
|
*/
|
||||||
|
public static function deleteFromProfile(Profile $target, $original=true) {
|
||||||
|
try {
|
||||||
|
$avatars = self::getProfileAvatars($target);
|
||||||
foreach ($avatars as $avatar) {
|
foreach ($avatars as $avatar) {
|
||||||
|
if ($avatar->original && !$original) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$avatar->delete();
|
$avatar->delete();
|
||||||
}
|
}
|
||||||
|
} catch (NoResultException $e) {
|
||||||
|
// There are no avatars to delete, a sort of success.
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getOriginal(Profile $target)
|
public static function getOriginal(Profile $target)
|
||||||
|
@ -77,9 +92,21 @@ class Avatar extends Managed_DataObject
|
||||||
return $avatar;
|
return $avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function hasOriginal($profile) {
|
||||||
|
try {
|
||||||
|
$avatar = Avatar::getOriginal($profile);
|
||||||
|
} catch (NoResultException $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !file_exists(Avatar::path($avatar->filename));
|
||||||
|
}
|
||||||
|
|
||||||
public static function getProfileAvatars(Profile $target) {
|
public static function getProfileAvatars(Profile $target) {
|
||||||
$avatar = new Avatar();
|
$avatar = new Avatar();
|
||||||
$avatar->profile_id = $target->id;
|
$avatar->profile_id = $target->id;
|
||||||
|
if (!$avatar->find()) {
|
||||||
|
throw new NoResultException($avatar);
|
||||||
|
}
|
||||||
return $avatar->fetchAll();
|
return $avatar->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,9 +187,9 @@ class Avatar extends Managed_DataObject
|
||||||
|
|
||||||
static function newSize(Profile $target, $size) {
|
static function newSize(Profile $target, $size) {
|
||||||
$size = floor($size);
|
$size = floor($size);
|
||||||
if ($size <1 || $size > 999) {
|
if ($size < 1 || $size > common_config('avatar', 'maxsize')) {
|
||||||
// TRANS: An error message when avatar size is unreasonable
|
// TRANS: An error message when avatar size is unreasonable
|
||||||
throw new Exception(_m('Unreasonable avatar size'));
|
throw new Exception(_m('Avatar size too large'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$original = Avatar::getOriginal($target);
|
$original = Avatar::getOriginal($target);
|
||||||
|
@ -175,7 +202,8 @@ class Avatar extends Managed_DataObject
|
||||||
$scaled->width = $size;
|
$scaled->width = $size;
|
||||||
$scaled->height = $size;
|
$scaled->height = $size;
|
||||||
$scaled->url = Avatar::url($filename);
|
$scaled->url = Avatar::url($filename);
|
||||||
$scaled->created = DB_DataObject_Cast::dateTime();
|
$scaled->filename = $filename;
|
||||||
|
$scaled->created = common_sql_now();
|
||||||
|
|
||||||
if (!$scaled->insert()) {
|
if (!$scaled->insert()) {
|
||||||
// TRANS: An error message when unable to insert avatar data into the db
|
// TRANS: An error message when unable to insert avatar data into the db
|
||||||
|
|
|
@ -111,7 +111,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a multi-instance object in an array
|
* Get a multi-instance object separated into an array
|
||||||
*
|
*
|
||||||
* This is a utility method to get multiple instances with a given set of
|
* This is a utility method to get multiple instances with a given set of
|
||||||
* values for a specific key column. Usually used for the primary key when
|
* values for a specific key column. Usually used for the primary key when
|
||||||
|
|
|
@ -276,7 +276,6 @@ class Memcached_DataObject extends Safe_DataObject
|
||||||
throw new NoResultException($i);
|
throw new NoResultException($i);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(__CLASS__ . "() got {$i->N} results for class $cls key $keyCol");
|
|
||||||
return $i;
|
return $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,17 +116,20 @@ class Profile extends Managed_DataObject
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $_avatars;
|
|
||||||
|
|
||||||
public function getAvatar($width, $height=null)
|
public function getAvatar($width, $height=null)
|
||||||
{
|
{
|
||||||
|
$width = (int) floor($width);
|
||||||
|
|
||||||
if (is_null($height)) {
|
if (is_null($height)) {
|
||||||
$height = $width;
|
$height = $width;
|
||||||
}
|
}
|
||||||
|
|
||||||
$avatar = $this->_getAvatar($width);
|
try {
|
||||||
|
return $this->_getAvatar($width);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$avatar = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($avatar)) {
|
|
||||||
if (Event::handle('StartProfileGetAvatar', array($this, $width, &$avatar))) {
|
if (Event::handle('StartProfileGetAvatar', array($this, $width, &$avatar))) {
|
||||||
$avatar = Avatar::pkeyGet(
|
$avatar = Avatar::pkeyGet(
|
||||||
array(
|
array(
|
||||||
|
@ -138,30 +141,22 @@ class Profile extends Managed_DataObject
|
||||||
Event::handle('EndProfileGetAvatar', array($this, $width, &$avatar));
|
Event::handle('EndProfileGetAvatar', array($this, $width, &$avatar));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if-empty within an if-empty? Let's find a prettier solution...
|
if (is_null($avatar)) {
|
||||||
if (empty($avatar)) {
|
|
||||||
// Obviously we can't find an avatar, so let's resize the original!
|
// Obviously we can't find an avatar, so let's resize the original!
|
||||||
try {
|
|
||||||
$avatar = Avatar::newSize($this, $width);
|
$avatar = Avatar::newSize($this, $width);
|
||||||
} catch (Exception $e) {
|
|
||||||
// Could not generate a resized avatar. How do we handle it?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cache the avatar for future use
|
// cache the avatar for future use
|
||||||
$this->_fillAvatar($width, $avatar);
|
$this->_fillAvatar($width, $avatar);
|
||||||
}
|
|
||||||
|
|
||||||
return $avatar;
|
return $avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected $_avatars = array();
|
||||||
|
|
||||||
// XXX: @Fix me gargargar
|
// XXX: @Fix me gargargar
|
||||||
function _getAvatar($width)
|
function _getAvatar($width)
|
||||||
{
|
{
|
||||||
if (empty($this->_avatars)) {
|
|
||||||
$this->_avatars = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
// GAR! I cannot figure out where _avatars gets pre-filled with the avatar from
|
// GAR! I cannot figure out where _avatars gets pre-filled with the avatar from
|
||||||
// the previously used profile! Please shoot me now! --Zach
|
// the previously used profile! Please shoot me now! --Zach
|
||||||
if (array_key_exists($width, $this->_avatars)) {
|
if (array_key_exists($width, $this->_avatars)) {
|
||||||
|
@ -171,7 +166,7 @@ class Profile extends Managed_DataObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
throw new Exception('No cached avatar available for size ');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _fillAvatar($width, $avatar)
|
protected function _fillAvatar($width, $avatar)
|
||||||
|
@ -207,8 +202,8 @@ class Profile extends Managed_DataObject
|
||||||
$avatar->created = DB_DataObject_Cast::dateTime(); # current time
|
$avatar->created = DB_DataObject_Cast::dateTime(); # current time
|
||||||
|
|
||||||
// XXX: start a transaction here
|
// XXX: start a transaction here
|
||||||
|
if (!Avatar::deleteFromProfile($this, true) || !$avatar->insert()) {
|
||||||
if (!$this->delete_avatars() || !$avatar->insert()) {
|
// If we can't delete the old avatars, let's abort right here.
|
||||||
@unlink(Avatar::path($filename));
|
@unlink(Avatar::path($filename));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -227,30 +222,6 @@ class Profile extends Managed_DataObject
|
||||||
return $avatar;
|
return $avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete attached avatars for this user from the database and filesystem.
|
|
||||||
* This should be used instead of a batch delete() to ensure that files
|
|
||||||
* get removed correctly.
|
|
||||||
*
|
|
||||||
* @param boolean $original true to delete only the original-size file
|
|
||||||
* @return <type>
|
|
||||||
*/
|
|
||||||
function delete_avatars($original=true)
|
|
||||||
{
|
|
||||||
$avatar = new Avatar();
|
|
||||||
$avatar->profile_id = $this->id;
|
|
||||||
$avatar->find();
|
|
||||||
while ($avatar->fetch()) {
|
|
||||||
if ($avatar->original) {
|
|
||||||
if ($original == false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$avatar->delete();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets either the full name (if filled) or the nickname.
|
* Gets either the full name (if filled) or the nickname.
|
||||||
*
|
*
|
||||||
|
@ -636,10 +607,11 @@ class Profile extends Managed_DataObject
|
||||||
|
|
||||||
function avatarUrl($size=AVATAR_PROFILE_SIZE)
|
function avatarUrl($size=AVATAR_PROFILE_SIZE)
|
||||||
{
|
{
|
||||||
|
$size = floor($size);
|
||||||
|
try {
|
||||||
$avatar = $this->getAvatar($size);
|
$avatar = $this->getAvatar($size);
|
||||||
if ($avatar) {
|
|
||||||
return $avatar->displayUrl();
|
return $avatar->displayUrl();
|
||||||
} else {
|
} catch (Exception $e) {
|
||||||
return Avatar::defaultImage($size);
|
return Avatar::defaultImage($size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -913,7 +885,7 @@ class Profile extends Managed_DataObject
|
||||||
$this->_deleteMessages();
|
$this->_deleteMessages();
|
||||||
$this->_deleteTags();
|
$this->_deleteTags();
|
||||||
$this->_deleteBlocks();
|
$this->_deleteBlocks();
|
||||||
$this->delete_avatars();
|
Avatar::deleteFromProfile($this, true);
|
||||||
|
|
||||||
// Warning: delete() will run on the batch objects,
|
// Warning: delete() will run on the batch objects,
|
||||||
// not on individual objects.
|
// not on individual objects.
|
||||||
|
|
|
@ -60,13 +60,7 @@ class AccountProfileBlock extends ProfileBlock
|
||||||
|
|
||||||
function avatar()
|
function avatar()
|
||||||
{
|
{
|
||||||
$avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
|
return $this->profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
if (empty($avatar)) {
|
|
||||||
$avatar = $this->profile->getAvatar(73);
|
|
||||||
}
|
|
||||||
return (!empty($avatar)) ?
|
|
||||||
$avatar->displayUrl() :
|
|
||||||
Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function name()
|
function name()
|
||||||
|
|
|
@ -474,27 +474,15 @@ class ActivityObject
|
||||||
|
|
||||||
foreach ($sizes as $size) {
|
foreach ($sizes as $size) {
|
||||||
$alink = null;
|
$alink = null;
|
||||||
|
try {
|
||||||
$avatar = $profile->getAvatar($size);
|
$avatar = $profile->getAvatar($size);
|
||||||
|
|
||||||
if (!empty($avatar)) {
|
|
||||||
$alink = AvatarLink::fromAvatar($avatar);
|
$alink = AvatarLink::fromAvatar($avatar);
|
||||||
} else {
|
} catch (Exception $e) {
|
||||||
$alink = new AvatarLink();
|
$alink = new AvatarLink();
|
||||||
$alink->type = 'image/png';
|
$alink->type = 'image/png';
|
||||||
$alink->height = $size;
|
$alink->height = $size;
|
||||||
$alink->width = $size;
|
$alink->width = $size;
|
||||||
$alink->url = Avatar::defaultImage($size);
|
$alink->url = Avatar::defaultImage($size);
|
||||||
|
|
||||||
if ($size == AVATAR_PROFILE_SIZE) {
|
|
||||||
// Hack for Twitter import: we don't have a 96x96 image,
|
|
||||||
// but we do have a 73x73 image. For now, fake it with that.
|
|
||||||
$avatar = $profile->getAvatar(73);
|
|
||||||
if ($avatar) {
|
|
||||||
$alink = AvatarLink::fromAvatar($avatar);
|
|
||||||
$alink->height= $size;
|
|
||||||
$alink->width = $size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$object->avatarLinks[] = $alink;
|
$object->avatarLinks[] = $alink;
|
||||||
|
|
|
@ -214,9 +214,7 @@ class ApiAction extends Action
|
||||||
$twitter_user['location'] = ($profile->location) ? $profile->location : null;
|
$twitter_user['location'] = ($profile->location) ? $profile->location : null;
|
||||||
$twitter_user['description'] = ($profile->bio) ? $profile->bio : null;
|
$twitter_user['description'] = ($profile->bio) ? $profile->bio : null;
|
||||||
|
|
||||||
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
$twitter_user['profile_image_url'] = $profile->avatarUrl(AVATAR_STREAM_SIZE);
|
||||||
$twitter_user['profile_image_url'] = ($avatar) ? $avatar->displayUrl() :
|
|
||||||
Avatar::defaultImage(AVATAR_STREAM_SIZE);
|
|
||||||
|
|
||||||
$twitter_user['url'] = ($profile->homepage) ? $profile->homepage : null;
|
$twitter_user['url'] = ($profile->homepage) ? $profile->homepage : null;
|
||||||
$twitter_user['protected'] = (!empty($user) && $user->private_stream) ? true : false;
|
$twitter_user['protected'] = (!empty($user) && $user->private_stream) ? true : false;
|
||||||
|
@ -995,10 +993,13 @@ class ApiAction extends Action
|
||||||
$entry['author-name'] = $from->getBestName();
|
$entry['author-name'] = $from->getBestName();
|
||||||
$entry['author-uri'] = $from->homepage;
|
$entry['author-uri'] = $from->homepage;
|
||||||
|
|
||||||
|
$entry['avatar'] = $from->avatarUrl(AVATAR_STREAM_SIZE);
|
||||||
|
try {
|
||||||
$avatar = $from->getAvatar(AVATAR_STREAM_SIZE);
|
$avatar = $from->getAvatar(AVATAR_STREAM_SIZE);
|
||||||
|
$entry['avatar-type'] = $avatar->mediatype;
|
||||||
$entry['avatar'] = (!empty($avatar)) ? $avatar->url : Avatar::defaultImage(AVATAR_STREAM_SIZE);
|
} catch (Exception $e) {
|
||||||
$entry['avatar-type'] = (!empty($avatar)) ? $avatar->mediatype : 'image/png';
|
$entry['avatar-type'] = 'image/png';
|
||||||
|
}
|
||||||
|
|
||||||
// RSS item specific
|
// RSS item specific
|
||||||
|
|
||||||
|
|
|
@ -97,9 +97,7 @@ class AtomUserNoticeFeed extends AtomNoticeFeed
|
||||||
);
|
);
|
||||||
$this->setSubtitle($subtitle);
|
$this->setSubtitle($subtitle);
|
||||||
|
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$this->setLogo($profile->avatarUrl(AVATAR_PROFILE_SIZE));
|
||||||
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
|
||||||
$this->setLogo($logo);
|
|
||||||
|
|
||||||
$this->setUpdated('now');
|
$this->setUpdated('now');
|
||||||
|
|
||||||
|
|
|
@ -131,11 +131,14 @@ $default =
|
||||||
'restore' => true,
|
'restore' => true,
|
||||||
'delete' => false,
|
'delete' => false,
|
||||||
'move' => true),
|
'move' => true),
|
||||||
|
'image' =>
|
||||||
|
array('jpegquality' => 85),
|
||||||
'avatar' =>
|
'avatar' =>
|
||||||
array('server' => null,
|
array('server' => null,
|
||||||
'dir' => INSTALLDIR . '/avatar/',
|
'dir' => INSTALLDIR . '/avatar/',
|
||||||
'path' => $_path . '/avatar/',
|
'path' => $_path . '/avatar/',
|
||||||
'ssl' => null),
|
'ssl' => null,
|
||||||
|
'maxsize' => 300),
|
||||||
'background' =>
|
'background' =>
|
||||||
array('server' => null,
|
array('server' => null,
|
||||||
'dir' => INSTALLDIR . '/background/',
|
'dir' => INSTALLDIR . '/background/',
|
||||||
|
|
|
@ -63,13 +63,7 @@ class DefaultProfileBlock extends AccountProfileBlock
|
||||||
|
|
||||||
function avatar()
|
function avatar()
|
||||||
{
|
{
|
||||||
$avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
|
return $this->profile->avatarUrl(AVATAR_STREAM_SIZE);
|
||||||
if (empty($avatar)) {
|
|
||||||
$avatar = $this->profile->getAvatar(73);
|
|
||||||
}
|
|
||||||
return (!empty($avatar)) ?
|
|
||||||
$avatar->displayUrl() :
|
|
||||||
Avatar::defaultImage(AVATAR_STREAM_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function location()
|
function location()
|
||||||
|
|
|
@ -247,7 +247,7 @@ class ImageFile
|
||||||
imagegif($image_dest, $outpath);
|
imagegif($image_dest, $outpath);
|
||||||
break;
|
break;
|
||||||
case IMAGETYPE_JPEG:
|
case IMAGETYPE_JPEG:
|
||||||
imagejpeg($image_dest, $outpath, 100);
|
imagejpeg($image_dest, $outpath, common_config('image', 'jpegquality'));
|
||||||
break;
|
break;
|
||||||
case IMAGETYPE_PNG:
|
case IMAGETYPE_PNG:
|
||||||
imagepng($image_dest, $outpath);
|
imagepng($image_dest, $outpath);
|
||||||
|
|
|
@ -243,10 +243,7 @@ class ResultItem
|
||||||
|
|
||||||
$this->source = $this->getSourceLink($this->notice->source);
|
$this->source = $this->getSourceLink($this->notice->source);
|
||||||
|
|
||||||
$avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
|
$this->profile_image_url = $this->profile->avatarUrl(AVATAR_STREAM_SIZE);
|
||||||
|
|
||||||
$this->profile_image_url = ($avatar) ?
|
|
||||||
$avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE);
|
|
||||||
|
|
||||||
$this->created_at = common_date_rfc2822($this->notice->created);
|
$this->created_at = common_date_rfc2822($this->notice->created);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,10 +76,8 @@ abstract class MessageListItem extends Widget
|
||||||
$this->out->elementStart('span', 'vcard author');
|
$this->out->elementStart('span', 'vcard author');
|
||||||
$this->out->elementStart('a', array('href' => $profile->profileurl,
|
$this->out->elementStart('a', array('href' => $profile->profileurl,
|
||||||
'class' => 'url'));
|
'class' => 'url'));
|
||||||
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
$avatarUrl = $profile->avatarUrl(AVATAR_STREAM_SIZE);
|
||||||
$this->out->element('img', array('src' => ($avatar) ?
|
$this->out->element('img', array('src' => $avatarUrl,
|
||||||
$avatar->displayUrl() :
|
|
||||||
Avatar::defaultImage(AVATAR_STREAM_SIZE),
|
|
||||||
'class' => 'photo avatar',
|
'class' => 'photo avatar',
|
||||||
'width' => AVATAR_STREAM_SIZE,
|
'width' => AVATAR_STREAM_SIZE,
|
||||||
'height' => AVATAR_STREAM_SIZE,
|
'height' => AVATAR_STREAM_SIZE,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* StatusNet, the distributed open-source microblogging tool
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
*
|
*
|
||||||
* class for an exception when a database lookup returns no results
|
* Class for an exception when a database lookup returns no results
|
||||||
*
|
*
|
||||||
* PHP version 5
|
* PHP version 5
|
||||||
*
|
*
|
||||||
|
@ -20,26 +20,14 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* @category Exception
|
* @category Exception
|
||||||
* @package StatusNet
|
* @package GNUSocial
|
||||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
* @author Mikael Nordfeldth <mmn@hethane.se>
|
||||||
* @copyright 2013 Free Software Foundation, Inc.
|
* @copyright 2013 Free Software Foundation, Inc.
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||||
* @link http://status.net/
|
* @link http://www.gnu.org/software/social/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('GNUSOCIAL')) {
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class for an exception when a local user is not found by certain criteria
|
|
||||||
*
|
|
||||||
* @category Exception
|
|
||||||
* @package StatusNet
|
|
||||||
* @author Mikael Nordfeldth <mmn@hethane.se>
|
|
||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
|
||||||
* @link http://status.net/
|
|
||||||
*/
|
|
||||||
|
|
||||||
class NoResultException extends ServerException
|
class NoResultException extends ServerException
|
||||||
{
|
{
|
||||||
|
|
|
@ -327,11 +327,9 @@ class NoticeListItem extends Widget
|
||||||
{
|
{
|
||||||
$avatar_size = $this->avatarSize();
|
$avatar_size = $this->avatarSize();
|
||||||
|
|
||||||
$avatar = $this->profile->getAvatar($avatar_size);
|
$avatarUrl = $this->profile->avatarUrl($avatar_size);
|
||||||
|
|
||||||
$this->out->element('img', array('src' => ($avatar) ?
|
$this->out->element('img', array('src' => $avatarUrl,
|
||||||
$avatar->displayUrl() :
|
|
||||||
Avatar::defaultImage($avatar_size),
|
|
||||||
'class' => 'avatar photo',
|
'class' => 'avatar photo',
|
||||||
'width' => $avatar_size,
|
'width' => $avatar_size,
|
||||||
'height' => $avatar_size,
|
'height' => $avatar_size,
|
||||||
|
|
|
@ -78,14 +78,14 @@ class NoticeSection extends Section
|
||||||
}
|
}
|
||||||
$this->out->elementStart('li', 'hentry notice');
|
$this->out->elementStart('li', 'hentry notice');
|
||||||
$this->out->elementStart('div', 'entry-title');
|
$this->out->elementStart('div', 'entry-title');
|
||||||
$avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
|
|
||||||
$this->out->elementStart('span', 'vcard author');
|
$this->out->elementStart('span', 'vcard author');
|
||||||
$this->out->elementStart('a', array('title' => ($profile->fullname) ?
|
$this->out->elementStart('a', array('title' => ($profile->fullname) ?
|
||||||
$profile->fullname :
|
$profile->fullname :
|
||||||
$profile->nickname,
|
$profile->nickname,
|
||||||
'href' => $profile->profileurl,
|
'href' => $profile->profileurl,
|
||||||
'class' => 'url'));
|
'class' => 'url'));
|
||||||
$this->out->element('img', array('src' => (($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_MINI_SIZE)),
|
$avatarUrl = $profile->avatarUrl(AVATAR_MINI_SIZE);
|
||||||
|
$this->out->element('img', array('src' => $avatarUrl,
|
||||||
'width' => AVATAR_MINI_SIZE,
|
'width' => AVATAR_MINI_SIZE,
|
||||||
'height' => AVATAR_MINI_SIZE,
|
'height' => AVATAR_MINI_SIZE,
|
||||||
'class' => 'avatar photo',
|
'class' => 'avatar photo',
|
||||||
|
|
|
@ -283,11 +283,9 @@ class PeopletagListItem extends Widget
|
||||||
|
|
||||||
function showAvatar($size=AVATAR_STREAM_SIZE)
|
function showAvatar($size=AVATAR_STREAM_SIZE)
|
||||||
{
|
{
|
||||||
$avatar = $this->profile->getAvatar($size);
|
$avatarUrl = $this->profile->avatarUrl($size);
|
||||||
|
|
||||||
$this->out->element('img', array('src' => ($avatar) ?
|
$this->out->element('img', array('src' => $avatarUrl,
|
||||||
$avatar->displayUrl() :
|
|
||||||
Avatar::defaultImage($size),
|
|
||||||
'class' => 'avatar photo',
|
'class' => 'avatar photo',
|
||||||
'width' => $size,
|
'width' => $size,
|
||||||
'height' => $size,
|
'height' => $size,
|
||||||
|
|
|
@ -199,10 +199,10 @@ class ProfileListItem extends Widget
|
||||||
|
|
||||||
function showAvatar()
|
function showAvatar()
|
||||||
{
|
{
|
||||||
$avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
|
$avatarUrl = $this->profile->avatarUrl(AVATAR_STREAM_SIZE);
|
||||||
$aAttrs = $this->linkAttributes();
|
$aAttrs = $this->linkAttributes();
|
||||||
$this->out->elementStart('a', $aAttrs);
|
$this->out->elementStart('a', $aAttrs);
|
||||||
$this->out->element('img', array('src' => (!empty($avatar)) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE),
|
$this->out->element('img', array('src' => $avatarUrl,
|
||||||
'class' => 'photo avatar',
|
'class' => 'photo avatar',
|
||||||
'width' => AVATAR_STREAM_SIZE,
|
'width' => AVATAR_STREAM_SIZE,
|
||||||
'height' => AVATAR_STREAM_SIZE,
|
'height' => AVATAR_STREAM_SIZE,
|
||||||
|
|
|
@ -79,8 +79,8 @@ class ProfileMiniListItem extends ProfileListItem
|
||||||
if (Event::handle('StartProfileListItemAvatar', array($this))) {
|
if (Event::handle('StartProfileListItemAvatar', array($this))) {
|
||||||
$aAttrs = $this->linkAttributes();
|
$aAttrs = $this->linkAttributes();
|
||||||
$this->out->elementStart('a', $aAttrs);
|
$this->out->elementStart('a', $aAttrs);
|
||||||
$avatar = $this->profile->getAvatar(AVATAR_MINI_SIZE);
|
$avatarUrl = $this->profile->avatarUrl(AVATAR_MINI_SIZE);
|
||||||
$this->out->element('img', array('src' => (($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_MINI_SIZE)),
|
$this->out->element('img', array('src' => $avatarUrl,
|
||||||
'width' => AVATAR_MINI_SIZE,
|
'width' => AVATAR_MINI_SIZE,
|
||||||
'height' => AVATAR_MINI_SIZE,
|
'height' => AVATAR_MINI_SIZE,
|
||||||
'class' => 'avatar photo',
|
'class' => 'avatar photo',
|
||||||
|
|
|
@ -86,8 +86,8 @@ class ProfileSection extends Section
|
||||||
'rel' => 'contact member',
|
'rel' => 'contact member',
|
||||||
'class' => 'url'));
|
'class' => 'url'));
|
||||||
$this->out->text(' ');
|
$this->out->text(' ');
|
||||||
$avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
|
$avatarUrl = $profile->avatarUrl(AVATAR_MINI_SIZE);
|
||||||
$this->out->element('img', array('src' => (($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_MINI_SIZE)),
|
$this->out->element('img', array('src' => $avatarUrl,
|
||||||
'width' => AVATAR_MINI_SIZE,
|
'width' => AVATAR_MINI_SIZE,
|
||||||
'height' => AVATAR_MINI_SIZE,
|
'height' => AVATAR_MINI_SIZE,
|
||||||
'class' => 'avatar photo',
|
'class' => 'avatar photo',
|
||||||
|
|
|
@ -875,10 +875,13 @@ class Router
|
||||||
array('action' => 'showfavorites',
|
array('action' => 'showfavorites',
|
||||||
'nickname' => $nickname));
|
'nickname' => $nickname));
|
||||||
|
|
||||||
|
$m->connect('avatar',
|
||||||
|
array('action' => 'avatarbynickname',
|
||||||
|
'nickname' => $nickname));
|
||||||
$m->connect('avatar/:size',
|
$m->connect('avatar/:size',
|
||||||
array('action' => 'avatarbynickname',
|
array('action' => 'avatarbynickname',
|
||||||
'nickname' => $nickname),
|
'nickname' => $nickname),
|
||||||
array('size' => '(original|96|48|24)'));
|
array('size' => '(|original|\d+)'));
|
||||||
|
|
||||||
$m->connect('tag/:tag/rss',
|
$m->connect('tag/:tag/rss',
|
||||||
array('action' => 'userrss',
|
array('action' => 'userrss',
|
||||||
|
@ -1047,9 +1050,12 @@ class Router
|
||||||
array('action' => 'showfavorites'),
|
array('action' => 'showfavorites'),
|
||||||
array('nickname' => Nickname::DISPLAY_FMT));
|
array('nickname' => Nickname::DISPLAY_FMT));
|
||||||
|
|
||||||
|
$m->connect(':nickname/avatar',
|
||||||
|
array('action' => 'avatarbynickname'),
|
||||||
|
array('nickname' => Nickname::DISPLAY_FMT));
|
||||||
$m->connect(':nickname/avatar/:size',
|
$m->connect(':nickname/avatar/:size',
|
||||||
array('action' => 'avatarbynickname'),
|
array('action' => 'avatarbynickname'),
|
||||||
array('size' => '(original|96|48|24)',
|
array('size' => '(|original|\d+)',
|
||||||
'nickname' => Nickname::DISPLAY_FMT));
|
'nickname' => Nickname::DISPLAY_FMT));
|
||||||
|
|
||||||
$m->connect(':nickname/tag/:tag/rss',
|
$m->connect(':nickname/tag/:tag/rss',
|
||||||
|
|
|
@ -306,9 +306,8 @@ class TaggedProfileItem extends Widget
|
||||||
$this->out->elementStart('a', array('class' => 'url',
|
$this->out->elementStart('a', array('class' => 'url',
|
||||||
'href' => $this->profile->profileurl,
|
'href' => $this->profile->profileurl,
|
||||||
'title' => $this->profile->getBestName()));
|
'title' => $this->profile->getBestName()));
|
||||||
$avatar = $this->profile->getAvatar(AVATAR_MINI_SIZE);
|
$avatarUrl = $this->profile->avatarUrl(AVATAR_MINI_SIZE);
|
||||||
$this->out->element('img', array('src' => (($avatar) ? $avatar->displayUrl() :
|
$this->out->element('img', array('src' => $avatarUrl,
|
||||||
Avatar::defaultImage(AVATAR_MINI_SIZE)),
|
|
||||||
'width' => AVATAR_MINI_SIZE,
|
'width' => AVATAR_MINI_SIZE,
|
||||||
'height' => AVATAR_MINI_SIZE,
|
'height' => AVATAR_MINI_SIZE,
|
||||||
'class' => 'avatar photo',
|
'class' => 'avatar photo',
|
||||||
|
|
|
@ -2004,7 +2004,11 @@ function common_user_property($property)
|
||||||
return $profile->$property;
|
return $profile->$property;
|
||||||
break;
|
break;
|
||||||
case 'avatar':
|
case 'avatar':
|
||||||
|
try {
|
||||||
return $profile->getAvatar(AVATAR_STREAM_SIZE);
|
return $profile->getAvatar(AVATAR_STREAM_SIZE);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'bestname':
|
case 'bestname':
|
||||||
return $profile->getBestName();
|
return $profile->getBestName();
|
||||||
|
|
|
@ -141,33 +141,27 @@ class AutocompleteAction extends Action
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach($this->users as $user){
|
foreach($this->users as $user){
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
$avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
|
$avatarUrl = $profile->avatarUrl(AVATAR_MINI_SIZE);
|
||||||
// sigh.... encapsulate this upstream!
|
|
||||||
if ($avatar) {
|
|
||||||
$avatar = $avatar->displayUrl();
|
|
||||||
} else {
|
|
||||||
$avatar = Avatar::defaultImage(AVATAR_MINI_SIZE);
|
|
||||||
}
|
|
||||||
$results[] = array(
|
$results[] = array(
|
||||||
'value' => '@'.$profile->nickname,
|
'value' => '@'.$profile->nickname,
|
||||||
'nickname' => $profile->nickname,
|
'nickname' => $profile->nickname,
|
||||||
'label'=> $profile->getFancyName(),
|
'label'=> $profile->getFancyName(),
|
||||||
'avatar' => $avatar,
|
'avatar' => $avatarUrl,
|
||||||
'type' => 'user'
|
'type' => 'user'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
foreach($this->groups as $group){
|
foreach($this->groups as $group){
|
||||||
// sigh.... encapsulate this upstream!
|
// sigh.... encapsulate this upstream!
|
||||||
if ($group->mini_logo) {
|
if ($group->mini_logo) {
|
||||||
$avatar = $group->mini_logo;
|
$avatarUrl = $group->mini_logo;
|
||||||
} else {
|
} else {
|
||||||
$avatar = User_group::defaultLogo(AVATAR_MINI_SIZE);
|
$avatarUrl = User_group::defaultLogo(AVATAR_MINI_SIZE);
|
||||||
}
|
}
|
||||||
$results[] = array(
|
$results[] = array(
|
||||||
'value' => '!'.$group->nickname,
|
'value' => '!'.$group->nickname,
|
||||||
'nickname' => $group->nickname,
|
'nickname' => $group->nickname,
|
||||||
'label'=> $group->getFancyName(),
|
'label'=> $group->getFancyName(),
|
||||||
'avatar' => $avatar,
|
'avatar' => $avatarUrl,
|
||||||
'type' => 'group');
|
'type' => 'group');
|
||||||
}
|
}
|
||||||
print json_encode($results);
|
print json_encode($results);
|
||||||
|
|
|
@ -97,7 +97,6 @@ class ApiTimelineBookmarksAction extends ApiBareAuthAction
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$profile = $this->user->getProfile();
|
$profile = $this->user->getProfile();
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
$title = sprintf(
|
$title = sprintf(
|
||||||
|
@ -120,15 +119,10 @@ class ApiTimelineBookmarksAction extends ApiBareAuthAction
|
||||||
$profile->getBestName(),
|
$profile->getBestName(),
|
||||||
$this->user->nickname
|
$this->user->nickname
|
||||||
);
|
);
|
||||||
$logo = !empty($avatar)
|
|
||||||
? $avatar->displayUrl()
|
|
||||||
: Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
$link = common_local_url(
|
|
||||||
'bookmarks',
|
|
||||||
array('nickname' => $this->user->nickname)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
$logo = $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
|
$link = common_local_url('bookmarks',
|
||||||
|
array('nickname' => $this->user->nickname));
|
||||||
$self = $this->getSelfUri();
|
$self = $this->getSelfUri();
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
|
|
|
@ -151,7 +151,7 @@ class UserEmailSummaryHandler extends QueueHandler
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
$avatarUrl = $profile->avatarUrl(AVATAR_STREAM_SIZE);
|
||||||
|
|
||||||
$out->elementStart('tr');
|
$out->elementStart('tr');
|
||||||
$out->elementStart('td', array('width' => AVATAR_STREAM_SIZE,
|
$out->elementStart('td', array('width' => AVATAR_STREAM_SIZE,
|
||||||
|
@ -159,9 +159,7 @@ class UserEmailSummaryHandler extends QueueHandler
|
||||||
'align' => 'left',
|
'align' => 'left',
|
||||||
'valign' => 'top',
|
'valign' => 'top',
|
||||||
'style' => 'border-bottom: 1px dotted #C5CEE3; padding: 10px 6px 10px 6px;'));
|
'style' => 'border-bottom: 1px dotted #C5CEE3; padding: 10px 6px 10px 6px;'));
|
||||||
$out->element('img', array('src' => ($avatar) ?
|
$out->element('img', array('src' => $avatarUrl,
|
||||||
$avatar->displayUrl() :
|
|
||||||
Avatar::defaultImage(AVATAR_STREAM_SIZE),
|
|
||||||
'width' => AVATAR_STREAM_SIZE,
|
'width' => AVATAR_STREAM_SIZE,
|
||||||
'height' => AVATAR_STREAM_SIZE,
|
'height' => AVATAR_STREAM_SIZE,
|
||||||
'alt' => $profile->getBestName()));
|
'alt' => $profile->getBestName()));
|
||||||
|
|
|
@ -46,7 +46,6 @@ class BioAction extends Action
|
||||||
$this->profile = Profile::getKV('nickname', $args[1]['nickname']);
|
$this->profile = Profile::getKV('nickname', $args[1]['nickname']);
|
||||||
//die(print_r($this->profile));
|
//die(print_r($this->profile));
|
||||||
gnusocial_profile_merge($this->profile);
|
gnusocial_profile_merge($this->profile);
|
||||||
$this->avatar = $this->profile->getAvatar(96);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -174,9 +174,12 @@ class ShowgroupmessageAction extends Action
|
||||||
*/
|
*/
|
||||||
function etag()
|
function etag()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$avatar = $this->sender->getAvatar(AVATAR_STREAM_SIZE);
|
$avatar = $this->sender->getAvatar(AVATAR_STREAM_SIZE);
|
||||||
|
$avtime = strtotime($avatar->modified);
|
||||||
$avtime = ($avatar) ? strtotime($avatar->modified) : 0;
|
} catch (Exception $e) {
|
||||||
|
$avtime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 'W/"' . implode(':', array($this->arg('action'),
|
return 'W/"' . implode(':', array($this->arg('action'),
|
||||||
common_user_cache_hash(),
|
common_user_cache_hash(),
|
||||||
|
|
|
@ -78,10 +78,8 @@ class GroupMessageListItem extends Widget
|
||||||
$this->out->elementStart('a',
|
$this->out->elementStart('a',
|
||||||
array('href' => $sender->profileurl,
|
array('href' => $sender->profileurl,
|
||||||
'class' => 'url'));
|
'class' => 'url'));
|
||||||
$avatar = $sender->getAvatar(AVATAR_STREAM_SIZE);
|
$avatarUrl = $sender->avatarUrl(AVATAR_STREAM_SIZE);
|
||||||
$this->out->element('img', array('src' => ($avatar) ?
|
$this->out->element('img', array('src' => $avatarUrl,
|
||||||
$avatar->displayUrl() :
|
|
||||||
Avatar::defaultImage(AVATAR_STREAM_SIZE),
|
|
||||||
'width' => AVATAR_STREAM_SIZE,
|
'width' => AVATAR_STREAM_SIZE,
|
||||||
'height' => AVATAR_STREAM_SIZE,
|
'height' => AVATAR_STREAM_SIZE,
|
||||||
'class' => 'photo avatar',
|
'class' => 'photo avatar',
|
||||||
|
|
|
@ -142,8 +142,7 @@ class OStatusSubAction extends Action
|
||||||
$ok = true;
|
$ok = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$avatar = $profile->avatarUrl(AVATAR_PROFILE_SIZE);
|
||||||
$avatarUrl = $avatar ? $avatar->displayUrl() : false;
|
|
||||||
|
|
||||||
$this->showEntity($profile,
|
$this->showEntity($profile,
|
||||||
$profile->profileurl,
|
$profile->profileurl,
|
||||||
|
@ -159,10 +158,6 @@ class OStatusSubAction extends Action
|
||||||
$homepage = $entity->homepage;
|
$homepage = $entity->homepage;
|
||||||
$location = $entity->location;
|
$location = $entity->location;
|
||||||
|
|
||||||
if (!$avatar) {
|
|
||||||
$avatar = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->elementStart('div', 'entity_profile vcard');
|
$this->elementStart('div', 'entity_profile vcard');
|
||||||
$this->element('img', array('src' => $avatar,
|
$this->element('img', array('src' => $avatar,
|
||||||
'class' => 'photo avatar entity_depiction',
|
'class' => 'photo avatar entity_depiction',
|
||||||
|
|
|
@ -96,7 +96,11 @@ class QnashowanswerAction extends ShownoticeAction
|
||||||
throw new ServerException(_m('User without a profile.'));
|
throw new ServerException(_m('User without a profile.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->avatar = null;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,11 @@ class QnashowquestionAction extends ShownoticeAction
|
||||||
throw new ServerException(_m('User without a profile.'));
|
throw new ServerException(_m('User without a profile.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
|
$this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->avatar = null;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class EditMirrorForm extends Form
|
||||||
$this->out->hidden('profile', $this->profile->id);
|
$this->out->hidden('profile', $this->profile->id);
|
||||||
|
|
||||||
$this->out->elementStart('div', array('style' => 'float: left; width: 80px;'));
|
$this->out->elementStart('div', array('style' => 'float: left; width: 80px;'));
|
||||||
$img = $this->getAvatar($this->profile);
|
$img = $this->profile->avatarUrl(AVATAR_STREAM_SIZE);
|
||||||
$feed = $this->getFeed($this->profile);
|
$feed = $this->getFeed($this->profile);
|
||||||
$this->out->elementStart('a', array('href' => $this->profile->profileurl));
|
$this->out->elementStart('a', array('href' => $this->profile->profileurl));
|
||||||
$this->out->element('img', array('src' => $img, 'style' => 'float: left'));
|
$this->out->element('img', array('src' => $img, 'style' => 'float: left'));
|
||||||
|
@ -130,16 +130,6 @@ class EditMirrorForm extends Form
|
||||||
$this->out->elementEnd('fieldset');
|
$this->out->elementEnd('fieldset');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAvatar($profile)
|
|
||||||
{
|
|
||||||
$avatar = $this->profile->getAvatar(48);
|
|
||||||
if ($avatar) {
|
|
||||||
return $avatar->displayUrl();
|
|
||||||
} else {
|
|
||||||
return Avatar::defaultImage(48);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getFeed($profile)
|
private function getFeed($profile)
|
||||||
{
|
{
|
||||||
// Ok this is a bit of a hack. ;)
|
// Ok this is a bit of a hack. ;)
|
||||||
|
|
|
@ -341,7 +341,14 @@ class TwitterImport
|
||||||
|
|
||||||
$newname = 'Twitter_' . $twitter_user->id . '_' . basename($twitter_user->profile_image_url);
|
$newname = 'Twitter_' . $twitter_user->id . '_' . basename($twitter_user->profile_image_url);
|
||||||
|
|
||||||
$oldname = $profile->getAvatar(48)->filename;
|
try {
|
||||||
|
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
|
||||||
|
$oldname = $avatar->filename;
|
||||||
|
unset($avatar);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$oldname = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($newname != $oldname) {
|
if ($newname != $oldname) {
|
||||||
common_debug($this->name() . ' - Avatar for Twitter user ' .
|
common_debug($this->name() . ' - Avatar for Twitter user ' .
|
||||||
|
@ -351,7 +358,7 @@ class TwitterImport
|
||||||
$this->updateAvatars($twitter_user, $profile);
|
$this->updateAvatars($twitter_user, $profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->missingAvatarFile($profile)) {
|
if (Avatar::hasOriginal($profile)) {
|
||||||
common_debug($this->name() . ' - Twitter user ' .
|
common_debug($this->name() . ' - Twitter user ' .
|
||||||
$profile->nickname .
|
$profile->nickname .
|
||||||
' is missing one or more local avatars.');
|
' is missing one or more local avatars.');
|
||||||
|
@ -382,17 +389,6 @@ class TwitterImport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function missingAvatarFile($profile) {
|
|
||||||
foreach (array(24, 48, 73) as $size) {
|
|
||||||
$filename = $profile->getAvatar($size)->filename;
|
|
||||||
$avatarpath = Avatar::path($filename);
|
|
||||||
if (file_exists($avatarpath) == FALSE) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMediatype($ext)
|
function getMediatype($ext)
|
||||||
{
|
{
|
||||||
$mediatype = null;
|
$mediatype = null;
|
||||||
|
@ -447,13 +443,7 @@ class TwitterImport
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sizes = array('mini' => 24, 'normal' => 48, 'bigger' => 73);
|
Avatar::deleteFromProfile($profile);
|
||||||
$avatar = $profile->getAvatar($sizes[$size]);
|
|
||||||
|
|
||||||
// Delete the avatar, if present
|
|
||||||
if ($avatar) {
|
|
||||||
$avatar->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->newAvatar($profile->id, $size, $mediatype, $filename);
|
$this->newAvatar($profile->id, $size, $mediatype, $filename);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user