From 398541fb08b2e6da2c0cb7070ca96e8b2654fbb5 Mon Sep 17 00:00:00 2001 From: Martin Blumenthal Date: Thu, 4 Jun 2009 12:25:48 +0200 Subject: [PATCH] Fixed 2 errors when creating a new class: create the share bevore adding students and allow the semesterdate to be modified when automatically set by global config. --- skoli/lib/Forms/CreateClass.php | 6 ++++-- skoli/lib/School.php | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/skoli/lib/Forms/CreateClass.php b/skoli/lib/Forms/CreateClass.php index 049aecd9c..b5ea2bb37 100644 --- a/skoli/lib/Forms/CreateClass.php +++ b/skoli/lib/Forms/CreateClass.php @@ -196,8 +196,10 @@ class Skoli_CreateClassForm extends Horde_Form { $class->set($property, $this->_vars->get($property) == '' ? null : $this->_vars->get($property)); } + $result = $GLOBALS['skoli_shares']->addShare($class); + // Save students - if ($this->_vars->exists('students')) { + if ($this->_vars->exists('students') && $result) { $driver = &Skoli_Driver::singleton($this->shareid); $result = $driver->addStudents($this->_vars->get('students')); if (is_a($result, 'PEAR_Error')) { @@ -230,7 +232,7 @@ class Skoli_CreateClassForm extends Horde_Form { } } - return $GLOBALS['skoli_shares']->addShare($class); + return $result; } } diff --git a/skoli/lib/School.php b/skoli/lib/School.php index 52f1ebc24..0f82ea9e7 100644 --- a/skoli/lib/School.php +++ b/skoli/lib/School.php @@ -55,7 +55,7 @@ class Skoli_School { switch ($property) { case 'start': case 'end': - $form->addVariable(_(ucfirst($property)), $property, 'monthdayyear', true, false, null, array()); + $form->addVariable(_(ucfirst($property)), $property, 'monthdayyear', true, false, null, array(date('Y') - 10)); if ($form->_vars->exists('semester') && isset($this->school['semester']) && is_array($this->school['semester'])) { foreach ($this->school['semester'] as $semester) { if ($semester['name'] == $form->_vars->get('semester')) { @@ -63,7 +63,7 @@ class Skoli_School { break; } } - if (isset($activesemester[$property])) { + if (isset($activesemester[$property]) && !is_array($form->_vars->get($property))) { require_once 'Horde/Date.php'; if ($property == 'start') { $startdate = 0; -- 2.11.0