Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
831 florian 1
<?php
2
if(!defined("PHORUM_ADMIN")) return;
3
 
4
// wow doing it all by hand this time :(
5
 
6
$cid=phorum_db_mysql_connect();
7
// adding the new field
8
mysql_query("ALTER TABLE {$PHORUM['user_newflags_table']} ADD message_id INT( 11 ) NOT NULL",$cid);
9
// removing old primary-key
10
mysql_query("ALTER TABLE {$PHORUM['user_newflags_table']} DROP PRIMARY KEY",$cid);
11
// adding new primary-key
12
mysql_query("ALTER TABLE {$PHORUM['user_newflags_table']} ADD PRIMARY KEY ( user_id , forum_id , message_id )",$cid);
13
 
14
// converting the newflags
15
$res=mysql_query("SELECT * FROM {$PHORUM['user_newflags_table']} where message_id=0",$cid);
16
$olduser=$GLOBALS['PHORUM']['user']['user_id'];
17
while($row=mysql_fetch_assoc($res)) {
18
    $forum=$row['forum_id'];
19
    $data=unserialize($row['newflags']);
20
    $GLOBALS['PHORUM']['user']['user_id']=$row['user_id'];
21
    $newdata=array();
22
    foreach($data as $mid1 => $mid2) {
23
        if(is_int($mid1)) {
24
            $newdata[]=array("id"=>$mid1,"forum"=>$forum);
25
        }
26
    }
27
    phorum_db_newflag_add_read($newdata);
28
    unset($data);
29
    unset($newdata);
30
}
31
$GLOBALS['PHORUM']['user']['user_id']=$olduser;
32
mysql_query("DELETE FROM {$PHORUM['user_newflags_table']} where message_id=0",$cid);
33
 
34
// remove old column
35
mysql_query("ALTER TABLE {$PHORUM['user_newflags_table']} DROP newflags",$cid);
36
 
37
?>