aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-10-18 18:30:50 -0700
committerzotlabs <mike@macgirvin.com>2016-10-18 18:30:50 -0700
commit2a59f45a3b2da30d00656729b6b008df410178ec (patch)
treeaef127b2caac77e1a733d6789a49193535748415
parent2db7b2d9487d9393d511998ae0258979fde379c4 (diff)
downloadvolse-hubzilla-2a59f45a3b2da30d00656729b6b008df410178ec.tar.gz
volse-hubzilla-2a59f45a3b2da30d00656729b6b008df410178ec.tar.bz2
volse-hubzilla-2a59f45a3b2da30d00656729b6b008df410178ec.zip
Change the behaviour of 'use existing photo for profile'. For a channel with one profile, works just as it did previously. For multiple profiles, go back to the "upload form" but with a pre-existing file selected so that the correct profile can be selected. The text on this page and the resulting form are changed to remove the 'upload' text and file selection; but falls through to cropping in either case.
-rw-r--r--Zotlabs/Module/Profile_photo.php42
-rwxr-xr-xview/tpl/profile_photo.tpl5
2 files changed, 36 insertions, 11 deletions
diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php
index 1ae3a0a75..6e5b4660b 100644
--- a/Zotlabs/Module/Profile_photo.php
+++ b/Zotlabs/Module/Profile_photo.php
@@ -205,15 +205,23 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$hash = photo_new_resource();
+ $importing = false;
$smallest = 0;
- require_once('include/attach.php');
+
+ if($_REQUEST['importfile']) {
+ $hash = $_REQUEST['importfile'];
+ $importing = true;
+ }
+ else {
+ require_once('include/attach.php');
- $res = attach_store(\App::get_channel(), get_observer_hash(), '', array('album' => t('Profile Photos'), 'hash' => $hash));
+ $res = attach_store(\App::get_channel(), get_observer_hash(), '', array('album' => t('Profile Photos'), 'hash' => $hash));
- logger('attach_store: ' . print_r($res,true));
+ logger('attach_store: ' . print_r($res,true));
+ }
- if($res && intval($res['data']['is_photo'])) {
+ if(($res && intval($res['data']['is_photo'])) || $importing) {
$i = q("select * from photo where resource_id = '%s' and uid = %d order by imgscale",
dbesc($hash),
intval(local_channel())
@@ -284,14 +292,17 @@ class Profile_photo extends \Zotlabs\Web\Controller {
// When using an existing photo, we don't have a dialogue to offer a choice of profiles,
// so it gets attached to the default
- $p = q("select id from profile where is_default = 1 and uid = %d",
+ $c = q("select id, is_default from profile where uid = %d",
intval(local_channel())
);
- if($p) {
- $_REQUEST['profile'] = $p[0]['id'];
+
+ $multi_profiles = true;
+
+ if(($c) && (count($c) === 1) && (intval($c[0]['is_default']))) {
+ $_REQUEST['profile'] = $c[0]['id'];
+ $multi_profiles = false;
}
-
$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)
@@ -366,9 +377,15 @@ class Profile_photo extends \Zotlabs\Web\Controller {
}
}
- $this->profile_photo_crop_ui_head($a, $ph, $hash, $smallest);
+ if($multi_profiles) {
+ \App::$data['importfile'] = $resource_id;
+ }
+ else {
+ $this->profile_photo_crop_ui_head($a, $ph, $hash, $smallest);
+ }
// falls through with App::$data['imagecrop'] set so we go straight to the cropping section
+
}
@@ -377,6 +394,8 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$profiles = q("select id, profile_name as name, is_default from profile where uid = %d order by id asc",
intval(local_channel())
);
+
+ $importing = ((array_key_exists('importfile',\App::$data)) ? true : false);
if(! x(\App::$data,'imagecrop')) {
@@ -384,10 +403,11 @@ class Profile_photo extends \Zotlabs\Web\Controller {
$o .= replace_macros($tpl,array(
'$user' => \App::$channel['channel_address'],
+ '$importfile' => (($importing) ? \App::$data['importfile'] : ''),
'$lbl_upfile' => t('Upload File:'),
'$lbl_profiles' => t('Select a profile:'),
- '$title' => t('Upload Profile Photo'),
- '$submit' => t('Upload'),
+ '$title' => (($importing) ? t('Use Photo for Profile') : t('Upload Profile Photo')),
+ '$submit' => (($importing) ? t('Use') : t('Upload')),
'$profiles' => $profiles,
'$single' => ((count($profiles) == 1) ? true : false),
'$profile0' => $profiles[0],
diff --git a/view/tpl/profile_photo.tpl b/view/tpl/profile_photo.tpl
index 88e17407b..ca107bfcc 100755
--- a/view/tpl/profile_photo.tpl
+++ b/view/tpl/profile_photo.tpl
@@ -9,10 +9,15 @@
<div id="profile-photo-upload-wrapper">
+ {{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}}