remove old readme
[atutor.git] / docs / admin / fix_content.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13 // $Id$
14
15 define('AT_INCLUDE_PATH', '../include/');
16
17 require(AT_INCLUDE_PATH.'vitals.inc.php');
18 admin_authenticate(AT_ADMIN_PRIV_ADMIN);
19
20 require(AT_INCLUDE_PATH.'header.inc.php');
21
22 echo '<div style="padding-left: 30px;"><pre>';
23
24 echo "cpID\torder\t cID";
25
26 $sql    = "SELECT content_id, content_parent_id, ordering, course_id FROM ".TABLE_PREFIX."content ORDER BY course_id, content_parent_id, ordering";
27 $result = mysql_query($sql, $db);
28
29
30 while ($row = mysql_fetch_assoc($result)) {
31         if ($current_course_id != $row['course_id']) {
32                 echo "\n\n-- course id $row[course_id]\n\n";
33                 $current_course_id = $row['course_id'];
34                 unset($current_parent_id);
35                 unset($ordering);
36                 
37         }
38         echo $row['content_parent_id'] . "\t" . $row['ordering'] . "\t" . $row['content_id'];
39         if ($current_parent_id != $row['content_parent_id']) {
40                 $current_parent_id = $row['content_parent_id'];
41                 $ordering = 1;
42                 
43         }
44
45         if ($row['ordering'] != $ordering) {
46                 echo "\t mismatch : expecting $ordering [fixed]";
47                 $sql = "UPDATE ".TABLE_PREFIX."content SET ordering=$ordering WHERE content_id=$row[content_id]";
48                 mysql_query($sql, $db);
49                 write_to_log(AT_ADMIN_LOG_UPDATE, 'content', mysql_affected_rows($db), $sql);
50                 
51         }
52
53          echo "\n";
54
55         $ordering++;
56         
57 }
58
59 $savant->assign('ordering', $ordering);
60 $savant->assign('content_id', $content_id);     
61 $savant->assign('content_parent_id', $content_parent_id);
62
63 echo' </pre></div>';
64 $savant->display('admin/fix_content.tmpl.php');
65 require(AT_INCLUDE_PATH.'footer.inc.php');
66 ?>