aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Cover_photo.php1
-rw-r--r--Zotlabs/Module/Import.php61
-rw-r--r--Zotlabs/Module/Photo.php70
-rw-r--r--Zotlabs/Module/Profile_photo.php1
4 files changed, 71 insertions, 62 deletions
diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php
index d76c1b408..76e80156c 100644
--- a/Zotlabs/Module/Cover_photo.php
+++ b/Zotlabs/Module/Cover_photo.php
@@ -355,6 +355,7 @@ class Cover_photo extends \Zotlabs\Web\Controller {
$o .= replace_macros($tpl,array(
'$user' => \App::$channel['channel_address'],
+ '$info' => t('Your cover photo may be visible to anybody on the internet'),
'$existing' => get_cover_photo(local_channel(),'array',PHOTO_RES_COVER_850),
'$lbl_upfile' => t('Upload File:'),
'$lbl_profiles' => t('Select a profile:'),
diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php
index 81c405f00..d031bf16b 100644
--- a/Zotlabs/Module/Import.php
+++ b/Zotlabs/Module/Import.php
@@ -6,6 +6,7 @@ require_once('include/zot.php');
require_once('include/channel.php');
require_once('include/import.php');
require_once('include/perm_upgrade.php');
+require_once('library/urlify/URLify.php');
/**
@@ -38,6 +39,7 @@ class Import extends \Zotlabs\Web\Controller {
$filename = basename($_FILES['filename']['name']);
$filesize = intval($_FILES['filename']['size']);
$filetype = $_FILES['filename']['type'];
+ $newname = trim(strtolower($_REQUEST['newname']));
// import channel from file
if($src) {
@@ -146,7 +148,20 @@ class Import extends \Zotlabs\Web\Controller {
}
}
- $channel = import_channel($data['channel'], $account_id, $seize);
+ if($newname) {
+ $x = false;
+
+ if(get_config('system','unicode_usernames')) {
+ $x = punify(mb_strtolower($newname));
+ }
+
+ if((! $x) || strlen($x) > 64) {
+ $x = strtolower(\URLify::transliterate($newname));
+ }
+ $newname = $x;
+ }
+
+ $channel = import_channel($data['channel'], $account_id, $seize, $newname);
}
else {
$moving = false;
@@ -363,11 +378,27 @@ class Import extends \Zotlabs\Web\Controller {
continue;
}
- abook_store_lowlevel($abook);
+ $r = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
+ dbesc($abook['abook_xchan']),
+ intval($channel['channel_id'])
+ );
+ if($r) {
+ foreach($abook as $k => $v) {
+ $r = q("UPDATE abook SET " . TQUOT . "%s" . TQUOT . " = '%s' WHERE abook_xchan = '%s' AND abook_channel = %d",
+ dbesc($k),
+ dbesc($v),
+ dbesc($abook['abook_xchan']),
+ intval($channel['channel_id'])
+ );
+ }
+ }
+ else {
+ abook_store_lowlevel($abook);
- $friends ++;
- if(intval($abook['abook_feed']))
- $feeds ++;
+ $friends ++;
+ if(intval($abook['abook_feed']))
+ $feeds ++;
+ }
translate_abook_perms_inbound($channel,$abook_copy);
@@ -516,16 +547,20 @@ class Import extends \Zotlabs\Web\Controller {
'$desc' => t('Use this form to import an existing channel from a different server/hub. You may retrieve the channel identity from the old server/hub via the network or provide an export file.'),
'$label_filename' => t('File to Upload'),
'$choice' => t('Or provide the old server/hub details'),
- '$label_old_address' => t('Your old identity address (xyz@example.com)'),
- '$label_old_email' => t('Your old login email address'),
- '$label_old_pass' => t('Your old login password'),
+
+ '$old_address' => [ 'old_address', t('Your old identity address (xyz@example.com)'), '', ''],
+ '$email' => [ 'email', t('Your old login email address'), '', '' ],
+ '$password' => [ 'password', t('Your old login password'), '', '' ],
+ '$import_posts' => [ 'import_posts', t('Import a few months of posts if possible (limited by available memory'), false, '', [ t('No'), t('Yes') ]],
+
'$common' => t('For either option, please choose whether to make this hub your new primary address, or whether your old location should continue this role. You will be able to post from either location, but only one can be marked as the primary location for files, photos, and media.'),
- '$label_import_primary' => t('Make this hub my primary location'),
- '$label_import_moving' => t('Move this channel (disable all previous locations)'),
- '$label_import_posts' => t('Import a few months of posts if possible (limited by available memory'),
+
+ '$make_primary' => [ 'make_primary', t('Make this hub my primary location'), false, '', [ t('No'), t('Yes') ] ],
+ '$moving' => [ 'moving', t('Move this channel (disable all previous locations)'), false, '', [ t('No'), t('Yes') ] ],
+ '$newname' => [ 'newname', t('Use this channel nickname instead of the one provided'), '', t('Leave blank to keep your existing channel nickname. You will be randomly assigned a similar nickname if either name is already allocated on this site.')],
+
'$pleasewait' => t('This process may take several minutes to complete. Please submit the form only once and leave this page open until finished.'),
- '$email' => '',
- '$pass' => '',
+
'$form_security_token' => get_form_security_token('channel_import'),
'$submit' => t('Submit')
));
diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php
index 8a110f925..b3171fe75 100644
--- a/Zotlabs/Module/Photo.php
+++ b/Zotlabs/Module/Photo.php
@@ -127,69 +127,45 @@ class Photo extends \Zotlabs\Web\Controller {
}
}
- $r = q("SELECT uid FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
+ $r = q("SELECT uid, photo_usage FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
dbesc($photo),
intval($resolution)
);
if($r) {
-
- $allowed = (($r[0]['uid']) ? perm_is_allowed($r[0]['uid'],$observer_xchan,'view_storage') : true);
-
- $sql_extra = permissions_sql($r[0]['uid']);
- if(! $sql_extra)
- $sql_extra = ' and true ';
-
- // Only check permissions on normal photos. Those photos we don't check includes
- // profile photos, xchan photos (which are also profile photos), 'thing' photos,
- // and cover photos
-
- $sql_extra = " and (( photo_usage = 0 $sql_extra ) or photo_usage != 0 )";
+ $allowed = (-1);
+ if(intval($r[0]['photo_usage'])) {
+ $allowed = 1;
+ if(intval($r[0]['photo_usage']) === PHOTO_COVER)
+ if($resolution < PHOTO_RES_COVER_1200)
+ $allowed = (-1);
+ if(intval($r[0]['photo_usage']) === PHOTO_PROFILE)
+ if(! in_array($resolution,[4,5,6]))
+ $allowed = (-1);
+ }
+ if($allowed === (-1))
+ $allowed = attach_can_view($r[0]['uid'],$observer_xchan,$photo);
+
$channel = channelx_by_n($r[0]['uid']);
// Now we'll see if we can access the photo
- $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d $sql_extra LIMIT 1",
+ $e = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d $sql_extra LIMIT 1",
dbesc($photo),
intval($resolution)
);
- // viewing cover photos is allowed unless a plugin chooses to block it.
-
- if($r && intval($r[0]['photo_usage']) === PHOTO_COVER && $resolution >= PHOTO_RES_COVER_1200)
- $allowed = 1;
-
- $d = [ 'imgscale' => $resolution, 'resource_id' => $photo, 'photo' => $r, 'allowed' => $allowed ];
- call_hooks('get_photo',$d);
+ $exists = (($e) ? true : false);
- $resolution = $d['imgscale'];
- $photo = $d['resource_id'];
- $r = $d['photo'];
- $allowed = $d['allowed'];
-
- if($r && $allowed) {
- $data = dbunescbin($r[0]['content']);
- $mimetype = $r[0]['mimetype'];
- if(intval($r[0]['os_storage'])) {
+ if($exists && $allowed) {
+ $data = dbunescbin($e[0]['content']);
+ $mimetype = $e[0]['mimetype'];
+ if(intval($e[0]['os_storage'])) {
$streaming = $data;
}
}
else {
-
- // Does the picture exist? It may be a remote person with no credentials,
- // but who should otherwise be able to view it. Show a default image to let
- // them know permissions was denied. It may be possible to view the image
- // through an authenticated profile visit.
- // There won't be many completely unauthorised people seeing this because
- // they won't have the photo link, so there's a reasonable chance that the person
- // might be able to obtain permission to view it.
-
- $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
- dbesc($photo),
- intval($resolution)
- );
-
- if($r) {
+ if(! $allowed) {
logger('mod_photo: forbidden. ' . \App::$query_string);
$observer = \App::get_observer();
logger('mod_photo: observer = ' . (($observer) ? $observer['xchan_addr'] : '(not authenticated)'));
@@ -201,9 +177,6 @@ class Photo extends \Zotlabs\Web\Controller {
}
}
-
-
-
if(! isset($data)) {
if(isset($resolution)) {
switch($resolution) {
@@ -295,7 +268,6 @@ class Photo extends \Zotlabs\Web\Controller {
}
killme();
- // NOTREACHED
}
}
diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php
index 2ce8686b9..751c4338f 100644
--- a/Zotlabs/Module/Profile_photo.php
+++ b/Zotlabs/Module/Profile_photo.php
@@ -451,6 +451,7 @@ 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.')),
'$importfile' => (($importing) ? \App::$data['importfile'] : ''),
'$lbl_upfile' => t('Upload File:'),
'$lbl_profiles' => t('Select a profile:'),