diff options
author | friendica <info@friendica.com> | 2014-08-04 16:47:49 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-08-04 16:48:40 -0700 |
commit | 00fc23bf4e169b4a48ae0bafae12cc3946b38cd6 (patch) | |
tree | a6353842e1cb0785e36483a41647d1500a5a5318 /mod | |
parent | a0695fa04fdc73a20beb216060573e1204950df6 (diff) | |
download | volse-hubzilla-00fc23bf4e169b4a48ae0bafae12cc3946b38cd6.tar.gz volse-hubzilla-00fc23bf4e169b4a48ae0bafae12cc3946b38cd6.tar.bz2 volse-hubzilla-00fc23bf4e169b4a48ae0bafae12cc3946b38cd6.zip |
issue #551 provide import/export of profiles (if this feature is enabled)
Diffstat (limited to 'mod')
-rw-r--r-- | mod/profiles.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/mod/profiles.php b/mod/profiles.php index c063599b4..bcaae909b 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -186,6 +186,33 @@ function profiles_post(&$a) { call_hooks('profile_post', $_POST); + // import from json export file. + // Only import fields that are allowed on this hub + + if(x($_FILES,'userfile')) { + $src = $_FILES['userfile']['tmp_name']; + $filesize = intval($_FILES['userfile']['size']); + if($filesize) { + $j = @json_decode(@file_get_contents($src),true); + @unlink($src); + if($j) { + $fields = get_profile_fields_advanced(); + if($fields) { + foreach($j as $jj => $v) { + foreach($fields as $f => $n) { + if($jj == $f) { + $_POST[$f] = $v; + break; + } + } + } + } + } + } + } + + + if((argc() > 1) && (argv(1) !== "new") && intval(argv(1))) { $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($a->argv[1]), @@ -205,6 +232,12 @@ function profiles_post(&$a) { notify( t('Profile Name is required.') . EOL); return; } + + if($_POST['dob']) { + $year = substr($_POST['dob'],0,4); + $month = substr($_POST['dob'],5,2); + $day = substr($_POST['dob'],8,2); + } $year = intval($_POST['year']); if($year < 1900 || $year > 2100 || $year < 0) @@ -559,6 +592,9 @@ function profiles_content(&$a) { '$cr_prof' => t('Create a new profile using these settings'), '$cl_prof' => t('Clone this profile'), '$del_prof' => t('Delete this profile'), + '$exportable' => feature_enabled(local_user(),'profile_export'), + '$lbl_import' => t('Import profile from file'), + '$lbl_export' => t('Export profile to file'), '$lbl_profname' => t('Profile Name:'), '$lbl_fullname' => t('Your Full Name:'), '$lbl_title' => t('Title/Description:'), |