summaryrefslogtreecommitdiff
path: root/setup/upgrade/0.9.9/convert_private.php
blob: b871d39508366fda84a47f574829870e0b65b8a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
   /**********************************************************\
   | This script converts the private/public history entries   |
   \***********************************************************/
   

$check_sql = $db->query('SELECT * FROM {history} WHERE event_type = 26 OR event_type = 27');

while ($row = $db->fetchRow($check_sql))
{
    $db->query('DELETE FROM {history} WHERE history_id = ?', array($row['history_id']));
    if ($row['event_type'] == 26) {
        $row['old_value'] = 0;
        $row['new_value'] = 1;
    }
    if ($row['event_type'] == 27) {
        $row['old_value'] = 1;
        $row['new_value'] = 0;
    }
    $db->query("INSERT INTO {history} (task_id, user_id, event_date, event_type, field_changed, old_value, new_value)
                                      VALUES(?, ?, ?, 0, 'mark_private', ?, ?)",
                                      array($row['task_id'], $row['user_id'], $row['event_date'], $row['old_value'], $row['new_value']));
}


?>