Fixed 2 errors when creating a new class: create the share bevore adding students...
authorMartin Blumenthal <tinu@humbapa.ch>
Thu, 4 Jun 2009 10:25:48 +0000 (12:25 +0200)
committerMartin Blumenthal <tinu@humbapa.ch>
Thu, 4 Jun 2009 10:25:48 +0000 (12:25 +0200)
skoli/lib/Forms/CreateClass.php
skoli/lib/School.php

index 049aecd..b5ea2bb 100644 (file)
@@ -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;
     }
 
 }
index 52f1ebc..0f82ea9 100644 (file)
@@ -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;