From b4aed1212930e40377665dc45271f2b1f428511f Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 20 Aug 2014 23:01:25 -0700 Subject: extensible profiles - add the input form elements. Still needs styling and we're not yet storing the results. And right now we're ignoring the type and only doing type=string. Oh yeah - and I split off starting the second delivery chain into its own function in tag_deliver since it was largely duplicate code. --- mod/profiles.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'mod/profiles.php') diff --git a/mod/profiles.php b/mod/profiles.php index b938e836b..d6df09e9a 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -568,6 +568,24 @@ function profiles_content(&$a) { '$no_selected' => (($r[0]['hide_friends'] == 0) ? " checked=\"checked\" " : "") )); + $q = q("select * from profdef where true"); + if($q) { + $extra_fields = array(); + + foreach($q as $qq) { + $mine = q("select v from profext where k = '%s' and hash = '%s' and channel_id = %d limit 1", + dbesc($qq['field_name']), + dbesc($r[0]['profile_guid']), + intval(local_user()) + ); + + if(array_key_exists($qq['field_name'],$fields)) { + $extra_fields[] = array($qq['field_name'],$qq['field_desc'],(($mine) ? $mine[0]['v'] : ''), $qq['field_help']); + } + } + } + +logger('extra_fields: ' . print_r($extra_fields,true)); $f = get_config('system','birthday_input_format'); if(! $f) @@ -674,6 +692,7 @@ function profiles_content(&$a) { '$education' => $r[0]['education'], '$contact' => $r[0]['contact'], '$channels' => $r[0]['channels'], + '$extra_fields' => $extra_fields, )); $arr = array('profile' => $r[0], 'entry' => $o); -- cgit v1.2.3 From feddf5d7fb1d0cecbad69ecd314af0d106c0a9be Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 28 Aug 2014 22:18:11 -0700 Subject: fix saving of extended profile attributes --- mod/profiles.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'mod/profiles.php') diff --git a/mod/profiles.php b/mod/profiles.php index d6df09e9a..1504f55f0 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -254,6 +254,7 @@ function profiles_post(&$a) { // $month = 1; $day = 1; // } + $dob = '0000-00-00'; $dob = sprintf('%04d-%02d-%02d',$year,$month,$day); @@ -264,6 +265,9 @@ function profiles_post(&$a) { $namechanged = true; + + + $pdesc = escape_tags(trim($_POST['pdesc'])); $gender = escape_tags(trim($_POST['gender'])); $address = escape_tags(trim($_POST['address'])); @@ -344,7 +348,41 @@ function profiles_post(&$a) { $with = $orig[0]['with']; } + $profile_fields_basic = get_profile_fields_basic(); + $profile_fields_advanced = get_profile_fields_advanced(); + $advanced = ((feature_enabled(local_user(),'advanced_profiles')) ? true : false); + if($advanced) + $fields = $profile_fields_advanced; + else + $fields = $profile_fields_basic; + $z = q("select * from profdef where true"); + if($z) { + foreach($z as $zz) { + if(array_key_exists($zz['field_name'],$fields)) { + $w = q("select * from profext where channel_id = %d and hash = '%s' and k = '%s' limit 1", + intval(local_user()), + dbesc($orig[0]['profile_guid']), + dbesc($zz['field_name']) + ); + if($w) { + q("update profext set v = '%s' where id = %d limit 1", + dbesc(escape_tags(trim($_POST[$zz['field_name']]))), + intval($w[0]['id']) + ); + } + else { + q("insert into profdef ( channel_id, hash, k, v ) values ( %d, '%s', '%s', '%s') ", + intval(local_user()), + dbesc($orig[0]['profile_guid']), + dbesc($zz['field_name']), + dbesc(escape_tags(trim($_POST[$zz['field_name']]))) + ); + } + } + } + } + $changes = array(); -- cgit v1.2.3 From 0825ec81c130621bdaccba3aa1f627b08c91128e Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 28 Aug 2014 22:27:05 -0700 Subject: except for a typo --- mod/profiles.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'mod/profiles.php') diff --git a/mod/profiles.php b/mod/profiles.php index 1504f55f0..6361f56a3 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -372,7 +372,7 @@ function profiles_post(&$a) { ); } else { - q("insert into profdef ( channel_id, hash, k, v ) values ( %d, '%s', '%s', '%s') ", + q("insert into profext ( channel_id, hash, k, v ) values ( %d, '%s', '%s', '%s') ", intval(local_user()), dbesc($orig[0]['profile_guid']), dbesc($zz['field_name']), @@ -383,8 +383,6 @@ function profiles_post(&$a) { } } - - $changes = array(); $value = ''; if($is_default) { -- cgit v1.2.3