0010554: create default department (school) on Courses installation
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 8 Dec 2014 10:54:20 +0000 (11:54 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 9 Dec 2014 12:11:33 +0000 (13:11 +0100)
https://forge.tine20.org/view.php?id=10554

Change-Id: Ie2dce15ec889f2738b02b623a1571a2e29abb1e6
Reviewed-on: http://gerrit.tine20.com/customers/1423
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Courses/Setup/Initialize.php

index 92a1283..94f6604 100644 (file)
@@ -5,7 +5,7 @@
  * @package     Courses
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
  * @author      Jonas Fischer <j.fischer@metaways.de>
- * @copyright   Copyright (c) 2008-2012 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2008-2014 Metaways Infosystems GmbH (http://www.metaways.de)
  *
  */
 
@@ -75,4 +75,23 @@ class Courses_Setup_Initialize extends Setup_Initialize
             'value'             => json_encode($keyfieldConfig),
         )));
     }
+    
+    /**
+     * init department
+     * 
+     * @see 0010554: create default department (school) on Courses installation
+     */
+    public static function _initializeDepartment()
+    {
+        // create a default department if none exists
+        $departments = Tinebase_Department::getInstance()->getAll();
+        if (count($departments) === 0) {
+            $translation = Tinebase_Translation::getTranslation('Courses');
+            $school = new Tinebase_Model_Department(array(
+                'name' => $translation->_('School'),
+                'description' => $translation->_('Defaul school for Courses application'),
+            ));
+            Tinebase_Department::getInstance()->create($school);
+        }
+    }
 }