@@ -957,7 +957,49 @@ function xmldb_block_opencast_upgrade($oldversion) {
957957 upgrade_block_savepoint (true , 2024111103 , 'opencast ' );
958958 }
959959
960- if ($ oldversion < 2025042200 ) {
960+ if ($ oldversion < 2025072900 ) {
961+ // Transcription settings changes.
962+ $ pluginname = 'tool_opencast ' ;
963+ // We change the config name from transcriptionflavors to transcriptionlanguages but the functionalitiy remains the same.
964+ $ params = ['plugin ' => $ pluginname , 'configname ' => 'transcriptionflavors% ' ];
965+ $ whereclause = $ DB ->sql_equal ('plugin ' , ':plugin ' ) . ' AND ' . $ DB ->sql_like ('name ' , ':configname ' );
966+ if ($ entries = $ DB ->get_records_select ('config_plugins ' , $ whereclause , $ params , '' , 'name, value ' )) {
967+ foreach ($ entries as $ entry ) {
968+ $ newconfigname = str_replace ('transcriptionflavors ' , 'transcriptionlanguages ' , $ entry ->name );
969+ set_config ($ newconfigname , $ entry ->value , $ pluginname );
970+ unset_config ($ entry ->name , $ pluginname );
971+ }
972+ }
973+
974+ // We remove the maxtranscriptionupload precisely, regardless of the ocinstance.
975+ $ params = ['plugin ' => $ pluginname , 'configname ' => 'maxtranscriptionupload% ' ];
976+ $ whereclause = $ DB ->sql_equal ('plugin ' , ':plugin ' ) . ' AND ' . $ DB ->sql_like ('name ' , ':configname ' );
977+ if ($ entries = $ DB ->get_records_select ('config_plugins ' , $ whereclause , $ params , '' , 'name ' )) {
978+ foreach ($ entries as $ entry ) {
979+ unset_config ($ entry ->name , $ pluginname );
980+ }
981+ }
982+
983+ // We then adjust the activation of newly added settings according to the previous settings relation.
984+ // Initially transcriptionworkflow worked as a feature activation toggle, meaning if it was empty,
985+ // the whole transcription feature was disabled. But now we divide this into two separate stand-alone settings.
986+ $ params = ['plugin ' => $ pluginname , 'configname ' => 'transcriptionworkflow% ' ];
987+ $ whereclause = $ DB ->sql_equal ('plugin ' , ':plugin ' ) . ' AND ' . $ DB ->sql_like ('name ' , ':configname ' );
988+ if ($ entries = $ DB ->get_records_select ('config_plugins ' , $ whereclause , $ params , '' , 'name, value ' )) {
989+ foreach ($ entries as $ entry ) {
990+ $ enabled = !empty ($ entry ->value );
991+ $ enableuploadsettingname = str_replace ('transcriptionworkflow ' , 'enableuploadtranscription ' , $ entry ->name );
992+ $ enablemanagesettingname = str_replace ('transcriptionworkflow ' , 'enablemanagetranscription ' , $ entry ->name );
993+ set_config ($ enableuploadsettingname , $ enabled , $ pluginname );
994+ set_config ($ enablemanagesettingname , $ enabled , $ pluginname );
995+ }
996+ }
997+ upgrade_block_savepoint (true , 2025072900 , 'opencast ' );
998+ }
999+
1000+ if ($ oldversion < 2025080100 ) {
1001+
1002+ // Changes for migrating most of the block admin setting to tool in version 5.
9611003
9621004 // Migrate settings.
9631005 $ DB ->execute ("UPDATE {config_plugins} SET plugin='tool_opencast'
@@ -1044,52 +1086,12 @@ function xmldb_block_opencast_upgrade($oldversion) {
10441086 // Change classname.
10451087 $ newclassname = str_replace ('block_opencast ' , 'tool_opencast ' , $ task );
10461088 $ DB ->execute ("UPDATE {task_adhoc} SET classname=' " . $ newclassname .
1047- "' WHERE component = 'tool_opencast' AND classname = ' " . $ task . "' " );
1089+ "' WHERE component = 'tool_opencast' AND classname = ' " . $ task . "' " );
10481090 }
10491091
1050- upgrade_block_savepoint (true , 2025042200 , 'opencast ' );
1092+ upgrade_block_savepoint (true , 2025080100 , 'opencast ' );
10511093
10521094 }
10531095
1054- if ($ oldversion < 2025072900 ) {
1055- // Transcription settings changes.
1056- $ pluginname = 'tool_opencast ' ;
1057- // We change the config name from transcriptionflavors to transcriptionlanguages but the functionalitiy remains the same.
1058- $ params = ['plugin ' => $ pluginname , 'configname ' => 'transcriptionflavors% ' ];
1059- $ whereclause = $ DB ->sql_equal ('plugin ' , ':plugin ' ) . ' AND ' . $ DB ->sql_like ('name ' , ':configname ' );
1060- if ($ entries = $ DB ->get_records_select ('config_plugins ' , $ whereclause , $ params , '' , 'name, value ' )) {
1061- foreach ($ entries as $ entry ) {
1062- $ newconfigname = str_replace ('transcriptionflavors ' , 'transcriptionlanguages ' , $ entry ->name );
1063- set_config ($ newconfigname , $ entry ->value , $ pluginname );
1064- unset_config ($ entry ->name , $ pluginname );
1065- }
1066- }
1067-
1068- // We remove the maxtranscriptionupload precisely, regardless of the ocinstance.
1069- $ params = ['plugin ' => $ pluginname , 'configname ' => 'maxtranscriptionupload% ' ];
1070- $ whereclause = $ DB ->sql_equal ('plugin ' , ':plugin ' ) . ' AND ' . $ DB ->sql_like ('name ' , ':configname ' );
1071- if ($ entries = $ DB ->get_records_select ('config_plugins ' , $ whereclause , $ params , '' , 'name ' )) {
1072- foreach ($ entries as $ entry ) {
1073- unset_config ($ entry ->name , $ pluginname );
1074- }
1075- }
1076-
1077- // We then adjust the activation of newly added settings according to the previous settings relation.
1078- // Initially transcriptionworkflow worked as a feature activation toggle, meaning if it was empty,
1079- // the whole transcription feature was disabled. But now we divide this into two separate stand-alone settings.
1080- $ params = ['plugin ' => $ pluginname , 'configname ' => 'transcriptionworkflow% ' ];
1081- $ whereclause = $ DB ->sql_equal ('plugin ' , ':plugin ' ) . ' AND ' . $ DB ->sql_like ('name ' , ':configname ' );
1082- if ($ entries = $ DB ->get_records_select ('config_plugins ' , $ whereclause , $ params , '' , 'name, value ' )) {
1083- foreach ($ entries as $ entry ) {
1084- $ enabled = !empty ($ entry ->value );
1085- $ enableuploadsettingname = str_replace ('transcriptionworkflow ' , 'enableuploadtranscription ' , $ entry ->name );
1086- $ enablemanagesettingname = str_replace ('transcriptionworkflow ' , 'enablemanagetranscription ' , $ entry ->name );
1087- set_config ($ enableuploadsettingname , $ enabled , $ pluginname );
1088- set_config ($ enablemanagesettingname , $ enabled , $ pluginname );
1089- }
1090- }
1091- upgrade_block_savepoint (true , 2025072900 , 'opencast ' );
1092- }
1093-
10941096 return true ;
10951097}
0 commit comments