Skip to content

Commit b73e668

Browse files
xendkkasperg
authored andcommitted
Implemented setting of default interest period.
1 parent e2629f2 commit b73e668

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

ding_provider/ding_provider_example/ding_provider_example.module

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function ding_provider_example_ding_reservation_list_form_update($form, $form_st
127127
*/
128128
function ding_provider_example_form_ding_cart_list_form_alter(&$form, &$form_state) {
129129

130-
$interest_period = (isset($account->interest_period) && $account->interest_period > 10) ? $account->interest_period : DING_LIBRARY_USER_DEFAULT_INTEREST_PERIOD;
130+
$interest_period = (isset($account->interest_period) && $account->interest_period > 10) ? $account->interest_period : ding_reservation_default_interest_period();
131131

132132
$form['options']['expiry'] = array(
133133
'#type' => 'date_popup',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/**
4+
* Reservation settings form.
5+
*/
6+
function ding_reservation_admin_settings_form(&$form_state) {
7+
$form = array();
8+
9+
$form['ding_reservation_default_interest_period'] = array(
10+
'#type' => 'select',
11+
'#title' => t('Default interest period'),
12+
'#description' => t("Reservation interest period, when the user haven't set one."),
13+
'#options' => array(
14+
7 => t('One week'),
15+
14 => t('Two weeks'),
16+
30 => t('One month'),
17+
91 => t('Three months'),
18+
183 => t('Six months'),
19+
365 => t('One year'),
20+
),
21+
'#default_value' => variable_get('ding_reservation_default_interest_period', DING_RESERVATION_DEFAULT_INTEREST_PERIOD),
22+
);
23+
24+
return system_settings_form($form);
25+
}

ding_reservation/ding_reservation.module

+16
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ function ding_reservation_menu() {
3030
'type' => MENU_CALLBACK,
3131
);
3232

33+
$items['admin/settings/ding/ding_reservation'] = array(
34+
'title' => 'Reservation settings',
35+
'page callback' => 'drupal_get_form',
36+
'page arguments' => array('ding_reservation_admin_settings_form'),
37+
'access arguments' => array('administer site configuration'),
38+
'type' => MENU_NORMAL_ITEM,
39+
'file' => 'ding_reservation.admin.inc',
40+
);
41+
3342
return $items;
3443
}
3544

@@ -308,3 +317,10 @@ function ding_reservation_ting_object_is($object, $class) {
308317
return TRUE;
309318
}
310319
}
320+
321+
/**
322+
* Returns the site default interest period in days.
323+
*/
324+
function ding_reservation_default_interest_period() {
325+
return variable_get('ding_reservation_default_interest_period', DING_RESERVATION_DEFAULT_INTEREST_PERIOD);
326+
}

0 commit comments

Comments
 (0)