This commit is contained in:
zotlabs 2019-04-07 19:23:38 -07:00
commit 1ed0079882
5 changed files with 57 additions and 35 deletions

View File

@ -48,6 +48,29 @@ class Cover_photo extends \Zotlabs\Web\Controller {
$channel = \App::get_channel(); $channel = \App::get_channel();
check_form_security_token_redirectOnErr('/cover_photo', 'cover_photo'); check_form_security_token_redirectOnErr('/cover_photo', 'cover_photo');
// Remove cover photo
if(isset($_POST['remove'])) {
$r = q("SELECT resource_id FROM photo WHERE photo_usage = %d AND uid = %d LIMIT 1",
intval(PHOTO_COVER),
intval(local_channel())
);
if($r) {
q("update photo set photo_usage = %d where photo_usage = %d and uid = %d",
intval(PHOTO_NORMAL),
intval(PHOTO_COVER),
intval(local_channel())
);
$sync = attach_export_data($channel,$r[0]['resource_id']);
if($sync)
build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
goaway(z_root() . '/cover_photo');
}
if((array_key_exists('cropfinal',$_POST)) && ($_POST['cropfinal'] == 1)) { if((array_key_exists('cropfinal',$_POST)) && ($_POST['cropfinal'] == 1)) {
@ -195,10 +218,12 @@ logger('gis: ' . print_r($gis,true));
); );
return; return;
} }
$channel = \App::get_channel();
$this->send_cover_photo_activity($channel,$base_image,$profile); $this->send_cover_photo_activity($channel,$base_image,$profile);
$sync = attach_export_data($channel,$base_image['resource_id']);
if($sync)
build_sync_packet($channel['channel_id'],array('file' => array($sync)));
} }
else else
@ -215,7 +240,7 @@ logger('gis: ' . print_r($gis,true));
require_once('include/attach.php'); require_once('include/attach.php');
$res = attach_store(\App::get_channel(), get_observer_hash(), '', array('album' => t('Cover Photos'), 'hash' => $hash)); $res = attach_store(\App::get_channel(), get_observer_hash(), '', array('album' => t('Cover Photos'), 'hash' => $hash, 'nosync' => true));
logger('attach_store: ' . print_r($res,true)); logger('attach_store: ' . print_r($res,true));
@ -393,6 +418,7 @@ logger('gis: ' . print_r($gis,true));
'$lbl_profiles' => t('Select a profile:'), '$lbl_profiles' => t('Select a profile:'),
'$title' => t('Change Cover Photo'), '$title' => t('Change Cover Photo'),
'$submit' => t('Upload'), '$submit' => t('Upload'),
'$remove' => t('Remove'),
'$profiles' => $profiles, '$profiles' => $profiles,
'$embedPhotos' => t('Use a photo from your albums'), '$embedPhotos' => t('Use a photo from your albums'),
'$embedPhotosModalTitle' => t('Use a photo from your albums'), '$embedPhotosModalTitle' => t('Use a photo from your albums'),

View File

@ -71,29 +71,32 @@ class Photo extends \Zotlabs\Web\Controller {
$modified = filemtime($default); $modified = filemtime($default);
$default = z_root() . '/' . $default; $default = z_root() . '/' . $default;
$uid = $person; $uid = $person;
$data = '';
$d = [ 'imgscale' => $resolution, 'channel_id' => $uid, 'default' => $default, 'data' => '', 'mimetype' => '' ]; $r = q("SELECT * FROM photo WHERE imgscale = %d AND uid = %d AND photo_usage = %d LIMIT 1",
call_hooks('get_profile_photo',$d); intval($resolution),
intval($uid),
$resolution = $d['imgscale']; intval(PHOTO_PROFILE)
$uid = $d['channel_id']; );
$default = $d['default']; if($r) {
$data = $d['data']; $modified = strtotime($r[0]['edited'] . "Z");
$mimetype = $d['mimetype']; $mimetype = $r[0]['mimetype'];
if(intval($r[0]['os_storage']))
$data = file_get_contents($data);
else
$data = dbunescbin($r[0]['content']);
}
if(! $data) { if(! $data) {
$r = q("SELECT * FROM photo WHERE imgscale = %d AND uid = %d AND photo_usage = %d LIMIT 1", $d = [ 'imgscale' => $resolution, 'channel_id' => $uid, 'default' => $default, 'data' => '', 'mimetype' => '' ];
intval($resolution), call_hooks('get_profile_photo',$d);
intval($uid),
intval(PHOTO_PROFILE) $resolution = $d['imgscale'];
); $uid = $d['channel_id'];
if($r) { $default = $d['default'];
$modified = strtotime($r[0]['edited'] . "Z"); $data = $d['data'];
$data = dbunescbin($r[0]['content']); $mimetype = $d['mimetype'];
$mimetype = $r[0]['mimetype'];
}
if(intval($r[0]['os_storage']))
$data = file_get_contents($data);
} }
if(! $data) { if(! $data) {

View File

@ -360,14 +360,6 @@ function get_features($filtered = true, $level = (-1)) {
get_config('feature_lock','personal_tab') get_config('feature_lock','personal_tab')
], ],
[
'suggest',
t('Suggest Channels'),
t('Show friend and connection suggestions'),
false,
get_config('feature_lock','suggest')
],
[ [
'network_list_mode', 'network_list_mode',
t('Use blog/list mode'), t('Use blog/list mode'),

View File

@ -102,7 +102,8 @@
<br /> <br />
<br /> <br />
<div id="profile-photo-submit-wrapper"> <div id="profile-photo-submit-wrapper">
<input type="submit" name="submit" id="profile-photo-submit" value="{{$submit}}"> <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>
</div> </div>

View File

@ -124,7 +124,7 @@
{{/if}} {{/if}}
<div id="profile-photo-submit-wrapper"> <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-primary" name="submit" id="profile-photo-submit">{{$submit}}</button>
</div> </div>
</div> </div>