aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-01-12 13:09:53 +0000
committerMario <mario@mariovavti.com>2022-01-12 13:09:53 +0000
commitf4046efcb2ea7cfba5bb57c0fe8e8900bdd871b0 (patch)
tree6652f07e192078b69b47e29befb569881a6104c2
parentfc1d3831cfa65cf10330204b417ac89b724cfc51 (diff)
downloadvolse-hubzilla-f4046efcb2ea7cfba5bb57c0fe8e8900bdd871b0.tar.gz
volse-hubzilla-f4046efcb2ea7cfba5bb57c0fe8e8900bdd871b0.tar.bz2
volse-hubzilla-f4046efcb2ea7cfba5bb57c0fe8e8900bdd871b0.zip
refactor mod profile_photo
-rw-r--r--Zotlabs/Module/Profile_photo.php294
-rw-r--r--view/tpl/profile_advanced.tpl3
-rw-r--r--view/tpl/profile_edit.tpl2
-rw-r--r--view/tpl/profile_photo.tpl156
-rw-r--r--view/tpl/profile_vcard.tpl15
5 files changed, 270 insertions, 200 deletions
diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php
index 6681cdcf9..95fcac9f5 100644
--- a/Zotlabs/Module/Profile_photo.php
+++ b/Zotlabs/Module/Profile_photo.php
@@ -37,7 +37,10 @@ class Profile_photo extends \Zotlabs\Web\Controller {
}
$channel = \App::get_channel();
- profile_load($channel['channel_address']);
+ $profile = \App::$argv[1];
+
+ profile_load($channel['channel_address'], $profile);
+
}
@@ -58,29 +61,68 @@ class Profile_photo extends \Zotlabs\Web\Controller {
check_form_security_token_redirectOnErr('/profile_photo', 'profile_photo');
- // Remove cover photo
+
+ $r = q("select id, profile_guid, is_default, gender from profile where uid = %d",
+ intval(local_channel())
+ );
+
+ $profile_id = intval($_POST['profile']);
+ $default_profile_id = null;
+ $profile = [];
+
+ foreach($r as $rr) {
+ if($rr['is_default']) {
+ $default_profile_id = intval($rr['id']);
+ }
+
+ if ($profile_id === intval($rr['id'])) {
+ $profile = $rr;
+ }
+ }
+
+ $is_default_profile = ($profile_id === $default_profile_id);
+
+ // Remove profile photo
if(isset($_POST['remove'])) {
- $r = q("SELECT resource_id FROM photo WHERE photo_usage = %d AND uid = %d LIMIT 1",
- intval(PHOTO_PROFILE),
- intval(local_channel())
- );
+ if ($is_default_profile) {
- if($r) {
- q("update photo set photo_usage = %d where photo_usage = %d and uid = %d",
- intval(PHOTO_NORMAL),
- intval(PHOTO_PROFILE),
- intval(local_channel())
- );
+ $r = q("SELECT resource_id FROM photo WHERE photo_usage = %d AND uid = %d LIMIT 1",
+ intval(PHOTO_PROFILE),
+ intval(local_channel())
+ );
- $sync = attach_export_data($channel,$r[0]['resource_id']);
- if($sync)
- Libsync:: build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+ if($r) {
+ q("update photo set photo_usage = %d where photo_usage = %d and uid = %d",
+ intval(PHOTO_NORMAL),
+ intval(PHOTO_PROFILE),
+ intval(local_channel())
+ );
+
+ q("update profile set photo = '%s', thumb = '%s' where is_default = 1 and uid = %d",
+ dbesc(z_root() . '/photo/profile/l/' . local_channel()),
+ dbesc(z_root() . '/photo/profile/m/' . local_channel()),
+ intval(local_channel())
+ );
+
+ }
+ }
+ else {
+ q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
+ dbesc(z_root() . '/' . get_default_profile_photo(300)),
+ dbesc(z_root() . '/' . get_default_profile_photo(80)),
+ intval($profile_id),
+ intval(local_channel())
+ );
}
+ $sync = attach_export_data($channel,$r[0]['resource_id']);
+ if($sync)
+ Libsync:: build_sync_packet($channel['channel_id'],array('file' => array($sync)));
+
$_SESSION['reload_avatar'] = true;
- goaway(z_root() . '/profiles');
+ goaway(z_root() . '/profiles/' . $profile_id);
}
if((array_key_exists('cropfinal',$_POST)) && (intval($_POST['cropfinal']) == 1)) {
@@ -101,23 +143,6 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$image_id = substr($image_id,0,-2);
}
-
- // unless proven otherwise
- $is_default_profile = 1;
-
- if($_REQUEST['profile']) {
- $r = q("select id, profile_guid, is_default, gender from profile where id = %d and uid = %d limit 1",
- intval($_REQUEST['profile']),
- intval(local_channel())
- );
- if($r) {
- $profile = $r[0];
- if(! intval($profile['is_default']))
- $is_default_profile = 0;
- }
- }
-
-
$srcX = intval($_POST['xstart']);
$srcY = intval($_POST['ystart']);
$srcW = intval($_POST['xfinal']) - $srcX;
@@ -126,7 +151,9 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$r = q("SELECT * FROM photo WHERE resource_id = '%s' AND uid = %d AND imgscale = %d LIMIT 1",
dbesc($image_id),
dbesc(local_channel()),
- intval($scale));
+ intval($scale)
+ );
+
if($r) {
$base_image = $r[0];
@@ -147,12 +174,10 @@ class Profile_photo extends \Zotlabs\Web\Controller {
'album' => t('Profile Photos'),
'os_path' => $base_image['os_path'],
'display_path' => $base_image['display_path'],
- 'photo_usage' => PHOTO_PROFILE,
+ 'photo_usage' => (($is_default_profile) ? PHOTO_PROFILE : PHOTO_NORMAL),
'edited' => dbescdate($base_image['edited'])
];
- $p['photo_usage'] = (($is_default_profile) ? PHOTO_PROFILE : PHOTO_NORMAL);
-
$r1 = $im->storeThumbnail($p, PHOTO_RES_PROFILE_300);
$im->scaleImage(80);
@@ -215,7 +240,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
dbesc(z_root() . '/photo/' . $base_image['resource_id'] . '-4'),
dbesc(z_root() . '/photo/' . $base_image['resource_id'] . '-5'),
- intval($_REQUEST['profile']),
+ intval($profile_id),
intval(local_channel())
);
}
@@ -241,7 +266,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
dbesc($channel['xchan_hash'])
);
- photo_profile_setperms(local_channel(),$base_image['resource_id'],$_REQUEST['profile']);
+ photo_profile_setperms(local_channel(),$base_image['resource_id'],$profile_id);
$sync = attach_export_data($channel,$base_image['resource_id']);
if($sync)
@@ -261,7 +286,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
notice( t('Unable to process image') . EOL);
}
- goaway(z_root() . '/profiles');
+ goaway(z_root() . '/profiles/' . $profile_id);
return; // NOTREACHED
}
@@ -279,8 +304,53 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$importing = true;
}
else {
- require_once('include/attach.php');
+
+ $matches = [];
+ $partial = false;
+
+ if(array_key_exists('HTTP_CONTENT_RANGE',$_SERVER)) {
+ $pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches);
+ if($pm) {
+ logger('Content-Range: ' . print_r($matches,true));
+ $partial = true;
+ }
+ }
+
+ if($partial) {
+ $x = save_chunk($channel,$matches[1],$matches[2],$matches[3]);
+
+ if($x['partial']) {
+ header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0));
+ json_return_and_die($result);
+ }
+ else {
+ header('Range: bytes=0-' . (($x['size']) ? $x['size'] - 1 : 0));
+
+ $_FILES['userfile'] = [
+ 'name' => $x['name'],
+ 'type' => $x['type'],
+ 'tmp_name' => $x['tmp_name'],
+ 'error' => $x['error'],
+ 'size' => $x['size']
+ ];
+ }
+ }
+ else {
+ if(! array_key_exists('userfile',$_FILES)) {
+ $_FILES['userfile'] = [
+ 'name' => $_FILES['files']['name'],
+ 'type' => $_FILES['files']['type'],
+ 'tmp_name' => $_FILES['files']['tmp_name'],
+ 'error' => $_FILES['files']['error'],
+ 'size' => $_FILES['files']['size']
+ ];
+ }
+ }
+
$res = attach_store(\App::get_channel(), get_observer_hash(), '', array('album' => t('Profile Photos'), 'hash' => $hash, 'nosync' => true, 'source' => 'photos'));
+
+ json_return_and_die([ 'message' => $hash ]);
+
}
if(($res && intval($res['data']['is_photo'])) || $importing) {
@@ -313,7 +383,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
return;
}
- return $this->profile_photo_crop_ui_head($a, $ph, $hash, $smallest);
+ return $this->profile_photo_crop_ui_head($ph, $hash, $smallest);
// This will "fall through" to the get() method, and since
// App::$data['imagecrop'] is set, it will proceed to cropping
@@ -337,11 +407,33 @@ class Profile_photo extends \Zotlabs\Web\Controller {
}
$channel = \App::get_channel();
- $pf = 0;
+ $profile_id = (($_REQUEST['profile']) ? intval($_REQUEST['profile']) : intval(argv(1)));
+ $default_profile = [];
+ $default_profile_id = null;
+
$newuser = false;
- if(argc() == 2 && argv(1) === 'new')
+ if(argc() == 2 && argv(1) === 'new') {
$newuser = true;
+ }
+
+ $r = q("select id, profile_name as name, is_default from profile where uid = %d order by id asc",
+ intval(local_channel())
+ );
+
+
+ foreach($r as $rr) {
+ if ($rr['is_default']) {
+ $default_profile_id = intval($rr['id']);
+ $default_profile = $rr;
+ }
+
+ if ($profile_id === intval($rr['id'])) {
+ $profile = $rr;
+ }
+ }
+
+ $is_default_profile = ($profile_id === $default_profile_id);
if(argv(1) === 'use') {
if (argc() < 3) {
@@ -351,23 +443,6 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$resource_id = argv(2);
-
- $pf = (($_REQUEST['pf']) ? intval($_REQUEST['pf']) : 0);
-
- $c = q("select id, is_default from profile where uid = %d",
- intval(local_channel())
- );
-
- $multi_profiles = true;
-
- if(($c) && (count($c) === 1) && (intval($c[0]['is_default']))) {
- $_REQUEST['profile'] = $c[0]['id'];
- $multi_profiles = false;
- }
- else {
- $_REQUEST['profile'] = $pf;
- }
-
$r = q("SELECT id, album, imgscale FROM photo WHERE uid = %d AND resource_id = '%s' ORDER BY imgscale ASC",
intval(local_channel()),
dbesc($resource_id)
@@ -385,28 +460,41 @@ class Profile_photo extends \Zotlabs\Web\Controller {
// set an already loaded and cropped photo as profile photo
if($havescale) {
- // unset any existing profile photos
- $x = q("UPDATE photo SET photo_usage = %d WHERE photo_usage = %d AND uid = %d",
- intval(PHOTO_NORMAL),
- intval(PHOTO_PROFILE),
- intval(local_channel())
- );
- $edited = datetime_convert();
+ if ($is_default_profile) {
- $x = q("UPDATE photo SET photo_usage = %d, edited = '%s' WHERE uid = %d AND resource_id = '%s' AND imgscale > 0",
- intval(PHOTO_PROFILE),
- dbescdate($edited),
- intval(local_channel()),
- dbesc($resource_id)
- );
+ // unset any existing profile photos
+ $x = q("UPDATE photo SET photo_usage = %d WHERE photo_usage = %d AND uid = %d",
+ intval(PHOTO_NORMAL),
+ intval(PHOTO_PROFILE),
+ intval(local_channel())
+ );
+
+ $edited = datetime_convert();
+
+ $x = q("UPDATE photo SET photo_usage = %d, edited = '%s' WHERE uid = %d AND resource_id = '%s' AND imgscale > 0",
+ intval(PHOTO_PROFILE),
+ dbescdate($edited),
+ intval(local_channel()),
+ dbesc($resource_id)
+ );
+
+ $x = q("UPDATE xchan SET xchan_photo_date = '%s' WHERE xchan_hash = '%s'",
+ dbescdate($edited),
+ dbesc($channel['xchan_hash'])
+
+ );
+
+ }
- $x = q("UPDATE xchan SET xchan_photo_date = '%s' WHERE xchan_hash = '%s'",
- dbescdate($edited),
- dbesc($channel['xchan_hash'])
+ $x = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
+ dbesc(z_root() . '/photo/' . $resource_id . '-4'),
+ dbesc(z_root() . '/photo/' . $resource_id . '-5'),
+ intval($profile_id),
+ intval(local_channel())
);
- photo_profile_setperms(local_channel(),$resource_id,$_REQUEST['profile']);
+ photo_profile_setperms(local_channel(),$resource_id,$profile_id);
$sync = attach_export_data($channel,$resource_id);
if($sync)
@@ -416,7 +504,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
\Zotlabs\Daemon\Master::Summon(array('Directory',local_channel()));
- goaway(z_root() . '/profiles');
+ goaway(z_root() . '/profiles/' . $profile_id);
}
$r = q("SELECT content, mimetype, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1",
@@ -430,13 +518,15 @@ class Profile_photo extends \Zotlabs\Web\Controller {
}
if(intval($r[0]['os_storage']))
- $data = @file_get_contents(dbunescbin($r[0]['content']));
+ $data = @file_get_contents($r[0]['content']);
else
$data = dbunescbin($r[0]['content']);
+
$ph = photo_factory($data, $r[0]['mimetype']);
$smallest = 0;
if($ph->is_valid()) {
+
// go ahead as if we have just uploaded a new photo to crop
$i = q("select resource_id, imgscale from photo where resource_id = '%s' and uid = %d order by imgscale",
dbesc($r[0]['resource_id']),
@@ -453,34 +543,13 @@ class Profile_photo extends \Zotlabs\Web\Controller {
}
}
- if($multi_profiles) {
- \App::$data['importfile'] = $resource_id;
- }
- else {
- $this->profile_photo_crop_ui_head($a, $ph, $hash, $smallest);
- }
+ $this->profile_photo_crop_ui_head($ph, $hash, $smallest);
// falls through with App::$data['imagecrop'] set so we go straight to the cropping section
}
- // present an upload form
-
- $profiles = q("select id, profile_name as name, is_default from profile where uid = %d order by id asc",
- intval(local_channel())
- );
-
- if($profiles) {
- for($x = 0; $x < count($profiles); $x ++) {
- $profiles[$x]['selected'] = false;
- if($pf && $profiles[$x]['id'] == $pf)
- $profiles[$x]['selected'] = true;
- if((! $pf) && $profiles[$x]['is_default'])
- $profiles[$x]['selected'] = true;
- }
- }
-
$importing = ((array_key_exists('importfile',\App::$data)) ? true : false);
if(! x(\App::$data,'imagecrop')) {
@@ -489,16 +558,13 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$o .= replace_macros($tpl,array(
'$user' => \App::$channel['channel_address'],
- '$info' => ((count($profiles) > 1) ? t('Your default profile photo is visible to anybody on the internet. Profile photos for alternate profiles will inherit the permissions of the profile') : t('Your profile photo is visible to anybody on the internet and may be distributed to other websites.')),
+ '$info' => (($is_default_profile) ? t('This profile photo will be visible to anybody on the internet and may be distributed to other websites.') : t('This profile photo will be visible only to channels with permission to view this profile.')),
'$importfile' => (($importing) ? \App::$data['importfile'] : ''),
- '$lbl_upfile' => t('Upload File:'),
- '$lbl_profiles' => t('Select a profile:'),
'$title' => (($importing) ? t('Use Photo for Profile') : t('Change Profile Photo')),
- '$submit' => (($importing) ? t('Use') : t('Upload')),
- '$remove' => t('Remove'),
- '$profiles' => $profiles,
- '$single' => ((count($profiles) == 1) ? true : false),
- '$profile0' => $profiles[0],
+ '$submit' => t('Upload'),
+ '$remove' => t('Reset to default'),
+ '$profile_id' => $profile_id,
+ '$profile' => $profile,
'$embedPhotos' => t('Use a photo from your albums'),
'$embedPhotosModalTitle' => t('Use a photo from your albums'),
'$embedPhotosModalCancel' => t('Cancel'),
@@ -510,7 +576,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
'$modalerrorlink' => t('Error getting photo link'),
'$modalerroralbum' => t('Error getting album'),
'$form_security_token' => get_form_security_token("profile_photo"),
- '$select' => t('Select existing photo'),
+ '$select' => t('Select existing'),
));
call_hooks('profile_photo_content_end', $o);
@@ -526,13 +592,13 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$tpl = get_markup_template("cropbody.tpl");
$o .= replace_macros($tpl,array(
'$filename' => $filename,
- '$profile' => intval($_REQUEST['profile']),
+ '$profile' => $profile_id,
'$resource' => \App::$data['imagecrop'] . '-' . \App::$data['imagecrop_resolution'],
'$image_url' => z_root() . '/photo/' . $filename,
'$title' => t('Crop Image'),
'$desc' => t('Please adjust the image cropping for optimum viewing.'),
'$form_security_token' => get_form_security_token("profile_photo"),
- '$done' => t('Done Editing')
+ '$done' => t('Done editing')
));
return $o;
}
@@ -550,7 +616,7 @@ class Profile_photo extends \Zotlabs\Web\Controller {
- function profile_photo_crop_ui_head(&$a, $ph, $hash, $smallest){
+ function profile_photo_crop_ui_head($ph, $hash, $smallest){
$max_length = get_config('system','max_image_length');
if(! $max_length)
diff --git a/view/tpl/profile_advanced.tpl b/view/tpl/profile_advanced.tpl
index a4f6c9525..dab2db4ac 100644
--- a/view/tpl/profile_advanced.tpl
+++ b/view/tpl/profile_advanced.tpl
@@ -21,9 +21,8 @@
<a class="btn btn-primary btn-sm dropdown-toggle" data-bs-toggle="dropdown" href="#" ><i class="fa fa-pencil"></i>&nbsp;{{$editmenu.edit.3}}</a>
<div class="dropdown-menu dropdown-menu-end">
{{foreach $editmenu.menu.entries as $e}}
- <a class="dropdown-item" href="profiles/{{$e.id}}"><img class="dropdown-menu-img-xs" src='{{$e.photo}}'> {{$e.profile_name}}</a>
+ <a class="dropdown-item" href="profiles/{{$e.id}}"><img class="menu-img-1" src='{{$e.photo}}'> {{$e.profile_name}}</a>
{{/foreach}}
- <a class="dropdown-item" href="profile_photo" >{{$editmenu.menu.chg_photo}}</a>
{{if $editmenu.menu.cr_new}}
<a class="dropdown-item" href="profiles/new" id="profile-listing-new-link">{{$editmenu.menu.cr_new}}</a>
{{/if}}
diff --git a/view/tpl/profile_edit.tpl b/view/tpl/profile_edit.tpl
index 3f5814c4a..7361411b9 100644
--- a/view/tpl/profile_edit.tpl
+++ b/view/tpl/profile_edit.tpl
@@ -5,7 +5,7 @@
<i class="fa fa-cog"></i>&nbsp;{{$tools_label}}
</button>
<div class="dropdown-menu dropdown-menu-end">
- <a class="dropdown-item" href="profile_photo" id="profile-photo_upload-link" title="{{$profpic}}"><i class="fa fa-fw fa-user"></i>&nbsp;{{$profpic}}</a>
+ <a class="dropdown-item" href="profile_photo/{{$profile_id}}" id="profile-photo_upload-link" title="{{$profpic}}"><i class="fa fa-fw fa-user"></i>&nbsp;{{$profpic}}</a>
{{if $is_default}}
<a class="dropdown-item" href="cover_photo" id="cover-photo_upload-link" title="{{$coverpic}}"><i class="fa fa-fw fa-picture-o"></i>&nbsp;{{$coverpic}}</a>
{{/if}}
diff --git a/view/tpl/profile_photo.tpl b/view/tpl/profile_photo.tpl
index c608806ca..ce9cf510e 100644
--- a/view/tpl/profile_photo.tpl
+++ b/view/tpl/profile_photo.tpl
@@ -1,3 +1,68 @@
+<input id="invisible-photos-file-upload" type="file" name="files" style="visibility:hidden;position:absolute;top:-50;left:-50;width:0;height:0;" >
+
+<div id="profile-photo-content" class="generic-content-wrapper">
+ <div class="section-title-wrapper">
+ <h2>{{$title}}: {{$profile.name}}</h2>
+ </div>
+ <div class="section-content-wrapper">
+
+ <form enctype="multipart/form-data" id="profile-photo-form" action="profile_photo" method="post">
+ <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
+
+ <div id="profile-photo-upload-wrapper">
+ {{if $info}}
+ <div class="section-content-warning-wrapper">{{$info}}</div>
+ {{/if}}
+ {{if $importfile}}
+ <input type="hidden" name="importfile" value="{{$importfile}}">
+ {{else}}
+ <!--label id="profile-photo-upload-label" class="" for="profile-photo-upload">{{$lbl_upfile}}</label>
+ <input name="userfile" class="form-control" type="file" id="profile-photo-upload" /-->
+ {{/if}}
+ <div class="clear mb-3"></div>
+
+ <input type="hidden" name="profile" value="{{$profile_id}}" />
+
+ <div id="profile-photo-upload-spinner" class="spinner-wrapper">
+ <div class="spinner m"></div>
+ </div>
+ <div id="profile-photo-submit-wrapper">
+ <button type="submit" class="btn btn-primary float-end" name="submit" id="profile-photo-submit">
+ {{$submit}}
+ </button>
+ <button id="embed-photo-wrapper" type="button" class="btn btn-default btn-outline-success float-end me-1" title="{{$embedPhotos}}" onclick="initializeEmbedPhotoDialog();">
+ <i id="embed-photo" class="fa fa-file-image-o"></i> {{$select}}
+ </button>
+ <button type="submit" class="btn btn-outline-danger" name="remove" id="profile-photo-remove">
+ {{$remove}}
+ </button>
+ </div>
+ </div>
+
+ </form>
+ </div>
+</div>
+
+<div class="modal" id="embedPhotoModal" tabindex="-1" role="dialog" aria-labelledby="embedPhotoLabel" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h4 class="modal-title" id="embedPhotoModalLabel">{{$embedPhotosModalTitle}}</h4>
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-hidden="true"></button>
+ </div>
+ <div class="modal-body" id="embedPhotoModalBody" >
+ <div id="embedPhotoModalBodyAlbumListDialog" class="d-none">
+ <div id="embedPhotoModalBodyAlbumList"></div>
+ </div>
+ <div id="embedPhotoModalBodyAlbumDialog" class="d-none"></div>
+ </div>
+ </div><!-- /.modal-content -->
+ </div><!-- /.modal-dialog -->
+</div><!-- /.modal -->
+
+<script src="vendor/blueimp/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
+<script src="vendor/blueimp/jquery-file-upload/js/jquery.iframe-transport.js"></script>
+<script src="vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js"></script>
<script>
var initializeEmbedPhotoDialog = function () {
$('.embed-photo-selected-photo').each(function (index) {
@@ -32,9 +97,7 @@
$.post("embedphotos/photolink", {href: href},
function(ddata) {
if (ddata['status']) {
- var pf = $('#profile-photo-profiles').val();
- var prof = ((typeof pf !== 'undefined') ? '?f=&pf=' + pf : '');
- window.location.href = 'profile_photo/use/' + ddata['resource_id'] + prof;
+ window.location.href = 'profile_photo/use/' + ddata['resource_id'] + '?f=&profile={{$profile_id}}';
} else {
window.console.log("{{$modalerrorlink}}" + ':' + ddata['errormsg']);
}
@@ -81,77 +144,26 @@
},
'json');
};
-</script>
-<div id="profile-photo-content" class="generic-content-wrapper">
- <div class="section-title-wrapper">
- <h2>{{$title}}</h2>
- </div>
- <div class="section-content-wrapper">
+ $('#invisible-photos-file-upload').fileupload({
+ url: 'profile_photo',
+ dataType: 'json',
+ // dropZone: filedrag,
+ maxChunkSize: 2 * 1024 * 1024,
- <form enctype="multipart/form-data" action="profile_photo" method="post">
- <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
-
- <div id="profile-photo-upload-wrapper">
- {{if $info}}
- <div class="section-content-warning-wrapper">{{$info}}</div>
- {{/if}}
- {{if $importfile}}
- <input type="hidden" name="importfile" value="{{$importfile}}">
- {{else}}
- <label id="profile-photo-upload-label" class="form-label" for="profile-photo-upload">{{$lbl_upfile}}</label>
- <input name="userfile" class="form-input" type="file" id="profile-photo-upload" size="48" />
- {{/if}}
- <div class="clear"></div>
-
-
- {{if $single}}
- <input type="hidden" name="profile" value="{{$profile0.id}}" />
- {{else}}
-
-
-
- <label id="profile-photo-profiles-label" class="form-label" for="profile-photo-profiles">{{$lbl_profiles}}</label>
- <select name="profile" id="profile-photo-profiles" class="form-control" >
- {{foreach $profiles as $p}}
- <option value="{{$p.id}}" {{if $p.selected}}selected="selected"{{/if}}>{{$p.name}}</option>
- {{/foreach}}
- </select>
- <div class="clear"></div>
- <br />
- <br />
- {{/if}}
-
- <div id="profile-photo-submit-wrapper">
- <button type="submit" class="btn btn-outline-primary" name="submit" id="profile-photo-submit">{{$submit}}</button>
- <button type="submit" class="btn btn-outline-danger" name="remove" id="profile-photo-remove">{{$remove}}</button>
- </div>
- </div>
+ add: function(e,data) {
+ data.formData = $('#profile-photo-form').serializeArray();
+ data.submit();
+ $('#profile-photo-upload-spinner').show();
+ },
- </form>
- <br />
- <div id="profile-photo-link-select-wrapper">
- <button id="embed-photo-wrapper" class="btn btn-default btn-primary" title="{{$embedPhotos}}" onclick="initializeEmbedPhotoDialog();return false;">
- <i id="embed-photo" class="fa fa-file-image-o"></i> {{$select}}
- </button>
- </div>
- </div>
-</div>
+ done: function(e,data) {
+ $('#profile-photo-upload-spinner').hide();
+ window.location.href = 'profile_photo/use/' + data.result.message + '?profile={{$profile_id}}';
+ }
-<div class="modal" id="embedPhotoModal" tabindex="-1" role="dialog" aria-labelledby="embedPhotoLabel" aria-hidden="true">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <h4 class="modal-title" id="embedPhotoModalLabel">{{$embedPhotosModalTitle}}</h4>
- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-hidden="true"></button>
- </div>
- <div class="modal-body" id="embedPhotoModalBody" >
- <div id="embedPhotoModalBodyAlbumListDialog" class="d-none">
- <div id="embedPhotoModalBodyAlbumList"></div>
- </div>
- <div id="embedPhotoModalBodyAlbumDialog" class="d-none"></div>
- </div>
- </div><!-- /.modal-content -->
- </div><!-- /.modal-dialog -->
-</div><!-- /.modal -->
+ });
+
+ $('#profile-photo-submit').click(function(event) { event.preventDefault(); $('#invisible-photos-file-upload').trigger('click'); return false;});
+</script>
diff --git a/view/tpl/profile_vcard.tpl b/view/tpl/profile_vcard.tpl
index 9002d3742..3da580f60 100644
--- a/view/tpl/profile_vcard.tpl
+++ b/view/tpl/profile_vcard.tpl
@@ -1,16 +1,10 @@
<div class="rounded mb-3 vcard-card h-card">
<div class="card mb-2">
<div class="row">
- <div class="col-4" style="width: 7rem;">
- {{if $editmenu}}
- <a href="profile_photo" title="{{$change_photo}}">
- {{/if}}
- <div id="profile-photo-wrapper">
- <img class="rounded-start u-photo" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.fullname}}" style="width: 6rem; height:6rem;">
- </div>
- {{if $editmenu}}
- </a>
- {{/if}}
+ <div class="col-4" style="width: fit-content;">
+ <div id="profile-photo-wrapper">
+ <img class="rounded-start u-photo" src="{{$profile.photo}}?rev={{$profile.picdate}}" alt="{{$profile.fullname}}" style="width: 6rem; height:6rem;">
+ </div>
</div>
<div class="col-7 m-1 p-0">
{{if $editmenu.multi}}
@@ -20,7 +14,6 @@
{{foreach $editmenu.menu.entries as $e}}
<a href="profiles/{{$e.id}}" class="dropdown-item"><img class="menu-img-1" src='{{$e.photo}}'> {{$e.profile_name}}</a>
{{/foreach}}
- <a href="profile_photo" class="dropdown-item">{{$editmenu.menu.chg_photo}}</a>
{{if $editmenu.menu.cr_new}}
<a href="profiles/new" id="profile-listing-new-link" class="dropdown-item">{{$editmenu.menu.cr_new}}</a>
{{/if}}