Revision 36818236
Added by Andreas Kohlbecker almost 7 years ago
modules/cdm_dataportal/cdm_dataportal.module | ||
---|---|---|
641 | 641 |
* The function generate form for own user cdm dataportal configurations. |
642 | 642 |
*/ |
643 | 643 |
function cdm_dataportal_user_form($form, &$form_state) { |
644 |
|
|
644 | 645 |
global $user; |
645 | 646 |
$checkbox_value = 'cdm_dataportal_' . $user->uid . '_default_tab_active'; |
646 | 647 |
|
647 | 648 |
$form['taxon_page_tabs'] = array( |
648 | 649 |
'#type' => 'fieldset', |
650 |
'#tree' => true, |
|
649 | 651 |
'#title' => t('Taxon page tabs'), |
650 | 652 |
); |
651 |
$form['taxon_page_tabs']['check'] = array( |
|
653 |
|
|
654 |
$form['taxon_page_tabs']['user_defined'] = array( |
|
652 | 655 |
'#type' => 'checkbox', |
653 | 656 |
'#title' => t('Activate user default configuration'), |
654 | 657 |
'#default_value' => variable_get($checkbox_value, 0), |
655 | 658 |
'#description' => t('Check this if you want configure your own default tab from the below menu.'), |
656 | 659 |
); |
657 | 660 |
|
658 |
$form['taxon_page_tabs']['cdm_dataportal_user_form'] = array(
|
|
661 |
$form['taxon_page_tabs']['default_tab'] = array(
|
|
659 | 662 |
'#type' => 'select', |
660 | 663 |
'#title' => t('Default tab to display'), |
661 | 664 |
'#default_value' => get_default_taxon_tab(TRUE), |
662 | 665 |
'#options' => unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB), |
663 | 666 |
'#description' => t('<p>Select the default tab to display when visiting a taxon page. Only available if Tabbed Taxon Page is enable.</p> |
664 | 667 |
<strong>Note:</strong> After performing a search and clicking in any synonym, the taxon tab |
665 |
to be renderized will be the synonymy of the accepted taxon and not the above selected tab.'), |
|
668 |
to be rendered will be the synonymy of the accepted taxon and not the above selected tab.'), |
|
669 |
); |
|
670 |
|
|
671 |
$form['developer_options'] = array( |
|
672 |
'#type' => 'fieldset', |
|
673 |
'#tree' => true, |
|
674 |
'#title' => t('Developer options'), |
|
675 |
); |
|
676 |
|
|
677 |
$form['developer_options']['show_render_path'] = array( |
|
678 |
'#type' => 'checkbox', |
|
679 |
'#title' => t('Display the render path for each taxon name.'), |
|
680 |
'#default_value' => variable_get($checkbox_value, 0), |
|
681 |
'#description' => t('This option is very helpful if you are editing the !link for taxon names.', |
|
682 |
array( |
|
683 |
'!link' => l( |
|
684 |
'render template', 'admin/config/cdm_dataportal/settings/layout', array('fragment' => 'edit-cdm-name-render-templates')) |
|
685 |
) |
|
686 |
), |
|
666 | 687 |
); |
667 | 688 |
|
668 | 689 |
$form['submit'] = array( |
... | ... | |
684 | 705 |
$username = $user->name; |
685 | 706 |
$variable_to_use = 'cdm_dataportal_' . $user->uid . '_default_tab'; |
686 | 707 |
|
687 |
// If is the right user the variables are setted. |
|
688 |
if (arg(0) == 'user' && ($uid = arg(1)) && is_numeric($uid) && $user->uid == $uid) { |
|
708 |
// FIXME: this is completely wrong, see user_profile_form_submit() |
|
709 |
|
|
710 |
// it is only possible to change own user settings |
|
711 |
if (arg(0) == 'user' && is_numeric(arg(1)) && $user->uid == arg(1)) { |
|
712 |
|
|
713 |
// DEFAULT_TAXON_TAB |
|
689 | 714 |
$variable = unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB); |
690 |
variable_set($variable_to_use . '_active', $form_state['values']['check']);
|
|
691 |
variable_set($variable_to_use, $form_state['values']['cdm_dataportal_user_form']);
|
|
692 |
if ($form_state['values']['check']) {
|
|
715 |
variable_set($variable_to_use . '_active', $form_state['values']['taxon_page_tabs']['user_defined']);
|
|
716 |
variable_set($variable_to_use, $form_state['values']['taxon_page_tabs']['default_tab']);
|
|
717 |
if ($form_state['values']['taxon_page_tabs']['user_defined']) {
|
|
693 | 718 |
drupal_set_message(check_plain(t('The user default tab will be used for the next taxon site visit.'))); |
694 | 719 |
drupal_set_message(check_plain(t('The user default tab has been changed to: !tab for the user !user', array( |
695 | 720 |
'!tab' => $variable[variable_get($variable_to_use, 0)], |
... | ... | |
700 | 725 |
drupal_set_message(check_plain(t('The user default tab wont be used for |
701 | 726 |
the next taxon site, check the box if you want to use the user default configuration.'))); |
702 | 727 |
} |
703 |
// Problem with the user id => variables wont be saved. |
|
728 |
|
|
704 | 729 |
} |
705 | 730 |
else { |
731 |
// Problem with the user id => variables wont be saved. |
|
706 | 732 |
$msg_type = 'warning'; |
707 | 733 |
drupal_set_message(check_plain(t('Default tab has not been saved due to user id problems')), $msg_type); |
708 | 734 |
} |
Also available in: Unified diff
working on user profile settings and finding big BUG