Skip to content

Commit 3511252

Browse files
committed
Work: Script: Adding script to fix wrong group_id in student publication - refs BT#20630
1 parent 64f1a15 commit 3511252

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/* For licensing terms, see /license.txt */
3+
/*
4+
* Update all the student publication to have the same post_group_id
5+
* as its parents if the parent has a post_group_id
6+
*/
7+
exit;
8+
9+
require_once '../../main/inc/global.inc.php';
10+
11+
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
12+
13+
$sql = "SELECT * FROM $workTable WHERE parent_id = 0 AND post_group_id != 0 AND active = 1";
14+
$res = Database::query($sql);
15+
while ($data = Database::fetch_array($res)) {
16+
echo "revising c_student_publicaton (" . $data['title'] . ") with id = " . $data['id'] . " in group = " . $data['post_group_id'];
17+
$updatesql = "update $workTable set post_group_id = " . $data['post_group_id'] . " WHERE parent_id = " . $data['id'] . ";";
18+
echo " update sql = " . $updatesql;
19+
$subres = Database::query($updatesql);
20+
}
21+

0 commit comments

Comments
 (0)