Merge pull request #707 from dawnbreak/docu

Import Module documentation and @-sign replacement.
This commit is contained in:
git-marijus 2017-03-27 11:30:16 +02:00 committed by GitHub
commit 6ed5784491

View file

@ -2,23 +2,29 @@
namespace Zotlabs\Module;
// Import a channel, either by direct file upload or via
// connection to original server.
require_once('include/zot.php');
require_once('include/channel.php');
require_once('include/import.php');
require_once('include/perm_upgrade.php');
/**
* @brief Module for channel import.
*
* Import a channel, either by direct file upload or via
* connection to another server.
*/
class Import extends \Zotlabs\Web\Controller {
/**
* @brief Import channel into account.
*
* @param int $account_id
*/
function import_account($account_id) {
if(! $account_id){
logger("import_account: No account ID supplied");
logger('No account ID supplied');
return;
}
@ -33,11 +39,11 @@ class Import extends \Zotlabs\Web\Controller {
$filesize = intval($_FILES['filename']['size']);
$filetype = $_FILES['filename']['type'];
// import channel from file
if($src) {
// This is OS specific and could also fail if your tmpdir isn't very large
// mostly used for Diaspora which exports gzipped files.
// This is OS specific and could also fail if your tmpdir isn't very
// large mostly used for Diaspora which exports gzipped files.
if(strpos($filename,'.gz')){
@rename($src,$src . '.gz');
@ -50,12 +56,16 @@ class Import extends \Zotlabs\Web\Controller {
unlink($src);
}
// import channel from another server
if(! $src) {
$old_address = ((x($_REQUEST,'old_address')) ? $_REQUEST['old_address'] : '');
if(! $old_address) {
logger('mod_import: nothing to import.');
logger('Nothing to import.');
notice( t('Nothing to import.') . EOL);
return;
} else if(strpos($old_address, '')) {
// if you copy the identity address from your profile page, make it work for convenience
$old_address = str_replace('', '@', $old_address);
}
$email = ((x($_REQUEST,'email')) ? $_REQUEST['email'] : '');
@ -87,7 +97,7 @@ class Import extends \Zotlabs\Web\Controller {
}
if(! $data) {
logger('mod_import: empty file.');
logger('Empty import file.');
notice( t('Imported file is empty.') . EOL);
return;
}
@ -97,7 +107,6 @@ class Import extends \Zotlabs\Web\Controller {
// logger('import: data: ' . print_r($data,true));
// print_r($data);
if(! array_key_exists('compatibility',$data)) {
call_hooks('import_foreign_channel_data',$data);
if($data['handled'])
@ -137,7 +146,6 @@ class Import extends \Zotlabs\Web\Controller {
}
$channel = import_channel($data['channel'], $account_id, $seize);
}
else {
$moving = false;
@ -145,22 +153,17 @@ class Import extends \Zotlabs\Web\Controller {
}
if(! $channel) {
logger('mod_import: channel not found. ', print_r($channel,true));
logger('Channel not found. ', print_r($channel,true));
notice( t('No channel. Import failed.') . EOL);
return;
}
if(is_array($data['config'])) {
import_config($channel,$data['config']);
}
logger('import step 2');
if(array_key_exists('channel',$data)) {
if($data['photo']) {
require_once('include/photo/photo_driver.php');
@ -212,7 +215,6 @@ class Import extends \Zotlabs\Web\Controller {
logger('import step 5');
// import xchans and contact photos
if(array_key_exists('channel',$data) && $seize) {
@ -223,7 +225,6 @@ class Import extends \Zotlabs\Web\Controller {
dbesc($channel['channel_hash'])
);
$r = xchan_store_lowlevel(
[
'xchan_hash' => $channel['channel_hash'],
@ -248,7 +249,6 @@ class Import extends \Zotlabs\Web\Controller {
logger('import step 6');
$xchans = $data['xchan'];
if($xchans) {
foreach($xchans as $xchan) {
@ -357,7 +357,7 @@ class Import extends \Zotlabs\Web\Controller {
translate_abook_perms_inbound($channel,$abook_copy);
if($abconfig) {
// @fixme does not handle sync of del_abconfig
/// @FIXME does not handle sync of del_abconfig
foreach($abconfig as $abc) {
set_abconfig($channel['channel_id'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
}
@ -469,12 +469,12 @@ class Import extends \Zotlabs\Web\Controller {
change_channel($channel['channel_id']);
goaway(z_root() . '/network' );
}
/**
* @brief Handle POST action on channel import page.
*/
function post() {
$account_id = get_account_id();
if(! $account_id)
return;
@ -482,6 +482,11 @@ class Import extends \Zotlabs\Web\Controller {
$this->import_account($account_id);
}
/**
* @brief Generate channel import page.
*
* @return string with parsed HTML.
*/
function get() {
if(! get_account_id()) {
@ -508,7 +513,6 @@ class Import extends \Zotlabs\Web\Controller {
));
return $o;
}
}