profile field admin page (functional only: still needs a lot of HTML/CSS cleanup)
This commit is contained in:
parent
a0baa480e3
commit
548bf884a4
@ -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)
|
||||
|
121
mod/admin.php
121
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;
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
<li><a href='{{$admin.plugins.0}}'>{{$admin.plugins.1}}</a></li>
|
||||
<li><a href='{{$admin.themes.0}}'>{{$admin.themes.1}}</a></li>
|
||||
<li><a href='{{$admin.features.0}}'>{{$admin.features.1}}</a></li>
|
||||
<li><a href='{{$admin.profs.0}}'>{{$admin.profs.1}}</a></li>
|
||||
<li><a href='{{$admin.dbsync.0}}'>{{$admin.dbsync.1}}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
31
view/tpl/admin_profiles.tpl
Normal file
31
view/tpl/admin_profiles.tpl
Normal file
@ -0,0 +1,31 @@
|
||||
<div class="generic-content-wrapper">
|
||||
<h2>{{$title}}</h2>
|
||||
|
||||
<form action="admin/profs" method="post">
|
||||
|
||||
{{include file="field_textarea.tpl" field=$basic}}
|
||||
{{include file="field_textarea.tpl" field=$advanced}}
|
||||
|
||||
<input type="submit" name="submit" value="{{$submit}}" />
|
||||
|
||||
</form>
|
||||
|
||||
<div>{{$all_desc}}</div>
|
||||
|
||||
<div>{{$all}}</div>
|
||||
|
||||
<br /><br />
|
||||
<div>{{$cust_field_desc}}</div>
|
||||
|
||||
<button href="admin/profs/new">{{$new}}</button>
|
||||
|
||||
{{if $cust_fields}}
|
||||
<table>
|
||||
{{foreach $cust_fields as $field}}
|
||||
<tr><td>{{$field.field_desc}}</td><td>{{$field.field_name}}</td><td><a href="admin/profs/{{$field.id}}" >{{$edit}}</a> <a href="admin/profs/drop/{{$field.id}}">{{$drop}}</a></td></tr>
|
||||
{{/foreach}}
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
|
||||
</div>
|
Reference in New Issue
Block a user