aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-08-04 16:47:49 -0700
committerfriendica <info@friendica.com>2014-08-04 16:48:40 -0700
commit00fc23bf4e169b4a48ae0bafae12cc3946b38cd6 (patch)
treea6353842e1cb0785e36483a41647d1500a5a5318
parenta0695fa04fdc73a20beb216060573e1204950df6 (diff)
downloadvolse-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)
-rw-r--r--include/features.php4
-rw-r--r--include/identity.php16
-rw-r--r--mod/profiles.php36
-rwxr-xr-xview/tpl/profile_edit.tpl8
4 files changed, 52 insertions, 12 deletions
diff --git a/include/features.php b/include/features.php
index 383cb739f..6bb444cb6 100644
--- a/include/features.php
+++ b/include/features.php
@@ -24,8 +24,8 @@ function get_features() {
// This is per post, and different from fixed expiration 'expire' which isn't working yet
array('content_expire', t('Content Expiration'), t('Remove posts/comments and/or private messages at a future time')),
array('multi_profiles', t('Multiple Profiles'), t('Ability to create multiple profiles')),
- array('advanced_profiles', t('Advanced Profiles'), t('Additional profile sections and selections')),
-
+ array('advanced_profiles', t('Advanced Profiles'), t('Additional profile sections and selections')),
+ array('profile_export', t('Profile Import/Export'), t('Save and load profile details across sites/channels')),
array('webpages', t('Web Pages'), t('Provide managed web pages on your channel')),
array('private_notes', t('Private Notes'), t('Enables a tool to store notes and reminders')),
// prettyphoto has licensing issues and will no longer be provided in core -
diff --git a/include/identity.php b/include/identity.php
index feb249ea3..643961465 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -1313,12 +1313,12 @@ function is_public_profile() {
return false;
}
-function get_profile_fields_basic() {
- $profile_fields_basic = get_config('system','profile_fields_basic');
+function get_profile_fields_basic($filter = 0) {
+
+ $profile_fields_basic = (($filter == 0) ? get_config('system','profile_fields_basic') : null);
if(! $profile_fields_basic)
- $profile_fields_basic = array('name','pdesc','gender','dob','address','locality','region','postal_code','country_name','marital','sexual','homepage','hometown','keywords','about','contact');
+ $profile_fields_basic = array('name','pdesc','chandesc','gender','dob','dob_tz','address','locality','region','postal_code','country_name','marital','sexual','homepage','hometown','keywords','about','contact');
-// return $profile_fields_basic;
$x = array();
if($profile_fields_basic)
foreach($profile_fields_basic as $f)
@@ -1329,14 +1329,12 @@ function get_profile_fields_basic() {
}
-function get_profile_fields_advanced() {
- $basic = get_profile_fields_basic();
- $profile_fields_advanced = get_config('system','profile_fields_advanced');
+function get_profile_fields_advanced($filter = 0) {
+ $basic = get_profile_fields_basic($filter);
+ $profile_fields_advanced = (($filter == 0) ? get_config('system','profile_fields_advanced') : null);
if(! $profile_fields_advanced)
$profile_fields_advanced = array('with','howlong','politic','religion','likes','dislikes','interest','channels','music','book','film','tv','romance','work','education');
-// return $profile_fields_advanced;
-
$x = array();
if($basic)
foreach($basic as $f => $v)
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:'),
diff --git a/view/tpl/profile_edit.tpl b/view/tpl/profile_edit.tpl
index 1a99a07be..afd24185c 100755
--- a/view/tpl/profile_edit.tpl
+++ b/view/tpl/profile_edit.tpl
@@ -2,23 +2,29 @@
<h1>{{$banner}}</h1>
+<form id="profile-edit-form" name="form1" action="profiles/{{$profile_id}}" enctype="multipart/form-data" method="post" >
+
<div id="profile-edit-links">
<ul>
<li><a href="profile_photo" id="profile-photo_upload-link" title="{{$profpic}}">{{$profpic}}</a></li>
<li><a href="profile/{{$profile_id}}/view" id="profile-edit-view-link" title="{{$viewprof}}">{{$viewprof}}</a></li>
{{if ! $default}}<li><a href="profperm/{{$profile_id}}" id="profile-edit-view-link" title="{{$editvis}}">{{$editvis}}</a></li>{{/if}}
{{if $profile_clone_link}}<li><a href="{{$profile_clone_link}}" id="profile-edit-clone-link" title="{{$cr_prof}}">{{$cl_prof}}</a></li>{{/if}}
+{{if $exportable}}<li><a href="profiles/export/{{$profile_id}}" target="_blank">{{$lbl_export}}</a></li>
+<li><b>{{$lbl_import}}</b> <input type="file" name="userfile" ></li>
+{{/if}}
<li></li>
{{if ! $default}}<li><a href="{{$profile_drop_link}}" id="profile-edit-drop-link" title="{{$del_prof}}" {{$disabled}} >{{$del_prof}}</a></li>{{/if}}
</ul>
</div>
+
+
<div id="profile-edit-links-end"></div>
<div id="profile-edit-wrapper" >
-<form id="profile-edit-form" name="form1" action="profiles/{{$profile_id}}" method="post" >
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
<div id="profile-edit-profile-name-wrapper" >