diff --git a/migrations/01_initial.php b/migrations/01_initial.php index 95fa09fa11ea44decc38a104a8107dace3f3314d..09c845cc107653e3e1dae0dea3720a91e51341dd 100644 --- a/migrations/01_initial.php +++ b/migrations/01_initial.php @@ -16,15 +16,15 @@ class Initial extends Migration { - + private static $cronjob = array( 'filename' => 'public/plugins_packages/data-quest/TandemPlugin/TandemPluginCronjob.class.php', 'class' => 'TandemPluginCronjob', 'priority' => 'normal', 'execution_interval' => ['3', '0'] //at 3:00 every day ); - - + + public function __construct() { $this->cronjob_md5 = md5( @@ -33,18 +33,18 @@ class Initial extends Migration self::$cronjob['priority'] . self::$cronjob['execution_interval'] ); - + parent::__construct(); } - - + + public function up() { $db = DBManager::get(); - - + + //Create tables: - + $db->exec( "CREATE TABLE IF NOT EXISTS tandem_languages ( id VARCHAR(3) PRIMARY KEY NOT NULL, @@ -55,7 +55,7 @@ class Initial extends Migration chdate BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' );" ); - + $db->exec( "CREATE TABLE IF NOT EXISTS tandem_user_mother_languages ( id VARCHAR(32) PRIMARY KEY NOT NULL, @@ -69,7 +69,7 @@ class Initial extends Migration INDEX(language_id) );" ); - + $db->exec( "CREATE TABLE IF NOT EXISTS tandem_profiles ( id VARCHAR(32) PRIMARY KEY NOT NULL, @@ -88,7 +88,7 @@ class Initial extends Migration INDEX(proof_of_attendance) );" ); - + $db->exec( "CREATE TABLE IF NOT EXISTS tandem_pairs ( id VARCHAR(32) PRIMARY KEY NOT NULL, @@ -101,10 +101,10 @@ class Initial extends Migration chdate BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' );" ); - - + + //Create configuration fields, if they don't exist yet: - + $gender_search_enabled = ConfigEntry::findByField('TANDEMPLUGIN_GENDER_SEARCH_ENABLED'); if(!$gender_search_enabled) { $gender_search_enabled = new ConfigEntry(); @@ -114,7 +114,7 @@ class Initial extends Migration $gender_search_enabled->section = 'tandemplugin'; $gender_search_enabled->store(); } - + $delete_old_period = ConfigEntry::findByField('TANDEMPLUGIN_DELETE_OLD_PERIOD'); if(!$delete_old_period) { $delete_old_period = new ConfigEntry(); @@ -124,25 +124,25 @@ class Initial extends Migration $delete_old_period->section = 'tandemplugin'; $delete_old_period->store(); } - - - + + + //Add cronjob: - + if($this->cronjob_md5) { $db = DBManager::get(); - + $db->exec( "INSERT INTO `cronjobs_tasks` - (`task_id`, `filename`, `class`, `active`) + (`task_id`, `filename`, `class`, `active`) VALUES ('".$this->cronjob_md5."', '" .self::$cronjob['filename']."', '" .self::$cronjob['class']."', '1')" ); - + $schedule_id = md5(uniqid($this->cronjob_md5, true)); - + $db->exec( "INSERT INTO `cronjobs_schedules` (`schedule_id`, `task_id`, `active`, `parameters`, `priority`, @@ -154,60 +154,60 @@ class Initial extends Migration ."', '" . self::$cronjob['execution_interval'][1] ."', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), NULL)" ); - + $db = null; } - - + + //close DB connection: $db = null; - + } - - + + public function down() { $db = DBManager::get(); - + //Drop tables: $db->exec('DROP TABLE IF EXISTS tandem_languages;'); $db->exec('DROP TABLE IF EXISTS tandem_user_mother_languages;'); $db->exec('DROP TABLE IF EXISTS tandem_profiles;'); $db->exec('DROP TABLE IF EXISTS tandem_pairs;'); - + //Delete configuration fields: - + $gender_search_enabled = ConfigEntry::findByField('TANDEMPLUGIN_GENDER_SEARCH_ENABLED'); if($gender_search_enabled) { foreach($gender_search_enabled as $gse) { $gse->delete(); } } - + $delete_old_period = ConfigEntry::findByField('TANDEMPLUGIN_DELETE_OLD_PERIOD'); if($delete_old_period) { foreach($delete_old_period as $dop) { $dop->delete(); } } - + //Delete cronjob: - + if($this->cronjob_md5) { $db = DBManager::get(); - + $db->exec( "DELETE FROM `cronjobs_tasks` WHERE task_id = '".$this->cronjob_md5."'" ); - + $db->exec( "DELETE FROM `cronjobs_schedules` WHERE task_id = '".$this->cronjob_md5."'" ); - + $db = null; } - - + + //close DB connection: $db = null; } diff --git a/migrations/02_add_data.php b/migrations/02_add_data.php index ef8aff0e4662a30528a726847ff34a75f7cd61eb..367b99dcd078f05fbfc16dcc3181ffd760685953 100644 --- a/migrations/02_add_data.php +++ b/migrations/02_add_data.php @@ -16,7 +16,7 @@ class AddData extends Migration { - + private $languages = [ ["ara", "Arabic", "Arabisch"], ["chi", "Chinese", "Chinesisch"], @@ -39,19 +39,19 @@ class AddData extends Migration ["spa", "Spanish", "Spanisch"], ["tur", "Turkish", "Türkisch"] ]; - - - - + + + + public function up() { $db = DBManager::get(); - + //insert languages: $sql = "INSERT INTO tandem_languages (id, name, name_eng, name_ger, mkdate, chdate) VALUES "; - + $values = []; foreach($this->languages as $language) { $values[] = '(' @@ -61,25 +61,25 @@ class AddData extends Migration . $db->quote($language[2]) . ',' . 'UNIX_TIMESTAMP(), UNIX_TIMESTAMP())'; } - + $sql .= implode(',', $values); - + $sql .= ';'; - + $db->exec($sql); - + //close DB connection: $db = null; - + } - - + + public function down() { $db = DBManager::get(); - + $db->exec('DELETE FROM tandem_languages;'); - + //close DB connection: $db = null; } diff --git a/migrations/04_add_terminated_tandem_pairs.php b/migrations/04_add_terminated_tandem_pairs.php index 7031864a98df88d3f2058a52d07c44a8fbd33770..8646fd863fd6d9ed9a4ec20c40e3cfc44d47a547 100644 --- a/migrations/04_add_terminated_tandem_pairs.php +++ b/migrations/04_add_terminated_tandem_pairs.php @@ -16,14 +16,14 @@ class AddTerminatedTandemPairs extends Migration { - + public function up() { $db = DBManager::get(); - - + + //Create table: - + $db->exec( "CREATE TABLE IF NOT EXISTS terminated_tandem_pairs ( id VARCHAR(32) PRIMARY KEY NOT NULL, @@ -41,20 +41,20 @@ class AddTerminatedTandemPairs extends Migration chdate BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' );" ); - + //close DB connection: $db = null; - + } - - + + public function down() { $db = DBManager::get(); - + //Drop table: $db->exec('DROP TABLE IF EXISTS terminated_tandem_pairs;'); - + //close DB connection: $db = null; } diff --git a/plugin.manifest b/plugin.manifest index 73d8fa19216c2350e7268bcb725885e4edf03dbe..5683bf59c77d8bf24877386943dd2e70153ef191 100644 --- a/plugin.manifest +++ b/plugin.manifest @@ -1,6 +1,7 @@ pluginname=TandemPlugin pluginclassname=TandemPlugin origin=data-quest -version=0.9.1 +version=1.0.0 description=Dieses Plugin ermöglicht es, Sprachtandems innerhalb der Stud.IP Platform zu bilden. -studipMinVersion=4.0 +studipMinVersion=4.1.99 +studipMaxVersion=4.99.99