Replace configuration textfield with select - refs BT#9438

1.10.x
Imanol Losada 11 years ago
parent 9c1e76cde9
commit e3839a7a33
  1. 14
      plugin/resubscription/src/HookResubscription.php
  2. 8
      plugin/resubscription/src/Resubscription.php

@ -28,8 +28,17 @@ class HookResubscription extends HookObserver implements HookResubscribeObserver
{
$data = $hook->getEventData();
if ($data['type'] === HOOK_EVENT_TYPE_PRE) {
$resubscriptionLimit = Resubscription::create()->get('resubscription_limit');
$limitDate = gmdate('Y-m-d', strtotime(gmdate('Y-m-d')." -$resubscriptionLimit year"));
$limitDate = gmdate('Y-m-d');
switch ($resubscriptionLimit) {
case 'calendar_year':
$resubscriptionLimit = "1 year";
$limitDate = gmdate('Y-m-d', strtotime(gmdate('Y-m-d')." -$resubscriptionLimit"));
break;
}
$join = " INNER JOIN ".Database::get_main_table(TABLE_MAIN_SESSION)."ON id = id_session";
@ -85,7 +94,7 @@ class HookResubscription extends HookObserver implements HookResubscribeObserver
foreach ($currentSessionCourseResult as $currentSessionCourse) {
if (isset($userSessionCourses[$currentSessionCourse['course_code']])) {
$endDate = $userSessionCourses[$currentSessionCourse['course_code']];
$resubscriptionDate = gmdate('Y-m-d', strtotime($endDate." +$resubscriptionLimit year"));
$resubscriptionDate = gmdate('Y-m-d', strtotime($endDate." +$resubscriptionLimit"));
$icon = Display::return_icon('students.gif', get_lang('Student'));
$canResubscribeFrom = sprintf(get_plugin_lang('CanResubscribeFromX', 'resubscription'), $resubscriptionDate);
throw new Exception(Display::label($icon . ' ' . $canResubscribeFrom, "info"));
@ -93,5 +102,4 @@ class HookResubscription extends HookObserver implements HookResubscribeObserver
}
}
}
}

@ -15,8 +15,14 @@ class Resubscription extends Plugin implements HookPluginInterface
*/
protected function __construct()
{
$options = array(
'calendar_year' => get_lang('CalendarYear')
);
$parameters = array(
'resubscription_limit' => 'text'
'resubscription_limit' => array(
'type' => 'select',
'options' => $options
)
);
parent::__construct('0.1', 'Imanol Losada Oriol', $parameters);

Loading…
Cancel
Save