From 7206e8af3a943b0fb286f253ed3abbda2d2572b6 Mon Sep 17 00:00:00 2001 From: jeroenpraat Date: Tue, 1 Mar 2016 22:08:50 +0100 Subject: Small fix for deleted forum channels showing in the forum widget (had this after migration from RM on 1 or 2 channels) --- include/widgets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/widgets.php b/include/widgets.php index a995fdf1c..aa0be87d6 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -1197,7 +1197,7 @@ function widget_forums($arr) { $perms_sql = item_permissions_sql(local_channel()) . item_normal(); - $r1 = q("select * from abook left join xchan on abook_xchan = xchan_hash where ( xchan_pubforum = 1 or ((abook_their_perms & %d ) != 0 and (abook_their_perms & %d ) = 0) ) and abook_channel = %d order by xchan_name $limit ", + $r1 = q("select * from abook left join xchan on abook_xchan = xchan_hash where ( xchan_pubforum = 1 or ((abook_their_perms & %d ) != 0 and (abook_their_perms & %d ) = 0) ) and xchan_deleted = 0 and abook_channel = %d order by xchan_name $limit ", intval(PERMS_W_TAGWALL), intval(PERMS_W_STREAM), intval(local_channel()) -- cgit v1.2.3 From c19a1a6b82d04d1c6a42f638998f2c692caf83dd Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 1 Mar 2016 14:13:38 -0800 Subject: revup --- version.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.inc b/version.inc index f06413611..9881b9f45 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2016-02-29.1322H +2016-03-01.1323H -- cgit v1.2.3 From 765dd5569b9ce2f18ac9974123d96452d0d19926 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 1 Mar 2016 14:55:04 -0800 Subject: Allow configuration of the display order of profile fields. This is an important piece of a more general profile configuration framework which will eventually be accessible via the admin page. --- include/identity.php | 19 +++++++++++ view/tpl/profile_advanced.tpl | 73 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 83 insertions(+), 9 deletions(-) diff --git a/include/identity.php b/include/identity.php index 380556246..382b096fe 100644 --- a/include/identity.php +++ b/include/identity.php @@ -1253,6 +1253,24 @@ function advanced_profile(&$a) { if($a->profile['name']) { + $profile_fields_basic = get_profile_fields_basic(); + $profile_fields_advanced = get_profile_fields_advanced(); + + $advanced = ((feature_enabled($a->profile['profile_uid'],'advanced_profiles')) ? true : false); + if($advanced) + $fields = $profile_fields_advanced; + else + $fields = $profile_fields_basic; + + $clean_fields = array(); + if($fields) { + foreach($fields as $k => $v) { + $clean_fields[] = trim($k); + } + } + + + $tpl = get_markup_template('profile_advanced.tpl'); $profile = array(); @@ -1370,6 +1388,7 @@ function advanced_profile(&$a) { '$canlike' => (($profile['canlike'])? true : false), '$likethis' => t('Like this thing'), '$profile' => $profile, + '$fields' => $clean_fields, '$editmenu' => profile_edit_menu($a->profile['profile_uid']), '$things' => $things )); diff --git a/view/tpl/profile_advanced.tpl b/view/tpl/profile_advanced.tpl index 3d09b762d..b7c527c31 100755 --- a/view/tpl/profile_advanced.tpl +++ b/view/tpl/profile_advanced.tpl @@ -31,186 +31,241 @@
-
-
{{$profile.fullname.0}}
-
{{$profile.fullname.1}}
-
+ {{foreach $fields as $f}} + {{if $f == 'name'}} +
+
{{$profile.fullname.0}}
+
{{$profile.fullname.1}}
+
+ {{/if}} + + {{if $f == 'gender'}} {{if $profile.gender}}
{{$profile.gender.0}}
{{$profile.gender.1}}
{{/if}} + {{/if}} + {{if $f == 'birthday'}} {{if $profile.birthday}}
{{$profile.birthday.0}}
{{$profile.birthday.1}}
{{/if}} + {{/if}} + {{if $f == 'age'}} {{if $profile.age}}
{{$profile.age.0}}
{{$profile.age.1}}
{{/if}} + {{/if}} + + {{if $f == 'marital'}} {{if $profile.marital}}
{{$profile.marital.0}}
{{$profile.marital.1}}{{if $profile.marital.with}} ({{$profile.marital.with}}){{/if}}{{if $profile.howlong}} {{$profile.howlong}}{{/if}}
{{/if}} + {{/if}} + {{if $f == 'sexual'}} {{if $profile.sexual}}
{{$profile.sexual.0}}
{{$profile.sexual.1}}
{{/if}} + {{/if}} + {{if $f == 'keywords'}} {{if $profile.keywords}}
{{$profile.keywords.0}}
{{$profile.keywords.1}}
{{/if}} + {{/if}} + {{if $f == 'homepage'}} {{if $profile.homepage}}
{{$profile.homepage.0}}
{{$profile.homepage.1}}
{{/if}} + {{/if}} + {{if $f == 'hometown'}} {{if $profile.hometown}}
{{$profile.hometown.0}}
{{$profile.hometown.1}}
{{/if}} + {{/if}} + + {{if $f == 'politic'}} {{if $profile.politic}}
{{$profile.politic.0}}
{{$profile.politic.1}}
{{/if}} + {{/if}} + {{if $f == 'religion'}} {{if $profile.religion}}
{{$profile.religion.0}}
{{$profile.religion.1}}
{{/if}} + {{/if}} + {{if $f == 'about'}} {{if $profile.about}}
{{$profile.about.0}}
{{$profile.about.1}}
{{/if}} + {{/if}} + {{if $f == 'interest'}} {{if $profile.interest}}
{{$profile.interest.0}}
{{$profile.interest.1}}
{{/if}} + {{/if}} + {{if $f == 'likes'}} {{if $profile.likes}}
{{$profile.likes.0}}
{{$profile.likes.1}}
{{/if}} + {{/if}} + {{if $f == 'dislikes'}} {{if $profile.dislikes}}
{{$profile.dislikes.0}}
{{$profile.dislikes.1}}
{{/if}} + {{/if}} + {{if $f == 'contact'}} {{if $profile.contact}}
{{$profile.contact.0}}
{{$profile.contact.1}}
{{/if}} + {{/if}} + {{if $f == 'channels'}} {{if $profile.channels}}
{{$profile.channels.0}}
{{$profile.channels.1}}
{{/if}} + {{/if}} + {{if $f == 'music'}} {{if $profile.music}}
{{$profile.music.0}}
{{$profile.music.1}}
{{/if}} + {{/if}} + {{if $f == 'book'}} {{if $profile.book}}
{{$profile.book.0}}
{{$profile.book.1}}
{{/if}} + {{/if}} + {{if $f == 'tv'}} {{if $profile.tv}}
{{$profile.tv.0}}
{{$profile.tv.1}}
{{/if}} + {{/if}} + {{if $f == 'film'}} {{if $profile.film}}
{{$profile.film.0}}
{{$profile.film.1}}
{{/if}} + {{/if}} + {{if $f == 'romance'}} {{if $profile.romance}}
{{$profile.romance.0}}
{{$profile.romance.1}}
{{/if}} + {{/if}} + {{if $f == 'work'}} {{if $profile.work}}
{{$profile.work.0}}
{{$profile.work.1}}
{{/if}} + {{/if}} + {{if $f == 'education'}} {{if $profile.education}}
{{$profile.education.0}}
{{$profile.education.1}}
{{/if}} + {{/if}} - {{foreach $profile.extra_fields as $f}} - {{if $profile.$f}} -
-
{{$profile.$f.0}}
-
{{$profile.$f.1}}
+ {{foreach $profile.extra_fields as $fld}} + {{if $f == $fld}} + {{if $profile.$fld}} +
+
{{$profile.$fld.0}}
+
{{$profile.$fld.1}}
{{/if}} + {{/if}} {{/foreach}} + {{/foreach}} {{if $things}} -- cgit v1.2.3 From 548bf884a4b34a4881f3188e54c592597f755dc9 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 1 Mar 2016 21:06:27 -0800 Subject: profile field admin page (functional only: still needs a lot of HTML/CSS cleanup) --- include/identity.php | 4 +- mod/admin.php | 121 +++++++++++++++++++++++++++++++++++++------- view/tpl/admin_aside.tpl | 1 + view/tpl/admin_profiles.tpl | 31 ++++++++++++ 4 files changed, 138 insertions(+), 19 deletions(-) create mode 100644 view/tpl/admin_profiles.tpl diff --git a/include/identity.php b/include/identity.php index 382b096fe..0a461dbe4 100644 --- a/include/identity.php +++ b/include/identity.php @@ -1652,7 +1652,7 @@ 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'); + $profile_fields_basic = array('name','pdesc','chandesc','gender','dob','dob_tz','address','locality','region','postal_code','country_name','marital','with','howlong','sexual','homepage','hometown','keywords','about','contact'); $x = array(); if($profile_fields_basic) @@ -1667,7 +1667,7 @@ 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'); + $profile_fields_advanced = array('politic','religion','likes','dislikes','interest','channels','music','book','film','tv','romance','work','education'); $x = array(); if($basic) diff --git a/mod/admin.php b/mod/admin.php index 292a4e66a..2e2536af3 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -1620,26 +1620,47 @@ readable."); function admin_page_profs_post(&$a) { - if($_REQUEST['id']) { - $r = q("update profdef set field_name = '%s', field_type = '%s', field_desc = '%s' field_help = '%s', field_inputs = '%s' where id = %d", - dbesc($_REQUEST['field_name']), - dbesc($_REQUEST['field_type']), - dbesc($_REQUEST['field_desc']), - dbesc($_REQUEST['field_help']), - dbesc($_REQUEST['field_inputs']), - intval($_REQUEST['id']) - ); + if(array_key_exists('basic',$_REQUEST)) { + $arr = explode(',',$_REQUEST['basic']); + for($x = 0; $x < count($arr); $x ++) + if(trim($arr[$x])) + $arr[$x] = trim($arr[$x]); + set_config('system','profile_fields_basic',$arr); + + if(array_key_exists('advanced',$_REQUEST)) { + $arr = explode(',',$_REQUEST['advanced']); + for($x = 0; $x < count($arr); $x ++) + if(trim($arr[$x])) + $arr[$x] = trim($arr[$x]); + set_config('system','profile_fields_advanced',$arr); + } + goaway(z_root() . '/admin/profs'); } - else { - $r = q("insert into profdef ( field_name, field_type, field_desc, field_help, field_inputs ) values ( '%s' , '%s', '%s', '%s', '%s' )", - dbesc($_REQUEST['field_name']), - dbesc($_REQUEST['field_type']), - dbesc($_REQUEST['field_desc']), - dbesc($_REQUEST['field_help']), - dbesc($_REQUEST['field_inputs']) - ); + + + if(array_key_exists('field_name',$_REQUEST)) { + if($_REQUEST['id']) { + $r = q("update profdef set field_name = '%s', field_type = '%s', field_desc = '%s' field_help = '%s', field_inputs = '%s' where id = %d", + dbesc($_REQUEST['field_name']), + dbesc($_REQUEST['field_type']), + dbesc($_REQUEST['field_desc']), + dbesc($_REQUEST['field_help']), + dbesc($_REQUEST['field_inputs']), + intval($_REQUEST['id']) + ); + } + else { + $r = q("insert into profdef ( field_name, field_type, field_desc, field_help, field_inputs ) values ( '%s' , '%s', '%s', '%s', '%s' )", + dbesc($_REQUEST['field_name']), + dbesc($_REQUEST['field_type']), + dbesc($_REQUEST['field_desc']), + dbesc($_REQUEST['field_help']), + dbesc($_REQUEST['field_inputs']) + ); + } } + // add to chosen array basic or advanced goaway(z_root() . '/admin/profs'); @@ -1686,4 +1707,70 @@ function admin_page_profs(&$a) { '$submit' => t('Save') )); } + + $basic = ''; + $barr = array(); + $fields = get_profile_fields_basic(); + if(! $fields) + $fields = get_profile_fields_basic(1); + if($fields) { + foreach($fields as $k => $v) { + if($basic) + $basic .= ', '; + $basic .= trim($k); + $barr[] = trim($k); + } + } + + $advanced = ''; + $fields = get_profile_fields_advanced(); + if(! $fields) + $fields = get_profile_fields_advanced(1); + if($fields) { + foreach($fields as $k => $v) { + if(in_array(trim($k),$barr)) + continue; + if($advanced) + $advanced .= ', '; + $advanced .= trim($k); + } + } + + $all = ''; + $fields = get_profile_fields_advanced(1); + if($fields) { + foreach($fields as $k => $v) { + if($all) + $all .= ', '; + $all .= trim($k); + } + } + + $r = q("select * from profdef where true"); + if($r) { + foreach($r as $rr) { + if($all) + $all .= ', '; + $all .= $rr['field_name']; + } + } + + + $o = replace_macros(get_markup_template('admin_profiles.tpl'),array( + '$title' => t('Profile Management'), + '$basic' => array('basic',t('Basic Profile Fields'),$basic,''), + '$advanced' => array('advanced',t('Advanced Profile Fields'),$advanced,t('In addition to basic fields')), + '$all' => $all, + '$all_desc' => t('All available fields'), + '$cust_field_desc' => t('Custom Fields'), + '$cust_fields' => $r, + '$edit' => t('Edit'), + '$drop' => t('Delete'), + '$new' => t('Create'), + '$submit' => t('Submit') + )); + + return $o; + + } diff --git a/view/tpl/admin_aside.tpl b/view/tpl/admin_aside.tpl index ab190fc95..da762a094 100755 --- a/view/tpl/admin_aside.tpl +++ b/view/tpl/admin_aside.tpl @@ -21,6 +21,7 @@
  • {{$admin.plugins.1}}
  • {{$admin.themes.1}}
  • {{$admin.features.1}}
  • +
  • {{$admin.profs.1}}
  • {{$admin.dbsync.1}}
  • diff --git a/view/tpl/admin_profiles.tpl b/view/tpl/admin_profiles.tpl new file mode 100644 index 000000000..70fcc303b --- /dev/null +++ b/view/tpl/admin_profiles.tpl @@ -0,0 +1,31 @@ +
    +

    {{$title}}

    + +
    + +{{include file="field_textarea.tpl" field=$basic}} +{{include file="field_textarea.tpl" field=$advanced}} + + + +
    + +
    {{$all_desc}}
    + +
    {{$all}}
    + +

    +
    {{$cust_field_desc}}
    + + + +{{if $cust_fields}} + +{{foreach $cust_fields as $field}} + +{{/foreach}} +
    {{$field.field_desc}}{{$field.field_name}}{{$edit}} {{$drop}}
    +{{/if}} + + +
    -- cgit v1.2.3 From 428b4dbad63d429c3b0d47b49ff5918dbda3c596 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 1 Mar 2016 22:47:07 -0800 Subject: sort out the with and howlong dependencies --- include/identity.php | 4 ++-- view/tpl/profile_advanced.tpl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/identity.php b/include/identity.php index 0a461dbe4..382b096fe 100644 --- a/include/identity.php +++ b/include/identity.php @@ -1652,7 +1652,7 @@ 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','with','howlong','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'); $x = array(); if($profile_fields_basic) @@ -1667,7 +1667,7 @@ 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('politic','religion','likes','dislikes','interest','channels','music','book','film','tv','romance','work','education'); + $profile_fields_advanced = array('with','howlong','politic','religion','likes','dislikes','interest','channels','music','book','film','tv','romance','work','education'); $x = array(); if($basic) diff --git a/view/tpl/profile_advanced.tpl b/view/tpl/profile_advanced.tpl index 034a6d43d..a724c41bb 100755 --- a/view/tpl/profile_advanced.tpl +++ b/view/tpl/profile_advanced.tpl @@ -72,7 +72,7 @@ {{if $profile.marital}}
    {{$profile.marital.0}}
    -
    {{$profile.marital.1}}{{if $profile.marital.with}} ({{$profile.marital.with}}){{/if}}{{if $profile.howlong}} {{$profile.howlong}}{{/if}}
    +
    {{$profile.marital.1}}{{if in_array('with',$fields)}}{{if $profile.marital.with}} ({{$profile.marital.with}}){{/if}}{{/if}}{{if in_array('howlong',$fields)}}{{if $profile.howlong}} {{$profile.howlong}}{{/if}}{{/if}}
    {{/if}} {{/if}} -- cgit v1.2.3