issue #551 provide import/export of profiles (if this feature is enabled)
This commit is contained in:
parent
a0695fa04f
commit
00fc23bf4e
@ -25,7 +25,7 @@ function get_features() {
|
||||
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('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 -
|
||||
|
@ -1313,12 +1313,12 @@ function is_public_profile() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_profile_fields_basic() {
|
||||
$profile_fields_basic = get_config('system','profile_fields_basic');
|
||||
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');
|
||||
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','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)
|
||||
|
@ -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]),
|
||||
@ -206,6 +233,12 @@ function profiles_post(&$a) {
|
||||
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)
|
||||
$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:'),
|
||||
|
@ -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" >
|
||||
|
Reference in New Issue
Block a user