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
$cid=phorum_db_mysql_connect();
5
 
6
// converting the custom-fields
7
$res=mysql_query("SELECT user_id,user_data FROM {$PHORUM['user_table']}",$cid);
8
 
9
while($row=mysql_fetch_assoc($res)) {
10
    $userdata=array('user_id'=>$row['user_id']);
11
    $user_data_new=array();
12
    $user_data_old=unserialize($row['user_data']);
13
 
14
    // converting meta-data to fields
15
    if(isset($user_data_old['show_signature']) && !empty($user_data_old['show_signature']))
16
        $userdata['show_signature']=$user_data_old['show_signature'];
17
 
18
    if(isset($user_data_old['email_notify']) && !empty($user_data_old['email_notify']))
19
        $userdata['email_notify']=$user_data_old['email_notify'];
20
 
21
    if(isset($user_data_old['tz_offset']) && !empty($user_data_old['tz_offset']))
22
        $userdata['tz_offset']=$user_data_old['tz_offset'];
23
 
24
    if(isset($user_data_old['is_dst']) && !empty($user_data_old['is_dst']))
25
        $userdata['is_dst']=$user_data_old['is_dst'];
26
 
27
    if(isset($user_data_old['user_language']) && !empty($user_data_old['user_language']))
28
        $userdata['user_language']=$user_data_old['user_language'];
29
 
30
    if(isset($user_data_old['user_template']) && !empty($user_data_old['user_template']))
31
        $userdata['user_template']=$user_data_old['user_template'];
32
 
33
    unset($user_data_old['user_template']);
34
    unset($user_data_old['user_language']);
35
    unset($user_data_old['is_dst']);
36
    unset($user_data_old['tz_offset']);
37
    unset($user_data_old['email_notify']);
38
    unset($user_data_old['show_signature']);
39
 
40
    // converting custom-fields now
41
    if(is_array($user_data_old) && count($user_data_old)) {
42
        foreach($user_data_old as $old_key => $old_val) {
43
            $type=-1;
44
            // find out which ID that custom-field has
45
            foreach($PHORUM['PROFILE_FIELDS'] as $ctype => $cdata) {
46
                if($cdata['name'] == $old_key) {
47
                    $type=$ctype;
48
                    break;
49
                }
50
            }
51
 
52
            if($type != -1) { // store it only if we found it
53
                if( $old_val!=="" ) {
54
                    if(!is_array($old_val)) {
55
                        $user_data_new[$type] = substr($old_val,0,$PHORUM['PROFILE_FIELDS'][$type]['length']);
56
                    } else {
57
                        $user_data_new[$type] = $old_val;
58
                    }
59
                }
60
            }
61
        }
62
    }
63
 
64
    $userdata['user_data']=$user_data_new;
65
    phorum_user_save($userdata);
66
}
67
// remove old column
68
//mysql_query("ALTER TABLE {$PHORUM['user_newflags_table']} DROP newflags",$cid);
69
 
70
?>