From 3a55b1bc7a6829d28d23c5f9e230877fa154c165 Mon Sep 17 00:00:00 2001 From: Cristian Fasanando Date: Thu, 29 Jan 2009 18:21:11 +0100 Subject: [PATCH] [svn r18078] Logic changes - Assigned date by default for date and date time fields when you add those ones into manager user field and added the possibility to select the year from 1900 - see FS#3452 --- main/admin/user_add.php | 7 ++++++- main/admin/user_edit.php | 7 ++++++- main/auth/inscription.php | 7 ++++++- main/auth/profile.php | 9 +++++++-- main/inc/lib/formvalidator/Element/datepicker.php | 9 ++++++++- main/inc/lib/formvalidator/Element/tbl_change.js.php | 4 ++-- main/mySpace/user_add.php | 5 +++++ main/survey/fillsurvey.php | 7 ++++++- 8 files changed, 46 insertions(+), 9 deletions(-) diff --git a/main/admin/user_add.php b/main/admin/user_add.php index ca2da875a6..816a3d77a6 100644 --- a/main/admin/user_add.php +++ b/main/admin/user_add.php @@ -1,4 +1,4 @@ - $field_details) case USER_FIELD_TYPE_DATE: $form->addElement('datepickerdate', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'user_add')); $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); $form->applyFilter('theme', 'trim'); break; case USER_FIELD_TYPE_DATETIME: $form->addElement('datepicker', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'user_add')); + $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); $form->applyFilter('theme', 'trim'); break; case USER_FIELD_TYPE_DOUBLE_SELECT: diff --git a/main/admin/user_edit.php b/main/admin/user_edit.php index ce28aad242..bc5585af33 100644 --- a/main/admin/user_edit.php +++ b/main/admin/user_edit.php @@ -1,4 +1,4 @@ - $field_details) case USER_FIELD_TYPE_DATE: $form->addElement('datepickerdate', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'user_add')); $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); $form->applyFilter('theme', 'trim'); break; case USER_FIELD_TYPE_DATETIME: $form->addElement('datepicker', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'user_add')); + $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); $form->applyFilter('theme', 'trim'); break; } diff --git a/main/auth/inscription.php b/main/auth/inscription.php index 4193a8638c..b86d88680e 100644 --- a/main/auth/inscription.php +++ b/main/auth/inscription.php @@ -1,5 +1,5 @@ $field_details) { case USER_FIELD_TYPE_DATE: $form->addElement('datepickerdate', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'registration')); $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]); $form->applyFilter('theme', 'trim'); break; case USER_FIELD_TYPE_DATETIME: $form->addElement('datepicker', 'extra_'.$field_details[1], $field_details[3],array('form_name'=>'registration')); + $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]); $form->applyFilter('theme', 'trim'); break; diff --git a/main/auth/profile.php b/main/auth/profile.php index b0bbdeaa87..6d6007d2b2 100644 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -1,4 +1,4 @@ - $field_details) break; case USER_FIELD_TYPE_DATE: $form->addElement('datepickerdate', 'extra_'.$field_details[1],$field_details[3], array('form_name'=>'profile')); - $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); + $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]); $form->applyFilter('theme', 'trim'); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); break; case USER_FIELD_TYPE_DATETIME: $form->addElement('datepicker', 'extra_'.$field_details[1],$field_details[3], array('form_name'=>'profile')); + $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); if ($field_details[7] == 0) $form->freeze('extra_'.$field_details[1]); $form->applyFilter('theme', 'trim'); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); break; case USER_FIELD_TYPE_DOUBLE_SELECT: foreach ($field_details[8] as $key=>$element) diff --git a/main/inc/lib/formvalidator/Element/datepicker.php b/main/inc/lib/formvalidator/Element/datepicker.php index 3425b864a6..a2a6d280ba 100644 --- a/main/inc/lib/formvalidator/Element/datepicker.php +++ b/main/inc/lib/formvalidator/Element/datepicker.php @@ -1,5 +1,5 @@ getName()]= $datetime; return $result; } + /** + * Sets an option to a value + */ + function setLocalOption($name,$value) + { + $this->_options[$name] = $value; + } } ?> \ No newline at end of file diff --git a/main/inc/lib/formvalidator/Element/tbl_change.js.php b/main/inc/lib/formvalidator/Element/tbl_change.js.php index 87d1fcea3a..f2307cf1c8 100644 --- a/main/inc/lib/formvalidator/Element/tbl_change.js.php +++ b/main/inc/lib/formvalidator/Element/tbl_change.js.php @@ -1,5 +1,5 @@ var day; @@ -177,7 +177,7 @@ function returnDate(d,m,y) { datevalues[0].selectedIndex = (d-1) ; datevalues[1].selectedIndex = m; date = new Date(); - year = date.getFullYear()-1; + year = 1900; datevalues[2].selectedIndex = (y-year); for(i = 0; i<= 3; i++) diff --git a/main/mySpace/user_add.php b/main/mySpace/user_add.php index 6d9d1113cf..e1056500e2 100644 --- a/main/mySpace/user_add.php +++ b/main/mySpace/user_add.php @@ -222,10 +222,15 @@ foreach($extra as $id => $field_details) case USER_FIELD_TYPE_DATE: $form->addElement('datepickerdate', 'extra_'.$field_details[1], $field_details[3]); $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); $form->applyFilter('theme', 'trim'); break; case USER_FIELD_TYPE_DATETIME: $form->addElement('datepicker', 'extra_'.$field_details[1], $field_details[3]); + $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); $form->applyFilter('theme', 'trim'); break; } diff --git a/main/survey/fillsurvey.php b/main/survey/fillsurvey.php index f21aaa57e1..1bc33a6db0 100644 --- a/main/survey/fillsurvey.php +++ b/main/survey/fillsurvey.php @@ -461,13 +461,18 @@ if ($survey_data['form_fields']!='' && $survey_data['anonymous'] == 0 && is_arra break; case USER_FIELD_TYPE_DATE : $form->addElement('datepickerdate', 'extra_' . $field_details[1], $field_details[3],array('form_name'=>'profile')); - $form->_elements[$form->_elementIndex['extra_' . $field_details[1]]]->setLocalOption('minYear', 1900); + $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); if ($field_details[7] == 0) $form->freeze('extra_' . $field_details[1]); $form->applyFilter('theme', 'trim'); break; case USER_FIELD_TYPE_DATETIME : $form->addElement('datepicker', 'extra_' . $field_details[1], $field_details[3],array('form_name'=>'profile')); + $form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear',1900); + $defaults['extra_'.$field_details[1]] = date('Y-m-d 12:00:00'); + $form -> setDefaults($defaults); if ($field_details[7] == 0) $form->freeze('extra_' . $field_details[1]); $form->applyFilter('theme', 'trim');