this should finish up hubzilla issue #113

This commit is contained in:
zotlabs 2017-12-31 14:45:42 -08:00
parent 45923f408f
commit ce38350e00
4 changed files with 30 additions and 9 deletions

View File

@ -179,7 +179,10 @@ class Profile_photo extends \Zotlabs\Web\Controller {
); );
} }
profiles_build_sync(local_channel()); // set $send to false in profiles_build_sync() to return the data
// so that we only send one sync packet.
$sync_profiles = profiles_build_sync(local_channel(),false);
// We'll set the updated profile-photo timestamp even if it isn't the default profile, // We'll set the updated profile-photo timestamp even if it isn't the default profile,
// so that browsers will do a cache update unconditionally // so that browsers will do a cache update unconditionally
@ -201,7 +204,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$sync = attach_export_data($channel,$base_image['resource_id']); $sync = attach_export_data($channel,$base_image['resource_id']);
if($sync) if($sync)
build_sync_packet($channel['channel_id'],array('file' => array($sync))); build_sync_packet($channel['channel_id'],array('file' => array($sync), 'profile' => $sync_profiles));
// Similarly, tell the nav bar to bypass the cache and update the avatar image. // Similarly, tell the nav bar to bypass the cache and update the avatar image.

View File

@ -1982,12 +1982,17 @@ function get_channel_default_perms($uid) {
} }
function profiles_build_sync($channel_id) { function profiles_build_sync($channel_id,$send = true) {
$r = q("select * from profile where uid = %d", $r = q("select * from profile where uid = %d",
intval($channel_id) intval($channel_id)
); );
if($r) { if($r) {
build_sync_packet($channel_id,array('profile' => $r)); if($send) {
build_sync_packet($channel_id,array('profile' => $r));
}
else {
return $r;
}
} }
} }

View File

@ -162,13 +162,17 @@ function import_profiles($channel, $profiles) {
convert_oldfields($profile,'work','employment'); convert_oldfields($profile,'work','employment');
/** /**
* @TODO we are going to reset all profile photos to the original * @TODO put all the applicable photos into the export.
* somebody will have to fix this later and put all the applicable
* photos into the export.
*/ */
$profile['photo'] = z_root() . '/photo/profile/l/' . $channel['channel_id']; if((strpos($profile['thumb'],'/photo/profile/l/') !== false) || intval($profile['is_default'])) {
$profile['thumb'] = z_root() . '/photo/profile/m/' . $channel['channel_id']; $profile['photo'] = z_root() . '/photo/profile/l/' . $channel['channel_id'];
$profile['thumb'] = z_root() . '/photo/profile/m/' . $channel['channel_id'];
}
else {
$profile['photo'] = z_root() . '/photo/' . basename($profile['photo']);
$profile['thumb'] = z_root() . '/photo/' . basename($profile['thumb']);
}
create_table_from_array('profile', $profile); create_table_from_array('profile', $profile);
} }

View File

@ -3745,6 +3745,15 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
* @TODO * @TODO
* We also need to import local photos if a custom photo is selected * We also need to import local photos if a custom photo is selected
*/ */
if((strpos($profile['thumb'],'/photo/profile/l/') !== false) || intval($profile['is_default'])) {
$profile['photo'] = z_root() . '/photo/profile/l/' . $channel['channel_id'];
$profile['thumb'] = z_root() . '/photo/profile/m/' . $channel['channel_id'];
}
else {
$profile['photo'] = z_root() . '/photo/' . basename($profile['photo']);
$profile['thumb'] = z_root() . '/photo/' . basename($profile['thumb']);
}
} }
if(count($clean)) { if(count($clean)) {