2007-11-13 12:28:36 +00:00
< ? php
// $Id$
/**
* @ file
* Administrative page callbacks for the profile module .
*/
/**
2007-11-30 09:02:51 +00:00
* Form builder to display a listing of all editable profile fields .
2007-12-08 14:06:23 +00:00
*
2007-11-30 09:02:51 +00:00
* @ ingroup forms
2008-01-08 10:35:43 +00:00
* @ see profile_admin_overview_submit ()
2007-11-13 12:28:36 +00:00
*/
2009-09-18 00:12:48 +00:00
function profile_admin_overview ( $form ) {
2008-12-05 12:50:28 +00:00
$result = db_query ( 'SELECT title, name, type, category, fid, weight FROM {profile_field} ORDER BY category, weight' );
2007-12-08 14:06:23 +00:00
2007-11-30 09:02:51 +00:00
$categories = array ();
2009-05-26 10:41:06 +00:00
foreach ( $result as $field ) {
2007-11-30 09:02:51 +00:00
// Collect all category information
$categories [] = $field -> category ;
// Save all field information
2008-07-16 21:59:29 +00:00
$form [ $field -> fid ][ 'name' ] = array ( '#markup' => check_plain ( $field -> name ));
$form [ $field -> fid ][ 'title' ] = array ( '#markup' => check_plain ( $field -> title ));
$form [ $field -> fid ][ 'type' ] = array ( '#markup' => $field -> type );
2007-11-30 09:02:51 +00:00
$form [ $field -> fid ][ 'category' ] = array ( '#type' => 'select' , '#default_value' => $field -> category , '#options' => array ());
$form [ $field -> fid ][ 'weight' ] = array ( '#type' => 'weight' , '#default_value' => $field -> weight );
2009-11-03 05:27:18 +00:00
$form [ $field -> fid ][ 'edit' ] = array ( '#type' => 'link' , '#title' => t ( 'edit' ), '#href' => " admin/config/people/profile/edit/ $field->fid " );
$form [ $field -> fid ][ 'delete' ] = array ( '#type' => 'link' , '#title' => t ( 'delete' ), '#href' => " admin/config/people/profile/delete/ $field->fid " );
2007-11-30 09:02:51 +00:00
}
2007-12-08 14:06:23 +00:00
2008-12-30 16:43:20 +00:00
// Add the category combo boxes
2007-11-30 09:02:51 +00:00
$categories = array_unique ( $categories );
2007-12-08 14:06:23 +00:00
foreach ( $form as $fid => $field ) {
foreach ( $categories as $cat => $category ) {
2007-11-30 09:02:51 +00:00
$form [ $fid ][ 'category' ][ '#options' ][ $category ] = $category ;
}
2007-11-13 12:28:36 +00:00
}
2007-12-08 14:06:23 +00:00
2007-11-30 09:02:51 +00:00
// Display the submit button only when there's more than one field
if ( count ( $form ) > 1 ) {
$form [ 'submit' ] = array ( '#type' => 'submit' , '#value' => t ( 'Save configuration' ));
2007-11-13 12:28:36 +00:00
}
2007-11-30 09:02:51 +00:00
else {
// Disable combo boxes when there isn't a submit button
foreach ( $form as $fid => $field ) {
unset ( $form [ $fid ][ 'weight' ]);
$form [ $fid ][ 'category' ][ '#type' ] = 'value' ;
}
}
$form [ '#tree' ] = TRUE ;
2007-12-08 14:06:23 +00:00
2009-11-03 05:27:18 +00:00
// @todo: Any reason this isn't done using an element with #theme = 'links'?
2008-04-14 17:48:46 +00:00
$addnewfields = '<h2>' . t ( 'Add new field' ) . '</h2>' ;
2007-11-30 09:02:51 +00:00
$addnewfields .= '<ul>' ;
foreach ( _profile_field_types () as $key => $value ) {
2009-08-21 14:27:47 +00:00
$addnewfields .= '<li>' . l ( $value , " admin/config/people/profile/add/ $key " ) . '</li>' ;
2007-11-30 09:02:51 +00:00
}
$addnewfields .= '</ul>' ;
2008-07-16 21:59:29 +00:00
$form [ 'addnewfields' ] = array ( '#markup' => $addnewfields );
2007-11-13 12:28:36 +00:00
2007-11-30 09:02:51 +00:00
return $form ;
}
2007-11-13 12:28:36 +00:00
2007-11-30 09:02:51 +00:00
/**
2008-01-21 15:20:43 +00:00
* Submit handler to update changed profile field weights and categories .
2007-12-08 14:06:23 +00:00
*
2008-01-08 10:35:43 +00:00
* @ see profile_admin_overview ()
2007-11-30 09:02:51 +00:00
*/
function profile_admin_overview_submit ( $form , & $form_state ) {
foreach ( element_children ( $form_state [ 'values' ]) as $fid ) {
if ( is_numeric ( $fid )) {
$weight = $form_state [ 'values' ][ $fid ][ 'weight' ];
$category = $form_state [ 'values' ][ $fid ][ 'category' ];
if ( $weight != $form [ $fid ][ 'weight' ][ '#default_value' ] || $category != $form [ $fid ][ 'category' ][ '#default_value' ]) {
2009-05-26 10:41:06 +00:00
db_update ( 'profile_field' )
-> fields ( array (
'weight' => $weight ,
'category' => $category ,
))
-> condition ( 'fid' , $fid )
-> execute ();
2007-11-30 09:02:51 +00:00
}
}
2007-11-13 12:28:36 +00:00
}
2007-11-30 09:02:51 +00:00
drupal_set_message ( t ( 'Profile fields have been updated.' ));
cache_clear_all ();
menu_rebuild ();
}
/**
* Theme the profile field overview into a drag and drop enabled table .
*
* @ ingroup themeable
2008-01-08 10:35:43 +00:00
* @ see profile_admin_overview ()
2007-11-30 09:02:51 +00:00
*/
2009-10-09 01:00:08 +00:00
function theme_profile_admin_overview ( $variables ) {
$form = $variables [ 'form' ];
2008-04-14 17:48:46 +00:00
drupal_add_css ( drupal_get_path ( 'module' , 'profile' ) . '/profile.css' );
2007-11-30 09:02:51 +00:00
// Add javascript if there's more than one field.
if ( isset ( $form [ 'submit' ])) {
2008-04-14 17:48:46 +00:00
drupal_add_js ( drupal_get_path ( 'module' , 'profile' ) . '/profile.js' );
2007-11-30 09:02:51 +00:00
}
$rows = array ();
$categories = array ();
$category_number = 0 ;
foreach ( element_children ( $form ) as $key ) {
// Don't take form control structures.
if ( array_key_exists ( 'category' , $form [ $key ])) {
$field = & $form [ $key ];
$category = $field [ 'category' ][ '#default_value' ];
if ( ! isset ( $categories [ $category ])) {
// Category classes are given numeric IDs because there's no guarantee
// class names won't contain invalid characters.
$categories [ $category ] = $category_number ;
2009-08-22 14:34:23 +00:00
$category_field [ '#attributes' ][ 'class' ] = array ( 'profile-category' , 'profile-category-' . $category_number );
$rows [] = array ( array ( 'data' => $category , 'colspan' => 7 , 'class' => array ( 'category' )));
$rows [] = array ( 'data' => array ( array ( 'data' => '<em>' . t ( 'No fields in this category. If this category remains empty when saved, it will be removed.' ) . '</em>' , 'colspan' => 7 )), 'class' => array ( 'category-' . $category_number . '-message' , 'category-message' , 'category-populated' ));
2007-12-08 14:06:23 +00:00
2008-12-30 16:43:20 +00:00
// Make it draggable only if there is more than one field
2007-11-30 09:02:51 +00:00
if ( isset ( $form [ 'submit' ])) {
2008-04-14 17:48:46 +00:00
drupal_add_tabledrag ( 'profile-fields' , 'order' , 'sibling' , 'profile-weight' , 'profile-weight-' . $category_number );
drupal_add_tabledrag ( 'profile-fields' , 'match' , 'sibling' , 'profile-category' , 'profile-category-' . $category_number );
2007-11-30 09:02:51 +00:00
}
$category_number ++ ;
}
// Add special drag and drop classes that group fields together.
2009-08-22 14:34:23 +00:00
$field [ 'weight' ][ '#attributes' ][ 'class' ] = array ( 'profile-weight' , 'profile-weight-' . $categories [ $category ]);
$field [ 'category' ][ '#attributes' ][ 'class' ] = array ( 'profile-category' , 'profile-category-' . $categories [ $category ]);
2007-12-08 14:06:23 +00:00
2007-11-30 09:02:51 +00:00
// Add the row
$row = array ();
$row [] = drupal_render ( $field [ 'title' ]);
$row [] = drupal_render ( $field [ 'name' ]);
$row [] = drupal_render ( $field [ 'type' ]);
if ( isset ( $form [ 'submit' ])) {
$row [] = drupal_render ( $field [ 'category' ]);
$row [] = drupal_render ( $field [ 'weight' ]);
}
$row [] = drupal_render ( $field [ 'edit' ]);
$row [] = drupal_render ( $field [ 'delete' ]);
2009-08-22 14:34:23 +00:00
$rows [] = array ( 'data' => $row , 'class' => array ( 'draggable' ));
2007-11-30 09:02:51 +00:00
}
}
2007-12-08 14:06:23 +00:00
2007-11-30 09:02:51 +00:00
$header = array ( t ( 'Title' ), t ( 'Name' ), t ( 'Type' ));
if ( isset ( $form [ 'submit' ])) {
$header [] = t ( 'Category' );
$header [] = t ( 'Weight' );
}
$header [] = array ( 'data' => t ( 'Operations' ), 'colspan' => 2 );
2009-12-02 14:56:32 +00:00
$output = theme ( 'table' , array ( 'header' => $header , 'rows' => $rows , 'empty' => t ( 'No fields available.' ), 'attributes' => array ( 'id' => 'profile-fields' )));
2009-02-03 18:55:32 +00:00
$output .= drupal_render_children ( $form );
2007-12-08 14:06:23 +00:00
2007-11-13 12:28:36 +00:00
return $output ;
}
/**
* Menu callback : Generate a form to add / edit a user profile field .
*
* @ ingroup forms
2008-01-08 10:35:43 +00:00
* @ see profile_field_form_validate ()
* @ see profile_field_form_submit ()
2007-11-13 12:28:36 +00:00
*/
2009-09-18 00:12:48 +00:00
function profile_field_form ( $form , & $form_state , $arg = NULL ) {
2009-08-22 09:22:01 +00:00
if ( arg ( 4 ) == 'edit' ) {
2007-11-13 12:28:36 +00:00
if ( is_numeric ( $arg )) {
$fid = $arg ;
2009-05-26 10:41:06 +00:00
$edit = db_query ( 'SELECT * FROM {profile_field} WHERE fid = :fid' , array ( 'fid' => $fid )) -> fetchAssoc ();
2007-11-13 12:28:36 +00:00
if ( ! $edit ) {
drupal_not_found ();
return ;
}
2010-03-07 08:05:02 +00:00
drupal_set_title ( t ( 'Edit %title' , array ( '%title' => $edit [ 'title' ])), PASS_THROUGH );
2007-11-13 12:28:36 +00:00
$form [ 'fid' ] = array ( '#type' => 'value' ,
'#value' => $fid ,
);
$type = $edit [ 'type' ];
}
else {
drupal_not_found ();
return ;
}
}
else {
$types = _profile_field_types ();
if ( ! isset ( $types [ $arg ])) {
drupal_not_found ();
return ;
}
$type = $arg ;
2010-03-07 08:05:02 +00:00
drupal_set_title ( t ( 'Add new %type' , array ( '%type' => $types [ $type ])), PASS_THROUGH );
2007-11-13 12:28:36 +00:00
$edit = array ( 'name' => 'profile_' );
$form [ 'type' ] = array ( '#type' => 'value' , '#value' => $type );
}
$edit += array (
'category' => '' ,
'title' => '' ,
'explanation' => '' ,
'weight' => 0 ,
'page' => '' ,
'autocomplete' => '' ,
'required' => '' ,
'register' => '' ,
);
2010-03-07 08:05:02 +00:00
$form [ 'category' ] = array ( '#type' => 'textfield' ,
2007-11-13 12:28:36 +00:00
'#title' => t ( 'Category' ),
'#default_value' => $edit [ 'category' ],
2009-08-21 14:27:47 +00:00
'#autocomplete_path' => 'admin/config/people/profile/autocomplete' ,
2007-11-13 12:28:36 +00:00
'#description' => t ( 'The category the new field should be part of. Categories are used to group fields logically. An example category is "Personal information".' ),
'#required' => TRUE ,
);
2010-03-07 08:05:02 +00:00
$form [ 'title' ] = array ( '#type' => 'textfield' ,
2007-11-13 12:28:36 +00:00
'#title' => t ( 'Title' ),
'#default_value' => $edit [ 'title' ],
'#description' => t ( 'The title of the new field. The title will be shown to the user. An example title is "Favorite color".' ),
'#required' => TRUE ,
);
2010-03-07 08:05:02 +00:00
$form [ 'name' ] = array ( '#type' => 'textfield' ,
2007-11-13 12:28:36 +00:00
'#title' => t ( 'Form name' ),
'#default_value' => $edit [ 'name' ],
'#description' => t ( ' The name of the field . The form name is not shown to the user but used internally in the HTML code and URLs .
Unless you know what you are doing , it is highly recommended that you prefix the form name with < code > profile_ </ code > to avoid name clashes with other fields . Spaces or any other special characters except dash ( - ) and underscore ( _ ) are not allowed . An example name is " profile_favorite_color " or perhaps just " profile_color " . ' ),
'#required' => TRUE ,
);
2010-03-07 08:05:02 +00:00
$form [ 'explanation' ] = array ( '#type' => 'textarea' ,
2007-11-13 12:28:36 +00:00
'#title' => t ( 'Explanation' ),
'#default_value' => $edit [ 'explanation' ],
'#description' => t ( 'An optional explanation to go with the new field. The explanation will be shown to the user.' ),
);
if ( $type == 'selection' ) {
$form [ 'fields' ][ 'options' ] = array ( '#type' => 'textarea' ,
'#title' => t ( 'Selection options' ),
'#default_value' => isset ( $edit [ 'options' ]) ? $edit [ 'options' ] : '' ,
'#description' => t ( 'A list of all options. Put each option on a separate line. Example options are "red", "blue", "green", etc.' ),
);
}
2010-03-07 08:05:02 +00:00
$form [ 'visibility' ] = array ( '#type' => 'radios' ,
2007-11-13 12:28:36 +00:00
'#title' => t ( 'Visibility' ),
'#default_value' => isset ( $edit [ 'visibility' ]) ? $edit [ 'visibility' ] : PROFILE_PUBLIC ,
'#options' => array ( PROFILE_HIDDEN => t ( 'Hidden profile field, only accessible by administrators, modules and themes.' ), PROFILE_PRIVATE => t ( 'Private field, content only available to privileged users.' ), PROFILE_PUBLIC => t ( 'Public field, content shown on profile page but not used on member list pages.' ), PROFILE_PUBLIC_LISTINGS => t ( 'Public field, content shown on profile page and on member list pages.' )),
);
if ( $type == 'selection' || $type == 'list' || $type == 'textfield' ) {
$form [ 'fields' ][ 'page' ] = array ( '#type' => 'textfield' ,
'#title' => t ( 'Page title' ),
'#default_value' => $edit [ 'page' ],
2008-04-14 17:48:46 +00:00
'#description' => t ( 'To enable browsing this field by value, enter a title for the resulting page. The word <code>%value</code> will be substituted with the corresponding value. An example page title is "People whose favorite color is %value" . This is only applicable for a public field.' ),
2007-11-13 12:28:36 +00:00
);
}
2008-10-12 04:30:09 +00:00
elseif ( $type == 'checkbox' ) {
2007-11-13 12:28:36 +00:00
$form [ 'fields' ][ 'page' ] = array ( '#type' => 'textfield' ,
'#title' => t ( 'Page title' ),
'#default_value' => $edit [ 'page' ],
2008-04-14 17:48:46 +00:00
'#description' => t ( 'To enable browsing this field by value, enter a title for the resulting page. An example page title is "People who are employed" . This is only applicable for a public field.' ),
2007-11-13 12:28:36 +00:00
);
}
2010-03-07 08:05:02 +00:00
$form [ 'weight' ] = array ( '#type' => 'weight' ,
2007-11-30 09:02:51 +00:00
'#title' => t ( 'Weight' ),
'#default_value' => $edit [ 'weight' ],
'#description' => t ( 'The weights define the order in which the form fields are shown. Lighter fields "float up" towards the top of the category.' ),
);
2010-03-07 08:05:02 +00:00
$form [ 'autocomplete' ] = array ( '#type' => 'checkbox' ,
2007-11-13 12:28:36 +00:00
'#title' => t ( 'Form will auto-complete while user is typing.' ),
'#default_value' => $edit [ 'autocomplete' ],
2008-10-10 07:49:49 +00:00
'#description' => t ( 'For security, auto-complete will be disabled if the user does not have access to user profiles.' ),
2007-11-13 12:28:36 +00:00
);
2010-03-07 08:05:02 +00:00
$form [ 'required' ] = array ( '#type' => 'checkbox' ,
2007-11-13 12:28:36 +00:00
'#title' => t ( 'The user must enter a value.' ),
'#default_value' => $edit [ 'required' ],
);
2010-03-07 08:05:02 +00:00
$form [ 'register' ] = array ( '#type' => 'checkbox' ,
2007-11-13 12:28:36 +00:00
'#title' => t ( 'Visible in user registration form.' ),
'#default_value' => $edit [ 'register' ],
);
2010-01-03 21:01:04 +00:00
$form [ 'actions' ] = array ( '#type' => 'container' , '#attributes' => array ( 'class' => array ( 'form-actions' )));
$form [ 'actions' ][ 'submit' ] = array ( '#type' => 'submit' ,
2007-11-13 12:28:36 +00:00
'#value' => t ( 'Save field' ),
);
return $form ;
}
/**
* Validate profile_field_form submissions .
*/
function profile_field_form_validate ( $form , & $form_state ) {
// Validate the 'field name':
if ( preg_match ( '/[^a-zA-Z0-9_-]/' , $form_state [ 'values' ][ 'name' ])) {
form_set_error ( 'name' , t ( 'The specified form name contains one or more illegal characters. Spaces or any other special characters except dash (-) and underscore (_) are not allowed.' ));
}
2009-02-26 07:30:29 +00:00
$users_table = drupal_get_schema ( 'users' );
2008-02-18 16:53:37 +00:00
if ( ! empty ( $users_table [ 'fields' ][ $form_state [ 'values' ][ 'name' ]])) {
2007-11-13 12:28:36 +00:00
form_set_error ( 'name' , t ( 'The specified form name is reserved for use by Drupal.' ));
}
// Validate the category:
if ( ! $form_state [ 'values' ][ 'category' ]) {
form_set_error ( 'category' , t ( 'You must enter a category.' ));
}
2007-11-26 08:30:19 +00:00
if ( strtolower ( $form_state [ 'values' ][ 'category' ]) == 'account' ) {
2007-11-13 12:28:36 +00:00
form_set_error ( 'category' , t ( 'The specified category name is reserved for use by Drupal.' ));
}
2009-05-26 10:41:06 +00:00
$query = db_select ( 'profile_field' );
$query -> fields ( 'profile_field' , array ( 'fid' ));
2007-11-13 12:28:36 +00:00
if ( isset ( $form_state [ 'values' ][ 'fid' ])) {
2009-11-20 04:15:15 +00:00
$query -> condition ( 'fid' , $form_state [ 'values' ][ 'fid' ], '<>' );
2007-11-13 12:28:36 +00:00
}
2009-05-26 10:41:06 +00:00
$query_name = clone $query ;
$title = $query
-> condition ( 'title' , $form_state [ 'values' ][ 'title' ])
-> condition ( 'category' , $form_state [ 'values' ][ 'category' ])
-> execute ()
-> fetchField ();
if ( $title ) {
2007-11-13 12:28:36 +00:00
form_set_error ( 'title' , t ( 'The specified title is already in use.' ));
}
2009-05-26 10:41:06 +00:00
$name = $query_name
-> condition ( 'name' , $form_state [ 'values' ][ 'name' ])
-> execute ()
-> fetchField ();
if ( $name ) {
2007-11-13 12:28:36 +00:00
form_set_error ( 'name' , t ( 'The specified name is already in use.' ));
}
if ( $form_state [ 'values' ][ 'visibility' ] == PROFILE_HIDDEN ) {
if ( $form_state [ 'values' ][ 'required' ]) {
form_set_error ( 'required' , t ( 'A hidden field cannot be required.' ));
}
if ( $form_state [ 'values' ][ 'register' ]) {
form_set_error ( 'register' , t ( 'A hidden field cannot be set to visible on the user registration form.' ));
}
}
}
/**
* Process profile_field_form submissions .
*/
function profile_field_form_submit ( $form , & $form_state ) {
if ( ! isset ( $form_state [ 'values' ][ 'options' ])) {
$form_state [ 'values' ][ 'options' ] = '' ;
}
if ( ! isset ( $form_state [ 'values' ][ 'page' ])) {
$form_state [ 'values' ][ 'page' ] = '' ;
}
2009-11-20 04:15:15 +00:00
// Remove all elements that are not profile_field columns.
$values = array_intersect_key ( $form_state [ 'values' ], array_flip ( array ( 'type' , 'category' , 'title' , 'name' , 'explanation' , 'visibility' , 'page' , 'weight' , 'autocomplete' , 'required' , 'register' , 'options' )));
2007-11-13 12:28:36 +00:00
if ( ! isset ( $form_state [ 'values' ][ 'fid' ])) {
2009-05-26 10:41:06 +00:00
db_insert ( 'profile_field' )
-> fields ( $values )
-> execute ();
2007-11-13 12:28:36 +00:00
drupal_set_message ( t ( 'The field has been created.' ));
2009-08-21 14:27:47 +00:00
watchdog ( 'profile' , 'Profile field %field added under category %category.' , array ( '%field' => $form_state [ 'values' ][ 'title' ], '%category' => $form_state [ 'values' ][ 'category' ]), WATCHDOG_NOTICE , l ( t ( 'view' ), 'admin/config/people/profile' ));
2007-11-13 12:28:36 +00:00
}
else {
2009-05-26 10:41:06 +00:00
db_update ( 'profile_field' )
2009-11-20 04:15:15 +00:00
-> fields ( $values )
2009-05-26 10:41:06 +00:00
-> condition ( 'fid' , $form_state [ 'values' ][ 'fid' ])
2009-11-20 04:15:15 +00:00
-> execute ();
2007-11-13 12:28:36 +00:00
drupal_set_message ( t ( 'The field has been updated.' ));
}
cache_clear_all ();
menu_rebuild ();
2009-08-21 14:27:47 +00:00
$form_state [ 'redirect' ] = 'admin/config/people/profile' ;
2007-11-13 12:28:36 +00:00
return ;
}
/**
* Menu callback ; deletes a field from all user profiles .
*/
2009-09-18 00:12:48 +00:00
function profile_field_delete ( $form , & $form_state , $fid ) {
2009-05-26 10:41:06 +00:00
$field = db_query ( " SELECT title FROM { profile_field} WHERE fid = :fid " , array ( ':fid' => $fid )) -> fetchObject ();
2007-11-13 12:28:36 +00:00
if ( ! $field ) {
drupal_not_found ();
return ;
}
$form [ 'fid' ] = array ( '#type' => 'value' , '#value' => $fid );
$form [ 'title' ] = array ( '#type' => 'value' , '#value' => $field -> title );
return confirm_form ( $form ,
2009-08-21 14:27:47 +00:00
t ( 'Are you sure you want to delete the field %field?' , array ( '%field' => $field -> title )), 'admin/config/people/profile' ,
t ( 'This action cannot be undone. If users have entered values into this field in their profile, these entries will also be deleted. If you want to keep the user-entered data, instead of deleting the field you may wish to <a href="@edit-field">edit this field</a> and change it to a hidden profile field so that it may only be accessed by administrators.' , array ( '@edit-field' => url ( 'admin/config/people/profile/edit/' . $fid ))),
2007-11-13 12:28:36 +00:00
t ( 'Delete' ), t ( 'Cancel' ));
}
/**
* Process a field delete form submission .
*/
function profile_field_delete_submit ( $form , & $form_state ) {
2009-05-26 10:41:06 +00:00
db_delete ( 'profile_field' )
-> condition ( 'fid' , $form_state [ 'values' ][ 'fid' ])
-> execute ();
db_delete ( 'profile_value' )
-> condition ( 'fid' , $form_state [ 'values' ][ 'fid' ])
-> execute ();
2007-11-13 12:28:36 +00:00
cache_clear_all ();
drupal_set_message ( t ( 'The field %field has been deleted.' , array ( '%field' => $form_state [ 'values' ][ 'title' ])));
2009-08-21 14:27:47 +00:00
watchdog ( 'profile' , 'Profile field %field deleted.' , array ( '%field' => $form_state [ 'values' ][ 'title' ]), WATCHDOG_NOTICE , l ( t ( 'view' ), 'admin/config/people/profile' ));
2007-11-13 12:28:36 +00:00
2009-08-21 14:27:47 +00:00
$form_state [ 'redirect' ] = 'admin/config/people/profile' ;
2007-11-13 12:28:36 +00:00
return ;
}
/**
* Retrieve a pipe delimited string of autocomplete suggestions for profile categories
*/
function profile_admin_settings_autocomplete ( $string ) {
$matches = array ();
2010-01-13 06:44:31 +00:00
$result = db_select ( 'profile_field' )
-> fields ( 'profile_field' , array ( 'category' ))
-> condition ( 'category' , db_like ( $string ) . '%' , 'LIKE' )
-> range ( 0 , 10 )
-> execute ();
2009-05-26 10:41:06 +00:00
foreach ( $result as $data ) {
2007-11-13 12:28:36 +00:00
$matches [ $data -> category ] = check_plain ( $data -> category );
}
2009-09-21 07:56:09 +00:00
drupal_json_output ( $matches );
2007-11-13 12:28:36 +00:00
}