~ubuntu-branches/ubuntu/breezy/moodle/breezy

« back to all changes in this revision

Viewing changes to mod/label/restorelib.php

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-10-13 02:00:59 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051013020059-y2qcyo41t7nqppcg
Tags: 1.5.2-1ubuntu1
* Resync with debian (security update)
* changed dependencys to php5
* changed apache dependency to apache2 
* References
  CAN-2005-2247

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?PHP //$Id: restorelib.php,v 1.3 2004/02/16 20:40:53 stronk7 Exp $
 
1
<?php //$Id: restorelib.php,v 1.7.2.2 2005/07/12 07:53:00 moodler Exp $
2
2
    //This php script contains all the stuff to backup/restore
3
3
    //label mods
4
4
 
43
43
            $newid = insert_record ("label",$label);
44
44
 
45
45
            //Do some output     
46
 
            echo "<ul><li>".get_string("modulename","label")." \"".$label->name."\"<br>";
 
46
            echo "<li>".get_string("modulename","label")." \"".format_string(stripslashes($label->name),true)."\"</li>";
47
47
            backup_flush(300);
48
48
 
49
49
            if ($newid) {
54
54
            } else {
55
55
                $status = false;
56
56
            }
57
 
 
58
 
            //Finalize ul        
59
 
            echo "</ul>";
60
 
 
61
57
        } else {
62
58
            $status = false;
63
59
        }
65
61
        return $status;
66
62
    }
67
63
 
 
64
    function label_decode_content_links_caller($restore) {
 
65
        global $CFG;
 
66
        $status = true;
 
67
 
 
68
        if ($labels = get_records_sql ("SELECT l.id, l.content
 
69
                                   FROM {$CFG->prefix}label l
 
70
                                   WHERE l.course = $restore->course_id")) {
 
71
            $i = 0;   //Counter to send some output to the browser to avoid timeouts
 
72
            foreach ($labels as $label) {
 
73
                //Increment counter
 
74
                $i++;
 
75
                $content = $label->content;
 
76
                $result = restore_decode_content_links_worker($content,$restore);
 
77
 
 
78
                if ($result != $content) {
 
79
                    //Update record
 
80
                    $label->content = addslashes($result);
 
81
                    $status = update_record("label", $label);
 
82
                    if ($CFG->debug>7) {
 
83
                        echo '<br /><hr />'.htmlentities($content).'<br />changed to<br />'.htmlentities($result).'<hr /><br />';
 
84
                    }
 
85
                }
 
86
                //Do some output
 
87
                if (($i+1) % 5 == 0) {
 
88
                    echo ".";
 
89
                    if (($i+1) % 100 == 0) {
 
90
                        echo "<br />";
 
91
                    }
 
92
                    backup_flush(300);
 
93
                }
 
94
            }
 
95
        }
 
96
        return $status;
 
97
    }
 
98
 
68
99
    //This function returns a log record with all the necessay transformations
69
100
    //done. It's used by restore_log_module() to restore modules log.
70
101
    function label_restore_logs($restore,$log) {
96
127
            }
97
128
            break;
98
129
        default:
99
 
            echo "action (".$log->module."-".$log->action.") unknow. Not restored<br>";                 //Debug
 
130
            echo "action (".$log->module."-".$log->action.") unknow. Not restored<br />";                 //Debug
100
131
            break;
101
132
        }
102
133