1
2<#2949>
3<?php
4    // empty step
5?>
6<#2950>
7<?php
8    $ilDB->modifyTableColumn(
9    'table_properties',
10    'value',
11    array("type" => "text", "length" => 4000, "notnull" => true)
12);
13?>
14<#2951>
15<?php
16if (!$ilDB->tableExists('payment_paymethods')) {
17    $fields = array(
18    'pm_id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
19    'pm_title' => array('type' => 'text', 'notnull' => true, 'length' => 60, 'fixed' => false),
20    'pm_enabled' => array('type' => 'integer', 'length' => 1,"notnull" => true,"default" => 0),
21    'save_usr_adr' => array('type' => 'integer', 'length' => 1,"notnull" => true,"default" => 0)
22  );
23    $ilDB->createTable('payment_paymethods', $fields);
24    $ilDB->addPrimaryKey('payment_paymethods', array('pm_id'));
25    // this is not necessary and triggers an error under oracle, since the index
26    // is already created with the primary key: (alex, 19.7.2010)
27    //  $ilDB->addIndex('payment_paymethods',array('pm_id'),'i1');
28    $ilDB->createSequence("payment_paymethods");
29}
30?>
31<#2952>
32<?php
33    $res = $ilDB->query("SELECT value FROM settings WHERE keyword = " . $ilDB->quote('pm_bill', 'text'));
34    $row = $ilDB->fetchAssoc($res);
35    $row['value'] == 1 ? $pm_bill = 1 : $pm_bill = 0;
36    $res = $ilDB->query("SELECT value FROM settings WHERE keyword = " . $ilDB->quote('save_user_adr_bill', 'text'));
37    $row = $ilDB->fetchAssoc($res);
38    $row['value'] == 1 ? $adr_bill = 1: $adr_bill = 0;
39
40    $res = $ilDB->query("SELECT value FROM settings WHERE keyword = " . $ilDB->quote('pm_bmf', 'text'));
41    $row = $ilDB->fetchAssoc($res);
42    $row['value'] == 1 ? $pm_bmf = 1: $pm_bmf = 0;
43    $res = $ilDB->query("SELECT value FROM settings WHERE keyword = " . $ilDB->quote('save_user_adr_bmf', 'text'));
44    $row = $ilDB->fetchAssoc($res);
45    $row['value'] == 1 ? $adr_bmf = 1: $adr_bmf = 0;
46
47    $res = $ilDB->query("SELECT value FROM settings WHERE keyword = " . $ilDB->quote('pm_paypal', 'text'));
48    $row = $ilDB->fetchAssoc($res);
49    $row['value'] == 1 ? $pm_ppal = 1: $pm_ppal = 0;
50    $res = $ilDB->query("SELECT value FROM settings WHERE keyword = " . $ilDB->quote('save_user_adr_paypal', 'text'));
51    $row = $ilDB->fetchAssoc($res);
52    $row['value'] == 1 ? $adr_ppal = 1: $adr_ppal = 0;
53
54    $res = $ilDB->query("SELECT value FROM settings WHERE keyword = " . $ilDB->quote('pm_epay', 'text'));
55    $row = $ilDB->fetchAssoc($res);
56    $row['value'] == 1 ? $pm_epay = 1: $pm_epay = 0;
57    $res = $ilDB->query("SELECT value FROM settings WHERE keyword = " . $ilDB->quote('save_user_adr_epay', 'text'));
58    $row = $ilDB->fetchAssoc($res);
59    $row['value'] == 1 ? $adr_epay = 1: $adr_epay = 0;
60
61    $query = 'INSERT INTO payment_paymethods (pm_id, pm_title, pm_enabled, save_usr_adr) VALUES (%s, %s, %s, %s)';
62    $types = array("integer", "text", "integer", "integer");
63
64    $nextId = $ilDB->nextId('payment_paymethods');
65    $bill_data = array($nextId, 'bill', $pm_bill, $adr_bill);
66    $ilDB->manipulateF($query, $types, $bill_data);
67
68    $nextId = $ilDB->nextId('payment_paymethods');
69    $bmf_data = array($nextId, 'bmf',  $pm_bmf, $adr_bmf);
70    $ilDB->manipulateF($query, $types, $bmf_data);
71
72    $nextId = $ilDB->nextId('payment_paymethods');
73    $paypal_data = array($nextId, 'paypal',  $pm_ppal, $adr_ppal);
74    $ilDB->manipulateF($query, $types, $paypal_data);
75
76    $nextId = $ilDB->nextId('payment_paymethods');
77    $epay_data = array($nextId, 'epay', $pm_epay, $adr_epay);
78      $ilDB->manipulateF($query, $types, $epay_data);
79?>
80<#2953>
81<?php
82    $res = $ilDB->manipulate('DELETE FROM settings WHERE keyword = ' . $ilDB->quote('pm_bill', 'text'));
83    $res = $ilDB->manipulate('DELETE FROM settings WHERE keyword = ' . $ilDB->quote('pm_bmf', 'text'));
84    $res = $ilDB->manipulate('DELETE FROM settings WHERE keyword = ' . $ilDB->quote('pm_paypal', 'text'));
85    $res = $ilDB->manipulate('DELETE FROM settings WHERE keyword = ' . $ilDB->quote('pm_epay', 'text'));
86
87    $res = $ilDB->manipulate('DELETE FROM settings WHERE keyword = ' . $ilDB->quote('save_user_adr_bill', 'text'));
88    $res = $ilDB->manipulate('DELETE FROM settings WHERE keyword = ' . $ilDB->quote('save_user_adr_bmf', 'text'));
89    $res = $ilDB->manipulate('DELETE FROM settings WHERE keyword = ' . $ilDB->quote('save_user_adr_paypal', 'text'));
90    $res = $ilDB->manipulate('DELETE FROM settings WHERE keyword = ' . $ilDB->quote('save_user_adr_epay', 'text'));
91?>
92<#2954>
93<?php
94    if ($ilDB->tableColumnExists("payment_settings", "hide_filtering")) {
95        $ilDB->renameTableColumn('payment_settings', 'hide_filtering', 'objects_allow_custom_sorting');
96    }
97    $ilDB->modifyTableColumn('payment_settings', 'objects_allow_custom_sorting', array(
98            "type" => "integer",
99            'length' => 4,
100            "notnull" => true,
101            "default" => 0));
102?>
103<#2955>
104<?php
105    if (!$ilDB->tableColumnExists("payment_statistic", "currency_unit")) {
106        $ilDB->addTableColumn("payment_statistic", "currency_unit", array(
107            "type" => "text",
108            "notnull" => false,
109            "length" => 16,
110            "fixed" => false));
111    }
112    $res = $ilDB->query('SELECT price from payment_statistic');
113    $row = $ilDB->fetchAssoc($res);
114    while ($row = $ilDB->fetchAssoc($res)) {
115        $exp = explode(' ', $row['price']);
116        $amount = $exp['0'];
117        $currency = $exp['1'];
118
119        $upd = $ilDB->manipulateF(
120            'UPDATE payment_statistic
121			SET price = %s, currency_unit = %s',
122            array('float','text'),
123            array($amount, $currency)
124        );
125    }
126?>
127<#2956>
128<?php
129if ($ilDB->tableExists('payment_currencies')) {
130    $ilDB->dropTable('payment_currencies');
131}
132if ($ilDB->tableExists('payment_currencies_seq')) {
133    $ilDB->dropTable('payment_currencies_seq');
134}
135?>
136<#2957>
137<?php
138if (!$ilDB->tableExists('payment_currencies')) {
139    $fields = array(
140    'currency_id' => array(
141            'type' => 'integer',
142            'length' => 4,
143            'notnull' => true,
144            'default' => 0),
145
146    'unit' => array(
147            'type' => 'text',
148            'notnull' => true,
149            'length' => 16,
150            'fixed' => false),
151
152    'iso_code' => array(
153            "type" => "text",
154            "notnull" => false,
155            "length" => 4,
156            "fixed" => false),
157
158    'symbol' => array(
159            "type" => "text",
160            "notnull" => false,
161            "length" => 4,
162            "fixed" => false),
163
164    'conversion_rate' => array(
165            "type" => "float",
166            "notnull" => true,
167            "default" => 0)
168  );
169    $ilDB->createTable('payment_currencies', $fields);
170    $ilDB->addPrimaryKey('payment_currencies', array('currency_id'));
171    $ilDB->createSequence("payment_currencies");
172}
173?>
174<#2958>
175<?php
176    $res = $ilDB->query('SELECT currency_unit FROM payment_settings');
177    $row = $ilDB->fetchAssoc($res);
178
179    while ($row = $ilDB->fetchAssoc($res)) {
180        $nextId = $ilDB->nextId('payment_currencies');
181        $ins_res = $ilDB->manipulateF(
182            'INSERT INTO payment_currencies (currency_id, unit)
183			VALUES(%s,%s)',
184            array('integer', 'text'),
185            array($nextId, $row['currency_unit'])
186        );
187
188        $upd_prices = $ilDB->manipulateF(
189            'UPDATE payment_prices SET currency = %s',
190            array('integer'),
191            array($nextId)
192        );
193        $ilDB->manipulateF('UPDATE payment_statistic SET currency_unit = %s', array('text'), array($row['currency_unit']));
194    }
195?>
196<#2959>
197<?php
198    $res = $ilDB->query('SELECT * FROM payment_statistic');
199    $statistic_arr = array();
200    $counter = 0;
201    while ($row = $ilDB->fetchAssoc($res)) {
202        $statistic_arr[$counter]['booking_id'] = $row['booking_id'];
203        $tmp_p = str_replace(",", ".", $row['price']);
204        $pr = str_replace(' ', '', $tmp_p);
205        $statistic_arr[$counter]['price'] = (float) $pr;
206        $tmp_d = str_replace(",", ".", $row['discount']);
207        $dis = str_replace(' ', '', $tmp_d);
208        $statistic_arr[$counter]['discount'] = (float) $dis;
209        $counter++;
210    }
211
212    $ilDB->manipulate('UPDATE payment_statistic SET
213		price = NULL, discount = NULL');
214
215            $ilDB->modifyTableColumn('payment_statistic', 'price', array(
216            "type" => "float",
217            "notnull" => true,
218            "default" => 0));
219
220    $ilDB->modifyTableColumn('payment_statistic', 'discount', array(
221            "type" => "float",
222            "notnull" => true,
223            "default" => 0));
224
225    foreach ($statistic_arr as $stat) {
226        $upd = $ilDB->manipulateF(
227            'UPDATE payment_statistic SET
228			price = %s,
229			discount = %s
230		WHERE booking_id = %s',
231            array('float', 'float','integer'),
232            array($stat['price'],$stat['discount'], $stat['booking_id'])
233        );
234    }
235?>
236<#2960>
237<?php
238    if (!$ilDB->tableColumnExists("payment_statistic", "email_extern")) {
239        $ilDB->addTableColumn('payment_statistic', 'email_extern', array(
240            "type" => "text",
241            "notnull" => false,
242            "length" => 80,
243            "fixed" => false));
244    }
245    if (!$ilDB->tableColumnExists("payment_statistic", "name_extern")) {
246        $ilDB->addTableColumn('payment_statistic', 'name_extern', array(
247            "type" => "text",
248            "notnull" => false,
249            "length" => 80,
250            "fixed" => false));
251    }
252?>
253<#2961>
254<?php
255    if (!$ilDB->tableColumnExists("payment_shopping_cart", "session_id")) {
256        $ilDB->addTableColumn('payment_shopping_cart', 'session_id', array(
257            "type" => "text",
258            "notnull" => false,
259            "length" => 80,
260            "fixed" => false));
261    }
262?>
263<#2962>
264<?php
265    if ($ilDB->tableExists('payment_bill_vendor')) {
266        $ilDB->dropTable('payment_bill_vendor');
267    }
268?>
269<#2963>
270<?php
271    $ilCtrlStructureReader->getStructure();
272?>
273<#2964>
274<?php
275    $ilDB->dropIndex('svy_category', 'i2');
276?>
277<#2965>
278<?php
279if ($ilDB->tableColumnExists('svy_category', 'scale')) {
280    $ilDB->dropTableColumn('svy_category', 'scale');
281}
282?>
283<#2966>
284<?php
285if ($ilDB->tableColumnExists('svy_category', 'other')) {
286    $ilDB->dropTableColumn('svy_category', 'other');
287}
288?>
289<#2967>
290<?php
291if (!$ilDB->tableColumnExists('svy_variable', 'other')) {
292    $ilDB->addTableColumn("svy_variable", "other", array("type" => "integer", "length" => 2, "notnull" => true, "default" => 0));
293}
294?>
295<#2968>
296<?php
297if ($ilDB->tableColumnExists('svy_qst_mc', 'use_other_answer')) {
298    $ilDB->dropTableColumn('svy_qst_mc', 'use_other_answer');
299}
300?>
301<#2969>
302<?php
303if ($ilDB->tableColumnExists('svy_qst_sc', 'use_other_answer')) {
304    $ilDB->dropTableColumn('svy_qst_sc', 'use_other_answer');
305}
306?>
307<#2970>
308<?php
309    // mail rcp_to
310    $ilDB->addTableColumn(
311        "mail",
312        "rcp_to_tmp",
313        array(
314        "type" => "clob",
315        "notnull" => false,
316        "default" => null)
317    );
318
319    $ilDB->manipulate('UPDATE mail SET rcp_to_tmp = rcp_to');
320    $ilDB->dropTableColumn('mail', 'rcp_to');
321    $ilDB->renameTableColumn("mail", "rcp_to_tmp", "rcp_to");
322?>
323<#2971>
324<?php
325    // mail rcp_cc
326    $ilDB->addTableColumn(
327        "mail",
328        "rcp_cc_tmp",
329        array(
330        "type" => "clob",
331        "notnull" => false,
332        "default" => null)
333    );
334
335    $ilDB->manipulate('UPDATE mail SET rcp_cc_tmp = rcp_cc');
336    $ilDB->dropTableColumn('mail', 'rcp_cc');
337    $ilDB->renameTableColumn("mail", "rcp_cc_tmp", "rcp_cc");
338?>
339<#2972>
340<?php
341    // mail rcp_bcc
342    $ilDB->addTableColumn(
343        "mail",
344        "rcp_bcc_tmp",
345        array(
346        "type" => "clob",
347        "notnull" => false,
348        "default" => null)
349    );
350
351    $ilDB->manipulate('UPDATE mail SET rcp_bcc_tmp = rcp_bcc');
352    $ilDB->dropTableColumn('mail', 'rcp_bcc');
353    $ilDB->renameTableColumn("mail", "rcp_bcc_tmp", "rcp_bcc");
354?>
355<#2973>
356<?php
357    // mail_saved rcp_to
358    $ilDB->addTableColumn(
359        "mail_saved",
360        "rcp_to_tmp",
361        array(
362        "type" => "clob",
363        "notnull" => false,
364        "default" => null)
365    );
366
367    $ilDB->manipulate('UPDATE mail_saved SET rcp_to_tmp = rcp_to');
368    $ilDB->dropTableColumn('mail_saved', 'rcp_to');
369    $ilDB->renameTableColumn("mail_saved", "rcp_to_tmp", "rcp_to");
370?>
371<#2974>
372<?php
373    // mail_saved rcp_cc
374    $ilDB->addTableColumn(
375        "mail_saved",
376        "rcp_cc_tmp",
377        array(
378        "type" => "clob",
379        "notnull" => false,
380        "default" => null)
381    );
382
383    $ilDB->manipulate('UPDATE mail_saved SET rcp_cc_tmp = rcp_cc');
384    $ilDB->dropTableColumn('mail_saved', 'rcp_cc');
385    $ilDB->renameTableColumn("mail_saved", "rcp_cc_tmp", "rcp_cc");
386?>
387<#2975>
388<?php
389    // mail_saved rcp_bcc
390    $ilDB->addTableColumn(
391        "mail_saved",
392        "rcp_bcc_tmp",
393        array(
394        "type" => "clob",
395        "notnull" => false,
396        "default" => null)
397    );
398
399    $ilDB->manipulate('UPDATE mail_saved SET rcp_bcc_tmp = rcp_bcc');
400    $ilDB->dropTableColumn('mail_saved', 'rcp_bcc');
401    $ilDB->renameTableColumn("mail_saved", "rcp_bcc_tmp", "rcp_bcc");
402?>
403<#2976>
404<?php
405    $ilCtrlStructureReader->getStructure();
406?>
407<#2977>
408<?php
409    $ilDB->addTableColumn("content_object", "public_scorm_file", array(
410        "type" => "text",
411        "notnull" => false,
412        "length" => 50));
413?>
414<#2978>
415<?php
416    $query = 'UPDATE usr_pref SET value = ROUND(value / 60) WHERE keyword = %s AND value IS NOT NULL';
417    if ($ilDB->getDBType() == 'oracle') {
418        $query .= " AND LENGTH(TRIM(TRANSLATE (value, ' +-.0123456789',' '))) IS NULL";
419        $ilDB->manipulateF($query, array('text'), array('session_reminder_lead_time'));
420    } else {
421        $ilDB->manipulateF($query, array('text'), array('session_reminder_lead_time'));
422    }
423?>
424<#2979>
425<?php
426    $ilCtrlStructureReader->getStructure();
427?>
428
429<#2980>
430<?php
431
432if (!$ilDB->tableExists('openid_provider')) {
433    $fields = array(
434        'provider_id' => array(
435            'type' => 'integer',
436            'length' => 4,
437        ),
438        'enabled' => array(
439            'type' => 'integer',
440            'length' => 1,
441        ),
442        'name' => array(
443            'type' => 'text',
444            'length' => 128,
445            'fixed' => false,
446            'notnull' => false
447        ),
448        'url' => array(
449            'type' => 'text',
450            'length' => 512,
451            'fixed' => false,
452            'notnull' => false
453        ),
454        'image' => array(
455            'type' => 'integer',
456            'length' => 2
457        )
458    );
459    $ilDB->createTable('openid_provider', $fields);
460    $ilDB->addPrimaryKey('openid_provider', array('provider_id'));
461    $ilDB->createSequence('openid_provider');
462}
463?>
464
465<#2981>
466<?php
467$query = "INSERT INTO openid_provider (provider_id,enabled,name,url,image) " .
468    "VALUES ( " .
469    $ilDB->quote($ilDB->nextId('openid_provider'), 'integer') . ',' .
470    $ilDB->quote(1, 'integer') . ',' .
471    $ilDB->quote('MyOpenID', 'text') . ',' .
472    $ilDB->quote('http://%s.myopenid.com') . ',' .
473    $ilDB->quote(1, 'integer') .
474    ")";
475$res = $ilDB->query($query);
476?>
477<#2982>
478<?php
479    $setting = new ilSetting();
480    $st_step = (int) $setting->get('patch_stex_db');
481    if ($st_step <= 0) {
482        $ilDB->createTable(
483            "exc_assignment",
484            array(
485                "id" => array(
486                    "type" => "integer", "length" => 4, "notnull" => true
487                ),
488                "exc_id" => array(
489                    "type" => "integer", "length" => 4, "notnull" => true
490                ),
491                "time_stamp" => array(
492                    "type" => "integer", "length" => 4, "notnull" => false
493                ),
494                "instruction" => array(
495                    "type" => "clob"
496                )
497            )
498        );
499
500        $ilDB->addPrimaryKey("exc_assignment", array("id"));
501
502        $ilDB->createSequence("exc_assignment");
503    }
504?>
505<#2983>
506<?php
507    $setting = new ilSetting();
508    $st_step = (int) $setting->get('patch_stex_db');
509    if ($st_step <= 1) {
510        $ilDB->createTable(
511            "exc_mem_ass_status",
512            array(
513                "ass_id" => array(
514                    "type" => "integer", "length" => 4, "notnull" => true
515                ),
516                "usr_id" => array(
517                    "type" => "integer", "length" => 4, "notnull" => true
518                ),
519                "notice" => array(
520                    "type" => "text", "length" => 4000, "notnull" => false
521                ),
522                "returned" => array(
523                    "type" => "integer", "length" => 1, "notnull" => true, "default" => 0
524                ),
525                "solved" => array(
526                    "type" => "integer", "length" => 1, "notnull" => false
527                ),
528                "status_time" => array(
529                    "type" => "timestamp", "notnull" => false
530                ),
531                "sent" => array(
532                    "type" => "integer", "length" => 1, "notnull" => false
533                ),
534                "sent_time" => array(
535                    "type" => "timestamp", "notnull" => false
536                ),
537                "feedback_time" => array(
538                    "type" => "timestamp", "notnull" => false
539                ),
540                "feedback" => array(
541                    "type" => "integer", "length" => 1, "notnull" => true, "default" => 0
542                ),
543                "status" => array(
544                    "type" => "text", "length" => 9, "fixed" => true, "default" => "notgraded", "notnull" => false
545                )
546            )
547        );
548
549        $ilDB->addPrimaryKey("exc_mem_ass_status", array("ass_id", "usr_id"));
550    }
551?>
552<#2984>
553<?php
554    $setting = new ilSetting();
555    $st_step = (int) $setting->get('patch_stex_db');
556    if ($st_step <= 2) {
557        $ilDB->addTableColumn(
558            "exc_returned",
559            "ass_id",
560            array("type" => "integer", "length" => 4, "notnull" => false)
561        );
562    }
563?>
564<#2985>
565<?php
566    /*$setting = new ilSetting();
567    $st_step = (int) $setting->get('patch_stex_db');
568    if ($st_step <= 3)
569    {
570        $ilDB->createTable("exc_mem_tut_status",
571            array (
572                "ass_id" => array(
573                    "type" => "integer", "length" => 4, "notnull" => true
574                ),
575                "mem_id" => array(
576                    "type" => "integer", "length" => 4, "notnull" => true
577                ),
578                "tut_id" => array(
579                    "type" => "integer", "length" => 4, "notnull" => true
580                ),
581                "download_time" => array(
582                    "type" => "timestamp"
583                )
584            )
585        );
586    }*/
587?>
588<#2986>
589<?php
590    /*$setting = new ilSetting();
591    $st_step = (int) $setting->get('patch_stex_db');
592    if ($st_step <= 4)
593    {
594        $ilDB->addPrimaryKey("exc_mem_tut_status", array("ass_id", "mem_id", "tut_id"));
595    }*/
596?>
597<#2987>
598<?php
599    $setting = new ilSetting();
600    $st_step = (int) $setting->get('patch_stex_db');
601    if ($st_step <= 5) {
602        $set = $ilDB->query("SELECT * FROM exc_data");
603        while ($rec = $ilDB->fetchAssoc($set)) {
604            // Create exc_assignment records for all existing exercises
605            // -> instruction and time_stamp fields in exc_data are obsolete
606            $next_id = $ilDB->nextId("exc_assignment");
607            $ilDB->insert("exc_assignment", array(
608                "id" => array("integer", $next_id),
609                "exc_id" => array("integer", $rec["obj_id"]),
610                "time_stamp" => array("integer", $rec["time_stamp"]),
611                "instruction" => array("clob", $rec["instruction"])
612                ));
613        }
614    }
615?>
616<#2988>
617<?php
618    $setting = new ilSetting();
619    $st_step = (int) $setting->get('patch_stex_db');
620    if ($st_step <= 6) {
621        $ilDB->addIndex("exc_members", array("obj_id"), "ob");
622    }
623?>
624<#2989>
625<?php
626    $setting = new ilSetting();
627    $st_step = (int) $setting->get('patch_stex_db');
628    if ($st_step <= 7) {
629        $set = $ilDB->query("SELECT id, exc_id FROM exc_assignment");
630        while ($rec = $ilDB->fetchAssoc($set)) {
631            $set2 = $ilDB->query(
632                "SELECT * FROM exc_members " .
633                " WHERE obj_id = " . $ilDB->quote($rec["exc_id"], "integer")
634            );
635            while ($rec2 = $ilDB->fetchAssoc($set2)) {
636                $ilDB->manipulate("INSERT INTO exc_mem_ass_status " .
637                    "(ass_id, usr_id, notice, returned, solved, status_time, sent, sent_time," .
638                    "feedback_time, feedback, status) VALUES (" .
639                    $ilDB->quote($rec["id"], "integer") . "," .
640                    $ilDB->quote($rec2["usr_id"], "integer") . "," .
641                    $ilDB->quote($rec2["notice"], "text") . "," .
642                    $ilDB->quote($rec2["returned"], "integer") . "," .
643                    $ilDB->quote($rec2["solved"], "integer") . "," .
644                    $ilDB->quote($rec2["status_time"], "timestamp") . "," .
645                    $ilDB->quote($rec2["sent"], "integer") . "," .
646                    $ilDB->quote($rec2["sent_time"], "timestamp") . "," .
647                    $ilDB->quote($rec2["feedback_time"], "timestamp") . "," .
648                    $ilDB->quote($rec2["feedback"], "integer") . "," .
649                    $ilDB->quote($rec2["status"], "text") .
650                    ")");
651            }
652        }
653    }
654?>
655<#2990>
656<?php
657    $setting = new ilSetting();
658    $st_step = (int) $setting->get('patch_stex_db');
659    if ($st_step <= 8) {
660        $ilDB->addIndex("exc_usr_tutor", array("obj_id"), "ob");
661    }
662?>
663<#2991>
664<?php
665    /*$setting = new ilSetting();
666    $st_step = (int) $setting->get('patch_stex_db');
667    if ($st_step <= 9)
668    {
669        $set = $ilDB->query("SELECT id, exc_id FROM exc_assignment");
670        while ($rec  = $ilDB->fetchAssoc($set))
671        {
672            $set2 = $ilDB->query("SELECT * FROM exc_usr_tutor ".
673                " WHERE obj_id = ".$ilDB->quote($rec["exc_id"], "integer")
674                );
675            while ($rec2  = $ilDB->fetchAssoc($set2))
676            {
677                $ilDB->manipulate("INSERT INTO exc_mem_tut_status ".
678                    "(ass_id, mem_id, tut_id, download_time) VALUES (".
679                    $ilDB->quote($rec["id"], "integer").",".
680                    $ilDB->quote($rec2["usr_id"], "integer").",".
681                    $ilDB->quote($rec2["tutor_id"], "integer").",".
682                    $ilDB->quote($rec2["download_time"], "timestamp").
683                    ")");
684            }
685        }
686    }*/
687?>
688<#2992>
689<?php
690    $setting = new ilSetting();
691    $st_step = (int) $setting->get('patch_stex_db');
692    if ($st_step <= 10) {
693        $set = $ilDB->query("SELECT id, exc_id FROM exc_assignment");
694        while ($rec = $ilDB->fetchAssoc($set)) {
695            $ilDB->manipulate(
696                "UPDATE exc_returned SET " .
697                " ass_id = " . $ilDB->quote($rec["id"], "integer") .
698                " WHERE obj_id = " . $ilDB->quote($rec["exc_id"], "integer")
699            );
700        }
701    }
702?>
703<#2993>
704<?php
705    $setting = new ilSetting();
706    $st_step = (int) $setting->get('patch_stex_db');
707    if ($st_step <= 11) {
708        $ilDB->addTableColumn(
709            "exc_assignment",
710            "title",
711            array("type" => "text", "length" => 200, "notnull" => false)
712        );
713
714        $ilDB->addTableColumn(
715            "exc_assignment",
716            "start_time",
717            array("type" => "integer", "length" => 4, "notnull" => false)
718        );
719
720        $ilDB->addTableColumn(
721            "exc_assignment",
722            "mandatory",
723            array("type" => "integer", "length" => 1, "notnull" => false, "default" => 0)
724        );
725    }
726?>
727<#2994>
728<?php
729    $setting = new ilSetting();
730    $st_step = (int) $setting->get('patch_stex_db');
731    if ($st_step <= 12) {
732        $ilDB->addTableColumn(
733            "exc_data",
734            "pass_mode",
735            array("type" => "text", "length" => 8, "fixed" => false,
736                "notnull" => true, "default" => "all")
737        );
738
739        $ilDB->addTableColumn(
740            "exc_data",
741            "pass_nr",
742            array("type" => "integer", "length" => 4, "notnull" => false)
743        );
744    }
745?>
746<#2995>
747<?php
748    $setting = new ilSetting();
749    $st_step = (int) $setting->get('patch_stex_db');
750    if ($st_step <= 13) {
751        $ilDB->addTableColumn(
752            "exc_assignment",
753            "order_nr",
754            array("type" => "integer", "length" => 4, "notnull" => true, "default" => 0)
755        );
756    }
757?>
758<#2996>
759<?php
760    $setting = new ilSetting();
761    $st_step = (int) $setting->get('patch_stex_db');
762    if ($st_step <= 14) {
763        $ilDB->addTableColumn(
764            "exc_data",
765            "show_submissions",
766            array("type" => "integer", "length" => 1, "notnull" => true, "default" => 0)
767        );
768    }
769?>
770<#2997>
771<?php
772/*	$setting = new ilSetting();
773    $st_step = (int) $setting->get('patch_stex_db');
774    if ($st_step <= 15)
775    {
776            $new_ex_path = CLIENT_DATA_DIR."/ilExercise";
777
778            $old_ex_path = CLIENT_DATA_DIR."/exercise";
779
780            $old_ex_files = array();
781
782            if (is_dir($old_ex_path))
783            {
784                $dh_old_ex_path = opendir($old_ex_path);
785
786                // old exercise files into an assoc array to
787                // avoid reading of all files each time
788
789                while($file = readdir($dh_old_ex_path))
790                {
791                    if(is_dir($old_ex_path."/".$file))
792                    {
793                        continue;
794                    }
795                    list($obj_id,$rest) = split('_',$file,2);
796                    $old_ex_files[$obj_id][] = array("full" => $file,
797                        "rest" => $rest);
798                }
799            }
800//var_dump($old_ex_files);
801
802            $set = $ilDB->query("SELECT id, exc_id FROM exc_assignment");
803            while ($rec  = $ilDB->fetchAssoc($set))
804            {
805                // move exercise files to assignment directories
806                if (is_array($old_ex_files[$rec["exc_id"]]))
807                {
808                    foreach ($old_ex_files[$rec["exc_id"]] as $file)
809                    {
810                        $old = $old_ex_path."/".$file["full"];
811                        $new = $new_ex_path."/".$this->createPathFromId($rec["exc_id"], "exc").
812                            "/ass_".$rec["id"]."/".$file["rest"];
813
814                        if (is_file($old))
815                        {
816                            ilUtil::makeDirParents(dirname($new));
817                            rename($old, $new);
818//echo "<br><br>move: ".$old.
819//	"<br>to: ".$new;
820                        }
821                    }
822                }
823
824                // move submitted files to assignment directories
825                if (is_dir($old_ex_path."/".$rec["exc_id"]))
826                {
827                    $old = $old_ex_path."/".$rec["exc_id"];
828                    $new = $new_ex_path."/".$this->createPathFromId($rec["exc_id"], "exc").
829                        "/subm_".$rec["id"];
830                    ilUtil::makeDirParents(dirname($new));
831                    rename($old, $new);
832//echo "<br><br>move: ".$old.
833//	"<br>to: ".$new;
834                }
835
836    }*/
837?>
838<#2998>
839<?php
840    $setting = new ilSetting();
841    $st_step = (int) $setting->get('patch_stex_db');
842    if ($st_step <= 16) {
843        $ilDB->addTableColumn(
844            "exc_usr_tutor",
845            "ass_id",
846            array("type" => "integer", "length" => 4, "notnull" => false)
847        );
848    }
849?>
850<#2999>
851<?php
852    $setting = new ilSetting();
853    $st_step = (int) $setting->get('patch_stex_db');
854    if ($st_step <= 17) {
855        $set = $ilDB->query("SELECT id, exc_id FROM exc_assignment");
856        while ($rec = $ilDB->fetchAssoc($set)) {
857            $ilDB->manipulate(
858                "UPDATE exc_usr_tutor SET " .
859                " ass_id = " . $ilDB->quote($rec["id"], "integer") .
860                " WHERE obj_id = " . $ilDB->quote($rec["exc_id"], "integer")
861            );
862        }
863        $ilDB->manipulate("DELETE FROM exc_usr_tutor WHERE ass_id IS NULL");
864    }
865?>
866<#3000>
867<?php
868    $setting = new ilSetting();
869    $st_step = (int) $setting->get('patch_stex_db');
870    if ($st_step <= 18) {
871        $ilCtrlStructureReader->getStructure();
872    }
873?>
874<#3001>
875<?php
876    $setting = new ilSetting();
877    $st_step = (int) $setting->get('patch_stex_db');
878    if ($st_step <= 19) {
879        $ilDB->addTableColumn(
880            "exc_mem_ass_status",
881            "mark",
882            array("type" => "text", "length" => 32, "notnull" => false)
883        );
884        $ilDB->addTableColumn(
885            "exc_mem_ass_status",
886            "u_comment",
887            array("type" => "text", "length" => 4000, "notnull" => false)
888        );
889
890        $set = $ilDB->query("SELECT id, exc_id FROM exc_assignment");
891        while ($rec = $ilDB->fetchAssoc($set)) {
892            $set2 = $ilDB->query("SELECT * FROM ut_lp_marks WHERE obj_id = " . $ilDB->quote($rec["exc_id"], "integer"));
893            while ($rec2 = $ilDB->fetchAssoc($set2)) {
894                $set3 = $ilDB->query("SELECT ass_id FROM exc_mem_ass_status WHERE " .
895                    "ass_id = " . $ilDB->quote($rec["id"], "integer") .
896                    " AND usr_id = " . $ilDB->quote($rec2["usr_id"], "integer"));
897                if ($rec3 = $ilDB->fetchAssoc($set3)) {
898                    $ilDB->manipulate(
899                        "UPDATE exc_mem_ass_status SET " .
900                        " mark = " . $ilDB->quote($rec2["mark"], "text") . "," .
901                        " u_comment = " . $ilDB->quote($rec2["u_comment"], "text") .
902                        " WHERE ass_id = " . $ilDB->quote($rec["id"], "integer") .
903                        " AND usr_id = " . $ilDB->quote($rec2["usr_id"], "integer")
904                    );
905                } else {
906                    $ilDB->manipulate(
907                        "INSERT INTO exc_mem_ass_status (ass_id, usr_id, mark, u_comment) VALUES (" .
908                        $ilDB->quote($rec["id"], "integer") . ", " .
909                        $ilDB->quote($rec2["usr_id"], "integer") . ", " .
910                        $ilDB->quote($rec2["mark"], "text") . ", " .
911                        $ilDB->quote($rec2["u_comment"], "text") . ")"
912                    );
913                }
914            }
915        }
916    }
917?>
918<#3002>
919<?php
920    $setting = new ilSetting();
921    $st_step = (int) $setting->get('patch_stex_db');
922    if ($st_step <= 20) {
923        $ilDB->dropPrimaryKey("exc_usr_tutor");
924        $ilDB->addPrimaryKey(
925            "exc_usr_tutor",
926            array("ass_id", "usr_id", "tutor_id")
927        );
928    }
929?>
930<#3003>
931<?php
932    $setting = new ilSetting();
933    $st_step = (int) $setting->get('patch_stex_db');
934    if ($st_step <= 23) {
935        $ilDB->modifyTableColumn(
936            "exc_assignment",
937            "mandatory",
938            array("type" => "integer", "length" => 1, "notnull" => false, "default" => 1)
939        );
940        $ilDB->manipulate("UPDATE exc_assignment SET " .
941            " mandatory = " . $ilDB->quote(1, "integer"));
942
943        $set = $ilDB->query("SELECT e.id, e.exc_id, o.title, e.title t2 FROM exc_assignment e JOIN object_data o" .
944                            " ON (e.exc_id = o.obj_id)");
945        while ($rec = $ilDB->fetchAssoc($set)) {
946            if ($rec["t2"] == "") {
947                $ilDB->manipulate("UPDATE exc_assignment SET " .
948                    " title = " . $ilDB->quote($rec["title"], "text") . " " .
949                    "WHERE id = " . $ilDB->quote($rec["id"], "text"));
950            }
951        }
952    }
953?>
954<#3004>
955<?php
956    $setting = new ilSetting();
957    $st_step = (int) $setting->get('patch_stex_db');
958    if ($st_step <= 15) {
959        include_once("./Services/Migration/DBUpdate_3004/classes/class.ilDBUpdate3004.php");
960
961        $new_ex_path = CLIENT_DATA_DIR . "/ilExercise";
962
963        $old_ex_path = CLIENT_DATA_DIR . "/exercise";
964
965        $old_ex_files = array();
966
967        if (is_dir($old_ex_path)) {
968            $dh_old_ex_path = opendir($old_ex_path);
969
970            // old exercise files into an assoc array to
971            // avoid reading of all files each time
972
973            while ($file = readdir($dh_old_ex_path)) {
974                if (is_dir($old_ex_path . "/" . $file)) {
975                    continue;
976                }
977                list($obj_id, $rest) = split('_', $file, 2);
978                $old_ex_files[$obj_id][] = array("full" => $file,
979                        "rest" => $rest);
980            }
981        }
982
983        //var_dump($old_ex_files);
984
985        $set = $ilDB->query("SELECT id, exc_id FROM exc_assignment");
986        while ($rec = $ilDB->fetchAssoc($set)) {
987            // move exercise files to assignment directories
988            if (is_array($old_ex_files[$rec["exc_id"]])) {
989                foreach ($old_ex_files[$rec["exc_id"]] as $file) {
990                    $old = $old_ex_path . "/" . $file["full"];
991                    $new = $new_ex_path . "/" . ilDBUpdate3004::createPathFromId($rec["exc_id"], "exc") .
992                            "/ass_" . $rec["id"] . "/" . $file["rest"];
993
994                    if (is_file($old)) {
995                        ilUtil::makeDirParents(dirname($new));
996                        rename($old, $new);
997                        //echo "<br><br>move: ".$old.
998//	"<br>to: ".$new;
999                    }
1000                }
1001            }
1002
1003            // move submitted files to assignment directories
1004            if (is_dir($old_ex_path . "/" . $rec["exc_id"])) {
1005                $old = $old_ex_path . "/" . $rec["exc_id"];
1006                $new = $new_ex_path . "/" . ilDBUpdate3004::createPathFromId($rec["exc_id"], "exc") .
1007                        "/subm_" . $rec["id"];
1008                ilUtil::makeDirParents(dirname($new));
1009                rename($old, $new);
1010                //echo "<br><br>move: ".$old.
1011//	"<br>to: ".$new;
1012            }
1013        }
1014    }
1015
1016?>
1017<#3005>
1018<?php
1019    if ($ilDB->getDBType() == 'oracle') {
1020        // mail rcp_to
1021        if (!$ilDB->tableColumnExists('mail', 'rcp_to_tmp')) {
1022            $ilDB->addTableColumn("mail", "rcp_to_tmp", array(
1023            "type" => "clob",
1024            "notnull" => false,
1025            "default" => null));
1026        }
1027    }
1028?>
1029<#3006>
1030<?php
1031    if ($ilDB->getDBType() == 'oracle') {
1032        $ilDB->manipulate('UPDATE mail SET rcp_to_tmp = rcp_to');
1033    }
1034?>
1035<#3007>
1036<?php
1037    if ($ilDB->getDBType() == 'oracle') {
1038        if ($ilDB->tableColumnExists('mail', 'rcp_to')) {
1039            $ilDB->dropTableColumn('mail', 'rcp_to');
1040        }
1041
1042        $ilDB->renameTableColumn("mail", "rcp_to_tmp", "rcp_to");
1043    }
1044?>
1045<#3008>
1046<?php
1047    if ($ilDB->getDBType() == 'oracle') {
1048        // mail rcp_cc
1049        if (!$ilDB->tableColumnExists('mail', 'rcp_cc_tmp')) {
1050            $ilDB->addTableColumn("mail", "rcp_cc_tmp", array(
1051            "type" => "clob",
1052            "notnull" => false,
1053            "default" => null));
1054        }
1055    }
1056?>
1057<#3009>
1058<?php
1059    if ($ilDB->getDBType() == 'oracle') {
1060        $ilDB->manipulate('UPDATE mail SET rcp_cc_tmp = rcp_cc');
1061    }
1062?>
1063<#3010>
1064<?php
1065    if ($ilDB->getDBType() == 'oracle') {
1066        if ($ilDB->tableColumnExists('mail', 'rcp_cc')) {
1067            $ilDB->dropTableColumn('mail', 'rcp_cc');
1068        }
1069
1070        $ilDB->renameTableColumn("mail", "rcp_cc_tmp", "rcp_cc");
1071    }
1072?>
1073<#3011>
1074<?php
1075    if ($ilDB->getDBType() == 'oracle') {
1076        // mail rcp_bcc
1077        if (!$ilDB->tableColumnExists('mail', 'rcp_bcc_tmp')) {
1078            $ilDB->addTableColumn("mail", "rcp_bcc_tmp", array(
1079            "type" => "clob",
1080            "notnull" => false,
1081            "default" => null));
1082        }
1083    }
1084?>
1085<#3012>
1086<?php
1087    if ($ilDB->getDBType() == 'oracle') {
1088        $ilDB->manipulate('UPDATE mail SET rcp_bcc_tmp = rcp_bcc');
1089    }
1090?>
1091<#3013>
1092<?php
1093    if ($ilDB->getDBType() == 'oracle') {
1094        if ($ilDB->tableColumnExists('mail', 'rcp_bcc')) {
1095            $ilDB->dropTableColumn('mail', 'rcp_bcc');
1096        }
1097
1098        $ilDB->renameTableColumn("mail", "rcp_bcc_tmp", "rcp_bcc");
1099    }
1100?>
1101<#3014>
1102<?php
1103    if ($ilDB->getDBType() == 'oracle') {
1104        // mail_saved rcp_to
1105        if (!$ilDB->tableColumnExists('mail_saved', 'rcp_to_tmp')) {
1106            $ilDB->addTableColumn("mail_saved", "rcp_to_tmp", array(
1107            "type" => "clob",
1108            "notnull" => false,
1109            "default" => null));
1110        }
1111    }
1112?>
1113<#3015>
1114<?php
1115    if ($ilDB->getDBType() == 'oracle') {
1116        $ilDB->manipulate('UPDATE mail_saved SET rcp_to_tmp = rcp_to');
1117    }
1118?>
1119<#3016>
1120<?php
1121    if ($ilDB->getDBType() == 'oracle') {
1122        if ($ilDB->tableColumnExists('mail_saved', 'rcp_to')) {
1123            $ilDB->dropTableColumn('mail_saved', 'rcp_to');
1124        }
1125
1126        $ilDB->renameTableColumn("mail_saved", "rcp_to_tmp", "rcp_to");
1127    }
1128?>
1129<#3017>
1130<?php
1131    if ($ilDB->getDBType() == 'oracle') {
1132        // mail_saved rcp_cc
1133        if (!$ilDB->tableColumnExists('mail_saved', 'rcp_cc_tmp')) {
1134            $ilDB->addTableColumn("mail_saved", "rcp_cc_tmp", array(
1135            "type" => "clob",
1136            "notnull" => false,
1137            "default" => null));
1138        }
1139    }
1140?>
1141<#3018>
1142<?php
1143    if ($ilDB->getDBType() == 'oracle') {
1144        $ilDB->manipulate('UPDATE mail_saved SET rcp_cc_tmp = rcp_cc');
1145    }
1146?>
1147<#3019>
1148<?php
1149    if ($ilDB->getDBType() == 'oracle') {
1150        if ($ilDB->tableColumnExists('mail_saved', 'rcp_cc')) {
1151            $ilDB->dropTableColumn('mail_saved', 'rcp_cc');
1152        }
1153
1154        $ilDB->renameTableColumn("mail_saved", "rcp_cc_tmp", "rcp_cc");
1155    }
1156?>
1157<#3020>
1158<?php
1159    if ($ilDB->getDBType() == 'oracle') {
1160        // mail_saved rcp_bcc
1161        if (!$ilDB->tableColumnExists('mail_saved', 'rcp_bcc_tmp')) {
1162            $ilDB->addTableColumn("mail_saved", "rcp_bcc_tmp", array(
1163            "type" => "clob",
1164            "notnull" => false,
1165            "default" => null));
1166        }
1167    }
1168?>
1169<#3021>
1170<?php
1171    if ($ilDB->getDBType() == 'oracle') {
1172        $ilDB->manipulate('UPDATE mail_saved SET rcp_bcc_tmp = rcp_bcc');
1173    }
1174?>
1175<#3022>
1176<?php
1177    if ($ilDB->getDBType() == 'oracle') {
1178        if ($ilDB->tableColumnExists('mail_saved', 'rcp_bcc')) {
1179            $ilDB->dropTableColumn('mail_saved', 'rcp_bcc');
1180        }
1181
1182        $ilDB->renameTableColumn("mail_saved", "rcp_bcc_tmp", "rcp_bcc");
1183    }
1184?>
1185<#3023>
1186<?php
1187    if ($ilDB->getDBType() == 'mysql') {
1188        $ilDB->modifyTableColumn('mail', 'rcp_to', array("type" => "clob", "default" => null, "notnull" => false));
1189    }
1190?>
1191<#3024>
1192<?php
1193    if ($ilDB->getDBType() == 'mysql') {
1194        $ilDB->modifyTableColumn('mail', 'rcp_cc', array("type" => "clob", "default" => null, "notnull" => false));
1195    }
1196?>
1197<#3025>
1198<?php
1199    if ($ilDB->getDBType() == 'mysql') {
1200        $ilDB->modifyTableColumn('mail', 'rcp_bcc', array("type" => "clob", "default" => null, "notnull" => false));
1201    }
1202?>
1203<#3026>
1204<?php
1205    if ($ilDB->getDBType() == 'mysql') {
1206        $ilDB->modifyTableColumn('mail_saved', 'rcp_to', array("type" => "clob", "default" => null, "notnull" => false));
1207    }
1208?>
1209<#3027>
1210<?php
1211    if ($ilDB->getDBType() == 'mysql') {
1212        $ilDB->modifyTableColumn('mail_saved', 'rcp_cc', array("type" => "clob", "default" => null, "notnull" => false));
1213    }
1214?>
1215<#3028>
1216<?php
1217    if ($ilDB->getDBType() == 'mysql') {
1218        $ilDB->modifyTableColumn('mail_saved', 'rcp_bcc', array("type" => "clob", "default" => null, "notnull" => false));
1219    }
1220?>
1221<#3029>
1222<?php
1223    if (!$ilDB->tableColumnExists('usr_session', 'type')) {
1224        $ilDB->addTableColumn(
1225            'usr_session',
1226            'type',
1227            array(
1228                "type" => "integer",
1229                "notnull" => false,
1230                "length" => 4,
1231                "default" => null
1232            )
1233        );
1234    }
1235    if (!$ilDB->tableColumnExists('usr_session', 'createtime')) {
1236        $ilDB->addTableColumn(
1237            'usr_session',
1238            'createtime',
1239            array(
1240                "type" => "integer",
1241                "notnull" => false,
1242                "length" => 4,
1243                "default" => null
1244            )
1245        );
1246    }
1247 ?>
1248<#3030>
1249<?php
1250$ilCtrlStructureReader->getStructure();
1251?>
1252<#3031>
1253<?php
1254    // new permission
1255    $new_ops_id = $ilDB->nextId('rbac_operations');
1256
1257    $res = $ilDB->manipulatef(
1258        '
1259		INSERT INTO rbac_operations (ops_id, operation, description, class)
1260	 	VALUES(%s, %s, %s, %s)',
1261        array('integer','text', 'text', 'text'),
1262        array($new_ops_id, 'mail_to_global_roles','User may send mails to global roles','object')
1263    );
1264
1265    $res = $ilDB->queryF(
1266        'SELECT obj_id FROM object_data WHERE type = %s AND title = %s',
1267        array('text', 'text'),
1268        array('typ', 'mail')
1269    );
1270    $row = $ilDB->fetchAssoc($res);
1271
1272    $typ_id = $row['obj_id'];
1273
1274    $query = $ilDB->manipulateF(
1275        'INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)',
1276        array('integer','integer'),
1277        array($typ_id, $new_ops_id)
1278    );
1279?>
1280<#3032>
1281<?php
1282    $query = 'SELECT ref_id FROM object_data '
1283           . 'INNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id '
1284           . 'WHERE type = ' . $ilDB->quote('mail', 'text');
1285    $res = $ilDB->query($query);
1286    $ref_ids = array();
1287    while ($row = $ilDB->fetchAssoc($res)) {
1288        $ref_ids[] = $row['ref_id'];
1289    }
1290
1291    $query = 'SELECT rol_id FROM rbac_fa '
1292           . 'WHERE assign = ' . $ilDB->quote('y', 'text') . ' '
1293           . 'AND parent = ' . $ilDB->quote(ROLE_FOLDER_ID, 'integer');
1294    $res = $ilDB->query($query);
1295    $global_roles = array();
1296    while ($row = $ilDB->fetchAssoc($res)) {
1297        $global_roles[] = $row['rol_id'];
1298    }
1299
1300    $query = 'SELECT ops_id FROM rbac_operations '
1301           . 'WHERE operation = ' . $ilDB->quote('mail_to_global_roles', 'text');
1302    $res = $ilDB->query($query);
1303    $data = $ilDB->fetchAssoc($res);
1304    $mtgr_permission = array();
1305    if ((int) $data['ops_id']) {
1306        $mtgr_permission[] = $data['ops_id'];
1307    }
1308
1309    foreach ($global_roles as $role) {
1310        if ($role == SYSTEM_ROLE_ID) {
1311            continue;
1312        }
1313
1314        foreach ($ref_ids as $ref_id) {
1315            $query = 'SELECT ops_id FROM rbac_pa '
1316                   . 'WHERE rol_id = ' . $ilDB->quote($role, 'integer') . ' '
1317                   . 'AND ref_id = ' . $ilDB->quote($ref_id, 'integer');
1318            $res = $ilDB->query($query);
1319            $operations = array();
1320            while ($row = $ilDB->fetchAssoc($res)) {
1321                $operations = unserialize($row['ops_id']);
1322            }
1323            if (!is_array($operations)) {
1324                $operations = array();
1325            }
1326
1327            $permissions = array_unique(array_merge($operations, $mtgr_permission));
1328
1329            // convert all values to integer
1330            foreach ($permissions as $key => $operation) {
1331                $permissions[$key] = (int) $operation;
1332            }
1333
1334            // Serialization des ops_id Arrays
1335            $ops_ids = serialize($permissions);
1336
1337            $query = 'DELETE FROM rbac_pa '
1338                   . 'WHERE rol_id = %s '
1339                   . 'AND ref_id = %s';
1340            $res = $ilDB->queryF(
1341                $query,
1342                array('integer', 'integer'),
1343                array($role, $ref_id)
1344            );
1345
1346            if (!count($permissions)) {
1347                continue;
1348            }
1349
1350            $ilDB->insert(
1351                'rbac_pa',
1352                array(
1353                    'rol_id' => array('integer', $role),
1354                    'ops_id' => array('text', $ops_ids),
1355                    'ref_id' => array('integer', $ref_id)
1356                )
1357            );
1358        }
1359    }
1360?>
1361<#3033>
1362<?php
1363    $ilCtrlStructureReader->getStructure();
1364?>
1365<#3034>
1366<?php
1367    $ilCtrlStructureReader->getStructure();
1368?>
1369<#3035>
1370<?php
1371    $ilDB->addTableColumn("ut_lp_marks", "status", array(
1372        "type" => "integer",
1373        "notnull" => true,
1374        "length" => 1,
1375        "default" => 0));
1376    $ilDB->addTableColumn("ut_lp_marks", "status_changed", array(
1377        "type" => "timestamp",
1378        "notnull" => false));
1379    $ilDB->addTableColumn("ut_lp_marks", "status_dirty", array(
1380        "type" => "integer",
1381        "notnull" => true,
1382        "length" => 1,
1383        "default" => 0));
1384    $ilDB->addTableColumn("ut_lp_marks", "percentage", array(
1385        "type" => "integer",
1386        "notnull" => true,
1387        "length" => 1,
1388        "default" => 0));
1389?>
1390<#3036>
1391<?php
1392    $ilDB->addIndex('mail_obj_data', array('user_id','m_type'), 'i1');
1393?>
1394<#3037>
1395<?php
1396$ilDB->addTableColumn('read_event', 'childs_read_count', array(
1397    "type" => "integer",
1398    "notnull" => true,
1399    "length" => 4,
1400    "default" => 0));
1401$ilDB->addTableColumn('read_event', 'childs_spent_seconds', array(
1402    "type" => "integer",
1403    "notnull" => true,
1404    "length" => 4,
1405    "default" => 0));
1406?>
1407<#3038>
1408<?php
1409  $ilDB->addIndex('addressbook', array('user_id','login','firstname','lastname'), 'i1');
1410?>
1411<#3039>
1412<?php
1413    $ilDB->addIndex('mail', array('sender_id','user_id'), 'i4');
1414?>
1415<#3040>
1416<?php
1417        $ilDB->addTableColumn("frm_settings", "new_post_title", array(
1418        "type" => "integer",
1419        "notnull" => true,
1420        "length" => 1,
1421        "default" => 0));
1422?>
1423<#3041>
1424<?php
1425// register new object type 'frma' for forum administration
1426 $id = $ilDB->nextId("object_data");
1427$ilDB->manipulateF(
1428    "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
1429        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
1430    array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
1431    array($id, "typ", "frma", "Forum administration", -1, ilUtil::now(), ilUtil::now())
1432);
1433$typ_id = $id;
1434
1435// create object data entry
1436$id = $ilDB->nextId("object_data");
1437$ilDB->manipulateF(
1438    "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
1439        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
1440    array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
1441    array($id, "frma", "__ForumAdministration", "Forum Administration", -1, ilUtil::now(), ilUtil::now())
1442);
1443
1444// create object reference entry
1445$ref_id = $ilDB->nextId('object_reference');
1446$res = $ilDB->manipulateF(
1447    "INSERT INTO object_reference (ref_id, obj_id) VALUES (%s, %s)",
1448    array("integer", "integer"),
1449    array($ref_id, $id)
1450);
1451
1452// put in tree
1453$tree = new ilTree(ROOT_FOLDER_ID);
1454$tree->insertNode($ref_id, SYSTEM_FOLDER_ID);
1455
1456// add rbac operations
1457// 1: edit_permissions, 2: visible, 3: read, 4:write
1458$ilDB->manipulateF(
1459    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
1460    array("integer", "integer"),
1461    array($typ_id, 1)
1462);
1463$ilDB->manipulateF(
1464    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
1465    array("integer", "integer"),
1466    array($typ_id, 2)
1467);
1468$ilDB->manipulateF(
1469    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
1470    array("integer", "integer"),
1471    array($typ_id, 3)
1472);
1473$ilDB->manipulateF(
1474    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
1475    array("integer", "integer"),
1476    array($typ_id, 4)
1477);
1478?>
1479<#3042>
1480<?php
1481    $ilCtrlStructureReader->getStructure();
1482?>
1483<#3043>
1484<?php
1485if (!$ilDB->tableExists('reg_registration_codes')) {
1486    $fields = array(
1487        'code_id' => array(
1488            'type' => 'integer',
1489            'length' => 4,
1490            'notnull' => true,
1491            'default' => 0),
1492
1493        'code' => array(
1494            'type' => 'text',
1495            'notnull' => false,
1496            'length' => 50,
1497            'fixed' => false),
1498
1499        'role' => array(
1500            'type' => 'integer',
1501            'notnull' => false,
1502            'length' => 4,
1503            'default' => 0),
1504
1505        'generated' => array(
1506            'type' => 'integer',
1507            'notnull' => false,
1508            'length' => 4,
1509            'default' => 0),
1510
1511        'used' => array(
1512            'type' => 'integer',
1513            'notnull' => true,
1514            'length' => 4,
1515            'default' => 0)
1516    );
1517    $ilDB->createTable('reg_registration_codes', $fields);
1518    $ilDB->addPrimaryKey('reg_registration_codes', array('code_id'));
1519    $ilDB->addIndex('reg_registration_codes', array('code'), 'i1');
1520    $ilDB->createSequence("reg_registration_codes");
1521}
1522?>
1523<#3044>
1524<?php
1525    $ilDB->update("settings", array("value" => array("integer", 0)), array("module" => array("text", "common"), "keyword" => array("text", "usr_settings_visib_reg_birthday")));
1526    $ilDB->update("settings", array("value" => array("integer", 0)), array("module" => array("text", "common"), "keyword" => array("text", "usr_settings_visib_reg_instant_messengers")));
1527?>
1528<#3045>
1529<?php
1530if (!$ilDB->tableExists('org_unit_data')) {
1531    $ilDB->createTable('org_unit_data', array(
1532            'ou_id' => array(
1533                'type' => 'integer',
1534                'length' => 4,
1535                'notnull' => true,
1536                'default' => 0
1537            ),
1538            'ou_title' => array(
1539                'type' => 'text',
1540                'length' => 128,
1541                'notnull' => false,
1542                'default' => null
1543            ),
1544            'ou_subtitle' => array(
1545                'type' => 'text',
1546                'length' => 128,
1547                'notnull' => false,
1548                'default' => null
1549            ),
1550            'ou_import_id' => array(
1551                'type' => 'text',
1552                'length' => 64,
1553                'notnull' => false,
1554                'default' => null
1555            )
1556    ));
1557    $ilDB->addPrimaryKey('org_unit_data', array('ou_id'));
1558    $ilDB->createSequence('org_unit_data');
1559    $root_unit_id = $ilDB->nextId('org_unit_data');
1560    $ilDB->insert('org_unit_data', array(
1561        'ou_id' => array('integer', $root_unit_id),
1562        'ou_title' => array('text', 'RootUnit')
1563    ));
1564}
1565
1566if (!$ilDB->tableExists('org_unit_tree')) {
1567    $ilDB->createTable('org_unit_tree', array(
1568            'tree' => array(
1569                'type' => 'integer',
1570                'length' => 4,
1571                'notnull' => true,
1572                'default' => 0
1573            ),
1574            'child' => array(
1575                'type' => 'integer',
1576                'length' => 4,
1577                'notnull' => true,
1578                'default' => 0
1579            ),
1580            'parent' => array(
1581                'type' => 'integer',
1582                'length' => 4,
1583                'notnull' => true,
1584                'default' => 0
1585            ),
1586            'lft' => array(
1587                'type' => 'integer',
1588                'length' => 4,
1589                'notnull' => true,
1590                'default' => 0
1591            ),
1592            'rgt' => array(
1593                'type' => 'integer',
1594                'length' => 4,
1595                'notnull' => true,
1596                'default' => 0
1597            ),
1598            'depth' => array(
1599                'type' => 'integer',
1600                'length' => 4,
1601                'notnull' => true,
1602                'default' => 0
1603            )
1604    ));
1605    $ilDB->addPrimaryKey('org_unit_tree', array('tree', 'child'));
1606    $ilDB->insert('org_unit_tree', array(
1607        'tree' => array('integer', 1),
1608        'child' => array('integer', $root_unit_id),
1609        'parent' => array('integer', 0),
1610        'lft' => array('integer', 1),
1611        'rgt' => array('integer', 2),
1612        'depth' => array('integer', 1)
1613    ));
1614}
1615
1616if (!$ilDB->tableExists('org_unit_assignments')) {
1617    $ilDB->createTable('org_unit_assignments', array(
1618            'oa_ou_id' => array(
1619                'type' => 'integer',
1620                'length' => 4,
1621                'notnull' => true,
1622                'default' => 0
1623            ),
1624            'oa_usr_id' => array(
1625                'type' => 'integer',
1626                'length' => 4,
1627                'notnull' => true,
1628                'default' => 0
1629            ),
1630            'oa_reporting_access' => array(
1631                'type' => 'integer',
1632                'length' => 4,
1633                'notnull' => true,
1634                'default' => 0
1635            ),
1636            'oa_cc_compl_invit' => array(
1637                'type' => 'integer',
1638                'length' => 4,
1639                'notnull' => true,
1640                'default' => 0
1641            ),
1642            'oa_cc_compl_not1' => array(
1643                'type' => 'integer',
1644                'length' => 4,
1645                'notnull' => true,
1646                'default' => 0
1647            ),
1648            'oa_cc_compl_not2' => array(
1649                'type' => 'integer',
1650                'length' => 4,
1651                'notnull' => true,
1652                'default' => 0
1653            )
1654    ));
1655    $ilDB->addPrimaryKey('org_unit_assignments', array('oa_ou_id', 'oa_usr_id'));
1656}
1657
1658?>
1659
1660<#3046>
1661<?php
1662    $ilDB->modifyTableColumn(
1663    'glossary_definition',
1664    'short_text',
1665    array("type" => "text", "length" => 4000, "notnull" => false)
1666);
1667?>
1668
1669<#3047>
1670<?php
1671$ilDB->addTableColumn('glossary', 'pres_mode', array(
1672    "type" => "text",
1673    "notnull" => true,
1674    "length" => 10,
1675    "default" => "table"));
1676?>
1677<#3048>
1678<?php
1679$ilDB->addTableColumn('glossary', 'snippet_length', array(
1680    "type" => "integer",
1681    "notnull" => true,
1682    "length" => 4,
1683    "default" => 200));
1684?>
1685
1686<#3049>
1687<?php
1688    $ilCtrlStructureReader->getStructure();
1689?>
1690
1691<#3050>
1692<?php
1693$ilDB->addTableColumn("glossary_definition", "short_text_dirty", array(
1694    "type" => "integer",
1695    "notnull" => true,
1696    "length" => 4,
1697    "default" => 0
1698    ));
1699?>
1700
1701<#3051>
1702<?php
1703if (!$ilDB->tableExists('table_templates')) {
1704    $ilDB->createTable('table_templates', array(
1705            'name' => array(
1706                'type' => 'text',
1707                'length' => 64,
1708                'notnull' => true
1709            ),
1710            'user_id' => array(
1711                'type' => 'integer',
1712                'length' => 4,
1713                'notnull' => true
1714            ),
1715            'context' => array(
1716                'type' => 'text',
1717                'length' => 128,
1718                'notnull' => true
1719            ),
1720            'value' => array(
1721                'type' => 'clob'
1722            )
1723    ));
1724    $ilDB->addPrimaryKey('table_templates', array('name', 'user_id', 'context'));
1725}
1726?>
1727
1728<#3052>
1729<?php
1730    $ilCtrlStructureReader->getStructure();
1731?>
1732
1733<#3053>
1734<?php
1735    $ilCtrlStructureReader->getStructure();
1736?>
1737<#3054>
1738<?php
1739$ilDB->addTableColumn('frm_settings', 'notification_type', array(
1740    "type" => "text",
1741    "notnull" => true,
1742    "length" => 10,
1743    "default" => "all_users"));
1744?>
1745<#3055>
1746<?php
1747    $ilDB->addTableColumn("udf_definition", "visible_lua", array(
1748        "type" => "integer",
1749        "length" => 1,
1750        "notnull" => true,
1751        "default" => 0
1752    ));
1753    $ilDB->addTableColumn("udf_definition", "changeable_lua", array(
1754        "type" => "integer",
1755        "length" => 1,
1756        "notnull" => true,
1757        "default" => 0
1758    ));
1759?>
1760<#3056>
1761<?php
1762    $ilCtrlStructureReader->getStructure();
1763?>
1764<#3057>
1765<?php
1766    $ilDB->addTableColumn("benchmark", "sql_stmt", array(
1767        "type" => "clob"
1768    ));
1769?>
1770<#3058>
1771<?php
1772    $ilDB->dropTable("ut_lp_filter", false);
1773?>
1774<#3059>
1775<?php
1776    $ilDB->modifyTableColumn(
1777    "exc_mem_ass_status",
1778    "u_comment",
1779    array("type" => "text", "length" => 4000, "notnull" => false)
1780);
1781?>
1782<#3060>
1783<?php
1784    // mail attachments
1785    $ilDB->addTableColumn(
1786        "mail",
1787        "attachments_tmp",
1788        array(
1789        "type" => "clob",
1790        "notnull" => false,
1791        "default" => null)
1792    );
1793
1794    $ilDB->manipulate('UPDATE mail SET attachments_tmp = attachments');
1795    $ilDB->dropTableColumn('mail', 'attachments');
1796    $ilDB->renameTableColumn("mail", "attachments_tmp", "attachments");
1797?>
1798<#3061>
1799<?php
1800    // mail_saved attachments
1801    $ilDB->addTableColumn(
1802        "mail_saved",
1803        "attachments_tmp",
1804        array(
1805        "type" => "clob",
1806        "notnull" => false,
1807        "default" => null)
1808    );
1809
1810    $ilDB->manipulate('UPDATE mail_saved SET attachments_tmp = attachments');
1811    $ilDB->dropTableColumn('mail_saved', 'attachments');
1812    $ilDB->renameTableColumn("mail_saved", "attachments_tmp", "attachments");
1813?>
1814<#3062>
1815<?php
1816    $ilDB->addTableColumn(
1817    'usr_search',
1818    'item_filter',
1819    array(
1820            'type' => 'text',
1821            'length' => 1000,
1822            'notnull' => false,
1823            'default' => null
1824        )
1825);
1826?>
1827<#3063>
1828<?php
1829    if ($ilDB->getDBType() == 'oracle') {
1830        // test sequence
1831        if (!$ilDB->tableColumnExists('tst_sequence', 'sequence_tmp')) {
1832            $ilDB->addTableColumn("tst_sequence", "sequence_tmp", array(
1833            "type" => "clob",
1834            "notnull" => false,
1835            "default" => null));
1836        }
1837    }
1838?>
1839<#3064>
1840<?php
1841    if ($ilDB->getDBType() == 'oracle') {
1842        $ilDB->manipulate('UPDATE tst_sequence SET sequence_tmp = sequence');
1843    }
1844?>
1845<#3065>
1846<?php
1847    if ($ilDB->getDBType() == 'oracle') {
1848        if ($ilDB->tableColumnExists('tst_sequence', 'sequence')) {
1849            $ilDB->dropTableColumn('tst_sequence', 'sequence');
1850        }
1851
1852        $ilDB->renameTableColumn("tst_sequence", "sequence_tmp", "sequence");
1853    }
1854?>
1855<#3066>
1856<?php
1857    if ($ilDB->getDBType() == 'mysql') {
1858        $ilDB->modifyTableColumn('tst_sequence', 'sequence', array("type" => "clob", "default" => null, "notnull" => false));
1859    }
1860?>
1861<#3067>
1862<?php
1863    $ilDB->modifyTableColumn('ut_lp_marks', 'u_comment', array('type' => 'text', 'default' => null, 'length' => 4000, 'notnull' => false));
1864?>
1865<#3068>
1866<?php
1867    $ilDB->addTableColumn('udf_definition', 'group_export', array('type' => 'integer','default' => 0,'length' => 1, 'notnull' => false));
1868?>
1869<#3069>
1870<?php
1871    $ilCtrlStructureReader->getStructure();
1872?>
1873<#3070>
1874<?php
1875    $ilDB->update(
1876    'rbac_operations',
1877    array('op_order' => array('integer', 200)),
1878    array('operation' => array('text','mail_visible'))
1879);
1880?>
1881<#3071>
1882<?php
1883    $ilDB->update(
1884    'rbac_operations',
1885    array('op_order' => array('integer', 210)),
1886    array('operation' => array('text','smtp_mail'))
1887);
1888?>
1889<#3072>
1890<?php
1891    $ilDB->update(
1892    'rbac_operations',
1893    array('op_order' => array('integer', 220)),
1894    array('operation' => array('text','system_message'))
1895);
1896?>
1897<#3073>
1898<?php
1899    $ilDB->update(
1900    'rbac_operations',
1901    array('op_order' => array('integer', 230)),
1902    array('operation' => array('text','mail_to_global_roles'))
1903);
1904?>
1905<#3074>
1906<?php
1907    $ilCtrlStructureReader->getStructure();
1908?>
1909<#3075>
1910<?php
1911    $ilCtrlStructureReader->getStructure();
1912?>
1913<#3076>
1914<?php
1915    $ilCtrlStructureReader->getStructure();
1916?>
1917<#3077>
1918<?php
1919if (!$ilDB->tableExists('notification')) {
1920    $ilDB->createTable('notification', array(
1921            'type' => array(
1922                'type' => 'integer',
1923                'length' => 1,
1924                'notnull' => true
1925            ),
1926            'id' => array(
1927                'type' => 'integer',
1928                'length' => 4,
1929                'notnull' => true
1930            ),
1931            'user_id' => array(
1932                'type' => 'integer',
1933                'length' => 4,
1934                'notnull' => true
1935            ),
1936            'last_mail' => array(
1937                'type' => 'timestamp',
1938                'notnull' => false
1939            )
1940    ));
1941    $ilDB->addPrimaryKey('notification', array('type', 'id', 'user_id'));
1942}
1943?>
1944<#3078>
1945<?php
1946    $ilCtrlStructureReader->getStructure();
1947?>
1948<#3079>
1949<?php
1950    $ilCtrlStructureReader->getStructure();
1951?>
1952<#3080>
1953<?php
1954    $ilCtrlStructureReader->getStructure();
1955?>
1956<#3081>
1957<?php
1958    $ilCtrlStructureReader->getStructure();
1959?>
1960<#3082>
1961<?php
1962    $ilDB->createTable('cal_rec_exclusion', array(
1963        'excl_id' => array(
1964            'type' => 'integer',
1965            'length' => 4,
1966            'notnull' => true
1967        ),
1968        'cal_id' => array(
1969            'type' => 'integer',
1970            'length' => 4,
1971            'notnull' => true
1972        ),
1973        'excl_date' => array(
1974            'type' => 'date',
1975            'notnull' => false,
1976        )
1977    ));
1978
1979    $ilDB->addPrimaryKey('cal_rec_exclusion', array('excl_id'));
1980    $ilDB->addIndex('cal_rec_exclusion', array('cal_id'), 'i1');
1981    $ilDB->createSequence('cal_rec_exclusion');
1982?>
1983<#3083>
1984<?php
1985
1986// new permission
1987$new_ops_id = $ilDB->nextId('rbac_operations');
1988$query = "INSERT INTO rbac_operations (operation,description,class,op_order) " .
1989    "VALUES( " .
1990    $ilDB->quote('add_consultation_hours', 'text') . ', ' .
1991    $ilDB->quote('Add Consultation Hours Calendar', 'text') . ", " .
1992    $ilDB->quote('object', 'text') . ", " .
1993    $ilDB->quote(300, 'integer') .
1994    ")";
1995$res = $ilDB->query($query);
1996
1997// Calendar settings
1998$query = "SELECT obj_id FROM object_data WHERE type = 'typ' AND title = 'cals' ";
1999$res = $ilDB->query($query);
2000$row = $res->fetchRow();
2001$cals = $row[0];
2002
2003
2004
2005$ilDB->manipulateF(
2006    'INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)',
2007    array('integer','integer'),
2008    array($cals, $new_ops_id)
2009);
2010
2011?>
2012<#3084>
2013<?php
2014    $ilCtrlStructureReader->getStructure();
2015?>
2016<#3085>
2017<?php
2018    $ilDB->createTable('rbac_log', array(
2019        'user_id' => array(
2020            'type' => 'integer',
2021            'length' => 4,
2022            'notnull' => true
2023        ),
2024        'created' => array(
2025            'type' => 'integer',
2026            'length' => 4,
2027            'notnull' => true
2028        ),
2029        'ref_id' => array(
2030            'type' => 'integer',
2031            'length' => 4,
2032            'notnull' => true
2033        ),
2034        'action' => array(
2035            'type' => 'integer',
2036            'length' => 1,
2037            'notnull' => true
2038        ),
2039        'data' => array(
2040            'type' => 'text',
2041            'length' => 4000
2042        )
2043    ));
2044    $ilDB->addIndex('rbac_log', array('ref_id'), 'i1');
2045?>
2046<#3086>
2047<?php
2048    $ilDB->createTable('booking_entry', array(
2049        'booking_id' => array(
2050            'type' => 'integer',
2051            'length' => 4,
2052            'notnull' => true
2053        ),
2054        'obj_id' => array(
2055            'type' => 'integer',
2056            'length' => 4,
2057            'notnull' => true
2058        ),
2059        'title' => array(
2060            'type' => 'text',
2061            'length' => 256,
2062            'notnull' => false
2063        ),
2064        'description' => array(
2065            'type' => 'text',
2066            'length' => 4000,
2067            'notnull' => false
2068        ),
2069        'location' => array(
2070            'type' => 'text',
2071            'length' => 512,
2072            'notnull' => false
2073        ),
2074        'deadline' => array(
2075            'type' => 'integer',
2076            'length' => 4,
2077            'notnull' => true
2078        ),
2079        'num_bookings' => array(
2080            'type' => 'integer',
2081            'length' => 4,
2082            'notnull' => true
2083        )
2084    ));
2085    $ilDB->addPrimaryKey('booking_entry', array('booking_id'));
2086    $ilDB->createSequence('booking_entry');
2087?>
2088<#3087>
2089<?php
2090    $ilCtrlStructureReader->getStructure();
2091?>
2092?>
2093<#3088>
2094<?php
2095    $ilDB->createTable('page_qst_answer', array(
2096        'qst_id' => array(
2097            'type' => 'integer',
2098            'length' => 4,
2099            'notnull' => true
2100        ),
2101        'user_id' => array(
2102            'type' => 'integer',
2103            'length' => 4,
2104            'notnull' => true
2105        ),
2106        'try' => array(
2107            'type' => 'integer',
2108            'length' => 1,
2109            'notnull' => true
2110        ),
2111        'passed' => array(
2112            'type' => 'integer',
2113            'length' => 1,
2114            'notnull' => true
2115        ),
2116        'points' => array(
2117            'type' => 'float',
2118            'notnull' => true
2119        )
2120    ));
2121    $ilDB->addPrimaryKey('page_qst_answer', array('qst_id', 'user_id'));
2122
2123?>
2124<#3089>
2125<?php
2126    $ilCtrlStructureReader->getStructure();
2127?>
2128<#3090>
2129<?php
2130if ($ilDB->tableColumnExists('booking_entry', 'title')) {
2131    $ilDB->dropTableColumn('booking_entry', 'title');
2132}
2133if ($ilDB->tableColumnExists('booking_entry', 'description')) {
2134    $ilDB->dropTableColumn('booking_entry', 'description');
2135}
2136if ($ilDB->tableColumnExists('booking_entry', 'location')) {
2137    $ilDB->dropTableColumn('booking_entry', 'location');
2138}
2139?>
2140<#3091>
2141<?php
2142    $ilCtrlStructureReader->getStructure();
2143?>
2144<#3092>
2145<?php
2146$fields = array(
2147    'id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
2148    'user_id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
2149    'order_nr' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
2150    'title' => array('type' => 'text', 'length' => 200)
2151);
2152
2153$ilDB->createTable('usr_ext_profile_page', $fields);
2154$ilDB->addPrimaryKey('usr_ext_profile_page', array('id'));
2155$ilDB->createSequence("usr_ext_profile_page");
2156
2157?>
2158<#3093>
2159<?php
2160    $ilCtrlStructureReader->getStructure();
2161?>
2162<#3094>
2163<?php
2164    $ilCtrlStructureReader->getStructure();
2165?>
2166
2167<#3095>
2168<?php
2169if (!$ilDB->tableExists('booking_user')) {
2170    $ilDB->createTable('booking_user', array(
2171        'entry_id' => array(
2172            'type' => 'integer',
2173            'length' => 4,
2174            'notnull' => true
2175        ),
2176        'user_id' => array(
2177            'type' => 'integer',
2178            'length' => 4,
2179            'notnull' => true
2180        ),
2181        'tstamp' => array(
2182            'type' => 'integer',
2183            'length' => 4,
2184            'notnull' => true
2185        )
2186    ));
2187    $ilDB->addPrimaryKey('booking_user', array('entry_id', 'user_id'));
2188}
2189?>
2190<#3096>
2191<?php
2192    if (!$ilDB->tableColumnExists('crs_settings', 'reg_ac_enabled')) {
2193        $ilDB->addTableColumn('crs_settings', 'reg_ac_enabled', array(
2194            'type' => 'integer',
2195            'notnull' => true,
2196            'length' => 1,
2197            'default' => 0
2198        ));
2199
2200        $ilDB->addTableColumn('crs_settings', 'reg_ac', array(
2201            'type' => 'text',
2202            'notnull' => false,
2203            'length' => 32
2204        ));
2205    }
2206?>
2207
2208<#3097>
2209<?php
2210    if (!$ilDB->tableColumnExists('grp_settings', 'reg_ac_enabled')) {
2211        $ilDB->addTableColumn('grp_settings', 'reg_ac_enabled', array(
2212            'type' => 'integer',
2213            'notnull' => true,
2214            'length' => 1,
2215            'default' => 0
2216        ));
2217
2218        $ilDB->addTableColumn('grp_settings', 'reg_ac', array(
2219            'type' => 'text',
2220            'notnull' => false,
2221            'length' => 32
2222        ));
2223    }
2224?>
2225<#3098>
2226<?php
2227    if ($ilDB->tableColumnExists("frm_settings", "new_post_title")) {
2228        $ilDB->renameTableColumn('frm_settings', 'new_post_title', 'preset_subject');
2229    }
2230?>
2231<#3099>
2232<?php
2233        $ilDB->addTableColumn("frm_settings", "add_re_subject", array(
2234        "type" => "integer",
2235        "notnull" => true,
2236        "length" => 1,
2237        "default" => 0));
2238?>
2239<#3100>
2240<?php
2241    $ilCtrlStructureReader->getStructure();
2242?>
2243<#3101>
2244<?php
2245    $ilDB->addTableColumn('il_object_def', 'export', array(
2246        'type' => 'integer',
2247        'notnull' => true,
2248        'length' => 1,
2249        'default' => 0
2250    ));
2251?>
2252<#3102>
2253<?php
2254if (!$ilDB->tableExists('booking_type')) {
2255    $ilDB->createTable('booking_type', array(
2256        'booking_type_id' => array(
2257            'type' => 'integer',
2258            'length' => 4,
2259            'notnull' => true
2260        ),
2261        'title' => array(
2262            'type' => 'text',
2263            'length' => 255,
2264            'notnull' => true
2265        ),
2266        'pool_id' => array(
2267            'type' => 'integer',
2268            'length' => 4,
2269            'notnull' => true
2270        )
2271    ));
2272    $ilDB->addPrimaryKey('booking_type', array('booking_type_id'));
2273    $ilDB->createSequence('booking_type');
2274}
2275?>
2276<#3103>
2277<?php
2278if (!$ilDB->tableExists('export_file_info')) {
2279    $ilDB->createTable('export_file_info', array(
2280        'obj_id' => array(
2281            'type' => 'integer',
2282            'length' => 4,
2283            'notnull' => true
2284        ),
2285        'export_type' => array(
2286            'type' => 'text',
2287            'length' => 32,
2288            'notnull' => false
2289        ),
2290        'file_name' => array(
2291            'type' => 'text',
2292            'length' => 64,
2293            'notnull' => false
2294        ),
2295        'version' => array(
2296            'type' => 'text',
2297            'length' => 16,
2298            'notnull' => false
2299        ),
2300        'create_date' => array(
2301            'type' => 'timestamp',
2302            'notnull' => true
2303        )
2304    ));
2305    $ilDB->addPrimaryKey('export_file_info', array('obj_id','export_type','file_name'));
2306    $ilDB->addIndex('export_file_info', array('create_date'), 'i1');
2307}
2308?>
2309<#3104>
2310<?php
2311if (!$ilDB->tableExists('export_options')) {
2312    $ilDB->createTable('export_options', array(
2313        'export_id' => array(
2314            'type' => 'integer',
2315            'length' => 2,
2316            'notnull' => true
2317        ),
2318        'keyword' => array(
2319            'type' => 'integer',
2320            'length' => 2,
2321            'notnull' => true
2322        ),
2323        'ref_id' => array(
2324            'type' => 'integer',
2325            'length' => 4,
2326            'notnull' => true
2327        ),
2328        'obj_id' => array(
2329            'type' => 'integer',
2330            'length' => 4,
2331            'notnull' => true
2332        ),
2333        'value' => array(
2334            'type' => 'text',
2335            'length' => 32,
2336            'notnull' => false
2337        )
2338    ));
2339    $ilDB->addPrimaryKey('export_options', array('export_id','keyword','ref_id'));
2340}
2341?>
2342<#3105>
2343<?php
2344    $ilCtrlStructureReader->getStructure();
2345?>
2346<#3106>
2347<?php
2348    $ilCtrlStructureReader->getStructure();
2349?>
2350<#3107>
2351<?php
2352    if (!$ilDB->tableColumnExists('svy_qst_mc', 'use_other_answer')) {
2353        $ilDB->addTableColumn("svy_qst_mc", "use_other_answer", array("type" => "integer", "length" => 2, "notnull" => false));
2354        $ilDB->addTableColumn("svy_qst_mc", "other_answer_label", array("type" => "text", "length" => 255, "notnull" => false, "default" => null));
2355    }
2356?>
2357<#3108>
2358<?php
2359    if (!$ilDB->tableColumnExists('svy_qst_sc', 'use_other_answer')) {
2360        $ilDB->addTableColumn("svy_qst_sc", "use_other_answer", array("type" => "integer", "length" => 2, "notnull" => false));
2361        $ilDB->addTableColumn("svy_qst_sc", "other_answer_label", array("type" => "text", "length" => 255, "notnull" => false, "default" => null));
2362    }
2363?>
2364<#3109>
2365<?php
2366    if (!$ilDB->tableColumnExists('svy_category', 'scale')) {
2367        $ilDB->addTableColumn("svy_category", "scale", array("type" => "integer", "length" => 4, "notnull" => false, "default" => null));
2368    }
2369?>
2370<#3110>
2371<?php
2372    if (!$ilDB->tableColumnExists('svy_category', 'other')) {
2373        $ilDB->addTableColumn("svy_category", "other", array("type" => "integer", "length" => 2, "notnull" => true, "default" => 0));
2374    }
2375?>
2376<#3111>
2377<?php
2378    if ($ilDB->tableColumnExists('svy_qst_mc', 'other_answer_label')) {
2379        $ilDB->dropTableColumn('svy_qst_mc', 'other_answer_label');
2380    }
2381?>
2382<#3112>
2383<?php
2384    if ($ilDB->tableColumnExists('svy_qst_sc', 'other_answer_label')) {
2385        $ilDB->dropTableColumn('svy_qst_sc', 'other_answer_label');
2386    }
2387?>
2388<#3113>
2389<?php
2390    $ilDB->addIndex('svy_category', array('other'), 'i2');
2391?>
2392<#3114>
2393<?php
2394    $ilDB->dropIndex('svy_category', 'i2');
2395?>
2396<#3115>
2397<?php
2398    if ($ilDB->tableColumnExists('svy_category', 'scale')) {
2399        $ilDB->dropTableColumn('svy_category', 'scale');
2400    }
2401?>
2402<#3116>
2403<?php
2404    if ($ilDB->tableColumnExists('svy_category', 'other')) {
2405        $ilDB->dropTableColumn('svy_category', 'other');
2406    }
2407?>
2408<#3117>
2409<?php
2410    if (!$ilDB->tableColumnExists('svy_variable', 'other')) {
2411        $ilDB->addTableColumn("svy_variable", "other", array("type" => "integer", "length" => 2, "notnull" => true, "default" => 0));
2412    }
2413?>
2414<#3118>
2415<?php
2416    if ($ilDB->tableColumnExists('svy_qst_mc', 'use_other_answer')) {
2417        $ilDB->dropTableColumn('svy_qst_mc', 'use_other_answer');
2418    }
2419?>
2420<#3119>
2421<?php
2422    if ($ilDB->tableColumnExists('svy_qst_sc', 'use_other_answer')) {
2423        $ilDB->dropTableColumn('svy_qst_sc', 'use_other_answer');
2424    }
2425?>
2426<#3120>
2427<?php
2428    if (!$ilDB->tableColumnExists('svy_qst_mc', 'use_min_answers')) {
2429        $ilDB->addTableColumn("svy_qst_mc", "use_min_answers", array("type" => "integer", "length" => 1, "notnull" => true, "default" => 0));
2430        $ilDB->addTableColumn("svy_qst_mc", "nr_min_answers", array("type" => "integer", "length" => 2, "notnull" => false));
2431    }
2432?>
2433<#3121>
2434<?php
2435    if (!$ilDB->tableColumnExists('svy_qst_matrixrows', 'other')) {
2436        $ilDB->addTableColumn("svy_qst_matrixrows", "other", array("type" => "integer", "length" => 1, "notnull" => true, "default" => 0));
2437    }
2438?>
2439<#3122>
2440<?php
2441    if (!$ilDB->tableColumnExists('svy_question', 'label')) {
2442        $ilDB->addTableColumn("svy_question", "label", array("type" => "text", "length" => 255, "notnull" => false));
2443    }
2444?>
2445<#3123>
2446<?php
2447    if (!$ilDB->tableColumnExists('svy_qst_matrixrows', 'label')) {
2448        $ilDB->addTableColumn("svy_qst_matrixrows", "label", array("type" => "text", "length" => 255, "notnull" => false));
2449    }
2450?>
2451<#3124>
2452<?php
2453    if (!$ilDB->tableColumnExists('svy_variable', 'scale')) {
2454        $ilDB->addTableColumn("svy_variable", "scale", array("type" => "integer", "length" => 3, "notnull" => false));
2455    }
2456?>
2457<#3125>
2458<?php
2459    if (!$ilDB->tableColumnExists('svy_svy', 'mailnotification')) {
2460        $ilDB->addTableColumn("svy_svy", "mailnotification", array("type" => "integer", "length" => 1, "notnull" => false));
2461    }
2462    if (!$ilDB->tableColumnExists('svy_svy', 'mailaddresses')) {
2463        $ilDB->addTableColumn("svy_svy", "mailaddresses", array("type" => "text", "length" => 2000, "notnull" => false));
2464    }
2465    if (!$ilDB->tableColumnExists('svy_svy', 'mailparticipantdata')) {
2466        $ilDB->addTableColumn("svy_svy", "mailparticipantdata", array("type" => "text", "length" => 4000, "notnull" => false));
2467    }
2468?>
2469<#3126>
2470<?php
2471    if (!$ilDB->tableColumnExists('svy_anonymous', 'externaldata')) {
2472        $ilDB->addTableColumn("svy_anonymous", "externaldata", array("type" => "text", "length" => 4000, "notnull" => false));
2473    }
2474?>
2475<#3127>
2476<?php
2477    if (!$ilDB->tableColumnExists('svy_constraint', 'conjunction')) {
2478        $ilDB->addTableColumn("svy_constraint", "conjunction", array("type" => "integer", "length" => 2, "default" => 0, "notnull" => true));
2479    }
2480?>
2481<#3128>
2482<?php
2483    $ilCtrlStructureReader->getStructure();
2484?>
2485<#3129>
2486<?php
2487if (!$ilDB->tableExists('booking_object')) {
2488    $ilDB->createTable('booking_object', array(
2489        'booking_object_id' => array(
2490            'type' => 'integer',
2491            'length' => 4,
2492            'notnull' => true
2493        ),
2494        'title' => array(
2495            'type' => 'text',
2496            'length' => 255,
2497            'notnull' => true
2498        ),
2499        'type_id' => array(
2500            'type' => 'integer',
2501            'length' => 4,
2502            'notnull' => true
2503        )
2504    ));
2505    $ilDB->addPrimaryKey('booking_object', array('booking_object_id'));
2506    $ilDB->createSequence('booking_object');
2507}
2508?>
2509
2510<#3130>
2511<?php
2512    @rename(CLIENT_DATA_DIR . DIRECTORY_SEPARATOR . 'ilFiles', CLIENT_DATA_DIR . DIRECTORY_SEPARATOR . 'ilFile');
2513?>
2514<#3131>
2515<?php
2516    @rename(CLIENT_DATA_DIR . DIRECTORY_SEPARATOR . 'ilEvents', CLIENT_DATA_DIR . DIRECTORY_SEPARATOR . 'ilSession');
2517?>
2518
2519<#3132>
2520<?php
2521function dirRek($dir)
2522{
2523    $dp = @opendir($dir);
2524    while ($file = @readdir($dp)) {
2525        if ($file == '.' or $file == '..') {
2526            continue;
2527        }
2528        if (substr($file, 0, 7) == 'course_') {
2529            $parts = explode('_', $file);
2530            @rename($dir . $file, $dir . 'crs_' . $parts[1]);
2531            continue;
2532        }
2533        if (is_dir($dir . $file)) {
2534            dirRek($dir . $file . DIRECTORY_SEPARATOR);
2535        }
2536    }
2537    @closedir($dp);
2538}
2539
2540$dir = CLIENT_DATA_DIR . DIRECTORY_SEPARATOR . 'ilCourses' . DIRECTORY_SEPARATOR;
2541dirRek($dir);
2542?>
2543<#3133>
2544<?php
2545    @rename(CLIENT_DATA_DIR . DIRECTORY_SEPARATOR . 'ilCourses', CLIENT_DATA_DIR . DIRECTORY_SEPARATOR . 'ilCourse');
2546?>
2547
2548<#3134>
2549<?php
2550    $set = $ilDB->query("SELECT obj_id FROM bookmark_data WHERE " .
2551        " obj_id = " . $ilDB->quote(1, "integer"));
2552    $rec = $ilDB->fetchAssoc($set);
2553    if ($rec["obj_id"] != 1) {
2554        $ilDB->manipulate("INSERT INTO bookmark_data " .
2555            "(obj_id, user_id, title, description, target, type) VALUES (" .
2556            $ilDB->quote(1, "integer") . "," .
2557            $ilDB->quote(0, "integer") . "," .
2558            $ilDB->quote("dummy_folder", "text") . "," .
2559            $ilDB->quote("", "text") . "," .
2560            $ilDB->quote("", "text") . "," .
2561            $ilDB->quote("bmf", "text") .
2562            ")");
2563    }
2564?>
2565
2566<#3135>
2567<?php
2568    $ilCtrlStructureReader->getStructure();
2569?>
2570<#3136>
2571<?php
2572    $setting = new ilSetting();
2573    $se_db = (int) $setting->get("se_db");
2574
2575    if ($se_db <= 101) {
2576        $set = $ilDB->query("SELECT * FROM object_data WHERE type = 'sty'");
2577        while ($rec = $ilDB->fetchAssoc($set)) {	// all styles
2578            $ast = array(
2579                array("tag" => "a", "type" => "link", "class" => "FileLink",
2580                    "par" => array(
2581                        array("name" => "text-decoration", "value" => "undeline"),
2582                        array("name" => "font-weight", "value" => "normal"),
2583                        array("name" => "color", "value" => "blue")
2584                        )),
2585                array("tag" => "div", "type" => "glo_overlay", "class" => "GlossaryOverlay",
2586                    "par" => array(
2587                        array("name" => "background-color", "value" => "#FFFFFF"),
2588                        array("name" => "border-color", "value" => "#A0A0A0"),
2589                        array("name" => "border-style", "value" => "solid"),
2590                        array("name" => "border-width", "value" => "2px"),
2591                        array("name" => "padding-top", "value" => "5px"),
2592                        array("name" => "padding-bottom", "value" => "5px"),
2593                        array("name" => "padding-left", "value" => "5px"),
2594                        array("name" => "padding-right", "value" => "5px")
2595                        ))
2596                );
2597
2598            foreach ($ast as $st) {
2599                $set2 = $ilDB->query("SELECT * FROM style_char WHERE " .
2600                    "style_id = " . $ilDB->quote($rec["obj_id"], "integer") . " AND " .
2601                    "characteristic = " . $ilDB->quote($st["class"], "text") . " AND " .
2602                    "type = " . $ilDB->quote($st["type"], "text"));
2603                if (!$ilDB->fetchAssoc($set2)) {
2604                    $q = "INSERT INTO style_char (style_id, type, characteristic, hide)" .
2605                        " VALUES (" .
2606                        $ilDB->quote($rec["obj_id"], "integer") . "," .
2607                        $ilDB->quote($st["type"], "text") . "," .
2608                        $ilDB->quote($st["class"], "text") . "," .
2609                        $ilDB->quote(0, "integer") . ")";
2610                    //echo "<br>-$q-";
2611                    $ilDB->manipulate($q);
2612                    foreach ($st["par"] as $par) {
2613                        $spid = $ilDB->nextId("style_parameter");
2614                        $q = "INSERT INTO style_parameter (id, style_id, type, class, tag, parameter, value)" .
2615                            " VALUES (" .
2616                            $ilDB->quote($spid, "integer") . "," .
2617                            $ilDB->quote($rec["obj_id"], "integer") . "," .
2618                            $ilDB->quote($st["type"], "text") . "," .
2619                            $ilDB->quote($st["class"], "text") . "," .
2620                            $ilDB->quote($st["tag"], "text") . "," .
2621                            $ilDB->quote($par["name"], "text") . "," .
2622                            $ilDB->quote($par["value"], "text") .
2623                            ")";
2624                        //echo "<br>-$q-";
2625                        $ilDB->manipulate($q);
2626                    }
2627                }
2628            }
2629        }
2630    }
2631
2632?>
2633
2634<#3137>
2635<?php
2636    $setting = new ilSetting();
2637    $se_db = (int) $setting->get("se_db");
2638
2639    if ($se_db <= 102) {
2640        include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
2641        ilDBUpdate3136::copyStyleClass("IntLink", "GlossaryLink", "link", "a");
2642    }
2643
2644?>
2645
2646<#3138>
2647<?php
2648    $setting = new ilSetting();
2649    $se_db = (int) $setting->get("se_db");
2650
2651    if ($se_db <= 103) {
2652        include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
2653        ilDBUpdate3136::addStyleClass(
2654            "GlossaryOvTitle",
2655            "glo_ovtitle",
2656            "h1",
2657            array("font-size" => "120%",
2658                          "margin-bottom" => "10px",
2659                          "margin-top" => "10px",
2660                          "font-weight" => "normal"
2661                          )
2662        );
2663    }
2664?>
2665
2666<#3139>
2667<?php
2668    $setting = new ilSetting();
2669    $se_db = (int) $setting->get("se_db");
2670
2671    if ($se_db <= 104) {
2672        include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
2673        ilDBUpdate3136::addStyleClass(
2674            "GlossaryOvCloseLink",
2675            "glo_ovclink",
2676            "a",
2677            array("text-decoration" => "underline",
2678                          "font-weight" => "normal",
2679                          "color" => "blue"
2680                          )
2681        );
2682        ilDBUpdate3136::addStyleClass(
2683            "GlossaryOvUnitGloLink",
2684            "glo_ovuglink",
2685            "a",
2686            array("text-decoration" => "underline",
2687                          "font-weight" => "normal",
2688                          "color" => "blue"
2689                          )
2690        );
2691        ilDBUpdate3136::addStyleClass(
2692            "GlossaryOvUGListLink",
2693            "glo_ovuglistlink",
2694            "a",
2695            array("text-decoration" => "underline",
2696                          "font-weight" => "normal",
2697                          "color" => "blue"
2698                          )
2699        );
2700    }
2701
2702?>
2703<#3140>
2704<?php
2705if (!$ilDB->tableExists('booking_schedule')) {
2706    $ilDB->createTable('booking_schedule', array(
2707        'booking_schedule_id' => array(
2708            'type' => 'integer',
2709            'length' => 4,
2710            'notnull' => true
2711        ),
2712        'title' => array(
2713            'type' => 'text',
2714            'length' => 255,
2715            'notnull' => true
2716        ),
2717        'pool_id' => array(
2718            'type' => 'integer',
2719            'length' => 4,
2720            'notnull' => true
2721        ),
2722        'deadline' => array(
2723            'type' => 'integer',
2724            'length' => 4,
2725            'notnull' => false
2726        ),
2727        'rent_min' => array(
2728            'type' => 'integer',
2729            'length' => 4,
2730            'notnull' => false
2731        ),
2732        'rent_max' => array(
2733            'type' => 'integer',
2734            'length' => 4,
2735            'notnull' => false
2736        ),
2737        'raster' => array(
2738            'type' => 'integer',
2739            'length' => 4,
2740            'notnull' => false
2741        ),
2742        'auto_break' => array(
2743            'type' => 'integer',
2744            'length' => 4,
2745            'notnull' => false
2746        ),
2747        'definition' => array(
2748            'type' => 'text',
2749            'length' => 500,
2750            'notnull' => true,
2751            'fixed' => false
2752        )
2753    ));
2754    $ilDB->addPrimaryKey('booking_schedule', array('booking_schedule_id'));
2755    $ilDB->createSequence('booking_schedule');
2756}
2757?>
2758<#3141>
2759<?php
2760
2761    $ilDB->addTableColumn("usr_data", "sel_country", array(
2762        "type" => "text",
2763        "notnull" => false,
2764        "default" => "",
2765        "length" => 2
2766        ));
2767
2768?>
2769<#3142>
2770<?php
2771
2772    $ilDB->addTableColumn("booking_type", "schedule_id", array(
2773        "type" => "integer",
2774        "notnull" => false,
2775        "length" => 4
2776        ));
2777
2778?>
2779<#3143>
2780<?php
2781
2782    $ilDB->addTableColumn("booking_object", "schedule_id", array(
2783        "type" => "integer",
2784        "notnull" => false,
2785        "length" => 4
2786        ));
2787
2788?>
2789
2790
2791<#3144>
2792<?php
2793
2794$id = $ilDB->nextId('object_data');
2795
2796// register new object type 'book' for booking manager
2797$query = "INSERT INTO object_data (obj_id,type, title, description, owner, create_date, last_update) " .
2798        "VALUES (" . $ilDB->quote($id, 'integer') . "," . $ilDB->quote('typ', 'text') .
2799        ", " . $ilDB->quote('book', 'text') . ", " . $ilDB->quote('Booking Manager', 'text') .
2800        ", " . $ilDB->quote(-1, 'integer') . ", " . $ilDB->now() . ", " . $ilDB->now() . ")";
2801$this->db->query($query);
2802
2803$query = "SELECT obj_id FROM object_data WHERE type = " . $ilDB->quote('typ', 'text') .
2804    " AND title = " . $ilDB->quote('book', 'text');
2805$res = $this->db->query($query);
2806$row = $res->fetchRow();
2807$typ_id = $row[0];
2808
2809// add rbac operations for booking object
2810// 1: edit_permissions, 2: visible, 3: read, 4:write
2811$query = "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (" . $ilDB->quote($typ_id, 'integer') .
2812    "," . $ilDB->quote(1, 'integer') . ")";
2813$this->db->query($query);
2814$query = "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (" . $ilDB->quote($typ_id, 'integer') .
2815    "," . $ilDB->quote(2, 'integer') . ")";
2816$this->db->query($query);
2817$query = "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (" . $ilDB->quote($typ_id, 'integer') .
2818    "," . $ilDB->quote(3, 'integer') . ")";
2819$this->db->query($query);
2820$query = "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (" . $ilDB->quote($typ_id, 'integer') .
2821    "," . $ilDB->quote(4, 'integer') . ")";
2822$this->db->query($query);
2823?>
2824
2825<#3145>
2826<?php
2827    $setting = new ilSetting();
2828    $setting->set("usr_settings_hide_sel_country", 1);
2829    $setting->set("usr_settings_disable_sel_country", 1);
2830    $setting->set("usr_settings_visib_reg_sel_country", 0);
2831    $setting->set("usr_settings_visib_lua_sel_country", 0);
2832    $setting->set("usr_settings_changeable_lua_sel_country", 0);
2833?>
2834
2835<#3146>
2836<?php
2837if (!$ilDB->tableExists('cal_registrations')) {
2838    $ilDB->createTable('cal_registrations', array(
2839        'cal_id' => array(
2840            'type' => 'integer',
2841            'length' => 4,
2842            'notnull' => true
2843        ),
2844        'usr_id' => array(
2845            'type' => 'integer',
2846            'length' => 4,
2847            'notnull' => true
2848        )
2849    ));
2850    $ilDB->addPrimaryKey('cal_registrations', array('cal_id', 'usr_id'));
2851}
2852?>
2853
2854<#3147>
2855<?php
2856if (!$ilDB->tableExists('booking_reservation')) {
2857    $ilDB->createTable('booking_reservation', array(
2858        'booking_reservation_id' => array(
2859            'type' => 'integer',
2860            'length' => 4,
2861            'notnull' => true
2862        ),
2863        'user_id' => array(
2864            'type' => 'integer',
2865            'length' => 4,
2866            'notnull' => true
2867        ),
2868        'object_id' => array(
2869            'type' => 'integer',
2870            'length' => 4,
2871            'notnull' => true
2872        ),
2873        'date_from' => array(
2874            'type' => 'integer',
2875            'length' => 4,
2876            'notnull' => true
2877        ),
2878        'date_to' => array(
2879            'type' => 'integer',
2880            'length' => 4,
2881            'notnull' => true
2882        ),
2883        'status' => array(
2884            'type' => 'integer',
2885            'length' => 2,
2886            'notnull' => false
2887        )
2888    ));
2889    $ilDB->addPrimaryKey('booking_reservation', array('booking_reservation_id'));
2890    $ilDB->createSequence('booking_reservation');
2891}
2892?>
2893<#3148>
2894<?php
2895    $ilDB->addTableColumn("cal_registrations", "dstart", array(
2896        "type" => "integer",
2897        "notnull" => true,
2898        "default" => 0,
2899        "length" => 4
2900        ));
2901
2902    $ilDB->addTableColumn("cal_registrations", "dend", array(
2903        "type" => "integer",
2904        "notnull" => true,
2905        "default" => 0,
2906        "length" => 4
2907        ));
2908
2909    $ilDB->dropPrimaryKey('cal_registrations');
2910    $ilDB->addPrimaryKey('cal_registrations', array('cal_id', 'usr_id','dstart','dend'));
2911?>
2912<#3149>
2913<?php
2914    $ilDB->addTableColumn("svy_anonymous", "sent", array(
2915        "type" => "integer",
2916        "notnull" => true,
2917        "default" => 0,
2918        "length" => 2
2919        ));
2920?>
2921<#3150>
2922<?php
2923    $ilDB->addIndex('svy_anonymous', array('sent'), 'i3');
2924?>
2925
2926<#3151>
2927<?php
2928if (!$ilDB->tableExists('booking_settings')) {
2929    $ilDB->createTable('booking_settings', array(
2930        'booking_pool_id' => array(
2931            'type' => 'integer',
2932            'length' => 4,
2933            'notnull' => true
2934        ),
2935        'public_log' => array(
2936            'type' => 'integer',
2937            'length' => 1,
2938            'notnull' => false
2939        ),
2940        'pool_offline' => array(
2941            'type' => 'integer',
2942            'length' => 1,
2943            'notnull' => false
2944        )
2945    ));
2946    $ilDB->addPrimaryKey('booking_settings', array('booking_pool_id'));
2947}
2948?>
2949<#3152>
2950<?php
2951    $ilDB->addTableColumn("qpl_qst_essay", "matchcondition", array(
2952        "type" => "integer",
2953        "notnull" => true,
2954        "default" => 0,
2955        "length" => 2
2956        ));
2957?>
2958
2959<#3153>
2960<?php
2961    $ilDB->addTableColumn("booking_settings", "slots_no", array(
2962        "type" => "integer",
2963        "notnull" => false,
2964        "default" => 0,
2965        "length" => 2
2966        ));
2967?>
2968<#3154>
2969<?php
2970
2971    $permission_ordering = array(
2972        'visible' => 1000,
2973        'join' => 1200,
2974        'leave' => 1400,
2975        'read' => 2000,
2976        'edit_content' => 3000,
2977        'add_thread' => 3100,
2978        'edit_event' => 3600,
2979        'moderate' => 3700,
2980        'moderate_frm' => 3750,
2981        'edit_learning_progress' => 3600,
2982        'copy' => 4000,
2983        'write' => 6000,
2984        'read_users' => 7000,
2985        'cat_administrate_users' => 7050,
2986        'invite' => 7200,
2987        'tst_statistics' => 7100,
2988        'delete' => 8000,
2989        'edit_permission' => 9000
2990    );
2991
2992    foreach ($permission_ordering as $op => $order) {
2993        $query = "UPDATE rbac_operations SET " .
2994            'op_order = ' . $ilDB->quote($order, 'integer') . ' ' .
2995            'WHERE operation = ' . $ilDB->quote($op, 'text') . ' ';
2996        $ilDB->manipulate($query);
2997    }
2998?>
2999
3000<#3155>
3001<?php
3002    if ($ilDB->tableColumnExists('svy_svy', 'mailaddresses')) {
3003        $ilDB->dropTableColumn('svy_svy', 'mailaddresses');
3004    }
3005    if ($ilDB->tableColumnExists('svy_svy', 'mailparticipantdata')) {
3006        $ilDB->dropTableColumn('svy_svy', 'mailparticipantdata');
3007    }
3008?>
3009<#3156>
3010<?php
3011    if (!$ilDB->tableColumnExists('svy_svy', 'mailaddresses')) {
3012        $ilDB->addTableColumn("svy_svy", "mailaddresses", array("type" => "text", "length" => 2000, "notnull" => false));
3013        $ilDB->addTableColumn("svy_svy", "mailparticipantdata", array("type" => "text", "length" => 4000, "notnull" => false));
3014    }
3015?>
3016
3017<#3157>
3018<?php
3019    if (!$ilDB->tableColumnExists('svy_qst_mc', 'nr_max_answers')) {
3020        $ilDB->addTableColumn("svy_qst_mc", "nr_max_answers", array("type" => "integer", "length" => 2, "notnull" => false));
3021    }
3022?>
3023<#3158>
3024<?php
3025if (!$ilDB->tableExists('svy_times')) {
3026    $ilDB->createTable('svy_times', array(
3027        'finished_fi' => array(
3028            'type' => 'integer',
3029            'length' => 4,
3030            'notnull' => true
3031        ),
3032        'entered_page' => array(
3033            'type' => 'integer',
3034            'length' => 4,
3035            'notnull' => false
3036        ),
3037        'left_page' => array(
3038            'type' => 'integer',
3039            'length' => 4,
3040            'notnull' => false
3041        )
3042    ));
3043    $ilDB->addIndex('svy_times', array('finished_fi'), 'i1');
3044}
3045?>
3046
3047<#3159>
3048<?php
3049    $query = 'UPDATE rbac_operations SET op_order = ' . $ilDB->quote(9999, 'integer') . ' WHERE class = ' . $ilDB->quote('create', 'text');
3050    $ilDB->manipulate($query);
3051?>
3052
3053<#3160>
3054<?php
3055
3056// add create operation for booking pools
3057
3058$ops_id = $ilDB->nextId('rbac_operations');
3059
3060$query = 'INSERT INTO rbac_operations (ops_id, operation, class, description, op_order)' .
3061    ' VALUES (' . $ilDB->quote($ops_id, 'integer') . ',' . $ilDB->quote('create_book', 'text') .
3062    ',' . $ilDB->quote('create', 'text') . ',' . $ilDB->quote('create booking pool', 'text') .
3063    ',' . $ilDB->quote(9999, 'integer') . ')';
3064$ilDB->query($query);
3065
3066// add create booking pool for root,crs,cat,fold and grp
3067foreach (array('cat', 'crs', 'grp', 'fold', 'root') as $type) {
3068    $query = 'SELECT obj_id FROM object_data WHERE type=' . $ilDB->quote('typ', 'text') .
3069        ' AND title=' . $ilDB->quote($type, 'text');
3070    $res = $ilDB->query($query);
3071    $row = $ilDB->fetchAssoc($res);
3072    $typ_id = $row['obj_id'];
3073
3074    $query = 'INSERT INTO rbac_ta (typ_id, ops_id) VALUES (' . $ilDB->quote($typ_id, 'integer') .
3075        ',' . $ilDB->quote($ops_id, 'integer') . ')';
3076    $ilDB->query($query);
3077}
3078
3079?>
3080<#3161>
3081<?php
3082    $ilCtrlStructureReader->getStructure();
3083?>
3084<#3162>
3085<?php
3086    $ilDB->manipulate(
3087    "UPDATE ut_lp_marks SET " .
3088        " status_dirty = " . $ilDB->quote(1, "integer")
3089);
3090?>
3091<#3163>
3092<?php
3093    $ilDB->addIndex("conditions", array("target_obj_id", "target_type"), "tot");
3094?>
3095<#3164>
3096<?php
3097if ($ilDB->tableExists('svy_times')) {
3098    $ilDB->addTableColumn("svy_times", "first_question", array("type" => "integer", "length" => 4, "notnull" => false));
3099}
3100?>
3101<#3165>
3102<?php
3103if (!$ilDB->tableExists('svy_settings')) {
3104    $ilDB->createTable('svy_settings', array(
3105        'settings_id' => array(
3106            'type' => 'integer',
3107            'length' => 4,
3108            'notnull' => true
3109        ),
3110        'usr_id' => array(
3111            'type' => 'integer',
3112            'length' => 4,
3113            'notnull' => true
3114        ),
3115        'keyword' => array(
3116            'type' => 'text',
3117            'length' => 40,
3118            'notnull' => true
3119        ),
3120        'title' => array(
3121            'type' => 'text',
3122            'length' => 400,
3123            'notnull' => false
3124        ),
3125        'value' => array(
3126            'type' => 'clob',
3127            'notnull' => false
3128        )
3129    ));
3130    $ilDB->addPrimaryKey('svy_settings', array('settings_id'));
3131    $ilDB->addIndex('svy_settings', array('usr_id'), 'i1');
3132}
3133?>
3134<#3166>
3135<?php
3136    $ilDB->createSequence('svy_settings');
3137?>
3138<#3167>
3139<?php
3140if (!$ilDB->tableExists('cal_ch_settings')) {
3141    $ilDB->createTable('cal_ch_settings', array(
3142        'user_id' => array(
3143            'type' => 'integer',
3144            'length' => 4,
3145            'notnull' => true
3146        ),
3147        'admin_id' => array(
3148            'type' => 'integer',
3149            'length' => 4,
3150            'notnull' => true
3151        ),
3152    ));
3153    $ilDB->addPrimaryKey('cal_ch_settings', array('user_id', 'admin_id'));
3154}
3155?>
3156<#3168>
3157<?php
3158    if (!$ilDB->tableColumnExists('booking_entry', 'target_obj_id')) {
3159        $ilDB->addTableColumn("booking_entry", "target_obj_id", array("type" => "integer", "length" => 4, "notnull" => false));
3160    }
3161?>
3162<#3169>
3163<?php
3164    $ilCtrlStructureReader->getStructure();
3165?>
3166<#3170>
3167<?php
3168
3169    $permission_ordering = array(
3170        'add_post' => 3050,
3171        'edit_roleassignment' => 2500,
3172        'push_desktop_items' => 2400,
3173        'search' => 300,
3174        'export_memberdata' => 400,
3175        'edit_userasignment' => 2600,
3176    );
3177
3178    foreach ($permission_ordering as $op => $order) {
3179        $query = "UPDATE rbac_operations SET " .
3180            'op_order = ' . $ilDB->quote($order, 'integer') . ' ' .
3181            'WHERE operation = ' . $ilDB->quote($op, 'text') . ' ';
3182        $ilDB->manipulate($query);
3183    }
3184?>
3185<#3171>
3186<?php
3187    $ilCtrlStructureReader->getStructure();
3188?>
3189<#3172>
3190<?php
3191    if ($ilDB->getDBType() == 'oracle') {
3192        // test sequence
3193        if (!$ilDB->tableColumnExists('svy_category', 'title_tmp')) {
3194            $ilDB->addTableColumn("svy_category", "title_tmp", array(
3195            "type" => "text",
3196            "length" => 1000,
3197            "notnull" => false,
3198            "default" => null));
3199        }
3200    }
3201?>
3202<#3173>
3203<?php
3204    if ($ilDB->getDBType() == 'oracle') {
3205        $ilDB->manipulate('UPDATE svy_category SET title_tmp = title');
3206    }
3207?>
3208<#3174>
3209<?php
3210    if ($ilDB->getDBType() == 'oracle') {
3211        if ($ilDB->tableColumnExists('svy_category', 'title')) {
3212            $ilDB->dropTableColumn('svy_category', 'title');
3213        }
3214
3215        $ilDB->renameTableColumn("svy_category", "title_tmp", "title");
3216    }
3217?>
3218<#3175>
3219<?php
3220    if ($ilDB->getDBType() == 'mysql') {
3221        $ilDB->modifyTableColumn('svy_category', 'title', array("type" => "text", "length" => 1000, "default" => null, "notnull" => false));
3222    }
3223?>
3224<#3176>
3225<?php
3226if (!$ilDB->tableColumnExists('qpl_qst_ordering', 'scoring_type')) {
3227    $ilDB->addTableColumn(
3228        "qpl_qst_ordering",
3229        "scoring_type",
3230        array(
3231        "type" => "integer",
3232        "length" => 3,
3233        "notnull" => true,
3234        "default" => 0)
3235    );
3236    $ilDB->addTableColumn(
3237        "qpl_qst_ordering",
3238        "reduced_points",
3239        array(
3240        "type" => "float",
3241        "notnull" => true,
3242        "default" => 0)
3243    );
3244}
3245?>
3246<#3177>
3247<?php
3248if (!$ilDB->tableColumnExists('tst_tests', 'mailnottype')) {
3249    $ilDB->addTableColumn(
3250        "tst_tests",
3251        "mailnottype",
3252        array(
3253        "type" => "integer",
3254        "length" => 2,
3255        "notnull" => true,
3256        "default" => 0)
3257    );
3258}
3259?>
3260<#3178>
3261<?php
3262
3263    $query = "UPDATE crs_settings SET view_mode = 0 WHERE view_mode = 3";
3264    $ilDB->manipulate($query);
3265?>
3266<#3179>
3267<?php
3268
3269// copy permission id
3270$query = "SELECT * FROM rbac_operations WHERE operation = " . $ilDB->quote('copy', 'text');
3271$res = $ilDB->query($query);
3272$row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
3273$ops_id = $row->ops_id;
3274
3275$all_types = array('spl','qpl');
3276foreach ($all_types as $type) {
3277    $query = "SELECT obj_id FROM object_data WHERE type = 'typ' AND title = " . $ilDB->quote($type, 'text');
3278    $res = $ilDB->query($query);
3279    $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
3280
3281    $query = "INSERT INTO rbac_ta (typ_id,ops_id) " .
3282        "VALUES( " .
3283        $ilDB->quote($row->obj_id, 'integer') . ', ' .
3284        $ilDB->quote($ops_id, 'integer') . ' ' .
3285        ')';
3286    $ilDB->manipulate($query);
3287}
3288?>
3289<#3180>
3290<?php
3291
3292// Calendar settings
3293$query = 'SELECT obj_id FROM object_data WHERE type = ' . $ilDB->quote('typ', 'text') .
3294    ' AND title = ' . $ilDB->quote('cals', 'text');
3295$res = $ilDB->query($query);
3296$row = $res->fetchRow();
3297$cals = $row[0];
3298
3299$insert = false;
3300$query = 'SELECT ops_id FROM rbac_operations WHERE operation = ' . $ilDB->quote('add_consultation_hours', 'text');
3301$res = $ilDB->query($query);
3302if ($ilDB->numRows($res)) {
3303    $row = $res->fetchRow();
3304    $ops_id = (int) $row[0];
3305
3306    // remove old (faulty) ops [see #3083]
3307    if ($ops_id === 0) {
3308        $query = 'DELETE FROM rbac_operations WHERE operation = ' . $ilDB->quote('add_consultation_hours', 'text');
3309        $ilDB->query($query);
3310        $query = 'DELETE FROM rbac_ta  WHERE ops_id = ' . $ilDB->quote(0, 'integer') .
3311            ' AND typ_id = ' . $ilDB->quote($cals, 'integer');
3312        $ilDB->query($query);
3313
3314        $insert = true;
3315    }
3316} else {
3317    $insert = true;
3318}
3319
3320if ($insert) {
3321    // new permission
3322    $new_ops_id = $ilDB->nextId('rbac_operations');
3323    $query = 'INSERT INTO rbac_operations (ops_id,operation,description,class,op_order) ' .
3324        'VALUES( ' .
3325        $ilDB->quote($new_ops_id, 'integer') . ', ' .
3326        $ilDB->quote('add_consultation_hours', 'text') . ', ' .
3327        $ilDB->quote('Add Consultation Hours Calendar', 'text') . ", " .
3328        $ilDB->quote('object', 'text') . ", " .
3329        $ilDB->quote(300, 'integer') .
3330        ')';
3331    $res = $ilDB->query($query);
3332
3333    $ilDB->manipulateF(
3334        'INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)',
3335        array('integer','integer'),
3336        array($cals, $new_ops_id)
3337    );
3338}
3339
3340?>
3341<#3181>
3342<?php
3343if (!$ilDB->tableColumnExists('svy_finished', 'lastpage')) {
3344    $ilDB->addTableColumn(
3345        "svy_finished",
3346        "lastpage",
3347        array(
3348        "type" => "integer",
3349        "length" => 4,
3350        "notnull" => true,
3351        "default" => 0)
3352    );
3353}
3354?>
3355<#3182>
3356<?php
3357if (!$ilDB->tableColumnExists('svy_phrase_cat', 'other')) {
3358    $ilDB->addTableColumn("svy_phrase_cat", "other", array("type" => "integer", "length" => 2, "notnull" => true, "default" => 0));
3359}
3360?>
3361<#3183>
3362<?php
3363if (!$ilDB->tableColumnExists('svy_phrase_cat', 'scale')) {
3364    $ilDB->addTableColumn("svy_phrase_cat", "scale", array("type" => "integer", "length" => 4, "notnull" => false, "default" => null));
3365}
3366?>
3367<#3184>
3368<?php
3369if (!$ilDB->tableColumnExists('tst_tests', 'exportsettings')) {
3370    $ilDB->addTableColumn("tst_tests", "exportsettings", array("type" => "integer", "length" => 4, "notnull" => true, "default" => 0));
3371}
3372?>
3373<#3185>
3374<?php
3375    $query = 'UPDATE rbac_operations SET operation = ' . $ilDB->quote('create_usr', 'text') . ' WHERE operation = ' . $ilDB->quote('create_user', 'text');
3376    $ilDB->manipulate($query);
3377?>
3378<#3186>
3379<?php
3380
3381// create new table
3382if (!$ilDB->tableExists('booking_schedule_slot')) {
3383    $ilDB->createTable('booking_schedule_slot', array(
3384        'booking_schedule_id' => array(
3385            'type' => 'integer',
3386            'length' => 4,
3387            'notnull' => true
3388        ),
3389        'day_id' => array(
3390            'type' => 'text',
3391            'length' => 2,
3392            'notnull' => true
3393        ),
3394        'slot_id' => array(
3395            'type' => 'integer',
3396            'length' => 1,
3397            'notnull' => true
3398        ),
3399        'times' => array(
3400            'type' => 'text',
3401            'length' => 50,
3402            'notnull' => true
3403        )
3404    ));
3405    $ilDB->addPrimaryKey('booking_schedule_slot', array('booking_schedule_id', 'day_id', 'slot_id'));
3406
3407    if ($ilDB->tableColumnExists('booking_schedule', 'definition')) {
3408        // migrate existing schedules
3409        $set = $ilDB->query('SELECT booking_schedule_id,definition FROM booking_schedule');
3410        while ($row = $ilDB->fetchAssoc($set)) {
3411            $definition = @unserialize($row["definition"]);
3412            if ($definition) {
3413                foreach ($definition as $day_id => $slots) {
3414                    foreach ($slots as $slot_id => $times) {
3415                        $fields = array(
3416                            "booking_schedule_id" => array('integer', $row["booking_schedule_id"]),
3417                            "day_id" => array('text', $day_id),
3418                            "slot_id" => array('integer', $slot_id),
3419                            "times" => array('text', $times)
3420                            );
3421                        $ilDB->insert('booking_schedule_slot', $fields);
3422                    }
3423                }
3424            }
3425        }
3426
3427        // remove old column
3428        $ilDB->dropTableColumn('booking_schedule', 'definition');
3429    }
3430}
3431?>
3432<#3187>
3433<?php
3434if (!$ilDB->tableColumnExists('notification', 'page_id')) {
3435    $ilDB->addTableColumn("notification", "page_id", array("type" => "integer", "length" => 4, "notnull" => false, "default" => 0));
3436}
3437?>
3438<#3188>
3439<?php
3440    $ilDB->addTableColumn("svy_svy", "startdate_tmp", array(
3441        "type" => "text",
3442        "notnull" => false,
3443        'length' => 14,
3444        "default" => null
3445    ));
3446?>
3447<#3189>
3448<?php
3449$res = $ilDB->query('SELECT survey_id, startdate FROM svy_svy');
3450while ($row = $ilDB->fetchAssoc($res)) {
3451    if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $row['startdate'], $matches)) {
3452        $ilDB->manipulateF(
3453            'UPDATE svy_svy SET startdate_tmp = %s WHERE survey_id = %s',
3454            array('text', 'integer'),
3455            array(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], 0, 0, 0), $row['survey_id'])
3456        );
3457    }
3458}
3459?>
3460<#3190>
3461<?php
3462$ilDB->dropTableColumn('svy_svy', 'startdate');
3463?>
3464<#3191>
3465<?php
3466$ilDB->renameTableColumn("svy_svy", "startdate_tmp", "startdate");
3467?>
3468<#3192>
3469<?php
3470    $ilDB->addTableColumn("svy_svy", "enddate_tmp", array(
3471        "type" => "text",
3472        "notnull" => false,
3473        'length' => 14,
3474        "default" => null
3475    ));
3476?>
3477<#3193>
3478<?php
3479$res = $ilDB->query('SELECT survey_id, enddate FROM svy_svy');
3480while ($row = $ilDB->fetchAssoc($res)) {
3481    if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $row['enddate'], $matches)) {
3482        $ilDB->manipulateF(
3483            'UPDATE svy_svy SET enddate_tmp = %s WHERE survey_id = %s',
3484            array('text', 'integer'),
3485            array(sprintf("%04d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], 0, 0, 0), $row['survey_id'])
3486        );
3487    }
3488}
3489?>
3490<#3194>
3491<?php
3492$ilDB->dropTableColumn('svy_svy', 'enddate');
3493?>
3494<#3195>
3495<?php
3496$ilDB->renameTableColumn("svy_svy", "enddate_tmp", "enddate");
3497?>
3498
3499<#3196>
3500<?php
3501    $ilDB->addTableColumn("export_file_info", "filename", array(
3502        "type" => "text",
3503        "notnull" => false,
3504        'length' => 64,
3505        "default" => null
3506    ));
3507?>
3508<#3197>
3509<?php
3510    $query = "UPDATE export_file_info SET filename = file_name ";
3511    $ilDB->manipulate($query);
3512?>
3513
3514<#3198>
3515<?php
3516    $ilDB->dropPrimaryKey('export_file_info');
3517?>
3518<#3199>
3519<?php
3520    $ilDB->addPrimaryKey('export_file_info', array('obj_id','export_type','filename'));
3521?>
3522
3523<#3200>
3524<?php
3525
3526    // Invalid assign flags
3527    $query = "SELECT rol_id FROM rbac_fa " .
3528        "WHERE assign = " . $ilDB->quote('y', 'text') . ' ' .
3529        "GROUP BY rol_id HAVING count(*) > 1";
3530    $res = $ilDB->query($query);
3531    while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
3532        $role_id = $row->rol_id;
3533
3534        $query = "SELECT depth, fa.parent parent FROM rbac_fa fa " .
3535            "JOIN tree t ON fa.parent = child " .
3536            "WHERE rol_id = " . $ilDB->quote($role_id, 'integer') . ' ' .
3537            "AND assign = " . $ilDB->quote('y', 'text') . ' ' .
3538            "ORDER BY depth, fa.parent";
3539        $assignable_res = $ilDB->query($query);
3540        $first = true;
3541        while ($assignable_row = $assignable_res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
3542            if ($first) {
3543                $first = false;
3544                continue;
3545            }
3546            // Only for security
3547            if ($assignable_row->parent == ROLE_FOLDER_ID) {
3548                continue;
3549            }
3550            $GLOBALS['ilLog']->write(__METHOD__ . ': Ressetting assignable flag for role_id: ' . $role_id . ' parent: ' . $assignable_row->parent);
3551            $query = "UPDATE rbac_fa SET assign = " . $ilDB->quote('n', 'text') . ' ' .
3552                "WHERE rol_id = " . $ilDB->quote($role_id, 'integer') . ' ' .
3553                "AND parent = " . $ilDB->quote($assignable_row->parent, 'integer');
3554            $ilDB->manipulate($query);
3555        }
3556    }
3557?>
3558<#3201>
3559<?php
3560if (!$ilDB->tableColumnExists('tst_test_random', 'sequence')) {
3561    $ilDB->addTableColumn("tst_test_random", "sequence", array(
3562    "type" => "integer",
3563    "length" => 4,
3564    "notnull" => true,
3565    "default" => 0));
3566}
3567?>
3568<#3202>
3569<?php
3570if ($ilDB->tableColumnExists('tst_test_random', 'sequence')) {
3571    $ilDB->manipulate("UPDATE tst_test_random SET sequence = test_random_id");
3572}
3573?>
3574<#3203>
3575<?php
3576if (!$ilDB->tableColumnExists('usr_session', 'remote_addr')) {
3577    $ilDB->addTableColumn("usr_session", "remote_addr", array(
3578    "type" => "text",
3579    "length" => 50,
3580    "notnull" => false,
3581    "default" => null));
3582}
3583?>
3584<#3204>
3585<?php
3586
3587include_once "Services/Tracking/classes/class.ilLPMarks.php";
3588
3589$set = $ilDB->query("SELECT event_id,usr_id,mark,e_comment" .
3590    " FROM event_participants" .
3591    " WHERE mark IS NOT NULL OR e_comment IS NOT NULL");
3592while ($row = $ilDB->fetchAssoc($set)) {
3593    // move to ut_lp_marks
3594
3595    $fields = array();
3596    $fields["mark"] = array("text", $row["mark"]);
3597    $fields["u_comment"] = array("text", $row["e_comment"]);
3598    // $fields["status_changed"] = array("timestamp", date("Y-m-d H:i:s"));
3599
3600    $where = array();
3601    $where["obj_id"] = array("integer", $row["event_id"]);
3602    $where["usr_id"] = array("integer", $row["usr_id"]);
3603
3604    $old = $ilDB->query("SELECT obj_id,usr_id" .
3605        " FROM ut_lp_marks" .
3606        " WHERE obj_id = " . $ilDB->quote($row["event_id"]) .
3607        " AND usr_id = " . $ilDB->quote($row["usr_id"]));
3608    if ($ilDB->numRows($old)) {
3609        $ilDB->update("ut_lp_marks", $fields, $where);
3610    } else {
3611        $fields = array_merge($fields, $where);
3612        $ilDB->insert("ut_lp_marks", $fields);
3613    }
3614
3615
3616    // delete old values
3617
3618    $fields = array();
3619    $fields["mark"] = array("text", null);
3620    $fields["e_comment"] = array("text", null);
3621
3622    $where = array();
3623    $where["event_id"] = array("integer", $row["event_id"]);
3624    $where["usr_id"] = array("integer", $row["usr_id"]);
3625
3626    $ilDB->update("event_participants", $fields, $where);
3627}
3628?>
3629<#3205>
3630<?php
3631    if (!$ilDB->tableColumnExists('export_options', 'pos')) {
3632        $ilDB->addTableColumn(
3633            'export_options',
3634            'pos',
3635            array(
3636                'type' => 'integer',
3637                'length' => 4,
3638                'notnull' => true,
3639                'default' => 0
3640            )
3641        );
3642    }
3643?>
3644
3645<#3206>
3646<?php
3647    $ilDB->modifyTableColumn(
3648    'ldap_server_settings',
3649    'filter',
3650    array("type" => "text", "length" => 512, "notnull" => false)
3651);
3652?>
3653<#3207>
3654<?php
3655$ilDB->manipulate(
3656    'UPDATE mail_obj_data SET title = ' . $ilDB->quote('z_local', 'text') . ' '
3657   . 'WHERE title != ' . $ilDB->quote('z_local', 'text') . ' AND m_type = ' . $ilDB->quote('local', 'text')
3658);
3659?>
3660<#3208>
3661<?php
3662    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
3663    ilDBUpdate3136::addStyleClass(
3664        "RTEMenu",
3665        "rte_menu",
3666        "div",
3667        array()
3668    );
3669?>
3670<#3209>
3671<?php
3672$set = $ilDB->query("SELECT obj_id FROM object_data WHERE type = " . $ilDB->quote("tst", "text"));
3673while ($r = $ilDB->fetchAssoc($set)) {
3674    $ilDB->manipulate(
3675        "UPDATE ut_lp_marks SET " .
3676        " status_dirty = " . $ilDB->quote(1, "integer") .
3677        " WHERE obj_id = " . $ilDB->quote($r["obj_id"], "integer")
3678    );
3679}
3680?>
3681<#3210>
3682<?php
3683$ilDB->addTableColumn("sahs_lm", "entry_page", array(
3684    "type" => "integer",
3685    "notnull" => true,
3686    "default" => 0,
3687    "length" => 4
3688));
3689?>
3690<#3211>
3691<?php
3692    $ilCtrlStructureReader->getStructure();
3693?>
3694<#3212>
3695<?php
3696    $ilCtrlStructureReader->getStructure();
3697?>
3698<#3213>
3699<?php
3700// convert old qpl export files
3701$qpl_export_base = ilUtil::getDataDir() . "/qpl_data/";
3702// quit if import dir not available
3703if (@is_dir($qpl_export_base) && is_writeable($qpl_export_base)) {
3704    // open directory
3705    $h_dir = dir($qpl_export_base);
3706
3707    // get files and save the in the array
3708    while ($entry = $h_dir->read()) {
3709        if ($entry != "." && $entry != "..") {
3710            if (@is_dir($qpl_export_base . $entry)) {
3711                $q_dir = dir($qpl_export_base . $entry);
3712                while ($q_entry = $q_dir->read()) {
3713                    if ($q_entry != "." and $q_entry != "..") {
3714                        if (@is_dir($qpl_export_base . $entry . '/' . $q_entry) && strcmp($q_entry, 'export') == 0) {
3715                            $exp_dir = dir($qpl_export_base . $entry . '/' . $q_entry);
3716                            while ($exp_entry = $exp_dir->read()) {
3717                                if (@is_file($qpl_export_base . $entry . '/' . $q_entry . '/' . $exp_entry)) {
3718                                    $res = preg_match("/^([0-9]{10}_{2}[0-9]+_{2})(qpl__)*([0-9]+)\.(zip)\$/", $exp_entry, $matches);
3719                                    if ($res) {
3720                                        switch ($matches[4]) {
3721                                            case 'zip':
3722                                                if (!@is_dir($qpl_export_base . $entry . '/' . 'export_zip')) {
3723                                                    ilUtil::makeDir($qpl_export_base . $entry . '/' . 'export_zip');
3724                                                }
3725                                                @rename($qpl_export_base . $entry . '/' . $q_entry . '/' . $exp_entry, $qpl_export_base . $entry . '/' . 'export_zip' . '/' . $matches[1] . 'qpl_' . $matches[3] . '.zip');
3726                                                break;
3727                                        }
3728                                    }
3729                                }
3730                            }
3731                            $exp_dir->close();
3732                            if (@is_dir($qpl_export_base . $entry . '/' . $q_entry)) {
3733                                ilUtil::delDir($qpl_export_base . $entry . '/' . $q_entry);
3734                            }
3735                        }
3736                    }
3737                }
3738                $q_dir->close();
3739            }
3740        }
3741    }
3742    $h_dir->close();
3743}
3744?>
3745<#3214>
3746<?php
3747if ($ilDB->tableColumnExists('svy_svy', 'mailaddresses')) {
3748    $ilDB->addTableColumn("svy_svy", "mailaddresses_tmp", array("type" => "text", "length" => 2000, "notnull" => false, "default" => null));
3749    $ilDB->manipulate('UPDATE svy_svy SET mailaddresses_tmp = mailaddresses');
3750    $ilDB->dropTableColumn('svy_svy', 'mailaddresses');
3751    $ilDB->renameTableColumn("svy_svy", "mailaddresses_tmp", "mailaddresses");
3752}
3753?>
3754<#3215>
3755<?php
3756if ($ilDB->tableColumnExists('svy_svy', 'mailparticipantdata')) {
3757    $ilDB->addTableColumn("svy_svy", "mailparticipantdata_tmp", array("type" => "text", "length" => 4000, "notnull" => false, "default" => null));
3758    $ilDB->manipulate('UPDATE svy_svy SET mailparticipantdata_tmp = mailparticipantdata');
3759    $ilDB->dropTableColumn('svy_svy', 'mailparticipantdata');
3760    $ilDB->renameTableColumn("svy_svy", "mailparticipantdata_tmp", "mailparticipantdata");
3761}
3762?>
3763<#3216>
3764<?php
3765$ilDB->addTableColumn("page_layout", "style_id", array(
3766    "type" => "integer",
3767    "notnull" => false,
3768    "default" => 0,
3769    "length" => 4
3770));
3771?>
3772<#3217>
3773<?php
3774$ilDB->addIndex('frm_thread_access', array('access_last'), 'i1');
3775?>
3776<#3218>
3777<?php
3778    $setting = new ilSetting();
3779
3780    $old_setting = $setting->get('disable_anonymous_fora');
3781    $new_setting = $setting->set('enable_anonymous_fora', $old_setting ? false : true);
3782
3783    $ilDB->manipulateF(
3784        'DELETE FROM settings WHERE keyword = %s',
3785        array('text'),
3786        array('disable_anonymous_fora')
3787    );
3788
3789?>
3790<#3219>
3791<?php
3792$fields = array(
3793    'id' => array(
3794        'type' => 'integer',
3795        'length' => 4,
3796        'notnull' => true
3797    ),
3798    'hide_obj_page' => array(
3799        'type' => 'integer',
3800        'length' => 1,
3801        'notnull' => true,
3802        'default' => 0
3803    )
3804);
3805$ilDB->createTable('sahs_sc13_sco', $fields);
3806$ilDB->addPrimaryKey("sahs_sc13_sco", array("id"));
3807
3808?>
3809<#3220>
3810<?php
3811$set = $ilDB->query(
3812    "SELECT * FROM sahs_sc13_tree_node WHERE " .
3813    " type = " . $ilDB->quote("sco", "text")
3814);
3815while ($rec = $ilDB->fetchAssoc($set)) {
3816    $ilDB->manipulate("INSERT INTO sahs_sc13_sco " .
3817        "(id, hide_obj_page) VALUES (" .
3818        $ilDB->quote($rec["obj_id"], "integer") . "," .
3819        $ilDB->quote(0, "integer") .
3820        ")");
3821}
3822?>
3823
3824<#3221>
3825<?php
3826if (!$ilDB->tableExists('tree_workspace')) {
3827    $fields = array(
3828        'tree' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
3829        'child' => array('type' => 'integer', 'notnull' => true, 'length' => 4, 'default' => 0),
3830        'parent' => array('type' => 'integer', 'length' => 4,"notnull" => true,"default" => 0),
3831        'lft' => array('type' => 'integer', 'length' => 4,"notnull" => true,"default" => 0),
3832        'rgt' => array('type' => 'integer', 'length' => 4,"notnull" => true,"default" => 0),
3833        'depth' => array('type' => 'integer', 'length' => 2,"notnull" => true,"default" => 0)
3834      );
3835    $ilDB->createTable('tree_workspace', $fields);
3836    $ilDB->addIndex('tree_workspace', array('child'), 'i1');
3837    $ilDB->addIndex('tree_workspace', array('parent'), 'i2');
3838    $ilDB->addIndex('tree_workspace', array('tree'), 'i3');
3839}
3840?>
3841<#3222>
3842<?php
3843if (!$ilDB->tableExists('object_reference_ws')) {
3844    $fields = array(
3845        'wsp_id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
3846        'obj_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4, 'default' => 0),
3847        'deleted' => array('type' => 'timestamp', 'notnull' => false)
3848      );
3849    $ilDB->createTable('object_reference_ws', $fields);
3850    $ilDB->addPrimaryKey('object_reference_ws', array('wsp_id'));
3851    $ilDB->addIndex('object_reference_ws', array('obj_id'), 'i1');
3852    $ilDB->addIndex('object_reference_ws', array('deleted'), 'i2');
3853    $ilDB->createSequence('object_reference_ws');
3854}
3855?>
3856<#3223>
3857<?php
3858if (!$ilDB->tableColumnExists('il_object_def', 'repository')) {
3859    $ilDB->addTableColumn(
3860        "il_object_def",
3861        "repository",
3862        array("type" => "integer", "length" => 1, "notnull" => true, "default" => 1)
3863    );
3864}
3865?>
3866<#3224>
3867<?php
3868if (!$ilDB->tableColumnExists('il_object_def', 'workspace')) {
3869    $ilDB->addTableColumn(
3870        "il_object_def",
3871        "workspace",
3872        array("type" => "integer", "length" => 1, "notnull" => true, "default" => 0)
3873    );
3874}
3875?>
3876<#3225>
3877<?php
3878
3879        if (!$ilDB->tableColumnExists('ldap_server_settings', 'authentication')) {
3880            $ilDB->addTableColumn(
3881                'ldap_server_settings',
3882                'authentication',
3883                array(
3884                    'type' => 'integer',
3885                    'length' => '1',
3886                    'notnull' => true,
3887                    'default' => 1
3888                )
3889            );
3890        }
3891?>
3892
3893<#3226>
3894<?php
3895        if (!$ilDB->tableColumnExists('ldap_server_settings', 'authentication_type')) {
3896            $ilDB->addTableColumn(
3897                'ldap_server_settings',
3898                'authentication_type',
3899                array(
3900                    'type' => 'integer',
3901                    'length' => '1',
3902                    'notnull' => true,
3903                    'default' => 0
3904                )
3905            );
3906        }
3907?>
3908<#3227>
3909<?php
3910    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
3911    ilDBUpdate3136::addStyleClass(
3912        "RTELogo",
3913        "rte_menu",
3914        "div",
3915        array("float" => "left")
3916    );
3917?>
3918<#3228>
3919<?php
3920    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
3921    ilDBUpdate3136::addStyleClass(
3922        "RTELinkBar",
3923        "rte_menu",
3924        "div",
3925        array()
3926    );
3927?>
3928<#3229>
3929<?php
3930    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
3931    ilDBUpdate3136::addStyleClass(
3932        "RTELink",
3933        "rte_mlink",
3934        "a",
3935        array()
3936    );
3937?>
3938<#3230>
3939<?php
3940    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
3941    ilDBUpdate3136::addStyleClass(
3942        "RTELinkDisabled",
3943        "rte_mlink",
3944        "a",
3945        array()
3946    );
3947?>
3948<#3231>
3949<?php
3950    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
3951    ilDBUpdate3136::addStyleClass(
3952        "RTETree",
3953        "rte_tree",
3954        "div",
3955        array()
3956    );
3957?>
3958<#3232>
3959<?php
3960$ilDB->addTableColumn("sahs_lm", "final_sco_page", array(
3961    "type" => "integer",
3962    "notnull" => true,
3963    "default" => 0,
3964    "length" => 4
3965));
3966$ilDB->addTableColumn("sahs_lm", "final_lm_page", array(
3967    "type" => "integer",
3968    "notnull" => true,
3969    "default" => 0,
3970    "length" => 4
3971));
3972?>
3973<#3233>
3974<?php
3975if (!$ilDB->tableExists('il_blog_posting')) {
3976    $fields = array(
3977        'id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
3978        'blog_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4, 'default' => 0),
3979        'title' => array('type' => 'text', 'notnull' => false, 'length' => 400),
3980        'created' => array('type' => 'timestamp', 'notnull' => true)
3981      );
3982    $ilDB->createTable('il_blog_posting', $fields);
3983    $ilDB->addPrimaryKey('il_blog_posting', array('id'));
3984    $ilDB->addIndex('il_blog_posting', array('created'), 'i1');
3985    $ilDB->createSequence('il_blog_posting');
3986}
3987?>
3988<#3234>
3989<?php
3990    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
3991    ilDBUpdate3136::addStyleClass(
3992        "RTECourse",
3993        "rte_node",
3994        "td",
3995        array()
3996    );
3997    ilDBUpdate3136::addStyleClass(
3998        "RTEChapter",
3999        "rte_node",
4000        "td",
4001        array()
4002    );
4003    ilDBUpdate3136::addStyleClass(
4004        "RTESco",
4005        "rte_node",
4006        "td",
4007        array()
4008    );
4009    ilDBUpdate3136::addStyleClass(
4010        "RTEAsset",
4011        "rte_node",
4012        "td",
4013        array()
4014    );
4015    ilDBUpdate3136::addStyleClass(
4016        "RTECourseDisabled",
4017        "rte_node",
4018        "td",
4019        array()
4020    );
4021    ilDBUpdate3136::addStyleClass(
4022        "RTEChapterDisabled",
4023        "rte_node",
4024        "td",
4025        array()
4026    );
4027    ilDBUpdate3136::addStyleClass(
4028        "RTEScoDisabled",
4029        "rte_node",
4030        "td",
4031        array()
4032    );
4033    ilDBUpdate3136::addStyleClass(
4034        "RTEAssetDisabled",
4035        "rte_node",
4036        "td",
4037        array()
4038    );
4039?>
4040<#3235>
4041<?php
4042    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4043    ilDBUpdate3136::addStyleClass(
4044        "RTEAsset",
4045        "rte_status",
4046        "a",
4047        array()
4048    );
4049    ilDBUpdate3136::addStyleClass(
4050        "RTECompleted",
4051        "rte_status",
4052        "a",
4053        array()
4054    );
4055    ilDBUpdate3136::addStyleClass(
4056        "RTENotAttempted",
4057        "rte_status",
4058        "a",
4059        array()
4060    );
4061    ilDBUpdate3136::addStyleClass(
4062        "RTERunning",
4063        "rte_status",
4064        "a",
4065        array()
4066    );
4067    ilDBUpdate3136::addStyleClass(
4068        "RTEIncomplete",
4069        "rte_status",
4070        "a",
4071        array()
4072    );
4073    ilDBUpdate3136::addStyleClass(
4074        "RTEPassed",
4075        "rte_status",
4076        "a",
4077        array()
4078    );
4079    ilDBUpdate3136::addStyleClass(
4080        "RTEFailed",
4081        "rte_status",
4082        "a",
4083        array()
4084    );
4085    ilDBUpdate3136::addStyleClass(
4086        "RTEBrowsed",
4087        "rte_status",
4088        "a",
4089        array()
4090    );
4091?>
4092<#3236>
4093<?php
4094    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4095    ilDBUpdate3136::addStyleClass(
4096        "RTETreeLink",
4097        "rte_tlink",
4098        "a",
4099        array()
4100    );
4101    ilDBUpdate3136::addStyleClass(
4102        "RTETreeLinkDisabled",
4103        "rte_tlink",
4104        "a",
4105        array()
4106    );
4107?>
4108
4109<#3237>
4110<?php
4111// this is a fix for patched scorm editor installations (separate branch)
4112if ($ilDB->getDBType() == 'mysql') {
4113    $set = $ilDB->query("SELECT max(id) mid FROM style_template");
4114    $rec = $ilDB->fetchAssoc($set);
4115    if ($rec["mid"] > 0) {
4116        $ilDB->manipulate("UPDATE style_template_seq SET " .
4117            " sequence = " . $ilDB->quote($rec["mid"], "integer"));
4118    }
4119}
4120?>
4121<#3238>
4122<?php
4123$ilDB->addTableColumn("page_layout", "special_page", array(
4124    "type" => "integer",
4125    "notnull" => false,
4126    "default" => 0,
4127    "length" => 1
4128));
4129?>
4130<#3239>
4131<?php
4132$ilDB->addTableColumn("il_wiki_data", "public_notes", array(
4133    "type" => "integer",
4134    "notnull" => false,
4135    "default" => 1,
4136    "length" => 1
4137));
4138?>
4139<#3240>
4140<?php
4141if (!$ilDB->tableExists('il_blog')) {
4142    $fields = array(
4143        'id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
4144        'notes' => array('type' => 'integer', 'notnull' => false, 'length' => 1, 'default' => 1)
4145      );
4146    $ilDB->createTable('il_blog', $fields);
4147    $ilDB->addPrimaryKey('il_blog', array('id'));
4148}
4149?>
4150<#3241>
4151<?php
4152if (!$ilDB->tableExists('acl_ws')) {
4153    $fields = array(
4154        'node_id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
4155        'object_id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0)
4156      );
4157    $ilDB->createTable('acl_ws', $fields);
4158    $ilDB->addPrimaryKey('acl_ws', array('node_id', 'object_id'));
4159}
4160?>
4161<#3242>
4162<?php
4163    if (!$ilDB->tableColumnExists('conditions', 'obligatory')) {
4164        $ilDB->addTableColumn(
4165            'conditions',
4166            'obligatory',
4167            array(
4168                'type' => 'integer',
4169                'notnull' => true,
4170                'length' => 1,
4171                'default' => 1
4172            )
4173        );
4174    }
4175?>
4176<#3243>
4177<?php
4178    if (!$ilDB->tableColumnExists('ut_lp_collections', 'grouping_id')) {
4179        $ilDB->addTableColumn(
4180            'ut_lp_collections',
4181            'grouping_id',
4182            array(
4183                'type' => 'integer',
4184                'notnull' => true,
4185                'length' => 4,
4186                'default' => 0
4187            )
4188        );
4189        $ilDB->addTableColumn(
4190            'ut_lp_collections',
4191            'num_obligatory',
4192            array(
4193                'type' => 'integer',
4194                'notnull' => true,
4195                'length' => 4,
4196                'default' => 0
4197            )
4198        );
4199    }
4200?>
4201<#3244>
4202<?php
4203    if (!$ilDB->tableColumnExists('ut_lp_collections', 'active')) {
4204        $ilDB->addTableColumn(
4205            'ut_lp_collections',
4206            'active',
4207            array(
4208                'type' => 'integer',
4209                'notnull' => true,
4210                'length' => 1,
4211                'default' => 1
4212            )
4213        );
4214    }
4215?>
4216<#3245>
4217<?php
4218    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4219    ilDBUpdate3136::addStyleClass(
4220        "FinalMessage",
4221        "sco_fmess",
4222        "div",
4223        array("margin" => "100px", "padding" => "50px", "font-size" => "125%",
4224            "border-width" => "1px", "border-style" => "solid", "border-color" => "#F0F0F0",
4225            "background-color" => "#FAFAFA", "text-align" => "center")
4226    );
4227?>
4228<#3246>
4229<?php
4230    $ilCtrlStructureReader->getStructure();
4231?>
4232<#3247>
4233<?php
4234    $ilDB->dropPrimaryKey("sahs_sc13_seq_item");
4235    $ilDB->addPrimaryKey(
4236        "sahs_sc13_seq_item",
4237        array("sahs_sc13_tree_node_id", "rootlevel")
4238    );
4239?>
4240<#3248>
4241<?php
4242    $ilDB->addTableColumn("sahs_sc13_seq_item", "importseqxml", array(
4243        "type" => "clob"));
4244?>
4245<#3249>
4246<?php
4247    $ilDB->addTableColumn("sahs_lm", "seq_exp_mode", array(
4248        "type" => "integer", "length" => 1, "notnull" => false, "default" => 0));
4249?>
4250<#3250>
4251<?php
4252    $ilCtrlStructureReader->getStructure();
4253?>
4254<#3251>
4255<?php
4256    if (!$ilDB->tableColumnExists('conditions', 'num_obligatory')) {
4257        $ilDB->addTableColumn(
4258            'conditions',
4259            'num_obligatory',
4260            array(
4261                'type' => 'integer',
4262                'notnull' => true,
4263                'length' => 1,
4264                'default' => 0
4265            )
4266        );
4267    }
4268?>
4269<#3252>
4270<?php
4271    if (!$ilDB->tableColumnExists('payment_prices', 'extension')) {
4272        $ilDB->addTableColumn(
4273            'payment_prices',
4274            'extension',
4275            array(
4276                'type' => 'integer',
4277                'length' => '1',
4278                'notnull' => true,
4279                'default' => 0
4280            )
4281        );
4282    }
4283?>
4284<#3253>
4285<?php
4286    if (!$ilDB->tableColumnExists('payment_statistic', 'access_enddate')) {
4287        $ilDB->addTableColumn(
4288            'payment_statistic',
4289            'access_enddate',
4290            array(
4291                'type' => 'timestamp',
4292                'notnull' => false
4293            )
4294        );
4295    }
4296?>
4297<#3254>
4298<?php
4299    $res = $ilDB->queryf(
4300    '
4301		SELECT booking_id, order_date, duration
4302		FROM payment_statistic
4303		WHERE duration > %s',
4304    array('integer'),
4305    array(0)
4306);
4307
4308    while ($row = $ilDB->fetchAssoc($res)) {
4309        $order_date = $row['order_date'];
4310        $duration = $row['duration'];
4311
4312        $orderDateYear = date("Y", $row['order_date']);
4313        $orderDateMonth = date("m", $row['order_date']);
4314        $orderDateDay = date("d", $row['order_date']);
4315        $orderDateHour = date("H", $row['order_date']);
4316        $orderDateMinute = date("i", $row['order_date']);
4317        $orderDateSecond = date("s", $row['order_date']);
4318
4319        $access_enddate = date("Y-m-d H:i:s", mktime(
4320            $orderDateHour,
4321            $orderDateMinute,
4322            $orderDateSecond,
4323            $orderDateMonth + $duration,
4324            $orderDateDay,
4325            $orderDateYear
4326        ));
4327
4328        $ilDB->update(
4329            'payment_statistic',
4330            array('access_enddate' => array('timestamp', $access_enddate)),
4331            array('booking_id' => array('integer', $row['booking_id']))
4332        );
4333    }
4334?>
4335<#3255>
4336<?php
4337
4338if (!$ilDB->tableColumnExists("il_wiki_data", "imp_pages")) {
4339    $ilDB->addTableColumn("il_wiki_data", "imp_pages", array(
4340        "type" => "integer",
4341        "notnull" => false,
4342        "length" => 1
4343    ));
4344}
4345?>
4346<#3256>
4347<?php
4348if (!$ilDB->tableExists('il_wiki_imp_pages')) {
4349    $fields = array(
4350        'wiki_id' => array(
4351            'type' => 'integer',
4352            'length' => 4,
4353            'notnull' => true
4354            ),
4355        'ord' => array(
4356            'type' => 'integer',
4357            'length' => 4,
4358            'notnull' => true
4359            ),
4360        'indent' => array(
4361            'type' => 'integer',
4362            'length' => 1,
4363            'notnull' => true
4364            ),
4365        'page_id' => array(
4366            'type' => 'integer',
4367            'length' => 4,
4368            'notnull' => true
4369            )
4370    );
4371    $ilDB->createTable('il_wiki_imp_pages', $fields);
4372}
4373?>
4374<#3257>
4375<?php
4376if (!$ilDB->tableExists('adm_settings_template')) {
4377    $fields = array(
4378        'id' => array(
4379            'type' => 'integer',
4380            'length' => 4,
4381            'notnull' => true
4382            ),
4383        'type' => array(
4384            'type' => 'text',
4385            'length' => 5,
4386            'notnull' => true
4387            ),
4388        'title' => array(
4389            'type' => 'text',
4390            'length' => 100,
4391            'notnull' => true
4392            ),
4393        'description' => array(
4394            'type' => 'clob'
4395            )
4396    );
4397    $ilDB->createTable('adm_settings_template', $fields);
4398    $ilDB->createSequence('adm_settings_template');
4399}
4400?>
4401<#3258>
4402<?php
4403if (!$ilDB->tableExists('adm_set_templ_value')) {
4404    $fields = array(
4405        'template_id' => array(
4406            'type' => 'integer',
4407            'length' => 4,
4408            'notnull' => true
4409            ),
4410        'setting' => array(
4411            'type' => 'text',
4412            'length' => 40,
4413            'notnull' => true
4414            ),
4415        'value' => array(
4416            'type' => 'text',
4417            'length' => 4000,
4418            'notnull' => false
4419            ),
4420        'hide' => array(
4421            'type' => 'integer',
4422            'length' => 1,
4423            'notnull' => false
4424            ),
4425    );
4426    $ilDB->createTable('adm_set_templ_value', $fields);
4427}
4428?>
4429<#3259>
4430<?php
4431if (!$ilDB->tableExists('adm_set_templ_hide_tab')) {
4432    $fields = array(
4433        'template_id' => array(
4434            'type' => 'integer',
4435            'length' => 4,
4436            'notnull' => true
4437            ),
4438        'tab_id' => array(
4439            'type' => 'text',
4440            'length' => 80,
4441            'notnull' => true
4442            )
4443    );
4444    $ilDB->createTable('adm_set_templ_hide_tab', $fields);
4445}
4446?>
4447<#3260>
4448<?php
4449    $ilCtrlStructureReader->getStructure();
4450?>
4451<#3261>
4452<?php
4453if (!$ilDB->tableColumnExists("il_wiki_data", "page_toc")) {
4454    $ilDB->addTableColumn("il_wiki_data", "page_toc", array(
4455        "type" => "integer",
4456        "notnull" => false,
4457        "length" => 1
4458    ));
4459}
4460?>
4461<#3262>
4462<?php
4463if (!$ilDB->tableColumnExists("il_wiki_page", "blocked")) {
4464    $ilDB->addTableColumn("il_wiki_page", "blocked", array(
4465        "type" => "integer",
4466        "notnull" => false,
4467        "length" => 1
4468    ));
4469}
4470?>
4471<#3263>
4472<?php
4473if (!$ilDB->tableColumnExists("svy_svy", "template_id")) {
4474    $ilDB->addTableColumn("svy_svy", "template_id", array(
4475        "type" => "integer",
4476        "notnull" => false,
4477        "length" => 4
4478    ));
4479}
4480?>
4481<#3264>
4482<?php
4483if (!$ilDB->tableColumnExists("tst_tests", "express_qpool_allowed")) {
4484    $ilDB->addTableColumn("tst_tests", "express_qpool_allowed", array(
4485        "type" => "integer",
4486        "notnull" => false,
4487        "length" => 1,
4488        "default" => 0
4489    ));
4490}
4491?>
4492<#3265>
4493<?php
4494if (!$ilDB->tableColumnExists("tst_tests", "enabled_view_mode")) {
4495    $ilDB->addTableColumn("tst_tests", "enabled_view_mode", array(
4496        "type" => "text",
4497        "notnull" => false,
4498        "length" => 20,
4499        "default" => 0
4500    ));
4501}
4502?>
4503<#3266>
4504<?php
4505if (!$ilDB->tableColumnExists("tst_tests", "template_id")) {
4506    $ilDB->addTableColumn("tst_tests", "template_id", array(
4507        "type" => "integer",
4508        "notnull" => false,
4509        "length" => 4
4510    ));
4511}
4512?>
4513<#3267>
4514<?php
4515if (!$ilDB->tableColumnExists("svy_svy", "pool_usage")) {
4516    $ilDB->addTableColumn("svy_svy", "pool_usage", array(
4517        "type" => "integer",
4518        "notnull" => false,
4519        "length" => 1
4520    ));
4521}
4522?>
4523<#3268>
4524<?php
4525if (!$ilDB->tableColumnExists("svy_qblk", "show_blocktitle")) {
4526    $ilDB->addTableColumn("svy_qblk", "show_blocktitle", array(
4527        "type" => "text",
4528        "notnull" => false,
4529        "length" => 1
4530    ));
4531}
4532?>
4533<#3269>
4534<?php
4535if (!$ilDB->tableColumnExists("tst_tests", "pool_usage")) {
4536    $ilDB->addTableColumn("tst_tests", "pool_usage", array(
4537        "type" => "integer",
4538        "notnull" => false,
4539        "length" => 1
4540    ));
4541}
4542?>
4543<#3270>
4544<?php
4545if ($ilDB->tableColumnExists("tst_tests", "express_qpool_allowed")) {
4546    $ilDB->dropTableColumn("tst_tests", "express_qpool_allowed");
4547}
4548?>
4549<#3271>
4550<?php
4551if (!$ilDB->tableColumnExists("il_news_item", "content_text_is_lang_var")) {
4552    $ilDB->addTableColumn("il_news_item", "content_text_is_lang_var", array(
4553        "type" => "integer",
4554        "length" => 1,
4555        "notnull" => true,
4556        "default" => 0
4557        ));
4558}
4559?>
4560<#3272>
4561<?php
4562    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4563    ilDBUpdate3136::addStyleClass(
4564        "Page",
4565        "page",
4566        "div",
4567        array()
4568    );
4569?>
4570<#3273>
4571<?php
4572    if (!$ilDB->tableColumnExists('exc_data', 'compl_by_submission')) {
4573        $ilDB->addTableColumn('exc_data', 'compl_by_submission', array(
4574            'type' => 'integer',
4575            'length' => 1,
4576            'notnull' => true,
4577            'default' => 0
4578        ));
4579    }
4580?>
4581<#3274>
4582<?php
4583    if (!$ilDB->tableColumnExists('crs_settings', 'auto_noti_disabled')) {
4584        $ilDB->addTableColumn('crs_settings', 'auto_noti_disabled', array(
4585            'type' => 'integer',
4586            'length' => 1,
4587            'notnull' => true,
4588            'default' => 0
4589        ));
4590    }
4591?>
4592<#3275>
4593<?php
4594if (!$ilDB->tableExists('il_verification')) {
4595    $ilDB->createTable('il_verification', array(
4596        'id' => array(
4597            'type' => 'integer',
4598            'length' => 4,
4599            'notnull' => true
4600        ),
4601        'type' => array(
4602            'type' => 'text',
4603            'length' => 100,
4604            'notnull' => true
4605        ),
4606        'parameters' => array(
4607            'type' => 'text',
4608            'length' => 1000,
4609            'notnull' => false
4610        ),
4611        'raw_data' => array(
4612            'type' => 'clob',
4613            'notnull' => false
4614        )
4615    ));
4616
4617    $ilDB->addIndex('il_verification', array('id'), 'i1');
4618}
4619?>
4620<#3276>
4621<?php
4622    $ilCtrlStructureReader->getStructure();
4623?>
4624<#3277>
4625<?php
4626    if (!$ilDB->tableColumnExists('qpl_qst_fileupload', 'compl_by_submission')) {
4627        $ilDB->addTableColumn('qpl_qst_fileupload', 'compl_by_submission', array(
4628            'type' => 'integer',
4629            'length' => 1,
4630            'notnull' => true,
4631            'default' => 0
4632        ));
4633    }
4634?>
4635<#3278>
4636<?php
4637    if (!$ilDB->tableColumnExists('payment_objects', 'subtype')) {
4638        $ilDB->addTableColumn("payment_objects", "subtype", array(
4639            "type" => "text",
4640            "length" => 10,
4641            "notnull" => false,
4642            "default" => null));
4643    }
4644?>
4645<#3279>
4646<?php
4647    if (!$ilDB->tableColumnExists('payment_settings', 'mail_use_placeholders')) {
4648        $ilDB->addTableColumn("payment_settings", "mail_use_placeholders", array(
4649            "type" => "integer",
4650            "length" => 1,
4651            "notnull" => true,
4652            "default" => 0));
4653    }
4654?>
4655<#3280>
4656<?php
4657    if (!$ilDB->tableColumnExists('payment_settings', 'mail_billing_text')) {
4658        $ilDB->addTableColumn("payment_settings", "mail_billing_text", array(
4659            "type" => "clob",
4660            "notnull" => false,
4661            "default" => null));
4662    }
4663?>
4664<#3281>
4665<?php
4666    if (!$ilDB->tableColumnExists('payment_settings', 'hide_shop_info')) {
4667        $ilDB->addTableColumn("payment_settings", "hide_shop_info", array(
4668            "type" => "integer",
4669            "length" => 1,
4670            "notnull" => true,
4671            "default" => 0));
4672    }
4673?>
4674<#3282>
4675<?php
4676    if (!$ilDB->tableColumnExists('payment_objects', 'is_special')) {
4677        $ilDB->addTableColumn("payment_objects", "is_special", array(
4678            "type" => "integer",
4679            "length" => 1,
4680            "notnull" => true,
4681            "default" => 0));
4682    }
4683?>
4684<#3283>
4685<?php
4686    if (!$ilDB->tableColumnExists('payment_settings', 'use_shop_specials')) {
4687        $ilDB->addTableColumn("payment_settings", "use_shop_specials", array(
4688            "type" => "integer",
4689            "length" => 1,
4690            "notnull" => true,
4691            "default" => 0));
4692    }
4693?>
4694<#3284>
4695<?php
4696    $ilCtrlStructureReader->getStructure();
4697?>
4698<#3285>
4699<?php
4700    $ilCtrlStructureReader->getStructure();
4701?>
4702<#3286>
4703<?php
4704if (!$ilDB->tableExists('usr_portfolio')) {
4705    $ilDB->createTable('usr_portfolio', array(
4706        'id' => array(
4707            'type' => 'integer',
4708            'length' => 4,
4709            'notnull' => true
4710        ),
4711        'user_id' => array(
4712            'type' => 'integer',
4713            'length' => 4,
4714            'notnull' => true
4715        ),
4716        'title' => array(
4717            'type' => 'text',
4718            'length' => 250,
4719            'notnull' => true
4720        ),
4721        'description' => array(
4722            'type' => 'clob',
4723            'notnull' => false
4724        ),
4725        'is_online' => array(
4726            'type' => 'integer',
4727            'length' => 1,
4728            'notnull' => false
4729        ),
4730        'is_default' => array(
4731            'type' => 'integer',
4732            'length' => 1,
4733            'notnull' => false
4734        )
4735    ));
4736    $ilDB->addPrimaryKey('usr_portfolio', array('id'));
4737    $ilDB->createSequence('usr_portfolio');
4738}
4739?>
4740<#3287>
4741<?php
4742if (!$ilDB->tableExists('usr_portfolio_page')) {
4743    $ilDB->createTable('usr_portfolio_page', array(
4744        'id' => array(
4745            'type' => 'integer',
4746            'length' => 4,
4747            'notnull' => true
4748        ),
4749        'portfolio_id' => array(
4750            'type' => 'integer',
4751            'length' => 4,
4752            'notnull' => true
4753        ),
4754        'title' => array(
4755            'type' => 'text',
4756            'length' => 250,
4757            'notnull' => true
4758        ),
4759        'order_nr' => array(
4760            'type' => 'integer',
4761            'length' => 4,
4762            'notnull' => true
4763        ),
4764    ));
4765    $ilDB->addPrimaryKey('usr_portfolio_page', array('id'));
4766    $ilDB->createSequence('usr_portfolio_page');
4767}
4768?>
4769<#3288>
4770<?php
4771    $ilCtrlStructureReader->getStructure();
4772?>
4773<#3289>
4774<?php
4775    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4776    ilDBUpdate3136::addStyleClass(
4777        "QuestionImage",
4778        "qimg",
4779        "img",
4780        array("margin" => "5px")
4781    );
4782?>
4783<#3290>
4784<?php
4785    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4786    ilDBUpdate3136::addStyleClass(
4787        "OrderList",
4788        "qordul",
4789        "ul",
4790        array("margin" => "0px",
4791                    "padding" => "0px",
4792                    "list-style" => "none",
4793                    "list-style-position" => "outside"
4794                    )
4795    );
4796?>
4797<#3291>
4798<?php
4799    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4800    ilDBUpdate3136::addStyleClass(
4801        "OrderListItem",
4802        "qordli",
4803        "li",
4804        array(
4805                    "margin-top" => "5px",
4806                    "margin-bottom" => "5px",
4807                    "margin-left" => "0px",
4808                    "margin-right" => "0px",
4809                    "border-width" => "1px",
4810                    "border-style" => "solid",
4811                    "border-color" => "#D0D0FF",
4812                    "padding" => "10px",
4813                    "cursor" => "move"
4814                    )
4815    );
4816
4817?>
4818<#3292>
4819<?php
4820
4821    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4822    ilDBUpdate3136::addStyleClass(
4823        "ImageDetailsLink",
4824        "qimgd",
4825        "a",
4826        array("font-size" => "90%")
4827    );
4828
4829?>
4830<#3293>
4831<?php
4832    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4833    ilDBUpdate3136::addStyleClass(
4834        "ErrorTextItem",
4835        "qetitem",
4836        "a",
4837        array("text-decoration" => "none",
4838                    "color" => "#000000",
4839                    "padding" => "2px"
4840                    )
4841    );
4842?>
4843<#3294>
4844<?php
4845    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4846    ilDBUpdate3136::addStyleClass(
4847        "ErrorTextItem:hover",
4848        "qetitem",
4849        "a",
4850        array("text-decoration" => "none",
4851                    "color" => "#000000",
4852                    "background-color" => "#D0D0D0"
4853                    )
4854    );
4855?>
4856<#3295>
4857<?php
4858    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4859    ilDBUpdate3136::addStyleClass(
4860        "ErrorTextSelected",
4861        "qetitem",
4862        "a",
4863        array("border-width" => "1px",
4864                    "border-style" => "solid",
4865                    "border-color" => "#606060",
4866                    "background-color" => "#9BD9FE"
4867                    )
4868    );
4869?>
4870<#3296>
4871<?php
4872    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4873    ilDBUpdate3136::addStyleClass(
4874        "ErrorTextCorrected",
4875        "qetcorr",
4876        "span",
4877        array("text-decoration" => "line-through",
4878                    "color" => "#909090"
4879                    )
4880    );
4881?>
4882<#3297>
4883<?php
4884    $set = $ilDB->query(
4885    "SELECT * FROM style_char " .
4886        " WHERE " . $ilDB->like("characteristic", "text", "%:hover%")
4887);
4888    while ($rec = $ilDB->fetchAssoc($set)) {
4889        $s = substr($rec["characteristic"], strlen($rec["characteristic"]) - 6);
4890        if ($s == ":hover") {
4891            $ilDB->manipulate(
4892                "DELETE FROM style_char WHERE " .
4893                " characteristic = " . $ilDB->quote($rec["characteristic"], "text")
4894            );
4895        }
4896    }
4897?>
4898<#3298>
4899<?php
4900    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4901    ilDBUpdate3136::addStyleClass(
4902        "OrderListHorizontal",
4903        "qordul",
4904        "ul",
4905        array("margin" => "0px",
4906                    "padding" => "0px",
4907                    "list-style" => "none",
4908                    "list-style-position" => "outside"
4909                    )
4910    );
4911?>
4912<#3299>
4913<?php
4914    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4915    ilDBUpdate3136::addStyleClass(
4916        "OrderListItemHorizontal",
4917        "qordli",
4918        "li",
4919        array(
4920                    "float" => "left",
4921                    "margin-top" => "5px",
4922                    "margin-bottom" => "5px",
4923                    "margin-right" => "10px",
4924                    "border-width" => "1px",
4925                    "border-style" => "solid",
4926                    "border-color" => "#D0D0FF",
4927                    "padding" => "10px",
4928                    "cursor" => "move"
4929                    )
4930    );
4931
4932?>
4933<#3300>
4934<?php
4935    $ilCtrlStructureReader->getStructure();
4936?>
4937<#3301>
4938<?php
4939    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4940    ilDBUpdate3136::addStyleClass(
4941        "ErrorText",
4942        "question",
4943        "div",
4944        array()
4945    );
4946?>
4947<#3302>
4948<?php
4949    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
4950    ilDBUpdate3136::addStyleClass(
4951        "TextSubset",
4952        "question",
4953        "div",
4954        array()
4955    );
4956?>
4957<#3303>
4958<?php
4959    $ilCtrlStructureReader->getStructure();
4960?>
4961<#3304>
4962<?php
4963$ilDB->modifyTableColumn('frm_settings', 'notification_type', array(
4964    "type" => "text",
4965    "notnull" => false,
4966    "length" => 10,
4967    "default" => null));
4968?>
4969<#3305>
4970<?php
4971
4972$set = $ilDB->query("SELECT * FROM object_data WHERE type = 'sty'");
4973
4974while ($rec = $ilDB->fetchAssoc($set)) {	// all styles
4975    $imgs = array("icon_pin.png", "icon_pin_on.png");
4976
4977    $a_style_id = $rec["obj_id"];
4978
4979    $sty_data_dir = CLIENT_WEB_DIR . "/sty";
4980    ilUtil::makeDir($sty_data_dir);
4981
4982    $style_dir = $sty_data_dir . "/sty_" . $a_style_id;
4983    ilUtil::makeDir($style_dir);
4984
4985    // create images subdirectory
4986    $im_dir = $style_dir . "/images";
4987    ilUtil::makeDir($im_dir);
4988
4989    // create thumbnails directory
4990    $thumb_dir = $style_dir . "/images/thumbnails";
4991    ilUtil::makeDir($thumb_dir);
4992
4993    //	ilObjStyleSheet::_createImagesDirectory($rec["obj_id"]);
4994    $imdir = CLIENT_WEB_DIR . "/sty/sty_" . $a_style_id .
4995            "/images";
4996    foreach ($imgs as $cim) {
4997        if (!is_file($imdir . "/" . $cim)) {
4998            copy("./Services/Style/basic_style/images/" . $cim, $imdir . "/" . $cim);
4999        }
5000    }
5001}
5002?>
5003<#3306>
5004<?php
5005    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
5006    ilDBUpdate3136::addStyleClass(
5007        "ContentPopup",
5008        "iim",
5009        "div",
5010        array("background-color" => "#FFFFFF",
5011                    "border-color" => "#A0A0A0",
5012                    "border-style" => "solid",
5013                    "border-width" => "2px",
5014                    "padding-top" => "5px",
5015                    "padding-right" => "10px",
5016                    "padding-bottom" => "5px",
5017                    "padding-left" => "10px"
5018                    )
5019    );
5020?>
5021<#3307>
5022<?php
5023    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
5024    ilDBUpdate3136::addStyleClass(
5025        "Marker",
5026        "marker",
5027        "a",
5028        array("display" => "block",
5029                    "cursor" => "pointer",
5030                    "width" => "27px",
5031                    "height" => "32px",
5032                    "position" => "absolute",
5033                    "background-image" => "icon_pin.png"
5034                    )
5035    );
5036?>
5037<#3308>
5038<?php
5039    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
5040    ilDBUpdate3136::addStyleClass(
5041        "Marker:hover",
5042        "marker",
5043        "a",
5044        array("background-image" => "icon_pin_on.png"
5045                    )
5046    );
5047?>
5048<#3309>
5049<?php
5050    $set = $ilDB->query(
5051    "SELECT * FROM style_char " .
5052        " WHERE " . $ilDB->like("characteristic", "text", "%:hover%")
5053);
5054    while ($rec = $ilDB->fetchAssoc($set)) {
5055        $s = substr($rec["characteristic"], strlen($rec["characteristic"]) - 6);
5056        if ($s == ":hover") {
5057            $ilDB->manipulate(
5058                "DELETE FROM style_char WHERE " .
5059                " characteristic = " . $ilDB->quote($rec["characteristic"], "text")
5060            );
5061        }
5062    }
5063?>
5064<#3310>
5065<?php
5066if (!$ilDB->tableExists('usr_portf_acl')) {
5067    $fields = array(
5068        'node_id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
5069        'object_id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0)
5070      );
5071    $ilDB->createTable('usr_portf_acl', $fields);
5072    $ilDB->addPrimaryKey('usr_portf_acl', array('node_id', 'object_id'));
5073}
5074?>
5075<#3311>
5076<?php
5077    $ilCtrlStructureReader->getStructure();
5078?>
5079<#3312>
5080<?php
5081    if (!$ilDB->tableColumnExists('note', 'no_repository')) {
5082        $ilDB->addTableColumn("note", "no_repository", array(
5083            "type" => "integer",
5084            "length" => 1,
5085            "notnull" => false,
5086            "default" => 0));
5087    }
5088?>
5089<#3313>
5090<?php
5091    $ilDB->createTable(
5092    'ecs_server',
5093    array(
5094            'server_id' => array('type' => 'integer','length' => 4, 'notnull' => false, 'default' => 0),
5095            'active' => array('type' => 'integer','length' => 1, 'notnull' => false, 'default' => 0),
5096            'protocol' => array('type' => 'integer','length' => 1, 'notnull' => false, 'default' => 1),
5097            'server' => array('type' => 'text', 'length' => 255, 'notnull' => false),
5098            'port' => array('type' => 'integer','length' => 2, 'notnull' => false, 'default' => 1),
5099            'auth_type' => array('type' => 'integer', 'length' => 1, 'notnull' => false, 'default' => 1),
5100            'client_cert_path' => array('type' => 'text', 'length' => 512, 'notnull' => false),
5101            'ca_cert_path' => array('type' => 'text', 'length' => 512, 'notnull' => false),
5102            'key_path' => array('type' => 'text', 'length' => 512, 'notnull' => false),
5103            'key_password' => array('type' => 'text', 'length' => 32, 'notnull' => false),
5104            'cert_serial' => array('type' => 'text', 'length' => 32, 'notnull' => false),
5105            'polling_time' => array('type' => 'integer','length' => 4, 'notnull' => false, 'default' => 0),
5106            'import_id' => array('type' => 'integer','length' => 4, 'notnull' => false, 'default' => 0),
5107            'global_role' => array('type' => 'integer','length' => 4, 'notnull' => false, 'default' => 0),
5108            'econtent_rcp' => array('type' => 'text', 'length' => 512, 'notnull' => false),
5109            'user_rcp' => array('type' => 'text', 'length' => 512, 'notnull' => false),
5110            'approval_rcp' => array('type' => 'text', 'length' => 512, 'notnull' => false),
5111            'duration' => array('type' => 'integer','length' => 4, 'notnull' => false, 'default' => 0)
5112        )
5113);
5114    $ilDB->createSequence('ecs_server');
5115
5116?>
5117<#3314>
5118<?php
5119    if (!$ilDB->tableColumnExists('payment_statistic', 'access_startdate')) {
5120        $ilDB->addTableColumn(
5121            'payment_statistic',
5122            'access_startdate',
5123            array(
5124                'type' => 'timestamp',
5125                'notnull' => false
5126            )
5127        );
5128    }
5129?>
5130<#3315>
5131<?php
5132
5133    // Migration of ecs settings
5134    $query = 'SELECT * FROM settings WHERE ' .
5135        'module = ' . $ilDB->quote('ecs', 'text');
5136    $res = $ilDB->query($query);
5137
5138    $ecs = array();
5139    while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
5140        $ecs[$row->keyword] = $row->value;
5141    }
5142    if (count($ecs)) {
5143        $ilDB->manipulate('INSERT INTO ecs_server (server_id,active,protocol,server,port,auth_type,client_cert_path,ca_cert_path,' .
5144            'key_path,key_password,cert_serial,polling_time,import_id,global_role,econtent_rcp,user_rcp,approval_rcp,duration) ' .
5145            'VALUES (' .
5146            $ilDB->quote($ilDB->nextId('ecs_server'), 'integer') . ', ' .
5147            $ilDB->quote($ecs['active'], 'integer') . ', ' .
5148            $ilDB->quote($ecs['protocol'], 'integer') . ', ' .
5149            $ilDB->quote($ecs['server'], 'text') . ', ' .
5150            $ilDB->quote($ecs['port'], 'integer') . ', ' .
5151            $ilDB->quote(1, 'integer') . ', ' .
5152            $ilDB->quote($ecs['client_cert_path'], 'text') . ', ' .
5153            $ilDB->quote($ecs['ca_cert_path'], 'text') . ', ' .
5154            $ilDB->quote($ecs['key_path'], 'text') . ', ' .
5155            $ilDB->quote($ecs['key_password'], 'text') . ', ' .
5156            $ilDB->quote($ecs['cert_serial'], 'text') . ', ' .
5157            $ilDB->quote($ecs['polling_time'], 'integer') . ', ' .
5158            $ilDB->quote($ecs['import_id'], 'integer') . ', ' .
5159            $ilDB->quote($ecs['global_role'], 'integer') . ', ' .
5160            $ilDB->quote($ecs['econtent_rcp'], 'text') . ', ' .
5161            $ilDB->quote($ecs['user_rcp'], 'text') . ', ' .
5162            $ilDB->quote($ecs['approval_rcp'], 'text') . ', ' .
5163            $ilDB->quote($ecs['duration'], 'integer') .
5164            ')');
5165    }
5166?>
5167<#3316>
5168<?php
5169    $ilDB->modifyTableColumn(
5170    'cal_entries',
5171    'context_id',
5172    array("type" => "integer", "length" => 4, "default" => 0, "notnull" => true)
5173);
5174?>
5175<#3317>
5176<?php
5177    $ilCtrlStructureReader->getStructure();
5178?>
5179<#3318>
5180<?php
5181    if (!$ilDB->tableColumnExists('payment_settings', 'show_general_filter')) {
5182        $ilDB->addTableColumn(
5183            'payment_settings',
5184            'show_general_filter',
5185            array(  "type" => "integer",
5186                "length" => 1,
5187                "notnull" => false,
5188                "default" => 0)
5189        );
5190    }
5191?>
5192<#3319>
5193<?php
5194    if (!$ilDB->tableColumnExists('payment_settings', 'show_topics_filter')) {
5195        $ilDB->addTableColumn(
5196            'payment_settings',
5197            'show_topics_filter',
5198            array(  "type" => "integer",
5199                "length" => 1,
5200                "notnull" => false,
5201                "default" => 0)
5202        );
5203    }
5204?>
5205<#3320>
5206<?php
5207    if (!$ilDB->tableColumnExists('payment_settings', 'show_shop_explorer')) {
5208        $ilDB->addTableColumn(
5209            'payment_settings',
5210            'show_shop_explorer',
5211            array(  "type" => "integer",
5212                "length" => 1,
5213                "notnull" => false,
5214                "default" => 0)
5215        );
5216    }
5217?>
5218<#3321>
5219<?php
5220    if (!$ilDB->tableColumnExists('payment_settings', 'ud_invoice_number')) {
5221        $ilDB->addTableColumn('payment_settings', 'ud_invoice_number', array(
5222            'type' => 'integer',
5223            'length' => 1,
5224            'notnull' => true,
5225            'default' => 0));
5226    }
5227?>
5228<#3322>
5229<?php
5230    if (!$ilDB->tableColumnExists('payment_settings', 'invoice_number_text')) {
5231        $ilDB->addTableColumn('payment_settings', 'invoice_number_text', array(
5232            'type' => 'text',
5233            'length' => 255,
5234            'notnull' => false,
5235            'default' => null));
5236    }
5237?>
5238<#3323>
5239<?php
5240    if (!$ilDB->tableColumnExists('payment_settings', 'inc_start_value')) {
5241        $ilDB->addTableColumn('payment_settings', 'inc_start_value', array(
5242            'type' => 'integer',
5243            'length' => 4,
5244            'notnull' => true,
5245            'default' => 0));
5246    }
5247?>
5248<#3324>
5249<?php
5250    if (!$ilDB->tableColumnExists('payment_settings', 'inc_current_value')) {
5251        $ilDB->addTableColumn('payment_settings', 'inc_current_value', array(
5252            'type' => 'integer',
5253            'length' => 4,
5254            'notnull' => true));
5255    }
5256?>
5257<#3325>
5258<?php
5259    if (!$ilDB->tableColumnExists('payment_settings', 'inc_reset_period')) {
5260        $ilDB->addTableColumn('payment_settings', 'inc_reset_period', array(
5261            'type' => 'integer',
5262            'length' => 1,
5263            'notnull' => true,
5264            'default' => 0));
5265    }
5266?>
5267<#3326>
5268<?php
5269    if (!$ilDB->tableColumnExists('payment_settings', 'inc_last_reset')) {
5270        $ilDB->addTableColumn('payment_settings', 'inc_last_reset', array(
5271            'type' => 'integer',
5272            'length' => 4,
5273            'notnull' => true));
5274    }
5275?>
5276<#3327>
5277<?php
5278    $ilDB->update(
5279    'payment_settings',
5280    array('inc_last_reset' => array('integer', time())),
5281    array('settings_id' => array('integer', 1))
5282);
5283?>
5284<#3328>
5285<?php
5286        $fields = array(
5287        'obj_id' => array(
5288            'type' => 'integer',
5289            'length' => 4,
5290            'notnull' => true
5291            ),
5292        'obj_type' => array(
5293            'type' => 'text',
5294            'length' => 10,
5295            'notnull' => true
5296            ),
5297        'yyyy' => array(
5298            'type' => 'integer',
5299            'length' => 2,
5300            'notnull' => false
5301            ),
5302        'mm' => array(
5303            'type' => 'integer',
5304            'length' => 1,
5305            'notnull' => false
5306            ),
5307        'dd' => array(
5308            'type' => 'integer',
5309            'length' => 1,
5310            'notnull' => false
5311            ),
5312        'hh' => array(
5313            'type' => 'integer',
5314            'length' => 1,
5315            'notnull' => false
5316            ),
5317        'read_count' => array(
5318            'type' => 'integer',
5319            'length' => 4,
5320            'notnull' => false
5321            ),
5322        'childs_read_count' => array(
5323            'type' => 'integer',
5324            'length' => 4,
5325            'notnull' => false
5326            ),
5327        'spent_seconds' => array(
5328            'type' => 'integer',
5329            'length' => 4,
5330            'notnull' => false
5331            ),
5332        'childs_spent_seconds' => array(
5333            'type' => 'integer',
5334            'length' => 4,
5335            'notnull' => false
5336            ),
5337    );
5338    $ilDB->createTable('obj_stat', $fields);
5339    $ilDB->addIndex("obj_stat", array("obj_id", "yyyy", "mm"), "i1");
5340?>
5341<#3329>
5342<?php
5343        $fields = array(
5344        'obj_id' => array(
5345            'type' => 'integer',
5346            'length' => 4,
5347            'notnull' => true
5348            ),
5349        'obj_type' => array(
5350            'type' => 'text',
5351            'length' => 10,
5352            'notnull' => true
5353            ),
5354        'tstamp' => array(
5355            'type' => 'integer',
5356            'length' => 4,
5357            'notnull' => false
5358            ),
5359        'yyyy' => array(
5360            'type' => 'integer',
5361            'length' => 2,
5362            'notnull' => false
5363            ),
5364        'mm' => array(
5365            'type' => 'integer',
5366            'length' => 1,
5367            'notnull' => false
5368            ),
5369        'dd' => array(
5370            'type' => 'integer',
5371            'length' => 1,
5372            'notnull' => false
5373            ),
5374        'hh' => array(
5375            'type' => 'integer',
5376            'length' => 1,
5377            'notnull' => false
5378            ),
5379        'read_count' => array(
5380            'type' => 'integer',
5381            'length' => 4,
5382            'notnull' => false
5383            ),
5384        'childs_read_count' => array(
5385            'type' => 'integer',
5386            'length' => 4,
5387            'notnull' => false
5388            ),
5389        'spent_seconds' => array(
5390            'type' => 'integer',
5391            'length' => 4,
5392            'notnull' => false
5393            ),
5394        'childs_spent_seconds' => array(
5395            'type' => 'integer',
5396            'length' => 4,
5397            'notnull' => false
5398            ),
5399    );
5400    $ilDB->createTable('obj_stat_tmp', $fields);
5401?>
5402<#3330>
5403<?php
5404        $fields = array(
5405        'obj_id' => array(
5406            'type' => 'integer',
5407            'length' => 4,
5408            'notnull' => true
5409            ),
5410        'obj_type' => array(
5411            'type' => 'text',
5412            'length' => 10,
5413            'notnull' => true
5414            ),
5415        'tstamp' => array(
5416            'type' => 'integer',
5417            'length' => 4,
5418            'notnull' => false
5419            ),
5420        'yyyy' => array(
5421            'type' => 'integer',
5422            'length' => 2,
5423            'notnull' => false
5424            ),
5425        'mm' => array(
5426            'type' => 'integer',
5427            'length' => 1,
5428            'notnull' => false
5429            ),
5430        'dd' => array(
5431            'type' => 'integer',
5432            'length' => 1,
5433            'notnull' => false
5434            ),
5435        'hh' => array(
5436            'type' => 'integer',
5437            'length' => 1,
5438            'notnull' => false
5439            ),
5440        'read_count' => array(
5441            'type' => 'integer',
5442            'length' => 4,
5443            'notnull' => false
5444            ),
5445        'childs_read_count' => array(
5446            'type' => 'integer',
5447            'length' => 4,
5448            'notnull' => false
5449            ),
5450        'spent_seconds' => array(
5451            'type' => 'integer',
5452            'length' => 4,
5453            'notnull' => false
5454            ),
5455        'childs_spent_seconds' => array(
5456            'type' => 'integer',
5457            'length' => 4,
5458            'notnull' => false
5459            ),
5460    );
5461    $ilDB->createTable('obj_stat_log', $fields);
5462?>
5463<#3331>
5464<?php
5465    $ilCtrlStructureReader->getStructure();
5466?>
5467<#3332>
5468<?php
5469if (!$ilDB->tableExists('cp_datamap')) {
5470    $fields = array(
5471        "sco_node_id" => array(
5472            "notnull" => true
5473            ,"length" => 4
5474            ,"unsigned" => false
5475            ,"default" => "0"
5476            ,"type" => "integer"
5477        )
5478        ,"cp_node_id" => array(
5479            "notnull" => false
5480            ,"length" => 4
5481            ,"unsigned" => false
5482            ,"default" => "0"
5483            ,"type" => "integer"
5484        )
5485        ,"slm_id" => array(
5486            "notnull" => true
5487            ,"length" => 4
5488            ,"type" => "integer"
5489        )
5490        ,"target_id" => array(
5491            "notnull" => true
5492            ,"length" => 4000
5493            ,"fixed" => false
5494            ,"type" => "text"
5495        )
5496        ,"read_shared_data" => array(
5497            "notnull" => false
5498            ,"length" => 1
5499            ,"unsigned" => false
5500            ,"default" => "1"
5501            ,"type" => "integer"
5502        )
5503        ,"write_shared_data" => array(
5504            "notnull" => false
5505            ,"length" => 1
5506            ,"unsigned" => false
5507            ,"default" => "1"
5508            ,"type" => "integer"
5509        )
5510    );
5511    $ilDB->createTable("cp_datamap", $fields);
5512
5513    $pk_fields = array("cp_node_id");
5514    $ilDB->addPrimaryKey("cp_datamap", $pk_fields);
5515}
5516?>
5517<#3333>
5518<?php
5519if (!$ilDB->tableExists('adl_shared_data')) {
5520    $fields = array(
5521        "slm_id" => array(
5522            "notnull" => true
5523            ,"length" => 4
5524            ,"type" => "integer"
5525        )
5526        ,"user_id" => array(
5527            "notnull" => true
5528            ,"length" => 4
5529            ,"type" => "integer"
5530        )
5531        ,"target_id" => array(
5532            "notnull" => true
5533            ,"length" => 4000
5534            ,"fixed" => false
5535            ,"type" => "text"
5536        )
5537        ,"store" => array(
5538            "notnull" => false
5539            ,"type" => "clob"
5540        )
5541    );
5542    $ilDB->createTable("adl_shared_data", $fields);
5543}
5544?>
5545<#3334>
5546<?php
5547    $ilDB->addTableColumn("cp_package", "shared_data_global_to_system", array(
5548        "type" => "integer",
5549        "notnull" => false,
5550        "unsigned" => false,
5551        "default" => "1",
5552        "length" => 1));
5553?>
5554<#3335>
5555<?php
5556    if ($ilDB->tableExists('cmi_gobjective')) {
5557        $ilDB->addTableColumn("cmi_gobjective", "score_raw", array(
5558            "type" => "text",
5559            "notnull" => false,
5560            "length" => 50));
5561        $ilDB->addTableColumn("cmi_gobjective", "score_min", array(
5562            "type" => "text",
5563            "notnull" => false,
5564            "length" => 50));
5565        $ilDB->addTableColumn("cmi_gobjective", "score_max", array(
5566            "type" => "text",
5567            "notnull" => false,
5568            "length" => 50));
5569        $ilDB->addTableColumn("cmi_gobjective", "progress_measure", array(
5570            "type" => "text",
5571            "notnull" => false,
5572            "length" => 50));
5573        $ilDB->addTableColumn("cmi_gobjective", "completion_status", array(
5574            "type" => "text",
5575            "notnull" => false,
5576            "length" => 50));
5577    }
5578?>
5579<#3336>
5580<?php
5581    $ilDB->addTableColumn("cp_item", "progressweight", array(
5582        "type" => "text",
5583        "notnull" => false,
5584        "default" => "1.0",
5585        "fixed" => false,
5586        "length" => 50));
5587    $ilDB->addTableColumn("cp_item", "completedbymeasure", array(
5588        "type" => "integer",
5589        "notnull" => false,
5590        "unsigned" => false,
5591        "default" => "0",
5592        "length" => 1));
5593    $ilDB->modifyTableColumn("cp_item", "completionthreshold", array("default" => "1.0"));
5594?>
5595<#3337>
5596<?php
5597    // cmi_objective completion_status from double to text
5598    $ilDB->addTableColumn(
5599        "cmi_objective",
5600        "completion_status_tmp",
5601        array(
5602        "type" => "text",
5603        "length" => 32,
5604        "notnull" => false,
5605        "default" => null)
5606    );
5607
5608    $ilDB->manipulate('UPDATE cmi_objective SET completion_status_tmp = completion_status');
5609    $ilDB->dropTableColumn('cmi_objective', 'completion_status');
5610    $ilDB->renameTableColumn("cmi_objective", "completion_status_tmp", "completion_status");
5611?>
5612<#3338>
5613<?php
5614    if (!$ilDB->tableColumnExists('ecs_server', 'title')) {
5615        $ilDB->addTableColumn(
5616            "ecs_server",
5617            "title",
5618            array(
5619            "type" => "text",
5620            "length" => 128,
5621            "notnull" => false,
5622            "default" => null)
5623        );
5624    }
5625?>
5626<#3339>
5627<?php
5628if (!$ilDB->tableColumnExists('tst_active', 'importname')) {
5629    $ilDB->addTableColumn(
5630        "tst_active",
5631        "importname",
5632        array(
5633                "type" => "text",
5634                "notnull" => false,
5635                "length" => 400,
5636                "fixed" => false)
5637    );
5638}
5639?>
5640<#3340>
5641<?php
5642    if (!$ilDB->tableExists('ecs_part_settings')) {
5643        $fields = array(
5644            "sid" => array("notnull" => true,"length" => 4,"type" => "integer"),
5645            "mid" => array("notnull" => true,"length" => 4,"type" => "integer"),
5646            "export" => array("notnull" => true,"length" => 1,"type" => "integer"),
5647            "import" => array("notnull" => true,"length" => 1,"type" => "integer"),
5648            "import_type" => array("notnull" => false,'length' => 1, "type" => "integer")
5649        );
5650        $ilDB->createTable("ecs_part_settings", $fields);
5651    }
5652?>
5653<#3341>
5654<?php
5655    if (!$ilDB->tableExists('ecs_data_mapping')) {
5656        $fields = array(
5657            "sid" => array("notnull" => true,"length" => 4,"type" => "integer"),
5658            "import_type" => array("notnull" => true,"length" => 1,"type" => "integer"),
5659            "ecs_field" => array("notnull" => false,'length' => 32,"type" => "text"),
5660            "advmd_id" => array("notnull" => true, "length" => 4, "type" => "integer")
5661        );
5662        $ilDB->createTable("ecs_data_mapping", $fields);
5663        $ilDB->addPrimaryKey('ecs_data_mapping', array('sid','import_type','ecs_field'));
5664    }
5665?>
5666<#3342>
5667<?php
5668    if (!$ilDB->tableExists('payment_tmp')) {
5669        $fields = array(
5670        'keyword' => array('type' => 'text', 'length' => 50,'notnull' => true, "fixed" => false),
5671        'value' => array('type' => 'clob', 'notnull' => false, 'default' => null),
5672        'scope' => array('type' => 'text', 'length' => 50,'notnull' => false, "default" => null)
5673        );
5674        $ilDB->createTable('payment_tmp', $fields);
5675        $ilDB->addPrimaryKey('payment_tmp', array('keyword'));
5676    }
5677?>
5678<#3343>
5679<?php
5680$old = array();
5681$res = $ilDB->query('SELECT * FROM payment_settings');
5682$old = $ilDB->fetchAssoc($res);
5683
5684if ($old == null) {
5685    //use default values
5686    $old['settings_id'] = '0';
5687    $old['currency_unit'] = null;
5688    $old['currency_subunit'] = null;
5689    $old['address'] = null;
5690    $old['bank_data'] = null;
5691    $old['add_info'] = null;
5692    $old['pdf_path'] = null;
5693    $old['paypal'] = null;
5694    $old['bmf'] = null;
5695    $old['topics_allow_custom_sorting'] = '0';
5696    $old['topics_sorting_type'] = '0';
5697    $old['topics_sorting_direction'] = null;
5698    $old['shop_enabled'] = '0';
5699    $old['max_hits'] = '0';
5700    $old['hide_advanced_search'] = null;
5701    $old['objects_allow_custom_sorting'] = '0';
5702    $old['hide_coupons'] = null;
5703    $old['epay '] = null;
5704    $old['hide_news'] = null;
5705    $old['mail_use_placeholders'] = '0';
5706    $old['mail_billing_text'] = null;
5707    $old['hide_shop_info'] = '0';
5708    $old['use_shop_specials'] = '0';
5709    $old['ud_invoice_number'] = '0';
5710    $old['invoice_number_text'] = null;
5711    $old['inc_start_value'] = '0';
5712    $old['inc_current_value'] = '0';
5713    $old['inc_reset_period'] = '0';
5714    $old['inc_last_reset'] = null;
5715    $old['show_general_filter'] = '0';
5716    $old['show_topics_filter'] = '0';
5717    $old['show_shop_explorer'] = '0';
5718}
5719foreach ($old as $key => $value) {
5720    switch ($key) {
5721        case 'paypal':
5722            $scope = 'paypal';
5723            break;
5724        case 'bmf':
5725            $scope = 'bmf';
5726            break;
5727        case 'epay':
5728            $scope = 'epay';
5729            break;
5730
5731        case 'currency_unit':
5732        case 'currency_subunit':
5733            $scope = 'currencies';
5734            break;
5735
5736        case 'address':
5737        case 'bank_data':
5738        case 'add_info':
5739        case 'pdf_path':
5740        case 'mail_use_placeholders':
5741        case 'mail_billing_text':
5742            $scope = 'invoice';
5743            break;
5744
5745        case 'ud_invoice_number':
5746        case 'ud_shop_specials':
5747        case 'invoice_number_text':
5748        case 'inc_start_value':
5749        case 'inc_currend_value':
5750        case 'inc_reset_period':
5751        case 'inc_last_reset':
5752            $scope = 'invoice_number';
5753            break;
5754        case 'topics_allow_custom_sorting':
5755        case 'topics_sorting_type':
5756        case 'topics_sorting_direction':
5757        case 'max_hits':
5758        case 'hide_advanced_search':
5759        case 'objects_allow_custom_sorting':
5760        case 'hide_coupons':
5761        case 'hide_news':
5762        case 'hide_shop_info':
5763        case 'show_general_filter':
5764        case 'show_topics_filter':
5765        case 'show_shop_explorer':
5766        case 'use_shop_specials':
5767            $scope = 'gui';
5768            break;
5769
5770        case 'shop_enabled':
5771            $scope = 'common';
5772            break;
5773
5774        default:
5775            // for custom settings
5776            $scope = null;
5777            break;
5778
5779    }
5780
5781    $ilDB->insert(
5782        'payment_tmp',
5783        array(
5784        'keyword' => array('text', $key),
5785        'value' => array('clob', $value),
5786        'scope' => array('text', $scope)
5787    )
5788    );
5789}
5790?>
5791<#3344>
5792<?php
5793    if ($ilDB->tableExists('payment_settings')) {
5794        $ilDB->dropTable('payment_settings');
5795    }
5796    if ($ilDB->tableExists('payment_settings_seq')) {
5797        $ilDB->dropTable('payment_settings_seq');
5798    }
5799?>
5800<#3345>
5801<?php
5802    if ($ilDB->tableExists('payment_tmp')) {
5803        $ilDB->renameTable('payment_tmp', 'payment_settings');
5804    }
5805?>
5806<#3346>
5807<?php
5808
5809    $ilDB->dropPrimaryKey('ecs_data_mapping');
5810    $ilDB->renameTableColumn('ecs_data_mapping', 'import_type', 'mapping_type');
5811    $ilDB->addPrimaryKey('ecs_data_mapping', array('sid','mapping_type','ecs_field'));
5812?>
5813<#3347>
5814<?php
5815    if (!$ilDB->tableColumnExists("acl_ws", "extended_data")) {
5816        $ilDB->addTableColumn("acl_ws", "extended_data", array(
5817            "type" => "text",
5818            "notnull" => false,
5819            "length" => 200,
5820            "fixed" => false));
5821    }
5822?>
5823<#3348>
5824<?php
5825    $ilCtrlStructureReader->getStructure();
5826?>
5827<#3349>
5828<?php
5829    $ilCtrlStructureReader->getStructure();
5830?>
5831<#3350>
5832<?php
5833    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
5834    ilDBUpdate3136::addStyleClass(
5835        "Correct",
5836        "qover",
5837        "div",
5838        array(
5839                    "margin-top" => "20px",
5840                    "margin-bottom" => "20px",
5841                    "padding-top" => "10px",
5842                    "padding-right" => "60px",
5843                    "padding-bottom" => "10px",
5844                    "padding-left" => "30px",
5845                    "background-color" => "#E7FFE7",
5846                    "border-width" => "1px",
5847                    "border-style" => "solid",
5848                    "border-color" => "#808080"
5849                )
5850    );
5851?>
5852<#3351>
5853<?php
5854    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
5855    ilDBUpdate3136::addStyleClass(
5856        "Incorrect",
5857        "qover",
5858        "div",
5859        array(
5860                    "margin-top" => "20px",
5861                    "margin-bottom" => "20px",
5862                    "padding-top" => "10px",
5863                    "padding-right" => "60px",
5864                    "padding-bottom" => "10px",
5865                    "padding-left" => "30px",
5866                    "background-color" => "#FFE7E7",
5867                    "border-width" => "1px",
5868                    "border-style" => "solid",
5869                    "border-color" => "#808080"
5870                )
5871    );
5872?>
5873<#3352>
5874<?php
5875    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
5876    ilDBUpdate3136::addStyleClass(
5877        "StatusMessage",
5878        "qover",
5879        "div",
5880        array(
5881                    "padding-bottom" => "7px"
5882                )
5883    );
5884?>
5885<#3353>
5886<?php
5887    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
5888    ilDBUpdate3136::addStyleClass(
5889        "WrongAnswersMessage",
5890        "qover",
5891        "div",
5892        array(
5893                )
5894    );
5895?>
5896<#3354>
5897<?php
5898    if (!$ilDB->tableColumnExists("ecs_import", "server_id")) {
5899        $ilDB->addTableColumn(
5900            "ecs_import",
5901            "server_id",
5902            array(
5903            "type" => "integer",
5904            "notnull" => true,
5905            "length" => 4,
5906            "default" => 0)
5907        );
5908    }
5909    $ilDB->dropPrimaryKey('ecs_import');
5910    $ilDB->addPrimaryKey('ecs_import', array('server_id','obj_id'));
5911?>
5912<#3355>
5913<?php
5914
5915    $res = $ilDB->query('SELECT server_id FROM ecs_server');
5916
5917    if ($res->numRows()) {
5918        $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
5919        $query = 'UPDATE ecs_import SET server_id = ' . $ilDB->quote($row->server_id);
5920        $ilDB->manipulate($query);
5921    }
5922?>
5923<#3356>
5924<?php
5925    $ilCtrlStructureReader->getStructure();
5926?>
5927<#3357>
5928<?php
5929$ilDB->addTableColumn("sahs_lm", "localization", array(
5930    "type" => "text",
5931    "notnull" => false,
5932    "length" => 2
5933));
5934?>
5935
5936<#3358>
5937<?php
5938    if (!$ilDB->tableColumnExists("ecs_export", "server_id")) {
5939        $ilDB->addTableColumn(
5940            "ecs_export",
5941            "server_id",
5942            array(
5943            "type" => "integer",
5944            "notnull" => true,
5945            "length" => 4,
5946            "default" => 0)
5947        );
5948    }
5949    $ilDB->dropPrimaryKey('ecs_export');
5950    $ilDB->addPrimaryKey('ecs_export', array('server_id','obj_id'));
5951?>
5952<#3359>
5953<?php
5954
5955    $res = $ilDB->query('SELECT server_id FROM ecs_server');
5956
5957    if ($res->numRows()) {
5958        $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
5959        $query = 'UPDATE ecs_export SET server_id = ' . $ilDB->quote($row->server_id);
5960        $ilDB->manipulate($query);
5961    }
5962?>
5963<#3360>
5964<?php
5965    $ilCtrlStructureReader->getStructure();
5966?>
5967<#3361>
5968<?php
5969    if (!$ilDB->tableColumnExists("ecs_part_settings", "title")) {
5970        $ilDB->addTableColumn(
5971            "ecs_part_settings",
5972            "title",
5973            array(
5974            "type" => "text",
5975            "notnull" => false,
5976            "length" => 255
5977            )
5978        );
5979        $ilDB->addTableColumn(
5980            "ecs_part_settings",
5981            "cname",
5982            array(
5983            "type" => "text",
5984            "notnull" => false,
5985            "length" => 255
5986            )
5987        );
5988    }
5989?>
5990<#3362>
5991<?php
5992    if (!$ilDB->tableColumnExists("exc_assignment", "type")) {
5993        $ilDB->addTableColumn(
5994            "exc_assignment",
5995            "type",
5996            array(
5997            "type" => "integer",
5998            "notnull" => true,
5999            "length" => 1,
6000            "default" => 1
6001            )
6002        );
6003    }
6004?>
6005<#3363>
6006<?php
6007    if (!$ilDB->tableExists('ecs_community')) {
6008        $fields = array(
6009            'sid' => array('type' => 'integer', 'length' => 4,'notnull' => true),
6010            'cid' => array('type' => 'integer', 'length' => 4, 'notnull' => true),
6011            'own_id' => array('type' => 'integer', 'length' => 4,"notnull" => true),
6012            'cname' => array('type' => 'text', 'length' => 255,"notnull" => false),
6013            'mids' => array('type' => 'text','length' => 512,'notnull' => false)
6014      );
6015        $ilDB->createTable('ecs_community', $fields);
6016        $ilDB->addPrimaryKey('ecs_community', array('sid','cid'));
6017    }
6018?>
6019<#3364>
6020<?php
6021    if (!$ilDB->tableColumnExists("ecs_events", "server_id")) {
6022        $ilDB->addTableColumn(
6023            "ecs_events",
6024            "server_id",
6025            array(
6026            "type" => "integer",
6027            "notnull" => true,
6028            "length" => 4,
6029            "default" => 0)
6030        );
6031    }
6032?>
6033<#3365>
6034<?php
6035
6036    $res = $ilDB->query('SELECT server_id FROM ecs_server');
6037
6038    if ($res->numRows()) {
6039        $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
6040        $query = 'UPDATE ecs_events SET server_id = ' . $ilDB->quote($row->server_id);
6041        $ilDB->manipulate($query);
6042    }
6043?>
6044<#3366>
6045<?php
6046    $ilCtrlStructureReader->getStructure();
6047?>
6048<#3367>
6049<?php
6050    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
6051    ilDBUpdate3136::addStyleClass(
6052        "RTETreeList",
6053        "rte_tul",
6054        "ul",
6055        array()
6056    );
6057    ilDBUpdate3136::addStyleClass(
6058        "RTETreeItem",
6059        "rte_tli",
6060        "li",
6061        array()
6062    );
6063    ilDBUpdate3136::addStyleClass(
6064        "RTETreeExpanded",
6065        "rte_texp",
6066        "a",
6067        array()
6068    );
6069    ilDBUpdate3136::addStyleClass(
6070        "RTETreeCollapsed",
6071        "rte_texp",
6072        "a",
6073        array()
6074    );
6075?>
6076<#3368>
6077<?php
6078$ilDB->manipulate(
6079    "UPDATE style_parameter SET " .
6080    " tag = " . $ilDB->quote("div", "integer") .
6081    " WHERE type = " . $ilDB->quote("rte_node", "text")
6082);
6083?>
6084<#3369>
6085<?php
6086$ilDB->manipulate(
6087    "UPDATE style_parameter SET " .
6088    " tag = " . $ilDB->quote("div", "integer") .
6089    " WHERE type = " . $ilDB->quote("rte_status", "text")
6090);
6091?>
6092<#3370>
6093<?php
6094    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
6095    ilDBUpdate3136::addStyleClass(
6096        "RTETreeCurrent",
6097        "rte_tlink",
6098        "a",
6099        array()
6100    );
6101?>
6102<#3371>
6103<?php
6104    if (!$ilDB->tableColumnExists("usr_portfolio_page", "type")) {
6105        $ilDB->addTableColumn(
6106            "usr_portfolio_page",
6107            "type",
6108            array(
6109            "type" => "integer",
6110            "notnull" => true,
6111            "length" => 1,
6112            "default" => 1)
6113        );
6114    }
6115?>
6116<#3372>
6117<?php
6118    // remove existing portfolios which are not based on object_data
6119    $ilDB->manipulate("DELETE FROM usr_portfolio");
6120    $ilDB->manipulate("DELETE FROM usr_portfolio_page");
6121
6122    // remove obsolete portfolio columns
6123    if ($ilDB->tableColumnExists('usr_portfolio', 'user_id')) {
6124        $ilDB->dropTableColumn('usr_portfolio', 'user_id');
6125    }
6126    if ($ilDB->tableColumnExists('usr_portfolio', 'title')) {
6127        $ilDB->dropTableColumn('usr_portfolio', 'title');
6128    }
6129    if ($ilDB->tableColumnExists('usr_portfolio', 'description')) {
6130        $ilDB->dropTableColumn('usr_portfolio', 'description');
6131    }
6132    $ilDB->dropSequence('usr_portfolio');
6133?>
6134<#3373>
6135<?php
6136    $ilCtrlStructureReader->getStructure();
6137?>
6138<#3374>
6139<?php
6140    if (!$ilDB->tableColumnExists('ecs_server', 'auth_user')) {
6141        $ilDB->addTableColumn(
6142            "ecs_server",
6143            "auth_user",
6144            array(
6145            "type" => "text",
6146            "length" => 32,
6147            "notnull" => false,
6148            "default" => null)
6149        );
6150    }
6151?>
6152<#3375>
6153<?php
6154    if (!$ilDB->tableColumnExists('ecs_server', 'auth_pass')) {
6155        $ilDB->addTableColumn(
6156            "ecs_server",
6157            "auth_pass",
6158            array(
6159            "type" => "text",
6160            "length" => 32,
6161            "notnull" => false,
6162            "default" => null)
6163        );
6164    }
6165?>
6166
6167<#3376>
6168<?php
6169    $setting = new ilSetting();
6170    $sk_step = (int) $setting->get('sk_db');
6171    if ($sk_step <= 0) {
6172        // skill tree
6173        $fields = array(
6174                'skl_tree_id' => array(
6175                        'type' => 'integer',
6176                        'length' => 4,
6177                        'notnull' => true,
6178                        'default' => 0
6179                ),
6180                'child' => array(
6181                        'type' => 'integer',
6182                        'length' => 4,
6183                        'notnull' => true,
6184                        'default' => 0
6185                ),
6186                'parent' => array(
6187                        'type' => 'integer',
6188                        'length' => 4,
6189                        'notnull' => false,
6190                        'default' => null
6191                ),
6192                'lft' => array(
6193                        'type' => 'integer',
6194                        'length' => 4,
6195                        'notnull' => true,
6196                        'default' => 0
6197                ),
6198                'rgt' => array(
6199                        'type' => 'integer',
6200                        'length' => 4,
6201                        'notnull' => true,
6202                        'default' => 0
6203                ),
6204                'depth' => array(
6205                        'type' => 'integer',
6206                        'length' => 2,
6207                        'notnull' => true,
6208                        'default' => 0
6209                )
6210        );
6211        $ilDB->createTable('skl_tree', $fields);
6212    }
6213?>
6214<#3377>
6215<?php
6216    $setting = new ilSetting();
6217    $sk_step = (int) $setting->get('sk_db');
6218    if ($sk_step <= 1) {
6219        // skill tree nodes
6220        $fields = array(
6221                'obj_id' => array(
6222                        'type' => 'integer',
6223                        'length' => 4,
6224                        'notnull' => true,
6225                        'default' => 0
6226
6227                ),
6228                'title' => array(
6229                        'type' => 'text',
6230                        'length' => 200,
6231                        'notnull' => false
6232                ),
6233                'type' => array(
6234                        'type' => 'text',
6235                        'length' => 4,
6236                        'fixed' => true,
6237                        'notnull' => false
6238                ),
6239                'create_date' => array(
6240                        'type' => 'timestamp',
6241                        'notnull' => false
6242                ),
6243                'last_update' => array(
6244                        'type' => 'timestamp',
6245                        'notnull' => false
6246                )
6247        );
6248        $ilDB->createTable('skl_tree_node', $fields);
6249        $ilDB->createSequence('skl_tree_node');
6250        $ilDB->addPrimaryKey("skl_tree_node", array("obj_id"));
6251    }
6252?>
6253<#3378>
6254<?php
6255    $setting = new ilSetting();
6256    $sk_step = (int) $setting->get('sk_db');
6257    if ($sk_step <= 2) {
6258        // add new type "skmg" for skill management
6259        $nid = $ilDB->nextId("object_data");
6260        $ilDB->manipulate("INSERT INTO object_data " .
6261            "(obj_id, type, title, description, owner, create_date, last_update) VALUES (" .
6262            $ilDB->quote($nid, "integer") . "," .
6263            $ilDB->quote("typ", "text") . "," .
6264            $ilDB->quote("skmg", "text") . "," .
6265            $ilDB->quote("Skill Management", "text") . "," .
6266            $ilDB->quote(-1, "integer") . "," .
6267            $ilDB->now() . "," .
6268            $ilDB->now() .
6269            ")");
6270        $typ_id = $nid;
6271
6272        // add skill management node in settings folder
6273        $nid = $ilDB->nextId("object_data");
6274        $ilDB->manipulate("INSERT INTO object_data " .
6275            "(obj_id, type, title, description, owner, create_date, last_update) VALUES (" .
6276            $ilDB->quote($nid, "integer") . "," .
6277            $ilDB->quote("skmg", "text") . "," .
6278            $ilDB->quote("__SkillManagement", "text") . "," .
6279            $ilDB->quote("Skill Management", "text") . "," .
6280            $ilDB->quote(-1, "integer") . "," .
6281            $ilDB->now() . "," .
6282            $ilDB->now() .
6283            ")");
6284
6285        $nrid = $ilDB->nextId("object_reference");
6286        $ilDB->manipulate("INSERT INTO object_reference " .
6287            "(ref_id, obj_id) VALUES (" .
6288            $ilDB->quote($nrid, "integer") . "," .
6289            $ilDB->quote($nid, "integer") .
6290            ")");
6291
6292        // put in tree
6293        $tree = new ilTree(ROOT_FOLDER_ID);
6294        $tree->insertNode($nrid, SYSTEM_FOLDER_ID);
6295
6296
6297        $set = $ilDB->query(
6298            "SELECT obj_id FROM object_data WHERE " .
6299            " type = " . $ilDB->quote("typ", "text") . " AND " .
6300            " title = " . $ilDB->quote("skmg", "text")
6301        );
6302        $rec = $ilDB->fetchAssoc($set);
6303        $typ_id = $rec["obj_id"];
6304
6305        // add rbac operations
6306        // 1: edit_permissions, 2: visible, 3: read, 4:write
6307        $ilDB->manipulate("INSERT INTO rbac_ta " .
6308            "(typ_id, ops_id) VALUES (" .
6309            $ilDB->quote($typ_id, "integer") . "," .
6310            $ilDB->quote(1, "integer") .
6311            ")");
6312        $ilDB->manipulate("INSERT INTO rbac_ta " .
6313            "(typ_id, ops_id) VALUES (" .
6314            $ilDB->quote($typ_id, "integer") . "," .
6315            $ilDB->quote(2, "integer") .
6316            ")");
6317        $ilDB->manipulate("INSERT INTO rbac_ta " .
6318            "(typ_id, ops_id) VALUES (" .
6319            $ilDB->quote($typ_id, "integer") . "," .
6320            $ilDB->quote(3, "integer") .
6321            ")");
6322        $ilDB->manipulate("INSERT INTO rbac_ta " .
6323            "(typ_id, ops_id) VALUES (" .
6324            $ilDB->quote($typ_id, "integer") . "," .
6325            $ilDB->quote(4, "integer") .
6326            ")");
6327    }
6328?>
6329<#3379>
6330<?php
6331    $setting = new ilSetting();
6332    $sk_step = (int) $setting->get('sk_db');
6333    if ($sk_step <= 4) {
6334        // add skill tree and root node
6335        $nid = $ilDB->nextId("skl_tree_node");
6336        $ilDB->manipulate("INSERT INTO skl_tree_node " .
6337            "(obj_id, type, title, create_date) VALUES (" .
6338            $ilDB->quote($nid, "integer") . "," .
6339            $ilDB->quote("skrt", "text") . "," .
6340            $ilDB->quote("Skill Tree Root Node", "text") . "," .
6341            $ilDB->now() .
6342            ")");
6343
6344        $skill_tree = new ilTree(1);
6345        $skill_tree->setTreeTablePK("skl_tree_id");
6346        $skill_tree->setTableNames('skl_tree', 'skl_tree_node');
6347        $skill_tree->addTree(1, $nid);
6348    }
6349?>
6350<#3380>
6351<?php
6352    $setting = new ilSetting();
6353    $sk_step = (int) $setting->get('sk_db');
6354    if ($sk_step <= 6) {
6355        $fields = array(
6356                'id' => array(
6357                        'type' => 'integer',
6358                        'length' => 4,
6359                        'notnull' => true
6360                ),
6361                'skill_id' => array(
6362                        'type' => 'integer',
6363                        'length' => 4,
6364                        'notnull' => true
6365                ),
6366                'nr' => array(
6367                        'type' => 'integer',
6368                        'length' => 2,
6369                        'notnull' => true
6370                ),
6371                'title' => array(
6372                        'type' => 'text',
6373                        'length' => 200,
6374                        'notnull' => false
6375                ),
6376                'description' => array(
6377                        'type' => 'clob'
6378                )
6379            );
6380        $ilDB->createTable('skl_level', $fields);
6381        $ilDB->createSequence('skl_level');
6382        $ilDB->addPrimaryKey("skl_level", array("id"));
6383    }
6384?>
6385<#3381>
6386<?php
6387    $setting = new ilSetting();
6388    $sk_step = (int) $setting->get('sk_db');
6389    if ($sk_step <= 8) {
6390        $ilDB->addTableColumn("skl_level", "trigger_ref_id", array(
6391            "type" => "integer",
6392            "notnull" => true,
6393            "length" => 4,
6394            "default" => 0
6395            ));
6396        $ilDB->addTableColumn("skl_level", "trigger_obj_id", array(
6397            "type" => "integer",
6398            "notnull" => true,
6399            "length" => 4,
6400            "default" => 0
6401            ));
6402    }
6403?>
6404<#3382>
6405<?php
6406    $setting = new ilSetting();
6407    $sk_step = (int) $setting->get('sk_db');
6408    if ($sk_step <= 9) {
6409        $fields = array(
6410                'level_id' => array(
6411                        'type' => 'integer',
6412                        'length' => 4,
6413                        'notnull' => true
6414                ),
6415                'user_id' => array(
6416                        'type' => 'integer',
6417                        'length' => 4,
6418                        'notnull' => true
6419                ),
6420                'status_date' => array(
6421                        'type' => 'timestamp',
6422                        'notnull' => true
6423                ),
6424                'skill_id' => array(
6425                        'type' => 'integer',
6426                        'length' => 4,
6427                        'notnull' => true
6428                ),
6429                'status' => array(
6430                        'type' => 'integer',
6431                        'length' => 1,
6432                        'notnull' => true
6433                ),
6434                'valid' => array(
6435                        'type' => 'integer',
6436                        'length' => 1,
6437                        'notnull' => true,
6438                        'default' => 0
6439                ),
6440                'trigger_ref_id' => array(
6441                        'type' => 'integer',
6442                        'length' => 4,
6443                        'notnull' => true
6444                ),
6445                'trigger_obj_id' => array(
6446                        'type' => 'integer',
6447                        'length' => 4,
6448                        'notnull' => true
6449                ),
6450                'trigger_title' => array(
6451                        'type' => 'text',
6452                        'length' => 200,
6453                        'notnull' => false
6454                )
6455            );
6456        $ilDB->createTable('skl_user_skill_level', $fields);
6457        $ilDB->addIndex("skl_user_skill_level", array("skill_id"), "isk");
6458        $ilDB->addIndex("skl_user_skill_level", array("level_id"), "ilv");
6459        $ilDB->addIndex("skl_user_skill_level", array("user_id"), "ius");
6460        $ilDB->addIndex("skl_user_skill_level", array("status_date"), "isd");
6461        $ilDB->addIndex("skl_user_skill_level", array("status"), "ist");
6462        $ilDB->addIndex("skl_user_skill_level", array("valid"), "ivl");
6463    }
6464?>
6465<#3383>
6466<?php
6467    $setting = new ilSetting();
6468    $sk_step = (int) $setting->get('sk_db');
6469    if ($sk_step <= 10) {
6470        $fields = array(
6471                'level_id' => array(
6472                        'type' => 'integer',
6473                        'length' => 4,
6474                        'notnull' => true
6475                ),
6476                'user_id' => array(
6477                        'type' => 'integer',
6478                        'length' => 4,
6479                        'notnull' => true
6480                ),
6481                'status_date' => array(
6482                        'type' => 'timestamp',
6483                        'notnull' => true
6484                ),
6485                'skill_id' => array(
6486                        'type' => 'integer',
6487                        'length' => 4,
6488                        'notnull' => true
6489                ),
6490                'trigger_ref_id' => array(
6491                        'type' => 'integer',
6492                        'length' => 4,
6493                        'notnull' => true
6494                ),
6495                'trigger_obj_id' => array(
6496                        'type' => 'integer',
6497                        'length' => 4,
6498                        'notnull' => true
6499                ),
6500                'trigger_title' => array(
6501                        'type' => 'text',
6502                        'length' => 200,
6503                        'notnull' => false
6504                )
6505            );
6506        $ilDB->createTable('skl_user_has_level', $fields);
6507        $ilDB->addPrimaryKey(
6508            'skl_user_has_level',
6509            array("level_id", "user_id")
6510        );
6511    }
6512?>
6513<#3384>
6514<?php
6515    $ilCtrlStructureReader->getStructure();
6516?>
6517<#3385>
6518<?php
6519    $setting = new ilSetting();
6520    $cd_step = (int) $setting->get('cd_db');
6521    if ($cd_step <= 3) {
6522        $ilDB->addTableColumn("skl_tree_node", "self_eval", array(
6523            "type" => "integer",
6524            "length" => 1,
6525            "notnull" => true,
6526            "default" => 0
6527            ));
6528    }
6529?>
6530<#3386>
6531<?php
6532    $setting = new ilSetting();
6533    $cd_step = (int) $setting->get('cd_db');
6534    if ($cd_step <= 5) {
6535        // skill self evaluation table
6536        $fields = array(
6537                'id' => array(
6538                        'type' => 'integer',
6539                        'length' => 4,
6540                        'notnull' => true,
6541                        'default' => 0
6542                ),
6543                'user_id' => array(
6544                        'type' => 'integer',
6545                        'length' => 4,
6546                        'notnull' => true,
6547                        'default' => 0
6548                ),
6549                'top_skill_id' => array(
6550                        'type' => 'integer',
6551                        'length' => 4,
6552                        'notnull' => true,
6553                        'default' => 0
6554                ),
6555                'created' => array(
6556                        'type' => 'timestamp',
6557                        'notnull' => true,
6558                ),
6559                'last_update' => array(
6560                        'type' => 'timestamp',
6561                        'notnull' => true,
6562                )
6563        );
6564
6565        $ilDB->createTable('skl_self_eval', $fields);
6566        $ilDB->addPrimaryKey("skl_self_eval", array("id"));
6567        $ilDB->createSequence('skl_self_eval');
6568    }
6569?>
6570<#3387>
6571<?php
6572    $setting = new ilSetting();
6573    $cd_step = (int) $setting->get('cd_db');
6574    if ($cd_step <= 6) {
6575        // skill self evaluation table
6576        $fields = array(
6577                'self_eval_id' => array(
6578                        'type' => 'integer',
6579                        'length' => 4,
6580                        'notnull' => true,
6581                        'default' => 0
6582                ),
6583                'skill_id' => array(
6584                        'type' => 'integer',
6585                        'length' => 4,
6586                        'notnull' => true,
6587                        'default' => 0
6588                ),
6589                'level_id' => array(
6590                        'type' => 'integer',
6591                        'length' => 4,
6592                        'notnull' => true,
6593                        'default' => 0
6594                )
6595        );
6596
6597        $ilDB->createTable('skl_self_eval_level', $fields);
6598        $ilDB->addPrimaryKey(
6599            "skl_self_eval_level",
6600            array("self_eval_id", "skill_id")
6601        );
6602    }
6603?>
6604<#3388>
6605<?php
6606    if (!$ilDB->tableColumnExists('tst_tests', 'online_status')) {
6607        $ilDB->addTableColumn("tst_tests", "online_status", array(
6608            "type" => "integer",
6609            "length" => 1,
6610            "notnull" => true,
6611            "default" => 0
6612        ));
6613    }
6614?>
6615<#3389>
6616<?php
6617
6618    $query = "
6619		UPDATE		tst_tests
6620		SET			online_status = 1
6621		WHERE		complete = 1
6622	";
6623
6624?>
6625<#3390>
6626<?php
6627
6628    $setting = new ilSetting();
6629    $elb_db = $setting->get("elb_db", -1);
6630
6631    if ($elb_db == -1) {
6632        $query = "
6633			UPDATE		tst_tests
6634			SET			online_status = 1
6635			WHERE		complete = 1
6636		";
6637
6638        $ilDB->manipulate($query);
6639    }
6640?>
6641
6642<#3391>
6643<?php
6644    // skill template reference
6645    $fields = array(
6646            'skl_node_id' => array(
6647                    'type' => 'integer',
6648                    'length' => 4,
6649                    'notnull' => true,
6650                    'default' => 0
6651            ),
6652            'templ_id' => array(
6653                    'type' => 'integer',
6654                    'length' => 4,
6655                    'notnull' => true,
6656                    'default' => 0
6657            )
6658    );
6659
6660    $ilDB->createTable('skl_templ_ref', $fields);
6661    $ilDB->addPrimaryKey("skl_templ_ref", array("skl_node_id"));
6662?>
6663<#3392>
6664<?php
6665    $ilCtrlStructureReader->getStructure();
6666?>
6667<#3393>
6668<?php
6669    $ilCtrlStructureReader->getStructure();
6670?>
6671<#3394>
6672<?php
6673
6674    // personal skill
6675    $fields = array(
6676            'user_id' => array(
6677                    'type' => 'integer',
6678                    'length' => 4,
6679                    'notnull' => true,
6680                    'default' => 0
6681            ),
6682            'skill_node_id' => array(
6683                    'type' => 'integer',
6684                    'length' => 4,
6685                    'notnull' => true,
6686                    'default' => 0
6687            )
6688    );
6689
6690    $ilDB->createTable("skl_personal_skill", $fields);
6691    $ilDB->addPrimaryKey("skl_personal_skill", array("user_id", "skill_node_id"));
6692?>
6693<#3395>
6694<?php
6695    if (!$ilDB->sequenceExists('ecs_container_mapping')) {
6696        $res = $ilDB->query('SELECT mapping_id FROM ecs_container_mapping ');
6697        $rows = $res->numRows();
6698
6699        $ilDB->createSequence('ecs_container_mapping', ++$rows);
6700    }
6701?>
6702<#3396>
6703<?php
6704
6705    // assigned materials
6706    $fields = array(
6707            'user_id' => array(
6708                    'type' => 'integer',
6709                    'length' => 4,
6710                    'notnull' => true,
6711                    'default' => 0
6712            ),
6713            'top_skill_id' => array(
6714                    'type' => 'integer',
6715                    'length' => 4,
6716                    'notnull' => true,
6717                    'default' => 0
6718            ),
6719            'skill_id' => array(
6720                    'type' => 'integer',
6721                    'length' => 4,
6722                    'notnull' => true,
6723                    'default' => 0
6724            ),
6725            'level_id' => array(
6726                    'type' => 'integer',
6727                    'length' => 4,
6728                    'notnull' => true,
6729                    'default' => 0
6730            ),
6731            'wsp_id' => array(
6732                    'type' => 'integer',
6733                    'length' => 4,
6734                    'notnull' => true,
6735                    'default' => 0
6736            )
6737    );
6738
6739    $ilDB->createTable("skl_assigned_material", $fields);
6740    $ilDB->addPrimaryKey("skl_assigned_material", array("user_id", "top_skill_id", "skill_id", "level_id", "wsp_id"));
6741?>
6742<#3397>
6743<?php
6744        $ilDB->addTableColumn("frm_settings", "mark_mod_posts", array(
6745        "type" => "integer",
6746        "notnull" => true,
6747        "length" => 1,
6748        "default" => 0));
6749?>
6750<#3398>
6751<?php
6752
6753    if (!$ilDB->tableColumnExists('cal_entries', 'notification')) {
6754        $ilDB->addTableColumn(
6755            'cal_entries',
6756            'notification',
6757            array(
6758                'type' => 'integer',
6759                'length' => 1,
6760                'notnull' => true,
6761                'default' => 0
6762            )
6763        );
6764    }
6765?>
6766<#3399>
6767<?php
6768    // assigned materials
6769    $fields = array(
6770            'user_id' => array(
6771                    'type' => 'integer',
6772                    'length' => 4,
6773                    'notnull' => true,
6774                    'default' => 0
6775            ),
6776            'nr' => array(
6777                    'type' => 'integer',
6778                    'length' => 4,
6779                    'notnull' => true,
6780                    'default' => 0
6781            ),
6782            'ref_id' => array(
6783                    'type' => 'integer',
6784                    'length' => 4,
6785                    'notnull' => true,
6786                    'default' => 0
6787            ),
6788            'type' => array(
6789                    'type' => 'text',
6790                    'length' => 10,
6791                    'notnull' => true,
6792            ),
6793            'sub_obj_id' => array(
6794                    'type' => 'text',
6795                    'length' => 40,
6796                    'notnull' => false
6797            ),
6798            'goto_link' => array(
6799                    'type' => 'text',
6800                    'length' => 1000,
6801                    'notnull' => false
6802            )
6803    );
6804
6805    $ilDB->createTable("last_visited", $fields);
6806    $ilDB->addPrimaryKey("last_visited", array("user_id", "nr"));
6807?>
6808<#3400>
6809<?php
6810    $ilCtrlStructureReader->getStructure();
6811?>
6812<#3401>
6813<?php
6814
6815    // Crs typ-id
6816    $query = 'SELECT obj_id FROM object_data WHERE type = ' . $ilDB->quote('typ', 'text') . ' AND title = ' . $ilDB->quote('crs');
6817    $res = $ilDB->query($query);
6818    $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
6819    $typ_id = $row->obj_id;
6820
6821    // operation create_crsr
6822    $query = 'SELECT * FROM rbac_operations WHERE operation = ' . $ilDB->quote('create_crsr');
6823    $res = $ilDB->query($query);
6824    $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
6825    $crs_create_id = $row->ops_id;
6826
6827    // operation create_catr
6828    $query = 'SELECT * FROM rbac_operations WHERE operation = ' . $ilDB->quote('create_catr');
6829    $res = $ilDB->query($query);
6830    $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
6831    $cat_create_id = $row->ops_id;
6832
6833    $query = 'SELECT * FROM rbac_ta WHERE typ_id = ' . $ilDB->quote($typ_id, 'integer') . ' AND ops_id = ' . $ilDB->quote($crs_create_id, 'integer');
6834    $res = $ilDB->query($query);
6835    if (!$res->numRows()) {
6836        $query = 'INSERT INTO rbac_ta (typ_id,ops_id) VALUES( ' . $ilDB->quote($typ_id, 'integer') . ', ' . $ilDB->quote($crs_create_id, 'integer') . ')';
6837        $ilDB->manipulate($query);
6838    }
6839
6840    $query = 'SELECT * FROM rbac_ta WHERE typ_id = ' . $ilDB->quote($typ_id, 'integer') . ' AND ops_id = ' . $ilDB->quote($cat_create_id, 'integer');
6841    $res = $ilDB->query($query);
6842    if (!$res->numRows()) {
6843        $query = 'INSERT INTO rbac_ta (typ_id,ops_id) VALUES( ' . $ilDB->quote($typ_id, 'integer') . ', ' . $ilDB->quote($cat_create_id, 'integer') . ')';
6844        $ilDB->manipulate($query);
6845    }
6846?>
6847<#3402>
6848<?php
6849    $ilDB->dropTableColumn("sahs_lm", "final_lm_page");
6850    $ilDB->dropTableColumn("sahs_lm", "final_sco_page");
6851?>
6852<#3403>
6853<?php
6854
6855        $ilDB->createTable(
6856            'didactic_tpl_settings',
6857            array(
6858                "id" => array(
6859                    "type" => "integer",
6860                    "length" => 4,
6861                    "notnull" => true
6862                ),
6863                "enabled" => array(
6864                    "type" => "integer",
6865                    "length" => 1,
6866                    "notnull" => true
6867                ),
6868                "type" => array(
6869                    "type" => "integer",
6870                    "length" => 1,
6871                    "notnull" => true
6872                ),
6873                "title" => array(
6874                    "type" => "text",
6875                    "length" => 64,
6876                    "notnull" => false
6877                ),
6878                "description" => array(
6879                    "type" => "text",
6880                    "length" => 512,
6881                    "notnull" => false
6882                )
6883            )
6884        );
6885        $ilDB->createSequence('didactic_tpl_settings');
6886        $ilDB->addPrimaryKey('didactic_tpl_settings', array('id'));
6887?>
6888<#3404>
6889<?php
6890
6891        $ilDB->createTable(
6892            'didactic_tpl_sa',
6893            array(
6894                "id" => array(
6895                    "type" => "integer",
6896                    "length" => 4,
6897                    "notnull" => true
6898                ),
6899                "obj_type" => array(
6900                    "type" => "text",
6901                    "length" => 8,
6902                    "notnull" => false
6903                )
6904            )
6905        );
6906        $ilDB->addPrimaryKey('didactic_tpl_sa', array('id','obj_type'));
6907?>
6908<#3405>
6909<?php
6910    if (!$ilDB->tableColumnExists('il_blog', 'bg_color')) {
6911        $ilDB->addTableColumn(
6912            'il_blog',
6913            'bg_color',
6914            array(
6915                'type' => 'text',
6916                'length' => 6,
6917                'notnull' => false,
6918                'fixed' => true
6919            )
6920        );
6921    }
6922    if (!$ilDB->tableColumnExists('il_blog', 'font_color')) {
6923        $ilDB->addTableColumn(
6924            'il_blog',
6925            'font_color',
6926            array(
6927                'type' => 'text',
6928                'length' => 6,
6929                'notnull' => false,
6930                'fixed' => true
6931            )
6932        );
6933    }
6934    if (!$ilDB->tableColumnExists('il_blog', 'img')) {
6935        $ilDB->addTableColumn(
6936            'il_blog',
6937            'img',
6938            array(
6939                'type' => 'text',
6940                'length' => 255,
6941                'notnull' => false
6942            )
6943        );
6944    }
6945?>
6946<#3406>
6947<?php
6948    $ilCtrlStructureReader->getStructure();
6949?>
6950<#3407>
6951<?php
6952        $ilDB->createTable(
6953    'didactic_tpl_a',
6954    array(
6955                "id" => array(
6956                    "type" => "integer",
6957                    "length" => 4,
6958                    "notnull" => true
6959                ),
6960                "tpl_id" => array(
6961                    "type" => "integer",
6962                    "length" => 4,
6963                    "notnull" => true
6964                ),
6965                "type_id" => array(
6966                    "type" => "integer",
6967                    "length" => 1,
6968                    "notnull" => true
6969                )
6970            )
6971);
6972
6973        $ilDB->createSequence('didactic_tpl_a');
6974        $ilDB->addPrimaryKey('didactic_tpl_a', array('id'));
6975?>
6976<#3408>
6977<?php
6978        $ilDB->createTable(
6979    'didactic_tpl_alp',
6980    array(
6981                "action_id" => array(
6982                    "type" => "integer",
6983                    "length" => 4,
6984                    "notnull" => true
6985                ),
6986                "filter_type" => array(
6987                    "type" => "integer",
6988                    "length" => 1,
6989                    "notnull" => true
6990                ),
6991                "template_type" => array(
6992                    "type" => "integer",
6993                    "length" => 1,
6994                    "notnull" => true
6995                ),
6996                "template_id" => array(
6997                    "type" => "integer",
6998                    "length" => 4,
6999                    "notnull" => true
7000                )
7001            )
7002);
7003
7004        $ilDB->addPrimaryKey('didactic_tpl_alp', array('action_id'));
7005?>
7006<#3409>
7007<?php
7008// register new object type 'blga' for blog administration
7009 $id = $ilDB->nextId("object_data");
7010$ilDB->manipulateF(
7011    "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
7012        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
7013    array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
7014    array($id, "typ", "blga", "Blog administration", -1, ilUtil::now(), ilUtil::now())
7015);
7016$typ_id = $id;
7017
7018// create object data entry
7019$id = $ilDB->nextId("object_data");
7020$ilDB->manipulateF(
7021    "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
7022        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
7023    array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
7024    array($id, "blga", "__BlogAdministration", "Blog Administration", -1, ilUtil::now(), ilUtil::now())
7025);
7026
7027// create object reference entry
7028$ref_id = $ilDB->nextId('object_reference');
7029$res = $ilDB->manipulateF(
7030    "INSERT INTO object_reference (ref_id, obj_id) VALUES (%s, %s)",
7031    array("integer", "integer"),
7032    array($ref_id, $id)
7033);
7034
7035// put in tree
7036$tree = new ilTree(ROOT_FOLDER_ID);
7037$tree->insertNode($ref_id, SYSTEM_FOLDER_ID);
7038
7039// add rbac operations
7040// 1: edit_permissions, 2: visible, 3: read, 4:write
7041$ilDB->manipulateF(
7042    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7043    array("integer", "integer"),
7044    array($typ_id, 1)
7045);
7046$ilDB->manipulateF(
7047    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7048    array("integer", "integer"),
7049    array($typ_id, 2)
7050);
7051$ilDB->manipulateF(
7052    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7053    array("integer", "integer"),
7054    array($typ_id, 3)
7055);
7056$ilDB->manipulateF(
7057    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7058    array("integer", "integer"),
7059    array($typ_id, 4)
7060);
7061?>
7062<#3410>
7063<?php
7064// register new object type 'prfa' for portfolio administration
7065 $id = $ilDB->nextId("object_data");
7066$ilDB->manipulateF(
7067    "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
7068        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
7069    array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
7070    array($id, "typ", "prfa", "Portfolio administration", -1, ilUtil::now(), ilUtil::now())
7071);
7072$typ_id = $id;
7073
7074// create object data entry
7075$id = $ilDB->nextId("object_data");
7076$ilDB->manipulateF(
7077    "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
7078        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
7079    array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
7080    array($id, "prfa", "__PortfolioAdministration", "Portfolio Administration", -1, ilUtil::now(), ilUtil::now())
7081);
7082
7083// create object reference entry
7084$ref_id = $ilDB->nextId('object_reference');
7085$res = $ilDB->manipulateF(
7086    "INSERT INTO object_reference (ref_id, obj_id) VALUES (%s, %s)",
7087    array("integer", "integer"),
7088    array($ref_id, $id)
7089);
7090
7091// put in tree
7092$tree = new ilTree(ROOT_FOLDER_ID);
7093$tree->insertNode($ref_id, SYSTEM_FOLDER_ID);
7094
7095// add rbac operations
7096// 1: edit_permissions, 2: visible, 3: read, 4:write
7097$ilDB->manipulateF(
7098    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7099    array("integer", "integer"),
7100    array($typ_id, 1)
7101);
7102$ilDB->manipulateF(
7103    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7104    array("integer", "integer"),
7105    array($typ_id, 2)
7106);
7107$ilDB->manipulateF(
7108    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7109    array("integer", "integer"),
7110    array($typ_id, 3)
7111);
7112$ilDB->manipulateF(
7113    "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7114    array("integer", "integer"),
7115    array($typ_id, 4)
7116);
7117?>
7118<#3411>
7119<?php
7120    $ilCtrlStructureReader->getStructure();
7121?>
7122<#3412>
7123<?php
7124    if (!$ilDB->tableColumnExists('usr_portfolio', 'bg_color')) {
7125        $ilDB->addTableColumn(
7126            'usr_portfolio',
7127            'bg_color',
7128            array(
7129                'type' => 'text',
7130                'length' => 6,
7131                'notnull' => false,
7132                'fixed' => true
7133            )
7134        );
7135    }
7136    if (!$ilDB->tableColumnExists('usr_portfolio', 'font_color')) {
7137        $ilDB->addTableColumn(
7138            'usr_portfolio',
7139            'font_color',
7140            array(
7141                'type' => 'text',
7142                'length' => 6,
7143                'notnull' => false,
7144                'fixed' => true
7145            )
7146        );
7147    }
7148    if (!$ilDB->tableColumnExists('usr_portfolio', 'img')) {
7149        $ilDB->addTableColumn(
7150            'usr_portfolio',
7151            'img',
7152            array(
7153                'type' => 'text',
7154                'length' => 255,
7155                'notnull' => false
7156            )
7157        );
7158    }
7159?>
7160<#3413>
7161<?php
7162    $ilCtrlStructureReader->getStructure();
7163?>
7164<#3414>
7165<?php
7166    require_once 'Modules/Chatroom/classes/class.ilChatroomFormFactory.php';
7167    require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
7168    require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
7169    ilChatroomInstaller::install();
7170
7171    require_once 'Services/Notifications/classes/class.ilNotificationSetupHelper.php';
7172    ilNotificationSetupHelper::setupTables();
7173
7174    $settings = new ilSetting('notifications');
7175    $settings->set('enable_mail', 1);
7176
7177    $ilDB->insert(
7178        'notification_usercfg',
7179        array(
7180            'usr_id' => array('integer', -1),
7181            'module' => array('text', 'chat_invitation'),
7182            'channel' => array('text', 'mail')
7183        )
7184    );
7185    $ilDB->insert(
7186        'notification_usercfg',
7187        array(
7188            'usr_id' => array('integer', -1),
7189            'module' => array('text', 'chat_invitation'),
7190            'channel' => array('text', 'osd')
7191        )
7192    );
7193    $ilDB->insert(
7194        'notification_usercfg',
7195        array(
7196            'usr_id' => array('integer', -1),
7197            'module' => array('text', 'osd_main'),
7198            'channel' => array('text', 'osd')
7199        )
7200    );
7201
7202    $ilDB->manipulate("UPDATE notification_channels SET config_type = 'set_by_admin'");
7203?>
7204<#3415>
7205<?php
7206    $ilCtrlStructureReader->getStructure();
7207?>
7208<#3416>
7209<?php
7210    $ilDB->manipulate(
7211    'INSERT INTO rbac_templates (rol_id, type, ops_id, parent) VALUES (' .
7212            $ilDB->quote(4, 'integer') . ', ' .
7213            $ilDB->quote('chtr', 'text') . ', ' .
7214            $ilDB->quote(2, 'integer') . ', ' .
7215            $ilDB->quote(8, 'integer') .
7216            ')'
7217);
7218    $ilDB->manipulate(
7219        'INSERT INTO rbac_templates (rol_id, type, ops_id, parent) VALUES (' .
7220            $ilDB->quote(4, 'integer') . ', ' .
7221            $ilDB->quote('chtr', 'text') . ', ' .
7222            $ilDB->quote(3, 'integer') . ', ' .
7223            $ilDB->quote(8, 'integer') .
7224            ')'
7225    );
7226?>
7227<#3417>
7228<?php
7229if (!$ilDB->tableExists('usr_account_codes')) {
7230    $fields = array(
7231        'code_id' => array(
7232            'type' => 'integer',
7233            'length' => 4,
7234            'notnull' => true,
7235            'default' => 0),
7236
7237        'code' => array(
7238            'type' => 'text',
7239            'notnull' => false,
7240            'length' => 50,
7241            'fixed' => false),
7242
7243        'valid_until' => array(
7244            'type' => 'text',
7245            'notnull' => false,
7246            'length' => 10),
7247
7248        'generated' => array(
7249            'type' => 'integer',
7250            'notnull' => false,
7251            'length' => 4,
7252            'default' => 0),
7253
7254        'used' => array(
7255            'type' => 'integer',
7256            'notnull' => true,
7257            'length' => 4,
7258            'default' => 0)
7259    );
7260    $ilDB->createTable('usr_account_codes', $fields);
7261    $ilDB->addPrimaryKey('usr_account_codes', array('code_id'));
7262    $ilDB->addIndex('usr_account_codes', array('code'), 'i1');
7263    $ilDB->createSequence("usr_account_codes");
7264}
7265?>
7266<#3418>
7267<?php
7268    $ilCtrlStructureReader->getStructure();
7269?>
7270<#3419>
7271<?php
7272
7273    // fix missing mep_data entries
7274    $set = $ilDB->query("SELECT * FROM object_data " .
7275        " WHERE type = " . $ilDB->quote("mep", "text"));
7276    while ($rec = $ilDB->fetchAssoc($set)) {
7277        $set2 = $ilDB->query("SELECT * FROM mep_data " .
7278            " WHERE id = " . $ilDB->quote($rec["obj_id"], "integer"));
7279        if ($rec2 = $ilDB->fetchAssoc($set2)) {
7280            // everything ok
7281        } else {
7282            $q = "INSERT INTO mep_data " .
7283                "(id, default_width, default_height) VALUES (" .
7284                $ilDB->quote($rec["obj_id"], "integer") . ", " .
7285                $ilDB->quote(null, "integer") . ", " .
7286                $ilDB->quote(null, "integer") .
7287                ")";
7288            $ilDB->manipulate($q);
7289        }
7290    }
7291?>
7292<#3420>
7293<?php
7294    $ilDB->query("UPDATE notification_types SET config_type = 'set_by_admin' WHERE type_name = 'chat_invitation'");
7295    $ilDB->query("UPDATE notification_types SET config_type = 'set_by_admin' WHERE type_name = 'osd_maint'");
7296?>
7297<#3421>
7298<?php
7299    require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
7300    require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
7301    ilChatroomInstaller::createMissinRoomSettingsForConvertedObjects();
7302?>
7303<#3422>
7304<?php
7305
7306    if (!$ilDB->tableColumnExists('grp_settings', 'view_mode')) {
7307        $ilDB->addTableColumn(
7308            'grp_settings',
7309            'view_mode',
7310            array(
7311                'type' => 'integer',
7312                'length' => 1,
7313                'notnull' => true,
7314                'default' => 6
7315            )
7316        );
7317    }
7318?>
7319<#3423>
7320<?php
7321    $query = "SELECT obj_id FROM object_data WHERE type = 'typ' AND title = 'chta'";
7322    $rset = $ilDB->query($query);
7323    $row = $ilDB->fetchAssoc($rset);
7324
7325    if (!$row) {
7326        $typ_id = $ilDB->nextId("object_data");
7327        $ilDB->manipulate("INSERT INTO object_data " .
7328            "(obj_id, type, title, description, owner, create_date, last_update) VALUES (" .
7329            $ilDB->quote($typ_id, "integer") . "," .
7330            $ilDB->quote("typ", "text") . "," .
7331            $ilDB->quote("chta", "text") . "," .
7332            $ilDB->quote("Chatroom Administration Type", "text") . "," .
7333            $ilDB->quote(-1, "integer") . "," .
7334            $ilDB->now() . "," .
7335            $ilDB->now() .
7336            ")");
7337
7338        // add rbac operations
7339        // 1: edit_permissions, 2: visible, 3: read, 4:write
7340        $ilDB->manipulate("INSERT INTO rbac_ta " .
7341            "(typ_id, ops_id) VALUES (" .
7342            $ilDB->quote($typ_id, "integer") . "," .
7343            $ilDB->quote(1, "integer") .
7344            ")");
7345        $ilDB->manipulate("INSERT INTO rbac_ta " .
7346            "(typ_id, ops_id) VALUES (" .
7347            $ilDB->quote($typ_id, "integer") . "," .
7348            $ilDB->quote(2, "integer") .
7349            ")");
7350        $ilDB->manipulate("INSERT INTO rbac_ta " .
7351            "(typ_id, ops_id) VALUES (" .
7352            $ilDB->quote($typ_id, "integer") . "," .
7353            $ilDB->quote(3, "integer") .
7354            ")");
7355        $ilDB->manipulate("INSERT INTO rbac_ta " .
7356            "(typ_id, ops_id) VALUES (" .
7357            $ilDB->quote($typ_id, "integer") . "," .
7358            $ilDB->quote(4, "integer") .
7359            ")");
7360    }
7361
7362?>
7363<#3424>
7364<?php
7365    if (!$ilDB->tableColumnExists('sahs_lm', 'open_mode')) {
7366        $ilDB->addTableColumn(
7367            'sahs_lm',
7368            'open_mode',
7369            array(
7370                'type' => 'integer',
7371                'length' => 1,
7372                'notnull' => true,
7373                'default' => 0
7374            )
7375        );
7376        $ilDB->query("UPDATE sahs_lm SET open_mode = 5");
7377    }
7378?>
7379<#3425>
7380<?php
7381    if (!$ilDB->tableColumnExists('sahs_lm', 'width')) {
7382        $ilDB->addTableColumn(
7383            'sahs_lm',
7384            'width',
7385            array(
7386                'type' => 'integer',
7387                'length' => 2,
7388                'notnull' => true,
7389                'default' => 950
7390            )
7391        );
7392        $ilDB->query("UPDATE sahs_lm SET width = 950");
7393    }
7394?>
7395<#3426>
7396<?php
7397    if (!$ilDB->tableColumnExists('sahs_lm', 'height')) {
7398        $ilDB->addTableColumn(
7399            'sahs_lm',
7400            'height',
7401            array(
7402                'type' => 'integer',
7403                'length' => 2,
7404                'notnull' => true,
7405                'default' => 650
7406            )
7407        );
7408        $ilDB->query("UPDATE sahs_lm SET height = 650");
7409    }
7410?>
7411
7412<#3427>
7413<?php
7414
7415        $ilDB->createTable(
7416            'didactic_tpl_fp',
7417            array(
7418                "pattern_id" => array(
7419                    "type" => "integer",
7420                    "length" => 4,
7421                    "notnull" => true
7422                ),
7423                "pattern_type" => array(
7424                    "type" => "integer",
7425                    "length" => 1,
7426                    "notnull" => true
7427                ),
7428                "pattern_sub_type" => array(
7429                    "type" => "integer",
7430                    "length" => 1,
7431                    "notnull" => true
7432                ),
7433                "pattern" => array(
7434                    "type" => "text",
7435                    "length" => 64,
7436                    "notnull" => false
7437                )
7438            )
7439        );
7440        $ilDB->createSequence('didactic_tpl_fp');
7441        $ilDB->addPrimaryKey('didactic_tpl_fp', array('pattern_id'));
7442?>
7443
7444<#3428>
7445<?php
7446
7447    $ilDB->addTableColumn(
7448        "didactic_tpl_fp",
7449        "parent_id",
7450        array(
7451            "type" => "integer",
7452            "notnull" => true,
7453            "length" => 4
7454        )
7455    );
7456
7457    $ilDB->addTableColumn(
7458        "didactic_tpl_fp",
7459        "parent_type",
7460        array(
7461            "type" => "text",
7462            "notnull" => false,
7463            "length" => 32
7464        )
7465    );
7466?>
7467
7468<#3429>
7469<?php
7470    $ilDB->createTable(
7471    'didactic_tpl_alr',
7472    array(
7473            "action_id" => array(
7474                "type" => "integer",
7475                "length" => 4,
7476                "notnull" => true
7477            ),
7478            "role_template_id" => array(
7479                "type" => "integer",
7480                "length" => 1,
7481                "notnull" => true
7482            )
7483        )
7484);
7485
7486    $ilDB->addPrimaryKey('didactic_tpl_alr', array('action_id'));
7487?>
7488
7489<#3430>
7490<?php
7491    if (!$ilDB->tableColumnExists('skl_tree_node', 'order_nr')) {
7492        $ilDB->addTableColumn(
7493            'skl_tree_node',
7494            'order_nr',
7495            array(
7496                'type' => 'integer',
7497                'length' => 4,
7498                'notnull' => true,
7499                'default' => 0
7500            )
7501        );
7502    }
7503?>
7504<#3431>
7505<?php
7506    $ilCtrlStructureReader->getStructure();
7507?>
7508<#3432>
7509<?php
7510    if (!$ilDB->tableColumnExists('sahs_lm', 'auto_continue')) {
7511        $ilDB->addTableColumn(
7512            'sahs_lm',
7513            'auto_continue',
7514            array(
7515                "type" => "text",
7516                'length' => 1,
7517                "notnull" => true,
7518                "default" => 'n'
7519            )
7520        );
7521        $ilDB->query("UPDATE sahs_lm SET auto_continue = 'n'");
7522    }
7523?>
7524
7525<#3433>
7526<?php
7527    $ilDB->createTable(
7528    'didactic_tpl_objs',
7529    array(
7530            "obj_id" => array(
7531                "type" => "integer",
7532                "length" => 4,
7533                "notnull" => true
7534            ),
7535            "tpl_id" => array(
7536                "type" => "integer",
7537                "length" => 4,
7538                "notnull" => true
7539            )
7540        )
7541);
7542
7543    $ilDB->addPrimaryKey('didactic_tpl_objs', array('obj_id','tpl_id'));
7544?>
7545<#3434>
7546<?php
7547    if (!$ilDB->tableColumnExists('usr_portfolio', 'comments')) {
7548        $ilDB->addTableColumn(
7549            'usr_portfolio',
7550            'comments',
7551            array(
7552                'type' => 'integer',
7553                'length' => 1,
7554                'notnull' => false
7555            )
7556        );
7557    }
7558?>
7559<#3435>
7560<?php
7561    $ilCtrlStructureReader->getStructure();
7562?>
7563<#3436>
7564<?php
7565    $ilDB->modifyTableColumn(
7566    'didactic_tpl_alr',
7567    'role_template_id',
7568    array("type" => "integer", "length" => 4, "notnull" => false)
7569);
7570?>
7571<#3437>
7572<?php
7573    $ilDB->createTable(
7574    'didactic_tpl_abr',
7575    array(
7576            "action_id" => array(
7577                "type" => "integer",
7578                "length" => 4,
7579                "notnull" => true
7580            ),
7581            "filter_type" => array(
7582                "type" => "integer",
7583                "length" => 1,
7584                "notnull" => true
7585            )
7586        )
7587);
7588
7589    $ilDB->addPrimaryKey('didactic_tpl_abr', array('action_id'));
7590?>
7591<#3438>
7592<?php
7593    if (!$ilDB->tableColumnExists('il_blog', 'ppic')) {
7594        $ilDB->addTableColumn(
7595            'il_blog',
7596            'ppic',
7597            array(
7598                'type' => 'integer',
7599                'length' => 1,
7600                'notnull' => false
7601            )
7602        );
7603    }
7604?>
7605<#3439>
7606<?php
7607    if (!$ilDB->tableColumnExists('usr_portfolio', 'ppic')) {
7608        $ilDB->addTableColumn(
7609            'usr_portfolio',
7610            'ppic',
7611            array(
7612                'type' => 'integer',
7613                'length' => 1,
7614                'notnull' => false
7615            )
7616        );
7617    }
7618?>
7619<#3440>
7620<?php
7621    $ilDB->addTableColumn("skl_assigned_material", "tref_id", array(
7622        "type" => "integer",
7623        "notnull" => true,
7624        "length" => 4,
7625        "default" => 0));
7626    $ilDB->dropPrimaryKey("skl_assigned_material");
7627    $ilDB->addPrimaryKey(
7628        "skl_assigned_material",
7629        array("user_id", "top_skill_id", "tref_id", "skill_id", "level_id", "wsp_id")
7630    );
7631?>
7632<#3441>
7633<?php
7634    $ilDB->addTableColumn("skl_self_eval_level", "tref_id", array(
7635        "type" => "integer",
7636        "notnull" => true,
7637        "length" => 4,
7638        "default" => 0));
7639    $ilDB->addTableColumn("skl_self_eval_level", "user_id", array(
7640        "type" => "integer",
7641        "notnull" => true,
7642        "length" => 4,
7643        "default" => 0));
7644    $ilDB->addTableColumn("skl_self_eval_level", "top_skill_id", array(
7645        "type" => "integer",
7646        "notnull" => true,
7647        "length" => 4,
7648        "default" => 0));
7649    $ilDB->addTableColumn("skl_self_eval_level", "last_update", array(
7650        "type" => "timestamp",
7651        "notnull" => false));
7652    $ilDB->dropPrimaryKey("skl_self_eval_level");
7653    $ilDB->dropTableColumn("skl_self_eval_level", "self_eval_id");
7654    $ilDB->addPrimaryKey(
7655        "skl_self_eval_level",
7656        array("user_id", "top_skill_id", "tref_id", "skill_id")
7657    );
7658?>
7659<#3442>
7660<?php
7661    if (!$ilDB->tableColumnExists('page_layout', 'mod_scorm')) {
7662        $ilDB->addTableColumn(
7663            'page_layout',
7664            'mod_scorm',
7665            array(
7666                'type' => 'integer',
7667                'length' => 1,
7668                'notnull' => false,
7669                'default' => 1
7670            )
7671        );
7672    }
7673    if (!$ilDB->tableColumnExists('page_layout', 'mod_portfolio')) {
7674        $ilDB->addTableColumn(
7675            'page_layout',
7676            'mod_portfolio',
7677            array(
7678                'type' => 'integer',
7679                'length' => 1,
7680                'notnull' => false
7681            )
7682        );
7683    }
7684?>
7685<#3443>
7686<?php
7687$ilDB->manipulate(
7688    "UPDATE style_data SET " .
7689    " uptodate = " . $ilDB->quote(0, "integer")
7690);
7691?>
7692<#3444>
7693<?php
7694    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
7695    ilDBUpdate3136::addStyleClass(
7696        "RTETreeControl",
7697        "rte_tree",
7698        "div",
7699        array()
7700    );
7701?>
7702<#3445>
7703<?php
7704    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
7705    ilDBUpdate3136::addStyleClass(
7706        "RTETreeControlLink",
7707        "rte_tclink",
7708        "a",
7709        array()
7710    );
7711?>
7712<#3446>
7713<?php
7714    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
7715    ilDBUpdate3136::addStyleClass(
7716        "RTEDragBar",
7717        "rte_drag",
7718        "div",
7719        array()
7720    );
7721?>
7722<#3447>
7723<?php
7724$setting = new ilSetting();
7725$setting->set("enable_sahs_pd", 1);
7726?>
7727<#3448>
7728<?php
7729    $ilCtrlStructureReader->getStructure();
7730?>
7731<#3449>
7732<?php
7733    if (!$ilDB->tableColumnExists("usr_portf_acl", "extended_data")) {
7734        $ilDB->addTableColumn("usr_portf_acl", "extended_data", array(
7735            "type" => "text",
7736            "notnull" => false,
7737            "length" => 200,
7738            "fixed" => false));
7739    }
7740?>
7741<#3450>
7742<?php
7743    $ilCtrlStructureReader->getStructure();
7744?>
7745<#3451>
7746<?php
7747    $ilCtrlStructureReader->getStructure();
7748?>
7749<#3452>
7750<?php
7751    // register new object type 'dtpl' for portfolio administration
7752    $id = $ilDB->nextId("object_data");
7753    $ilDB->manipulateF(
7754        "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
7755        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
7756        array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
7757        array($id, "typ", "otpl", "Object Template administration", -1, ilUtil::now(), ilUtil::now())
7758    );
7759    $typ_id = $id;
7760
7761    // create object data entry
7762    $id = $ilDB->nextId("object_data");
7763    $ilDB->manipulateF(
7764        "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
7765        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
7766        array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
7767        array($id, "otpl", "__ObjectTemplateAdministration", "Object Template Administration", -1, ilUtil::now(), ilUtil::now())
7768    );
7769
7770    // create object reference entry
7771    $ref_id = $ilDB->nextId('object_reference');
7772    $res = $ilDB->manipulateF(
7773        "INSERT INTO object_reference (ref_id, obj_id) VALUES (%s, %s)",
7774        array("integer", "integer"),
7775        array($ref_id, $id)
7776    );
7777
7778    // put in tree
7779    $tree = new ilTree(ROOT_FOLDER_ID);
7780    $tree->insertNode($ref_id, SYSTEM_FOLDER_ID);
7781
7782    // add rbac operations
7783    // 1: edit_permissions, 2: visible, 3: read, 4:write
7784    $ilDB->manipulateF(
7785        "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7786        array("integer", "integer"),
7787        array($typ_id, 1)
7788    );
7789    $ilDB->manipulateF(
7790        "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7791        array("integer", "integer"),
7792        array($typ_id, 2)
7793    );
7794    $ilDB->manipulateF(
7795        "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7796        array("integer", "integer"),
7797        array($typ_id, 3)
7798    );
7799    $ilDB->manipulateF(
7800        "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
7801        array("integer", "integer"),
7802        array($typ_id, 4)
7803    );
7804?>
7805<#3453>
7806<?php
7807    $ilCtrlStructureReader->getStructure();
7808?>
7809<#3454>
7810<?php
7811
7812    if (!$ilDB->tableColumnExists("didactic_tpl_settings", "info")) {
7813        $ilDB->addTableColumn("didactic_tpl_settings", "info", array(
7814            "type" => "text",
7815            "notnull" => false,
7816            "length" => 4000,
7817            "fixed" => false));
7818    }
7819?>
7820
7821<#3455>
7822<?php
7823
7824    $query = 'DELETE FROM didactic_tpl_objs';
7825    $ilDB->manipulate($query);
7826
7827    if (!$ilDB->tableColumnExists("didactic_tpl_objs", "ref_id")) {
7828        $ilDB->addTableColumn("didactic_tpl_objs", "ref_id", array(
7829            "type" => "integer",
7830            "notnull" => false,
7831            "length" => 4
7832        ));
7833    }
7834
7835    $ilDB->dropPrimaryKey('didactic_tpl_objs');
7836    $ilDB->addPrimaryKey('didactic_tpl_objs', array('ref_id','tpl_id'));
7837?>
7838
7839<#3456>
7840<?php
7841    if (!$ilDB->tableColumnExists("chatroom_settings", "display_past_msgs")) {
7842        $ilDB->addTableColumn("chatroom_settings", "display_past_msgs", array(
7843            "type" => "integer",
7844            "notnull" => true,
7845            "length" => 4,
7846            "default" => 0));
7847    }
7848?>
7849<#3457>
7850<?php
7851    $ilCtrlStructureReader->getStructure();
7852?>
7853<#3458>
7854<?php
7855    $ilDB->addTableColumn(
7856    "usr_data",
7857    "last_visited",
7858    array(
7859        "type" => "clob",
7860        "notnull" => false,
7861        "default" => null)
7862);
7863?>
7864<#3459>
7865<?php
7866    if (!$ilDB->tableColumnExists("chatroom_history", "sub_room")) {
7867        $ilDB->addTableColumn("chatroom_history", "sub_room", array(
7868            "type" => "integer",
7869            "notnull" => false,
7870            "length" => 4,
7871            "default" => 0));
7872    }
7873?>
7874<#3460>
7875<?php
7876    $ilDB->setLimit(1);
7877    $query = "SELECT object_data.obj_id, object_reference.ref_id FROM object_data INNER JOIN object_reference on object_data.obj_id = object_reference.obj_id WHERE type = 'chta'";
7878    $rset = $ilDB->query($query);
7879    $row = $ilDB->fetchAssoc($rset);
7880
7881    $chatfolder_obj_id = $row['obj_id'];
7882    $chatfolder_ref_id = $row['ref_id'];
7883
7884    $settings = new ilSetting('chatroom');
7885    $public_room_ref_id = $settings->get('public_room_ref', 0);
7886
7887    $query = "SELECT object_data.obj_id, object_reference.ref_id FROM object_data INNER JOIN object_reference on object_data.obj_id = object_reference.obj_id WHERE ref_id = %s AND deleted IS null";
7888    $rset = $ilDB->queryF($query, array('integer'), array($public_room_ref_id));
7889
7890    if (!$public_room_ref_id || !$rset->numRows($res)) {
7891
7892        // add chat below ChatSettings for personal desktop chat
7893
7894        $obj_id = $ilDB->nextId('object_data');
7895
7896        // Get chat settings id
7897
7898        $ilDB->manipulateF(
7899            "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
7900                "VALUES (%s, %s, %s, %s, %s, %s, %s)",
7901            array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
7902            array($obj_id, "chtr", "Public Chatroom", "Public Chatroom", -1, ilUtil::now(), ilUtil::now())
7903        );
7904
7905        $ref_id = $ilDB->nextId('object_reference');
7906
7907        // Create reference
7908        $ilDB->manipulateF(
7909            "INSERT INTO object_reference (ref_id, obj_id) VALUES (%s, %s)",
7910            array('integer', 'integer'),
7911            array($ref_id,$obj_id)
7912        );
7913
7914        // put in tree
7915        $tree = new ilTree(ROOT_FOLDER_ID);
7916        $tree->insertNode($ref_id, $chatfolder_ref_id);
7917
7918        $rolf_obj_id = $ilDB->nextId('object_data');
7919
7920        // Create role folder
7921        $ilDB->manipulateF(
7922            "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
7923                "VALUES (%s, %s, %s, %s, %s, %s, %s)",
7924            array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
7925            array($rolf_obj_id, "rolf", $obj_id, "(ref_id " . $ref_id . ")", -1, ilUtil::now(), ilUtil::now())
7926        );
7927
7928        $rolf_ref_id = $ilDB->nextId('object_reference');
7929
7930        // Create reference
7931        $ilDB->manipulateF(
7932            "INSERT INTO object_reference (ref_id, obj_id) VALUES (%s, %s)",
7933            array('integer', 'integer'),
7934            array($rolf_ref_id,$rolf_obj_id)
7935        );
7936
7937        // put in tree
7938        $tree->insertNode($rolf_ref_id, $ref_id);
7939
7940        $role_obj_id = $ilDB->nextId('object_data');
7941
7942        // Create role
7943        $ilDB->manipulateF(
7944            "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
7945                "VALUES (%s, %s, %s, %s, %s, %s, %s)",
7946            array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
7947            array($role_obj_id, "role", "il_chat_moderator_" . $ref_id, "Moderator of chat obj_no." . $obj_id, -1, ilUtil::now(), ilUtil::now())
7948        );
7949
7950        // Insert role_data
7951        $ilDB->manipulateF(
7952            'INSERT INTO role_data (role_id) VALUES (%s)',
7953            array('integer'),
7954            array($role_obj_id)
7955        );
7956
7957        $permissions = ilRbacReview::_getOperationIdsByName(array('visible','read','moderate'));
7958        $rbacadmin = new ilRbacAdmin();
7959        $rbacadmin->grantPermission($role_obj_id, $permissions, $ref_id);
7960        $rbacadmin->assignRoleToFolder($role_obj_id, $rolf_ref_id);
7961
7962
7963        $id = $ilDB->nextId('chatroom_settings');
7964        $ilDB->insert(
7965            'chatroom_settings',
7966            array(
7967            'room_id' => array('integer', $id),
7968            'object_id' => array('integer', $obj_id),
7969            'room_type' => array('text', 'default'),
7970            'allow_anonymous' => array('integer', 0),
7971            'allow_custom_usernames' => array('integer', 0),
7972            'enable_history' => array('integer', 0),
7973            'restrict_history' => array('integer', 0),
7974            'autogen_usernames' => array('text', 'Anonymous #'),
7975            'allow_private_rooms' => array('integer', 1),
7976        )
7977        );
7978
7979        $settings = new ilSetting('chatroom');
7980        $settings->set('public_room_ref', $ref_id);
7981    }
7982
7983?>
7984<#3461>
7985<?php
7986
7987    $chat_modetator_tpl_id = $ilDB->nextId('object_data');
7988
7989    $ilDB->manipulateF(
7990        "
7991		INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
7992        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
7993        array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
7994        array($chat_modetator_tpl_id, "rolt", "il_chat_moderator", "Moderator template for chat moderators", -1, ilUtil::now(), ilUtil::now())
7995    );
7996
7997    $query = 'SELECT ops_id FROM rbac_operations WHERE operation = ' . $ilDB->quote('moderate', 'text');
7998    $rset = $ilDB->query($query);
7999    $row = $ilDB->fetchAssoc($rset);
8000    $moderateId = $row['ops_id'];
8001
8002    $chat_modetator_ops = array(2,3,4,$moderateId);
8003    foreach ($chat_modetator_ops as $op_id) {
8004        $query = "INSERT INTO rbac_templates
8005		VALUES (" . $ilDB->quote($chat_modetator_tpl_id) . ", 'chtr', " . $ilDB->quote($op_id) . ", 8)";
8006        $ilDB->manipulate($query);
8007    }
8008
8009    $query = "INSERT
8010		INTO rbac_fa
8011		VALUES (" . $ilDB->quote($chat_modetator_tpl_id) . ", 8, 'n', 'n')";
8012    $ilDB->manipulate($query);
8013?>
8014<#3462>
8015<?php
8016
8017    $ilDB->setLimit(1);
8018    $query = "SELECT object_data.obj_id, object_reference.ref_id FROM object_data INNER JOIN object_reference on object_data.obj_id = object_reference.obj_id WHERE type = 'chta'";
8019    $rset = $ilDB->query($query);
8020    $row = $ilDB->fetchAssoc($rset);
8021
8022    $chatfolder_obj_id = $row['obj_id'];
8023    $chatfolder_ref_id = $row['ref_id'];
8024
8025    $settings = new ilSetting('chatroom');
8026    $public_room_ref_id = $settings->get('public_room_ref', 0);
8027
8028    if ($public_room_ref_id) {
8029        $tree = new ilTree(ROOT_FOLDER_ID);
8030        $pid = $tree->getParentId($public_room_ref_id);
8031        if ($pid != $chatfolder_ref_id) {
8032            $tree->moveTree($public_room_ref_id, $chatfolder_ref_id);
8033        }
8034    }
8035?>
8036<#3463>
8037<?php
8038    $ilCtrlStructureReader->getStructure();
8039?>
8040<#3464>
8041<?php
8042if (!$ilDB->tableExists('note_settings')) {
8043    $fields = array(
8044        'rep_obj_id' => array(
8045            'type' => 'integer',
8046            'length' => 4,
8047            'notnull' => true,
8048            'default' => 0),
8049
8050        'obj_id' => array(
8051            'type' => 'integer',
8052            'length' => 4,
8053            'notnull' => true,
8054            'default' => 0),
8055
8056        'obj_type' => array(
8057            'type' => 'text',
8058            'notnull' => true,
8059            'length' => 10,
8060            'default' => "-"),
8061
8062        'activated' => array(
8063            'type' => 'integer',
8064            'length' => 1,
8065            'notnull' => true,
8066            'default' => 0)
8067    );
8068    $ilDB->createTable('note_settings', $fields);
8069    $ilDB->addPrimaryKey('note_settings', array('rep_obj_id', 'obj_id', 'obj_type'));
8070}
8071?>
8072<#3465>
8073<?php
8074    $set = $ilDB->query(
8075    "SELECT * FROM settings " .
8076        " WHERE module = " . $ilDB->quote("notes", "text")
8077);
8078    while ($rec = $ilDB->fetchAssoc($set)) {
8079        $kw_arr = explode("_", $rec["keyword"]);
8080        if ($rec["value"] == "1" && $kw_arr[0] == "activate") {
8081            if ($kw_arr[3] == "") {
8082                $kw_arr[3] = "-";
8083            }
8084            $q = "INSERT INTO note_settings " .
8085                "(rep_obj_id, obj_id, obj_type, activated) VALUES (" .
8086                $ilDB->quote((int) $kw_arr[1], "integer") . "," .
8087                $ilDB->quote((int) $kw_arr[2], "integer") . "," .
8088                $ilDB->quote($kw_arr[3], "text") . "," .
8089                $ilDB->quote(1, "integer") .
8090                ")";
8091            $ilDB->manipulate($q);
8092        }
8093    }
8094?>
8095<#3466>
8096<?php
8097    if (!$ilDB->tableColumnExists("chatroom_settings", "private_rooms_enabled")) {
8098        $ilDB->addTableColumn("chatroom_settings", "private_rooms_enabled", array(
8099            "type" => "integer",
8100            "notnull" => true,
8101            "length" => 4,
8102            "default" => 0));
8103    }
8104?>
8105<#3467>
8106<?php
8107    $settings = new ilSetting('chatroom');
8108    $public_room_ref_id = $settings->get('public_room_ref', 0);
8109    if ($public_room_ref_id) {
8110        //$ilDB->manipulateF('UPDATE ')
8111        $rset = $ilDB->queryF('SELECT obj_id FROM object_reference WHERE ref_id = %s', array('integer'), array($public_room_ref_id));
8112        $row = $ilDB->fetchAssoc($rset);
8113        if ($row) {
8114            $obj_id = $row['obj_id'];
8115            $ilDB->manipulateF('UPDATE chatroom_settings SET private_rooms_enabled = 1 WHERE object_id = %s', array('integer'), array($obj_id));
8116        }
8117    }
8118?>
8119<#3468>
8120<?php
8121    $statement = $ilDB->queryF(
8122    '
8123		SELECT obj_id FROM object_data
8124		WHERE type = %s
8125		AND title = %s',
8126    array('text', 'text'),
8127    array('rolt', 'il_chat_moderator')
8128);
8129
8130    $res = $ilDB->fetchAssoc($statement);
8131
8132    if (!$res || $res->obj_id) {
8133        $chat_modetator_tpl_id = $ilDB->nextId('object_data');
8134
8135        $ilDB->manipulateF(
8136            "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
8137            "VALUES (%s, %s, %s, %s, %s, %s, %s)",
8138            array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
8139            array($chat_modetator_tpl_id, "rolt", "il_chat_moderator", "Moderator template for chat moderators", -1, ilUtil::now(), ilUtil::now())
8140        );
8141
8142        $query = 'SELECT ops_id FROM rbac_operations WHERE operation = ' . $ilDB->quote('moderate', 'text');
8143        $rset = $ilDB->query($query);
8144        $row = $ilDB->fetchAssoc($rset);
8145        $moderateId = $row['ops_id'];
8146
8147        $chat_modetator_ops = array(2,3,4,$moderateId);
8148        foreach ($chat_modetator_ops as $op_id) {
8149            $query = "INSERT INTO rbac_templates
8150			VALUES (" . $ilDB->quote($chat_modetator_tpl_id) . ", 'chtr', " . $ilDB->quote($op_id) . ", 8)";
8151            $ilDB->manipulate($query);
8152        }
8153
8154        $query = "INSERT
8155			INTO rbac_fa
8156			VALUES (" . $ilDB->quote($chat_modetator_tpl_id) . ", 8, 'n', 'n')";
8157        $ilDB->manipulate($query);
8158    }
8159?>
8160<#3469>
8161<?php
8162    $query = 'SELECT ops_id FROM rbac_operations WHERE operation = ' . $ilDB->quote('moderate', 'text');
8163    $rset = $ilDB->query($query);
8164    $row = $ilDB->fetchAssoc($rset);
8165    $moderateId = $row['ops_id'];
8166
8167    $statement = $ilDB->queryF(
8168        '
8169		SELECT obj_id FROM object_data
8170		WHERE type = %s
8171		AND title = %s',
8172        array('text', 'text'),
8173        array('rolt', 'il_chat_moderator')
8174    );
8175
8176    $res = $ilDB->fetchAssoc($statement);
8177
8178    $typ_id = $res['obj_id'];
8179    /*
8180    $chat_moderator_ops = array(2,3,4,$moderateId);
8181    foreach($chat_moderator_ops as $new_ops_id) {
8182        $query = $ilDB->manipulateF(
8183            'INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)',
8184            array('integer','integer'),
8185            array($typ_id, $new_ops_id)
8186        );
8187    }
8188     */
8189?>
8190<#3470>
8191<?php
8192    $ilCtrlStructureReader->getStructure();
8193?>
8194<#3471>
8195<?php
8196    $ilCtrlStructureReader->getStructure();
8197?>
8198<#3472>
8199<?php
8200    $statement = $ilDB->queryF(
8201    '
8202		SELECT obj_id FROM object_data
8203		WHERE type = %s
8204		AND title = %s',
8205    array('text', 'text'),
8206    array('rolt', 'il_chat_moderator')
8207);
8208
8209    $res = $ilDB->fetchAssoc($statement);
8210
8211    if ($res && $res['obj_id']) {
8212        $chat_modetator_tpl_id = $res['obj_id'];
8213
8214        $ilDB->manipulateF(
8215            "DELETE FROM rbac_ta WHERE typ_id = %s",
8216            array("integer"),
8217            array($chat_modetator_tpl_id)
8218        );
8219    }
8220?>
8221<#3473>
8222<?php
8223    $ilCtrlStructureReader->getStructure();
8224?>
8225<#3474>
8226<?php
8227    $ilCtrlStructureReader->getStructure();
8228?>
8229<#3475>
8230<?php
8231    $ilCtrlStructureReader->getStructure();
8232?>
8233<#3476>
8234<?php
8235    if (!$ilDB->tableColumnExists("exc_data", "certificate_visibility")) {
8236        $ilDB->addTableColumn("exc_data", "certificate_visibility", array(
8237            "type" => "integer",
8238            "notnull" => true,
8239            "length" => 1,
8240            "default" => 0));
8241    }
8242?>
8243<#3477>
8244<?php
8245    $ilCtrlStructureReader->getStructure();
8246?>
8247<#3478>
8248<?php
8249    $ilCtrlStructureReader->getStructure();
8250?>
8251<#3479>
8252<?php
8253    if (!$ilDB->tableColumnExists('sahs_lm', 'sequencing')) {
8254        $ilDB->addTableColumn(
8255            'sahs_lm',
8256            'sequencing',
8257            array(
8258                "type" => "text",
8259                'length' => 1,
8260                "notnull" => true,
8261                "default" => 'y'
8262            )
8263        );
8264        $ilDB->query("UPDATE sahs_lm SET sequencing = 'y'");
8265    }
8266?>
8267<#3480>
8268<?php
8269    if (!$ilDB->tableColumnExists('sahs_lm', 'interactions')) {
8270        $ilDB->addTableColumn(
8271            'sahs_lm',
8272            'interactions',
8273            array(
8274                "type" => "text",
8275                'length' => 1,
8276                "notnull" => true,
8277                "default" => 'y'
8278            )
8279        );
8280        $ilDB->query("UPDATE sahs_lm SET interactions = 'y'");
8281    }
8282?>
8283<#3481>
8284<?php
8285    if (!$ilDB->tableColumnExists('sahs_lm', 'objectives')) {
8286        $ilDB->addTableColumn(
8287            'sahs_lm',
8288            'objectives',
8289            array(
8290                "type" => "text",
8291                'length' => 1,
8292                "notnull" => true,
8293                "default" => 'y'
8294            )
8295        );
8296        $ilDB->query("UPDATE sahs_lm SET objectives = 'y'");
8297    }
8298?>
8299<#3482>
8300<?php
8301    if (!$ilDB->tableColumnExists('sahs_lm', 'time_from_lms')) {
8302        $ilDB->addTableColumn(
8303            'sahs_lm',
8304            'time_from_lms',
8305            array(
8306                "type" => "text",
8307                'length' => 1,
8308                "notnull" => true,
8309                "default" => 'n'
8310            )
8311        );
8312        $ilDB->query("UPDATE sahs_lm SET time_from_lms = 'n'");
8313    }
8314?>
8315<#3483>
8316<?php
8317    if (!$ilDB->tableColumnExists('sahs_lm', 'comments')) {
8318        $ilDB->addTableColumn(
8319            'sahs_lm',
8320            'comments',
8321            array(
8322                "type" => "text",
8323                'length' => 1,
8324                "notnull" => true,
8325                "default" => 'y'
8326            )
8327        );
8328        $ilDB->query("UPDATE sahs_lm SET comments = 'y'");
8329    }
8330?>
8331<#3484>
8332<?php
8333
8334    // Get all users with extended profile pages
8335    $set = $ilDB->query("SELECT DISTINCT(user_id) FROM usr_ext_profile_page");
8336    $user_ids = array();
8337    while ($rec = $ilDB->fetchAssoc($set)) {
8338        $user_ids[] = $rec["user_id"];
8339    }
8340
8341    if (sizeof($user_ids)) {
8342        foreach ($user_ids as $user_id) {
8343            $portfolio_id = $ilDB->nextId("object_data");
8344
8345            // create portfolio object
8346            $ilDB->manipulate("INSERT INTO object_data" .
8347                 " (obj_id,type,title,description,owner,create_date,last_update,import_id)" .
8348                 " VALUES (" .
8349                 $ilDB->quote($portfolio_id, "integer") . "," .
8350                 $ilDB->quote("prtf", "text") . "," .
8351                 $ilDB->quote("Default", "text") . "," .
8352                 $ilDB->quote("", "text") . "," .
8353                 $ilDB->quote($user_id, "integer") . "," .
8354                 $ilDB->now() . "," .
8355                 $ilDB->now() . "," .
8356                 $ilDB->quote("", "text") . ")");
8357
8358            // create portfolio data
8359            $ilDB->manipulate("INSERT INTO usr_portfolio (id,is_online,is_default)" .
8360                " VALUES (" . $ilDB->quote($portfolio_id, "integer") . "," .
8361                $ilDB->quote(true, "integer") . "," .
8362                $ilDB->quote(true, "integer") . ")");
8363
8364            $page_id = $ilDB->nextId("usr_portfolio_page");
8365
8366            // create first page as profile
8367            $fields = array("portfolio_id" => array("integer", $portfolio_id),
8368                "type" => array("integer", 1),
8369                "title" => array("text", "###-"),
8370                "order_nr" => array("integer", 10),
8371                "id" => array("integer", $page_id));
8372            $ilDB->insert("usr_portfolio_page", $fields);
8373
8374            // first page has public profile as default
8375            $xml = "<PageObject>" .
8376                "<PageContent PCID=\"" . ilUtil::randomHash() . "\">" .
8377                    "<Profile Mode=\"inherit\" User=\"" . $user_id . "\"/>" .
8378                "</PageContent>" .
8379            "</PageObject>";
8380
8381            // create first page core
8382            $ilDB->insert("page_object", array(
8383                "page_id" => array("integer", $page_id),
8384                "parent_id" => array("integer", $portfolio_id),
8385                "content" => array("clob", $xml),
8386                "parent_type" => array("text", "prtf"),
8387                "create_user" => array("integer", $user_id),
8388                "last_change_user" => array("integer", $user_id),
8389                "inactive_elements" => array("integer", 0),
8390                "int_links" => array("integer", 0),
8391                "created" => array("timestamp", ilUtil::now()),
8392                "last_change" => array("timestamp", ilUtil::now())
8393                ));
8394
8395            // migrate extended profile pages
8396            $set = $ilDB->query("SELECT ext.id, ext.title, pg.content FROM usr_ext_profile_page ext" .
8397                " JOIN page_object pg ON (pg.page_id = ext.id)" .
8398                " WHERE ext.user_id = " . $ilDB->quote($user_id, "integer") .
8399                " AND parent_type =" . $ilDB->quote("user", "text") .
8400                " AND parent_id = " . $ilDB->quote($user_id, "integer") .
8401                " ORDER BY ext.order_nr");
8402            $order = 10;
8403            while ($rec = $ilDB->fetchAssoc($set)) {
8404                $order += 10;
8405
8406                $page_id = $ilDB->nextId("usr_portfolio_page");
8407
8408                // #8600: title may be null
8409                $page_title = $rec["title"];
8410                if (!$page_title) {
8411                    $page_title = "prtf" . $portfolio_id . "_" . $rec["id"];
8412                }
8413
8414                // create portfolio page
8415                $fields = array("portfolio_id" => array("integer", $portfolio_id),
8416                    "type" => array("integer", 1),
8417                    "title" => array("text", $page_title),
8418                    "order_nr" => array("integer", $order),
8419                    "id" => array("integer", $page_id));
8420                $ilDB->insert("usr_portfolio_page", $fields);
8421
8422                // create page core
8423                $ilDB->insert("page_object", array(
8424                    "page_id" => array("integer", $page_id),
8425                    "parent_id" => array("integer", $portfolio_id),
8426                    "content" => array("clob", $rec["content"]),
8427                    "parent_type" => array("text", "prtf"),
8428                    "create_user" => array("integer", $user_id),
8429                    "last_change_user" => array("integer", $user_id),
8430                    "inactive_elements" => array("integer", 0),
8431                    "int_links" => array("integer", 0),
8432                    "created" => array("timestamp", ilUtil::now()),
8433                    "last_change" => array("timestamp", ilUtil::now())
8434                    ));
8435            }
8436        }
8437    }
8438?>
8439<#3485>
8440<?php
8441    $ilDB->addPrimaryKey('adm_settings_template', array('id'));
8442?>
8443<#3486>
8444<?php
8445    $ilDB->addPrimaryKey('ecs_server', array('server_id'));
8446?>
8447<#3487>
8448<?php
8449    $setting = new ilSetting();
8450    $setting->set("obj_dis_creation_dbk", 1);
8451?>
8452<#3488>
8453<?php
8454
8455    $ilDB->modifyTableColumn(
8456        'frm_settings',
8457        'preset_subject',
8458        array('type' => 'integer',
8459        'notnull' => true,
8460        'length' => 1,
8461        'default' => 1)
8462    );
8463?>
8464<#3489>
8465<?php
8466    $ilCtrlStructureReader->getStructure();
8467?>
8468<#3490>
8469<?php
8470    $ilDB->addIndex("page_object", array("parent_id"), "i2");
8471?>
8472<#3491>
8473<?php
8474    $ilDB->addIndex("page_history", array("page_id"), "i1");
8475?>
8476<#3492>
8477<?php
8478    $ilDB->addIndex('cmi_interaction', array('cmi_node_id'), "i4");
8479?>
8480<#3493>
8481<?php
8482    $ilDB->addIndex('object_data', array('import_id'), "i4");
8483?>
8484<#3494>
8485<?php
8486    $ilDB->addIndex('usr_data', array('ext_account', 'auth_mode'), "i2");
8487?>
8488<#3495>
8489<?php
8490    $ilDB->addIndex('event', array('obj_id'), "i1");
8491?>
8492<#3496>
8493<?php
8494    $ilDB->addIndex('conditions', array('target_obj_id'), "i1");
8495?>
8496<#3497>
8497<?php
8498    $ilDB->addIndex('mob_usage', array('usage_id'), "i1");
8499?>
8500<#3498>
8501<?php
8502    $ilDB->addIndex('lo_access', array('usr_id'), "i1");
8503?>
8504<#3499>
8505<?php
8506    $ilDB->addIndex('cal_categories', array('type'), "i3");
8507?>
8508<#3500>
8509<?php
8510    $ilDB->addIndex('tree', array('lft'), "i4");
8511?>
8512<#3501>
8513<?php
8514    $ilDB->addTableColumn("skl_tree_node", "draft", array(
8515        "type" => "integer",
8516        "notnull" => true,
8517        "length" => 1,
8518        "default" => 0));
8519?>
8520<#3502>
8521<?php
8522    $next_id = $ilDB->nextId('rbac_operations');
8523
8524    $ilDB->insert("rbac_operations", array(
8525        "ops_id" => array("integer", $next_id),
8526        "operation" => array("text", "create_chtr"),
8527        "description" => array("text", "create chatroom"),
8528        "class" => array("text", "create"),
8529        "op_order" => array("integer", 9999)
8530        ));
8531?>
8532<#3503>
8533<?php
8534    if (!$ilDB->tableColumnExists('il_object_def', 'administration')) {
8535        $ilDB->addTableColumn(
8536            "il_object_def",
8537            "administration",
8538            array(
8539                "type" => "integer",
8540                "length" => 1,
8541                "notnull" => true,
8542                "default" => 0)
8543        );
8544    }
8545?>
8546<#3504>
8547<?php
8548    $ilCtrlStructureReader->getStructure();
8549?>
8550<#3505>
8551<?php
8552    // activate pool usage
8553    $ilDB->manipulate("UPDATE svy_svy SET pool_usage = " . $ilDB->quote(1, "integer"));
8554?>
8555<#3506>
8556<?php
8557    $setting = new ilSetting();
8558    $ilrqtix = $setting->get("ilrqtix");
8559    if (!$ilrqtix) {
8560        $ilDB->addIndex("il_request_token", array("stamp"), "i4");
8561        $setting->set("ilrqtix", 1);
8562    }
8563?>
8564<#3507>
8565<?php
8566    $setting = new ilSetting();
8567    $ilmpathix = $setting->get("ilmpathix");
8568    if (!$ilmpathix) {
8569        $ilDB->addIndex("mail_attachment", array("path"), "i1");
8570        $setting->set("ilmpathix", 1);
8571    }
8572?>
8573<#3508>
8574<?php
8575    $ilCtrlStructureReader->getStructure();
8576?>
8577<#3509>
8578<?php
8579    if (!$ilDB->tableColumnExists('tst_tests', 'print_bs_with_res')) {
8580        $ilDB->addTableColumn(
8581            'tst_tests',
8582            'print_bs_with_res',
8583            array(
8584                'type' => 'integer',
8585                'length' => 1,
8586                'notnull' => true,
8587                'default' => 1
8588            )
8589        );
8590    }
8591?>
8592<#3510>
8593<?php
8594    $setting = new ilSetting();
8595    $allreadyApplied = $setting->get('ilGlobalTstPoolUsageSettingInitilisation', 0);
8596
8597    if (!$allreadyApplied) {
8598        $ilDB->queryF("UPDATE tst_tests SET pool_usage = %s", array('integer'), array(1));
8599
8600        $setting->set("ilGlobalTstPoolUsageSettingInitilisation", 1);
8601    }
8602?>
8603<#3511>
8604<?php
8605    if (!$ilDB->tableExists('obj_lp_stat')) {
8606        $fields = array(
8607            'type' => array(
8608                'type' => 'text',
8609                'length' => 4,
8610                'notnull' => true
8611                ),
8612            'obj_id' => array(
8613                'type' => 'integer',
8614                'length' => 4,
8615                'notnull' => true
8616                ),
8617            'yyyy' => array(
8618                'type' => 'integer',
8619                'length' => 2,
8620                'notnull' => true
8621                ),
8622            'mm' => array(
8623                'type' => 'integer',
8624                'length' => 1,
8625                'notnull' => true
8626                ),
8627            'dd' => array(
8628                'type' => 'integer',
8629                'length' => 1,
8630                'notnull' => true
8631                ),
8632            'fulldate' => array(
8633                'type' => 'integer',
8634                'length' => 4,
8635                'notnull' => true
8636                ),
8637            'mem_cnt' => array(
8638                'type' => 'integer',
8639                'length' => 4,
8640                'notnull' => false
8641                ),
8642            'in_progress' => array(
8643                'type' => 'integer',
8644                'length' => 4,
8645                'notnull' => false
8646                ),
8647            'completed' => array(
8648                'type' => 'integer',
8649                'length' => 4,
8650                'notnull' => false
8651                ),
8652            'failed' => array(
8653                'type' => 'integer',
8654                'length' => 4,
8655                'notnull' => false
8656                ),
8657            'not_attempted' => array(
8658                'type' => 'integer',
8659                'length' => 4,
8660                'notnull' => false
8661                )
8662        );
8663        $ilDB->createTable('obj_lp_stat', $fields);
8664        $ilDB->addPrimaryKey('obj_lp_stat', array("obj_id", "fulldate"));
8665    }
8666?>
8667<#3512>
8668<?php
8669    if (!$ilDB->tableExists('obj_type_stat')) {
8670        $fields = array(
8671            'type' => array(
8672                'type' => 'text',
8673                'length' => 4,
8674                'notnull' => true
8675                ),
8676            'yyyy' => array(
8677                'type' => 'integer',
8678                'length' => 2,
8679                'notnull' => true
8680                ),
8681            'mm' => array(
8682                'type' => 'integer',
8683                'length' => 1,
8684                'notnull' => true
8685                ),
8686            'dd' => array(
8687                'type' => 'integer',
8688                'length' => 1,
8689                'notnull' => true
8690                ),
8691            'fulldate' => array(
8692                'type' => 'integer',
8693                'length' => 4,
8694                'notnull' => true
8695                ),
8696            'cnt_references' => array(
8697                'type' => 'integer',
8698                'length' => 4,
8699                'notnull' => false
8700                ),
8701            'cnt_objects' => array(
8702                'type' => 'integer',
8703                'length' => 4,
8704                'notnull' => false
8705                ),
8706            'cnt_deleted' => array(
8707                'type' => 'integer',
8708                'length' => 4,
8709                'notnull' => false
8710                )
8711        );
8712        $ilDB->createTable('obj_type_stat', $fields);
8713        $ilDB->addPrimaryKey('obj_type_stat', array("type", "fulldate"));
8714    }
8715?>
8716<#3513>
8717<?php
8718    if (!$ilDB->tableExists('obj_user_stat')) {
8719        $fields = array(
8720            'obj_id' => array(
8721                'type' => 'integer',
8722                'length' => 4,
8723                'notnull' => true
8724                ),
8725            'yyyy' => array(
8726                'type' => 'integer',
8727                'length' => 2,
8728                'notnull' => true
8729                ),
8730            'mm' => array(
8731                'type' => 'integer',
8732                'length' => 1,
8733                'notnull' => true
8734                ),
8735            'dd' => array(
8736                'type' => 'integer',
8737                'length' => 1,
8738                'notnull' => true
8739                ),
8740            'fulldate' => array(
8741                'type' => 'integer',
8742                'length' => 4,
8743                'notnull' => true
8744                ),
8745            'counter' => array(
8746                'type' => 'integer',
8747                'length' => 4,
8748                'notnull' => false
8749                )
8750        );
8751        $ilDB->createTable('obj_user_stat', $fields);
8752        $ilDB->addPrimaryKey('obj_user_stat', array("obj_id", "fulldate"));
8753    }
8754?>
8755<#3514>
8756<?php
8757    /* #15615 - obsolete
8758    if(!$ilDB->tableColumnExists("obj_stat", "tstamp"))
8759    {
8760        // table must be empty to add not null column
8761        $ilDB->manipulate("DELETE FROM obj_stat");
8762
8763        $ilDB->addTableColumn('obj_stat', 'tstamp', array(
8764            "type" => "integer",
8765            "notnull" => true,
8766            "length" => 4));
8767
8768        $ilDB->addIndex("obj_stat", array("tstamp", "obj_id"), "i2");
8769    }
8770    */
8771?>
8772<#3515>
8773<?php
8774    if (!$ilDB->tableExists('usr_session_stats_raw')) {
8775        $fields = array(
8776            'session_id' => array(
8777                'type' => 'text',
8778                'length' => 80,
8779                'notnull' => true
8780                ),
8781            'type' => array(
8782                'type' => 'integer',
8783                'length' => 2,
8784                'notnull' => true
8785                ),
8786            'start_time' => array(
8787                'type' => 'integer',
8788                'length' => 4,
8789                'notnull' => true
8790                ),
8791            'end_time' => array(
8792                'type' => 'integer',
8793                'length' => 4,
8794                'notnull' => false
8795                ),
8796            'end_context' => array(
8797                'type' => 'integer',
8798                'length' => 2,
8799                'notnull' => false
8800                ),
8801            'user_id' => array(
8802                'type' => 'integer',
8803                'length' => 4,
8804                'notnull' => true
8805                )
8806        );
8807        $ilDB->createTable('usr_session_stats_raw', $fields);
8808        $ilDB->addPrimaryKey('usr_session_stats_raw', array('session_id'));
8809    }
8810?>
8811<#3516>
8812<?php
8813    if (!$ilDB->tableExists('usr_session_stats')) {
8814        $fields = array(
8815            'slot_begin' => array(
8816                'type' => 'integer',
8817                'length' => 4,
8818                'notnull' => true
8819                ),
8820            'slot_end' => array(
8821                'type' => 'integer',
8822                'length' => 4,
8823                'notnull' => true
8824                ),
8825            'active_min' => array(
8826                'type' => 'integer',
8827                'length' => 4,
8828                'notnull' => false
8829                ),
8830            'active_max' => array(
8831                'type' => 'integer',
8832                'length' => 4,
8833                'notnull' => false
8834                ),
8835            'active_avg' => array(
8836                'type' => 'integer',
8837                'length' => 4,
8838                'notnull' => false
8839                ),
8840            'active_end' => array(
8841                'type' => 'integer',
8842                'length' => 4,
8843                'notnull' => false
8844                ),
8845            'opened' => array(
8846                'type' => 'integer',
8847                'length' => 4,
8848                'notnull' => false
8849                ),
8850            'closed_manual' => array(
8851                'type' => 'integer',
8852                'length' => 4,
8853                'notnull' => false
8854                ),
8855            'closed_expire' => array(
8856                'type' => 'integer',
8857                'length' => 4,
8858                'notnull' => false
8859                ),
8860            'closed_idle' => array(
8861                'type' => 'integer',
8862                'length' => 4,
8863                'notnull' => false
8864                ),
8865            'closed_idle_first' => array(
8866                'type' => 'integer',
8867                'length' => 4,
8868                'notnull' => false
8869                ),
8870            'closed_limit' => array(
8871                'type' => 'integer',
8872                'length' => 4,
8873                'notnull' => false
8874                ),
8875            'closed_login' => array(
8876                'type' => 'integer',
8877                'length' => 4,
8878                'notnull' => false
8879                ),
8880            'max_sessions' => array(
8881                'type' => 'integer',
8882                'length' => 4,
8883                'notnull' => false
8884                )
8885        );
8886        $ilDB->createTable('usr_session_stats', $fields);
8887        $ilDB->addIndex('usr_session_stats', array('slot_end'), 'i1');
8888    }
8889?>
8890<#3517>
8891<?php
8892    $ilCtrlStructureReader->getStructure();
8893?>
8894<#3518>
8895<?php
8896    // taxonomy tree
8897    $fields = array(
8898            'tax_tree_id' => array(
8899                    'type' => 'integer',
8900                    'length' => 4,
8901                    'notnull' => true,
8902                    'default' => 0
8903            ),
8904            'child' => array(
8905                    'type' => 'integer',
8906                    'length' => 4,
8907                    'notnull' => true,
8908                    'default' => 0
8909            ),
8910            'parent' => array(
8911                    'type' => 'integer',
8912                    'length' => 4,
8913                    'notnull' => false,
8914                    'default' => null
8915            ),
8916            'lft' => array(
8917                    'type' => 'integer',
8918                    'length' => 4,
8919                    'notnull' => true,
8920                    'default' => 0
8921            ),
8922            'rgt' => array(
8923                    'type' => 'integer',
8924                    'length' => 4,
8925                    'notnull' => true,
8926                    'default' => 0
8927            ),
8928            'depth' => array(
8929                    'type' => 'integer',
8930                    'length' => 2,
8931                    'notnull' => true,
8932                    'default' => 0
8933            )
8934    );
8935    $ilDB->createTable('tax_tree', $fields);
8936?>
8937<#3519>
8938<?php
8939    // taxonomy node
8940    $fields = array(
8941            'obj_id' => array(
8942                    'type' => 'integer',
8943                    'length' => 4,
8944                    'notnull' => true,
8945                    'default' => 0
8946            ),
8947            'title' => array(
8948                    'type' => 'text',
8949                    'length' => 200,
8950                    'notnull' => false
8951            ),
8952            'type' => array(
8953                    'type' => 'text',
8954                    'length' => 4,
8955                    'fixed' => true,
8956                    'notnull' => false
8957            ),
8958            'create_date' => array(
8959                    'type' => 'timestamp',
8960                    'notnull' => false
8961            ),
8962            'last_update' => array(
8963                    'type' => 'timestamp',
8964                    'notnull' => false
8965            )
8966    );
8967    $ilDB->createTable('tax_node', $fields);
8968    $ilDB->createSequence('tax_node');
8969    $ilDB->addPrimaryKey("tax_node", array("obj_id"));
8970?>
8971<#3520>
8972<?php
8973    // taxonomy use
8974    $fields = array(
8975        'tax_id' => array(
8976            'type' => 'integer',
8977            'length' => 4,
8978            'notnull' => true,
8979            'default' => 0
8980        ),
8981        'obj_id' => array(
8982            'type' => 'integer',
8983            'length' => 4,
8984            'notnull' => true,
8985            'default' => 0
8986        ));
8987    $ilDB->createTable('tax_usage', $fields);
8988    $ilDB->addPrimaryKey("tax_usage", array("tax_id", "obj_id"));
8989?>
8990<#3521>
8991<?php
8992    if (!$ilDB->tableColumnExists("crs_settings", "status_dt")) {
8993        $ilDB->addTableColumn("crs_settings", "status_dt", array(
8994                'type' => 'integer',
8995                'length' => 1,
8996                'default' => 2));
8997    }
8998    if (!$ilDB->tableColumnExists("crs_members", "origin")) {
8999        $ilDB->addTableColumn("crs_members", "origin", array(
9000                'type' => 'integer',
9001                'length' => 4,
9002                'default' => 0));
9003    }
9004    if (!$ilDB->tableColumnExists("crs_members", "origin_ts")) {
9005        $ilDB->addTableColumn("crs_members", "origin_ts", array(
9006                'type' => 'integer',
9007                'length' => 4,
9008                'default' => 0));
9009    }
9010?>
9011<#3522>
9012<?php
9013    $ilCtrlStructureReader->getStructure();
9014?>
9015<#3523>
9016<?php
9017    if (!$ilDB->tableExists('il_event_handling')) {
9018        $fields = array(
9019            'component' => array(
9020                'type' => 'text',
9021                'length' => 50,
9022                'notnull' => true,
9023                'fixed' => false
9024            ),
9025            'type' => array(
9026                'type' => 'text',
9027                'length' => 10,
9028                'notnull' => true,
9029                'fixed' => false
9030            ),
9031            'id' => array(
9032                'type' => 'text',
9033                'length' => 100,
9034                'notnull' => true,
9035                'fixed' => false
9036            ));
9037        $ilDB->createTable('il_event_handling', $fields);
9038    }
9039?>
9040<#3524>
9041<?php
9042    $ilCtrlStructureReader->getStructure();
9043?>
9044<#3525>
9045<?php
9046    if (!$ilDB->tableColumnExists('mail_template', 'att_file')) {
9047        $atts = array(
9048            'type' => 'text',
9049            'length' => 400,
9050            'default' => '',
9051            'notnull' => false
9052        );
9053        $ilDB->addTableColumn('mail_template', 'att_file', $atts);
9054    }
9055?>
9056<#3526>
9057<?php
9058    $ilCtrlStructureReader->getStructure();
9059?>
9060<#3527>
9061<?php
9062$atts = array(
9063    'type' => 'integer',
9064    'length' => 4,
9065    'default' => 0,
9066    'notnull' => true
9067);
9068$ilDB->addTableColumn('tax_node', 'tax_id', $atts);
9069?>
9070<#3528>
9071<?php
9072
9073
9074$ilDB->manipulate("INSERT INTO tax_node " .
9075    "(obj_id, title, type, create_date, last_update, tax_id) VALUES (" .
9076    $ilDB->quote(1, "integer") . "," .
9077    $ilDB->quote("Dummy top node for all tax trees.", "text") . "," .
9078    $ilDB->quote("", "text") . "," .
9079    $ilDB->now() . "," .
9080    $ilDB->now() . "," .
9081    $ilDB->quote(0, "integer") .
9082    ")");
9083
9084?>
9085<#3529>
9086<?php
9087$ilDB->addTableColumn("tax_node", "order_nr", array(
9088        'type' => 'integer',
9089        'length' => 4,
9090        'default' => 0,
9091        'notnull' => true
9092    ));
9093?>
9094<#3530>
9095<?php
9096    include_once "./Services/Object/classes/class.ilObject.php";
9097    include_once "Services/Administration/classes/class.ilSetting.php";
9098    $ilSetting = new ilSetting();
9099    $ilSetting->set("rep_shorten_description", 1);
9100    $ilSetting->set("rep_shorten_description_length", 128);
9101?>
9102<#3531>
9103<?php
9104    $ilCtrlStructureReader->getStructure();
9105?>
9106<#3532>
9107<?php
9108$fields = array(
9109    'chap' => array(
9110        'type' => 'integer',
9111        'length' => 4,
9112        'notnull' => true
9113    ),
9114    'component' => array(
9115        'type' => 'text',
9116        'length' => 10,
9117        'notnull' => true,
9118        'fixed' => false
9119    ),
9120    'screen_id' => array(
9121        'type' => 'text',
9122        'length' => 30,
9123        'notnull' => true,
9124        'fixed' => false
9125    ),
9126    'screen_sub_id' => array(
9127        'type' => 'text',
9128        'length' => 30,
9129        'notnull' => true,
9130        'fixed' => false
9131    )
9132    );
9133$ilDB->createTable('help_map', $fields);
9134$ilDB->addPrimaryKey('help_map', array('component', 'screen_id', 'screen_sub_id', 'chap'));
9135$ilDB->addIndex("help_map", array("screen_id"), "sc");
9136$ilDB->addIndex("help_map", array("chap"), "ch");
9137?>
9138<#3533>
9139<?php
9140    if (!$ilDB->tableExists('usr_session_log')) {
9141        $fields = array(
9142            'tstamp' => array(
9143                'type' => 'integer',
9144                'length' => 4,
9145                'notnull' => true
9146                ),
9147            'maxval' => array(
9148                'type' => 'integer',
9149                'length' => 3,
9150                'notnull' => true
9151                ),
9152            'user_id' => array(
9153                'type' => 'integer',
9154                'length' => 4,
9155                'notnull' => true
9156                ),
9157        );
9158        $ilDB->createTable('usr_session_log', $fields);
9159    }
9160?>
9161<#3534>
9162<?php
9163    $setting = new ilSetting();
9164    $ilpghi2 = $setting->get("ilpghi2");
9165    if (!$ilpghi2) {
9166        $ilDB->addIndex("page_history", array("parent_id", "parent_type", "hdate"), "i2");
9167        $setting->set("ilpghi2", 1);
9168    }
9169?>
9170<#3535>
9171<?php
9172    $setting = new ilSetting();
9173    $ilpgi3 = $setting->get("ilpgi3");
9174    if (!$ilpgi3) {
9175        $ilDB->addIndex("page_object", array("parent_id", "parent_type", "last_change"), "i3");
9176        $setting->set("ilpgi3", 1);
9177    }
9178?>
9179<#3536>
9180<?php
9181    $ilCtrlStructureReader->getStructure();
9182?>
9183<#3537>
9184<?php
9185    // if rpc-server is enabled, enable certificates (migrating old behaviour)
9186    $ilSetting = new ilSetting();
9187    if ($ilSetting->get('rpc_server_host') && $ilSetting->get('rpc_server_port')) {
9188        $certificate_active = new ilSetting("certificate");
9189        $certificate_active->set("active", true);
9190    }
9191?>
9192<#3538>
9193<?php
9194    if (!$ilDB->tableColumnExists("udf_definition", "certificate")) {
9195        $ilDB->addTableColumn("udf_definition", "certificate", array(
9196            "type" => "integer",
9197            "notnull" => true,
9198            "length" => 1,
9199            "default" => 0));
9200    }
9201?>
9202<#3539>
9203<?php
9204$fields = array(
9205    'id' => array(
9206        'type' => 'integer',
9207        'length' => 4,
9208        'notnull' => true
9209    ),
9210    'tt_text' => array(
9211        'type' => 'text',
9212        'length' => 4000,
9213        'notnull' => false,
9214        'fixed' => false
9215    )
9216    );
9217$ilDB->createTable('help_tooltip', $fields);
9218$ilDB->addPrimaryKey('help_tooltip', array('id'));
9219$ilDB->createSequence("help_tooltip");
9220?>
9221<#3540>
9222<?php
9223$fields = array(
9224    'text_id' => array(
9225        'type' => 'integer',
9226        'length' => 4,
9227        'notnull' => true
9228    ),
9229    'tt_id' => array(
9230        'type' => 'text',
9231        'length' => 30,
9232        'notnull' => true,
9233        'fixed' => false
9234    )
9235    );
9236$ilDB->createTable('help_tt_map', $fields);
9237$ilDB->addPrimaryKey('help_tt_map', array('text_id', 'tt_id'));
9238?>
9239<#3541>
9240<?php
9241
9242    if (!$ilDB->tableExists('qpl_hints')) {
9243        $ilDB->createTable('qpl_hints', array(
9244            'qht_hint_id' => array(
9245                'type' => 'integer',
9246                'length' => 4,
9247                'notnull' => true
9248            ),
9249            'qht_question_fi' => array(
9250                'type' => 'integer',
9251                'length' => 4,
9252                'notnull' => true
9253            ),
9254            'qht_hint_index' => array(
9255                'type' => 'integer',
9256                'length' => 4,
9257                'notnull' => true
9258            ),
9259            'qht_hint_points' => array(
9260                'type' => 'float',
9261                'notnull' => true,
9262                'default' => 0
9263            ),
9264            'qht_hint_text' => array(
9265                'type' => 'text',
9266                'length' => 4000,
9267                'fixed' => false,
9268                'notnull' => true
9269            )
9270        ));
9271
9272        $ilDB->addPrimaryKey('qpl_hints', array('qht_hint_id'));
9273        $ilDB->createSequence('qpl_hints');
9274    }
9275
9276?>
9277<#3542>
9278<?php
9279    if (!$ilDB->tableColumnExists("usr_session_stats", "closed_misc")) {
9280        $ilDB->addTableColumn("usr_session_stats", "closed_misc", array(
9281                'type' => 'integer',
9282                'length' => 4,
9283                'default' => 0));
9284    }
9285?>
9286<#3543>
9287<?php
9288
9289    $setting = new ilSetting();
9290    $ilchtrbacfix = $setting->get("ilchtrbacfix");
9291    if (!$ilchtrbacfix) {
9292        $result = $ilDB->query(
9293            'SELECT ops_id
9294			FROM rbac_operations
9295			WHERE operation = ' . $ilDB->quote('create_chat', 'text')
9296        );
9297        while ($row = $ilDB->fetchAssoc($result)) {
9298            $chat_id = $row['ops_id'];
9299        }
9300
9301        $result = $ilDB->query(
9302            'SELECT ops_id
9303			FROM rbac_operations
9304			WHERE operation = ' . $ilDB->quote('create_chtr', 'text')
9305        );
9306        while ($row = $ilDB->fetchAssoc($result)) {
9307            $chatroom_id = $row['ops_id'];
9308        }
9309
9310        if ($chat_id && $chatroom_id) {
9311            $result = $ilDB->query(
9312                'SELECT *
9313				FROM rbac_pa
9314				WHERE ' . $ilDB->like('ops_id', 'text', '%i:' . $chat_id . ';%')
9315            );
9316
9317            $statement = $ilDB->prepareManip(
9318                'UPDATE rbac_pa
9319				SET ops_id = ?
9320				WHERE rol_id = ?
9321				AND ref_id = ?',
9322                array('text', 'integer', 'integer')
9323            );
9324
9325            $rows = array();
9326            while ($row = $ilDB->fetchAssoc($result)) {
9327                $rows[] = $row;
9328            }
9329
9330            foreach ($rows as $row) {
9331                $ops_arr = unserialize($row['ops_id']);
9332
9333                if (!$ops_arr) {
9334                    continue;
9335                }
9336
9337                $key = array_search($chat_id, $ops_arr);
9338                if (!$key) {
9339                    continue;
9340                }
9341
9342                $ops_arr[$key] = $chatroom_id;
9343                $new_ops = serialize($ops_arr);
9344                $ilDB->execute(
9345                    $statement,
9346                    array($new_ops, $row['rol_id'], $row['ref_id'])
9347                );
9348            }
9349
9350            $like = '%s:' . strlen($chat_id) . ':"' . $chat_id . '";%';
9351            $result = $ilDB->query(
9352                'SELECT * FROM rbac_pa
9353				WHERE ' . $ilDB->like('ops_id', 'text', $like)
9354            );
9355
9356            $rows = array();
9357            while ($row = $ilDB->fetchAssoc($result)) {
9358                $rows[] = $row;
9359            }
9360
9361            foreach ($rows as $row) {
9362                $ops_arr = unserialize($row['ops_id']);
9363                if (!$ops_arr) {
9364                    continue;
9365                }
9366
9367                $key = array_search($chat_id, $ops_arr);
9368                if (!$key) {
9369                    continue;
9370                }
9371
9372                $ops_arr[$key] = $chatroom_id;
9373                $new_ops = serialize($ops_arr);
9374                $ilDB->execute(
9375                    $statement,
9376                    array($new_ops, $row['rol_id'], $row['ref_id'])
9377                );
9378            }
9379            $ilDB->free($statement);
9380
9381            $ilDB->manipulate(
9382                'DELETE
9383				FROM rbac_operations
9384				WHERE ops_id = ' . $ilDB->quote($chat_id, 'integer')
9385            );
9386
9387            $ilDB->manipulate(
9388                'UPDATE rbac_ta
9389				SET ops_id = ' . $ilDB->quote($chatroom_id, 'integer') . '
9390				WHERE ops_id = ' . $ilDB->quote($chat_id, 'integer')
9391            );
9392
9393            $ilDB->manipulate(
9394                'UPDATE rbac_templates
9395				SET ops_id = ' . $ilDB->quote($chatroom_id, 'integer') . '
9396				WHERE ops_id = ' . $ilDB->quote($chat_id, 'integer')
9397            );
9398        }
9399
9400        $setting->set("ilchtrbacfix", 1);
9401    }
9402?>
9403<#3544>
9404<?php
9405    $ilDB->manipulate(
9406    'UPDATE rbac_templates
9407		SET type = ' . $ilDB->quote('chtr', 'text') . '
9408		WHERE type = ' . $ilDB->quote('chat', 'text')
9409);
9410?>
9411<#3545>
9412<?php
9413    if (!$ilDB->tableColumnExists("il_blog", "rss_active")) {
9414        $ilDB->addTableColumn("il_blog", "rss_active", array(
9415                'type' => 'integer',
9416                'length' => 1,
9417                'default' => 0));
9418    }
9419?>
9420<#3546>
9421<?php
9422    require_once 'Modules/Chatroom/classes/class.ilChatroom.php';
9423    require_once 'Modules/Chatroom/classes/class.ilChatroomInstaller.php';
9424    ilChatroomInstaller::createMissinRoomSettingsForConvertedObjects();
9425?>
9426<#3547>
9427<?php
9428    if (!$ilDB->tableColumnExists("il_media_cast_data", "sortmode")) {
9429        $ilDB->addTableColumn("il_media_cast_data", "sortmode", array(
9430                'type' => 'integer',
9431                'length' => 1,
9432                'default' => 3));
9433    }
9434?>
9435<#3548>
9436<?php
9437    $ilCtrlStructureReader->getStructure();
9438?>
9439<#3549>
9440<?php
9441
9442    if (!$ilDB->tableExists('il_media_cast_data_ord')) {
9443        $ilDB->createTable('il_media_cast_data_ord', array(
9444            'obj_id' => array(
9445                'type' => 'integer',
9446                'length' => 4,
9447                'notnull' => true
9448            ),
9449            'item_id' => array(
9450                'type' => 'integer',
9451                'length' => 4,
9452                'notnull' => true
9453            ),
9454            'pos' => array(
9455                'type' => 'integer',
9456                'length' => 3,
9457                'notnull' => true
9458            )
9459        ));
9460
9461        $ilDB->addPrimaryKey('il_media_cast_data_ord', array('obj_id','item_id'));
9462    }
9463
9464?>
9465<#3550>
9466<?php
9467    $ilCtrlStructureReader->getStructure();
9468?>
9469<#3551>
9470<?php
9471    $ilCtrlStructureReader->getStructure();
9472?>
9473<#3552>
9474<?php
9475    $ilCtrlStructureReader->getStructure();
9476?>
9477<#3553>
9478<?php
9479$ilCtrlStructureReader->getStructure();
9480?>
9481<#3554>
9482<?php
9483$ilDB->addTableColumn("help_tooltip", "tt_id", array(
9484        'type' => 'text',
9485        'length' => 200,
9486        'notnull' => true,
9487        'fixed' => false
9488    ));
9489?>
9490<#3555>
9491<?php
9492$ilDB->dropTable('help_tt_map');
9493?>
9494<#3556>
9495<?php
9496
9497    if (!$ilDB->tableExists('usr_form_settings')) {
9498        $ilDB->dropTable('member_usr_settings');
9499
9500        $ilDB->createTable('usr_form_settings', array(
9501            'user_id' => array(
9502                'type' => 'integer',
9503                'length' => 4,
9504                'notnull' => true
9505            ),
9506            'id' => array(
9507                'type' => 'text',
9508                'length' => 50,
9509                'notnull' => true
9510            ),
9511            'settings' => array(
9512                'type' => 'text',
9513                'length' => 4000,
9514                'notnull' => true
9515            )
9516        ));
9517
9518        $ilDB->addPrimaryKey('usr_form_settings', array('user_id','id'));
9519    }
9520
9521?>
9522<#3557>
9523<?php
9524$ilCtrlStructureReader->getStructure();
9525?>
9526<#3558>
9527<?php
9528$ilDB->addTableColumn("help_tooltip", "comp", array(
9529        'type' => 'text',
9530        'length' => 10,
9531        'notnull' => true,
9532        'fixed' => false
9533    ));
9534?>
9535<#3559>
9536<?php
9537$ilCtrlStructureReader->getStructure();
9538?>
9539<#3560>
9540<?php
9541
9542include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
9543
9544$blog_type_id = ilDBUpdateNewObjectType::addNewType('blog', 'Blog Object');
9545
9546$rbac_ops = array(
9547    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
9548    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
9549    ilDBUpdateNewObjectType::RBAC_OP_READ,
9550    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
9551    ilDBUpdateNewObjectType::RBAC_OP_DELETE,
9552    ilDBUpdateNewObjectType::RBAC_OP_COPY
9553);
9554ilDBUpdateNewObjectType::addRBACOperations($blog_type_id, $rbac_ops);
9555
9556$parent_types = array('root', 'cat', 'crs', 'fold', 'grp');
9557ilDBUpdateNewObjectType::addRBACCreate('create_blog', 'Create Blog', $parent_types);
9558
9559?>
9560<#3561>
9561<?php
9562$ilDB->addTableColumn("help_map", "perm", array(
9563        'type' => 'text',
9564        'length' => 20,
9565        'notnull' => true,
9566        'fixed' => false
9567    ));
9568?>
9569<#3562>
9570<?php
9571$ilDB->dropPrimaryKey("help_map");
9572$ilDB->addPrimaryKey(
9573    "help_map",
9574    array("chap", "component", "screen_id", "screen_sub_id", "perm")
9575);
9576?>
9577<#3563>
9578<?php
9579    if (!$ilDB->tableColumnExists("il_blog_posting", "author")) {
9580        $ilDB->addTableColumn("il_blog_posting", "author", array(
9581                'type' => 'integer',
9582                'length' => 4,
9583                'notnull' => true,
9584                'default' => 0));
9585    }
9586?>
9587<#3564>
9588<?php
9589
9590include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
9591$type_id = ilDBUpdateNewObjectType::getObjectTypeId('book');
9592ilDBUpdateNewObjectType::addRBACOperations($type_id, array(ilDBUpdateNewObjectType::RBAC_OP_DELETE));
9593
9594?>
9595<#3565>
9596<?php
9597$ilCtrlStructureReader->getStructure();
9598?>
9599
9600<#3566>
9601<?php
9602
9603    include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
9604    ilDBUpdateNewObjectType::deleteRBACOperation(
9605        'sess',
9606        ilDBUpdateNewObjectType::getCustomRBACOperationId('edit_event')
9607    );
9608
9609?>
9610<#3567>
9611<?php
9612
9613include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
9614$type_id = ilDBUpdateNewObjectType::getObjectTypeId('trac');
9615ilDBUpdateNewObjectType::addRBACOperations($type_id, array(ilDBUpdateNewObjectType::RBAC_OP_WRITE));
9616
9617?>
9618<#3568>
9619<?php
9620
9621include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
9622
9623$dcl_type_id = ilDBUpdateNewObjectType::addNewType('dcl', 'Data Collection Object');
9624
9625$rbac_ops = array(
9626    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
9627    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
9628    ilDBUpdateNewObjectType::RBAC_OP_READ,
9629    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
9630    ilDBUpdateNewObjectType::RBAC_OP_DELETE,
9631    ilDBUpdateNewObjectType::RBAC_OP_COPY
9632);
9633ilDBUpdateNewObjectType::addRBACOperations($dcl_type_id, $rbac_ops);
9634
9635$parent_types = array('root', 'cat', 'crs', 'fold', 'grp');
9636ilDBUpdateNewObjectType::addRBACCreate('create_dcl', 'Create Data Collection', $parent_types);
9637
9638// see 3675
9639// ilDBUpdateNewObjectType::addCustomRBACOperation($dcl_type_id, 'add_entry');
9640
9641?>
9642<#3569>
9643<?php
9644$ilCtrlStructureReader->getStructure();
9645?>
9646<#3570>
9647<?php
9648
9649if (!$ilDB->tableColumnExists('tst_tests', 'offer_question_hints')) {
9650    $ilDB->addTableColumn('tst_tests', 'offer_question_hints', array(
9651        'type' => 'integer',
9652        'length' => 1,
9653        'notnull' => true,
9654        'default' => 0
9655    ));
9656}
9657
9658?>
9659<#3571>
9660<?php
9661
9662if (!$ilDB->tableExists('qpl_hint_tracking')) {
9663    $ilDB->createTable('qpl_hint_tracking', array(
9664        'qhtr_track_id' => array(
9665            'type' => 'integer',
9666            'length' => 4,
9667            'notnull' => true
9668        ),
9669        'qhtr_active_fi' => array(
9670            'type' => 'integer',
9671            'length' => 4,
9672            'notnull' => true
9673        ),
9674        'qhtr_pass' => array(
9675            'type' => 'integer',
9676            'length' => 4,
9677            'notnull' => true
9678        ),
9679        'qhtr_question_fi' => array(
9680            'type' => 'integer',
9681            'length' => 4,
9682            'notnull' => true
9683        ),
9684        'qhtr_hint_fi' => array(
9685            'type' => 'integer',
9686            'length' => 4,
9687            'notnull' => true
9688        )
9689    ));
9690
9691    $ilDB->addPrimaryKey('qpl_hint_tracking', array('qhtr_track_id'));
9692
9693    $ilDB->createSequence('qpl_hint_tracking');
9694}
9695
9696?>
9697<#3572>
9698<?php
9699    $ilCtrlStructureReader->getStructure();
9700?>
9701<#3573>
9702<?php
9703    $ilCtrlStructureReader->getStructure();
9704?>
9705<#3574>
9706<?php
9707    // taxonomy node assignment
9708    $fields = array(
9709            'node_id' => array(
9710                    'type' => 'integer',
9711                    'length' => 4,
9712                    'notnull' => true,
9713                    'default' => 0
9714            ),
9715            'component' => array(
9716                    'type' => 'text',
9717                    'length' => 10,
9718                    'notnull' => true
9719            ),
9720            'item_type' => array(
9721                    'type' => 'text',
9722                    'length' => 20,
9723                    'notnull' => true
9724            ),
9725            'item_id' => array(
9726                    'type' => 'integer',
9727                    'length' => 4,
9728                    'notnull' => true,
9729                    'default' => 0
9730            )
9731    );
9732    $ilDB->createTable('tax_node_assignment', $fields);
9733    $ilDB->addPrimaryKey('tax_node_assignment', array('node_id', 'component', 'item_type', 'item_id'));
9734    $ilDB->addIndex("tax_node_assignment", array("component", "item_type", "item_id"), "i1");
9735?>
9736<#3575>
9737<?php
9738    if (!$ilDB->tableColumnExists('payment_prices', 'duration_from')) {
9739        $ilDB->addTableColumn(
9740            "payment_prices",
9741            "duration_from",
9742            array('type' => 'date', 'notnull' => false
9743        )
9744        );
9745    }
9746?>
9747<#3576>
9748<?php
9749    if (!$ilDB->tableColumnExists('payment_prices', 'duration_until')) {
9750        $ilDB->addTableColumn(
9751            "payment_prices",
9752            "duration_until",
9753            array('type' => 'date', 'notnull' => false
9754        )
9755        );
9756    }
9757?>
9758<#3577>
9759<?php
9760    if (!$ilDB->tableColumnExists('payment_prices', 'description')) {
9761        $ilDB->addTableColumn(
9762            "payment_prices",
9763            "description",
9764            array(	'type' => 'text',
9765                'length' => 255,
9766                'notnull' => false,
9767                'fixed' => false
9768        )
9769        );
9770    }
9771?>
9772<#3578>
9773<?php
9774    if (!$ilDB->tableColumnExists('payment_prices', 'price_type')) {
9775        $ilDB->addTableColumn(
9776            'payment_prices',
9777            'price_type',
9778            array('type' => 'integer', 'length' => 1,"notnull" => true,"default" => 1)
9779        );
9780    }
9781?>
9782<#3579>
9783<?php
9784    // migrate prices_table
9785    $ilDB->update(
9786        'payment_prices',
9787        array('price_type' => array('integer', 3)),
9788        array('unlimited_duration' => array('integer', 1))
9789    );
9790?>
9791<#3580>
9792<?php
9793    $ilCtrlStructureReader->getStructure();
9794?>
9795
9796<#3581>
9797<?php
9798    $ilCtrlStructureReader->getStructure();
9799?>
9800
9801<#3582>
9802<?php
9803
9804    if (!$ilDB->tableColumnExists('tst_test_result', 'hint_count')) {
9805        $ilDB->addTableColumn('tst_test_result', 'hint_count', array(
9806            'type' => 'integer',
9807            'length' => 4,
9808            'notnull' => false,
9809            'default' => 0
9810        ));
9811    }
9812
9813    if (!$ilDB->tableColumnExists('tst_test_result', 'hint_points')) {
9814        $ilDB->addTableColumn('tst_test_result', 'hint_points', array(
9815            'type' => 'float',
9816            'notnull' => false,
9817            'default' => 0
9818        ));
9819    }
9820
9821?>
9822
9823<#3583>
9824<?php
9825    $ilCtrlStructureReader->getStructure();
9826?>
9827
9828<#3584>
9829<?php
9830
9831    if (!$ilDB->tableColumnExists('tst_pass_result', 'hint_count')) {
9832        $ilDB->addTableColumn('tst_pass_result', 'hint_count', array(
9833            'type' => 'integer',
9834            'length' => 4,
9835            'notnull' => false,
9836            'default' => 0
9837        ));
9838    }
9839
9840    if (!$ilDB->tableColumnExists('tst_pass_result', 'hint_points')) {
9841        $ilDB->addTableColumn('tst_pass_result', 'hint_points', array(
9842            'type' => 'float',
9843            'notnull' => false,
9844            'default' => 0
9845        ));
9846    }
9847
9848?>
9849
9850<#3585>
9851<?php
9852
9853    if (!$ilDB->tableColumnExists('tst_result_cache', 'hint_count')) {
9854        $ilDB->addTableColumn('tst_result_cache', 'hint_count', array(
9855            'type' => 'integer',
9856            'length' => 4,
9857            'notnull' => false,
9858            'default' => 0
9859        ));
9860    }
9861
9862    if (!$ilDB->tableColumnExists('tst_result_cache', 'hint_points')) {
9863        $ilDB->addTableColumn('tst_result_cache', 'hint_points', array(
9864            'type' => 'float',
9865            'notnull' => false,
9866            'default' => 0
9867        ));
9868    }
9869
9870?>
9871<#3586>
9872<?php
9873$ilDB->addTableColumn('glossary', 'show_tax', array(
9874    'type' => 'integer',
9875    'length' => 1,
9876    'notnull' => true,
9877    'default' => 0
9878));
9879?>
9880<#3587>
9881<?php
9882    $ilCtrlStructureReader->getStructure();
9883?>
9884<#3588>
9885<?php
9886    // taxonomy properties
9887    $fields = array(
9888            'id' => array(
9889                    'type' => 'integer',
9890                    'length' => 4,
9891                    'notnull' => true,
9892                    'default' => 0
9893            ),
9894            'sorting_mode' => array(
9895                    'type' => 'integer',
9896                    'length' => 4,
9897                    'notnull' => true,
9898                    'default' => 0
9899            )
9900    );
9901    $ilDB->createTable('tax_data', $fields);
9902    $ilDB->addPrimaryKey('tax_data', array('id'));
9903?>
9904<#3589>
9905<?php
9906    $set = $ilDB->query(
9907    "SELECT * FROM object_data " .
9908        " WHERE type = " . $ilDB->quote("tax", "text")
9909);
9910    while ($rec = $ilDB->fetchAssoc($set)) {
9911        $ilDB->manipulate("INSERT INTO tax_data " .
9912            "(id, sorting_mode) VALUES (" .
9913            $ilDB->quote($rec["obj_id"], "integer") . "," .
9914            $ilDB->quote(0, "integer") .
9915            ")");
9916    }
9917?>
9918<#3590>
9919<?php
9920    $ts_now = time();
9921    $ts_latest = mktime(23, 55, 00, date('n', time()), date('j', time()), date('Y', time()));
9922
9923    // all limited course objects with ref_id and parent ref_id
9924    $query = "SELECT t.child,t.parent,c.activation_start,c.activation_end" .
9925        " FROM crs_settings c" .
9926        " JOIN object_reference r ON (r.obj_id = c.obj_id)" .
9927        " JOIN tree t ON (r.ref_id = t.child)" .
9928        " LEFT JOIN crs_items i ON (i.obj_id = r.ref_id)" .
9929        " WHERE c.activation_type = " . $ilDB->quote(2, "integer") .
9930        " AND i.obj_id IS NULL";
9931    $set = $ilDB->query($query);
9932    while ($row = $ilDB->fetchAssoc($set)) {
9933        $query = "INSERT INTO crs_items (parent_id,obj_id,timing_type,timing_start," .
9934            "timing_end,suggestion_start,suggestion_end,changeable,earliest_start," .
9935            "latest_end,visible,position) VALUES (" .
9936            $ilDB->quote($row["parent"], 'integer') . "," .
9937            $ilDB->quote($row["child"], 'integer') . "," .
9938            $ilDB->quote(0, 'integer') . "," .
9939            $ilDB->quote($row["activation_start"], 'integer') . "," .
9940            $ilDB->quote($row["activation_end"], 'integer') . "," .
9941            $ilDB->quote($ts_now, 'integer') . "," .
9942            $ilDB->quote($ts_now, 'integer') . "," .
9943            $ilDB->quote(0, 'integer') . "," .
9944            $ilDB->quote($ts_now, 'integer') . ", " .
9945            $ilDB->quote($ts_latest, 'integer') . ", " .
9946            $ilDB->quote(0, 'integer') . ", " .
9947            $ilDB->quote(0, 'integer') . ")";
9948        $ilDB->manipulate($query);
9949    }
9950?>
9951<#3591>
9952<?php
9953    $ilCtrlStructureReader->getStructure();
9954?>
9955<#3592>
9956<?php
9957    $ilDB->addPrimaryKey('tax_tree', array('tax_tree_id', 'child'));
9958?>
9959<#3593>
9960<?php
9961$ilDB->addTableColumn('page_object', 'show_activation_info', array(
9962    'type' => 'integer',
9963    'length' => 1,
9964    'notnull' => true,
9965    'default' => 0
9966));
9967?>
9968<#3594>
9969<?php
9970
9971    if (!$ilDB->tableColumnExists('tst_tests', 'highscore_enabled')) {
9972        $ilDB->addTableColumn('tst_tests', 'highscore_enabled', array(
9973            'type' => 'integer',
9974            'length' => 4,
9975            'notnull' => false,
9976            'default' => 0
9977        ));
9978    }
9979
9980    if (!$ilDB->tableColumnExists('tst_tests', 'highscore_anon')) {
9981        $ilDB->addTableColumn('tst_tests', 'highscore_anon', array(
9982            'type' => 'integer',
9983            'length' => 4,
9984            'notnull' => false,
9985            'default' => 0
9986        ));
9987    }
9988
9989    if (!$ilDB->tableColumnExists('tst_tests', 'highscore_achieved_ts')) {
9990        $ilDB->addTableColumn('tst_tests', 'highscore_achieved_ts', array(
9991            'type' => 'integer',
9992            'length' => 4,
9993            'notnull' => false,
9994            'default' => 0
9995        ));
9996    }
9997
9998    if (!$ilDB->tableColumnExists('tst_tests', 'highscore_score')) {
9999        $ilDB->addTableColumn('tst_tests', 'highscore_score', array(
10000            'type' => 'integer',
10001            'length' => 4,
10002            'notnull' => false,
10003            'default' => 0
10004        ));
10005    }
10006
10007    if (!$ilDB->tableColumnExists('tst_tests', 'highscore_percentage')) {
10008        $ilDB->addTableColumn('tst_tests', 'highscore_percentage', array(
10009            'type' => 'integer',
10010            'length' => 4,
10011            'notnull' => false,
10012            'default' => 0
10013        ));
10014    }
10015
10016    if (!$ilDB->tableColumnExists('tst_tests', 'highscore_hints')) {
10017        $ilDB->addTableColumn('tst_tests', 'highscore_hints', array(
10018            'type' => 'integer',
10019            'length' => 4,
10020            'notnull' => false,
10021            'default' => 0
10022        ));
10023    }
10024
10025    if (!$ilDB->tableColumnExists('tst_tests', 'highscore_wtime')) {
10026        $ilDB->addTableColumn('tst_tests', 'highscore_wtime', array(
10027            'type' => 'integer',
10028            'length' => 4,
10029            'notnull' => false,
10030            'default' => 0
10031        ));
10032    }
10033
10034    if (!$ilDB->tableColumnExists('tst_tests', 'highscore_own_table')) {
10035        $ilDB->addTableColumn('tst_tests', 'highscore_own_table', array(
10036            'type' => 'integer',
10037            'length' => 4,
10038            'notnull' => false,
10039            'default' => 0
10040        ));
10041    }
10042
10043    if (!$ilDB->tableColumnExists('tst_tests', 'highscore_top_table')) {
10044        $ilDB->addTableColumn('tst_tests', 'highscore_top_table', array(
10045            'type' => 'integer',
10046            'length' => 4,
10047            'notnull' => false,
10048            'default' => 0
10049        ));
10050    }
10051
10052    if (!$ilDB->tableColumnExists('tst_tests', 'highscore_top_num')) {
10053        $ilDB->addTableColumn('tst_tests', 'highscore_top_num', array(
10054            'type' => 'integer',
10055            'length' => 4,
10056            'notnull' => false,
10057            'default' => 0
10058        ));
10059    }
10060?>
10061<#3595>
10062<?php
10063    include_once "Services/Administration/classes/class.ilSetting.php";
10064    $ilSetting = new ilSetting();
10065    $ilSetting->set("lp_desktop", 1);
10066    $ilSetting->set("lp_learner", 1);
10067?>
10068<#3596>
10069<?php
10070
10071    $pfpg = array();
10072
10073    $set = $ilDB->query("SELECT id,rep_obj_id" .
10074                " FROM note" .
10075                " WHERE obj_type = " . $ilDB->quote("pf", "text") .
10076                " AND obj_id = " . $ilDB->quote(0, "integer"));
10077    while ($nt = $ilDB->fetchAssoc($set)) {
10078        // get first page of portfolio
10079        if (!isset($pfpg[$nt["rep_obj_id"]])) {
10080            $ilDB->setLimit(1);
10081            $fset = $ilDB->query("SELECT id" .
10082                " FROM usr_portfolio_page" .
10083                " WHERE portfolio_id  = " . $ilDB->quote($nt["rep_obj_id"], "integer") .
10084                " AND type = " . $ilDB->quote(1, "integer") .
10085                " ORDER BY order_nr ASC");
10086            $first = $ilDB->fetchAssoc($fset);
10087            $pfpg[$nt["rep_obj_id"]] = $first["id"];
10088        }
10089
10090        if ($pfpg[$nt["rep_obj_id"]] && $nt["id"]) {
10091            $ilDB->manipulate("UPDATE note" .
10092                " SET obj_type = " . $ilDB->quote("pfpg", "text") .
10093                ", obj_id = " . $ilDB->quote($pfpg[$nt["rep_obj_id"]], "integer") .
10094                " WHERE id = " . $ilDB->quote($nt["id"], "integer"));
10095        }
10096    }
10097
10098    unset($pfpg);
10099?>
10100<#3597>
10101<?php
10102    $fields = array(
10103        'id' => array(
10104            'type' => 'integer',
10105            'length' => 4,
10106            'notnull' => true
10107        ),
10108        'main_table_id' => array(
10109            'type' => 'integer',
10110            'length' => 4,
10111            'notnull' => true
10112        ),
10113        'is_online' => array(
10114            'type' => 'integer',
10115            'length' => 1,
10116        ),
10117        'edit_type' => array(
10118            'type' => 'integer',
10119            'length' => 1,
10120        ),
10121        'edit_start' => array(
10122            'type' => 'timestamp',
10123        ),
10124        'edit_end' => array(
10125            'type' => 'timestamp',
10126        ),
10127        'rating' => array(
10128            'type' => 'integer',
10129            'length' => 1,
10130        ),
10131        'public_notes' => array(
10132            'type' => 'integer',
10133            'length' => 1,
10134        ),
10135        'approval' => array(
10136            'type' => 'integer',
10137            'length' => 1,
10138        ),
10139        'notification' => array(
10140            'type' => 'integer',
10141            'length' => 1,
10142        )
10143    );
10144
10145    $ilDB->createTable("il_dcl_data", $fields);
10146    $ilDB->addPrimaryKey("il_dcl_data", array("id"));
10147    $ilDB->createSequence("il_dcl_data");
10148?>
10149<#3598>
10150<?php
10151    $fields = array(
10152        'id' => array(
10153            'type' => 'integer',
10154            'length' => 4,
10155            'notnull' => true
10156        ),
10157        'table_id' => array(
10158            'type' => 'integer',
10159            'length' => 4,
10160            'notnull' => true
10161        ),
10162        'type' => array(
10163            'type' => 'integer',
10164            'length' => 1,
10165        ),
10166        'formtype' => array(
10167            'type' => 'integer',
10168            'length' => 1,
10169        ),
10170    );
10171    $ilDB->createTable("il_dcl_view", $fields);
10172    $ilDB->addPrimaryKey("il_dcl_view", array("id"));
10173    $ilDB->createSequence("il_dcl_view");
10174?>
10175<#3599>
10176<?php
10177  $fields = array(
10178    'id' => array(
10179      'type' => 'integer',
10180      'length' => 4,
10181      'notnull' => true
10182    ),
10183    'datatype_id' => array(
10184      'type' => 'integer',
10185      'length' => 4,
10186      'notnull' => false
10187    ),
10188    'title' => array(
10189      'type' => 'text',
10190      'length' => 256,
10191      'notnull' => false
10192    ),
10193    'inputformat' => array(
10194      'type' => 'integer',
10195      'length' => 1,
10196      'notnull' => true
10197    ),
10198  );
10199  $ilDB->createTable("il_dcl_datatype_prop", $fields);
10200  $ilDB->addPrimaryKey("il_dcl_datatype_prop", array("id"));
10201?>
10202<#3600>
10203<?php
10204    $fields = array(
10205        'id' => array(
10206            'type' => 'integer',
10207            'length' => 4,
10208            'notnull' => true
10209        ),
10210        'obj_id' => array(
10211            'type' => 'integer',
10212            'length' => 4,
10213            'notnull' => true
10214        ),
10215        'title' => array(
10216            'type' => 'text',
10217            'length' => 256,
10218            'notnull' => false
10219        ),
10220    );
10221    $ilDB->createTable("il_dcl_table", $fields);
10222    $ilDB->addPrimaryKey("il_dcl_table", array("id"));
10223    $ilDB->createSequence("il_dcl_table");
10224?>
10225<#3601>
10226<?php
10227    $fields = array(
10228        'id' => array(
10229            'type' => 'integer',
10230            'length' => 4,
10231            'notnull' => true
10232        ),
10233        'table_id' => array(
10234            'type' => 'integer',
10235            'length' => 4,
10236            'notnull' => true
10237        ),
10238        'title' => array(
10239            'type' => 'text',
10240            'length' => 256,
10241            'notnull' => false
10242        ),
10243        'description' => array(
10244            'type' => 'text',
10245            'length' => 256,
10246            'notnull' => false
10247        ),
10248        'datatype_id' => array(
10249            'type' => 'integer',
10250            'length' => 4,
10251            'notnull' => true
10252        ),
10253        'required' => array(
10254        'type' => 'integer',
10255        'length' => 1,
10256        'notnull' => true
10257        ),
10258    );
10259
10260    $ilDB->createTable("il_dcl_field", $fields);
10261    $ilDB->addPrimaryKey("il_dcl_field", array("id"));
10262    $ilDB->createSequence("il_dcl_field");
10263?>
10264<#3602>
10265<?php
10266    $fields = array(
10267        'id' => array(
10268            'type' => 'integer',
10269            'length' => 4,
10270            'notnull' => true
10271        ),
10272        'field_id' => array(
10273        'type' => 'integer',
10274        'length' => 4,
10275        'notnull' => true
10276        ),
10277        'datatype_prop_id' => array(
10278            'type' => 'integer',
10279            'length' => 4,
10280            'notnull' => true
10281        ),
10282        'value' => array(
10283            'type' => 'text',
10284            'length' => 256,
10285            'notnull' => false
10286        ),
10287    );
10288    $ilDB->createTable("il_dcl_field_prop", $fields);
10289    $ilDB->addPrimaryKey("il_dcl_field_prop", array("id"));
10290    $ilDB->createSequence("il_dcl_field_prop");
10291?>
10292<#3603>
10293<?php
10294    $fields = array(
10295        'id' => array(
10296            'type' => 'integer',
10297            'length' => 4,
10298            'notnull' => true
10299        ),
10300        'title' => array(
10301            'type' => 'text',
10302            'length' => 256,
10303            'notnull' => false
10304        ),
10305        'ildb_type' => array(
10306        'type' => 'text',
10307        'length' => 256,
10308        'notnull' => true
10309        ),
10310        'storage_location' => array(
10311        'type' => 'integer',
10312        'length' => 4,
10313        'notnull' => true
10314        ),
10315    );
10316    $ilDB->createTable("il_dcl_datatype", $fields);
10317    $ilDB->addPrimaryKey("il_dcl_datatype", array("id"));
10318?>
10319<#3604>
10320<?php
10321        $ilDB->manipulate("INSERT INTO il_dcl_datatype (id, title, ildb_type, storage_location) " .
10322            " VALUES (" .
10323            $ilDB->quote(1, "integer") . ", " . $ilDB->quote("integer", "text") . ", " . $ilDB->quote("integer", "text") . ", " . $ilDB->quote(2, "integer") .
10324            ")");
10325
10326        $ilDB->manipulate("INSERT INTO il_dcl_datatype (id, title, ildb_type, storage_location) " .
10327            " VALUES (" .
10328$ilDB->quote(2, "integer") . ", " . $ilDB->quote("text", "text") . ", " . $ilDB->quote("text", "text") . ", " . $ilDB->quote(1, "integer") .
10329            ")");
10330
10331        $ilDB->manipulate("INSERT INTO il_dcl_datatype (id, title, ildb_type, storage_location) " .
10332            " VALUES (" .
10333            $ilDB->quote(3, "integer") . ", " . $ilDB->quote("reference", "text") . ", " . $ilDB->quote("integer", "text") . ", " . $ilDB->quote(2, "integer") .
10334            ")");
10335
10336        $ilDB->manipulate("INSERT INTO il_dcl_datatype (id, title, ildb_type, storage_location) " .
10337            " VALUES (" .
10338            $ilDB->quote(4, "integer") . ", " . $ilDB->quote("boolean", "text") . ", " . $ilDB->quote("integer", "text") . ", " . $ilDB->quote(2, "integer") .
10339            ")");
10340
10341        $ilDB->manipulate("INSERT INTO il_dcl_datatype (id, title, ildb_type, storage_location) " .
10342            " VALUES (" .
10343            $ilDB->quote(5, "integer") . ", " . $ilDB->quote("datetime", "text") . ", " . $ilDB->quote("date", "text") . ", " . $ilDB->quote(3, "integer") .
10344            ")");
10345?>
10346<#3605>
10347<?php
10348    $fields = array(
10349        'id' => array(
10350            'type' => 'integer',
10351            'length' => 4,
10352            'notnull' => true
10353        ),
10354        'table_id' => array(
10355            'type' => 'integer',
10356            'length' => 4,
10357            'notnull' => true
10358        ),
10359    'create_date' => array(
10360      'type' => 'date',
10361      'notnull' => false
10362    ),
10363    'last_update' => array(
10364      'type' => 'date',
10365      'notnull' => false
10366    ),
10367    'owner' => array(
10368      'type' => 'integer',
10369      'length' => 4,
10370      'notnull' => true
10371    ),
10372    );
10373
10374    $ilDB->createTable("il_dcl_record", $fields);
10375    $ilDB->addPrimaryKey("il_dcl_record", array("id"));
10376    $ilDB->createSequence("il_dcl_record");
10377?>
10378<#3606>
10379<?php
10380    $fields = array(
10381        'id' => array(
10382            'type' => 'integer',
10383            'length' => 4,
10384            'notnull' => true
10385        ),
10386        'record_id' => array(
10387            'type' => 'integer',
10388            'length' => 4,
10389            'notnull' => true
10390        ),
10391        'field_id' => array(
10392        'type' => 'integer',
10393        'length' => 4,
10394        'notnull' => true
10395        ),
10396    );
10397
10398    $ilDB->createTable("il_dcl_record_field", $fields);
10399    $ilDB->addPrimaryKey("il_dcl_record_field", array("id"));
10400    $ilDB->createSequence("il_dcl_record_field");
10401?>
10402<#3607>
10403<?php
10404  $fields = array(
10405  'id' => array(
10406      'type' => 'integer',
10407      'length' => 4,
10408      'notnull' => true
10409    ),
10410    'record_field_id' => array(
10411      'type' => 'integer',
10412      'length' => 4,
10413      'notnull' => true
10414    ),
10415    'value' => array(
10416      'type' => 'text',
10417      'length' => 4000,
10418      'notnull' => false
10419    ),
10420  );
10421  $ilDB->createTable("il_dcl_stloc1_value", $fields);
10422  $ilDB->addPrimaryKey("il_dcl_stloc1_value", array("id"));
10423  $ilDB->createSequence("il_dcl_stloc1_value");
10424?>
10425<#3608>
10426<?php
10427  $fields = array(
10428    'id' => array(
10429      'type' => 'integer',
10430      'length' => 4,
10431      'notnull' => true
10432    ),
10433    'record_field_id' => array(
10434      'type' => 'integer',
10435      'length' => 4,
10436      'notnull' => true
10437    ),
10438    'value' => array(
10439      'type' => 'integer',
10440      'length' => 4,
10441      'notnull' => false
10442    ),
10443  );
10444  $ilDB->createTable("il_dcl_stloc2_value", $fields);
10445  $ilDB->addPrimaryKey("il_dcl_stloc2_value", array("id"));
10446  $ilDB->createSequence("il_dcl_stloc2_value");
10447?>
10448<#3609>
10449<?php
10450  $fields = array(
10451    'id' => array(
10452      'type' => 'integer',
10453      'length' => 4,
10454      'notnull' => true
10455    ),
10456    'record_field_id' => array(
10457      'type' => 'integer',
10458      'length' => 4,
10459      'notnull' => true
10460    ),
10461    'value' => array(
10462      'type' => 'timestamp',
10463      'notnull' => true
10464    ),
10465  );
10466  $ilDB->createTable("il_dcl_stloc3_value", $fields);
10467  $ilDB->addPrimaryKey("il_dcl_stloc3_value", array("id"));
10468  $ilDB->createSequence("il_dcl_stloc3_value");
10469?>
10470<#3610>
10471<?php
10472$ilDB->manipulate("INSERT INTO il_dcl_datatype_prop " .
10473            " (id, title, datatype_id, inputformat) VALUES (" .
10474            $ilDB->quote(1, "integer") . ", " . $ilDB->quote("length", "text") . ", " . $ilDB->quote(2, "integer") . ", " . $ilDB->quote(1, "integer") .
10475            ")");
10476
10477$ilDB->manipulate("INSERT INTO il_dcl_datatype_prop " .
10478            " (id, title, datatype_id, inputformat) VALUES (" .
10479            $ilDB->quote(2, "integer") . ", " . $ilDB->quote("regex", "text") . ", " . $ilDB->quote(2, "integer") . ", " . $ilDB->quote(2, "integer") .
10480            ")");
10481
10482$ilDB->manipulate("INSERT INTO il_dcl_datatype_prop " .
10483            " (id, title, datatype_id, inputformat) VALUES (" .
10484            $ilDB->quote(3, "integer") . ", " . $ilDB->quote("table_id", "text") . ", " . $ilDB->quote(3, "integer") . ", " . $ilDB->quote(1, "integer") .
10485            ")");
10486?>
10487<#3611>
10488<?php
10489    $ilCtrlStructureReader->getStructure();
10490?>
10491<#3612>
10492<?php
10493    if (!$ilDB->tableColumnExists('il_rating', 'category_id')) {
10494        $ilDB->addTableColumn('il_rating', 'category_id', array(
10495            'type' => 'integer',
10496            'length' => 4,
10497            'notnull' => true,
10498            'default' => 0
10499        ));
10500    }
10501?>
10502<#3613>
10503<?php
10504  $fields = array(
10505    'id' => array(
10506      'type' => 'integer',
10507      'length' => 4,
10508      'notnull' => true
10509    ),
10510    'parent_id' => array(
10511      'type' => 'integer',
10512      'length' => 4,
10513      'notnull' => true
10514    ),
10515    'title' => array(
10516      'type' => 'text',
10517      'length' => 100
10518    ),
10519    'description' => array(
10520      'type' => 'text',
10521      'length' => 1000
10522    ),
10523    'pos' => array(
10524      'type' => 'integer',
10525      'length' => 2,
10526      'notnull' => true
10527    )
10528  );
10529  $ilDB->createTable("il_rating_cat", $fields);
10530  $ilDB->addPrimaryKey("il_rating_cat", array("id"));
10531  $ilDB->createSequence("il_rating_cat");
10532?>
10533<#3614>
10534<?php
10535    $ilCtrlStructureReader->getStructure();
10536?>
10537<#3615>
10538<?php
10539    $ilDB->dropPrimaryKey("il_rating");
10540    $ilDB->addPrimaryKey("il_rating", array("obj_id", "obj_type", "sub_obj_id", "sub_obj_type", "user_id", "category_id"));
10541?>
10542<#3616>
10543<?php
10544    if (!$ilDB->tableColumnExists('il_wiki_data', 'rating_side')) {
10545        $ilDB->addTableColumn('il_wiki_data', 'rating_side', array(
10546            'type' => 'integer',
10547            'length' => 1,
10548            'notnull' => true,
10549            'default' => 0
10550        ));
10551    }
10552    if (!$ilDB->tableColumnExists('il_wiki_data', 'rating_new')) {
10553        $ilDB->addTableColumn('il_wiki_data', 'rating_new', array(
10554            'type' => 'integer',
10555            'length' => 1,
10556            'notnull' => true,
10557            'default' => 0
10558        ));
10559    }
10560    if (!$ilDB->tableColumnExists('il_wiki_data', 'rating_ext')) {
10561        $ilDB->addTableColumn('il_wiki_data', 'rating_ext', array(
10562            'type' => 'integer',
10563            'length' => 1,
10564            'notnull' => true,
10565            'default' => 0
10566        ));
10567    }
10568?>
10569<#3617>
10570<?php
10571    if (!$ilDB->tableColumnExists('il_wiki_page', 'rating')) {
10572        $ilDB->addTableColumn('il_wiki_page', 'rating', array(
10573            'type' => 'integer',
10574            'length' => 1,
10575            'notnull' => true,
10576            'default' => 0
10577        ));
10578    }
10579?>
10580<#3618>
10581<?php
10582
10583    $wiki_ids = array();
10584    $set = $ilDB->query("SELECT id FROM il_wiki_data" .
10585        " WHERE rating = " . $ilDB->quote(1, "integer"));
10586    while ($row = $ilDB->fetchAssoc($set)) {
10587        $wiki_ids[] = $row["id"];
10588    }
10589
10590    if ($wiki_ids) {
10591        $ilDB->manipulate("UPDATE il_wiki_data" .
10592            " SET rating_new = " . $ilDB->quote(1, "integer") .
10593            " WHERE " . $ilDB->in("id", $wiki_ids, "", "integer"));
10594
10595        $ilDB->manipulate("UPDATE il_wiki_page" .
10596            " SET rating = " . $ilDB->quote(1, "integer") .
10597            " WHERE " . $ilDB->in("wiki_id", $wiki_ids, "", "integer"));
10598    }
10599?>
10600<#3619>
10601<?php
10602    /* #10745
10603    $ts_now = time();
10604    $ts_latest = mktime(23,55,00,date('n',time()),date('j',time()),date('Y',time()));
10605
10606    // all limited course objects with ref_id and parent ref_id
10607    $query = "SELECT t.child,t.parent,c.starting_time,c.ending_time".
10608        " FROM tst_tests c".
10609        " JOIN object_reference r ON (r.obj_id = c.obj_fi)".
10610        " JOIN tree t ON (r.ref_id = t.child)".
10611        " LEFT JOIN crs_items i ON (i.obj_id = r.ref_id)".
10612        " WHERE i.obj_id IS NULL";
10613    $set = $ilDB->query($query);
10614    while($row = $ilDB->fetchAssoc($set))
10615    {
10616        if($row["starting_time"] || $row["ending_time"])
10617        {
10618            $ts_start = time();
10619            if(preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $row["starting_time"], $d_parts))
10620            {
10621                $ts_start = mktime(
10622                    isset($d_parts[4]) ? $d_parts[4] : 0,
10623                    isset($d_parts[5]) ? $d_parts[5] : 0,
10624                    isset($d_parts[6]) ? $d_parts[6] : 0,
10625                    $d_parts[2],
10626                    $d_parts[3],
10627                    $d_parts[1]);
10628            }
10629            $ts_end = mktime(0, 0, 1, 1, 1, date("Y")+3);
10630            if(preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $row["ending_time"], $d_parts))
10631            {
10632                $ts_end = mktime(
10633                    isset($d_parts[4]) ? $d_parts[4] : 0,
10634                    isset($d_parts[5]) ? $d_parts[5] : 0,
10635                    isset($d_parts[6]) ? $d_parts[6] : 0,
10636                    $d_parts[2],
10637                    $d_parts[3],
10638                    $d_parts[1]);
10639            }
10640
10641            $query = "INSERT INTO crs_items (parent_id,obj_id,timing_type,timing_start,".
10642                "timing_end,suggestion_start,suggestion_end,changeable,earliest_start,".
10643                "latest_end,visible,position) VALUES (".
10644                $ilDB->quote($row["parent"],'integer').",".
10645                $ilDB->quote($row["child"],'integer').",".
10646                $ilDB->quote(0,'integer').",".
10647                $ilDB->quote($ts_start,'integer').",".
10648                $ilDB->quote($ts_end,'integer').",".
10649                $ilDB->quote($ts_now,'integer').",".
10650                $ilDB->quote($ts_now,'integer').",".
10651                $ilDB->quote(0,'integer').",".
10652                $ilDB->quote($ts_now,'integer').", ".
10653                $ilDB->quote($ts_latest,'integer').", ".
10654                $ilDB->quote(1,'integer').", ".
10655                $ilDB->quote(0,'integer').")";
10656            $ilDB->manipulate($query);
10657        }
10658    }
10659    */
10660?>
10661<#3620>
10662<?php
10663    /* #10745
10664    if( $ilDB->tableColumnExists("tst_tests", "starting_time") )
10665    {
10666        $ilDB->dropTableColumn("tst_tests", "starting_time");
10667    }
10668    if( $ilDB->tableColumnExists("tst_tests", "ending_time") )
10669    {
10670        $ilDB->dropTableColumn("tst_tests", "ending_time");
10671    }
10672    */
10673?>
10674<#3621>
10675<?php
10676
10677$ilDB->manipulate("INSERT INTO il_dcl_datatype (id, title, ildb_type, storage_location) " .
10678        " VALUES (" .
10679        $ilDB->quote(6, "integer") . ", " . $ilDB->quote("file", "text") . ", " . $ilDB->quote("integer", "text") . ", " . $ilDB->quote(2, "text") .
10680        ")");
10681
10682?>
10683<#3622>
10684<?php
10685if (!$ilDB->tableColumnExists('media_item', 'highlight_mode')) {
10686    $ilDB->addTableColumn("media_item", "highlight_mode", array(
10687        "type" => "text",
10688        "notnull" => false,
10689        "length" => 8,
10690        "fixed" => false));
10691}
10692?>
10693<#3623>
10694<?php
10695if (!$ilDB->tableColumnExists('media_item', 'highlight_class')) {
10696    $ilDB->addTableColumn("media_item", "highlight_class", array(
10697        "type" => "text",
10698        "notnull" => false,
10699        "length" => 8,
10700        "fixed" => false));
10701}
10702?>
10703<#3624>
10704<?php
10705
10706    if (!$ilDB->tableColumnExists('booking_object', 'pool_id')) {
10707        $ilDB->addTableColumn("booking_object", "pool_id", array(
10708            "type" => "integer",
10709            "notnull" => false,
10710            "length" => 4,
10711            "default" => 0));
10712    }
10713
10714    $types = $ilDB->query("SELECT * FROM booking_type");
10715    while ($row = $ilDB->fetchAssoc($types)) {
10716        $sql = "UPDATE booking_object SET" .
10717            " pool_id = " . $ilDB->quote($row["pool_id"], "integer");
10718        if ($row["schedule_id"]) {
10719            $sql .= ",schedule_id = " . $ilDB->quote($row["schedule_id"], "integer");
10720        }
10721        $sql .= ", title = CONCAT(title, " . $ilDB->quote(" (" . $row["title"] . ")", "text") . ")" .
10722            " WHERE type_id = " . $ilDB->quote($row["booking_type_id"], "integer");
10723
10724        $ilDB->manipulate($sql);
10725    }
10726
10727    if ($ilDB->tableColumnExists("booking_object", "type_id")) {
10728        $ilDB->dropTableColumn("booking_object", "type_id");
10729        $ilDB->dropTable("booking_type");
10730    }
10731
10732?>
10733<#3625>
10734<?php
10735
10736    if (!$ilDB->tableColumnExists('booking_object', 'description')) {
10737        $ilDB->addTableColumn("booking_object", "description", array(
10738            "type" => "text",
10739            "notnull" => false,
10740            "length" => 1000,
10741            "fixed" => false));
10742    }
10743    if (!$ilDB->tableColumnExists('booking_object', 'nr_items')) {
10744        $ilDB->addTableColumn("booking_object", "nr_items", array(
10745            "type" => "integer",
10746            "notnull" => true,
10747            "length" => 2,
10748            "default" => 1));
10749    }
10750
10751?>
10752<#3626>
10753<?php
10754
10755    if (!$ilDB->tableColumnExists('booking_settings', 'schedule_type')) {
10756        $ilDB->addTableColumn("booking_settings", "schedule_type", array(
10757            "type" => "integer",
10758            "notnull" => true,
10759            "length" => 1,
10760            "default" => 1));
10761    }
10762
10763?>
10764<#3627>
10765<?php
10766    $ilCtrlStructureReader->getStructure();
10767?>
10768<#3628>
10769<?php
10770
10771include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
10772
10773$poll_type_id = ilDBUpdateNewObjectType::addNewType('poll', 'Poll Object');
10774
10775$rbac_ops = array(
10776    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
10777    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
10778    ilDBUpdateNewObjectType::RBAC_OP_READ,
10779    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
10780    ilDBUpdateNewObjectType::RBAC_OP_DELETE,
10781    ilDBUpdateNewObjectType::RBAC_OP_COPY
10782);
10783ilDBUpdateNewObjectType::addRBACOperations($poll_type_id, $rbac_ops);
10784
10785$parent_types = array('root', 'cat', 'crs', 'fold', 'grp');
10786ilDBUpdateNewObjectType::addRBACCreate('create_poll', 'Create Poll', $parent_types);
10787
10788// see 3675
10789// ilDBUpdateNewObjectType::addCustomRBACOperation($poll_type_id, 'add_entry');
10790
10791?>
10792<#3629>
10793<?php
10794    $ilCtrlStructureReader->getStructure();
10795?>
10796<#3630>
10797<?php
10798  $fields = array(
10799    'id' => array(
10800      'type' => 'integer',
10801      'length' => 4,
10802      'notnull' => true
10803    ),
10804    'question' => array(
10805      'type' => 'text',
10806      'length' => 1000
10807    ),
10808    'image' => array(
10809      'type' => 'text',
10810      'length' => 1000
10811    ),
10812    'online_status' => array(
10813      'type' => 'integer',
10814      'length' => 1,
10815      'notnull' => true,
10816      'default' => 0
10817    ),
10818    'view_results' => array(
10819      'type' => 'integer',
10820      'length' => 1,
10821      'notnull' => true,
10822      'default' => 3
10823    )
10824  );
10825  $ilDB->createTable("il_poll", $fields);
10826  $ilDB->addPrimaryKey("il_poll", array("id"));
10827?>
10828<#3631>
10829<?php
10830  $fields = array(
10831    'id' => array(
10832      'type' => 'integer',
10833      'length' => 4,
10834      'notnull' => true
10835    ),
10836    'poll_id' => array(
10837      'type' => 'integer',
10838      'length' => 4,
10839      'notnull' => true
10840    ),
10841    'answer' => array(
10842      'type' => 'text',
10843      'length' => 1000
10844    ),
10845    'pos' => array(
10846      'type' => 'integer',
10847      'length' => 2,
10848      'notnull' => true
10849    )
10850  );
10851  $ilDB->createTable("il_poll_answer", $fields);
10852  $ilDB->addPrimaryKey("il_poll_answer", array("id"));
10853  $ilDB->createSequence("il_poll_answer");
10854?>
10855<#3632>
10856<?php
10857  $fields = array(
10858    'user_id' => array(
10859      'type' => 'integer',
10860      'length' => 4,
10861      'notnull' => true
10862    ),
10863    'poll_id' => array(
10864      'type' => 'integer',
10865      'length' => 4,
10866      'notnull' => true
10867    ),
10868    'answer_id' => array(
10869      'type' => 'integer',
10870      'length' => 4,
10871      'notnull' => true
10872    )
10873  );
10874  $ilDB->createTable("il_poll_vote", $fields);
10875  $ilDB->addPrimaryKey("il_poll_vote", array("user_id", "poll_id"));
10876?>
10877<#3633>
10878<?php
10879    $ilCtrlStructureReader->getStructure();
10880?>
10881<#3634>
10882<?php
10883$ilDB->addIndex("bookmark_tree", array("child", "tree"), "i3");
10884?>
10885<#3635>
10886<?php
10887    $ilDB->modifyTableColumn(
10888    'il_dcl_record',
10889    'create_date',
10890    array("type" => "timestamp")
10891);
10892?>
10893<#3636>
10894<?php
10895    $ilDB->modifyTableColumn(
10896    'il_dcl_record',
10897    'last_update',
10898    array("type" => "timestamp")
10899);
10900?>
10901<#3637>
10902<?php
10903    $ilCtrlStructureReader->getStructure();
10904?>
10905<#3638>
10906<?php
10907    $fields = array(
10908    'id' => array(
10909        'type' => 'integer',
10910        'length' => 4,
10911        'notnull' => true
10912    ),
10913    'view_id' => array(
10914        'type' => 'integer',
10915        'length' => 4,
10916        'notnull' => true
10917    ),
10918    'field' => array(
10919        'type' => 'text',
10920        'length' => 255,
10921        'notnull' => true
10922    ),
10923    'field_order' => array(
10924        'type' => 'integer',
10925        'length' => 4,
10926        'notnull' => true
10927    ),
10928  );
10929  $ilDB->createTable("il_dcl_viewdefinition", $fields);
10930  $ilDB->addPrimaryKey("il_dcl_viewdefinition", array("id"));
10931  $ilDB->createSequence("il_dcl_viewdefinition");
10932?>
10933<#3639>
10934<?php
10935    $ilCtrlStructureReader->getStructure();
10936?>
10937<#3640>
10938<?php
10939    $fields = array(
10940    'id' => array(
10941        'type' => 'integer',
10942        'length' => 4,
10943        'notnull' => true
10944    ),
10945    'ass_id' => array(
10946        'type' => 'integer',
10947        'length' => 4,
10948        'notnull' => true
10949    ),
10950    'user_id' => array(
10951        'type' => 'integer',
10952        'length' => 4,
10953        'notnull' => true
10954    )
10955  );
10956  $ilDB->createTable("il_exc_team", $fields);
10957  $ilDB->addPrimaryKey("il_exc_team", array("ass_id", "user_id"));
10958  $ilDB->createSequence("il_exc_team");
10959?>
10960<#3641>
10961<?php
10962    $fields = array(
10963    'team_id' => array(
10964        'type' => 'integer',
10965        'length' => 4,
10966        'notnull' => true
10967    ),
10968    'user_id' => array(
10969        'type' => 'integer',
10970        'length' => 4,
10971        'notnull' => true
10972    ),
10973    'details' => array(
10974        'type' => 'text',
10975        'length' => 500,
10976        'notnull' => false
10977    ),
10978    'action' => array(
10979        'type' => 'integer',
10980        'length' => 1,
10981        'notnull' => true
10982    ),
10983    'tstamp' => array(
10984        'type' => 'integer',
10985        'length' => 4,
10986        'notnull' => true
10987    ),
10988  );
10989  $ilDB->createTable("il_exc_team_log", $fields);
10990?>
10991<#3642>
10992<?php
10993// Fetch orphaned entries of table "mail_attachment"
10994$res = $ilDB->query(
10995    '
10996	SELECT mattorphaned.mail_id, mattorphaned.path
10997	FROM mail_attachment mattorphaned
10998	WHERE mattorphaned.mail_id NOT IN (
10999		SELECT matt.mail_id
11000		FROM mail_attachment matt
11001		INNER JOIN mail
11002			ON mail.mail_id = matt.mail_id
11003		INNER JOIN usr_data
11004			ON usr_data.usr_id = mail.user_id
11005	)'
11006);
11007
11008// Helper array to collect paths of orphaned entries
11009$paths = array();
11010
11011$stmt = $ilDB->prepareManip('DELETE FROM mail_attachment WHERE mail_id = ?', array('integer'));
11012// Delete the entries and store the path to check if it is shared with residual entries in the next step
11013while ($row = $ilDB->fetchAssoc($res)) {
11014    $ilDB->execute($stmt, array($row['mail_id']));
11015
11016    // Save path in key to prevent unnecessary lookups for duplicates
11017    isset($paths[$row['path']]) ? $paths[$row['path']]++ : $paths[$row['path']] = 0;
11018}
11019$ilDB->free($stmt);
11020
11021/***************************/
11022
11023$stmt = $ilDB->prepare('SELECT COUNT(mail_id) cnt FROM mail_attachment WHERE path = ?', array('text'));
11024foreach ($paths as $path => $number) {
11025    $res = $ilDB->execute($stmt, array($path));
11026    $row = $ilDB->fetchAssoc($res);
11027
11028    // Check if the path is used by residual entries
11029    if (isset($row['cnt']) && $row['cnt'] == 0) {
11030        try {
11031            // Delete the directory recursively
11032            $basedirectory = CLIENT_DATA_DIR . DIRECTORY_SEPARATOR . 'mail' . DIRECTORY_SEPARATOR . $path;
11033
11034            $iter = new RecursiveIteratorIterator(
11035                new RecursiveDirectoryIterator($basedirectory),
11036                RecursiveIteratorIterator::CHILD_FIRST
11037            );
11038            foreach ($iter as $file) {
11039                /**
11040                 * @var $file SplFileInfo
11041                 */
11042                $filepath = $file->getPathname();
11043                $bool = false;
11044
11045                if ($file->isDir()) {
11046                    $bool = @rmdir($file->getPathname());
11047                } else {
11048                    $bool = @unlink($file->getPathname());
11049                }
11050
11051                if ($bool) {
11052                    $GLOBALS['ilLog']->write('Database Update: Deletion of file/subdirectory ' . $filepath . ' finished.');
11053                } else {
11054                    $GLOBALS['ilLog']->write('Database Update: Deletion of file/subdirectory ' . $filepath . ' failed.');
11055                }
11056            }
11057
11058            // Finally delete the base directory
11059            $bool = @rmdir($basedirectory);
11060            if ($bool) {
11061                $GLOBALS['ilLog']->write('Database Update: Deletion of base directory ' . $basedirectory . ' finished.');
11062            } else {
11063                $GLOBALS['ilLog']->write('Database Update: Deletion of base directory ' . $basedirectory . ' failed.');
11064            }
11065        } catch (Exception $e) {
11066        }
11067    }
11068}
11069$ilDB->free($stmt);
11070?>
11071<#3643>
11072<?php
11073// Delete all mails without an existing owner
11074if ($ilDB->getDBType() == 'mysql' || $ilDB->getDBType() == 'innodb') {
11075    $ilDB->manipulate('
11076		DELETE m1
11077		FROM mail m1
11078		INNER JOIN (
11079			SELECT mail.mail_id
11080			FROM mail
11081			LEFT JOIN usr_data
11082				ON usr_data.usr_id = mail.user_id
11083			WHERE usr_data.usr_id IS NULL
11084		) m2
11085		ON m2.mail_id = m1.mail_id');
11086} else {
11087    // Oracle and Postgres
11088    $ilDB->manipulate('
11089		DELETE FROM mail
11090		WHERE mail.mail_id IN (
11091			SELECT mail.mail_id
11092			FROM mail
11093			LEFT JOIN usr_data
11094				ON usr_data.usr_id = mail.user_id
11095			WHERE usr_data.usr_id IS NULL
11096		)');
11097}
11098?>
11099<#3644>
11100<?php
11101$stmt = $ilDB->prepare('SELECT COUNT(mail_id) cnt FROM mail_attachment WHERE ' . $ilDB->like('path', 'text', '?'), array('text'));
11102try {
11103    $iter = new RegexIterator(
11104        new RecursiveIteratorIterator(
11105            new RecursiveDirectoryIterator(CLIENT_DATA_DIR . DIRECTORY_SEPARATOR . 'mail'),
11106            RecursiveIteratorIterator::SELF_FIRST
11107        ),
11108        '/mail_\d+_\d+$/'
11109    );
11110    foreach ($iter as $file) {
11111        /**
11112         * @var $file SplFileInfo
11113         */
11114        if ($file->isDir()) {
11115            $path = $file->getPathname();
11116
11117            $res = $ilDB->execute($stmt, array('%/' . $file->getFilename()));
11118
11119            $row = $ilDB->fetchAssoc($res);
11120            if (isset($row['cnt']) && $row['cnt'] == 0) {
11121                $basedirectory = $file->getPathname();
11122
11123                $GLOBALS['ilLog']->write('Database Update: Directory ' . $basedirectory . ' not in use anymore. Processing deletion ...');
11124                try {
11125                    $delete_iter = new RecursiveIteratorIterator(
11126                        new RecursiveDirectoryIterator($basedirectory),
11127                        RecursiveIteratorIterator::CHILD_FIRST
11128                    );
11129                    foreach ($delete_iter as $file_to_delete) {
11130                        /**
11131                         * @var $file_to_delete SplFileInfo
11132                         */
11133                        $filepath = $file_to_delete->getPathname();
11134                        $bool = false;
11135
11136                        if ($file_to_delete->isDir()) {
11137                            $bool = @rmdir($file_to_delete->getPathname());
11138                        } else {
11139                            $bool = @unlink($file_to_delete->getPathname());
11140                        }
11141
11142                        if ($bool) {
11143                            $GLOBALS['ilLog']->write('Database Update: Deletion of file/subdirectory ' . $filepath . ' finished.');
11144                        } else {
11145                            $GLOBALS['ilLog']->write('Database Update: Deletion of file/subdirectory ' . $filepath . ' failed.');
11146                        }
11147                    }
11148
11149                    $bool = @rmdir($basedirectory);
11150                    if ($bool) {
11151                        $GLOBALS['ilLog']->write('Database Update: Deletion of base directory ' . $basedirectory . ' finished.');
11152                    } else {
11153                        $GLOBALS['ilLog']->write('Database Update: Deletion of base directory ' . $basedirectory . ' failed.');
11154                    }
11155                } catch (Exception $e) {
11156                }
11157            }
11158        }
11159    }
11160} catch (Exception $e) {
11161}
11162$ilDB->free($stmt);
11163?>
11164<#3645>
11165<?php
11166
11167    if (!$ilDB->tableColumnExists('qpl_qst_mc', 'feedback_setting')) {
11168        $ilDB->addTableColumn('qpl_qst_mc', 'feedback_setting', array(
11169            "type" => "integer",
11170            "notnull" => true,
11171            "length" => 1,
11172            "default" => 1));
11173    }
11174?>
11175<#3646>
11176<?php
11177    $ilCtrlStructureReader->getStructure();
11178?>
11179<#3647>
11180<?php
11181    $ilCtrlStructureReader->getStructure();
11182?>
11183<#3648>
11184<?php
11185    $ilCtrlStructureReader->getStructure();
11186?>
11187<#3649>
11188<?php
11189
11190    if (!$ilDB->tableColumnExists('container_reference', 'title_type')) {
11191        $ilDB->addTableColumn('container_reference', 'title_type', array(
11192            "type" => "integer",
11193            "notnull" => true,
11194            "length" => 1,
11195            "default" => 1));
11196    }
11197?>
11198<#3650>
11199<?php
11200
11201    if (!$ilDB->tableExists('qpl_fb_cloze')) {
11202        $fields = array(
11203            'feedback_id' => array(
11204                'type' => 'integer',
11205                'length' => 4,
11206                'notnull' => true
11207            ),
11208            'question_fi' => array(
11209                'type' => 'integer',
11210                'length' => 4,
11211                'notnull' => true
11212            ),
11213            'answer' => array(
11214                'type' => 'integer',
11215                'length' => 4,
11216                'notnull' => true
11217            ),
11218            'feedback' => array(
11219                'type' => 'text',
11220                'length' => 4000,
11221                'notnull' => false
11222            ),
11223            'tstamp' => array(
11224                'type' => 'integer',
11225                'length' => 4,
11226                'notnull' => true
11227            )
11228        );
11229
11230        $ilDB->createTable('qpl_fb_cloze', $fields);
11231        $ilDB->addIndex('qpl_fb_cloze', array('question_fi'), 'i1');
11232        $ilDB->createSequence('qpl_fb_cloze');
11233    }
11234?>
11235<#3651>
11236<?php
11237    $ilCtrlStructureReader->getStructure();
11238?>
11239<#3652>
11240<?php
11241
11242    if (!$ilDB->tableExists('qpl_fb_errortext')) {
11243        $fields = array(
11244            'feedback_id' => array(
11245                'type' => 'integer',
11246                'length' => 4,
11247                'notnull' => true
11248            ),
11249            'question_fi' => array(
11250                'type' => 'integer',
11251                'length' => 4,
11252                'notnull' => true
11253            ),
11254            'answer' => array(
11255                'type' => 'integer',
11256                'length' => 4,
11257                'notnull' => true
11258            ),
11259            'feedback' => array(
11260                'type' => 'text',
11261                'length' => 4000,
11262                'notnull' => false
11263            ),
11264            'tstamp' => array(
11265                'type' => 'integer',
11266                'length' => 4,
11267                'notnull' => true
11268            )
11269        );
11270
11271        $ilDB->createTable('qpl_fb_errortext', $fields);
11272        $ilDB->addIndex('qpl_fb_errortext', array('question_fi'), 'i1');
11273        $ilDB->createSequence('qpl_fb_errortext');
11274    }
11275?>
11276<#3653>
11277<?php
11278
11279    if (!$ilDB->tableExists('qpl_fb_matching')) {
11280        $fields = array(
11281            'feedback_id' => array(
11282                'type' => 'integer',
11283                'length' => 4,
11284                'notnull' => true
11285            ),
11286            'question_fi' => array(
11287                'type' => 'integer',
11288                'length' => 4,
11289                'notnull' => true
11290            ),
11291            'answer' => array(
11292                'type' => 'integer',
11293                'length' => 4,
11294                'notnull' => true
11295            ),
11296            'feedback' => array(
11297                'type' => 'text',
11298                'length' => 4000,
11299                'notnull' => false
11300            ),
11301            'tstamp' => array(
11302                'type' => 'integer',
11303                'length' => 4,
11304                'notnull' => true
11305            )
11306        );
11307
11308        $ilDB->createTable('qpl_fb_matching', $fields);
11309        $ilDB->addIndex('qpl_fb_matching', array('question_fi'), 'i1');
11310        $ilDB->createSequence('qpl_fb_matching');
11311    }
11312?>
11313<#3654>
11314<?php
11315    $ilCtrlStructureReader->getStructure();
11316?>
11317<#3655>
11318<?php
11319
11320    if (!$ilDB->tableColumnExists('cal_categories', 'loc_type')) {
11321        $ilDB->addTableColumn('cal_categories', 'loc_type', array(
11322            "type" => "integer",
11323            "notnull" => true,
11324            "length" => 1,
11325            "default" => 1));
11326    }
11327    if (!$ilDB->tableColumnExists('cal_categories', 'remote_url')) {
11328        $ilDB->addTableColumn('cal_categories', 'remote_url', array(
11329            "type" => "text",
11330            "notnull" => false,
11331            "length" => 500
11332        ));
11333    }
11334    if (!$ilDB->tableColumnExists('cal_categories', 'remote_user')) {
11335        $ilDB->addTableColumn('cal_categories', 'remote_user', array(
11336            "type" => "text",
11337            "notnull" => false,
11338            "length" => 50
11339        ));
11340    }
11341    if (!$ilDB->tableColumnExists('cal_categories', 'remote_pass')) {
11342        $ilDB->addTableColumn('cal_categories', 'remote_pass', array(
11343            "type" => "text",
11344            "notnull" => false,
11345            "length" => 50
11346        ));
11347    }
11348?>
11349
11350<#3656>
11351<?php
11352
11353if (!$ilDB->tableExists('syst_style_cat')) {
11354    $fields = array(
11355        'skin_id' => array(
11356            'type' => 'text',
11357            'length' => 100,
11358            'fixed' => false,
11359            'notnull' => true
11360        ),
11361        'style_id' => array(
11362            'type' => 'text',
11363            'length' => 100,
11364            'fixed' => false,
11365            'notnull' => true
11366        ),
11367        'category_ref_id' => array(
11368            'type' => 'integer',
11369            'length' => 1,
11370        )
11371    );
11372    $ilDB->createTable('syst_style_cat', $fields);
11373    $ilDB->addPrimaryKey('syst_style_cat', array('skin_id', 'style_id', 'category_ref_id'));
11374}
11375?>
11376<#3657>
11377<?php
11378$ilDB->dropTable("syst_style_cat");
11379$fields = array(
11380    'skin_id' => array(
11381        'type' => 'text',
11382        'length' => 50,
11383        'fixed' => false,
11384        'notnull' => true
11385    ),
11386    'style_id' => array(
11387        'type' => 'text',
11388        'length' => 50,
11389        'fixed' => false,
11390        'notnull' => true
11391    ),
11392    'substyle' => array(
11393        'type' => 'text',
11394        'length' => 50,
11395        'fixed' => false,
11396        'notnull' => true
11397    ),
11398    'category_ref_id' => array(
11399        'type' => 'integer',
11400        'length' => 1,
11401    )
11402);
11403
11404$ilDB->createTable('syst_style_cat', $fields);
11405$ilDB->addPrimaryKey('syst_style_cat', array('skin_id', 'style_id', 'substyle', 'category_ref_id'));
11406
11407?>
11408<#3658>
11409<?php
11410
11411    $ilDB->manipulate("DELETE FROM syst_style_cat");
11412
11413    $ilDB->dropPrimaryKey('syst_style_cat');
11414    $ilDB->dropTableColumn('syst_style_cat', 'category_ref_id');
11415
11416    $ilDB->addTableColumn("syst_style_cat", "category_ref_id", array(
11417        'type' => 'integer',
11418        'length' => 4,
11419        'notnull' => true,
11420        'default' => 0
11421        ));
11422
11423    $ilDB->addPrimaryKey('syst_style_cat', array('skin_id', 'style_id', 'substyle', 'category_ref_id'));
11424?>
11425<#3659>
11426<?php
11427    include_once("./Services/Migration/DBUpdate_3136/classes/class.ilDBUpdate3136.php");
11428    ilDBUpdate3136::addStyleClass(
11429        "AdvancedKnowledge",
11430        "section",
11431        "div",
11432        array("margin-bottom" => "20px",
11433                      "margin-top" => "20px",
11434                      "background-color" => "#FFF9EF",
11435                      "border-color" => "#FFDDA5",
11436                      "border-style" => "solid",
11437                      "border-width" => "1px",
11438                      "padding-bottom" => "10px",
11439                      "padding-top" => "10px",
11440                      "padding-right" => "20px",
11441                      "padding-left" => "20px",
11442                      "background-image" => "advknow.png",
11443                      "background-repeat" => "no-repeat",
11444                      "background-position" => "right top",
11445                      )
11446    );
11447?>
11448<#3660>
11449<?php
11450        // check, whether core style class exists
11451        $sets = $ilDB->query("SELECT * FROM object_data WHERE type = 'sty'");
11452
11453        while ($rec = $ilDB->fetchAssoc($sets)) {
11454            // now check, whether some core image files are missing
11455            ilUtil::makeDir(CLIENT_WEB_DIR . "/sty");
11456            ilUtil::makeDir(CLIENT_WEB_DIR . "/sty/sty_" . $rec["obj_id"]);
11457            $tdir = CLIENT_WEB_DIR . "/sty/sty_" . $rec["obj_id"] . "/images";
11458            ilUtil::makeDir($tdir);
11459            $sfile = "./Services/Style/basic_style/images/advknow.png";
11460            $cim = "advknow.png";
11461            if (!is_file($tdir . "/" . $cim) && is_file($sfile)) {
11462                copy($sfile, $tdir . "/" . $cim);
11463            }
11464        }
11465
11466?>
11467<#3661>
11468<?php
11469if (!$ilDB->tableExists('il_certificate')) {
11470    $fields = array(
11471        'obj_id' => array(
11472            'type' => 'integer',
11473            'length' => 4,
11474            'notnull' => true
11475        )
11476    );
11477
11478    $ilDB->createTable('il_certificate', $fields);
11479    $ilDB->addPrimaryKey('il_certificate', array('obj_id'));
11480}
11481?>
11482<#3662>
11483<?php
11484
11485$cdirs = array(
11486    CLIENT_WEB_DIR . "/course/certificates/",
11487    CLIENT_WEB_DIR . "/exercise/certificates/",
11488    CLIENT_WEB_DIR . "/certificates/scorm/",
11489    CLIENT_WEB_DIR . "/certificates/skill/",
11490    CLIENT_WEB_DIR . "/assessment/certificates/"
11491);
11492$coids = array();
11493foreach ($cdirs as $cdir) {
11494    // #10277
11495    if (is_dir($cdir)) {
11496        foreach (glob($cdir . "*", GLOB_ONLYDIR) as $codir) {
11497            $coids[] = str_replace($cdir, "", $codir);
11498        }
11499    }
11500}
11501foreach ($coids as $coid) {
11502    $ilDB->insert("il_certificate", array("obj_id" => array("integer", $coid)));
11503}
11504
11505?>
11506<#3663>
11507<?php
11508if (!$ilDB->tableColumnExists('tst_tests', 'specific_feedback')) {
11509    $ilDB->addTableColumn('tst_tests', 'specific_feedback', array(
11510        "type" => "integer",
11511        "notnull" => false,
11512        "length" => 4,
11513        'default' => 0
11514    ));
11515}
11516?>
11517
11518<#3664>
11519<?php
11520
11521    $ilDB->renameTable('crs_members', 'obj_members');
11522?>
11523
11524<#3665>
11525<?php
11526
11527include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
11528$hlps_type_id = ilDBUpdateNewObjectType::addNewType('hlps', 'Help Settings');
11529
11530$obj_id = $ilDB->nextId('object_data');
11531$ilDB->manipulate("INSERT INTO object_data " .
11532    "(obj_id, type, title, description, owner, create_date, last_update) VALUES (" .
11533    $ilDB->quote($obj_id, "integer") . "," .
11534    $ilDB->quote("hlps", "text") . "," .
11535    $ilDB->quote("HelpSettings", "text") . "," .
11536    $ilDB->quote("Help Settings", "text") . "," .
11537    $ilDB->quote(-1, "integer") . "," .
11538    $ilDB->now() . "," .
11539    $ilDB->now() .
11540    ")");
11541
11542$ref_id = $ilDB->nextId('object_reference');
11543$ilDB->manipulate("INSERT INTO object_reference " .
11544    "(obj_id, ref_id) VALUES (" .
11545    $ilDB->quote($obj_id, "integer") . "," .
11546    $ilDB->quote($ref_id, "integer") .
11547    ")");
11548
11549// put in tree
11550$tree = new ilTree(ROOT_FOLDER_ID);
11551$tree->insertNode($ref_id, SYSTEM_FOLDER_ID);
11552
11553
11554$rbac_ops = array(
11555    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
11556    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
11557    ilDBUpdateNewObjectType::RBAC_OP_READ,
11558    ilDBUpdateNewObjectType::RBAC_OP_WRITE
11559);
11560ilDBUpdateNewObjectType::addRBACOperations($hlps_type_id, $rbac_ops);
11561
11562?>
11563<#3666>
11564<?php
11565    $ilCtrlStructureReader->getStructure();
11566?>
11567<#3667>
11568<?php
11569
11570#9350: removing visible permission for side blocks (feed, poll)
11571include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
11572ilDBUpdateNewObjectType::deleteRBACOperation(
11573    'poll',
11574    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE
11575);
11576ilDBUpdateNewObjectType::deleteRBACOperation(
11577    'feed',
11578    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE
11579);
11580
11581?>
11582<#3668>
11583<?php
11584    $fields = array(
11585        'id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0)
11586        );
11587    $ilDB->createTable('help_file', $fields);
11588    $ilDB->addPrimaryKey('help_file', array('id'));
11589    $ilDB->createSequence("help_file");
11590?>
11591<#3669>
11592<?php
11593$ilDB->dropSequence("help_file");
11594$ilDB->dropTable("help_file");
11595?>
11596<#3670>
11597<?php
11598    $fields = array(
11599        'id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
11600        'lm_id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0)
11601        );
11602    $ilDB->createTable('help_module', $fields);
11603    $ilDB->addPrimaryKey('help_module', array('id'));
11604    $ilDB->createSequence("help_module");
11605?>
11606<#3671>
11607<?php
11608$ilDB->addTableColumn("help_tooltip", "lang", array(
11609    "type" => "text",
11610    "notnull" => true,
11611    "length" => 2,
11612    "fixed" => true,
11613    "default" => "de"));
11614?>
11615<#3672>
11616<?php
11617$ilDB->addTableColumn("help_tooltip", "module_id", array(
11618    "type" => "integer",
11619    "notnull" => true,
11620    "length" => 4,
11621    "default" => 0));
11622?>
11623<#3673>
11624<?php
11625$ilDB->addTableColumn("help_map", "module_id", array(
11626    "type" => "integer",
11627    "notnull" => true,
11628    "length" => 4,
11629    "default" => 0));
11630?>
11631<#3674>
11632<?php
11633$ilDB->dropPrimaryKey("help_map");
11634$ilDB->addPrimaryKey('help_map', array('component', 'screen_id', 'screen_sub_id', 'chap', 'perm', 'module_id'));
11635?>
11636<#3675>
11637<?php
11638
11639// #9396: fixing custom rbac operations for dcl, poll
11640include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
11641$poll_type_id = ilDBUpdateNewObjectType::getObjectTypeId('poll');
11642if ($poll_type_id) {
11643    $ilDB->manipulate('DELETE FROM rbac_operations WHERE operation = ' .
11644        $ilDB->quote($poll_type_id, 'text'));
11645}
11646$dcl_type_id = ilDBUpdateNewObjectType::getObjectTypeId('dcl');
11647if ($dcl_type_id) {
11648    $ilDB->manipulate('DELETE FROM rbac_operations WHERE operation = ' .
11649        $ilDB->quote($dcl_type_id, 'text'));
11650
11651    // re-doing dcl
11652    $ops_id = ilDBUpdateNewObjectType::addCustomRBACOperation('add_entry', 'Add Entry', 'object', 3200);
11653    if ($ops_id) {
11654        ilDBUpdateNewObjectType::addRBACOperation($dcl_type_id, $ops_id);
11655    }
11656}
11657
11658?>
11659<#3676>
11660<?php
11661
11662#6969
11663include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
11664ilDBUpdateNewObjectType::updateOperationOrder('invite', 2600);
11665
11666?>
11667<#3677>
11668<?php
11669global $ilDB;
11670
11671if (!$ilDB->tableExists('ecs_node_mapping_a')) {
11672    $fields = array(
11673        'server_id' => array(
11674            'type' => 'integer',
11675            'length' => 4,
11676        ),
11677        'mid' => array(
11678            'type' => 'integer',
11679            'length' => 4,
11680        ),
11681        'cs_root' => array(
11682            'type' => 'integer',
11683            'length' => 4,
11684        ),
11685        'cs_id' => array(
11686            'type' => 'integer',
11687            'length' => 4
11688        ),
11689        'ref_id' => array(
11690            'type' => 'integer',
11691            'length' => 4
11692        ),
11693        'obj_id' => array(
11694            'type' => 'integer',
11695            'length' => 4
11696        ),
11697        'title_update' => array(
11698            'type' => 'integer',
11699            'length' => 1
11700        ),
11701        'position_update' => array(
11702            'type' => 'integer',
11703            'length' => 1
11704        ),
11705        'tree_update' => array(
11706            'type' => 'integer',
11707            'length' => 1
11708        )
11709    );
11710    $ilDB->createTable('ecs_node_mapping_a', $fields);
11711    $ilDB->addPrimaryKey('ecs_node_mapping_a', array('server_id', 'mid', 'cs_root', 'cs_id'));
11712}
11713?>
11714
11715<#3678>
11716<?php
11717global $ilDB;
11718
11719if (!$ilDB->tableExists('ecs_cms_tree')) {
11720    $fields = array(
11721        'tree' => array(
11722            'type' => 'integer',
11723            'length' => 4,
11724        ),
11725        'child' => array(
11726            'type' => 'integer',
11727            'length' => 4,
11728        ),
11729        'parent' => array(
11730            'type' => 'integer',
11731            'length' => 4,
11732        ),
11733        'lft' => array(
11734            'type' => 'integer',
11735            'length' => 4
11736        ),
11737        'rgt' => array(
11738            'type' => 'integer',
11739            'length' => 4
11740        ),
11741        'depth' => array(
11742            'type' => 'integer',
11743            'length' => 4
11744        )
11745    );
11746    $ilDB->createTable('ecs_cms_tree', $fields);
11747    $ilDB->addPrimaryKey('ecs_cms_tree', array('tree', 'child'));
11748}
11749if (!$ilDB->tableExists('ecs_cms_data')) {
11750    $fields = array(
11751        'obj_id' => array(
11752            'type' => 'integer',
11753            'length' => 4,
11754        ),
11755        'server_id' => array(
11756            'type' => 'integer',
11757            'length' => 4,
11758        ),
11759        'mid' => array(
11760            'type' => 'integer',
11761            'length' => 4,
11762        ),
11763        'tree_id' => array(
11764            'type' => 'integer',
11765            'length' => 4,
11766        ),
11767        'cms_id' => array(
11768            'type' => 'integer',
11769            'length' => 4,
11770        ),
11771        'title' => array(
11772            'type' => 'text',
11773            'length' => 512,
11774            'notnull' => false
11775        )
11776    );
11777    $ilDB->createTable('ecs_cms_data', $fields);
11778    $ilDB->addPrimaryKey('ecs_cms_data', array('obj_id'));
11779    $ilDB->createSequence('ecs_cms_data');
11780}
11781?>
11782<#3679>
11783<?php
11784
11785    global $ilDB;
11786
11787    if (!$ilDB->tableColumnExists('ecs_cms_data', 'term')) {
11788        $ilDB->addTableColumn(
11789            'ecs_cms_data',
11790            'term',
11791            array(
11792                'type' => 'text',
11793                'length' => 255,
11794                'notnull' => false
11795            )
11796        );
11797    }
11798?>
11799<#3680>
11800<?php
11801    global $ilDB;
11802
11803    if (!$ilDB->tableColumnExists('ecs_cms_data', 'status')) {
11804        $ilDB->addTableColumn(
11805            'ecs_cms_data',
11806            'status',
11807            array(
11808                'type' => 'integer',
11809                'length' => 2,
11810                'notnull' => true,
11811                'default' => 1
11812            )
11813        );
11814    }
11815?>
11816<#3681>
11817<?php
11818    // original update step (#3395) was broken
11819    if (!$ilDB->sequenceExists('ecs_container_mapping')) {
11820        $res = $ilDB->query('SELECT mapping_id FROM ecs_container_mapping');
11821        $rows = $res->numRows();
11822        $ilDB->createSequence('ecs_container_mapping', ++$rows);
11823    }
11824?>
11825<#3682>
11826<?php
11827    $ilCtrlStructureReader->getStructure();
11828?>
11829<#3683>
11830<?php
11831    $ilCtrlStructureReader->getStructure();
11832?>
11833<#3684>
11834<?php
11835if (!$ilDB->tableExists('qpl_a_essay')) {
11836    $fields = array(
11837        'answer_id' => array(
11838            'type' => 'integer',
11839            'length' => 4,
11840        ),
11841        'question_fi' => array(
11842            'type' => 'integer',
11843            'length' => 4,
11844        ),
11845        'answertext' => array(
11846            'type' => 'text',
11847            'length' => 1000,
11848            'notnull' => false
11849        ),
11850        'points' => array(
11851            'type' => 'integer',
11852            'length' => 4,
11853        )
11854    );
11855    $ilDB->createTable('qpl_a_essay', $fields);
11856    $ilDB->addPrimaryKey('qpl_a_essay', array('answer_id'));
11857    $ilDB->createSequence('qpl_a_essay');
11858}
11859?>
11860<#3685>
11861<?php
11862    if (!$ilDB->tableColumnExists('qpl_qst_essay', 'keyword_relation')) {
11863        $ilDB->addTableColumn(
11864            'qpl_qst_essay',
11865            'keyword_relation',
11866            array(
11867                'type' => 'text',
11868                'length' => 3,
11869                'notnull' => true,
11870                'default' => 'any'
11871            )
11872        );
11873    }
11874?>
11875<#3686>
11876<?php
11877    if (!$ilDB->tableExists('qpl_fb_essay')) {
11878        $fields = array(
11879            'feedback_id' => array(
11880                'type' => 'integer',
11881                'length' => 4,
11882                'notnull' => true
11883            ),
11884            'question_fi' => array(
11885                'type' => 'integer',
11886                'length' => 4,
11887                'notnull' => true
11888            ),
11889            'answer' => array(
11890                'type' => 'integer',
11891                'length' => 4,
11892                'notnull' => true
11893            ),
11894            'feedback' => array(
11895                'type' => 'text',
11896                'length' => 4000,
11897                'notnull' => false
11898            ),
11899            'tstamp' => array(
11900                'type' => 'integer',
11901                'length' => 4,
11902                'notnull' => true
11903            )
11904        );
11905
11906        $ilDB->createTable('qpl_fb_essay', $fields);
11907        $ilDB->addIndex('qpl_fb_essay', array('question_fi'), 'i1');
11908        $ilDB->createSequence('qpl_fb_essay');
11909    }
11910?>
11911<#3687>
11912<?php
11913    $ilCtrlStructureReader->getStructure();
11914?>
11915<#3688>
11916<?php
11917    $ilDB->manipulateF(
11918    'UPDATE rbac_operations SET operation = %s WHERE operation = %s',
11919    array('text', 'text'),
11920    array('internal_mail', 'mail_visible')
11921);
11922?>
11923<#3689>
11924<?php
11925
11926include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
11927
11928$itgr_type_id = ilDBUpdateNewObjectType::addNewType('itgr', 'Item Group');
11929
11930$rbac_ops = array(
11931    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
11932    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
11933    ilDBUpdateNewObjectType::RBAC_OP_READ,
11934    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
11935    ilDBUpdateNewObjectType::RBAC_OP_DELETE,
11936    ilDBUpdateNewObjectType::RBAC_OP_COPY
11937);
11938ilDBUpdateNewObjectType::addRBACOperations($itgr_type_id, $rbac_ops);
11939
11940$parent_types = array('root', 'cat', 'crs', 'fold', 'grp');
11941ilDBUpdateNewObjectType::addRBACCreate('create_itgr', 'Create Item Group', $parent_types);
11942
11943?>
11944<#3690>
11945<?php
11946    $ilCtrlStructureReader->getStructure();
11947?>
11948
11949<#3691>
11950<?php
11951
11952    // table fields used by tst's obligate test questions (elba steps 21, 22, 23 and 24)
11953
11954    if (!$ilDB->tableColumnExists('tst_test_question', 'obligatory')) {
11955        $ilDB->addTableColumn("tst_test_question", "obligatory", array(
11956            "type" => "integer",
11957            "length" => 1,
11958            "notnull" => true,
11959            "default" => 0
11960        ));
11961    }
11962
11963    if (!$ilDB->tableColumnExists('tst_test_result', 'answered')) {
11964        $ilDB->addTableColumn("tst_test_result", "answered", array(
11965            "type" => "integer",
11966            "length" => 1,
11967            "notnull" => true,
11968            "default" => 1
11969        ));
11970    }
11971
11972    if (!$ilDB->tableColumnExists('tst_pass_result', 'obligations_answered')) {
11973        $ilDB->addTableColumn("tst_pass_result", "obligations_answered", array(
11974            "type" => "integer",
11975            "length" => 1,
11976            "notnull" => true,
11977            "default" => 1
11978        ));
11979    }
11980
11981    if (!$ilDB->tableColumnExists('tst_result_cache', 'obligations_answered')) {
11982        $ilDB->addTableColumn("tst_result_cache", "obligations_answered", array(
11983            "type" => "integer",
11984            "length" => 1,
11985            "notnull" => true,
11986            "default" => 1
11987        ));
11988    }
11989
11990?>
11991<#3692>
11992<?php
11993
11994$fields = array(
11995    'item_group_id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0),
11996    'item_ref_id' => array('type' => 'integer', 'length' => 4,'notnull' => true, 'default' => 0)
11997);
11998$ilDB->createTable('item_group_item', $fields);
11999$ilDB->addPrimaryKey('item_group_item', array('item_group_id', 'item_ref_id'));
12000
12001?>
12002<#3693>
12003<?php
12004    $ilDB->manipulateF(
12005    'UPDATE rbac_operations SET operation = %s WHERE operation = %s',
12006    array('text', 'text'),
12007    array('add_reply', 'add_post')
12008);
12009?>
12010<#3694>
12011<?php
12012    $ilDB->manipulateF(
12013    'UPDATE rbac_operations SET description = %s WHERE operation = %s',
12014    array('text', 'text'),
12015    array('Reply to forum articles', 'add_reply')
12016);
12017?>
12018<#3695>
12019<?php
12020
12021if (!$ilDB->tableColumnExists('tst_tests', 'obligations_enabled')) {
12022    $ilDB->addTableColumn('tst_tests', 'obligations_enabled', array(
12023        'type' => 'integer',
12024        'length' => 1,
12025        'notnull' => true,
12026        'default' => 0
12027    ));
12028}
12029
12030?>
12031<#3696>
12032<?php
12033
12034$text_questions = $ilDB->query(
12035    'SELECT question_fi, keywords, points
12036	 FROM qpl_questions
12037	 JOIN qpl_qst_essay ON qpl_questions.question_id = qpl_qst_essay.question_fi
12038	 WHERE keywords IS NOT NULL'
12039);
12040
12041while ($row = $ilDB->fetchAssoc($text_questions)) {
12042    $points = $row['points'];
12043    foreach (preg_split("/[\s, ]+/", $row['keywords']) as $keyword) {
12044        $keyword = trim($keyword);
12045        if (strlen($keyword)) {
12046            $nextId = $ilDB->nextId('qpl_a_essay');
12047            $query = 'INSERT INTO qpl_a_essay (answer_id, question_fi, answertext, points) VALUES (%s, %s, %s, %s)';
12048            $types = array("integer", "integer", "text", "integer");
12049            $values = array($nextId, $row['question_fi'], $keyword, $points);
12050            $ilDB->manipulateF($query, $types, $values);
12051            $points = 0;
12052        }
12053    }
12054}
12055?>
12056<#3697>
12057<?php
12058if (!$ilDB->tableColumnExists('sahs_lm', 'auto_last_visited')) {
12059    $ilDB->addTableColumn(
12060        'sahs_lm',
12061        'auto_last_visited',
12062        array(
12063            'type' => 'text',
12064            'length' => 1,
12065            'notnull' => true,
12066            'default' => 'y'
12067        )
12068    );
12069    $ilDB->query("UPDATE sahs_lm SET auto_last_visited = 'n'");
12070}
12071?>
12072<#3698>
12073<?php
12074if (!$ilDB->tableColumnExists('sahs_lm', 'check_values')) {
12075    $ilDB->addTableColumn(
12076        'sahs_lm',
12077        'check_values',
12078        array(
12079             'type' => 'text',
12080             'length' => 1,
12081             'notnull' => true,
12082             'default' => 'y'
12083        )
12084    );
12085    $ilDB->query("UPDATE sahs_lm SET check_values = 'y'");
12086}
12087?>
12088<#3699>
12089<?php
12090// remove obsolete id columns
12091if ($ilDB->tableColumnExists('il_dcl_viewdefinition', 'id')) {
12092    $ilDB->dropTableColumn('il_dcl_viewdefinition', 'id');
12093}
12094$ilDB->dropSequence('il_dcl_viewdefinition');
12095?>
12096<#3700>
12097<?php
12098if (!$ilDB->tableColumnExists('il_dcl_data', 'edit_by_owner')) {
12099    $ilDB->addTableColumn(
12100        'il_dcl_data',
12101        'edit_by_owner',
12102        array(
12103            'type' => 'integer',
12104            'length' => 1,
12105        )
12106    );
12107}
12108?>
12109<#3701>
12110<?php
12111if (!$ilDB->tableColumnExists('cmi_node', 'additional_tables')) {
12112    $ilDB->addTableColumn('cmi_node', 'additional_tables', array(
12113                                                            'type' => 'integer',
12114                                                            'length' => 1,
12115                                                            'notnull' => true,
12116                                                            'default' => 0
12117                                                       ));
12118    $ilDB->query("UPDATE cmi_node SET additional_tables = 15");
12119}
12120?>
12121<#3702>
12122<?php
12123if ($ilDB->tableColumnExists('cmi_node', 'cp_node_id')) {
12124    $ilDB->query("DELETE from cmi_node where cp_node_id is null");
12125    $reverse = $ilDB->loadModule('Reverse');
12126    $def = $reverse->getTableFieldDefinition("cmi_node", "cp_node_id");
12127    if ($def[0]['notnull'] == false) {
12128        $ilDB->modifyTableColumn('cmi_node', 'cp_node_id', array(
12129                                                            'type' => 'integer',
12130                                                            'length' => 4,
12131                                                            'notnull' => true,
12132                                                            'default' => 0
12133                                                       ));
12134    }
12135}
12136?>
12137<#3703>
12138<?php
12139if ($ilDB->tableColumnExists('cmi_node', 'user_id')) {
12140    $ilDB->query("DELETE from cmi_node where user_id is null");
12141    $reverse = $ilDB->loadModule('Reverse');
12142    $def = $reverse->getTableFieldDefinition("cmi_node", "user_id");
12143    if ($def[0]['notnull'] == false) {
12144        $ilDB->modifyTableColumn('cmi_node', 'user_id', array(
12145                                                            'type' => 'integer',
12146                                                            'length' => 4,
12147                                                            'notnull' => true,
12148                                                            'default' => 0
12149                                                       ));
12150    }
12151}
12152?>
12153<#3704>
12154<?php
12155
12156if (!$ilDB->tableExists('rcat_settings')) {
12157    $fields = array(
12158        'obj_id' => array(
12159            'type' => 'integer',
12160            'length' => 4,
12161            'notnull' => true
12162        ),
12163        'mid' => array(
12164            'type' => 'integer',
12165            'length' => 4,
12166            'notnull' => true
12167        ),
12168        'organization' => array(
12169            'type' => 'text',
12170            'length' => 400,
12171            'notnull' => false
12172        ),
12173        'local_information' => array(
12174            'type' => 'text',
12175            'length' => 4000,
12176            'notnull' => false
12177        ),
12178        'remote_link' => array(
12179            'type' => 'text',
12180            'length' => 400,
12181            'notnull' => false
12182        )
12183    );
12184    $ilDB->createTable('rcat_settings', $fields);
12185    $ilDB->addPrimaryKey('rcat_settings', array('obj_id'));
12186}
12187
12188?>
12189<#3705>
12190<?php
12191
12192include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
12193
12194$rcat_type_id = ilDBUpdateNewObjectType::addNewType('rcat', 'Remote Category Object');
12195
12196$rbac_ops = array(
12197    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
12198    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
12199    ilDBUpdateNewObjectType::RBAC_OP_READ,
12200    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
12201    ilDBUpdateNewObjectType::RBAC_OP_DELETE
12202);
12203ilDBUpdateNewObjectType::addRBACOperations($rcat_type_id, $rbac_ops);
12204
12205?>
12206<#3706>
12207<?php
12208
12209if (!$ilDB->tableExists('rwik_settings')) {
12210    $fields = array(
12211        'obj_id' => array(
12212            'type' => 'integer',
12213            'length' => 4,
12214            'notnull' => true
12215        ),
12216        'mid' => array(
12217            'type' => 'integer',
12218            'length' => 4,
12219            'notnull' => true
12220        ),
12221        'organization' => array(
12222            'type' => 'text',
12223            'length' => 400,
12224            'notnull' => false
12225        ),
12226        'local_information' => array(
12227            'type' => 'text',
12228            'length' => 4000,
12229            'notnull' => false
12230        ),
12231        'remote_link' => array(
12232            'type' => 'text',
12233            'length' => 400,
12234            'notnull' => false
12235        ),
12236        'availability_type' => array(
12237            'type' => 'integer',
12238            'length' => 1,
12239            'notnull' => true,
12240            'default' => 0
12241        ),
12242    );
12243    $ilDB->createTable('rwik_settings', $fields);
12244    $ilDB->addPrimaryKey('rwik_settings', array('obj_id'));
12245}
12246
12247?>
12248<#3707>
12249<?php
12250
12251include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
12252
12253$rwik_type_id = ilDBUpdateNewObjectType::addNewType('rwik', 'Remote Wiki Object');
12254
12255$rbac_ops = array(
12256    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
12257    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
12258    ilDBUpdateNewObjectType::RBAC_OP_READ,
12259    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
12260    ilDBUpdateNewObjectType::RBAC_OP_DELETE
12261);
12262ilDBUpdateNewObjectType::addRBACOperations($rwik_type_id, $rbac_ops);
12263
12264?>
12265<#3708>
12266<?php
12267
12268if (!$ilDB->tableExists('rlm_settings')) {
12269    $fields = array(
12270        'obj_id' => array(
12271            'type' => 'integer',
12272            'length' => 4,
12273            'notnull' => true
12274        ),
12275        'mid' => array(
12276            'type' => 'integer',
12277            'length' => 4,
12278            'notnull' => true
12279        ),
12280        'organization' => array(
12281            'type' => 'text',
12282            'length' => 400,
12283            'notnull' => false
12284        ),
12285        'local_information' => array(
12286            'type' => 'text',
12287            'length' => 4000,
12288            'notnull' => false
12289        ),
12290        'remote_link' => array(
12291            'type' => 'text',
12292            'length' => 400,
12293            'notnull' => false
12294        ),
12295        'availability_type' => array(
12296            'type' => 'integer',
12297            'length' => 1,
12298            'notnull' => true,
12299            'default' => 0
12300        ),
12301    );
12302    $ilDB->createTable('rlm_settings', $fields);
12303    $ilDB->addPrimaryKey('rlm_settings', array('obj_id'));
12304}
12305
12306?>
12307<#3709>
12308<?php
12309
12310include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
12311
12312$rlm_type_id = ilDBUpdateNewObjectType::addNewType('rlm', 'Remote Learning Module Object');
12313
12314$rbac_ops = array(
12315    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
12316    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
12317    ilDBUpdateNewObjectType::RBAC_OP_READ,
12318    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
12319    ilDBUpdateNewObjectType::RBAC_OP_DELETE
12320);
12321ilDBUpdateNewObjectType::addRBACOperations($rlm_type_id, $rbac_ops);
12322
12323?>
12324<#3710>
12325<?php
12326
12327if (!$ilDB->tableExists('rglo_settings')) {
12328    $fields = array(
12329        'obj_id' => array(
12330            'type' => 'integer',
12331            'length' => 4,
12332            'notnull' => true
12333        ),
12334        'mid' => array(
12335            'type' => 'integer',
12336            'length' => 4,
12337            'notnull' => true
12338        ),
12339        'organization' => array(
12340            'type' => 'text',
12341            'length' => 400,
12342            'notnull' => false
12343        ),
12344        'local_information' => array(
12345            'type' => 'text',
12346            'length' => 4000,
12347            'notnull' => false
12348        ),
12349        'remote_link' => array(
12350            'type' => 'text',
12351            'length' => 400,
12352            'notnull' => false
12353        ),
12354        'availability_type' => array(
12355            'type' => 'integer',
12356            'length' => 1,
12357            'notnull' => true,
12358            'default' => 0
12359        ),
12360    );
12361    $ilDB->createTable('rglo_settings', $fields);
12362    $ilDB->addPrimaryKey('rglo_settings', array('obj_id'));
12363}
12364
12365?>
12366<#3711>
12367<?php
12368
12369include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
12370
12371$rglo_type_id = ilDBUpdateNewObjectType::addNewType('rglo', 'Remote Glossary Object');
12372
12373$rbac_ops = array(
12374    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
12375    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
12376    ilDBUpdateNewObjectType::RBAC_OP_READ,
12377    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
12378    ilDBUpdateNewObjectType::RBAC_OP_DELETE
12379);
12380ilDBUpdateNewObjectType::addRBACOperations($rglo_type_id, $rbac_ops);
12381
12382?>
12383<#3712>
12384	<?php
12385    if (!$ilDB->tableColumnExists('il_dcl_record', 'last_edit_by')) {
12386        $ilDB->addTableColumn(
12387            'il_dcl_record',
12388            'last_edit_by',
12389            array(
12390                'type' => 'integer',
12391                'length' => 4,
12392            )
12393        );
12394    }
12395    ?>
12396<#3713>
12397<?php
12398if (!$ilDB->tableColumnExists('il_dcl_viewdefinition', 'is_set')) {
12399        $ilDB->addTableColumn(
12400            'il_dcl_viewdefinition',
12401            'is_set',
12402            array(
12403            'type' => 'integer',
12404            'length' => 1,
12405            'notnull' => true,
12406            'default' => 0
12407        )
12408        );
12409    }
12410?>
12411<#3714>
12412<?php
12413
12414if (!$ilDB->tableExists('rfil_settings')) {
12415    $fields = array(
12416        'obj_id' => array(
12417            'type' => 'integer',
12418            'length' => 4,
12419            'notnull' => true
12420        ),
12421        'mid' => array(
12422            'type' => 'integer',
12423            'length' => 4,
12424            'notnull' => true
12425        ),
12426        'organization' => array(
12427            'type' => 'text',
12428            'length' => 400,
12429            'notnull' => false
12430        ),
12431        'local_information' => array(
12432            'type' => 'text',
12433            'length' => 4000,
12434            'notnull' => false
12435        ),
12436        'remote_link' => array(
12437            'type' => 'text',
12438            'length' => 400,
12439            'notnull' => false
12440        ),
12441        'version' => array(
12442            'type' => 'integer',
12443            'length' => 2,
12444            'notnull' => true,
12445            'default' => 1
12446        ),
12447        'version_tstamp' => array(
12448            'type' => 'integer',
12449            'length' => 4,
12450            'notnull' => false
12451        )
12452    );
12453    $ilDB->createTable('rfil_settings', $fields);
12454    $ilDB->addPrimaryKey('rfil_settings', array('obj_id'));
12455}
12456
12457?>
12458<#3715>
12459<?php
12460
12461include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
12462
12463$rfil_type_id = ilDBUpdateNewObjectType::addNewType('rfil', 'Remote File Object');
12464
12465$rbac_ops = array(
12466    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
12467    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
12468    ilDBUpdateNewObjectType::RBAC_OP_READ,
12469    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
12470    ilDBUpdateNewObjectType::RBAC_OP_DELETE
12471);
12472ilDBUpdateNewObjectType::addRBACOperations($rfil_type_id, $rbac_ops);
12473
12474?>
12475<#3716>
12476<?php
12477
12478if (!$ilDB->tableExists('rgrp_settings')) {
12479    $fields = array(
12480        'obj_id' => array(
12481            'type' => 'integer',
12482            'length' => 4,
12483            'notnull' => true
12484        ),
12485        'mid' => array(
12486            'type' => 'integer',
12487            'length' => 4,
12488            'notnull' => true
12489        ),
12490        'organization' => array(
12491            'type' => 'text',
12492            'length' => 400,
12493            'notnull' => false
12494        ),
12495        'local_information' => array(
12496            'type' => 'text',
12497            'length' => 4000,
12498            'notnull' => false
12499        ),
12500        'remote_link' => array(
12501            'type' => 'text',
12502            'length' => 400,
12503            'notnull' => false
12504        ),
12505        'availability_type' => array(
12506            'type' => 'integer',
12507            'length' => 1,
12508            'notnull' => true,
12509            'default' => 0
12510        ),
12511        'availability_start' => array(
12512            'type' => 'integer',
12513            'length' => 4,
12514            'notnull' => false
12515        ),
12516        'availability_end' => array(
12517            'type' => 'integer',
12518            'length' => 4,
12519            'notnull' => false
12520        )
12521    );
12522    $ilDB->createTable('rgrp_settings', $fields);
12523    $ilDB->addPrimaryKey('rgrp_settings', array('obj_id'));
12524}
12525
12526?>
12527<#3717>
12528<?php
12529
12530include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
12531
12532$rgrp_type_id = ilDBUpdateNewObjectType::addNewType('rgrp', 'Remote Group Object');
12533
12534$rbac_ops = array(
12535    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
12536    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
12537    ilDBUpdateNewObjectType::RBAC_OP_READ,
12538    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
12539    ilDBUpdateNewObjectType::RBAC_OP_DELETE
12540);
12541ilDBUpdateNewObjectType::addRBACOperations($rgrp_type_id, $rbac_ops);
12542
12543?>
12544<#3718>
12545<?php
12546    $ilCtrlStructureReader->getStructure();
12547?>
12548<#3719>
12549<?php
12550if (!$ilDB->tableColumnExists('il_dcl_table', 'blocked')) {
12551    $ilDB->addTableColumn(
12552        'il_dcl_table',
12553        'blocked',
12554        array(
12555            'type' => 'integer',
12556            'length' => 1,
12557            'notnull' => true,
12558            'default' => 0
12559        )
12560    );
12561}
12562?>
12563<#3720>
12564<?php
12565if (!$ilDB->tableColumnExists('il_dcl_field', 'is_unique')) {
12566    $ilDB->addTableColumn(
12567        'il_dcl_field',
12568        'is_unique',
12569        array(
12570            'type' => 'integer',
12571            'length' => 1,
12572            'notnull' => true,
12573            'default' => 0
12574        )
12575    );
12576}
12577?>
12578<#3721>
12579<?php
12580if (!$ilDB->tableColumnExists('tst_tests', 'autosave')) {
12581    $ilDB->addTableColumn(
12582        'tst_tests',
12583        'autosave',
12584        array(
12585            'type' => 'integer',
12586            'length' => 1,
12587            'notnull' => true,
12588            'default' => 0
12589        )
12590    );
12591
12592    $ilDB->manipulate('UPDATE tst_tests SET autosave = ' . $ilDB->quote(0, 'integer'));
12593}
12594if (!$ilDB->tableColumnExists('tst_tests', 'autosave_ival')) {
12595    $ilDB->addTableColumn(
12596        'tst_tests',
12597        'autosave_ival',
12598        array(
12599            'type' => 'integer',
12600            'length' => 4,
12601            'notnull' => true,
12602            'default' => 0
12603        )
12604    );
12605
12606    $ilDB->manipulate('UPDATE tst_tests SET autosave_ival = ' . $ilDB->quote(30000, 'integer'));
12607}
12608?>
12609<#3722>
12610<?php
12611
12612if (!$ilDB->tableExists('rtst_settings')) {
12613    $fields = array(
12614        'obj_id' => array(
12615            'type' => 'integer',
12616            'length' => 4,
12617            'notnull' => true
12618        ),
12619        'mid' => array(
12620            'type' => 'integer',
12621            'length' => 4,
12622            'notnull' => true
12623        ),
12624        'organization' => array(
12625            'type' => 'text',
12626            'length' => 400,
12627            'notnull' => false
12628        ),
12629        'local_information' => array(
12630            'type' => 'text',
12631            'length' => 4000,
12632            'notnull' => false
12633        ),
12634        'remote_link' => array(
12635            'type' => 'text',
12636            'length' => 400,
12637            'notnull' => false
12638        ),
12639        'availability_type' => array(
12640            'type' => 'integer',
12641            'length' => 1,
12642            'notnull' => true,
12643            'default' => 0
12644        ),
12645        'availability_start' => array(
12646            'type' => 'integer',
12647            'length' => 4,
12648            'notnull' => false
12649        ),
12650        'availability_end' => array(
12651            'type' => 'integer',
12652            'length' => 4,
12653            'notnull' => false
12654        )
12655    );
12656    $ilDB->createTable('rtst_settings', $fields);
12657    $ilDB->addPrimaryKey('rtst_settings', array('obj_id'));
12658}
12659
12660?>
12661<#3723>
12662<?php
12663
12664include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
12665
12666$rtst_type_id = ilDBUpdateNewObjectType::addNewType('rtst', 'Remote Test Object');
12667
12668$rbac_ops = array(
12669    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
12670    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
12671    ilDBUpdateNewObjectType::RBAC_OP_READ,
12672    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
12673    ilDBUpdateNewObjectType::RBAC_OP_DELETE
12674);
12675ilDBUpdateNewObjectType::addRBACOperations($rtst_type_id, $rbac_ops);
12676
12677?>
12678<#3724>
12679<?php
12680    $ilCtrlStructureReader->getStructure();
12681?>
12682<#3725>
12683<?php
12684
12685include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
12686
12687$blog_type_id = ilDBUpdateNewObjectType::getObjectTypeId('blog');
12688$ops_id = ilDBUpdateNewObjectType::addCustomRBACOperation('contribute', 'Contribute', 'object', 3205);
12689if ($ops_id && $blog_type_id) {
12690    ilDBUpdateNewObjectType::addRBACOperation($blog_type_id, $ops_id);
12691}
12692
12693?>
12694<#3726>
12695<?php
12696if (!$ilDB->tableColumnExists('il_dcl_table', 'add_perm')) {
12697    $ilDB->addTableColumn(
12698        'il_dcl_table',
12699        'add_perm',
12700        array(
12701            'type' => 'integer',
12702            'length' => 1,
12703            'notnull' => true,
12704            'default' => 1
12705        )
12706    );
12707}
12708if (!$ilDB->tableColumnExists('il_dcl_table', 'edit_perm')) {
12709    $ilDB->addTableColumn(
12710        'il_dcl_table',
12711        'edit_perm',
12712        array(
12713            'type' => 'integer',
12714            'length' => 1,
12715            'notnull' => true,
12716            'default' => 1
12717        )
12718    );
12719}
12720if (!$ilDB->tableColumnExists('il_dcl_table', 'delete_perm')) {
12721    $ilDB->addTableColumn(
12722        'il_dcl_table',
12723        'delete_perm',
12724        array(
12725            'type' => 'integer',
12726            'length' => 1,
12727            'notnull' => true,
12728            'default' => 1
12729        )
12730    );
12731}
12732if (!$ilDB->tableColumnExists('il_dcl_table', 'edit_by_owner')) {
12733    $ilDB->addTableColumn(
12734        'il_dcl_table',
12735        'edit_by_owner',
12736        array(
12737            'type' => 'integer',
12738            'length' => 1,
12739            'notnull' => true,
12740            'default' => 1
12741        )
12742    );
12743}
12744if (!$ilDB->tableColumnExists('il_dcl_table', 'limited')) {
12745    $ilDB->addTableColumn(
12746        'il_dcl_table',
12747        'limited',
12748        array(
12749            'type' => 'integer',
12750            'length' => 1,
12751            'notnull' => true,
12752            'default' => 0
12753        )
12754    );
12755}
12756if (!$ilDB->tableColumnExists('il_dcl_table', 'limit_start')) {
12757    $ilDB->addTableColumn(
12758        'il_dcl_table',
12759        'limit_start',
12760        array(
12761            'type' => 'timestamp',
12762            'notnull' => false
12763        )
12764    );
12765}
12766if (!$ilDB->tableColumnExists('il_dcl_table', 'limit_end')) {
12767    $ilDB->addTableColumn(
12768        'il_dcl_table',
12769        'limit_end',
12770        array(
12771            'type' => 'timestamp',
12772            'notnull' => false
12773        )
12774    );
12775}
12776?>
12777<#3727>
12778<?php
12779if ($ilDB->tableColumnExists('il_dcl_data', 'edit_type')) {
12780    $ilDB->dropTableColumn('il_dcl_data', 'edit_type');
12781}
12782if ($ilDB->tableColumnExists('il_dcl_data', 'edit_start')) {
12783    $ilDB->dropTableColumn('il_dcl_data', 'edit_start');
12784}
12785if ($ilDB->tableColumnExists('il_dcl_data', 'edit_end')) {
12786    $ilDB->dropTableColumn('il_dcl_data', 'edit_end');
12787}
12788if ($ilDB->tableColumnExists('il_dcl_data', 'edit_by_owner')) {
12789    $ilDB->dropTableColumn('il_dcl_data', 'edit_by_owner');
12790}
12791?>
12792<#3728>
12793<?php
12794if (!$ilDB->tableColumnExists('il_dcl_field', 'is_locked')) {
12795    $ilDB->addTableColumn(
12796        'il_dcl_field',
12797        'is_locked',
12798        array(
12799            'type' => 'integer',
12800            'length' => 1,
12801            'notnull' => true,
12802            'default' => 0
12803        )
12804    );
12805}
12806?>
12807<#3729>
12808<?php
12809  $ilDB->manipulateF(
12810    'UPDATE il_dcl_datatype_prop SET inputformat = %s WHERE title = %s',
12811    array('integer', 'text'),
12812    array(2, 'regex')
12813);
12814?>
12815<#3730>
12816<?php
12817  $ilDB->manipulateF(
12818    'UPDATE il_dcl_datatype_prop SET inputformat = %s WHERE title = %s',
12819    array('integer', 'text'),
12820    array(1, 'table_id')
12821);
12822?>
12823<#3731>
12824<?php
12825  $ins_res = $ilDB->manipulateF(
12826    'INSERT INTO il_dcl_datatype_prop (id, datatype_id, title, inputformat)
12827      VALUES(%s,%s,%s,%s)',
12828    array('integer','integer', 'text','integer'),
12829    array(4,2, 'url',2)
12830);
12831?>
12832<#3732>
12833<?php
12834  $ilDB->manipulateF(
12835    'UPDATE il_dcl_datatype_prop SET inputformat = %s WHERE title = %s',
12836    array('integer', 'text'),
12837    array(4, 'url')
12838);
12839?>
12840<#3733>
12841<?php
12842if ($ilDB->tableColumnExists('il_dcl_table', 'blocked')) {
12843    $ilDB->dropTableColumn('il_dcl_table', 'blocked');
12844}
12845?>
12846<#3734>
12847<?php
12848    $ilCtrlStructureReader->getStructure();
12849?>
12850<#3735>
12851<?php
12852$ilDB->manipulate("INSERT INTO il_dcl_datatype (id, title, ildb_type, storage_location) VALUES (" . $ilDB->quote(7, "integer") . ", " . $ilDB->quote("rating", "text") . ", " . $ilDB->quote("integer", "text") . ", " . $ilDB->quote(0, "integer") . ")");
12853?>
12854<#3736>
12855<?php
12856if (!$ilDB->tableColumnExists('il_poll', 'period')) {
12857    $ilDB->addTableColumn(
12858        'il_poll',
12859        'period',
12860        array(
12861            'type' => 'integer',
12862            'length' => 1,
12863            'notnull' => true,
12864            'default' => 0
12865        )
12866    );
12867    $ilDB->addTableColumn(
12868        'il_poll',
12869        'period_begin',
12870        array(
12871            'type' => 'integer',
12872            'length' => 4,
12873            'notnull' => false,
12874            'default' => 0
12875        )
12876    );
12877    $ilDB->addTableColumn(
12878        'il_poll',
12879        'period_end',
12880        array(
12881            'type' => 'integer',
12882            'length' => 4,
12883            'notnull' => false,
12884            'default' => 0
12885        )
12886    );
12887}
12888?>
12889<#3737>
12890<?php
12891    $ilCtrlStructureReader->getStructure();
12892?>
12893<#3738>
12894<?php
12895$ilDB->manipulateF(
12896    "INSERT INTO il_dcl_datatype_prop (id,datatype_id,title,inputformat) VALUES " .
12897           " (%s,%s,%s,%s)",
12898    array("integer", "integer", "text", "integer"),
12899    array(5, 2, "text_area", 4)
12900);
12901?>
12902<#3739>
12903<?php
12904    $ilCtrlStructureReader->getStructure();
12905?>
12906<#3740>
12907<?php
12908$ilDB->manipulate("INSERT INTO il_dcl_datatype (id, title, ildb_type, storage_location) " .
12909        " VALUES (" .
12910        $ilDB->quote(8, "integer") . ", " . $ilDB->quote("ILIAS_reference", "text") . ", " . $ilDB->quote("integer", "text") . ", " . $ilDB->quote(2, "integer") .
12911        ")");
12912?>
12913<#3741>
12914<?php
12915if (!$ilDB->tableColumnExists('il_blog', 'approval')) {
12916    $ilDB->addTableColumn(
12917        'il_blog',
12918        'approval',
12919        array(
12920            'type' => 'integer',
12921            'length' => 1,
12922            'notnull' => false,
12923            'default' => 0
12924        )
12925    );
12926    $ilDB->addTableColumn(
12927        'il_blog_posting',
12928        'approved',
12929        array(
12930            'type' => 'integer',
12931            'length' => 1,
12932            'notnull' => false,
12933            'default' => 0
12934        )
12935    );
12936}
12937?>
12938<#3742>
12939<?php
12940    $ilCtrlStructureReader->getStructure();
12941?>
12942<#3743>
12943<?php
12944
12945include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
12946
12947$sess_ops_id = ilDBUpdateNewObjectType::getCustomRBACOperationId('create_sess');
12948if ($sess_ops_id) {
12949    $fold_type_id = ilDBUpdateNewObjectType::getObjectTypeId('fold');
12950    if ($fold_type_id) {
12951        ilDBUpdateNewObjectType::addRBACOperation($fold_type_id, $sess_ops_id);
12952    }
12953    $grp_type_id = ilDBUpdateNewObjectType::getObjectTypeId('grp');
12954    if ($grp_type_id) {
12955        ilDBUpdateNewObjectType::addRBACOperation($grp_type_id, $sess_ops_id);
12956    }
12957}
12958
12959?>
12960<#3744>
12961<?php
12962if (!$ilDB->tableColumnExists('booking_object', 'info_file')) {
12963    $ilDB->addTableColumn(
12964        'booking_object',
12965        'info_file',
12966        array(
12967            'type' => 'text',
12968            'length' => 500,
12969            'notnull' => false
12970        )
12971    );
12972    $ilDB->addTableColumn(
12973        'booking_object',
12974        'post_text',
12975        array(
12976            'type' => 'text',
12977            'length' => 4000,
12978            'notnull' => false
12979        )
12980    );
12981    $ilDB->addTableColumn(
12982        'booking_object',
12983        'post_file',
12984        array(
12985            'type' => 'text',
12986            'length' => 500,
12987            'notnull' => false
12988        )
12989    );
12990}
12991?>
12992<#3745>
12993<?php
12994$ilDB->manipulateF(
12995    "INSERT INTO il_dcl_datatype_prop (id,datatype_id,title,inputformat) VALUES " .
12996           " (%s,%s,%s,%s)",
12997    array("integer", "integer", "text", "integer"),
12998    array(6, 3, "reference_link", 4)
12999);
13000?>
13001<#3746>
13002<?php
13003    $ilCtrlStructureReader->getStructure();
13004?>
13005<#3747>
13006<?php
13007$ilDB->manipulate("INSERT INTO il_dcl_datatype (id, title, ildb_type, storage_location) " .
13008        " VALUES (" .
13009        $ilDB->quote(9, "integer") . ", " . $ilDB->quote("mob", "text") . ", " . $ilDB->quote("integer", "text") . ", " . $ilDB->quote(2, "text") .
13010        ")");
13011
13012?>
13013<#3748>
13014<?php
13015$ilDB->manipulateF(
13016    "INSERT INTO il_dcl_datatype_prop (id,datatype_id,title,inputformat) VALUES " .
13017           " (%s,%s,%s,%s)",
13018    array("integer", "integer", "text", "integer"),
13019    array(7, 9, "width", 1)
13020);
13021
13022$ilDB->manipulateF(
13023    "INSERT INTO il_dcl_datatype_prop (id,datatype_id,title,inputformat) VALUES " .
13024           " (%s,%s,%s,%s)",
13025    array("integer", "integer", "text", "integer"),
13026    array(8, 9, "height", 1)
13027);
13028?>
13029<#3749>
13030<?php
13031$ilDB->manipulateF(
13032    "INSERT INTO il_dcl_datatype_prop (id,datatype_id,title,inputformat) VALUES " .
13033           " (%s,%s,%s,%s)",
13034    array("integer", "integer", "text", "integer"),
13035    array(9, 8, "learning_progress", 4)
13036);
13037?>
13038<#3750>
13039<?php
13040if (!$ilDB->tableColumnExists('il_rating', 'tstamp')) {
13041    $ilDB->addTableColumn(
13042        'il_rating',
13043        'tstamp',
13044        array(
13045            'type' => 'integer',
13046            'length' => 4,
13047            'notnull' => false
13048        )
13049    );
13050}
13051?>
13052<#3751>
13053<?php
13054$setting = new ilSetting();
13055$setting->set('obj_dis_creation_icrs', 1);
13056$setting->set('obj_dis_creation_icla', 1);
13057?>
13058<#3752>
13059<?php
13060$ilDB->manipulateF(
13061    "INSERT INTO il_dcl_datatype_prop (id,datatype_id,title,inputformat) VALUES " .
13062           " (%s,%s,%s,%s)",
13063    array("integer", "integer", "text", "integer"),
13064    array(10, 8, "ILIAS_reference_link", 4)
13065);
13066?>
13067<#3753>
13068<?php
13069$setting = new ilSetting();
13070$ade = $setting->get("admin_email");
13071$fbr = $setting->get("feedback_recipient");
13072if (trim($ade) && !trim($fbr)) {
13073    $setting->set("feedback_recipient", $ade);
13074}
13075?>
13076<#3754>
13077<?php
13078    /* #10745
13079    // see 3619
13080    $ts_now = time();
13081    $ts_latest = mktime(23,55,00,date('n',time()),date('j',time()),date('Y',time()));
13082
13083    // all limited course objects with ref_id and parent ref_id
13084    $query = "SELECT t.child,t.parent,c.startdate,c.enddate".
13085        " FROM svy_svy c".
13086        " JOIN object_reference r ON (r.obj_id = c.obj_fi)".
13087        " JOIN tree t ON (r.ref_id = t.child)".
13088        " LEFT JOIN crs_items i ON (i.obj_id = r.ref_id)".
13089        " WHERE i.obj_id IS NULL";
13090    $set = $ilDB->query($query);
13091    while($row = $ilDB->fetchAssoc($set))
13092    {
13093        if($row["startdate"] || $row["enddate"])
13094        {
13095            $ts_start = time();
13096            if(preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $row["startdate"], $d_parts))
13097            {
13098                $ts_start = mktime(
13099                    isset($d_parts[4]) ? $d_parts[4] : 0,
13100                    isset($d_parts[5]) ? $d_parts[5] : 0,
13101                    isset($d_parts[6]) ? $d_parts[6] : 0,
13102                    $d_parts[2],
13103                    $d_parts[3],
13104                    $d_parts[1]);
13105            }
13106            $ts_end = mktime(0, 0, 1, 1, 1, date("Y")+3);
13107            if(preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $row["enddate"], $d_parts))
13108            {
13109                $ts_end = mktime(
13110                    isset($d_parts[4]) ? $d_parts[4] : 0,
13111                    isset($d_parts[5]) ? $d_parts[5] : 0,
13112                    isset($d_parts[6]) ? $d_parts[6] : 0,
13113                    $d_parts[2],
13114                    $d_parts[3],
13115                    $d_parts[1]);
13116            }
13117
13118            $query = "INSERT INTO crs_items (parent_id,obj_id,timing_type,timing_start,".
13119                "timing_end,suggestion_start,suggestion_end,changeable,earliest_start,".
13120                "latest_end,visible,position) VALUES (".
13121                $ilDB->quote($row["parent"],'integer').",".
13122                $ilDB->quote($row["child"],'integer').",".
13123                $ilDB->quote(0,'integer').",".
13124                $ilDB->quote($ts_start,'integer').",".
13125                $ilDB->quote($ts_end,'integer').",".
13126                $ilDB->quote($ts_now,'integer').",".
13127                $ilDB->quote($ts_now,'integer').",".
13128                $ilDB->quote(0,'integer').",".
13129                $ilDB->quote($ts_now,'integer').", ".
13130                $ilDB->quote($ts_latest,'integer').", ".
13131                $ilDB->quote(1,'integer').", ".
13132                $ilDB->quote(0,'integer').")";
13133            $ilDB->manipulate($query);
13134        }
13135    }
13136     */
13137?>
13138<#3755>
13139<?php
13140    $ilDB->addPrimaryKey('qpl_fb_cloze', array('feedback_id'));
13141?>
13142<#3756>
13143<?php
13144    $ilDB->addPrimaryKey('qpl_fb_errortext', array('feedback_id'));
13145?>
13146<#3757>
13147<?php
13148    $ilDB->addPrimaryKey('qpl_fb_matching', array('feedback_id'));
13149?>
13150<#3758>
13151<?php
13152    $ilDB->addPrimaryKey('qpl_fb_essay', array('feedback_id'));
13153?>
13154
13155<#3759>
13156<?php
13157
13158    if (!$ilDB->tableColumnExists('usr_data', 'inactivation_date')) {
13159        $ilDB->addTableColumn('usr_data', 'inactivation_date', array(
13160            'type' => 'timestamp',
13161            'notnull' => false,
13162            'default' => null
13163        ));
13164    } else {
13165        // if field does already exist, this is the awd installation,
13166        // so turn stored configuration to new inactivation cron
13167
13168        $settings = array(
13169            'cron_inactive_user_delete',
13170            'cron_inactive_user_delete_interval',
13171            'cron_inactive_user_delete_include_roles',
13172            'cron_inactive_user_delete_period',
13173            'cron_inactive_user_delete_last_run'
13174        );
13175
13176        $_keyword_IN_keywords = $ilDB->in('keyword', $settings, false, 'text');
13177
13178        $res = $ilDB->query("
13179			SELECT keyword, value
13180			FROM settings
13181			WHERE $_keyword_IN_keywords
13182		");
13183
13184        while ($row = $ilDB->fetchAssoc($res)) {
13185            $settingName = $row['keyword'];
13186            $settingValue = $row['value'];
13187
13188            $settingName = str_replace('cron_inactive_', 'cron_inactivated_', $settingName);
13189
13190            $ilDB->insert('settings', array(
13191                'module' => array('text', 'common'),
13192                'keyword' => array('text', $settingName),
13193                'value' => array('text', $settingValue)
13194            ));
13195        }
13196
13197        $ilDB->manipulate("DELETE FROM settings WHERE $_keyword_IN_keywords");
13198    }
13199
13200?>
13201<#3760>
13202<?php
13203
13204    // map wsp ids to object ids
13205    $ntfmap = array();
13206    $set = $ilDB->query("SELECT ntf.id,orw.obj_id" .
13207        " FROM notification ntf" .
13208        " JOIN object_reference_ws orw ON (ntf.id = orw.wsp_id)" .
13209        " WHERE ntf.type = " . $ilDB->quote(4, "integer"));
13210    while ($row = $ilDB->fetchAssoc($set)) {
13211        $ntfmap[$row["id"]] = $row["obj_id"];
13212    }
13213
13214    if (sizeof($ntfmap)) {
13215        // remove existing object entries (just to make sure, there should be none)
13216        $ilDB->manipulate("DELETE FROM notification" .
13217            " WHERE type = " . $ilDB->quote(4, "integer") .
13218            " AND " . $ilDB->in("id", array_values($ntfmap), "", "integer"));
13219
13220        // convert wsp_id entries to obj_id entries
13221        foreach ($ntfmap as $ntf_wsp_id => $ntf_obj_id) {
13222            $ilDB->manipulate("UPDATE notification" .
13223                " SET id = " . $ilDB->quote($ntf_obj_id, "integer") .
13224                " WHERE id = " . $ilDB->quote($ntf_wsp_id, "integer") .
13225                " AND type = " . $ilDB->quote(4, "integer"));
13226        }
13227    }
13228
13229?>
13230<#3761>
13231<?php
13232    $settings = new ilSetting('MathJax');
13233    $settings->set('path_to_mathjax', 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML');
13234?>
13235<#3762>
13236<?php
13237    $ilCtrlStructureReader->getStructure();
13238?>
13239<#3763>
13240<?php
13241
13242    $blog_contributor_tpl_id = $ilDB->nextId('object_data');
13243
13244    $ilDB->manipulateF(
13245        "INSERT INTO object_data (obj_id, type, title, description," .
13246        " owner, create_date, last_update) VALUES (%s, %s, %s, %s, %s, %s, %s)",
13247        array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
13248        array($blog_contributor_tpl_id, "rolt", "il_blog_contributor",
13249            "Contributor template for blogs", -1, ilUtil::now(), ilUtil::now())
13250    );
13251
13252    $query = 'SELECT ops_id FROM rbac_operations WHERE operation = ' .
13253        $ilDB->quote('contribute', 'text');
13254    $rset = $ilDB->query($query);
13255    $row = $ilDB->fetchAssoc($rset);
13256    $contr_op_id = $row['ops_id'];
13257    if ($contr_op_id) {
13258        $ilDB->manipulateF(
13259            "INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" .
13260            " VALUES (%s, %s, %s, %s)",
13261            array("integer", "text", "integer", "integer"),
13262            array($blog_contributor_tpl_id, "blog", $contr_op_id, 8)
13263        );
13264
13265        $ilDB->manipulateF(
13266            "INSERT INTO rbac_fa (rol_id, parent, assign, protected)" .
13267            " VALUES (%s, %s, %s, %s)",
13268            array("integer", "integer", "text", "text"),
13269            array($blog_contributor_tpl_id, 8, "n", "n")
13270        );
13271    }
13272?>
13273<#3764>
13274<?php
13275if (!$ilDB->tableColumnExists('il_dcl_table', 'is_visible')) {
13276    $ilDB->addTableColumn(
13277        'il_dcl_table',
13278        'is_visible',
13279        array(
13280            'type' => 'integer',
13281            'length' => 1,
13282            'notnull' => true,
13283            'default' => 1
13284        )
13285    );
13286}
13287?>
13288<#3765>
13289<?php
13290$ilDB->manipulate(
13291    "UPDATE style_parameter SET " .
13292    " tag = " . $ilDB->quote("div", "text") .
13293    " WHERE class = " . $ilDB->quote("PageFrame", "text")
13294);
13295?>
13296<#3766>
13297<?php
13298$ilDB->manipulate(
13299    "UPDATE style_parameter SET " .
13300    " tag = " . $ilDB->quote("div", "text") .
13301    " WHERE class = " . $ilDB->quote("PageContainer", "text")
13302);
13303?>
13304<#3767>
13305<?php
13306$ilDB->manipulate(
13307    "DELETE FROM style_parameter WHERE " .
13308    " class = " . $ilDB->quote("PageContainer", "text") . " AND " .
13309    " parameter = " . $ilDB->quote("width", "text") . " AND " .
13310    " value = " . $ilDB->quote("100%", "text")
13311);
13312?>
13313<#3768>
13314<?php
13315$ilDB->manipulate(
13316    "DELETE FROM style_parameter WHERE " .
13317    " class = " . $ilDB->quote("PageContainer", "text") . " AND " .
13318    " parameter = " . $ilDB->quote("width", "text") . " AND " .
13319    " value = " . $ilDB->quote("100%", "text")
13320);
13321?>
13322<#3769>
13323<?php
13324$ilDB->manipulate(
13325    "UPDATE style_data SET " .
13326    " uptodate = " . $ilDB->quote(0, "integer")
13327);
13328?>
13329<#3770>
13330<?php
13331$ilDB->manipulate(
13332    "DELETE FROM style_parameter WHERE " .
13333    " class = " . $ilDB->quote("PageFrame", "text") . " AND " .
13334    " parameter = " . $ilDB->quote("width", "text") . " AND " .
13335    " value = " . $ilDB->quote("100%", "text")
13336);
13337?>
13338<#3771>
13339<?php
13340$ilDB->manipulate(
13341    "UPDATE style_data SET " .
13342    " uptodate = " . $ilDB->quote(0, "integer")
13343);
13344?>
13345<#3772>
13346<?php
13347    $ilCtrlStructureReader->getStructure();
13348?>
13349<#3773>
13350<?php
13351    $ilCtrlStructureReader->getStructure();
13352?>
13353<#3774>
13354<?php
13355
13356$bcset = $ilDB->query("SELECT obj_id FROM object_data" .
13357        " WHERE type = " . $ilDB->quote("rolt", "text") .
13358        " AND title = " . $ilDB->quote("il_blog_contributor", "text"));
13359$bcrow = $ilDB->fetchAssoc($bcset);
13360$blog_contributor_tpl_id = $bcrow["obj_id"];
13361if ($blog_contributor_tpl_id) {
13362    $bcset = $ilDB->query("SELECT ops_id FROM rbac_templates" .
13363        " WHERE rol_id = " . $ilDB->quote($blog_contributor_tpl_id, "integer") .
13364        " AND type = " . $ilDB->quote("blog", "text"));
13365    while ($bcrow = $ilDB->fetchAssoc($bcset)) {
13366        $bc_ops_ids[] = $bcrow["ops_id"];
13367    }
13368
13369    include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
13370
13371    if (!in_array(ilDBUpdateNewObjectType::RBAC_OP_VISIBLE, $bc_ops_ids)) {
13372        $ilDB->manipulateF(
13373            "INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" .
13374            " VALUES (%s, %s, %s, %s)",
13375            array("integer", "text", "integer", "integer"),
13376            array($blog_contributor_tpl_id, "blog", ilDBUpdateNewObjectType::RBAC_OP_VISIBLE, 8)
13377        );
13378    }
13379
13380    if (!in_array(ilDBUpdateNewObjectType::RBAC_OP_READ, $bc_ops_ids)) {
13381        $ilDB->manipulateF(
13382            "INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" .
13383            " VALUES (%s, %s, %s, %s)",
13384            array("integer", "text", "integer", "integer"),
13385            array($blog_contributor_tpl_id, "blog", ilDBUpdateNewObjectType::RBAC_OP_READ, 8)
13386        );
13387    }
13388}
13389
13390?>
13391<#3775>
13392<?php
13393    $fields = array(
13394        'session_id' => array('type' => 'text', 'length' => 80, 'notnull' => true),
13395        'component_id' => array('type' => 'text', 'length' => 30, 'notnull' => true),
13396        'vkey' => array('type' => 'text', 'length' => 50, 'notnull' => true),
13397        'value' => array('type' => 'text', 'length' => 1000, 'notnull' => false),
13398    );
13399    $ilDB->createTable('usr_sess_istorage', $fields);
13400    $ilDB->addPrimaryKey('usr_sess_istorage', array('session_id', 'component_id', 'vkey'));
13401?>
13402<#3776>
13403<?php
13404
13405$ilDB->dropTableColumn('media_item', 'highlight_class');
13406$ilDB->dropTableColumn('media_item', 'highlight_mode');
13407
13408?>
13409<#3777>
13410<?php
13411if (!$ilDB->tableColumnExists('map_area', 'highlight_mode')) {
13412    $ilDB->addTableColumn("map_area", "highlight_mode", array(
13413        "type" => "text",
13414        "notnull" => false,
13415        "length" => 8,
13416        "fixed" => false));
13417}
13418?>
13419<#3778>
13420<?php
13421if (!$ilDB->tableColumnExists('map_area', 'highlight_class')) {
13422    $ilDB->addTableColumn("map_area", "highlight_class", array(
13423        "type" => "text",
13424        "notnull" => false,
13425        "length" => 8,
13426        "fixed" => false));
13427}
13428?>
13429<#3779>
13430<?php
13431if (!$ilDB->tableColumnExists('il_media_cast_data', 'viewmode')) {
13432    $ilDB->addTableColumn("il_media_cast_data", "viewmode", array(
13433        "type" => "text",
13434        "notnull" => false,
13435        "length" => 20));
13436}
13437?>
13438<#3780>
13439<?php
13440$ilDB->addTableColumn('qpl_a_essay', 'tmp_points', array('type' => 'float', 'notnull' => false));
13441$ilDB->query('UPDATE qpl_a_essay SET tmp_points = points');
13442$ilDB->dropTableColumn('qpl_a_essay', 'points');
13443$ilDB->addTableColumn('qpl_a_essay', 'points', array('type' => 'float', 'notnull' => false));
13444$ilDB->query('UPDATE qpl_a_essay SET points = tmp_points');
13445$ilDB->dropTableColumn('qpl_a_essay', 'tmp_points');
13446?>
13447
13448<#3781>
13449<?php
13450
13451if ($ilDB->tableExists('cal_notification')) {
13452    return true;
13453}
13454
13455// Create notification table
13456$ilDB->createTable(
13457    'cal_notification',
13458    array(
13459    'notification_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true),
13460    'cal_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true, 'default' => 0),
13461    'user_type' => array('type' => 'integer', 'length' => 1, 'notnull' => true, 'default' => 0),
13462    'user_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true, 'default' => 0),
13463    'email' => array('type' => 'text', 'length' => 64, 'notnull' => false)
13464        )
13465);
13466$ilDB->addPrimaryKey(
13467    'cal_notification',
13468    array(
13469    'notification_id'
13470        )
13471);
13472$ilDB->createSequence('cal_notification');
13473$ilDB->addIndex('cal_notification', array('cal_id'), 'i1');
13474
13475?>
13476<#3782>
13477<?php
13478$ilDB->manipulate(
13479    "UPDATE object_data SET " .
13480    " type = " . $ilDB->quote("lm", "text") . "," .
13481    " import_id = " . $ilDB->quote("lm_migrated", "text") .
13482    " WHERE type = " . $ilDB->quote("dbk", "text")
13483);
13484?>
13485<#3783>
13486<?php
13487$ilDB->manipulate(
13488    "UPDATE page_object SET " .
13489    " parent_type = " . $ilDB->quote("lm", "text") .
13490    " WHERE parent_type = " . $ilDB->quote("dbk", "text")
13491);
13492?>
13493<#3784>
13494<?php
13495    $ilCtrlStructureReader->getStructure();
13496?>
13497<#3785>
13498<?php
13499$setting = new ilSetting();
13500$prevent_reuse = $setting->get('prevent_reuse_of_loginnames');
13501
13502$new_setting = 1;
13503
13504if (!$prevent_reuse) {
13505    $new_setting = 1;
13506} else {
13507    $new_setting = 0;
13508}
13509$setting->set('reuse_of_loginnames', $new_setting);
13510
13511$setting->delete('prevent_reuse_of_loginnames');
13512?>
13513<#3786>
13514<?php
13515if (!$ilDB->tableColumnExists('crs_settings', 'auto_notification')) {
13516    $ilDB->addTableColumn(
13517        'crs_settings',
13518        'auto_notification',
13519        array(	'type' => 'integer',
13520            'length' => 1,
13521            'notnull' => true,
13522            'default' => 1
13523    )
13524    );
13525}
13526$ilDB->update(
13527    'crs_settings',
13528    array('auto_notification' => array('integer', 0)),
13529    array('auto_noti_disabled' => array('integer', 1))
13530);
13531
13532$ilDB->dropTableColumn('crs_settings', 'auto_noti_disabled');
13533?>
13534<#3787>
13535<?php
13536    $ilCtrlStructureReader->getStructure();
13537?>
13538<#3788>
13539<?php
13540if ($ilDB->sequenceExists('svy_inv_grp')) {
13541    $ilDB->dropSequence('svy_inv_grp');
13542}
13543?>
13544<#3789>
13545<?php
13546if ($ilDB->sequenceExists('svy_qst_mat')) {
13547    $ilDB->dropSequence('svy_qst_mat');
13548}
13549?>
13550<#3790>
13551<?php
13552
13553include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
13554
13555$trac_type_id = ilDBUpdateNewObjectType::getObjectTypeId('trac');
13556if ($trac_type_id) {
13557    $ops_id = ilDBUpdateNewObjectType::addCustomRBACOperation('lp_other_users', 'See LP Data Of Other Users', 'object', 250);
13558    if ($ops_id) {
13559        ilDBUpdateNewObjectType::addRBACOperation($trac_type_id, $ops_id);
13560    }
13561}
13562?>
13563
13564<#3791>
13565<?php
13566
13567if (!$ilDB->tableColumnExists('cal_categories', 'remote_sync')) {
13568    $ilDB->addTableColumn(
13569        'cal_categories',
13570        'remote_sync',
13571        array(
13572            'type' => 'timestamp',
13573            'notnull' => false
13574    )
13575    );
13576}
13577?>
13578
13579<#3792>
13580<?php
13581
13582if (!$ilDB->tableColumnExists('ecs_cms_data', 'deleted')) {
13583    $ilDB->addTableColumn(
13584        'ecs_cms_data',
13585        'deleted',
13586        array(
13587                'type' => 'integer',
13588                'length' => 1,
13589                'default' => 0,
13590                'notnull' => true)
13591    );
13592}
13593?>
13594<#3793>
13595<?php
13596    $ilCtrlStructureReader->getStructure();
13597?>
13598<#3794>
13599<?php
13600if (!$ilDB->tableColumnExists('tst_tests', 'pass_deletion_allowed')) {
13601    $ilDB->addTableColumn('tst_tests', 'pass_deletion_allowed', array(
13602            'type' => 'integer',
13603            'length' => 4,
13604            'notnull' => true,
13605            'default' => 0
13606    ));
13607}
13608?>
13609
13610<#3795>
13611<?php
13612    // register new object type 'ecss' for ECS administration
13613    $id = $ilDB->nextId("object_data");
13614    $ilDB->manipulateF(
13615        "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
13616        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
13617        array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
13618        array($id, "typ", "ecss", "ECS Administration", -1, ilUtil::now(), ilUtil::now())
13619    );
13620    $typ_id = $id;
13621
13622    // create object data entry
13623    $id = $ilDB->nextId("object_data");
13624    $ilDB->manipulateF(
13625        "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
13626        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
13627        array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
13628        array($id, "ecss", "__ECSSettings", "ECS Administration", -1, ilUtil::now(), ilUtil::now())
13629    );
13630
13631    // create object reference entry
13632    $ref_id = $ilDB->nextId('object_reference');
13633    $res = $ilDB->manipulateF(
13634        "INSERT INTO object_reference (ref_id, obj_id) VALUES (%s, %s)",
13635        array("integer", "integer"),
13636        array($ref_id, $id)
13637    );
13638
13639    // put in tree
13640    $tree = new ilTree(ROOT_FOLDER_ID);
13641    $tree->insertNode($ref_id, SYSTEM_FOLDER_ID);
13642
13643    // add rbac operations
13644    // 1: edit_permissions, 2: visible, 3: read, 4:write
13645    $ilDB->manipulateF(
13646        "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
13647        array("integer", "integer"),
13648        array($typ_id, 1)
13649    );
13650    $ilDB->manipulateF(
13651        "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
13652        array("integer", "integer"),
13653        array($typ_id, 2)
13654    );
13655    $ilDB->manipulateF(
13656        "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
13657        array("integer", "integer"),
13658        array($typ_id, 3)
13659    );
13660    $ilDB->manipulateF(
13661        "INSERT INTO rbac_ta (typ_id, ops_id) VALUES (%s, %s)",
13662        array("integer", "integer"),
13663        array($typ_id, 4)
13664    );
13665?>
13666<#3796>
13667<?php
13668    $ilCtrlStructureReader->getStructure();
13669?>
13670<#3797>
13671<?php
13672if ($ilDB->tableColumnExists('cmi_objective', 'id')) {
13673    $ilDB->modifyTableColumn('cmi_objective', 'id', array(
13674                                                        'type' => 'text',
13675                                                        'length' => 4000,
13676                                                        'notnull' => false,
13677                                                        'default' => null
13678                                                    ));
13679}
13680?>
13681<#3798>
13682<?php
13683include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
13684
13685$setting = new ilSetting();
13686$chtr_perms = $setting->get("ilchtrperms");
13687if (!$chtr_perms) {
13688    $type_id = ilDBUpdateNewObjectType::getObjectTypeId('chtr');
13689
13690    if ($type_id) {
13691        ilDBUpdateNewObjectType::addRBACOperations(
13692            $type_id,
13693            array(
13694                ilDBUpdateNewObjectType::RBAC_OP_DELETE,
13695                ilDBUpdateNewObjectType::RBAC_OP_COPY
13696            )
13697        );
13698    }
13699
13700    $setting->set("ilchtrperms", 1);
13701}
13702?>
13703<#3799>
13704<?php
13705
13706include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
13707$grp_type_id = ilDBUpdateNewObjectType::getObjectTypeId('grp');
13708if ($grp_type_id) {
13709    $ops_id = ilDBUpdateNewObjectType::getCustomRBACOperationId('create_crsr');
13710    ilDBUpdateNewObjectType::addRBACOperation($grp_type_id, $ops_id);
13711
13712    $ops_id = ilDBUpdateNewObjectType::getCustomRBACOperationId('create_catr');
13713    ilDBUpdateNewObjectType::addRBACOperation($grp_type_id, $ops_id);
13714}
13715
13716?>
13717<#3800>
13718<?php
13719    $ilCtrlStructureReader->getStructure();
13720?>
13721<#3801>
13722<?php
13723
13724include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
13725$ops_id = ilDBUpdateNewObjectType::getCustomRBACOperationId('copy');
13726ilDBUpdateNewObjectType::deleteRBACOperation('rcat', $ops_id);
13727
13728?>
13729<#3802>
13730<?php
13731    $ilCtrlStructureReader->getStructure();
13732?>
13733
13734<#3803>
13735<?php
13736
13737    if (!$ilDB->tableExists('ecs_crs_mapping_atts')) {
13738        $fields = array(
13739            'id' => array('notnull' => true,'length' => 4,'type' => 'integer'),
13740            "sid" => array("notnull" => true,"length" => 4,"type" => "integer"),
13741            "mid" => array("notnull" => true,"length" => 4,"type" => "integer"),
13742            "name" => array("notnull" => false,'length' => 64, "type" => "text")
13743        );
13744        $ilDB->createTable("ecs_crs_mapping_atts", $fields);
13745        $ilDB->createSequence('ecs_crs_mapping_atts');
13746        $ilDB->addPrimaryKey('ecs_crs_mapping_atts', array('id'));
13747    }
13748?>
13749<#3804>
13750<?php
13751
13752    if (!$ilDB->tableExists('ecs_cmap_rule')) {
13753        $fields = array(
13754            'rid' => array('notnull' => true,'length' => 4,'type' => 'integer'),
13755            "sid" => array("notnull" => true,"length" => 4,"type" => "integer"),
13756            "mid" => array("notnull" => true,"length" => 4,"type" => "integer"),
13757            "attribute" => array("notnull" => false,'length' => 64, "type" => "text"),
13758            "ref_id" => array("notnull" => true,"length" => 4,"type" => "integer"),
13759            "is_filter" => array("notnull" => true,"length" => 1,"type" => "integer"),
13760            "filter" => array("notnull" => false,"length" => 512,"type" => "text"),
13761            "create_subdir" => array("notnull" => true,"length" => 1,"type" => "integer"),
13762            "subdir_type" => array("notnull" => true,"length" => 1,"type" => "integer"),
13763            "directory" => array("notnull" => false,"length" => 64,"type" => "text")
13764        );
13765
13766        $ilDB->createTable("ecs_cmap_rule", $fields);
13767        $ilDB->createSequence('ecs_cmap_rule');
13768        $ilDB->addPrimaryKey('ecs_cmap_rule', array('rid'));
13769    }
13770?>
13771<#3805>
13772<?php
13773    $ilCtrlStructureReader->getStructure();
13774?>
13775<#3806>
13776<?php
13777if (!$ilDB->tableColumnExists('il_dcl_table', 'export_enabled')) {
13778    $ilDB->addTableColumn(
13779        'il_dcl_table',
13780        'export_enabled',
13781        array(
13782            'type' => 'integer',
13783            'length' => 1,
13784        )
13785    );
13786}
13787?>
13788<#3807>
13789<?php
13790
13791    if (!$ilDB->tableExists('ecs_course_assignments')) {
13792        $fields = array(
13793            'id' => array('notnull' => true,'length' => 4,'type' => 'integer'),
13794            "sid" => array("notnull" => true,"length" => 4,"type" => "integer"),
13795            "mid" => array("notnull" => true,"length" => 4,"type" => "integer"),
13796            "cms_id" => array("notnull" => true,'length' => 4, "type" => "integer"),
13797            "obj_id" => array("notnull" => true,"length" => 4,"type" => "integer"),
13798            "usr_id" => array("notnull" => false,"length" => 64,"type" => "text"),
13799            "status" => array("notnull" => true,"length" => 1,"type" => "integer")
13800        );
13801
13802        $ilDB->createTable("ecs_course_assignments", $fields);
13803        $ilDB->createSequence('ecs_course_assignments');
13804        $ilDB->addPrimaryKey('ecs_course_assignments', array('id'));
13805    }
13806?>
13807<#3808>
13808<?php
13809if (!$ilDB->tableColumnExists('addressbook_mlist', 'lmode')) {
13810    $ilDB->addTableColumn(
13811        'addressbook_mlist',
13812        'lmode',
13813        array(
13814            'type' => 'integer',
13815            'length' => 1,
13816            'notnull' => true,
13817            'default' => 1
13818        )
13819    );
13820}
13821?>
13822<#3809>
13823<?php
13824$setting = new ilSetting();
13825$iltosobjinstall = $setting->get('iltosobjinstall');
13826if (!$iltosobjinstall) {
13827    include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
13828    $tos_type_id = ilDBUpdateNewObjectType::addNewType('tos', 'Terms of Service');
13829
13830    $rbac_ops = array(
13831        ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
13832        ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
13833        ilDBUpdateNewObjectType::RBAC_OP_READ,
13834        ilDBUpdateNewObjectType::RBAC_OP_WRITE
13835    );
13836    ilDBUpdateNewObjectType::addRBACOperations($tos_type_id, $rbac_ops);
13837
13838    $obj_id = $ilDB->nextId('object_data');
13839    $ilDB->insert(
13840        'object_data',
13841        array(
13842            'obj_id' => array('integer', $obj_id),
13843            'type' => array('text', 'tos'),
13844            'title' => array('text', 'Terms of Service'),
13845            'description' => array('text', 'Terms of Service: Settings'),
13846            'owner' => array('integer', -1),
13847            'create_date' => array('timestamp', date('Y-m-d H:i:s')),
13848            'last_update' => array('timestamp', date('Y-m-d H:i:s'))
13849        )
13850    );
13851
13852    $ref_id = $ilDB->nextId('object_reference');
13853    $query = "
13854		INSERT INTO object_reference
13855		(ref_id, obj_id)
13856		VALUES(" . $ilDB->quote($ref_id, 'integer') . ", " . $ilDB->quote($obj_id, 'integer') . ")
13857	";
13858    $ilDB->manipulate($query);
13859
13860    $tree = new ilTree(ROOT_FOLDER_ID);
13861    $tree->insertNode($ref_id, SYSTEM_FOLDER_ID);
13862
13863    $setting->set('iltosobjinstall', 1);
13864}
13865?>
13866<#3810>
13867<?php
13868$setting = new ilSetting();
13869$setting->set('tos_status', 1);
13870?>
13871<#3811>
13872<?php
13873$ilCtrlStructureReader->getStructure();
13874?>
13875<#3812>
13876<?php
13877if (!$ilDB->tableExists('tos_versions')) {
13878    $fields = array(
13879        'id' => array(
13880            'type' => 'integer',
13881            'length' => 4,
13882            'notnull' => true,
13883            'default' => 0
13884        ),
13885        'lng' => array(
13886            'type' => 'text',
13887            'notnull' => false,
13888            'length' => 2,
13889            'default' => null
13890        ),
13891        'path' => array(
13892            'type' => 'text',
13893            'notnull' => false,
13894            'length' => 4000,
13895            'default' => null
13896        ),
13897        'text' => array(
13898            'type' => 'clob',
13899            'notnull' => false,
13900            'default' => null
13901        ),
13902        'hash' => array(
13903            'type' => 'text',
13904            'notnull' => false,
13905            'length' => 32,
13906            'default' => null
13907        ),
13908        'ts' => array(
13909            'type' => 'integer',
13910            'length' => 4,
13911            'notnull' => true,
13912            'default' => 0
13913        )
13914    );
13915    $ilDB->createTable('tos_versions', $fields);
13916    $ilDB->addPrimaryKey('tos_versions', array('id'));
13917    $ilDB->createSequence('tos_versions');
13918    $ilDB->addIndex('tos_versions', array('hash', 'lng'), 'i1');
13919}
13920?>
13921<#3813>
13922<?php
13923if (!$ilDB->tableExists('tos_acceptance_track')) {
13924    $fields = array(
13925        'tosv_id' => array(
13926            'type' => 'integer',
13927            'length' => 4,
13928            'notnull' => true,
13929            'default' => 0
13930        ),
13931        'usr_id' => array(
13932            'type' => 'integer',
13933            'length' => 4,
13934            'notnull' => true,
13935            'default' => 0
13936        ),
13937        'ts' => array(
13938            'type' => 'integer',
13939            'length' => 4,
13940            'notnull' => true,
13941            'default' => 0
13942        )
13943    );
13944    $ilDB->createTable('tos_acceptance_track', $fields);
13945    $ilDB->addPrimaryKey('tos_acceptance_track', array('tosv_id', 'usr_id', 'ts'));
13946    $ilDB->createSequence('tos_acceptance_track');
13947    $ilDB->addIndex('tos_acceptance_track', array('usr_id', 'ts'), 'i1');
13948}
13949?>
13950<#3814>
13951<?php
13952
13953    if (!$ilDB->tableColumnExists('ecs_import', 'sub_id')) {
13954        $ilDB->addTableColumn(
13955            'ecs_import',
13956            'sub_id',
13957            array(
13958                    "type" => "text",
13959                    "notnull" => false,
13960                    "length" => 64
13961                )
13962        );
13963    }
13964?>
13965<#3815>
13966	<?php
13967    if (!$ilDB->tableColumnExists('frm_settings', 'thread_sorting')) {
13968        $ilDB->addTableColumn("frm_settings", "thread_sorting", array(
13969            "type" => "integer",
13970            "length" => 4,
13971            "default" => 0,
13972            "notnull" => true,
13973        ));
13974    }
13975    ?>
13976<#3816>
13977<?php
13978    if (!$ilDB->tableColumnExists('frm_threads', 'thread_sorting')) {
13979        $ilDB->addTableColumn("frm_threads", "thread_sorting", array(
13980            "type" => "integer",
13981            "length" => 4,
13982            "default" => 0,
13983            "notnull" => true,
13984        ));
13985    }
13986?>
13987<#3817>
13988<?php
13989    if (!$ilDB->tableColumnExists('addressbook', 'auto_update')) {
13990        $ilDB->addTableColumn("addressbook", "auto_update", array(
13991            "type" => "integer",
13992            "length" => 4,
13993            "default" => 1,
13994            "notnull" => true,
13995        ));
13996    }
13997?>
13998<#3818>
13999<?php
14000if (!$ilDB->tableColumnExists('tos_versions', 'src_type')) {
14001    $ilDB->addTableColumn('tos_versions', 'src_type', array(
14002        'type' => 'integer',
14003        'length' => 1,
14004        'default' => 0,
14005        'notnull' => true,
14006    ));
14007}
14008?>
14009<#3819>
14010<?php
14011if ($ilDB->tableColumnExists('tos_versions', 'path')) {
14012    $ilDB->renameTableColumn('tos_versions', 'path', 'src');
14013}
14014?>
14015<#3820>
14016<?php
14017
14018    if (!$ilDB->tableColumnExists('ecs_course_assignments', 'cms_sub_id')) {
14019        $ilDB->addTableColumn(
14020            'ecs_course_assignments',
14021            'cms_sub_id',
14022            array(
14023                    "type" => "integer",
14024                    "notnull" => false,
14025                    "length" => 4,
14026                    'default' => 0
14027                )
14028        );
14029    }
14030?>
14031<#3821>
14032<?php
14033
14034    if (!$ilDB->tableColumnExists('ecs_import', 'ecs_id')) {
14035        $ilDB->addTableColumn(
14036            'ecs_import',
14037            'ecs_id',
14038            array(
14039                    "type" => "integer",
14040                    "notnull" => false,
14041                    "length" => 4,
14042                    'default' => 0
14043                )
14044        );
14045    }
14046
14047
14048
14049?>
14050<#3822>
14051<?php
14052    if (!$ilDB->tableColumnExists('qpl_a_ordering', 'depth')) {
14053        $ilDB->addTableColumn(
14054            'qpl_a_ordering',
14055            'depth',
14056            array('type' => 'integer',
14057                  'length' => 4,
14058                  'notnull' => true,
14059                  'default' => 0)
14060        );
14061    }
14062?>
14063<#3823>
14064<?php
14065
14066    if (!$ilDB->tableExists('cron_job')) {
14067        $fields = array(
14068            "job_id" => array("notnull" => true,"length" => 50,"type" => "text"),
14069            "component" => array("notnull" => false,"length" => 200,"type" => "text"),
14070            "schedule_type" => array("notnull" => false,"length" => 1,"type" => "integer"),
14071            "schedule_value" => array("notnull" => false,"length" => 4,"type" => "integer"),
14072            "job_status" => array("notnull" => false,"length" => 1, "type" => "integer"),
14073            "job_status_user_id" => array("notnull" => false,"length" => 4,"type" => "integer"),
14074            "job_status_type" => array("notnull" => false,"length" => 1,"type" => "integer"),
14075            "job_status_ts" => array("notnull" => false,"length" => 4,"type" => "integer"),
14076            "job_result_status" => array("notnull" => false,"length" => 1,"type" => "integer"),
14077            "job_result_user_id" => array("notnull" => false,"length" => 4,"type" => "integer"),
14078            "job_result_code" => array("notnull" => false,"length" => 64,"type" => "text"),
14079            "job_result_message" => array("notnull" => false,"length" => 400,"type" => "text"),
14080            "job_result_type" => array("notnull" => false,"length" => 1,"type" => "integer"),
14081            "job_result_ts" => array("notnull" => false,"length" => 4,"type" => "integer")
14082        );
14083
14084        $ilDB->createTable("cron_job", $fields);
14085        $ilDB->addPrimaryKey("cron_job", array("job_id"));
14086    }
14087
14088?>
14089<#3824>
14090<?php
14091
14092if (!$ilDB->tableColumnExists('cron_job', 'running_ts')) {
14093    $ilDB->addTableColumn(
14094        'cron_job',
14095        'class',
14096        array('type' => 'text', 'length' => 255, 'notnull' => false)
14097    );
14098    $ilDB->addTableColumn(
14099        'cron_job',
14100        'path',
14101        array('type' => 'text', 'length' => 400, 'notnull' => false)
14102    );
14103
14104    $ilDB->addTableColumn(
14105        'cron_job',
14106        'running_ts',
14107        array('type' => 'integer', 'length' => 4, 'notnull' => false)
14108    );
14109}
14110
14111?>
14112<#3825>
14113<?php
14114
14115if (!$ilDB->tableColumnExists('cron_job', 'job_result_dur')) {
14116    $ilDB->addTableColumn(
14117        'cron_job',
14118        'job_result_dur',
14119        array('type' => 'integer', 'length' => 4, 'notnull' => false)
14120    );
14121}
14122
14123?>
14124<#3826>
14125<?php
14126
14127if (!$ilDB->tableColumnExists('cron_job', 'alive_ts')) {
14128    $ilDB->addTableColumn(
14129        'cron_job',
14130        'alive_ts',
14131        array('type' => 'integer', 'length' => 4, 'notnull' => false)
14132    );
14133}
14134
14135?>
14136<#3827>
14137<?php
14138    $ilCtrlStructureReader->getStructure();
14139?>
14140<#3828>
14141<?php
14142
14143if (!$ilDB->tableColumnExists('qpl_questions', 'add_cont_edit_mode')) {
14144    $ilDB->addTableColumn('qpl_questions', 'add_cont_edit_mode', array(
14145        'type' => 'text', 'length' => 16, 'notnull' => false, 'default' => null
14146    ));
14147}
14148
14149$ilDB->modifyTableColumn('qpl_hints', 'qht_hint_text', array(
14150        'type' => 'text', 'length' => 4000, 'fixed' => false, 'notnull' => false, 'default' => null
14151));
14152
14153?>
14154<#3829>
14155<?php
14156
14157if (!$ilDB->tableExists('qpl_fb_specific')) {
14158    // create new feedback table for all answer specific feedbacks,
14159    // regardless from question type
14160
14161    $ilDB->createTable('qpl_fb_specific', array(
14162        'feedback_id' => array(
14163            'type' => 'integer',
14164            'length' => 4,
14165            'notnull' => true
14166        ),
14167        'question_fi' => array(
14168            'type' => 'integer',
14169            'length' => 4,
14170            'notnull' => true
14171        ),
14172        'answer' => array(
14173            'type' => 'integer',
14174            'length' => 4,
14175            'notnull' => true
14176        ),
14177        'feedback' => array(
14178            'type' => 'text',
14179            'length' => 4000,
14180            'notnull' => false
14181        ),
14182        'tstamp' => array(
14183            'type' => 'integer',
14184            'length' => 4,
14185            'notnull' => true
14186        )
14187    ));
14188
14189    $ilDB->createSequence('qpl_fb_specific');
14190
14191    $ilDB->addPrimaryKey('qpl_fb_specific', array('feedback_id'));
14192
14193    $ilDB->addIndex('qpl_fb_specific', array('question_fi'), 'i1');
14194}
14195
14196?>
14197<#3830>
14198<?php
14199
14200if ($ilDB->tableExists('qpl_fb_cloze')) {
14201    $res = $ilDB->query("SELECT * FROM qpl_fb_cloze");
14202
14203    while ($row = $ilDB->fetchAssoc($res)) {
14204        $feedbackId = $ilDB->nextId('qpl_fb_specific');
14205
14206        $ilDB->insert('qpl_fb_specific', array(
14207            'feedback_id' => array('integer', $feedbackId),
14208            'question_fi' => array('integer', $row['question_fi']),
14209            'answer' => array('integer', $row['answer']),
14210            'feedback' => array('text', $row['feedback']),
14211            'tstamp' => array('integer', $row['tstamp'])
14212        ));
14213    }
14214
14215    $ilDB->dropTable('qpl_fb_cloze');
14216}
14217
14218?>
14219<#3831>
14220<?php
14221
14222if ($ilDB->tableExists('qpl_fb_errortext')) {
14223    $res = $ilDB->query("SELECT * FROM qpl_fb_errortext");
14224
14225    while ($row = $ilDB->fetchAssoc($res)) {
14226        $feedbackId = $ilDB->nextId('qpl_fb_specific');
14227
14228        $ilDB->insert('qpl_fb_specific', array(
14229            'feedback_id' => array('integer', $feedbackId),
14230            'question_fi' => array('integer', $row['question_fi']),
14231            'answer' => array('integer', $row['answer']),
14232            'feedback' => array('text', $row['feedback']),
14233            'tstamp' => array('integer', $row['tstamp'])
14234        ));
14235    }
14236
14237    $ilDB->dropTable('qpl_fb_errortext');
14238}
14239
14240?>
14241<#3832>
14242<?php
14243
14244if ($ilDB->tableExists('qpl_fb_essay')) {
14245    $res = $ilDB->query("SELECT * FROM qpl_fb_essay");
14246
14247    while ($row = $ilDB->fetchAssoc($res)) {
14248        $feedbackId = $ilDB->nextId('qpl_fb_specific');
14249
14250        $ilDB->insert('qpl_fb_specific', array(
14251            'feedback_id' => array('integer', $feedbackId),
14252            'question_fi' => array('integer', $row['question_fi']),
14253            'answer' => array('integer', $row['answer']),
14254            'feedback' => array('text', $row['feedback']),
14255            'tstamp' => array('integer', $row['tstamp'])
14256        ));
14257    }
14258
14259    $ilDB->dropTable('qpl_fb_essay');
14260}
14261
14262?>
14263<#3833>
14264<?php
14265
14266if ($ilDB->tableExists('qpl_fb_imap')) {
14267    $res = $ilDB->query("SELECT * FROM qpl_fb_imap");
14268
14269    while ($row = $ilDB->fetchAssoc($res)) {
14270        $feedbackId = $ilDB->nextId('qpl_fb_specific');
14271
14272        $ilDB->insert('qpl_fb_specific', array(
14273            'feedback_id' => array('integer', $feedbackId),
14274            'question_fi' => array('integer', $row['question_fi']),
14275            'answer' => array('integer', $row['answer']),
14276            'feedback' => array('text', $row['feedback']),
14277            'tstamp' => array('integer', $row['tstamp'])
14278        ));
14279    }
14280
14281    $ilDB->dropTable('qpl_fb_imap');
14282}
14283
14284?>
14285<#3834>
14286<?php
14287
14288if ($ilDB->tableExists('qpl_fb_matching')) {
14289    $res = $ilDB->query("SELECT * FROM qpl_fb_matching");
14290
14291    while ($row = $ilDB->fetchAssoc($res)) {
14292        $feedbackId = $ilDB->nextId('qpl_fb_specific');
14293
14294        $ilDB->insert('qpl_fb_specific', array(
14295            'feedback_id' => array('integer', $feedbackId),
14296            'question_fi' => array('integer', $row['question_fi']),
14297            'answer' => array('integer', $row['answer']),
14298            'feedback' => array('text', $row['feedback']),
14299            'tstamp' => array('integer', $row['tstamp'])
14300        ));
14301    }
14302
14303    $ilDB->dropTable('qpl_fb_matching');
14304}
14305
14306?>
14307<#3835>
14308<?php
14309
14310if ($ilDB->tableExists('qpl_fb_mc')) {
14311    $res = $ilDB->query("SELECT * FROM qpl_fb_mc");
14312
14313    while ($row = $ilDB->fetchAssoc($res)) {
14314        $feedbackId = $ilDB->nextId('qpl_fb_specific');
14315
14316        $ilDB->insert('qpl_fb_specific', array(
14317            'feedback_id' => array('integer', $feedbackId),
14318            'question_fi' => array('integer', $row['question_fi']),
14319            'answer' => array('integer', $row['answer']),
14320            'feedback' => array('text', $row['feedback']),
14321            'tstamp' => array('integer', $row['tstamp'])
14322        ));
14323    }
14324
14325    $ilDB->dropTable('qpl_fb_mc');
14326}
14327
14328?>
14329<#3836>
14330<?php
14331
14332if ($ilDB->tableExists('qpl_fb_sc')) {
14333    $res = $ilDB->query("SELECT * FROM qpl_fb_sc");
14334
14335    while ($row = $ilDB->fetchAssoc($res)) {
14336        $feedbackId = $ilDB->nextId('qpl_fb_specific');
14337
14338        $ilDB->insert('qpl_fb_specific', array(
14339            'feedback_id' => array('integer', $feedbackId),
14340            'question_fi' => array('integer', $row['question_fi']),
14341            'answer' => array('integer', $row['answer']),
14342            'feedback' => array('text', $row['feedback']),
14343            'tstamp' => array('integer', $row['tstamp'])
14344        ));
14345    }
14346
14347    $ilDB->dropTable('qpl_fb_sc');
14348}
14349
14350?>
14351<#3837>
14352<?php
14353
14354$ilCtrlStructureReader->getStructure();
14355
14356?>
14357<#3838>
14358<?php
14359    $ilDB->manipulate("INSERT INTO il_dcl_datatype (id, title, ildb_type, storage_location) " .
14360    " VALUES (" .
14361    $ilDB->quote(10, "integer") . ", " . $ilDB->quote("referencelist", "text") . ", " . $ilDB->quote("integer", "text") . ", " . $ilDB->quote(2, "integer") .
14362    ")");
14363?>
14364<#3839>
14365<?php
14366$ilDB->manipulateF(
14367    "INSERT INTO il_dcl_datatype_prop (id,datatype_id,title,inputformat) VALUES " .
14368        " (%s,%s,%s,%s)",
14369    array("integer", "integer", "text", "integer"),
14370    array(11, 10, "table_id", 1)
14371);
14372?>
14373<#3840>
14374<?php
14375$ilDB->manipulate("DELETE FROM il_dcl_datatype WHERE id = " . $ilDB->quote(10, "integer"));
14376$ilDB->manipulate("DELETE FROM il_dcl_datatype_prop WHERE id = " . $ilDB->quote(11, "integer"));
14377$ilDB->manipulateF(
14378    "INSERT INTO il_dcl_datatype_prop (id,datatype_id,title,inputformat) VALUES " .
14379        " (%s,%s,%s,%s)",
14380    array("integer", "integer", "text", "integer"),
14381    array(11, 3, "multiple_selection", 4)
14382);
14383?>
14384
14385<#3841>
14386<?php
14387if (!$ilDB->tableColumnExists('il_dcl_datatype', 'sort')) {
14388    $ilDB->addTableColumn('il_dcl_datatype', 'sort', array(
14389        'type' => 'integer', 'length' => 2, 'notnull' => false, 'default' => 0
14390    ));
14391    $ilDB->manipulate("UPDATE il_dcl_datatype SET sort = " . $ilDB->quote(0, "integer") . " WHERE title=" . $ilDB->quote("text", "text"));
14392    $ilDB->manipulate("UPDATE il_dcl_datatype SET sort = " . $ilDB->quote(10, "integer") . " WHERE title=" . $ilDB->quote("integer", "text"));
14393    $ilDB->manipulate("UPDATE il_dcl_datatype SET sort = " . $ilDB->quote(20, "integer") . " WHERE title=" . $ilDB->quote("boolean", "text"));
14394    $ilDB->manipulate("UPDATE il_dcl_datatype SET sort = " . $ilDB->quote(30, "integer") . " WHERE title=" . $ilDB->quote("datetime", "text"));
14395    $ilDB->manipulate("UPDATE il_dcl_datatype SET sort = " . $ilDB->quote(40, "integer") . " WHERE title=" . $ilDB->quote("mob", "text"));
14396    $ilDB->manipulate("UPDATE il_dcl_datatype SET sort = " . $ilDB->quote(50, "integer") . " WHERE title=" . $ilDB->quote("file", "text"));
14397    $ilDB->manipulate("UPDATE il_dcl_datatype SET sort = " . $ilDB->quote(60, "integer") . " WHERE title=" . $ilDB->quote("reference", "text"));
14398    $ilDB->manipulate("UPDATE il_dcl_datatype SET sort = " . $ilDB->quote(70, "integer") . " WHERE title=" . $ilDB->quote("ILIAS_reference", "text"));
14399    $ilDB->manipulate("UPDATE il_dcl_datatype SET sort = " . $ilDB->quote(80, "integer") . " WHERE title=" . $ilDB->quote("rating", "text"));
14400}
14401?>
14402<#3842>
14403<?php
14404
14405if (!$ilDB->tableExists('il_bibl_data')) {
14406    $fields = array(
14407        'id' => array(
14408            'type' => 'integer',
14409            'length' => 4
14410        ),
14411        'filename' => array(
14412            'type' => 'text',
14413            'length' => 256
14414        ),
14415        'is_online' => array(
14416            'type' => 'integer',
14417            'length' => 1,
14418        ),
14419    );
14420    $ilDB->createTable('il_bibl_data', $fields);
14421    $ilDB->addPrimaryKey('il_bibl_data', array('id'));
14422}
14423?>
14424<#3843>
14425<?php
14426
14427if (!$ilDB->tableExists('il_bibl_entry')) {
14428    $fields = array(
14429        'data_id' => array(
14430                'type' => 'integer',
14431                'length' => 4
14432        ),
14433        'id' => array(
14434            'type' => 'integer',
14435            'length' => 4
14436        ),
14437        'type' => array(
14438            'type' => 'text',
14439            'length' => 128
14440        )
14441    );
14442    $ilDB->createTable('il_bibl_entry', $fields);
14443    $ilDB->addPrimaryKey('il_bibl_entry', array('id'));
14444}
14445?>
14446<#3844>
14447<?php
14448
14449if (!$ilDB->tableExists('il_bibl_attribute')) {
14450    $fields = array(
14451        'entry_id' => array(
14452            'type' => 'integer',
14453            'length' => 4
14454        ),
14455        'name' => array(
14456            'type' => 'text',
14457            'length' => 32
14458        ),
14459        'value' => array(
14460            'type' => 'text',
14461            'length' => 512
14462        ),
14463        'id' => array(
14464            'type' => 'integer',
14465            'length' => 4
14466        )
14467    );
14468    $ilDB->createTable('il_bibl_attribute', $fields);
14469    $ilDB->addPrimaryKey('il_bibl_attribute', array('id'));
14470}
14471?>
14472<#3845>
14473<?php
14474if (!$ilDB->sequenceExists('il_bibl_entry')) {
14475    $ilDB->createSequence('il_bibl_entry');
14476}
14477?>
14478<#3846>
14479<?php
14480if (!$ilDB->sequenceExists('il_bibl_attribute')) {
14481    $ilDB->createSequence('il_bibl_attribute');
14482}
14483?>
14484<#3847>
14485<?php
14486// create file upload directory for bibliographic module
14487$bibl_data_dir = ilUtil::getDataDir() . "/bibl";
14488ilUtil::makeDir($bibl_data_dir);
14489?>
14490<#3848>
14491<?php
14492if (!$ilDB->tableExists('il_bibl_overview_model')) {
14493    $fields = array(
14494        'ovm_id' => array(
14495            'type' => 'integer',
14496            'length' => 4
14497        ),
14498        'filetype' => array(
14499            'type' => 'text',
14500            'length' => 8
14501        ),
14502        'literature_type' => array(
14503            'type' => 'text',
14504            'length' => 32
14505        ),
14506        'pattern' => array(
14507            'type' => 'text',
14508            'length' => 512
14509        )
14510    );
14511    $ilDB->createTable('il_bibl_overview_model', $fields);
14512    $ilDB->addPrimaryKey('il_bibl_overview_model', array('ovm_id'));
14513}
14514?>
14515<#3849>
14516<?php
14517//fill bibliographic overview model default-patterns
14518//BibTeX
14519$ilDB->manipulateF(
14520    'INSERT INTO  il_bibl_overview_model (ovm_id, filetype, literature_type, pattern)
14521	VALUES(%s, %s, %s, %s)',
14522    array('integer', 'text', 'text', 'text'),
14523    array(1, 'bib', 'default', '[<strong>|bib_default_author|</strong>: ][|bib_default_title|. ]<Emph>[|bib_default_publisher|][, |bib_default_year|][, |bib_default_address|].</Emph>')
14524);
14525//RIS
14526$ilDB->manipulateF(
14527    'INSERT INTO  il_bibl_overview_model (ovm_id, filetype, literature_type, pattern)
14528	VALUES(%s, %s, %s, %s)',
14529    array('integer', 'text', 'text', 'text'),
14530    array(2, 'ris', 'default', '[<strong>|ris_default_a1|</strong>:][ |ris_default_t1|][: |ris_default_t2|]. <Emph>[|ris_default_pb|][, |ris_default_y1|][, |ris_default_cy|].</Emph>')
14531);
14532?>
14533<#3850>
14534<?php
14535include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
14536
14537$dcl_type_id = ilDBUpdateNewObjectType::addNewType('bibl', 'Bibliographic Object');
14538
14539$rbac_ops = array(
14540    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
14541    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
14542    ilDBUpdateNewObjectType::RBAC_OP_READ,
14543    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
14544    ilDBUpdateNewObjectType::RBAC_OP_DELETE,
14545    ilDBUpdateNewObjectType::RBAC_OP_COPY
14546);
14547ilDBUpdateNewObjectType::addRBACOperations($dcl_type_id, $rbac_ops);
14548
14549$parent_types = array('root', 'cat', 'crs', 'fold', 'grp');
14550ilDBUpdateNewObjectType::addRBACCreate('create_bibl', 'Create Bibliographic', $parent_types);
14551?>
14552<#3851>
14553<?php
14554$ilCtrlStructureReader->getStructure();
14555?>
14556<#3852>
14557<?php
14558$ilCtrlStructureReader->getStructure();
14559?>
14560<#3853>
14561<?php
14562//fill bibliographic overview model default-patterns
14563//BibTeX
14564    $ilDB->manipulateF(
14565        'UPDATE  il_bibl_overview_model SET filetype = %s, literature_type = %s, pattern = %s WHERE ovm_id = %s',
14566        array('text', 'text', 'text', 'integer'),
14567        array('bib', 'default', '[<strong>|bib_default_author|</strong>: ][|bib_default_title|. ]<Emph>[|bib_default_publisher|][, |bib_default_year|][, |bib_default_address|].</Emph>', 1)
14568    );
14569//RIS
14570    $ilDB->manipulateF(
14571        'UPDATE  il_bibl_overview_model SET filetype = %s, literature_type = %s, pattern = %s WHERE ovm_id = %s',
14572        array('text', 'text', 'text', 'integer'),
14573        array('ris', 'default', '[<strong>|ris_default_a1|</strong>:][ |ris_default_t1|][: |ris_default_t2|]. <Emph>[|ris_default_pb|][, |ris_default_y1|][, |ris_default_cy|].</Emph>',2)
14574    );
14575?>
14576
14577<#3854>
14578<?php
14579
14580// find all essay questions without keywords stored in qpl_a_essay
14581// and migrate them to scoring mode "NON" (keyword relation)
14582
14583$res = $ilDB->query("
14584	SELECT qstq.question_fi
14585
14586	FROM qpl_qst_essay qstq
14587
14588	LEFT JOIN qpl_a_essay qsta
14589	ON qstq.question_fi = qsta.question_fi
14590
14591	WHERE qsta.answer_id IS NULL
14592");
14593
14594$questionIds = array();
14595
14596while ($row = $ilDB->fetchAssoc($res)) {
14597    $questionIds[] = $row['question_fi'];
14598}
14599
14600$questionId__IN__questionIds = $ilDB->in('question_fi', $questionIds, false, 'integer');
14601
14602$query = "
14603	UPDATE qpl_qst_essay
14604	SET keyword_relation = %s
14605	WHERE $questionId__IN__questionIds
14606";
14607
14608$ilDB->manipulateF($query, array('text'), array('non'));
14609
14610?>
14611<#3855>
14612<?php
14613
14614// find all essay questions with exactly one keyword stored in qpl_a_essay
14615// and migrate them to scoring mode "ONE" (keyword relation)
14616
14617$query = "
14618	SELECT	qstq.question_fi,
14619			COUNT(qsta.answer_id) keywordscount,
14620			SUM(qsta.points) qst_points
14621
14622	FROM qpl_qst_essay qstq
14623
14624	INNER JOIN qpl_a_essay qsta
14625	ON qstq.question_fi = qsta.question_fi
14626
14627	WHERE qstq.keywords IS NOT NULL
14628
14629	GROUP BY qstq.question_fi
14630";
14631
14632$res = $ilDB->query($query);
14633
14634$questionPoints = array();
14635
14636while ($row = $ilDB->fetchAssoc($res)) {
14637    if ($row['keywordscount'] != 1) {
14638        continue;
14639    }
14640
14641    $questionPoints[$row['question_fi']] = $row['qst_points'];
14642}
14643
14644$questionId__IN__questionIds = $ilDB->in(
14645    'question_fi',
14646    array_keys($questionPoints),
14647    false,
14648    'integer'
14649);
14650
14651$query = "
14652	UPDATE qpl_qst_essay
14653	SET keyword_relation = %s
14654	WHERE $questionId__IN__questionIds
14655";
14656
14657$ilDB->manipulateF($query, array('text'), array('one'));
14658
14659$updateQuestionPoints = $ilDB->prepareManip(
14660    "UPDATE qpl_questions SET points = ? WHERE question_id = ?",
14661    array('integer', 'integer')
14662);
14663
14664foreach ($questionPoints as $questionId => $points) {
14665    $ilDB->execute($updateQuestionPoints, array($points, $questionId));
14666}
14667
14668?>
14669<#3856>
14670<?php
14671
14672// find all essay questions with more than one keywords stored in qpl_a_essay
14673// where only one of them has store points > 0
14674// and migrate them to scoring mode "ONE" (keyword relation)
14675
14676$query = "
14677	SELECT	qstq.question_fi,
14678			SUM(qsta.points) points_sum,
14679			MIN(qsta.points) points_min,
14680			MAX(qsta.points) points_max,
14681			COUNT(qsta.answer_id) keywordscount
14682
14683	FROM qpl_qst_essay qstq
14684
14685	LEFT JOIN qpl_a_essay qsta
14686	ON qstq.question_fi = qsta.question_fi
14687
14688	WHERE qstq.keywords IS NOT NULL
14689	AND qsta.answer_id IS NOT NULL
14690
14691	GROUP BY qstq.question_fi
14692";
14693
14694$res = $ilDB->queryF($query, array('integer'), array(0));
14695
14696$questionPoints = array();
14697
14698while ($row = $ilDB->fetchAssoc($res)) {
14699    if ($row['keywordscount'] <= 1) {
14700        continue;
14701    }
14702
14703    if ($row['points_sum'] != $row['points_max']) {
14704        continue;
14705    }
14706
14707    if ($row['points_min'] > 0) {
14708        continue;
14709    }
14710
14711    $questionPoints[$row['question_fi']] = $row['points_sum'];
14712}
14713
14714$questionId__IN__questionIds = $ilDB->in(
14715    'question_fi',
14716    array_keys($questionPoints),
14717    false,
14718    'integer'
14719);
14720
14721$query = "
14722	UPDATE qpl_qst_essay
14723	SET keyword_relation = %s
14724	WHERE $questionId__IN__questionIds
14725";
14726
14727$ilDB->manipulateF($query, array('text'), array('one'));
14728
14729$updateQuestionPoints = $ilDB->prepareManip(
14730    "UPDATE qpl_questions SET points = ? WHERE question_id = ?",
14731    array('integer', 'integer')
14732);
14733
14734foreach ($questionPoints as $questionId => $points) {
14735    $ilDB->execute($updateQuestionPoints, array($points, $questionId));
14736}
14737
14738?>
14739<#3857>
14740<?php
14741
14742    if (!$ilDB->tableColumnExists("ut_lp_collections", "lpmode")) {
14743        $ilDB->addTableColumn("ut_lp_collections", "lpmode", array(
14744            "type" => "integer",
14745            "notnull" => false,
14746            "length" => 1,
14747            "default" => 5));
14748    }
14749
14750?>
14751<#3858>
14752<?php
14753if (!$ilDB->tableExists('lm_read_event')) {
14754    $fields = array(
14755        'obj_id' => array(
14756            'type' => 'integer',
14757            'length' => 4,
14758            'notnull' => true,
14759            'default' => 0),
14760        'usr_id' => array(
14761            'type' => 'integer',
14762            'length' => 4,
14763            'notnull' => true,
14764            'default' => 0),
14765        'read_count' => array(
14766            'type' => 'integer',
14767            'length' => 4,
14768            'notnull' => true,
14769            'default' => 0),
14770        'spent_seconds' => array(
14771            'type' => 'integer',
14772            'length' => 4,
14773            'notnull' => true,
14774            'default' => 0),
14775        'last_access' => array(
14776            'type' => 'integer',
14777            'length' => 4,
14778            'notnull' => true,
14779            'default' => 0)
14780    );
14781    $ilDB->createTable('lm_read_event', $fields);
14782    $ilDB->addPrimaryKey('lm_read_event', array('obj_id', 'usr_id'));
14783}
14784?>
14785<#3859>
14786<?php
14787if (!$ilDB->tableExists('ut_lp_coll_manual')) {
14788    $fields = array(
14789        'obj_id' => array(
14790            'type' => 'integer',
14791            'length' => 4,
14792            'notnull' => true,
14793            'default' => 0),
14794        'usr_id' => array(
14795            'type' => 'integer',
14796            'length' => 4,
14797            'notnull' => true,
14798            'default' => 0),
14799        'subitem_id' => array(
14800            'type' => 'integer',
14801            'length' => 4,
14802            'notnull' => true,
14803            'default' => 0),
14804        'completed' => array(
14805            'type' => 'integer',
14806            'length' => 1,
14807            'notnull' => true,
14808            'default' => 0),
14809        'last_change' => array(
14810            'type' => 'integer',
14811            'length' => 4,
14812            'notnull' => true,
14813            'default' => 0)
14814    );
14815    $ilDB->createTable('ut_lp_coll_manual', $fields);
14816    $ilDB->addPrimaryKey('ut_lp_coll_manual', array('obj_id', 'usr_id', 'subitem_id'));
14817}
14818?>
14819<#3860>
14820<?php
14821    $ilCtrlStructureReader->getStructure();
14822?>
14823<#3861>
14824<?php
14825
14826    $query = 'UPDATE rbac_operations SET op_order = ' . $ilDB->quote(2500, 'integer') . ' WHERE operation = ' . $ilDB->quote('edit_userassignment', 'text');
14827    $ilDB->manipulate($query);
14828
14829?>
14830<#3862>
14831<?php
14832    // ensure that ID 1 is not used
14833    $ilDB->nextId("tax_node");
14834?>
14835<#3863>
14836<?php
14837
14838$base_path = ilUtil::getDataDir();
14839
14840$set = $ilDB->query("SELECT at.*,ea.exc_id" .
14841    " FROM exc_assignment ea" .
14842    " JOIN il_exc_team at ON (at.ass_id = ea.id)" .
14843    " WHERE ea.type = " . $ilDB->quote(4, "integer"));
14844while ($row = $ilDB->fetchAssoc($set)) {
14845    // see ilFileSystemStorage::_createPathFromId()
14846    $tpath = array();
14847    $tfound = false;
14848    $tnum = $row["exc_id"];
14849    for ($i = 3; $i > 0;$i--) {
14850        $factor = pow(100, $i);
14851        if (($tmp = (int) ($tnum / $factor)) or $tfound) {
14852            $tpath[] = $tmp;
14853            $tnum = $tnum % $factor;
14854            $tfound = true;
14855        }
14856    }
14857
14858    $ass_path = $base_path . "/ilExercise/";
14859    if (count($tpath)) {
14860        $ass_path .= (implode('/', $tpath) . '/');
14861    }
14862    $ass_path .= "exc_" . $row["exc_id"] . "/feedb_" . $row["ass_id"] . "/";
14863
14864    $team_path = $ass_path . "t" . $row["id"] . "/";
14865    $user_path = $ass_path . $row["user_id"] . "/";
14866
14867    foreach (glob($user_path . "*") as $ufile) {
14868        if (!is_dir($team_path)) {
14869            mkdir($team_path);
14870        }
14871        $tfile = $team_path . basename($ufile);
14872        if (!file_exists($tfile)) {
14873            copy($ufile, $tfile);
14874        }
14875    }
14876}
14877
14878?>
14879<#3864>
14880<?php
14881
14882if (!$ilDB->tableColumnExists('svy_svy', 'mode_360')) {
14883    $ilDB->addTableColumn('svy_svy', 'mode_360', array(
14884        'type' => 'integer',
14885        'length' => 1,
14886        'notnull' => true,
14887        'default' => 0));
14888}
14889
14890if (!$ilDB->tableColumnExists('svy_svy', 'mode_360_self_eval')) {
14891    $ilDB->addTableColumn('svy_svy', 'mode_360_self_eval', array(
14892        'type' => 'integer',
14893        'length' => 1,
14894        'notnull' => true,
14895        'default' => 0));
14896}
14897
14898if (!$ilDB->tableColumnExists('svy_svy', 'mode_360_self_rate')) {
14899    $ilDB->addTableColumn('svy_svy', 'mode_360_self_rate', array(
14900        'type' => 'integer',
14901        'length' => 1,
14902        'notnull' => true,
14903        'default' => 0));
14904}
14905
14906if (!$ilDB->tableColumnExists('svy_svy', 'mode_360_self_appr')) {
14907    $ilDB->addTableColumn('svy_svy', 'mode_360_self_appr', array(
14908        'type' => 'integer',
14909        'length' => 1,
14910        'notnull' => true,
14911        'default' => 0));
14912}
14913
14914if (!$ilDB->tableColumnExists('svy_svy', 'mode_360_results')) {
14915    $ilDB->addTableColumn('svy_svy', 'mode_360_results', array(
14916        'type' => 'integer',
14917        'length' => 1,
14918        'notnull' => true,
14919        'default' => 0));
14920}
14921
14922?>
14923<#3865>
14924<?php
14925
14926if (!$ilDB->tableExists("svy_360_appr")) {
14927    $fields = array(
14928        'obj_id' => array(
14929            'type' => 'integer',
14930            'length' => 4,
14931            'notnull' => true,
14932            'default' => 0),
14933        'user_id' => array(
14934            'type' => 'integer',
14935            'length' => 4,
14936            'notnull' => true,
14937            'default' => 0)
14938    );
14939    $ilDB->createTable('svy_360_appr', $fields);
14940    $ilDB->addPrimaryKey('svy_360_appr', array('obj_id', 'user_id'));
14941}
14942
14943?>
14944<#3866>
14945<?php
14946
14947if (!$ilDB->tableExists("svy_360_rater")) {
14948    $fields = array(
14949        'obj_id' => array(
14950            'type' => 'integer',
14951            'length' => 4,
14952            'notnull' => true,
14953            'default' => 0),
14954        'appr_id' => array(
14955            'type' => 'integer',
14956            'length' => 4,
14957            'notnull' => true,
14958            'default' => 0),
14959        'user_id' => array(
14960            'type' => 'integer',
14961            'length' => 4,
14962            'notnull' => true,
14963            'default' => 0),
14964        'anonymous_id' => array(
14965            'type' => 'integer',
14966            'length' => 4,
14967            'notnull' => true,
14968            'default' => 0)
14969    );
14970    $ilDB->createTable('svy_360_rater', $fields);
14971    $ilDB->addPrimaryKey('svy_360_rater', array('obj_id', 'appr_id', 'user_id', 'anonymous_id'));
14972}
14973
14974?>
14975<#3867>
14976<?php
14977
14978if (!$ilDB->tableColumnExists('svy_finished', 'appr_id')) {
14979    $ilDB->addTableColumn('svy_finished', 'appr_id', array(
14980        'type' => 'integer',
14981        'length' => 4,
14982        'notnull' => false,
14983        'default' => 0));
14984}
14985
14986?>
14987<#3868>
14988<?php
14989    $ilCtrlStructureReader->getStructure();
14990?>
14991<#3869>
14992<?php
14993
14994if (!$ilDB->tableExists("skl_profile")) {
14995    $fields = array(
14996        'id' => array(
14997            'type' => 'integer',
14998            'length' => 4,
14999            'notnull' => true),
15000        'title' => array(
15001            'type' => 'text',
15002            'length' => 200,
15003            'notnull' => false),
15004        'description' => array(
15005            'type' => 'text',
15006            'length' => 4000,
15007            'notnull' => false)
15008    );
15009    $ilDB->createTable('skl_profile', $fields);
15010    $ilDB->addPrimaryKey('skl_profile', array('id'));
15011}
15012
15013?>
15014<#3870>
15015<?php
15016
15017if (!$ilDB->tableExists("skl_profile_level")) {
15018    $fields = array(
15019        'profile_id' => array(
15020            'type' => 'integer',
15021            'length' => 4,
15022            'notnull' => true),
15023        'base_skill_id' => array(
15024            'type' => 'integer',
15025            'length' => 4,
15026            'notnull' => true),
15027        'tref_id' => array(
15028            'type' => 'integer',
15029            'length' => 4,
15030            'notnull' => true,
15031            'default' => 0),
15032        'level_id' => array(
15033            'type' => 'integer',
15034            'length' => 4,
15035            'notnull' => true)
15036    );
15037    $ilDB->createTable('skl_profile_level', $fields);
15038    $ilDB->addPrimaryKey('skl_profile_level', array('profile_id', 'tref_id', 'level_id'));
15039}
15040
15041?>
15042<#3871>
15043<?php
15044$ilDB->createSequence('skl_profile');
15045?>
15046<#3872>
15047<?php
15048$ilDB->dropPrimaryKey('skl_profile_level');
15049$ilDB->addPrimaryKey('skl_profile_level', array('profile_id', 'tref_id', 'base_skill_id'));
15050?>
15051<#3873>
15052<?php
15053
15054if (!$ilDB->tableExists("skl_profile_user")) {
15055    $fields = array(
15056        'profile_id' => array(
15057            'type' => 'integer',
15058            'length' => 4,
15059            'notnull' => true),
15060        'user_id' => array(
15061            'type' => 'integer',
15062            'length' => 4,
15063            'notnull' => true)
15064    );
15065    $ilDB->createTable('skl_profile_user', $fields);
15066    $ilDB->addPrimaryKey('skl_profile_user', array('profile_id', 'user_id'));
15067}
15068
15069?>
15070<#3874>
15071<?php
15072    $ilCtrlStructureReader->getStructure();
15073?>
15074<#3875>
15075<?php
15076    $fields = array(
15077        'base_skill_id' => array(
15078            'type' => 'integer',
15079            'length' => 4,
15080            'notnull' => true),
15081        'tref_id' => array(
15082            'type' => 'integer',
15083            'length' => 4,
15084            'notnull' => true),
15085        'level_id' => array(
15086            'type' => 'integer',
15087            'length' => 4,
15088            'notnull' => true,
15089            'default' => 0),
15090        'rep_ref_id' => array(
15091            'type' => 'integer',
15092            'length' => 4,
15093            'notnull' => true),
15094        'imparting' => array(
15095            'type' => 'integer',
15096            'length' => 1,
15097            'notnull' => true,
15098            'default' => 0),
15099        'ltrigger' => array(
15100            'type' => 'integer',
15101            'length' => 1,
15102            'notnull' => true,
15103            'default' => 0)
15104    );
15105    $ilDB->createTable('skl_skill_resource', $fields);
15106    $ilDB->addPrimaryKey('skl_skill_resource', array('base_skill_id', 'tref_id', 'level_id', 'rep_ref_id'));
15107?>
15108<#3876>
15109<?php
15110if (!$ilDB->tableColumnExists('svy_svy', 'skill_service')) {
15111    $ilDB->addTableColumn('svy_svy', 'mode_360_skill_service', array(
15112        'type' => 'integer',
15113        'length' => 1,
15114        'notnull' => true,
15115        'default' => 0));
15116}
15117?>
15118<#3877>
15119<?php
15120    $ilCtrlStructureReader->getStructure();
15121?>
15122<#3878>
15123<?php
15124    $fields = array(
15125        'q_id' => array(
15126            'type' => 'integer',
15127            'length' => 4,
15128            'notnull' => true,
15129            'default' => 0),
15130        'survey_id' => array(
15131            'type' => 'integer',
15132            'length' => 4,
15133            'notnull' => true,
15134            'default' => 0),
15135        'base_skill_id' => array(
15136            'type' => 'integer',
15137            'length' => 4,
15138            'notnull' => true),
15139        'tref_id' => array(
15140            'type' => 'integer',
15141            'length' => 4,
15142            'notnull' => true)
15143    );
15144    $ilDB->createTable('svy_quest_skill', $fields);
15145    $ilDB->addPrimaryKey('svy_quest_skill', array('q_id'));
15146?>
15147<#3879>
15148<?php
15149    $ilCtrlStructureReader->getStructure();
15150?>
15151<#3880>
15152<?php
15153    $fields = array(
15154        'survey_id' => array(
15155            'type' => 'integer',
15156            'length' => 4,
15157            'notnull' => true,
15158            'default' => 0),
15159        'base_skill_id' => array(
15160            'type' => 'integer',
15161            'length' => 4,
15162            'notnull' => true),
15163        'tref_id' => array(
15164            'type' => 'integer',
15165            'length' => 4,
15166            'notnull' => true),
15167        'level_id' => array(
15168            'type' => 'integer',
15169            'length' => 4,
15170            'notnull' => true),
15171        'threshold' => array(
15172            'type' => 'integer',
15173            'length' => 4,
15174            'notnull' => true,
15175            'default' => 0)
15176    );
15177    $ilDB->createTable('svy_skill_threshold', $fields);
15178    $ilDB->addPrimaryKey('svy_skill_threshold', array('survey_id', 'base_skill_id', 'tref_id', 'level_id'));
15179?>
15180<#3881>
15181<?php
15182    $ilCtrlStructureReader->getStructure();
15183?>
15184<#3882>
15185<?php
15186
15187if (!$ilDB->tableColumnExists('skl_user_skill_level', 'tref_id')) {
15188    $ilDB->addTableColumn('skl_user_skill_level', 'tref_id', array(
15189        'type' => 'integer',
15190        'length' => 4,
15191        'notnull' => true,
15192        'default' => 0));
15193}
15194
15195if (!$ilDB->tableColumnExists('skl_user_skill_level', 'trigger_obj_type')) {
15196    $ilDB->addTableColumn('skl_user_skill_level', 'trigger_obj_type', array(
15197        'type' => 'text',
15198        'length' => 4,
15199        'notnull' => true,
15200        'default' => 'crs'));
15201}
15202
15203?>
15204<#3883>
15205<?php
15206
15207if (!$ilDB->tableColumnExists('skl_user_has_level', 'tref_id')) {
15208    $ilDB->addTableColumn('skl_user_has_level', 'tref_id', array(
15209        'type' => 'integer',
15210        'length' => 4,
15211        'notnull' => true,
15212        'default' => 0));
15213}
15214
15215if (!$ilDB->tableColumnExists('skl_user_has_level', 'trigger_obj_type')) {
15216    $ilDB->addTableColumn('skl_user_has_level', 'trigger_obj_type', array(
15217        'type' => 'text',
15218        'length' => 4,
15219        'notnull' => true,
15220        'default' => 'crs'));
15221}
15222
15223?>
15224<#3884>
15225<?php
15226$ilDB->dropPrimaryKey('skl_user_has_level');
15227$ilDB->addPrimaryKey('skl_user_has_level', array('level_id', 'tref_id', 'user_id', 'trigger_obj_id'));
15228?>
15229<#3885>
15230<?php
15231
15232if (!$ilDB->tableColumnExists('svy_360_rater', 'mail_sent')) {
15233    $ilDB->addTableColumn('svy_360_rater', 'mail_sent', array(
15234        'type' => 'integer',
15235        'length' => 4,
15236        'notnull' => false,
15237        'default' => 0));
15238}
15239?>
15240<#3886>
15241<?php
15242    $ilCtrlStructureReader->getStructure();
15243?>
15244<#3887>
15245<?php
15246
15247if (!$ilDB->tableColumnExists('svy_360_appr', 'has_closed')) {
15248    $ilDB->addTableColumn('svy_360_appr', 'has_closed', array(
15249        'type' => 'integer',
15250        'length' => 4,
15251        'notnull' => false,
15252        'default' => 0));
15253}
15254
15255?>
15256<#3888>
15257<?php
15258
15259if (!$ilDB->tableColumnExists('svy_svy', 'reminder_status')) {
15260    $ilDB->addTableColumn(
15261        'svy_svy',
15262        'reminder_status',
15263        array('type' => 'integer', 'length' => 1, 'notnull' => true, 'default' => 0)
15264    );
15265    $ilDB->addTableColumn(
15266        'svy_svy',
15267        'reminder_start',
15268        array('type' => 'timestamp', 'notnull' => false)
15269    );
15270    $ilDB->addTableColumn(
15271        'svy_svy',
15272        'reminder_end',
15273        array('type' => 'timestamp', 'notnull' => false)
15274    );
15275    $ilDB->addTableColumn(
15276        'svy_svy',
15277        'reminder_frequency',
15278        array('type' => 'integer', 'length' => 2, 'notnull' => true, 'default' => 0)
15279    );
15280    $ilDB->addTableColumn(
15281        'svy_svy',
15282        'reminder_target',
15283        array('type' => 'integer', 'length' => 1, 'notnull' => true, 'default' => 0)
15284    );
15285
15286    $ilDB->addTableColumn(
15287        'svy_svy',
15288        'tutor_ntf_status',
15289        array('type' => 'integer', 'length' => 1, 'notnull' => true, 'default' => 0)
15290    );
15291    $ilDB->addTableColumn(
15292        'svy_svy',
15293        'tutor_ntf_reci',
15294        array('type' => 'text', 'length' => 2000, 'notnull' => false, 'fixed' => false)
15295    );
15296    $ilDB->addTableColumn(
15297        'svy_svy',
15298        'tutor_ntf_target',
15299        array('type' => 'integer', 'length' => 1, 'notnull' => true, 'default' => 0)
15300    );
15301}
15302
15303?>
15304<#3889>
15305<?php
15306
15307if (!$ilDB->tableColumnExists('svy_svy', 'reminder_last_sent')) {
15308    $ilDB->addTableColumn(
15309        'svy_svy',
15310        'reminder_last_sent',
15311        array('type' => 'timestamp', 'notnull' => false)
15312    );
15313}
15314
15315?>
15316<#3890>
15317<?php
15318    $ilCtrlStructureReader->getStructure();
15319?>
15320<#3891>
15321<?php
15322    $ilCtrlStructureReader->getStructure();
15323?>
15324<#3892>
15325<?php
15326
15327if (!$ilDB->tableColumnExists('reg_registration_codes', 'role_local')) {
15328    $ilDB->addTableColumn(
15329        'reg_registration_codes',
15330        'role_local',
15331        array('type' => 'text', 'length' => 255)
15332    );
15333    $ilDB->addTableColumn(
15334        'reg_registration_codes',
15335        'alimit',
15336        array('type' => 'text', 'length' => 50)
15337    );
15338    $ilDB->addTableColumn(
15339        'reg_registration_codes',
15340        'alimitdt',
15341        array('type' => 'text', 'length' => 255)
15342    );
15343}
15344
15345?>
15346<#3893>
15347<?php
15348if (!$ilDB->tableExists('cal_ch_group')) {
15349    $fields =
15350                array(
15351                        'grp_id' => array('type' => 'integer', 'length' => 4,'notnull' => true),
15352                        'usr_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4),
15353                        'multiple_assignments' => array('type' => 'integer', 'length' => 1,"notnull" => true),
15354                        'title' => array('type' => 'text', 'length' => 512,"notnull" => false)
15355  );
15356    $ilDB->createTable('cal_ch_group', $fields);
15357    $ilDB->addPrimaryKey('cal_ch_group', array('grp_id'));
15358    $ilDB->createSequence('cal_ch_group');
15359}
15360?>
15361<#3894>
15362<?php
15363if (!$ilDB->tableColumnExists('booking_entry', 'booking_group')) {
15364    $ilDB->addTableColumn(
15365        'booking_entry',
15366        'booking_group',
15367        array(
15368                                'type' => 'integer',
15369                                'length' => 4,
15370                                'default' => 0,
15371                                'notnull' => true
15372                        )
15373    );
15374}
15375?>
15376<#3895>
15377<?php
15378;
15379?>
15380
15381<#3896>
15382<?php
15383
15384if (!$ilDB->tableColumnExists('booking_user', 'booking_message')) {
15385    $ilDB->addTableColumn(
15386        'booking_user',
15387        'booking_message',
15388        array(
15389                                'type' => 'text',
15390                                'length' => 1024,
15391                                'notnull' => false
15392                        )
15393    );
15394}
15395?>
15396
15397<#3897>
15398<?php
15399
15400if (!$ilDB->tableExists('booking_obj_assignment')) {
15401    $fields =
15402                array(
15403                        'booking_id' => array('type' => 'integer', 'length' => 4,'notnull' => true),
15404                        'target_obj_id' => array('type' => 'integer', 'notnull' => true, 'length' => 4)
15405  );
15406    $ilDB->createTable('booking_obj_assignment', $fields);
15407    $ilDB->addPrimaryKey('booking_obj_assignment', array('booking_id','target_obj_id'));
15408}
15409?>
15410
15411<#3898>
15412<?php
15413;
15414?>
15415
15416<#3899>
15417<?php
15418
15419$query = 'SELECT * FROM booking_entry ';
15420$res = $ilDB->query($query);
15421while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
15422    if ($row->target_obj_id) {
15423        $query = 'INSERT INTO booking_obj_assignment (booking_id,target_obj_id) ' .
15424                                'VALUES (' .
15425                                $ilDB->quote($row->booking_id) . ', ' .
15426                                $ilDB->quote($row->target_obj_id) . ' ' .
15427                                ')';
15428        $ilDB->manipulate($query);
15429    }
15430}
15431?>
15432<#3900>
15433<?php
15434
15435    include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
15436    $glo_type_id = ilDBUpdateNewObjectType::getObjectTypeId('glo');
15437    if ($glo_type_id) {
15438        $ops_id = ilDBUpdateNewObjectType::getCustomRBACOperationId('edit_content');
15439        if ($ops_id) {
15440            ilDBUpdateNewObjectType::addRBACOperation($glo_type_id, $ops_id);
15441        }
15442    }
15443
15444?>
15445<#3901>
15446<?php
15447$setting = new ilSetting();
15448$ilfrmthri2 = $setting->get('ilfrmthri2');
15449if (!$ilfrmthri2) {
15450    $ilDB->addIndex('frm_threads', array('thr_top_fk'), 'i2');
15451    $setting->set('ilfrmthri2', 1);
15452}
15453?>
15454<#3902>
15455<?php
15456
15457if (!$ilDB->tableExists('il_disk_quota')) {
15458    $fields = array(
15459        'owner_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true),
15460        'src_type' => array('type' => 'text', 'length' => 50, 'notnull' => false),
15461        'src_obj_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true),
15462        'src_size' => array('type' => 'integer', 'notnull' => true, 'length' => 4)
15463    );
15464    $ilDB->createTable('il_disk_quota', $fields);
15465    $ilDB->addPrimaryKey('il_disk_quota', array('owner_id', 'src_type', 'src_obj_id'));
15466}
15467
15468?>
15469<#3903>
15470<?php
15471
15472function quotaHandleFile($a_obj_id, $a_owner_id)
15473{
15474    global $ilDB;
15475
15476    // see ilFileSystemStorage::_createPathFromId()
15477    $tpath = array();
15478    $tfound = false;
15479    $tnum = $a_obj_id;
15480    for ($i = 3; $i > 0;$i--) {
15481        $factor = pow(100, $i);
15482        if (($tmp = (int) ($tnum / $factor)) or $tfound) {
15483            $tpath[] = $tmp;
15484            $tnum = $tnum % $factor;
15485            $tfound = true;
15486        }
15487    }
15488
15489    $file_path = ilUtil::getDataDir() . "/ilFile/";
15490    if (count($tpath)) {
15491        $file_path .= (implode('/', $tpath) . '/');
15492    }
15493    $file_path .= "file_" . $a_obj_id;
15494    if (file_exists($file_path)) {
15495        $file_size = (int) ilUtil::dirsize($file_path);
15496        if ($file_size > 0) {
15497            $ilDB->manipulate("INSERT INTO il_disk_quota" .
15498                " (owner_id, src_type, src_obj_id, src_size)" .
15499                " VALUES (" . $ilDB->quote($a_owner_id, "integer") .
15500                ", " . $ilDB->quote("file", "text") .
15501                ", " . $ilDB->quote($a_obj_id, "integer") .
15502                ", " . $ilDB->quote($file_size, "integer") . ")");
15503        }
15504    }
15505}
15506
15507$ilDB->manipulate("DELETE FROM il_disk_quota" .
15508    " WHERE src_type = " . $ilDB->quote("file", "text"));
15509
15510$quota_done = array();
15511
15512// get all workspace files
15513$set = $ilDB->query("SELECT od.owner, od.obj_id" .
15514    " FROM object_data od" .
15515    " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
15516    " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
15517    " WHERE od.type = " . $ilDB->quote("file", "text") .
15518    " AND t.tree = od.owner");
15519while ($row = $ilDB->fetchAssoc($set)) {
15520    $id = $row["owner"] . "-" . $row["obj_id"];
15521    if (!in_array($id, $quota_done)) {
15522        quotaHandleFile($row["obj_id"], $row["owner"]);
15523        $quota_done[] = $id;
15524    }
15525}
15526
15527// get all file usage for workspace blogs
15528$set = $ilDB->query("SELECT od.owner, fu.id" .
15529    " FROM object_data od" .
15530    " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
15531    " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
15532    " JOIN il_blog_posting blp ON (blp.blog_id = od.obj_id)" .
15533    " JOIN file_usage fu ON (fu.usage_id = blp.id)" .
15534    " WHERE fu.usage_type = " . $ilDB->quote("blp:pg", "text") .
15535    " AND fu.usage_hist_nr = " . $ilDB->quote(0, "integer"));
15536while ($row = $ilDB->fetchAssoc($set)) {
15537    $id = $row["owner"] . "-" . $row["id"];
15538    if (!in_array($id, $quota_done)) {
15539        quotaHandleFile($row["id"], $row["owner"]);
15540        $quota_done[] = $id;
15541    }
15542}
15543
15544// get all file usage for portfolios
15545$set = $ilDB->query("SELECT od.owner, fu.id" .
15546    " FROM object_data od" .
15547    " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
15548    " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
15549    " JOIN usr_portfolio_page prtf ON (prtf.portfolio_id = od.obj_id)" .
15550    " JOIN file_usage fu ON (fu.usage_id = prtf.id)" .
15551    " WHERE fu.usage_type = " . $ilDB->quote("prtf:pg", "text") .
15552    " AND fu.usage_hist_nr = " . $ilDB->quote(0, "integer"));
15553while ($row = $ilDB->fetchAssoc($set)) {
15554    $id = $row["owner"] . "-" . $row["id"];
15555    if (!in_array($id, $quota_done)) {
15556        quotaHandleFile($row["id"], $row["owner"]);
15557        $quota_done[] = $id;
15558    }
15559}
15560
15561function quotaHandleMob($a_obj_id, $a_owner_id)
15562{
15563    global $ilDB;
15564
15565    $file_path = CLIENT_WEB_DIR . "/mobs/mm_" . $a_obj_id;
15566    if (file_exists($file_path)) {
15567        $file_size = (int) ilUtil::dirsize($file_path);
15568        if ($file_size > 0) {
15569            $ilDB->manipulate("INSERT INTO il_disk_quota" .
15570                " (owner_id, src_type, src_obj_id, src_size)" .
15571                " VALUES (" . $ilDB->quote($a_owner_id, "integer") .
15572                ", " . $ilDB->quote("mob", "text") .
15573                ", " . $ilDB->quote($a_obj_id, "integer") .
15574                ", " . $ilDB->quote($file_size, "integer") . ")");
15575        }
15576    }
15577}
15578
15579$ilDB->manipulate("DELETE FROM il_disk_quota" .
15580    " WHERE src_type = " . $ilDB->quote("mob", "text"));
15581
15582$quota_done = array();
15583
15584// get all mob usage for workspace blogs
15585$set = $ilDB->query("SELECT od.owner, mu.id" .
15586    " FROM object_data od" .
15587    " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
15588    " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
15589    " JOIN il_blog_posting blp ON (blp.blog_id = od.obj_id)" .
15590    " JOIN mob_usage mu ON (mu.usage_id = blp.id)" .
15591    " WHERE mu.usage_type = " . $ilDB->quote("blp:pg", "text") .
15592    " AND mu.usage_hist_nr = " . $ilDB->quote(0, "integer"));
15593while ($row = $ilDB->fetchAssoc($set)) {
15594    $id = $row["owner"] . "-" . $row["id"];
15595    if (!in_array($id, $quota_done)) {
15596        quotaHandleMob($row["id"], $row["owner"]);
15597        $quota_done[] = $id;
15598    }
15599}
15600
15601// get all mob usage for portfolios
15602$set = $ilDB->query("SELECT od.owner, mu.id" .
15603    " FROM object_data od" .
15604    " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
15605    " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
15606    " JOIN usr_portfolio_page prtf ON (prtf.portfolio_id = od.obj_id)" .
15607    " JOIN mob_usage mu ON (mu.usage_id = prtf.id)" .
15608    " WHERE mu.usage_type = " . $ilDB->quote("prtf:pg", "text") .
15609    " AND mu.usage_hist_nr = " . $ilDB->quote(0, "integer"));
15610while ($row = $ilDB->fetchAssoc($set)) {
15611    $id = $row["owner"] . "-" . $row["id"];
15612    if (!in_array($id, $quota_done)) {
15613        quotaHandleMob($row["id"], $row["owner"]);
15614        $quota_done[] = $id;
15615    }
15616}
15617
15618?>
15619<#3904>
15620<?php
15621
15622function quotaHandleFileStorage($a_type, $a_obj_id, $a_owner_id, $a_dir)
15623{
15624    global $ilDB;
15625
15626    // see ilFileSystemStorage::_createPathFromId()
15627    $tpath = array();
15628    $tfound = false;
15629    $tnum = $a_obj_id;
15630    for ($i = 3; $i > 0;$i--) {
15631        $factor = pow(100, $i);
15632        if (($tmp = (int) ($tnum / $factor)) or $tfound) {
15633            $tpath[] = $tmp;
15634            $tnum = $tnum % $factor;
15635            $tfound = true;
15636        }
15637    }
15638
15639    $file_path = CLIENT_WEB_DIR . "/" . $a_dir . "/";
15640    if (count($tpath)) {
15641        $file_path .= (implode('/', $tpath) . '/');
15642    }
15643    $file_path .= $a_type . "_" . $a_obj_id;
15644    if (file_exists($file_path)) {
15645        $file_size = (int) ilUtil::dirsize($file_path);
15646        if ($file_size > 0) {
15647            $ilDB->manipulate("INSERT INTO il_disk_quota" .
15648                " (owner_id, src_type, src_obj_id, src_size)" .
15649                " VALUES (" . $ilDB->quote($a_owner_id, "integer") .
15650                ", " . $ilDB->quote($a_type, "text") .
15651                ", " . $ilDB->quote($a_obj_id, "integer") .
15652                ", " . $ilDB->quote($file_size, "integer") . ")");
15653        }
15654    }
15655}
15656
15657$ilDB->manipulate("DELETE FROM il_disk_quota" .
15658    " WHERE src_type = " . $ilDB->quote("prtf", "text"));
15659$ilDB->manipulate("DELETE FROM il_disk_quota" .
15660    " WHERE src_type = " . $ilDB->quote("blog", "text"));
15661
15662// portfolios
15663$set = $ilDB->query("SELECT od.owner, od.obj_id" .
15664    " FROM object_data od" .
15665    " JOIN usr_portfolio prtf ON (prtf.id = od.obj_id)" .
15666    " WHERE od.type = " . $ilDB->quote("prtf", "text") .
15667    " AND prtf.img IS NOT NULL");
15668while ($row = $ilDB->fetchAssoc($set)) {
15669    quotaHandleFileStorage("prtf", $row["obj_id"], $row["owner"], "ilPortfolio");
15670}
15671
15672// (workspace) blogs
15673$set = $ilDB->query("SELECT od.owner, od.obj_id" .
15674    " FROM object_data od" .
15675    " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
15676    " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
15677    " JOIN il_blog blog ON (blog.id = od.obj_id)" .
15678    " WHERE od.type = " . $ilDB->quote("blog", "text") .
15679    " AND blog.img IS NOT NULL" .
15680    " AND t.tree = od.owner");
15681while ($row = $ilDB->fetchAssoc($set)) {
15682    quotaHandleFileStorage("blog", $row["obj_id"], $row["owner"], "ilBlog");
15683}
15684
15685?>
15686<#3905>
15687<?php
15688
15689function quotaHandleVerification($a_type, $a_obj_id, $a_owner_id)
15690{
15691    global $ilDB;
15692
15693    // see ilFileSystemStorage::_createPathFromId()
15694    $tpath = array();
15695    $tfound = false;
15696    $tnum = $a_obj_id;
15697    for ($i = 3; $i > 0;$i--) {
15698        $factor = pow(100, $i);
15699        if (($tmp = (int) ($tnum / $factor)) or $tfound) {
15700            $tpath[] = $tmp;
15701            $tnum = $tnum % $factor;
15702            $tfound = true;
15703        }
15704    }
15705
15706    $file_path = ilUtil::getDataDir() . "/ilVerification/";
15707    if (count($tpath)) {
15708        $file_path .= (implode('/', $tpath) . '/');
15709    }
15710    $file_path .= "vrfc_" . $a_obj_id;
15711    if (file_exists($file_path)) {
15712        $file_size = (int) ilUtil::dirsize($file_path);
15713        if ($file_size > 0) {
15714            $ilDB->manipulate("INSERT INTO il_disk_quota" .
15715                " (owner_id, src_type, src_obj_id, src_size)" .
15716                " VALUES (" . $ilDB->quote($a_owner_id, "integer") .
15717                ", " . $ilDB->quote($a_type, "text") .
15718                ", " . $ilDB->quote($a_obj_id, "integer") .
15719                ", " . $ilDB->quote($file_size, "integer") . ")");
15720        }
15721    }
15722}
15723
15724$ilDB->manipulate("DELETE FROM il_disk_quota" .
15725    " WHERE src_type = " . $ilDB->quote("tstv", "text"));
15726$ilDB->manipulate("DELETE FROM il_disk_quota" .
15727    " WHERE src_type = " . $ilDB->quote("excv", "text"));
15728
15729// (workspace) verifications
15730$set = $ilDB->query("SELECT od.owner, od.obj_id, od.type" .
15731    " FROM object_data od" .
15732    " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
15733    " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
15734    " WHERE " . $ilDB->in("od.type", array("tstv", "excv"), "", "text") .
15735    " AND t.tree = od.owner");
15736while ($row = $ilDB->fetchAssoc($set)) {
15737    quotaHandleVerification($row["type"], $row["obj_id"], $row["owner"]);
15738}
15739
15740?>
15741<#3906>
15742<?php
15743
15744if (!$ilDB->tableColumnExists('role_data', 'wsp_disk_quota')) {
15745    $ilDB->addTableColumn(
15746        'role_data',
15747        'wsp_disk_quota',
15748        array(
15749                                'type' => 'integer',
15750                                'length' => 4,
15751                                'notnull' => false
15752                        )
15753    );
15754}
15755
15756?>
15757<#3907>
15758<?php
15759
15760// #10745
15761if (!$ilDB->tableColumnExists('tst_tests', 'starting_time')) {
15762    $ilDB->addTableColumn(
15763        'tst_tests',
15764        'starting_time',
15765        array(
15766                                'type' => 'text',
15767                                'length' => 14,
15768                                'notnull' => false
15769                        )
15770    );
15771}
15772if (!$ilDB->tableColumnExists('tst_tests', 'ending_time')) {
15773    $ilDB->addTableColumn(
15774        'tst_tests',
15775        'ending_time',
15776        array(
15777                                'type' => 'text',
15778                                'length' => 14,
15779                                'notnull' => false
15780                        )
15781    );
15782}
15783
15784?>
15785<#3908>
15786<?php
15787    $ilCtrlStructureReader->getStructure();
15788?>
15789<#3909>
15790<?php
15791    if (!$ilDB->tableExists('tst_addtime')) {
15792        $ilDB->createTable(
15793            'tst_addtime',
15794            array(
15795                'active_fi' => array(
15796                    'type' => 'integer',
15797                    'length' => 8,
15798                    'notnull' => true,
15799                    'default' => 0
15800                ),
15801                'additionaltime' => array(
15802                    'type' => 'integer',
15803                    'length' => 8,
15804                    'notnull' => true,
15805                    'default' => 0,
15806                ),
15807                "tstamp" => array(
15808                    "notnull" => true,
15809                    "length" => 8,
15810                    "default" => "0",
15811                    "type" => "integer"
15812                )
15813            )
15814        );
15815        $ilDB->addIndex("tst_addtime", array('active_fi'), "i1", false);
15816    }
15817?>
15818<#3910>
15819<?php
15820if (!$ilDB->tableColumnExists("qpl_qst_imagemap", "is_multiple_choice")) {
15821    $atts = array(
15822        'type' => 'integer',
15823        'length' => 1,
15824        'default' => 0,
15825        'notnull' => true
15826    );
15827    $ilDB->addTableColumn("qpl_qst_imagemap", "is_multiple_choice", $atts);
15828}
15829?>
15830<#3911>
15831<?php
15832if (!$ilDB->tableColumnExists("qpl_a_imagemap", "points_unchecked")) {
15833    $atts = array(
15834        'type' => 'float',
15835        'notnull' => true,
15836        'default' => 0
15837    );
15838    $ilDB->addTableColumn("qpl_a_imagemap", "points_unchecked", $atts);
15839}
15840?>
15841<#3912>
15842<?php
15843    if (!$ilDB->tableColumnExists('tax_node_assignment', 'tax_id')) {
15844        $ilDB->addTableColumn(
15845            "tax_node_assignment",
15846            "tax_id",
15847            array(	'type' => 'integer',
15848                'length' => 4,
15849                'notnull' => true,
15850                'default' => 0
15851        )
15852        );
15853    }
15854?>
15855<#3913>
15856<?php
15857$set = $ilDB->query("SELECT * FROM tax_node_assignment");
15858while ($rec = $ilDB->fetchAssoc($set)) {
15859    $set2 = $ilDB->query("SELECT tax_tree_id FROM tax_tree " .
15860        " WHERE child = " . $ilDB->quote($rec["node_id"], "integer"));
15861    $rec2 = $ilDB->fetchAssoc($set2);
15862    if ($rec2["tax_tree_id"] > 0) {
15863        $ilDB->manipulate(
15864            "UPDATE tax_node_assignment SET " .
15865            " tax_id = " . $ilDB->quote($rec2["tax_tree_id"], "integer") .
15866            " WHERE node_id = " . $ilDB->quote($rec["node_id"], "integer")
15867        );
15868    }
15869}
15870?>
15871<#3914>
15872<?php
15873// Determine the client id: 11.06.2013 ;-). The constant CLIENT_ID is empty in this context
15874$client_id = basename(CLIENT_DATA_DIR);
15875$status = 0;
15876
15877foreach (array(
15878    realpath('Customizing/global/agreement'),
15879    realpath('Customizing/clients/' . $client_id)
15880) as $path) {
15881    try {
15882        foreach (
15883            new RegexIterator(
15884                new RecursiveIteratorIterator(
15885                    new RecursiveDirectoryIterator($path),
15886                    RecursiveIteratorIterator::SELF_FIRST,
15887                    RecursiveIteratorIterator::CATCH_GET_CHILD
15888                ),
15889                '/agreement_([a-z]+)\.html$/'
15890            ) as $file
15891        ) {
15892            $status = 1;
15893            break 2;
15894        }
15895    } catch (Exception $e) {
15896    }
15897}
15898
15899$setting = new ilSetting();
15900$setting->set('tos_status', $status);
15901?>
15902<#3915>
15903<?php
15904if (!$ilDB->tableColumnExists('tst_tests', 'redirection_mode')) {
15905    $ilDB->addTableColumn(
15906        'tst_tests',
15907        'redirection_mode',
15908        array(
15909            'type' => 'integer',
15910            'length' => 4,
15911            'notnull' => true,
15912            'default' => 0)
15913    );
15914}
15915?>
15916<#3916>
15917<?php
15918if (!$ilDB->tableColumnExists('tst_tests', 'redirection_url')) {
15919    $ilDB->addTableColumn(
15920        'tst_tests',
15921        'redirection_url',
15922        array(
15923            'type' => 'text',
15924            'length' => 128,
15925            'notnull' => false,
15926            'default' => null)
15927    );
15928}
15929?>
15930<#3917>
15931<?php
15932    if (!$ilDB->tableColumnExists('tax_data', 'item_sorting')) {
15933        $ilDB->addTableColumn(
15934            "tax_data",
15935            "item_sorting",
15936            array(	'type' => 'integer',
15937                'length' => 1,
15938                'notnull' => true,
15939                'default' => 0
15940        )
15941        );
15942    }
15943?>
15944<#3918>
15945<?php
15946    if (!$ilDB->tableColumnExists('tax_node_assignment', 'order_nr')) {
15947        $ilDB->addTableColumn(
15948            "tax_node_assignment",
15949            "order_nr",
15950            array(	'type' => 'integer',
15951                'length' => 4,
15952                'notnull' => true,
15953                'default' => 0
15954        )
15955        );
15956    }
15957?>
15958<#3919>
15959<?php
15960    $ilCtrlStructureReader->getStructure();
15961?>
15962<#3920>
15963<?php
15964if (!$ilDB->tableColumnExists('tst_pass_result', 'exam_id')) {
15965    $ilDB->addTableColumn(
15966        "tst_pass_result",
15967        "exam_id",
15968        array(	'type' => 'text',
15969                                    'length' => 128,
15970                                    'notnull' => false,
15971                                    'default' => null
15972                          )
15973    );
15974}
15975?>
15976<#3921>
15977<?php
15978if (!$ilDB->tableColumnExists('tst_tests', 'examid_in_kiosk')) {
15979    $ilDB->addTableColumn(
15980        "tst_tests",
15981        "examid_in_kiosk",
15982        array(	'type' => 'integer',
15983                                    'length' => 4,
15984                                    'notnull' => true,
15985                                    'default' => 0
15986                          )
15987    );
15988}
15989?>
15990<#3922>
15991<?php
15992
15993include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
15994ilDBUpdateNewObjectType::addAdminNode('sysc', 'System Check');
15995
15996?>
15997<#3923>
15998<?php
15999    $ilCtrlStructureReader->getStructure();
16000?>
16001<#3924>
16002<?php
16003    $ilCtrlStructureReader->getStructure();
16004?>
16005<#3925>
16006<?php
16007$fields = array(
16008    'id' => array(
16009        'type' => 'integer',
16010        'length' => 4,
16011        'notnull' => true
16012    ),
16013    'is_online' => array(
16014        'type' => 'integer',
16015        'length' => 1,
16016        'notnull' => false
16017    ),
16018    'service' => array(
16019        'type' => 'text',
16020        'length' => 255,
16021        'fixed' => false,
16022        'notnull' => false
16023    ),
16024    'root_folder' => array(
16025        'type' => 'text',
16026        'length' => 255,
16027        'fixed' => false,
16028        'notnull' => false
16029    ),
16030    'root_id' => array(
16031        'type' => 'text',
16032        'length' => 255,
16033        'fixed' => false,
16034        'notnull' => false
16035    ),
16036    'owner_id' => array(
16037        'type' => 'integer',
16038        'length' => 8,
16039        'notnull' => true
16040    ),
16041    'auth_complete' => array(
16042        'type' => 'integer',
16043        'length' => 1,
16044        'notnull' => false
16045    ),
16046);
16047
16048$ilDB->createTable("il_cld_data", $fields);
16049$ilDB->addPrimaryKey("il_cld_data", array("id"));
16050?>
16051
16052<#3926>
16053<?php
16054$setting = new ilSetting();
16055$setting->set("obj_dis_creation_cld", 1);
16056?>
16057<#3927>
16058<?php
16059include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
16060
16061$cld_type_id = ilDBUpdateNewObjectType::addNewType('cld', 'Cloud Folder');
16062
16063$rbac_ops = array(
16064    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
16065    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
16066    ilDBUpdateNewObjectType::RBAC_OP_READ,
16067    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
16068    ilDBUpdateNewObjectType::RBAC_OP_DELETE
16069);
16070ilDBUpdateNewObjectType::addRBACOperations($cld_type_id, $rbac_ops);
16071
16072$parent_types = array('root', 'cat', 'crs', 'fold', 'grp');
16073ilDBUpdateNewObjectType::addRBACCreate('create_cld', 'Create Cloud Folder', $parent_types);
16074
16075$ops_id = ilDBUpdateNewObjectType::addCustomRBACOperation('upload', 'Upload Items', 'object', 3200);
16076ilDBUpdateNewObjectType::addRBACOperation($cld_type_id, $ops_id);
16077$ops_id = ilDBUpdateNewObjectType::addCustomRBACOperation('delete_files', 'Delete Files', 'object', 3200);
16078ilDBUpdateNewObjectType::addRBACOperation($cld_type_id, $ops_id);
16079$ops_id = ilDBUpdateNewObjectType::addCustomRBACOperation('delete_folders', 'Delete Folders', 'object', 3200);
16080ilDBUpdateNewObjectType::addRBACOperation($cld_type_id, $ops_id);
16081$ops_id = ilDBUpdateNewObjectType::addCustomRBACOperation('download', 'Download Items', 'object', 3200);
16082ilDBUpdateNewObjectType::addRBACOperation($cld_type_id, $ops_id);
16083$ops_id = ilDBUpdateNewObjectType::addCustomRBACOperation('files_visible', 'Files are visible', 'object', 3200);
16084ilDBUpdateNewObjectType::addRBACOperation($cld_type_id, $ops_id);
16085$ops_id = ilDBUpdateNewObjectType::addCustomRBACOperation('folders_visible', 'Folders are visible', 'object', 3200);
16086ilDBUpdateNewObjectType::addRBACOperation($cld_type_id, $ops_id);
16087$ops_id = ilDBUpdateNewObjectType::addCustomRBACOperation('folders_create', 'Folders may be created', 'object', 3200);
16088ilDBUpdateNewObjectType::addRBACOperation($cld_type_id, $ops_id);
16089?>
16090<#3928>
16091<?php
16092$ilCtrlStructureReader->getStructure();
16093?>
16094<#3929>
16095<?php
16096    $setting = new ilSetting();
16097    $ilfrmnoti1 = $setting->get('ilfrmnoti1');
16098    if (!$ilfrmnoti1) {
16099        $ilDB->addIndex('frm_notification', array('user_id', 'thread_id'), 'i1');
16100        $setting->set('ilfrmnoti1', 1);
16101    }
16102?>
16103<#3930>
16104<?php
16105if (!$ilDB->tableColumnExists('tst_tests', 'show_exam_id')) {
16106    $ilDB->addTableColumn(
16107        "tst_tests",
16108        "show_exam_id",
16109        array(	'type' => 'integer',
16110                                    'length' => 4,
16111                                    'notnull' => true,
16112                                    'default' => 0
16113                          )
16114    );
16115}
16116?>
16117<#3931>
16118<?php
16119if (!$ilDB->tableColumnExists('acl_ws', 'tstamp')) {
16120    $ilDB->addTableColumn(
16121        "acl_ws",
16122        "tstamp",
16123        array(	'type' => 'integer',
16124                                    'length' => 4,
16125                                    'notnull' => true,
16126                                    'default' => 0
16127                          )
16128    );
16129}
16130?>
16131<#3932>
16132<?php
16133
16134$ilDB->manipulate("UPDATE acl_ws SET tstamp = " . $ilDB->quote(time(), "integer") .
16135    " WHERE tstamp = " . $ilDB->quote(0, "integer"));
16136
16137?>
16138<#3933>
16139<?php
16140if (!$ilDB->tableColumnExists('usr_portf_acl', 'tstamp')) {
16141    $ilDB->addTableColumn(
16142        "usr_portf_acl",
16143        "tstamp",
16144        array(	'type' => 'integer',
16145                                    'length' => 4,
16146                                    'notnull' => true,
16147                                    'default' => 0
16148                          )
16149    );
16150}
16151?>
16152<#3934>
16153<?php
16154
16155$ilDB->manipulate("UPDATE usr_portf_acl SET tstamp = " . $ilDB->quote(time(), "integer") .
16156    " WHERE tstamp = " . $ilDB->quote(0, "integer"));
16157
16158?>
16159<#3935>
16160<?php
16161$ilCtrlStructureReader->getStructure();
16162?>
16163<#3936>
16164<?php
16165if (!$ilDB->tableColumnExists('exc_returned', 'atext')) {
16166    $ilDB->addTableColumn(
16167        "exc_returned",
16168        "atext",
16169        array(
16170            "type" => "clob",
16171          "notnull" => false,
16172          "default" => null)
16173    );
16174}
16175?>
16176<#3937>
16177<?php
16178if (!$ilDB->tableColumnExists('exc_assignment', 'peer')) {
16179    $ilDB->addTableColumn(
16180        "exc_assignment",
16181        "peer",
16182        array(
16183            "type" => "integer",
16184            "length" => 1,
16185            "notnull" => true,
16186            "default" => 0)
16187    );
16188}
16189if (!$ilDB->tableColumnExists('exc_assignment', 'peer_min')) {
16190    $ilDB->addTableColumn(
16191        "exc_assignment",
16192        "peer_min",
16193        array(
16194            "type" => "integer",
16195            "length" => 2,
16196            "notnull" => true,
16197            "default" => 0)
16198    );
16199}
16200?>
16201<#3938>
16202<?php
16203if (!$ilDB->tableExists('sysc_groups')) {
16204    $fields = array(
16205    'id' => array(
16206            'type' => 'integer',
16207            'length' => 4,
16208            'notnull' => true),
16209
16210    'title' => array(
16211            'type' => 'text',
16212            'notnull' => false,
16213            'length' => 64,
16214            'fixed' => true),
16215
16216    'description' => array(
16217            "type" => "text",
16218            "notnull" => false,
16219            "length" => 64,
16220            "fixed" => true),
16221
16222    'component' => array(
16223            "type" => "text",
16224            "notnull" => false,
16225            "length" => 16,
16226            "fixed" => true),
16227
16228    'last_update' => array(
16229            "type" => "timestamp",
16230            "notnull" => false),
16231
16232    'status' => array(
16233            "type" => "integer",
16234            "notnull" => true,
16235            'length' => 1,
16236            'default' => 0)
16237      );
16238    $ilDB->createTable('sysc_groups', $fields);
16239    $ilDB->addPrimaryKey('sysc_groups', array('id'));
16240    $ilDB->createSequence("sysc_groups");
16241}
16242?>
16243<#3939>
16244<?php
16245if (!$ilDB->tableExists('exc_assignment_peer')) {
16246    $fields = array(
16247    'ass_id' => array(
16248            'type' => 'integer',
16249            'length' => 4,
16250            'notnull' => true),
16251    'giver_id' => array(
16252            'type' => 'integer',
16253            'length' => 4,
16254            'notnull' => true),
16255    'peer_id' => array(
16256            'type' => 'integer',
16257            'length' => 4,
16258            'notnull' => true),
16259    'pcomment' => array(
16260            "type" => "text",
16261            "notnull" => false,
16262            "length" => 2000,
16263            "fixed" => false),
16264    'tstamp' => array(
16265            "type" => "timestamp",
16266            "notnull" => false)
16267      );
16268    $ilDB->createTable('exc_assignment_peer', $fields);
16269    $ilDB->addPrimaryKey('exc_assignment_peer', array('ass_id', 'giver_id', 'peer_id'));
16270}
16271?>
16272<#3940>
16273<?php
16274$ilCtrlStructureReader->getStructure();
16275?>
16276<#3941>
16277<?php
16278if (!$ilDB->tableExists('preview')) {
16279    $fields = array(
16280        'obj_id' => array(
16281            'type' => 'integer',
16282            'length' => 4,
16283            'notnull' => true
16284        ),
16285        'render_date' => array(
16286            'type' => 'timestamp',
16287            'notnull' => true
16288        ),
16289        'render_status' => array(
16290            'type' => 'text',
16291            'length' => 20,
16292            'notnull' => true,
16293            'fixed' => false
16294        )
16295    );
16296    $ilDB->createTable('preview', $fields);
16297    $ilDB->addPrimaryKey('preview', array('obj_id'));
16298}
16299?>
16300<#3942>
16301<?php
16302$ilCtrlStructureReader->getStructure();
16303?>
16304<#3943>
16305<?php
16306if (!$ilDB->tableColumnExists('qpl_questions', 'external_id')) {
16307    $ilDB->addTableColumn(
16308        "qpl_questions",
16309        "external_id",
16310        array(
16311            "type" => "text",
16312            "notnull" => false,
16313            "length" => 255,
16314            "default" => null
16315        )
16316    );
16317}
16318?>
16319<#3944>
16320<?php
16321$ilCtrlStructureReader->getStructure();
16322?>
16323<#3945>
16324<?php
16325if (!$ilDB->tableColumnExists('exc_assignment', 'fb_file')) {
16326    $ilDB->addTableColumn(
16327        "exc_assignment",
16328        "fb_file",
16329        array(
16330            "type" => "text",
16331            "length" => 1000,
16332            "notnull" => false)
16333    );
16334}
16335if (!$ilDB->tableColumnExists('exc_assignment', 'fb_cron')) {
16336    $ilDB->addTableColumn(
16337        "exc_assignment",
16338        "fb_cron",
16339        array(
16340            "type" => "integer",
16341            "length" => 1,
16342            "notnull" => true,
16343            "default" => 0)
16344    );
16345}
16346?>
16347<#3946>
16348<?php
16349if (!$ilDB->tableColumnExists('exc_assignment', 'fb_cron_done')) {
16350    $ilDB->addTableColumn(
16351        "exc_assignment",
16352        "fb_cron_done",
16353        array(
16354            "type" => "integer",
16355            "length" => 1,
16356            "notnull" => true,
16357            "default" => 0)
16358    );
16359}
16360?>
16361<#3947>
16362<?php
16363$ilCtrlStructureReader->getStructure();
16364?>
16365<#3948>
16366<?php
16367    if (!$ilDB->tableColumnExists('sahs_lm', 'offline_mode')) {
16368        $ilDB->addTableColumn(
16369            'sahs_lm',
16370            'offline_mode',
16371            array(
16372                "type" => "text",
16373                'length' => 1,
16374                "notnull" => true,
16375                "default" => 'n'
16376            )
16377        );
16378        $ilDB->query("UPDATE sahs_lm SET offline_mode = 'n'");
16379    }
16380?>
16381<#3949>
16382<?php
16383if (!$ilDB->tableExists('sahs_user')) {
16384    $fields = array(
16385        'obj_id' => array(
16386            'type' => 'integer',
16387            'length' => 4,
16388            'notnull' => true
16389        ),
16390        'user_id' => array(
16391            'type' => 'integer',
16392            'length' => 4,
16393            'notnull' => true
16394        ),
16395        'package_attempts' => array(
16396            'type' => 'integer',
16397            'length' => 2,
16398            'notnull' => false
16399        ),
16400        'module_version' => array(
16401            'type' => 'integer',
16402            'length' => 2,
16403            'notnull' => false
16404        ),
16405        'last_visited' => array(
16406            'type' => 'text',
16407            'length' => 255,
16408            'notnull' => false,
16409            'fixed' => false,
16410            'default' => null
16411        ),
16412        'hash' => array(
16413            'type' => 'text',
16414            'length' => 20,
16415            'notnull' => false,
16416            'fixed' => false,
16417            'default' => null
16418        ),
16419        'hash_end' => array(
16420            'type' => 'timestamp',
16421            'notnull' => false
16422        ),
16423        'offline_mode' => array(
16424            'type' => 'text',
16425            'length' => 8,
16426            'notnull' => false,
16427            'fixed' => false,
16428            'default' => null
16429        )
16430    );
16431    $ilDB->createTable('sahs_user', $fields);
16432    $ilDB->addPrimaryKey('sahs_user', array('obj_id','user_id'));
16433}
16434?>
16435<#3950>
16436<?php
16437$ilCtrlStructureReader->getStructure();
16438?>
16439?>
16440<#3951>
16441<?php
16442if (!$ilDB->tableColumnExists('tst_tests', 'enable_examview')) {
16443    $ilDB->addTableColumn(
16444        'tst_tests',
16445        'enable_examview',
16446        array(
16447            'type' => 'integer',
16448            'length' => 1,
16449            'notnull' => false
16450        )
16451    );
16452}
16453
16454if (!$ilDB->tableColumnExists('tst_tests', 'show_examview_html')) {
16455    $ilDB->addTableColumn(
16456        'tst_tests',
16457        'show_examview_html',
16458        array(
16459            'type' => 'integer',
16460            'length' => 1,
16461            'notnull' => false
16462        )
16463    );
16464}
16465
16466if (!$ilDB->tableColumnExists('tst_tests', 'show_examview_pdf')) {
16467    $ilDB->addTableColumn(
16468        'tst_tests',
16469        'show_examview_pdf',
16470        array(
16471            'type' => 'integer',
16472            'length' => 1,
16473            'notnull' => false
16474        )
16475    );
16476}
16477
16478if (!$ilDB->tableColumnExists('tst_tests', 'enable_archiving')) {
16479    $ilDB->addTableColumn(
16480        'tst_tests',
16481        'enable_archiving',
16482        array(
16483            'type' => 'integer',
16484            'length' => 1,
16485            'notnull' => false
16486        )
16487    );
16488}
16489
16490$ilCtrlStructureReader->getStructure();
16491?>
16492<#3952>
16493<?php
16494
16495include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
16496ilDBUpdateNewObjectType::addAdminNode('reps', 'Repository Settings');
16497
16498?>
16499<#3953>
16500<?php
16501    $ilCtrlStructureReader->getStructure();
16502?>
16503<#3954>
16504<?php
16505
16506include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
16507ilDBUpdateNewObjectType::addAdminNode('crss', 'Course Settings');
16508
16509?>
16510<#3955>
16511<?php
16512
16513include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
16514ilDBUpdateNewObjectType::addAdminNode('grps', 'Group Settings');
16515
16516?>
16517<#3956>
16518<?php
16519
16520include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
16521ilDBUpdateNewObjectType::addAdminNode('wbrs', 'WebResource Settings');
16522
16523?>
16524<#3957>
16525<?php
16526    $ilCtrlStructureReader->getStructure();
16527?>
16528<#3958>
16529<?php
16530$ilDB->renameTable('preview', 'preview_data');
16531?>
16532<#3959>
16533<?php
16534    $ilCtrlStructureReader->getStructure();
16535?>
16536<#3960>
16537<?php
16538    $ilCtrlStructureReader->getStructure();
16539?>
16540<#3961>
16541<?php
16542if (!$ilDB->tableExists('copg_pc_def')) {
16543    $fields = array(
16544        'pc_type' => array(
16545            'type' => 'text',
16546            'length' => 20,
16547            'notnull' => true
16548        ),
16549        'name' => array(
16550            'type' => 'text',
16551            'length' => 40,
16552            'notnull' => true
16553        ),
16554        'directory' => array(
16555            'type' => 'text',
16556            'length' => 40,
16557            'notnull' => false
16558        ),
16559        'int_links' => array(
16560            'type' => 'integer',
16561            'length' => 1,
16562            'notnull' => true,
16563            'default' => 0
16564        ),
16565        'style_classes' => array(
16566            'type' => 'integer',
16567            'length' => 1,
16568            'notnull' => true,
16569            'default' => 0
16570        ),
16571        'xsl' => array(
16572            'type' => 'integer',
16573            'length' => 1,
16574            'notnull' => true,
16575            'default' => 0
16576        )
16577    );
16578    $ilDB->createTable('copg_pc_def', $fields);
16579    $ilDB->addPrimaryKey('copg_pc_def', array('pc_type'));
16580}
16581
16582?>
16583<#3962>
16584<?php
16585    $ilCtrlStructureReader->getStructure();
16586?>
16587<#3963>
16588<?php
16589    $ilCtrlStructureReader->getStructure();
16590?>
16591<#3964>
16592<?php
16593if (!$ilDB->tableColumnExists("copg_pc_def", "component")) {
16594    $ilDB->addTableColumn("copg_pc_def", "component", array(
16595        "type" => "text",
16596        "notnull" => false,
16597        "length" => 40));
16598}
16599?>
16600<#3965>
16601<?php
16602    $ilCtrlStructureReader->getStructure();
16603?>
16604<#3966>
16605<?php
16606    $ilCtrlStructureReader->getStructure();
16607?>
16608<#3967>
16609<?php
16610if (!$ilDB->tableColumnExists("copg_pc_def", "def_enabled")) {
16611    $ilDB->addTableColumn("copg_pc_def", "def_enabled", array(
16612        "type" => "integer",
16613        "notnull" => false,
16614        "length" => 1,
16615        "default" => 0));
16616}
16617?>
16618<#3968>
16619<?php
16620    $ilCtrlStructureReader->getStructure();
16621?>
16622<#3969>
16623<?php
16624    $ilCtrlStructureReader->getStructure();
16625?>
16626<#3970>
16627<?php
16628if (!$ilDB->tableColumnExists("file_data", "rating")) {
16629    $ilDB->addTableColumn("file_data", "rating", array(
16630        'type' => 'integer',
16631        'length' => 1,
16632        'notnull' => true,
16633        'default' => 0));
16634}
16635?>
16636<#3971>
16637<?php
16638if (!$ilDB->tableColumnExists("content_object", "rating")) {
16639    $ilDB->addTableColumn("content_object", "rating", array(
16640        'type' => 'integer',
16641        'length' => 1,
16642        'notnull' => true,
16643        'default' => 0));
16644}
16645?>
16646<#3972>
16647<?php
16648    $ilCtrlStructureReader->getStructure();
16649?>
16650<#3973>
16651<?php
16652
16653// migrate security default mode to custom settings
16654$setting = new ilSetting();
16655if ($setting->get('ps_account_security_mode', 1) == 1) {
16656    $setting->set('ps_account_security_mode', 2);
16657    $setting->set('ps_password_chars_and_numbers_enabled', false);
16658    $setting->set('ps_password_special_chars_enabled', false);
16659    $setting->set('ps_password_min_length', 6);
16660    $setting->set('ps_password_max_length', 0);
16661    $setting->set('ps_password_max_age', 0);
16662    $setting->set('ps_login_max_attempts', 0);
16663}
16664
16665?>
16666<#3974>
16667<?php
16668    $ilCtrlStructureReader->getStructure();
16669?>
16670<#3975>
16671<?php
16672if (!$ilDB->tableColumnExists("booking_user", "notification_sent")) {
16673    $ilDB->addTableColumn("booking_user", "notification_sent", array(
16674        'type' => 'integer',
16675        'length' => 1,
16676        'notnull' => true,
16677        'default' => 0));
16678}
16679?>
16680<#3976>
16681<?php
16682if (!$ilDB->tableExists('il_new_item_grp')) {
16683    $fields = array(
16684        'id' => array(
16685            'type' => 'integer',
16686            'length' => 4,
16687            'notnull' => true,
16688            'default' => 0
16689        ),
16690        'titles' => array(
16691            'type' => 'text',
16692            'length' => 1000,
16693            'notnull' => false
16694        ),
16695        'pos' => array(
16696            'type' => 'integer',
16697            'length' => 2,
16698            'notnull' => true,
16699            'default' => 0
16700        )
16701    );
16702    $ilDB->createTable('il_new_item_grp', $fields);
16703    $ilDB->addPrimaryKey('il_new_item_grp', array('id'));
16704    $ilDB->createSequence('il_new_item_grp');
16705}
16706
16707?>
16708<#3977>
16709<?php
16710
16711if (!$ilDB->tableColumnExists('tst_tests', 'question_set_type')) {
16712    $ilDB->addTableColumn('tst_tests', 'question_set_type', array(
16713            'type' => 'text',
16714            'length' => 32,
16715            'notnull' => true,
16716            'default' => 'FIXED_QUEST_SET'
16717    ));
16718}
16719
16720if ($ilDB->tableColumnExists('tst_tests', 'random_test')) {
16721    $ilDB->manipulateF(
16722        "UPDATE tst_tests SET question_set_type = %s WHERE random_test = %s",
16723        array('text', 'text'),
16724        array('FIXED_QUEST_SET', '0')
16725    );
16726
16727    $ilDB->manipulateF(
16728        "UPDATE tst_tests SET question_set_type = %s WHERE random_test = %s",
16729        array('text', 'text'),
16730        array('RANDOM_QUEST_SET', '1')
16731    );
16732
16733    $ilDB->dropTableColumn('tst_tests', 'random_test');
16734}
16735
16736?>
16737<#3978>
16738<?php
16739
16740if (!$ilDB->tableExists('tst_dyn_quest_set_cfg')) {
16741    $ilDB->createTable('tst_dyn_quest_set_cfg', array(
16742        'test_fi' => array('type' => 'integer', 'length' => 4, 'notnull' => true, 'default' => 0),
16743        'source_qpl_fi' => array('type' => 'integer', 'length' => 4, 'notnull' => true, 'default' => 0),
16744        'tax_filter_enabled' => array('type' => 'integer', 'length' => 1, 'notnull' => true, 'default' => 0)
16745    ));
16746}
16747
16748?>
16749<#3979>
16750<?php
16751
16752if (!$ilDB->tableColumnExists('qpl_questionpool', 'show_taxonomies')) {
16753    $ilDB->addTableColumn('qpl_questionpool', 'show_taxonomies', array(
16754            'type' => 'integer',
16755            'length' => 1,
16756            'notnull' => true,
16757            'default' => 0
16758    ));
16759}
16760
16761if (!$ilDB->tableColumnExists('qpl_questionpool', 'nav_taxonomy')) {
16762    $ilDB->addTableColumn('qpl_questionpool', 'nav_taxonomy', array(
16763            'type' => 'integer',
16764            'length' => 4,
16765            'notnull' => false,
16766            'default' => null
16767    ));
16768}
16769
16770?>
16771<#3980>
16772<?php
16773
16774if (!$ilDB->tableColumnExists('tst_dyn_quest_set_cfg', 'order_tax')) {
16775    $ilDB->addTableColumn('tst_dyn_quest_set_cfg', 'order_tax', array(
16776            'type' => 'integer',
16777            'length' => 4,
16778            'notnull' => false,
16779            'default' => null
16780    ));
16781}
16782
16783if (!$ilDB->tableColumnExists('tst_active', 'taxfilter')) {
16784    $ilDB->addTableColumn('tst_active', 'taxfilter', array(
16785            'type' => 'text',
16786            'length' => 1024,
16787            'notnull' => false,
16788            'default' => null
16789    ));
16790}
16791
16792?>
16793<#3981>
16794<?php
16795    $ilCtrlStructureReader->getStructure();
16796?>
16797<#3982>
16798<?php
16799
16800if (!$ilDB->tableExists("lm_glossaries")) {
16801    $fields = array(
16802        "lm_id" => array(
16803            'type' => 'integer',
16804            'length' => 4,
16805            'notnull' => true,
16806            'default' => 0
16807        ),
16808        "glo_id" => array(
16809            'type' => 'integer',
16810            'length' => 4,
16811            'notnull' => true,
16812            'default' => 0
16813        ));
16814
16815    $ilDB->createTable(
16816        'lm_glossaries',
16817        $fields
16818    );
16819
16820    $ilDB->addPrimaryKey("lm_glossaries", array("lm_id", "glo_id"));
16821}
16822
16823?>
16824<#3983>
16825<?php
16826    $ilCtrlStructureReader->getStructure();
16827?>
16828<#3984>
16829<?php
16830
16831if (!$ilDB->tableColumnExists("content_object", "hide_head_foot_print")) {
16832    $def = array(
16833            'type' => 'integer',
16834            'length' => 1,
16835            'notnull' => true,
16836            'default' => 0
16837        );
16838    $ilDB->addTableColumn("content_object", "hide_head_foot_print", $def);
16839}
16840?>
16841<#3985>
16842<?php
16843
16844if (!$ilDB->tableColumnExists("il_news_item", "mob_cnt_download")) {
16845    $def = array(
16846            'type' => 'integer',
16847            'length' => 4,
16848            'notnull' => true,
16849            'default' => 0
16850        );
16851    $ilDB->addTableColumn("il_news_item", "mob_cnt_download", $def);
16852}
16853?>
16854<#3986>
16855<?php
16856
16857if (!$ilDB->tableColumnExists("il_news_item", "mob_cnt_play")) {
16858    $def = array(
16859            'type' => 'integer',
16860            'length' => 4,
16861            'notnull' => true,
16862            'default' => 0
16863        );
16864    $ilDB->addTableColumn("il_news_item", "mob_cnt_play", $def);
16865}
16866?>
16867<#3987>
16868<?php
16869
16870if (!$ilDB->tableColumnExists("il_object_def", "amet")) {
16871    $def = array(
16872            'type' => 'integer',
16873            'length' => 1,
16874            'notnull' => true,
16875            'default' => 0
16876        );
16877    $ilDB->addTableColumn("il_object_def", "amet", $def);
16878}
16879?>
16880<#3988>
16881<?php
16882
16883if (!$ilDB->tableExists("il_object_subitem")) {
16884    $fields = array(
16885        "object" => array(
16886            'type' => 'text',
16887            'length' => 10,
16888            'notnull' => true
16889        ),
16890        "subitem" => array(
16891            'type' => 'text',
16892            'length' => 10,
16893            'notnull' => true
16894        ),
16895        "amet" => array(
16896            'type' => 'integer',
16897            'length' => 1,
16898            'notnull' => true,
16899            'default' => 0
16900        )
16901        );
16902
16903    $ilDB->createTable(
16904        'il_object_subitem',
16905        $fields
16906    );
16907
16908    $ilDB->addPrimaryKey("il_object_subitem", array("object", "subitem"));
16909}
16910
16911?>
16912<#3989>
16913<?php
16914    $ilCtrlStructureReader->getStructure();
16915?>
16916<#3990>
16917<?php
16918    $ilDB->dropTable("il_object_subitem");
16919?>
16920<#3991>
16921<?php
16922
16923if (!$ilDB->tableExists("il_object_sub_type")) {
16924    $fields = array(
16925        "obj_type" => array(
16926            'type' => 'text',
16927            'length' => 10,
16928            'notnull' => true
16929        ),
16930        "sub_type" => array(
16931            'type' => 'text',
16932            'length' => 10,
16933            'notnull' => true
16934        ),
16935        "amet" => array(
16936            'type' => 'integer',
16937            'length' => 1,
16938            'notnull' => true,
16939            'default' => 0
16940        )
16941        );
16942
16943    $ilDB->createTable(
16944        'il_object_sub_type',
16945        $fields
16946    );
16947
16948    $ilDB->addPrimaryKey("il_object_sub_type", array("obj_type", "sub_type"));
16949}
16950
16951?>
16952<#3992>
16953<?php
16954    $ilCtrlStructureReader->getStructure();
16955?>
16956<#3993>
16957<?php
16958
16959if (!$ilDB->tableColumnExists("adv_md_record_objs", "sub_type")) {
16960    $def = array(
16961            'type' => 'text',
16962            'length' => 10,
16963            'notnull' => false
16964        );
16965    $ilDB->addTableColumn("adv_md_record_objs", "sub_type", $def);
16966}
16967?>
16968<#3994>
16969<?php
16970
16971if (!$ilDB->tableColumnExists("adv_md_values", "sub_type")) {
16972    $def = array(
16973            'type' => 'text',
16974            'length' => 10,
16975            'notnull' => true,
16976            'default' => "-"
16977        );
16978    $ilDB->addTableColumn("adv_md_values", "sub_type", $def);
16979}
16980?>
16981<#3995>
16982<?php
16983
16984if (!$ilDB->tableColumnExists("adv_md_values", "sub_id")) {
16985    $def = array(
16986            'type' => 'integer',
16987            'length' => 4,
16988            'notnull' => true,
16989            'default' => 0
16990        );
16991    $ilDB->addTableColumn("adv_md_values", "sub_id", $def);
16992}
16993?>
16994<#3996>
16995<?php
16996
16997$ilDB->dropPrimaryKey("adv_md_values");
16998$ilDB->addPrimaryKey("adv_md_values", array("obj_id", "field_id", "sub_type", "sub_id"));
16999
17000?>
17001<#3997>
17002<?php
17003$ilDB->dropTableColumn("adv_md_record_objs", "sub_type");
17004if (!$ilDB->tableColumnExists("adv_md_record_objs", "sub_type")) {
17005    $def = array(
17006            'type' => 'text',
17007            'length' => 10,
17008            'notnull' => true,
17009            'default' => "-"
17010        );
17011    $ilDB->addTableColumn("adv_md_record_objs", "sub_type", $def);
17012}
17013?>
17014<#3998>
17015<?php
17016    $ilDB->dropPrimaryKey("adv_md_record_objs");
17017    $ilDB->addPrimaryKey("adv_md_record_objs", array("record_id", "obj_type", "sub_type"));
17018?>
17019<#3999>
17020<?php
17021
17022if (!$ilDB->tableExists("adv_md_obj_rec_select")) {
17023    $fields = array(
17024        "obj_id" => array(
17025            'type' => 'integer',
17026            'length' => 4,
17027            'notnull' => true
17028        ),
17029        "rec_id" => array(
17030            'type' => 'integer',
17031            'length' => 4,
17032            'notnull' => true
17033        )
17034        );
17035
17036    $ilDB->createTable(
17037        'adv_md_obj_rec_select',
17038        $fields
17039    );
17040
17041    $ilDB->addPrimaryKey("adv_md_obj_rec_select", array("obj_id", "rec_id"));
17042}
17043
17044?>
17045<#4000>
17046<?php
17047$ilDB->dropPrimaryKey("adv_md_obj_rec_select");
17048$ilDB->dropTable("adv_md_obj_rec_select");
17049if (!$ilDB->tableExists("adv_md_obj_rec_select")) {
17050    $fields = array(
17051        "obj_id" => array(
17052            'type' => 'integer',
17053            'length' => 4,
17054            'notnull' => true
17055        ),
17056        "sub_type" => array(
17057            'type' => 'text',
17058            'length' => 10,
17059            'notnull' => true,
17060            'default' => "-"
17061        ),
17062        "rec_id" => array(
17063            'type' => 'integer',
17064            'length' => 4,
17065            'notnull' => true
17066        )
17067        );
17068
17069    $ilDB->createTable(
17070        'adv_md_obj_rec_select',
17071        $fields
17072    );
17073
17074    $ilDB->addPrimaryKey("adv_md_obj_rec_select", array("obj_id", "sub_type", "rec_id"));
17075}
17076
17077?>
17078<#4001>
17079<?php
17080if (!$ilDB->tableColumnExists("il_new_item_grp", "type")) {
17081    $def = array(
17082            'type' => 'integer',
17083            'length' => 1,
17084            'notnull' => true,
17085            'default' => 1
17086        );
17087    $ilDB->addTableColumn("il_new_item_grp", "type", $def);
17088}
17089?>
17090<#4002>
17091<?php
17092    $ilCtrlStructureReader->getStructure();
17093?>
17094<#4003>
17095<?php
17096    $ilCtrlStructureReader->getStructure();
17097?>
17098<#4004>
17099<?php
17100
17101    $ilDB->addTableColumn('tst_active', 'tmplastindex', array(
17102            'type' => 'integer',
17103            'length' => 4,
17104            'notnull' => true,
17105            'default' => 0
17106    ));
17107
17108    $ilDB->manipulate('UPDATE tst_active SET tmplastindex = lastindex');
17109
17110    $ilDB->dropTableColumn('tst_active', 'lastindex');
17111
17112    $ilDB->addTableColumn('tst_active', 'lastindex', array(
17113            'type' => 'integer',
17114            'length' => 4,
17115            'notnull' => true,
17116            'default' => 0
17117    ));
17118
17119    $ilDB->manipulate('UPDATE tst_active SET lastindex = tmplastindex');
17120
17121    $ilDB->dropTableColumn('tst_active', 'tmplastindex');
17122
17123?>
17124<#4005>
17125<?php
17126
17127    if (!$ilDB->tableColumnExists('ecs_import', 'content_id')) {
17128        $ilDB->addTableColumn(
17129            'ecs_import',
17130            'content_id',
17131            array(
17132                    "type" => "text",
17133                    "notnull" => false,
17134                    "length" => 255,
17135                    'default' => ''
17136                )
17137        );
17138    }
17139?>
17140<#4006>
17141<?php
17142    $ilCtrlStructureReader->getStructure();
17143?>
17144<#4007>
17145<?php
17146    $ilCtrlStructureReader->getStructure();
17147?>
17148<#4008>
17149<?php
17150    $ilCtrlStructureReader->getStructure();
17151?>
17152<#4009>
17153<?php
17154    $ilCtrlStructureReader->getStructure();
17155?>
17156<#4010>
17157<?php
17158$ilDB->manipulate("UPDATE page_object" .
17159    " SET parent_type = " . $ilDB->quote("cont", "text") .
17160    " WHERE " . $ilDB->in("parent_type", array("cat","crs","fold","grp","root"), "", "text"));
17161
17162?>
17163<#4011>
17164<?php
17165$ilDB->manipulate("UPDATE int_link" .
17166    " SET source_type = " . $ilDB->quote("cont:pg", "text") .
17167    " WHERE " . $ilDB->in("source_type", array("cat:pg","crs:pg","fold:pg","grp:pg","root:pg"), "", "text"));
17168
17169?>
17170<#4012>
17171<?php
17172$ilDB->manipulate("UPDATE page_style_usage" .
17173    " SET page_type = " . $ilDB->quote("cont", "text") .
17174    " WHERE " . $ilDB->in("page_type", array("cat","crs","fold","grp","root"), "", "text"));
17175
17176?>
17177<#4013>
17178<?php
17179$ilDB->manipulate("UPDATE page_pc_usage" .
17180    " SET usage_type = " . $ilDB->quote("cont:pg", "text") .
17181    " WHERE " . $ilDB->in("usage_type", array("cat:pg","crs:pg","fold:pg","grp:pg","root:pg"), "", "text"));
17182
17183?>
17184<#4014>
17185<?php
17186$ilDB->manipulate("UPDATE page_anchor" .
17187    " SET page_parent_type = " . $ilDB->quote("cont", "text") .
17188    " WHERE " . $ilDB->in("page_parent_type", array("cat","crs","fold","grp","root"), "", "text"));
17189
17190?>
17191<#4015>
17192<?php
17193$ilDB->manipulate("UPDATE page_question" .
17194    " SET page_parent_type = " . $ilDB->quote("cont", "text") .
17195    " WHERE " . $ilDB->in("page_parent_type", array("cat","crs","fold","grp","root"), "", "text"));
17196
17197?>
17198<#4016>
17199<?php
17200$ilDB->manipulate("UPDATE mob_usage" .
17201    " SET usage_type = " . $ilDB->quote("cont:pg", "text") .
17202    " WHERE " . $ilDB->in("usage_type", array("cat:pg","crs:pg","fold:pg","grp:pg","root:pg"), "", "text"));
17203
17204?>
17205<#4017>
17206<?php
17207$ilDB->manipulate("UPDATE file_usage" .
17208    " SET usage_type = " . $ilDB->quote("cont:pg", "text") .
17209    " WHERE " . $ilDB->in("usage_type", array("cat:pg","crs:pg","fold:pg","grp:pg","root:pg"), "", "text"));
17210
17211?>
17212<#4018>
17213<?php
17214    $ilCtrlStructureReader->getStructure();
17215?>
17216<#4019>
17217<?php
17218if (!$ilDB->tableExists('copg_pobj_def')) {
17219    $fields = array(
17220        'parent_type' => array(
17221            'type' => 'text',
17222            'length' => 20,
17223            'notnull' => true
17224        ),
17225        'class_name' => array(
17226            'type' => 'text',
17227            'length' => 80,
17228            'notnull' => true
17229        ),
17230        'directory' => array(
17231            'type' => 'text',
17232            'length' => 40,
17233            'notnull' => false
17234        ),
17235        "component" => array(
17236            "type" => "text",
17237            "notnull" => false,
17238            "length" => 40)
17239    );
17240    $ilDB->createTable('copg_pobj_def', $fields);
17241    $ilDB->addPrimaryKey('copg_pobj_def', array('parent_type'));
17242}
17243
17244?>
17245<#4020>
17246<?php
17247    $ilCtrlStructureReader->getStructure();
17248?>
17249<#4021>
17250<?php
17251    $ilCtrlStructureReader->getStructure();
17252?>
17253<#4022>
17254<?php
17255
17256include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
17257
17258$prtt_type_id = ilDBUpdateNewObjectType::addNewType('prtt', 'Portfolio Template Object');
17259
17260$rbac_ops = array(
17261    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
17262    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
17263    ilDBUpdateNewObjectType::RBAC_OP_READ,
17264    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
17265    ilDBUpdateNewObjectType::RBAC_OP_DELETE,
17266    ilDBUpdateNewObjectType::RBAC_OP_COPY
17267);
17268ilDBUpdateNewObjectType::addRBACOperations($prtt_type_id, $rbac_ops);
17269
17270$parent_types = array('root', 'cat', 'crs', 'fold', 'grp');
17271ilDBUpdateNewObjectType::addRBACCreate('create_prtt', 'Create Portfolio Template', $parent_types);
17272
17273?>
17274<#4023>
17275<?php
17276    $ilCtrlStructureReader->getStructure();
17277?>
17278<#4024>
17279<?php
17280    $ilCtrlStructureReader->getStructure();
17281?>
17282<#4025>
17283<?php
17284    if (!$ilDB->tableColumnExists("tst_tests", "sign_submission")) {
17285        $def = array(
17286            'type' => 'integer',
17287            'length' => 4,
17288            'notnull' => true,
17289            'default' => 0
17290        );
17291        $ilDB->addTableColumn("tst_tests", "sign_submission", $def);
17292    }
17293?>
17294<#4026>
17295<?php
17296$ilCtrlStructureReader->getStructure();
17297?>
17298<#4027>
17299<?php
17300    $ilDB->manipulateF(
17301    "UPDATE adm_set_templ_value SET setting = %s, value = %s
17302				WHERE setting = %s AND value = %s",
17303    array('text', 'text', 'text', 'text'),
17304    array('question_set_type', 'FIXED_QUEST_SET', 'random_test', '0')
17305);
17306    $ilDB->manipulateF(
17307        "UPDATE adm_set_templ_value SET setting = %s, value = %s
17308				WHERE setting = %s AND value = %s",
17309        array('text', 'text', 'text', 'text'),
17310        array('question_set_type', 'RANDOM_QUEST_SET', 'random_test', '1')
17311    );
17312?>
17313<#4028>
17314<?php
17315$ilCtrlStructureReader->getStructure();
17316?>
17317<#4029>
17318<?php
17319$ilDB->manipulateF(
17320    "UPDATE qpl_questions SET add_cont_edit_mode = %s WHERE add_cont_edit_mode IS NULL",
17321    array('text'),
17322    array('default')
17323);
17324?>
17325<#4030>
17326<?php
17327include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
17328
17329$orgu_type_id = ilDBUpdateNewObjectType::addNewType('orgu', 'Organisational Unit');
17330
17331$rbac_ops = array(
17332    ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS,
17333    ilDBUpdateNewObjectType::RBAC_OP_VISIBLE,
17334    ilDBUpdateNewObjectType::RBAC_OP_READ,
17335    ilDBUpdateNewObjectType::RBAC_OP_WRITE,
17336    ilDBUpdateNewObjectType::RBAC_OP_DELETE,
17337    ilDBUpdateNewObjectType::RBAC_OP_COPY
17338);
17339ilDBUpdateNewObjectType::addRBACOperations($orgu_type_id, $rbac_ops);
17340
17341$parent_types = array('root', 'orgu');
17342ilDBUpdateNewObjectType::addRBACCreate('create_orgu', 'Create OrgUnit', $parent_types);
17343
17344$ilCtrlStructureReader->getStructure();
17345?>
17346
17347<#4031>
17348<?php
17349// create object data entry
17350$id = $ilDB->nextId("object_data");
17351$ilDB->manipulateF(
17352    "INSERT INTO object_data (obj_id, type, title, description, owner, create_date, last_update) " .
17353    "VALUES (%s, %s, %s, %s, %s, %s, %s)",
17354    array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
17355    array($id, "orgu", "__OrgUnitAdministration", "Organisationsal Units", -1, ilUtil::now(), ilUtil::now())
17356);
17357
17358// create object reference entry
17359$ref_id = $ilDB->nextId('object_reference');
17360$res = $ilDB->manipulateF(
17361    "INSERT INTO object_reference (ref_id, obj_id) VALUES (%s, %s)",
17362    array("integer", "integer"),
17363    array($ref_id, $id)
17364);
17365
17366// put in tree
17367$tree = new ilTree(ROOT_FOLDER_ID);
17368$tree->insertNode($ref_id, SYSTEM_FOLDER_ID);
17369?>
17370
17371<#4032>
17372<?php
17373require_once("./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php");
17374$orgu_type_id = ilDBUpdateNewObjectType::getObjectTypeId('orgu');
17375if ($orgu_type_id) {
17376    $adm_ops_id = ilDBUpdateNewObjectType::getCustomRBACOperationId('cat_administrate_users');
17377    $shw_ops_id = ilDBUpdateNewObjectType::getCustomRBACOperationId('read_users');
17378    if ($adm_ops_id && $shw_ops_id) {
17379        ilDBUpdateNewObjectType::addRBACOperation($orgu_type_id, $adm_ops_id);
17380        ilDBUpdateNewObjectType::addRBACOperation($orgu_type_id, $shw_ops_id);
17381    }
17382}
17383?>
17384<#4033>
17385<?php
17386require_once("./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php");
17387$orgu_type_id = ilDBUpdateNewObjectType::getObjectTypeId('orgu');
17388if ($orgu_type_id) {
17389    $view_lp = ilDBUpdateNewObjectType::addCustomRBACOperation('view_learning_progress', 'View learning progress from users in this orgu.', 'object', 270);
17390    $view_lp_rec = ilDBUpdateNewObjectType::addCustomRBACOperation('view_learning_progress_rec', 'View learning progress from users in this orgu and subsequent orgus.', 'object', 280);
17391    if ($view_lp && $view_lp_rec) {
17392        ilDBUpdateNewObjectType::addRBACOperation($orgu_type_id, $view_lp);
17393        ilDBUpdateNewObjectType::addRBACOperation($orgu_type_id, $view_lp_rec);
17394    }
17395}
17396?>
17397
17398<#4034>
17399<?php
17400require_once("./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php");
17401$orgu_type_id = ilDBUpdateNewObjectType::getObjectTypeId('orgu');
17402if ($orgu_type_id) {
17403    $view_lp = ilDBUpdateNewObjectType::addCustomRBACOperation('view_learning_progress', 'View learning progress from users in this orgu.', 'object', 270);
17404    $view_lp_rec = ilDBUpdateNewObjectType::addCustomRBACOperation('view_learning_progress_rec', 'View learning progress from users in this orgu and subsequent orgus.', 'object', 280);
17405    if ($view_lp && $view_lp_rec) {
17406        ilDBUpdateNewObjectType::addRBACOperation($orgu_type_id, $view_lp);
17407        ilDBUpdateNewObjectType::addRBACOperation($orgu_type_id, $view_lp_rec);
17408    }
17409}
17410?>
17411<#4035>
17412	<?php
17413    //ORGU TEMPLATES
17414    $orgu_employee_contributor_tpl_id = $ilDB->nextId('object_data');
17415
17416    $ilDB->manipulateF(
17417        "INSERT INTO object_data (obj_id, type, title, description," .
17418    " owner, create_date, last_update) VALUES (%s, %s, %s, %s, %s, %s, %s)",
17419        array("integer", "text", "text", "text", "integer", "timestamp", "timestamp"),
17420        array($orgu_employee_contributor_tpl_id, "rolt", "il_orgu_superior",
17421    "OrgUnit Superior Role Template", -1, ilUtil::now(), ilUtil::now())
17422    );
17423
17424    $query = 'SELECT ops_id FROM rbac_operations WHERE operation = ' .
17425    $ilDB->quote('view_learning_progress', 'text');
17426    $rset = $ilDB->query($query);
17427    $row = $ilDB->fetchAssoc($rset);
17428    $view_lp = $row['ops_id'];
17429    if ($view_lp) {
17430        // See LP
17431        $ilDB->manipulateF(
17432            "INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" .
17433    " VALUES (%s, %s, %s, %s)",
17434            array("integer", "text", "integer", "integer"),
17435            array($orgu_employee_contributor_tpl_id, "orgu", $view_lp, 8)
17436        );
17437        //Show
17438        $ilDB->manipulateF(
17439            "INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" .
17440    " VALUES (%s, %s, %s, %s)",
17441            array("integer", "text", "integer", "integer"),
17442            array($orgu_employee_contributor_tpl_id, "orgu", 2, 8)
17443        );
17444        //Read
17445        $ilDB->manipulateF(
17446            "INSERT INTO rbac_templates (rol_id, type, ops_id, parent)" .
17447    " VALUES (%s, %s, %s, %s)",
17448            array("integer", "text", "integer", "integer"),
17449            array($orgu_employee_contributor_tpl_id, "orgu", 3, 8)
17450        );
17451        //No idea
17452        $ilDB->manipulateF(
17453            "INSERT INTO rbac_fa (rol_id, parent, assign, protected)" .
17454    " VALUES (%s, %s, %s, %s)",
17455            array("integer", "integer", "text", "text"),
17456            array($orgu_employee_contributor_tpl_id, 8, "n", "n")
17457        );
17458    }
17459?>
17460<#4036>
17461<?php
17462if (!$ilDB->tableColumnExists('tst_dyn_quest_set_cfg', 'source_qpl_title')) {
17463    $ilDB->addTableColumn('tst_dyn_quest_set_cfg', 'source_qpl_title', array(
17464        'type' => 'text',
17465        'length' => 255,
17466        'notnull' => false,
17467        'default' => null
17468    ));
17469}
17470?>
17471<#4037>
17472<?php
17473if (!$ilDB->tableExists('skl_usage')) {
17474    $fields = array(
17475        'obj_id' => array(
17476            'type' => 'integer',
17477            'length' => 4,
17478            'notnull' => true,
17479            'default' => 0
17480        ),
17481        'skill_id' => array(
17482            'type' => 'integer',
17483            'length' => 4,
17484            'notnull' => true,
17485            'default' => 0
17486        ),
17487        'tref_id' => array(
17488            'type' => 'integer',
17489            'length' => 4,
17490            'notnull' => true,
17491            'default' => 0
17492        )
17493
17494    );
17495    $ilDB->createTable('skl_usage', $fields);
17496    $ilDB->addPrimaryKey('skl_usage', array('obj_id', 'skill_id', 'tref_id'));
17497}
17498
17499?>
17500<#4038>
17501<?php
17502    $ilCtrlStructureReader->getStructure();
17503?>
17504<#4039>
17505<?php
17506
17507if (!$ilDB->tableColumnExists('exc_assignment', 'peer_dl')) {
17508    $ilDB->addTableColumn(
17509        "exc_assignment",
17510        "peer_dl",
17511        array(
17512            "type" => "integer",
17513            "length" => 4,
17514            "notnull" => false,
17515            "default" => 0)
17516    );
17517}
17518?>
17519<#4040>
17520<?php
17521
17522/* mysql only :(
17523$ilDB->manipulate("UPDATE cal_entries ce".
17524    " JOIN cal_cat_assignments ccass ON (ccass.cal_id = ce.cal_id)".
17525    " JOIN cal_categories ccat ON (ccat.cat_id = ccass.cat_id)".
17526    " SET ce.subtitle = ".$ilDB->quote("#consultationhour#", "text").
17527    " WHERE ccat.type = ".$ilDB->quote(4, "integer"));
17528*/
17529
17530$entry_ids = array();
17531$set = $ilDB->query("SELECT ce.cal_id" .
17532    " FROM cal_entries ce" .
17533    " JOIN cal_cat_assignments ccass ON (ccass.cal_id = ce.cal_id)" .
17534    " JOIN cal_categories ccat ON (ccat.cat_id = ccass.cat_id)" .
17535    " WHERE ccat.type = " . $ilDB->quote(4, "integer"));
17536while ($row = $ilDB->fetchAssoc($set)) {
17537    $entry_ids[] = $row["cal_id"];
17538}
17539if (sizeof($entry_ids)) {
17540    $ilDB->manipulate("UPDATE cal_entries" .
17541        " SET subtitle = " . $ilDB->quote("#consultationhour#", "text") .
17542        " WHERE " . $ilDB->in("cal_id", $entry_ids, "", "integer"));
17543}
17544
17545?>
17546<#4041>
17547<?php
17548    if (!$ilDB->tableColumnExists('page_object', 'lang')) {
17549        $ilDB->addTableColumn('page_object', 'lang', array(
17550            'type' => 'text',
17551            'length' => 2,
17552            'notnull' => true,
17553            'default' => "-"
17554        ));
17555    }
17556?>
17557<#4042>
17558<?php
17559    $ilDB->dropPrimaryKey("page_object");
17560    $ilDB->addPrimaryKey('page_object', array('page_id', 'parent_type', 'lang'));
17561?>
17562<#4043>
17563<?php
17564    if (!$ilDB->tableColumnExists('page_history', 'lang')) {
17565        $ilDB->addTableColumn('page_history', 'lang', array(
17566            'type' => 'text',
17567            'length' => 2,
17568            'notnull' => true,
17569            'default' => "-"
17570        ));
17571    }
17572?>
17573<#4044>
17574<?php
17575    $ilDB->dropPrimaryKey("page_history");
17576    $ilDB->addPrimaryKey('page_history', array('page_id', 'parent_type', 'hdate', 'lang'));
17577?>
17578<#4045>
17579<?php
17580    include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
17581
17582    ilDBUpdateNewObjectType::updateOperationOrder('files_visible', 3210);
17583    ilDBUpdateNewObjectType::updateOperationOrder('folders_visible', 3220);
17584    ilDBUpdateNewObjectType::updateOperationOrder('download', 3230);
17585    ilDBUpdateNewObjectType::updateOperationOrder('upload', 3240);
17586    ilDBUpdateNewObjectType::updateOperationOrder('folders_create', 3250);
17587    ilDBUpdateNewObjectType::updateOperationOrder('delete_files', 3260);
17588    ilDBUpdateNewObjectType::updateOperationOrder('delete_folders', 3270);
17589?>
17590<#4046>
17591<?php
17592if (!$ilDB->tableExists('copg_multilang')) {
17593    $fields = array(
17594        'parent_type' => array(
17595            'type' => 'text',
17596            'length' => 10,
17597            'notnull' => true,
17598            'default' => 0
17599        ),
17600        'parent_id' => array(
17601            'type' => 'integer',
17602            'length' => 4,
17603            'notnull' => true,
17604            'default' => 0
17605        ),
17606        'master_lang' => array(
17607            'type' => 'text',
17608            'length' => 2,
17609            'notnull' => true
17610        )
17611    );
17612    $ilDB->createTable('copg_multilang', $fields);
17613    $ilDB->addPrimaryKey('copg_multilang', array('parent_type', 'parent_id'));
17614}
17615
17616?>
17617<#4047>
17618<?php
17619if (!$ilDB->tableExists('copg_multilang_lang')) {
17620    $fields = array(
17621        'parent_type' => array(
17622            'type' => 'text',
17623            'length' => 10,
17624            'notnull' => true,
17625            'default' => 0
17626        ),
17627        'parent_id' => array(
17628            'type' => 'integer',
17629            'length' => 4,
17630            'notnull' => true,
17631            'default' => 0
17632        ),
17633        'lang' => array(
17634            'type' => 'text',
17635            'length' => 2,
17636            'notnull' => true
17637        )
17638    );
17639    $ilDB->createTable('copg_multilang_lang', $fields);
17640    $ilDB->addPrimaryKey('copg_multilang_lang', array('parent_type', 'parent_id', 'lang'));
17641}
17642
17643?>
17644<#4048>
17645<?php
17646$res = $ilDB->queryF(
17647    'SELECT question_type_id, plugin FROM qpl_qst_type WHERE type_tag = %s',
17648    array('text'),
17649    array('assFormulaQuestion')
17650);
17651$row = $ilDB->fetchAssoc($res);
17652
17653if ((int) $row['question_type_id']) {
17654    if ((int) $row['plugin']) {
17655        $ilDB->manipulateF(
17656            'UPDATE qpl_qst_type SET plugin = %s WHERE question_type_id = %s',
17657            array('integer', 'integer'),
17658            array(0, (int) $row['question_type_id'])
17659        );
17660    }
17661} else {
17662    $res = $ilDB->query('SELECT MAX(question_type_id) maxid FROM qpl_qst_type');
17663    $data = $ilDB->fetchAssoc($res);
17664    $max = $data['maxid'] + 1;
17665
17666    $ilDB->manipulateF(
17667        'INSERT INTO qpl_qst_type (question_type_id, type_tag, plugin) VALUES (%s, %s, %s)',
17668        array('integer', 'text', 'integer'),
17669        array($max, 'assFormulaQuestion', 0)
17670    );
17671}
17672?>
17673<#4049>
17674<?php
17675if (!$ilDB->tableExists('il_qpl_qst_fq_unit')) {
17676    $fields = array(
17677        'unit_id' => array(
17678            'type' => 'integer',
17679            'length' => 4,
17680            'notnull' => true,
17681            'default' => 0
17682        ),
17683        'unit' => array(
17684            'type' => 'text',
17685            'length' => 255,
17686            'notnull' => false,
17687            'default' => null
17688        ),
17689        'factor' => array(
17690            'type' => 'float',
17691            'notnull' => true,
17692            'default' => 0
17693        ),
17694        'baseunit_fi' => array(
17695            'type' => 'integer',
17696            'length' => 4,
17697            'notnull' => true,
17698            'default' => 0
17699        ),
17700        'category_fi' => array(
17701            'type' => 'integer',
17702            'length' => 4,
17703            'notnull' => true,
17704            'default' => 0
17705        ),
17706        'sequence' => array(
17707            'type' => 'integer',
17708            'length' => 4,
17709            'notnull' => true,
17710            'default' => 0
17711        )
17712    );
17713    $ilDB->createTable('il_qpl_qst_fq_unit', $fields);
17714    $ilDB->addPrimaryKey('il_qpl_qst_fq_unit', array('unit_id'));
17715    $ilDB->createSequence('il_qpl_qst_fq_unit');
17716    $ilDB->addIndex('il_qpl_qst_fq_unit', array('baseunit_fi', 'category_fi'), 'i1');
17717}
17718?>
17719<#4050>
17720<?php
17721if (!$ilDB->tableExists('il_qpl_qst_fq_ucat')) {
17722    $fields = array(
17723        'category_id' => array(
17724            'type' => 'integer',
17725            'length' => 4,
17726            'notnull' => true,
17727            'default' => 0
17728        ),
17729        'category' => array(
17730            'type' => 'text',
17731            'length' => 255,
17732            'notnull' => false,
17733            'default' => null
17734        )
17735    );
17736    $ilDB->createTable('il_qpl_qst_fq_ucat', $fields);
17737    $ilDB->addPrimaryKey('il_qpl_qst_fq_ucat', array('category_id'));
17738    $ilDB->createSequence('il_qpl_qst_fq_ucat');
17739}
17740?>
17741<#4051>
17742<?php
17743if (!$ilDB->tableColumnExists('il_qpl_qst_fq_ucat', 'question_fi')) {
17744    $ilDB->addTableColumn(
17745        'il_qpl_qst_fq_ucat',
17746        'question_fi',
17747        array(
17748            'type' => 'integer',
17749            'length' => 4,
17750            'notnull' => true,
17751            'default' => 0
17752        )
17753    );
17754}
17755?>
17756<#4052>
17757<?php
17758if (!$ilDB->tableExists('il_qpl_qst_fq_res')) {
17759    $fields = array(
17760        'result_id' => array(
17761            'type' => 'integer',
17762            'length' => 4,
17763            'notnull' => true,
17764            'default' => 0
17765        ),
17766        'question_fi' => array(
17767            'type' => 'integer',
17768            'length' => 4,
17769            'notnull' => true,
17770            'default' => 0
17771        ),
17772        'result' => array(
17773            'type' => 'text',
17774            'length' => 255,
17775            'notnull' => false,
17776            'default' => null
17777        ),
17778        'range_min' => array(
17779            'type' => 'float',
17780            'notnull' => true,
17781            'default' => 0
17782        ),
17783        'range_max' => array(
17784            'type' => 'float',
17785            'notnull' => true,
17786            'default' => 0
17787        ),
17788        'tolerance' => array(
17789            'type' => 'float',
17790            'notnull' => true,
17791            'default' => 0
17792        ),
17793        'unit_fi' => array(
17794            'type' => 'integer',
17795            'length' => 4,
17796            'notnull' => true,
17797            'default' => 0
17798        ),
17799        'formula' => array(
17800            'type' => 'clob',
17801            'notnull' => false,
17802            'default' => null
17803        ),
17804        'rating_simple' => array(
17805            'type' => 'integer',
17806            'length' => 4,
17807            'notnull' => true,
17808            'default' => 1
17809        ),
17810        'rating_sign' => array(
17811            'type' => 'float',
17812            'notnull' => true,
17813            'default' => 0.25
17814        ),
17815        'rating_value' => array(
17816            'type' => 'float',
17817            'notnull' => true,
17818            'default' => 0.25
17819        ),
17820        'rating_unit' => array(
17821            'type' => 'float',
17822            'notnull' => true,
17823            'default' => 0.25
17824        ),
17825        'points' => array(
17826            'type' => 'float',
17827            'notnull' => true,
17828            'default' => 0
17829        ),
17830        'resprecision' => array(
17831            'type' => 'integer',
17832            'length' => 4,
17833            'notnull' => true,
17834            'default' => 0
17835        )
17836    );
17837    $ilDB->createTable('il_qpl_qst_fq_res', $fields);
17838    $ilDB->addPrimaryKey('il_qpl_qst_fq_res', array('result_id'));
17839    $ilDB->createSequence('il_qpl_qst_fq_res');
17840    $ilDB->addIndex('il_qpl_qst_fq_res', array('question_fi', 'result'), 'i1');
17841}
17842?>
17843<#4053>
17844<?php
17845if (!$ilDB->tableColumnExists('il_qpl_qst_fq_res', 'result_type')) {
17846    $ilDB->addTableColumn(
17847        'il_qpl_qst_fq_res',
17848        'result_type',
17849        array(
17850            'type' => 'integer',
17851            'length' => 4,
17852            'notnull' => true,
17853            'default' => 0
17854        )
17855    );
17856}
17857?>
17858<#4054>
17859<?php
17860if (!$ilDB->tableColumnExists('il_qpl_qst_fq_res', 'range_min_txt')) {
17861    $ilDB->addTableColumn(
17862        'il_qpl_qst_fq_res',
17863        'range_min_txt',
17864        array('type' => 'text', 'length' => 4000, 'notnull' => false)
17865    );
17866}
17867if (!$ilDB->tableColumnExists('il_qpl_qst_fq_res', 'range_max_txt')) {
17868    $ilDB->addTableColumn(
17869        'il_qpl_qst_fq_res',
17870        'range_max_txt',
17871        array('type' => 'text', 'length' => 4000, 'notnull' => false)
17872    );
17873}
17874?>
17875<#4055>
17876<?php
17877if (!$ilDB->tableExists('il_qpl_qst_fq_var')) {
17878    $fields = array(
17879        'variable_id' => array(
17880            'type' => 'integer',
17881            'length' => 4,
17882            'notnull' => true,
17883            'default' => 0
17884        ),
17885        'question_fi' => array(
17886            'type' => 'integer',
17887            'length' => 4,
17888            'notnull' => true,
17889            'default' => 0
17890        ),
17891        'variable' => array(
17892            'type' => 'text',
17893            'length' => 255,
17894            'notnull' => false,
17895            'default' => null
17896        ),
17897        'range_min' => array(
17898            'type' => 'float',
17899            'notnull' => true,
17900            'default' => 0
17901        ),
17902        'range_max' => array(
17903            'type' => 'float',
17904            'notnull' => true,
17905            'default' => 0
17906        ),
17907        'unit_fi' => array(
17908            'type' => 'integer',
17909            'length' => 4,
17910            'notnull' => true,
17911            'default' => 0
17912        ),
17913        'step_dim_min' => array(
17914            'type' => 'integer',
17915            'length' => 4,
17916            'notnull' => true,
17917            'default' => 0
17918        ),
17919        'step_dim_max' => array(
17920            'type' => 'integer',
17921            'length' => 4,
17922            'notnull' => true,
17923            'default' => 0
17924        ),
17925        'varprecision' => array(
17926            'type' => 'integer',
17927            'length' => 4,
17928            'notnull' => true,
17929            'default' => 0
17930        ),
17931        'intprecision' => array(
17932            'type' => 'integer',
17933            'length' => 4,
17934            'notnull' => true,
17935            'default' => 1
17936        )
17937    );
17938    $ilDB->createTable('il_qpl_qst_fq_var', $fields);
17939    $ilDB->addPrimaryKey('il_qpl_qst_fq_var', array('variable_id'));
17940    $ilDB->createSequence('il_qpl_qst_fq_var');
17941    $ilDB->addIndex('il_qpl_qst_fq_var', array('question_fi', 'variable'), 'i1');
17942}
17943?>
17944<#4056>
17945<?php
17946if (!$ilDB->tableColumnExists('il_qpl_qst_fq_var', 'range_min_txt')) {
17947    $ilDB->addTableColumn(
17948        'il_qpl_qst_fq_var',
17949        'range_min_txt',
17950        array('type' => 'text', 'length' => 4000, 'notnull' => false)
17951    );
17952}
17953if (!$ilDB->tableColumnExists('il_qpl_qst_fq_var', 'range_max_txt')) {
17954    $ilDB->addTableColumn(
17955        'il_qpl_qst_fq_var',
17956        'range_max_txt',
17957        array('type' => 'text', 'length' => 4000, 'notnull' => false)
17958    );
17959}
17960?>
17961<#4057>
17962<?php
17963$res = $ilDB->query('SELECT variable_id, range_min, range_max FROM il_qpl_qst_fq_var');
17964while ($row = $ilDB->fetchAssoc($res)) {
17965    $ilDB->update(
17966        'il_qpl_qst_fq_var',
17967        array(
17968            'range_min_txt' => array('text', $row['range_min']),
17969            'range_max_txt' => array('text', $row['range_max']),
17970        ),
17971        array('variable_id' => array('integer', $row['variable_id']))
17972    );
17973}
17974?>
17975<#4058>
17976<?php
17977$res = $ilDB->query('SELECT result_id, range_min, range_max FROM il_qpl_qst_fq_res');
17978while ($row = $ilDB->fetchAssoc($res)) {
17979    $ilDB->update(
17980        'il_qpl_qst_fq_res',
17981        array(
17982            'range_min_txt' => array('text', $row['range_min']),
17983            'range_max_txt' => array('text', $row['range_max']),
17984        ),
17985        array('result_id' => array('integer', $row['result_id']))
17986    );
17987}
17988?>
17989<#4059>
17990<?php
17991if (!$ilDB->tableColumnExists('il_qpl_qst_fq_unit', 'question_fi')) {
17992    $ilDB->addTableColumn(
17993        'il_qpl_qst_fq_unit',
17994        'question_fi',
17995        array(
17996            'type' => 'integer',
17997            'length' => 4,
17998            'notnull' => true,
17999            'default' => 0
18000        )
18001    );
18002}
18003?>
18004<#4060>
18005<?php
18006    $ilCtrlStructureReader->getStructure();
18007?>
18008<#4061>
18009<?php
18010$ilCtrlStructureReader->getStructure();
18011?>
18012<#4062>
18013<?php
18014$ilDB->manipulateF(
18015    "UPDATE il_plugin SET last_update_version = %s WHERE name = %s AND slot_id = %s AND plugin_id = %s",
18016    array('text', 'text', 'text', 'text'),
18017    array('99.0.1', 'assFormulaQuestion', 'qst', 'formulaquestion')
18018);
18019?>
18020<#4063>
18021<?php
18022if (!$ilDB->tableColumnExists('sahs_lm', 'offline_zip_created')) {
18023    $ilDB->addTableColumn(
18024        'sahs_lm',
18025        'offline_zip_created',
18026        array(
18027            'type' => 'timestamp',
18028            'notnull' => false
18029        )
18030    );
18031}
18032?>
18033<#4064>
18034<?php
18035if (!$ilDB->tableColumnExists('sahs_user', 'last_access')) {
18036    $ilDB->addTableColumn(
18037        'sahs_user',
18038        'last_access',
18039        array(
18040            'type' => 'timestamp',
18041            'notnull' => false
18042        )
18043    );
18044}
18045?>
18046<#4065>
18047<?php
18048if (!$ilDB->tableColumnExists('sahs_user', 'total_time_sec')) {
18049    $ilDB->addTableColumn(
18050        'sahs_user',
18051        'total_time_sec',
18052        array(
18053            'type' => 'integer',
18054            'length' => 4,
18055            'notnull' => false
18056        )
18057    );
18058}
18059?>
18060<#4066>
18061<?php
18062if (!$ilDB->tableColumnExists('sahs_user', 'sco_total_time_sec')) {
18063    $ilDB->addTableColumn(
18064        'sahs_user',
18065        'sco_total_time_sec',
18066        array(
18067            'type' => 'integer',
18068            'length' => 4,
18069            'notnull' => false
18070        )
18071    );
18072}
18073?>
18074<#4067>
18075<?php
18076if (!$ilDB->tableColumnExists('sahs_user', 'status')) {
18077    $ilDB->addTableColumn(
18078        'sahs_user',
18079        'status',
18080        array(
18081            'type' => 'integer',
18082            'length' => 1,
18083            'notnull' => false
18084        )
18085    );
18086}
18087?>
18088<#4068>
18089<?php
18090    $ilCtrlStructureReader->getStructure();
18091?>
18092<#4069>
18093<?php
18094if (!$ilDB->tableColumnExists('crs_settings', 'mail_members_type')) {
18095    $ilDB->addTableColumn(
18096        'crs_settings',
18097        'mail_members_type',
18098        array(
18099            'type' => 'integer',
18100            'length' => 1,
18101            'notnull' => false,
18102            'default' => 1
18103        )
18104    );
18105}
18106?>
18107
18108<#4070>
18109<?php
18110if (!$ilDB->tableColumnExists('grp_settings', 'mail_members_type')) {
18111    $ilDB->addTableColumn(
18112        'grp_settings',
18113        'mail_members_type',
18114        array(
18115            'type' => 'integer',
18116            'length' => 1,
18117            'notnull' => false,
18118            'default' => 1
18119        )
18120    );
18121}
18122?>
18123<#4071>
18124<?php
18125if (!$ilDB->tableColumnExists('usr_search', 'mime_filter')) {
18126    $ilDB->addTableColumn(
18127        'usr_search',
18128        'mime_filter',
18129        array(
18130            'type' => 'text',
18131            'length' => 1000,
18132            'notnull' => false
18133        )
18134    );
18135}
18136?>
18137<#4072>
18138<?php
18139    $ilCtrlStructureReader->getStructure();
18140?>
18141<#4073>
18142<?php
18143if (!$ilDB->tableColumnExists('cal_shared', 'writable')) {
18144    $ilDB->addTableColumn(
18145        'cal_shared',
18146        'writable',
18147        array(
18148            'type' => 'integer',
18149            'length' => 1,
18150            'notnull' => false,
18151            'default' => 0
18152        )
18153    );
18154}
18155?>
18156<#4074>
18157<?php
18158//put cmi_custom to sahs_user
18159$set = $ilDB->query("SELECT obj_id,user_id FROM cmi_custom GROUP BY obj_id, user_id");
18160while ($row = $ilDB->fetchAssoc($set)) {
18161    $fields = array();
18162    $fields["obj_id"] = array("integer", $row["obj_id"]);
18163    $fields["user_id"] = array("integer", $row["user_id"]);
18164    $ilDB->insert("sahs_user", $fields);
18165}
18166?>
18167<#4075>
18168<?php
18169    // empty step
18170?>
18171<#4076>
18172<?php
18173    // empty step
18174?>
18175<#4077>
18176<?php
18177// move to sahs_user
18178$set = $ilDB->queryF(
18179    "SELECT obj_id,user_id, max(c_timestamp) last_access FROM cmi_custom WHERE lvalue <> %s GROUP BY obj_id, user_id",
18180    array('text'),
18181    array("hash")
18182);
18183while ($row = $ilDB->fetchAssoc($set)) {
18184    $fields = array();
18185    $fields["last_access"] = array("date", $row["last_access"]);
18186    $where = array();
18187    $where["obj_id"] = array("integer", $row["obj_id"]);
18188    $where["user_id"] = array("integer", $row["user_id"]);
18189    $ilDB->update("sahs_user", $fields, $where);
18190}
18191?>
18192<#4078>
18193<?php
18194$lval = "hash";
18195$lvalField = $lval;
18196$lvalType = "text";
18197$counter = 0;
18198// move to sahs_user
18199$set = $ilDB->queryF(
18200    "SELECT obj_id,user_id,rvalue,c_timestamp FROM cmi_custom WHERE lvalue = %s GROUP BY obj_id, user_id, rvalue, c_timestamp",
18201    array('text'),
18202    array($lval)
18203);
18204while ($row = $ilDB->fetchAssoc($set)) {
18205    $fields = array();
18206    $fields[$lvalField] = array($lvalType, $row["rvalue"]);
18207    $fields["hash_end"] = array("date", $row["c_timestamp"]);
18208    $where = array();
18209    $where["obj_id"] = array("integer", $row["obj_id"]);
18210    $where["user_id"] = array("integer", $row["user_id"]);
18211    $ilDB->update("sahs_user", $fields, $where);
18212    $counter++;
18213}
18214?>
18215<#4079>
18216<?php
18217$lval = "hash";
18218$lvalField = $lval;
18219// delete old values
18220$set = $ilDB->query("SELECT obj_id, user_id FROM sahs_user where " . $lvalField . " is not null");
18221while ($row = $ilDB->fetchAssoc($set)) {
18222    $ilDB->queryF(
18223        "DELETE FROM cmi_custom WHERE lvalue = %s AND obj_id = %s AND user_id = %s",
18224        array('text','integer','integer'),
18225        array($lval,$row["obj_id"],$row["user_id"])
18226    );
18227}
18228?>
18229<#4080>
18230<?php
18231$lval = "package_attempts";
18232$lvalField = $lval;
18233$lvalType = "integer";
18234$counter = 0;
18235// move to sahs_user
18236$set = $ilDB->queryF(
18237    "SELECT obj_id,user_id,rvalue FROM cmi_custom WHERE lvalue = %s GROUP BY obj_id, user_id, rvalue",
18238    array('text'),
18239    array($lval)
18240);
18241while ($row = $ilDB->fetchAssoc($set)) {
18242    $fieldValue = $row["rvalue"];
18243    if ($lvalType == "integer") {
18244        $fieldValue = (int) $fieldValue;
18245    }
18246    $fields = array();
18247    $fields[$lvalField] = array($lvalType, $fieldValue);
18248    $where = array();
18249    $where["obj_id"] = array("integer", $row["obj_id"]);
18250    $where["user_id"] = array("integer", $row["user_id"]);
18251    $ilDB->update("sahs_user", $fields, $where);
18252    $counter++;
18253}
18254?>
18255<#4081>
18256<?php
18257$lval = "package_attempts";
18258$lvalField = $lval;
18259// delete old values
18260$set = $ilDB->query("SELECT obj_id, user_id FROM sahs_user where " . $lvalField . " is not null");
18261while ($row = $ilDB->fetchAssoc($set)) {
18262    $ilDB->queryF(
18263        "DELETE FROM cmi_custom WHERE lvalue = %s AND obj_id = %s AND user_id = %s",
18264        array('text','integer','integer'),
18265        array($lval,$row["obj_id"],$row["user_id"])
18266    );
18267}
18268?>
18269<#4082>
18270<?php
18271$lval = "module_version";
18272$lvalField = $lval;
18273$lvalType = "integer";
18274$counter = 0;
18275// move to sahs_user
18276$set = $ilDB->queryF(
18277    "SELECT obj_id,user_id,rvalue FROM cmi_custom WHERE lvalue = %s GROUP BY obj_id, user_id, rvalue",
18278    array('text'),
18279    array($lval)
18280);
18281while ($row = $ilDB->fetchAssoc($set)) {
18282    $fieldValue = $row["rvalue"];
18283    if ($lvalType == "integer") {
18284        $fieldValue = (int) $fieldValue;
18285    }
18286    $fields = array();
18287    $fields[$lvalField] = array($lvalType, $fieldValue);
18288    $where = array();
18289    $where["obj_id"] = array("integer", $row["obj_id"]);
18290    $where["user_id"] = array("integer", $row["user_id"]);
18291    $ilDB->update("sahs_user", $fields, $where);
18292    $counter++;
18293}
18294?>
18295<#4083>
18296<?php
18297$lval = "module_version";
18298$lvalField = $lval;
18299// delete old values
18300$set = $ilDB->query("SELECT obj_id, user_id FROM sahs_user where " . $lvalField . " is not null");
18301while ($row = $ilDB->fetchAssoc($set)) {
18302    $ilDB->queryF(
18303        "DELETE FROM cmi_custom WHERE lvalue = %s AND obj_id = %s AND user_id = %s",
18304        array('text','integer','integer'),
18305        array($lval,$row["obj_id"],$row["user_id"])
18306    );
18307}
18308?>
18309<#4084>
18310<?php
18311$lval = "last_visited";
18312$lvalField = $lval;
18313$lvalType = "text";
18314$counter = 0;
18315// move to sahs_user
18316$set = $ilDB->queryF(
18317    "SELECT obj_id,user_id,rvalue FROM cmi_custom WHERE lvalue = %s GROUP BY obj_id, user_id, rvalue",
18318    array('text'),
18319    array($lval)
18320);
18321while ($row = $ilDB->fetchAssoc($set)) {
18322    $fieldValue = $row["rvalue"];
18323    if ($lvalType == "integer") {
18324        $fieldValue = (int) $fieldValue;
18325    }
18326    $fields = array();
18327    $fields[$lvalField] = array($lvalType, $fieldValue);
18328    $where = array();
18329    $where["obj_id"] = array("integer", $row["obj_id"]);
18330    $where["user_id"] = array("integer", $row["user_id"]);
18331    $ilDB->update("sahs_user", $fields, $where);
18332    $counter++;
18333}
18334?>
18335<#4085>
18336<?php
18337$lval = "last_visited";
18338$lvalField = $lval;
18339// delete old values
18340$set = $ilDB->query("SELECT obj_id, user_id FROM sahs_user where " . $lvalField . " is not null");
18341while ($row = $ilDB->fetchAssoc($set)) {
18342    $ilDB->queryF(
18343        "DELETE FROM cmi_custom WHERE lvalue = %s AND obj_id = %s AND user_id = %s",
18344        array('text','integer','integer'),
18345        array($lval,$row["obj_id"],$row["user_id"])
18346    );
18347}
18348?>
18349<#4086>
18350<?php
18351if (!$ilDB->tableColumnExists('sahs_user', 'percentage_completed')) {
18352    $ilDB->addTableColumn(
18353        'sahs_user',
18354        'percentage_completed',
18355        array(
18356            'type' => 'integer',
18357            'length' => 1,
18358            'notnull' => false
18359        )
18360    );
18361}
18362?>
18363<#4087>
18364<?php
18365//put scorm_tracking to sahs_user
18366$set = $ilDB->query("SELECT obj_id,user_id FROM scorm_tracking GROUP BY obj_id, user_id");
18367while ($row = $ilDB->fetchAssoc($set)) {
18368    $res = $ilDB->queryF(
18369        "SELECT obj_id, user_id FROM sahs_user WHERE obj_id=%s AND user_id=%s",
18370        array('integer','integer'),
18371        array($row["obj_id"],$row["user_id"])
18372    );
18373    if (!$ilDB->numRows($res)) {
18374        $fields = array();
18375        $fields["obj_id"] = array("integer", $row["obj_id"]);
18376        $fields["user_id"] = array("integer", $row["user_id"]);
18377        $ilDB->insert("sahs_user", $fields);
18378    }
18379}
18380?>
18381<#4088>
18382<?php
18383// move to sahs_user
18384$set = $ilDB->query("SELECT obj_id,user_id, max(c_timestamp) last_access FROM scorm_tracking GROUP BY obj_id, user_id");
18385while ($row = $ilDB->fetchAssoc($set)) {
18386    $fields = array();
18387    $fields["last_access"] = array("date", $row["last_access"]);
18388    $where = array();
18389    $where["obj_id"] = array("integer", $row["obj_id"]);
18390    $where["user_id"] = array("integer", $row["user_id"]);
18391    $ilDB->update("sahs_user", $fields, $where);
18392}
18393?>
18394<#4089>
18395<?php
18396$lval = "package_attempts";
18397$lvalField = $lval;
18398$lvalType = "integer";
18399$counter = 0;
18400// move to sahs_user
18401$set = $ilDB->queryF(
18402    "SELECT obj_id,user_id,rvalue FROM scorm_tracking WHERE lvalue = %s",
18403    array('text'),
18404    array($lval)
18405);
18406while ($row = $ilDB->fetchAssoc($set)) {
18407    $fieldValue = $row["rvalue"];
18408    if ($lvalType == "integer") {
18409        $fieldValue = (int) $fieldValue;
18410    }
18411    $fields = array();
18412    $fields[$lvalField] = array($lvalType, $fieldValue);
18413    $where = array();
18414    $where["obj_id"] = array("integer", $row["obj_id"]);
18415    $where["user_id"] = array("integer", $row["user_id"]);
18416    $ilDB->update("sahs_user", $fields, $where);
18417    $counter++;
18418}
18419?>
18420<#4090>
18421<?php
18422$lval = "package_attempts";
18423$lvalField = $lval;
18424// delete old values
18425$set = $ilDB->query("SELECT obj_id, user_id FROM sahs_user where " . $lvalField . " is not null");
18426while ($row = $ilDB->fetchAssoc($set)) {
18427    $ilDB->queryF(
18428        "DELETE FROM scorm_tracking WHERE lvalue = %s AND obj_id = %s AND user_id = %s",
18429        array('text','integer','integer'),
18430        array($lval,$row["obj_id"],$row["user_id"])
18431    );
18432}
18433?>
18434<#4091>
18435<?php
18436$lval = "module_version";
18437$lvalField = $lval;
18438$lvalType = "integer";
18439$counter = 0;
18440// move to sahs_user
18441$set = $ilDB->queryF(
18442    "SELECT obj_id,user_id,rvalue FROM scorm_tracking WHERE lvalue = %s",
18443    array('text'),
18444    array($lval)
18445);
18446while ($row = $ilDB->fetchAssoc($set)) {
18447    $fieldValue = $row["rvalue"];
18448    if ($lvalType == "integer") {
18449        $fieldValue = (int) $fieldValue;
18450    }
18451    $fields = array();
18452    $fields[$lvalField] = array($lvalType, $fieldValue);
18453    $where = array();
18454    $where["obj_id"] = array("integer", $row["obj_id"]);
18455    $where["user_id"] = array("integer", $row["user_id"]);
18456    $ilDB->update("sahs_user", $fields, $where);
18457    $counter++;
18458}
18459?>
18460<#4092>
18461<?php
18462$lval = "module_version";
18463$lvalField = $lval;
18464// delete old values
18465$set = $ilDB->query("SELECT obj_id, user_id FROM sahs_user where " . $lvalField . " is not null");
18466while ($row = $ilDB->fetchAssoc($set)) {
18467    $ilDB->queryF(
18468        "DELETE FROM scorm_tracking WHERE lvalue = %s AND obj_id = %s AND user_id = %s",
18469        array('text','integer','integer'),
18470        array($lval,$row["obj_id"],$row["user_id"])
18471    );
18472}
18473?>
18474<#4093>
18475<?php
18476$lval = "last_visited";
18477$lvalField = $lval;
18478$lvalType = "text";
18479$counter = 0;
18480// move to sahs_user
18481$set = $ilDB->queryF(
18482    "SELECT obj_id,user_id,rvalue FROM scorm_tracking WHERE lvalue = %s",
18483    array('text'),
18484    array($lval)
18485);
18486while ($row = $ilDB->fetchAssoc($set)) {
18487    $fieldValue = $row["rvalue"];
18488    if ($lvalType == "integer") {
18489        $fieldValue = (int) $fieldValue;
18490    }
18491    $fields = array();
18492    $fields[$lvalField] = array($lvalType, $fieldValue);
18493    $where = array();
18494    $where["obj_id"] = array("integer", $row["obj_id"]);
18495    $where["user_id"] = array("integer", $row["user_id"]);
18496    $ilDB->update("sahs_user", $fields, $where);
18497    $counter++;
18498}
18499?>
18500<#4094>
18501<?php
18502$lval = "last_visited";
18503$lvalField = $lval;
18504// delete old values
18505$set = $ilDB->query("SELECT obj_id, user_id FROM sahs_user where " . $lvalField . " is not null");
18506while ($row = $ilDB->fetchAssoc($set)) {
18507    $ilDB->queryF(
18508        "DELETE FROM scorm_tracking WHERE lvalue = %s AND obj_id = %s AND user_id = %s",
18509        array('text','integer','integer'),
18510        array($lval,$row["obj_id"],$row["user_id"])
18511    );
18512}
18513?>
18514<#4095>
18515<?php
18516    if (!$ilDB->tableColumnExists('int_link', 'source_lang')) {
18517        $ilDB->addTableColumn('int_link', 'source_lang', array(
18518            'type' => 'text',
18519            'length' => 2,
18520            'notnull' => true,
18521            'default' => "-"
18522        ));
18523    }
18524?>
18525<#4096>
18526<?php
18527    $ilDB->dropPrimaryKey("int_link");
18528    $ilDB->addPrimaryKey('int_link', array('source_type', 'source_id', 'source_lang', 'target_type', 'target_id', 'target_inst'));
18529?>
18530<#4097>
18531<?php
18532    if (!$ilDB->tableColumnExists('page_question', 'page_lang')) {
18533        $ilDB->addTableColumn('page_question', 'page_lang', array(
18534            'type' => 'text',
18535            'length' => 2,
18536            'notnull' => true,
18537            'default' => "-"
18538        ));
18539    }
18540?>
18541<#4098>
18542<?php
18543    if (!$ilDB->tableColumnExists('page_style_usage', 'page_lang')) {
18544        $ilDB->addTableColumn('page_style_usage', 'page_lang', array(
18545            'type' => 'text',
18546            'length' => 2,
18547            'notnull' => true,
18548            'default' => "-"
18549        ));
18550    }
18551?>
18552<#4099>
18553<?php
18554    if (!$ilDB->tableColumnExists('mob_usage', 'usage_lang')) {
18555        $ilDB->addTableColumn('mob_usage', 'usage_lang', array(
18556            'type' => 'text',
18557            'length' => 2,
18558            'notnull' => true,
18559            'default' => "-"
18560        ));
18561    }
18562?>
18563<#4100>
18564<?php
18565    $ilDB->dropPrimaryKey("mob_usage");
18566    $ilDB->addPrimaryKey('mob_usage', array('id', 'usage_type', 'usage_id', 'usage_hist_nr', 'usage_lang'));
18567?>
18568<#4101>
18569<?php
18570    if (!$ilDB->tableColumnExists('page_anchor', 'page_lang')) {
18571        $ilDB->addTableColumn('page_anchor', 'page_lang', array(
18572            'type' => 'text',
18573            'length' => 2,
18574            'notnull' => true,
18575            'default' => "-"
18576        ));
18577    }
18578?>
18579<#4102>
18580<?php
18581    $ilDB->dropPrimaryKey("page_anchor");
18582    $ilDB->addPrimaryKey('page_anchor', array('page_parent_type', 'page_id', 'page_lang', 'anchor_name'));
18583?>
18584<#4103>
18585<?php
18586    if (!$ilDB->tableColumnExists('file_usage', 'usage_lang')) {
18587        $ilDB->addTableColumn('file_usage', 'usage_lang', array(
18588            'type' => 'text',
18589            'length' => 2,
18590            'notnull' => true,
18591            'default' => "-"
18592        ));
18593    }
18594?>
18595<#4104>
18596<?php
18597    $ilDB->dropPrimaryKey("file_usage");
18598    $ilDB->addPrimaryKey('file_usage', array('id', 'usage_type', 'usage_id', 'usage_hist_nr', 'usage_lang'));
18599?>
18600<#4105>
18601<?php
18602    if (!$ilDB->tableColumnExists('page_pc_usage', 'usage_lang')) {
18603        $ilDB->addTableColumn('page_pc_usage', 'usage_lang', array(
18604            'type' => 'text',
18605            'length' => 2,
18606            'notnull' => true,
18607            'default' => "-"
18608        ));
18609    }
18610?>
18611<#4106>
18612<?php
18613    $ilDB->dropPrimaryKey("page_pc_usage");
18614    $ilDB->addPrimaryKey('page_pc_usage', array('pc_type', 'pc_id', 'usage_type', 'usage_id', 'usage_hist_nr', 'usage_lang'));
18615?>
18616<#4107>
18617<?php
18618    $ilCtrlStructureReader->getStructure();
18619?>
18620<#4108>
18621<?php
18622    if (!$ilDB->tableColumnExists("page_object", "edit_lock_user")) {
18623        $ilDB->addTableColumn("page_object", "edit_lock_user", array(
18624            "type" => "integer",
18625            "notnull" => false,
18626            "length" => 4));
18627    }
18628
18629?>
18630<#4109>
18631<?php
18632    if (!$ilDB->tableColumnExists("page_object", "edit_lock_ts")) {
18633        $ilDB->addTableColumn("page_object", "edit_lock_ts", array(
18634            "type" => "integer",
18635            "notnull" => true,
18636            "default" => 0,
18637            "length" => 4));
18638    }
18639
18640?>
18641<#4110>
18642<?php
18643    $ilCtrlStructureReader->getStructure();
18644?>
18645<#4111>
18646<?php
18647    if (!$ilDB->tableColumnExists("content_object", "disable_def_feedback")) {
18648        $ilDB->addTableColumn("content_object", "disable_def_feedback", array(
18649            "type" => "integer",
18650            "notnull" => true,
18651            "default" => 0,
18652            "length" => 4));
18653    }
18654
18655?>
18656<#4112>
18657<?php
18658    $ilCtrlStructureReader->getStructure();
18659?>
18660<#4113>
18661<?php
18662    $ilCtrlStructureReader->getStructure();
18663?>
18664<#4114>
18665<?php
18666//fill bibliographic overview model default-patterns (new standard)
18667//BibTeX
18668    $ilDB->manipulateF(
18669        'UPDATE  il_bibl_overview_model SET filetype = %s, literature_type = %s, pattern = %s WHERE ovm_id = %s',
18670        array('text', 'text', 'text', 'integer'),
18671        array('bib', 'default', '[<strong>|bib_default_author|</strong> ][|bib_default_title|]: <Emph>[|bib_default_publisher| ][|bib_default_year| ][|bib_default_address|]</Emph>', 1)
18672    );
18673//RIS
18674    $ilDB->manipulateF(
18675        'UPDATE  il_bibl_overview_model SET filetype = %s, literature_type = %s, pattern = %s WHERE ovm_id = %s',
18676        array('text', 'text', 'text', 'integer'),
18677        array('ris', 'default', '[<strong>|ris_default_a1|</strong> ][<strong>|ris_default_au|</strong> ][|ris_default_t1|][ |ris_default_ti|]: <Emph>[|ris_default_pb| ][|ris_default_y1| ][|ris_default_py| ][|ris_default_cy|]</Emph>',2)
18678    );
18679?>
18680<#4115>
18681<?php
18682    $ilCtrlStructureReader->getStructure();
18683?>
18684<#4116>
18685<?php
18686
18687$ilDB->createTable(
18688    "lm_data_transl",
18689    array(
18690        "id" => array(
18691            "type" => "integer", "length" => 4, "notnull" => true
18692        ),
18693        "lang" => array(
18694            "type" => "text", "length" => 2, "notnull" => true
18695        ),
18696        "title" => array(
18697            "type" => "text", "length" => 200, "notnull" => false
18698        ),
18699        "create_date" => array(
18700            "type" => "timestamp"
18701        ),
18702        "last_update" => array(
18703            "type" => "timestamp"
18704        )
18705    )
18706);
18707
18708$ilDB->addPrimaryKey("lm_data_transl", array("id", "lang"));
18709
18710?>
18711<#4117>
18712<?php
18713    $ilCtrlStructureReader->getStructure();
18714?>
18715
18716<#4118>
18717<?php
18718if (!$ilDB->tableExists('tst_rnd_quest_set_cfg')) {
18719    $ilDB->createTable('tst_rnd_quest_set_cfg', array(
18720        'test_fi' => array(
18721            'type' => 'integer',
18722            'length' => 4,
18723            'notnull' => true,
18724            'default' => 0
18725        ),
18726        'req_pools_homo_scored' => array(
18727            'type' => 'integer',
18728            'length' => 1,
18729            'notnull' => true,
18730            'default' => 0
18731        ),
18732        'quest_amount_cfg_mode' => array(
18733            'type' => 'text',
18734            'length' => 16,
18735            'notnull' => false,
18736            'default' => null
18737        ),
18738        'quest_amount_per_test' => array(
18739            'type' => 'integer',
18740            'length' => 4,
18741            'notnull' => false,
18742            'default' => null
18743        ),
18744        'quest_sync_timestamp' => array(
18745            'type' => 'integer',
18746            'length' => 4,
18747            'notnull' => true,
18748            'default' => 0
18749        )
18750    ));
18751
18752    $ilDB->addPrimaryKey('tst_rnd_quest_set_cfg', array('test_fi'));
18753
18754    $query = "SELECT test_id, random_question_count FROM tst_tests WHERE question_set_type = %s";
18755    $res = $ilDB->queryF($query, array('text'), array('RANDOM_QUEST_SET'));
18756
18757    while ($row = $ilDB->fetchAssoc($res)) {
18758        if ($row['random_question_count'] > 0) {
18759            $quest_amount_cfg_mode = 'TEST';
18760        } else {
18761            $quest_amount_cfg_mode = 'POOL';
18762        }
18763
18764        $ilDB->insert('tst_rnd_quest_set_cfg', array(
18765            'test_fi' => array('integer', $row['test_id']),
18766            'req_pools_homo_scored' => array('integer', 0),
18767            'quest_amount_cfg_mode' => array('text', $quest_amount_cfg_mode),
18768            'quest_amount_per_test' => array('integer', $row['random_question_count'])
18769        ));
18770    }
18771
18772    $ilDB->dropTableColumn('tst_tests', 'random_question_count');
18773}
18774?>
18775<#4119>
18776<?php
18777if (!$ilDB->tableExists('tst_rnd_quest_set_qpls')) {
18778    $ilDB->createTable('tst_rnd_quest_set_qpls', array(
18779        'def_id' => array(
18780            'type' => 'integer',
18781            'length' => 4,
18782            'notnull' => true,
18783            'default' => 0
18784        ),
18785        'test_fi' => array(
18786            'type' => 'integer',
18787            'length' => 4,
18788            'notnull' => true,
18789            'default' => 0
18790        ),
18791        'pool_fi' => array(
18792            'type' => 'integer',
18793            'length' => 4,
18794            'notnull' => true,
18795            'default' => 0
18796        ),
18797        'pool_title' => array(
18798            'type' => 'text',
18799            'length' => 128,
18800            'notnull' => false,
18801            'default' => null
18802        ),
18803        'pool_path' => array(
18804            'type' => 'text',
18805            'length' => 512,
18806            'notnull' => false,
18807            'default' => null
18808        ),
18809        'pool_quest_count' => array(
18810            'type' => 'integer',
18811            'length' => 4,
18812            'notnull' => false,
18813            'default' => null
18814        ),
18815        'origin_tax_fi' => array(
18816            'type' => 'integer',
18817            'length' => 4,
18818            'notnull' => false,
18819            'default' => null
18820        ),
18821        'origin_node_fi' => array(
18822            'type' => 'integer',
18823            'length' => 4,
18824            'notnull' => false,
18825            'default' => null
18826        ),
18827        'mapped_tax_fi' => array(
18828            'type' => 'integer',
18829            'length' => 4,
18830            'notnull' => false,
18831            'default' => null
18832        ),
18833        'mapped_node_fi' => array(
18834            'type' => 'integer',
18835            'length' => 4,
18836            'notnull' => false,
18837            'default' => null
18838        ),
18839        'quest_amount' => array(
18840            'type' => 'integer',
18841            'length' => 4,
18842            'notnull' => false,
18843            'default' => null
18844        ),
18845        'sequence_pos' => array(
18846            'type' => 'integer',
18847            'length' => 4,
18848            'notnull' => false,
18849            'default' => null
18850        )
18851    ));
18852
18853    $ilDB->addPrimaryKey('tst_rnd_quest_set_qpls', array('def_id'));
18854
18855    $ilDB->createSequence('tst_rnd_quest_set_qpls');
18856
18857    $query = "
18858		SELECT		tst_test_random.test_fi,
18859					tst_test_random.questionpool_fi,
18860					tst_rnd_qpl_title.qpl_title,
18861					tst_test_random.num_of_q,
18862					tst_test_random.tstamp,
18863					tst_test_random.sequence
18864
18865		FROM		tst_tests
18866
18867		INNER JOIN	tst_test_random
18868		ON			tst_tests.test_id = tst_test_random.test_fi
18869
18870		LEFT JOIN	tst_rnd_qpl_title
18871		ON			tst_test_random.test_fi = tst_rnd_qpl_title.tst_fi
18872		AND			tst_test_random.questionpool_fi = tst_rnd_qpl_title.qpl_fi
18873
18874		WHERE		question_set_type = %s
18875	";
18876
18877    $res = $ilDB->queryF($query, array('text'), array('RANDOM_QUEST_SET'));
18878
18879    $syncTimes = array();
18880
18881    while ($row = $ilDB->fetchAssoc($res)) {
18882        if (!(int) $row['num_of_q']) {
18883            $row['num_of_q'] = null;
18884        }
18885
18886        $nextId = $ilDB->nextId('tst_rnd_quest_set_qpls');
18887
18888        $ilDB->insert('tst_rnd_quest_set_qpls', array(
18889            'def_id' => array('integer', $nextId),
18890            'test_fi' => array('integer', $row['test_fi']),
18891            'pool_fi' => array('integer', $row['questionpool_fi']),
18892            'pool_title' => array('text', $row['qpl_title']),
18893            'origin_tax_fi' => array('integer', null),
18894            'origin_node_fi' => array('integer', null),
18895            'mapped_tax_fi' => array('integer', null),
18896            'mapped_node_fi' => array('integer', null),
18897            'quest_amount' => array('integer', $row['num_of_q']),
18898            'sequence_pos' => array('integer', $row['sequence'])
18899        ));
18900
18901        if (!is_array($syncTimes[$row['test_fi']])) {
18902            $syncTimes[$row['test_fi']] = array();
18903        }
18904
18905        $syncTimes[$row['test_fi']][] = $row['tstamp'];
18906    }
18907
18908    foreach ($syncTimes as $testId => $times) {
18909        $assumedSyncTS = max($times);
18910
18911        $ilDB->update(
18912            'tst_rnd_quest_set_cfg',
18913            array(
18914                'quest_sync_timestamp' => array('integer', $assumedSyncTS)
18915            ),
18916            array(
18917                'test_fi' => array('integer', $testId)
18918            )
18919        );
18920    }
18921
18922    $ilDB->dropTable('tst_test_random');
18923}
18924?>
18925<#4120>
18926<?php
18927    if (!$ilDB->tableColumnExists('sahs_lm', 'auto_suspend')) {
18928        $ilDB->addTableColumn(
18929            'sahs_lm',
18930            'auto_suspend',
18931            array(
18932                "type" => "text",
18933                'length' => 1,
18934                "notnull" => true,
18935                "default" => 'n'
18936            )
18937        );
18938        $ilDB->query("UPDATE sahs_lm SET auto_suspend = 'n'");
18939    }
18940?>
18941<#4121>
18942<?php
18943if (!$ilDB->tableColumnExists('sahs_user', 'first_access')) {
18944    $ilDB->addTableColumn(
18945        'sahs_user',
18946        'first_access',
18947        array(
18948            'type' => 'timestamp',
18949            'notnull' => false
18950        )
18951    );
18952}
18953?>
18954<#4122>
18955<?php
18956if (!$ilDB->tableColumnExists('sahs_user', 'last_status_change')) {
18957    $ilDB->addTableColumn(
18958        'sahs_user',
18959        'last_status_change',
18960        array(
18961            'type' => 'timestamp',
18962            'notnull' => false
18963        )
18964    );
18965}
18966?>
18967<#4123>
18968<?php
18969    if (!$ilDB->tableColumnExists('crs_f_definitions', 'field_values_opt')) {
18970        $ilDB->addTableColumn('crs_f_definitions', 'field_values_opt', array(
18971            'type' => 'text',
18972            'length' => 1000,
18973            'notnull' => false
18974        ));
18975    }
18976?>
18977<#4124>
18978<?php
18979    $ilCtrlStructureReader->getStructure();
18980?>
18981<#4125>
18982<?php
18983// 4 is ilDataCollectionField::EXPORTABLE_VIEW
18984require_once("./Modules/DataCollection/classes/class.ilDataCollectionField.php");
18985require_once("./Modules/DataCollection/classes/class.ilObjDataCollection.php");
18986//we need to initialize the view of the export. thus we select all table ids which currently do not have this view.
18987$q = "SELECT il_dcl_table.id FROM il_dcl_table WHERE not exists (SELECT il_dcl_view.id FROM il_dcl_view WHERE il_dcl_view.table_id = il_dcl_table.id AND il_dcl_view.type = " . $ilDB->quote(ilDataCollectionField::EXPORTABLE_VIEW, "integer") . ")";
18988$set = $ilDB->query($q);
18989while ($res = $ilDB->fetchAssoc($set)) {
18990    // create the view for this table
18991    $table_id = $res["id"];
18992    $view_id = $ilDB->nextId("il_dcl_view");
18993    $query = "INSERT INTO il_dcl_view (id, table_id, type, formtype) VALUES (" . $ilDB->quote($view_id, "integer") . ", " . $ilDB->quote($table_id, "integer") . ", " . $ilDB->quote(ilDataCollectionField::EXPORTABLE_VIEW, "integer") . ", " . $ilDB->quote(1, "integer") . ")";
18994    $ilDB->manipulate($query);
18995}
18996?>
18997<#4126>
18998<?php
18999require_once("./Modules/DataCollection/classes/class.ilDataCollectionField.php");
19000require_once("./Modules/DataCollection/classes/class.ilObjDataCollection.php");
19001//if the table was "exportable" before, every visible field was exported, now we set the default value of the existing dcls to field.isExportable() iff field.isVisible().
19002$q = "SELECT view2.id as view_id, viewdef.field, viewdef.field_order FROM il_dcl_viewdefinition viewdef" .
19003        " INNER JOIN il_dcl_view view ON viewdef.view_id = view.id AND view.type = " . ilDataCollectionField::VIEW_VIEW .
19004        " INNER JOIN il_dcl_view view2 ON view.table_id = view2.table_id AND view2.type = " . ilDataCollectionField::EXPORTABLE_VIEW .
19005        " WHERE viewdef.is_set = " . $ilDB->quote(1, "integer");
19006$set = $ilDB->query($q);
19007while ($res = $ilDB->fetchAssoc($set)) {
19008    $q = "INSERT INTO il_dcl_viewdefinition VALUES (" . $ilDB->quote($res["view_id"], "integer") . ", " . $ilDB->quote($res["field"], "text") . ", " . $ilDB->quote($res["field_order"], "integer") . ", " . $ilDB->quote(1, "integer") . ")";
19009    $ilDB->manipulate($q);
19010}
19011?>
19012<#4127>
19013<?php
19014    if (!$ilDB->tableColumnExists("tst_tests", "char_selector_availability")) {
19015        $ilDB->addTableColumn("tst_tests", "char_selector_availability", array(
19016            "type" => "integer",
19017            "notnull" => true,
19018            "default" => 0,
19019            "length" => 4));
19020    }
19021
19022    if (!$ilDB->tableColumnExists("tst_tests", "char_selector_definition")) {
19023        $ilDB->addTableColumn("tst_tests", "char_selector_definition", array(
19024            "type" => "text",
19025            "length" => 4000));
19026    }
19027?>
19028<#4128>
19029<?php
19030    // change type of usr_pref.value from char(40) to varchar(4000)
19031    // flexible space is needed	to store the individual char selector settings
19032    $ilDB->addTableColumn('usr_pref', 'value2', array("type" => "text", "length" => 4000));
19033    $ilDB->manipulate("UPDATE usr_pref SET value2 = value");
19034    $ilDB->dropTableColumn('usr_pref', 'value');
19035    $ilDB->renameTableColumn('usr_pref', 'value2', 'value');
19036?>
19037<#4129>
19038<?php
19039    $ilCtrlStructureReader->getStructure();
19040?>
19041<#4130>
19042<?php
19043$settings = new ilSetting();
19044$settings_captcha = new ilSetting('cptch');
19045if ((int) $settings->get('activate_captcha_anonym', 0)) {
19046    $settings_captcha->set('activate_captcha_anonym_frm', 1);
19047    $settings_captcha->set('activate_captcha_anonym_wiki', 1);
19048}
19049$settings->delete('activate_captcha_anonym');
19050?>
19051<#4131>
19052<?php
19053if (!$ilDB->tableColumnExists("usr_data", "is_self_registered")) {
19054    $ilDB->addTableColumn(
19055        "usr_data",
19056        "is_self_registered",
19057        array(
19058        "type" => "integer",
19059        "notnull" => true,
19060        "default" => 0,
19061        "length" => 1)
19062    );
19063}
19064?>
19065<#4132>
19066<?php
19067
19068include_once('./Services/Migration/DBUpdate_3560/classes/class.ilDBUpdateNewObjectType.php');
19069ilDBUpdateNewObjectType::addAdminNode('wiks', 'Wiki Settings');
19070
19071?>
19072<#4133>
19073<?php
19074    $ilCtrlStructureReader->getStructure();
19075?>
19076<#4134>
19077<?php
19078if (!$ilDB->tableExists('il_qpl_qst_fq_res_unit')) {
19079    $fields = array(
19080        'result_unit_id' => array(
19081            'type' => 'integer',
19082            'length' => 4,
19083            'notnull' => true,
19084            'default' => 0
19085        ),
19086        'result' => array(
19087            'type' => 'text',
19088            'length' => 255,
19089            'notnull' => false,
19090            'default' => null
19091        ),
19092        'question_fi' => array(
19093            'type' => 'integer',
19094            'length' => 4,
19095            'notnull' => true,
19096            'default' => 0
19097        ),
19098        'unit_fi' => array(
19099            'type' => 'integer',
19100            'length' => 4,
19101            'notnull' => true,
19102            'default' => 0
19103        )
19104    );
19105    $ilDB->createTable('il_qpl_qst_fq_res_unit', $fields);
19106    $ilDB->addPrimaryKey('il_qpl_qst_fq_res_unit', array('result_unit_id'));
19107    $ilDB->createSequence('il_qpl_qst_fq_res_unit');
19108    $ilDB->addIndex('il_qpl_qst_fq_res_unit', array('question_fi', 'unit_fi'), 'i1');
19109}
19110?>
19111<#4135>
19112<?php
19113    $ilCtrlStructureReader->getStructure();
19114?>
19115<#4136>
19116<?php
19117    $ilCtrlStructureReader->getStructure();
19118?>
19119<#4137>
19120<?php
19121    $ilCtrlStructureReader->getStructure();
19122?>
19123<#4138>
19124<?php
19125// Generic feedback
19126/** @var ilDB $ilDB */
19127$ilDB->addTableColumn(
19128    'qpl_fb_generic',
19129    'feedback_tmp',
19130    array(
19131                                          'type' => 'clob',
19132                                          'notnull' => false,
19133                                          'default' => null)
19134);
19135$ilDB->manipulate('UPDATE qpl_fb_generic SET feedback_tmp = feedback');
19136$ilDB->dropTableColumn('qpl_fb_generic', 'feedback');
19137$ilDB->renameTableColumn('qpl_fb_generic', 'feedback_tmp', 'feedback');
19138?>
19139<#4139>
19140<?php
19141// Generic feedback
19142/** @var ilDB $ilDB */
19143$ilDB->addTableColumn(
19144    'qpl_fb_specific',
19145    'feedback_tmp',
19146    array(
19147                                          'type' => 'clob',
19148                                          'notnull' => false,
19149                                          'default' => null)
19150);
19151
19152$ilDB->manipulate('UPDATE qpl_fb_specific SET feedback_tmp = feedback');
19153$ilDB->dropTableColumn('qpl_fb_specific', 'feedback');
19154$ilDB->renameTableColumn('qpl_fb_specific', 'feedback_tmp', 'feedback');
19155?>
19156<#4140>
19157<?php
19158// Hints
19159/** @var ilDB $ilDB */
19160$ilDB->addTableColumn(
19161    'qpl_hints',
19162    'hint_text_tmp',
19163    array(
19164                                     'type' => 'clob',
19165                                     'notnull' => false,
19166                                     'default' => null)
19167);
19168
19169$ilDB->manipulate('UPDATE qpl_hints SET hint_text_tmp = qht_hint_text');
19170$ilDB->dropTableColumn('qpl_hints', 'qht_hint_text');
19171$ilDB->renameTableColumn('qpl_hints', 'hint_text_tmp', 'qht_hint_text');
19172?>
19173<#4141>
19174<?php
19175// Suggested Solution
19176/** @var ilDB $ilDB */
19177$ilDB->addTableColumn(
19178    'qpl_sol_sug',
19179    'value_tmp',
19180    array(
19181                                       'type' => 'clob',
19182                                       'notnull' => false,
19183                                       'default' => null)
19184);
19185
19186$ilDB->manipulate('UPDATE qpl_sol_sug SET value_tmp = value');
19187$ilDB->dropTableColumn('qpl_sol_sug', 'value');
19188$ilDB->renameTableColumn('qpl_sol_sug', 'value_tmp', 'value');
19189?>
19190<#4142>
19191<?php
19192// Manual feedback
19193/** @var ilDB $ilDB */
19194$ilDB->addTableColumn(
19195    'tst_manual_fb',
19196    'feedback_tmp',
19197    array(
19198                                         'type' => 'clob',
19199                                         'notnull' => false,
19200                                         'default' => null)
19201);
19202
19203$ilDB->manipulate('UPDATE tst_manual_fb SET feedback_tmp = feedback');
19204$ilDB->dropTableColumn('tst_manual_fb', 'feedback');
19205$ilDB->renameTableColumn('tst_manual_fb', 'feedback_tmp', 'feedback');
19206?>
19207<#4143>
19208<?php
19209if (!$ilDB->tableColumnExists('tree', 'path')) {
19210    $ilDB->addTableColumn(
19211        "tree",
19212        "path",
19213        array(
19214        "type" => "text",
19215        "notnull" => false,
19216        "length" => 4000)
19217    );
19218}
19219?>
19220<#4144>
19221<?php
19222$ilCtrlStructureReader->getStructure();
19223?>
19224<#4145>
19225<?php
19226
19227if (!$ilDB->tableExists('glo_advmd_col_order')) {
19228    $fields = array(
19229        'glo_id' => array(
19230            'type' => 'integer',
19231            'length' => 4,
19232            'notnull' => true
19233        ),
19234        'field_id' => array(
19235            'type' => 'integer',
19236            'length' => 4,
19237            'notnull' => true
19238        ),
19239        'order_nr' => array(
19240            'type' => 'integer',
19241            'length' => 4,
19242            'notnull' => true
19243        )
19244    );
19245    $ilDB->createTable('glo_advmd_col_order', $fields);
19246    $ilDB->addPrimaryKey('glo_advmd_col_order', array('glo_id', 'field_id'));
19247}
19248?>
19249<#4146>
19250<?php
19251if (
19252    $ilDB->tableColumnExists('il_qpl_qst_fq_res', 'rating_val') &&
19253    !$ilDB->tableColumnExists('il_qpl_qst_fq_res', 'rating_value')) {
19254    $ilDB->renameTableColumn('il_qpl_qst_fq_res', 'rating_val', 'rating_value');
19255}
19256?>
19257<#4147>
19258<?php
19259    $ilCtrlStructureReader->getStructure();
19260?>
19261<#4148>
19262<?php
19263    $ilDB->addTableColumn(
19264    "tax_node_assignment",
19265    "obj_id",
19266    array("type" => "integer", "length" => 4, "notnull" => true, "default" => 0)
19267);
19268?>
19269<#4149>
19270<?php
19271    $ilDB->dropPrimaryKey('tax_node_assignment');
19272    $ilDB->addPrimaryKey('tax_node_assignment', array('node_id', 'component', 'obj_id', 'item_type', 'item_id'));
19273?>
19274<#4150>
19275<?php
19276
19277$set = $ilDB->query(
19278    "SELECT * FROM tax_node_assignment " .
19279    " WHERE item_type = " . $ilDB->quote("term", "text")
19280);
19281while ($rec = $ilDB->fetchAssoc($set)) {
19282    $set2 = $ilDB->query(
19283        "SELECT * FROM glossary_term " .
19284        " WHERE id = " . $ilDB->quote($rec["item_id"], "integer")
19285    );
19286    $rec2 = $ilDB->fetchAssoc($set2);
19287    $glo_id = (int) $rec2["glo_id"];
19288    $ilDB->manipulate(
19289        "UPDATE tax_node_assignment SET " .
19290        " obj_id = " . $ilDB->quote($glo_id, "integer") .
19291        " WHERE node_id = " . $ilDB->quote($rec["node_id"], "integer") .
19292        " AND component = " . $ilDB->quote($rec["component"], "text") .
19293        " AND item_type = " . $ilDB->quote($rec["item_type"], "text") .
19294        " AND item_id = " . $ilDB->quote($rec["item_id"], "integer") .
19295        " AND obj_id = " . $ilDB->quote(0, "integer")
19296    );
19297}
19298
19299?>
19300<#4151>
19301<?php
19302$query = "
19303	SELECT		tax_node_assignment.node_id,
19304				tax_node_assignment.item_id,
19305				tax_node_assignment.item_type,
19306				tax_usage.obj_id,
19307				object_data.type obj_type
19308	FROM		tax_node_assignment
19309	INNER JOIN	tax_usage
19310	ON 			tax_node_assignment.tax_id = tax_usage.tax_id
19311	INNER JOIN	object_data
19312	ON			object_data.obj_id = tax_usage.obj_id
19313	WHERE		tax_node_assignment.item_type = %s
19314";
19315
19316$res = $ilDB->queryF($query, array('text'), array('quest'));
19317
19318while ($row = $ilDB->fetchAssoc($res)) {
19319    $ilDB->update(
19320        'tax_node_assignment',
19321        array(
19322            'component' => array('text', $row['obj_type']),
19323            'obj_id' => array('integer', $row['obj_id'])
19324        ),
19325        array(
19326            'node_id' => array('integer', $row['node_id']),
19327            'item_id' => array('integer', $row['item_id']),
19328            'item_type' => array('text', $row['item_type'])
19329        )
19330    );
19331}
19332?>
19333<#4152>
19334<?php
19335
19336if (!$ilDB->tableColumnExists("booking_reservation", "group_id")) {
19337    $ilDB->addTableColumn("booking_reservation", "group_id", array(
19338        "type" => "integer",
19339        "length" => 4,
19340        "notnull" => false));
19341
19342    $ilDB->createSequence("booking_reservation_group");
19343}
19344
19345?>
19346<#4153>
19347<?php
19348
19349$lang_map = array();
19350$set = $ilDB->query("SELECT lang_key, value, identifier" .
19351    " FROM lng_data" .
19352    " WHERE " . $ilDB->in("identifier", array("wsp_type_tstv", "wsp_type_excv"), "", "text"));
19353while ($row = $ilDB->fetchAssoc($set)) {
19354    $lang_map[substr($row["identifier"], -4)][$row["lang_key"]] = $row["value"];
19355}
19356
19357$set = $ilDB->query("SELECT type, obj_id, title" .
19358    " FROM object_data" .
19359    " WHERE " . $ilDB->in("type", array("tstv", "excv"), "", "text"));
19360while ($row = $ilDB->fetchAssoc($set)) {
19361    foreach ($lang_map[$row["type"]] as $lang_item) {
19362        $lang_item .= ' "';
19363        if (strpos($row["title"], $lang_item) === 0) {
19364            $title = substr($row["title"], strlen($lang_item), -1);
19365            $ilDB->manipulate("UPDATE object_data" .
19366                " SET title = " . $ilDB->quote($title, "text") .
19367                " WHERE obj_id = " . $ilDB->quote($row["obj_id"]));
19368            break;
19369        }
19370    }
19371}
19372
19373?>
19374<#4154>
19375<?php
19376
19377if ($ilDB->getDBType() == 'mysql' || $ilDB->getDBType() == 'innodb') {
19378    $ilDB->manipulate("UPDATE object_reference SET  deleted = NULL WHERE  deleted = '0000-00-00 00:00:00'");
19379}
19380?>
19381<#4155>
19382<?php
19383    $ilCtrlStructureReader->getStructure();
19384?>
19385<#4156>
19386<?php
19387    $ilCtrlStructureReader->getStructure();
19388?>
19389<#4157>
19390<?php
19391if (!$ilDB->tableColumnExists('il_dcl_table', 'description')) {
19392    $ilDB->addTableColumn(
19393        'il_dcl_table',
19394        'description',
19395        array(
19396            'type' => 'text',
19397            'notnull' => false,
19398            'length' => 4000,
19399        )
19400    );
19401}
19402?>
19403<#4158>
19404<?php
19405if (!$ilDB->tableColumnExists('il_wiki_data', 'rating_overall')) {
19406    $ilDB->addTableColumn(
19407        'il_wiki_data',
19408        'rating_overall',
19409        array(
19410            'type' => 'integer',
19411            'length' => 1,
19412            'notnull' => false,
19413            'default' => 0
19414        )
19415    );
19416}
19417
19418if (!$ilDB->tableColumnExists('content_object', 'rating_pages')) {
19419    $ilDB->addTableColumn(
19420        'content_object',
19421        'rating_pages',
19422        array(
19423            'type' => 'integer',
19424            'length' => 1,
19425            'notnull' => false,
19426            'default' => 0
19427        )
19428    );
19429}
19430?>
19431<#4159>
19432<?php
19433    $ilCtrlStructureReader->getStructure();
19434?>
19435<#4160>
19436<?php
19437    $ilCtrlStructureReader->getStructure();
19438?>
19439<#4161>
19440<?php
19441    $ilDB->manipulate("DELETE FROM ctrl_calls WHERE comp_prefix = " . $ilDB->quote('qpl_qst_formulaquestion', 'text'));
19442    $ilDB->manipulate("DELETE FROM ctrl_classfile WHERE comp_prefix = " . $ilDB->quote('qpl_qst_formulaquestion', 'text'));
19443?>
19444<#4162>
19445<?php
19446    $ilCtrlStructureReader->getStructure();
19447?>
19448<#4163>
19449<?php
19450    // unused
19451?>
19452<#4164>
19453<?php
19454    if (!$ilDB->tableColumnExists("skl_tree_node", "status")) {
19455        $ilDB->renameTableColumn('skl_tree_node', 'draft', 'status');
19456    }
19457?>
19458<#4165>
19459<?php
19460$ilinc_role_tpl_titles = array('il_icrs_admin', 'il_icrs_member');
19461foreach ($ilinc_role_tpl_titles as $title) {
19462    $query = "SELECT obj_id FROM object_data WHERE title = " . $ilDB->quote($title, 'text') . " " .
19463             "AND type = " . $ilDB->quote('rolt', 'text');
19464    $res = $ilDB->query($query);
19465    $row = $ilDB->fetchAssoc($res);
19466    if ($row) {
19467        $query = "DELETE FROM rbac_templates WHERE rol_id = " . $ilDB->quote($row['obj_id'], 'integer');
19468        $ilDB->manipulate($query);
19469
19470        $query = "DELETE FROM rbac_fa WHERE rol_id = " . $ilDB->quote($row['obj_id'], 'integer');
19471        $ilDB->manipulate($query);
19472
19473        $query = "DELETE FROM object_data WHERE obj_id = " . $ilDB->quote($row['obj_id'], 'integer');
19474        $ilDB->manipulate($query);
19475    }
19476}
19477?>
19478<#4166>
19479<?php
19480
19481// #12419 - find all original questions which are not in a question pool
19482$set = $ilDB->query("SELECT sqo.question_id" .
19483    " FROM svy_question sqp" .
19484    " JOIN svy_question sqo ON (sqp.question_id = sqo.original_id)" .
19485    " JOIN object_data od ON (sqp.obj_fi = od.obj_id)" .
19486    " WHERE od.type <> " . $ilDB->quote("spl", "text"));
19487while ($row = $ilDB->fetchAssoc($set)) {
19488    $ilDB->manipulate("UPDATE svy_question" .
19489        " SET original_id = NULL" .
19490        " WHERE question_id = " . $ilDB->quote($row["question_id"], "integer"));
19491}
19492
19493?>
19494<#4167>
19495<?php
19496    $ilCtrlStructureReader->getStructure();
19497?>
19498<#4168>
19499<?php
19500    if (!$ilDB->tableColumnExists('sahs_lm', 'fourth_edition')) {
19501        $ilDB->addTableColumn(
19502            'sahs_lm',
19503            'fourth_edition',
19504            array(
19505                "type" => "text",
19506                'length' => 1,
19507                "notnull" => true,
19508                "default" => 'n'
19509            )
19510        );
19511        $ilDB->query("UPDATE sahs_lm SET fourth_edition = 'n'");
19512    }
19513?>
19514<#4169>
19515<?php
19516    if (!$ilDB->tableColumnExists('sahs_lm', 'ie_compatibility')) {
19517        $ilDB->addTableColumn(
19518            'sahs_lm',
19519            'ie_compatibility',
19520            array(
19521                "type" => "text",
19522                'length' => 1,
19523                "notnull" => false
19524            )
19525        );
19526    }
19527?>
19528<#4170>
19529<?php
19530    if (!$ilDB->tableColumnExists('sahs_lm', 'ie_force_render')) {
19531        $ilDB->addTableColumn(
19532            'sahs_lm',
19533            'ie_force_render',
19534            array(
19535                "type" => "text",
19536                'length' => 1,
19537                "notnull" => true,
19538                "default" => 'n'
19539            )
19540        );
19541        $ilDB->query("UPDATE sahs_lm SET ie_force_render = 'n'");
19542    }
19543?>
19544<#4171>
19545<?php
19546    if (!$ilDB->tableColumnExists('qpl_qst_sc', 'feedback_setting')) {
19547        $ilDB->addTableColumn('qpl_qst_sc', 'feedback_setting', array(
19548            "type" => "integer",
19549            "notnull" => false,
19550            "length" => 1,
19551            "default" => 2
19552        ));
19553    }
19554?>
19555<#4172>
19556<?php
19557    $ilCtrlStructureReader->getStructure();
19558?>
19559<#4173>
19560<?php
19561    $ilCtrlStructureReader->getStructure();
19562?>
19563<#4174>
19564<?php
19565    $ilCtrlStructureReader->getStructure();
19566?>
19567<#4175>
19568<?php
19569if (!$ilDB->tableExists('obj_content_master_lng')) {
19570    $fields = array(
19571        'obj_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true, 'default' => 0),
19572        'master_lang' => array('type' => 'text', 'notnull' => true, 'length' => 2, 'fixed' => false)
19573    );
19574    $ilDB->createTable('obj_content_master_lng', $fields);
19575    $ilDB->addPrimaryKey('obj_content_master_lng', array('obj_id'));
19576}
19577?>
19578<#4176>
19579<?php
19580    $set = $ilDB->query("SELECT * FROM copg_multilang");
19581    while ($rec = $ilDB->fetchAssoc($set)) {
19582        $ilDB->manipulate("INSERT INTO obj_content_master_lng " .
19583            "(obj_id, master_lang) VALUES (" .
19584            $ilDB->quote($rec["parent_id"], "integer") . "," .
19585            $ilDB->quote($rec["master_lang"], "text") .
19586            ")");
19587    }
19588?>
19589<#4177>
19590<?php
19591    $ilCtrlStructureReader->getStructure();
19592?>
19593<#4178>
19594<?php
19595    $ilCtrlStructureReader->getStructure();
19596?>
19597<#4179>
19598<?php
19599    $ilDB->modifyTableColumn(
19600    'il_subscribers',
19601    'subject',
19602    array("type" => "text", "length" => 4000, "notnull" => false)
19603);
19604?>
19605<#4180>
19606<?php
19607$ilCtrlStructureReader->getStructure();
19608?>
19609<#4181>
19610<?php
19611    if (!$ilDB->tableColumnExists('il_poll', 'max_answers')) {
19612        $ilDB->addTableColumn('il_poll', 'max_answers', array(
19613            "type" => "integer",
19614            "notnull" => true,
19615            "length" => 1,
19616            "default" => 1
19617        ));
19618    }
19619?>
19620<#4182>
19621<?php
19622    $ilDB->dropPrimaryKey("il_poll_vote");
19623    $ilDB->addPrimaryKey("il_poll_vote", array("user_id", "poll_id", "answer_id"));
19624
19625
19626
19627
19628
19629                    // FILE ENDS HERE, DO NOT ADD ANY ADDITIONAL STEPS
19630                    //
19631                    //         USE dbupdate_04.php INSTEAD
19632
19633?>