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

« back to all changes in this revision

Viewing changes to mod/glossary/db/mysql.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: mysql.php,v 1.31.2.2 2004/11/18 19:11:58 moodler Exp $
 
1
<?php   // $Id: mysql.php,v 1.40 2005/05/16 22:21:19 stronk7 Exp $
2
2
 
3
3
 
4
4
 
65
65
                    "ADD `sourceglossaryid` INT(10) unsigned NOT NULL DEFAULT '0' AFTER `attachment` " );
66
66
 
67
67
    }
68
 
        
 
68
 
69
69
    if ( $oldversion < 2003101500 ) {
70
70
        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary` " .
71
71
                    "ADD `intro`  text NOT NULL DEFAULT '' AFTER `name` " );
94
94
    if ( $oldversion < 2003101600 ) {
95
95
        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary` " .
96
96
                    "ADD `usedynalink`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `allowcomments` " );
97
 
                                        
 
97
 
98
98
        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_entries` " .
99
99
                    "ADD `usedynalink`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '1' AFTER `sourceglossaryid`, ".
100
100
                    "ADD `casesensitive`  TINYINT(2) UNSIGNED NOT NULL DEFAULT '0' AFTER `usedynalink` ");
112
112
    if ( $oldversion < 2003102000 ) {
113
113
        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary`" .
114
114
                     " ADD `defaultapproval` TINYINT(2) UNSIGNED NOT NULL default '1' AFTER `usedynalink`");
115
 
                                        
 
115
 
116
116
        execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_entries`" .
117
117
                    " ADD `approved` TINYINT(2) UNSIGNED NOT NULL default '1' AFTER `fullmatch`");
118
118
 
125
125
    }
126
126
 
127
127
    if ( $oldversion < 2003103100 ) {
128
 
        print_simple_box("This update might take several seconds.<p>The more glossaries, entries and categories you have created, the more it will take so please be patient.","center", "50%", "$THEME->cellheading", "20", "noticebox");
 
128
        print_simple_box('This update might take several seconds.<br />The more glossaries, entries and categories you have created, the more it will take so please be patient.','center', '50%', '', '20', 'noticebox');
129
129
        if ( $glossaries = get_records("glossary")) {
130
130
            $gids = "";
131
131
            foreach ( $glossaries as $glossary ) {
258
258
 
259
259
  
260
260
  if ( $oldversion < 2004051400 ) {
261
 
        print_simple_box("This update might take several seconds.<p>The more glossaries, entries and aliases you have created, the more it will take so please be patient.","center", "50%", "$THEME->cellheading", "20", "noticebox");
 
261
        print_simple_box("This update might take several seconds.<p>The more glossaries, entries and aliases you have created, the more it will take so please be patient.","center", "50%", '', "20", "noticebox");
262
262
        if ( $entries = get_records("glossary_entries", '', '', '', 'id,concept')) {
263
263
            foreach($entries as $entry) {
264
264
                set_field("glossary_entries","concept",addslashes(trim($entry->concept)),"id",$entry->id);
345
345
      set_field('glossary','editalways','1','mainglossary','0');
346
346
  }
347
347
 
348
 
  if ($oldversion < 2004080932) {
 
348
  if ($oldversion < 2004111200) {
 
349
      execute_sql("ALTER TABLE {$CFG->prefix}glossary DROP INDEX course;",false);
 
350
      execute_sql("ALTER TABLE {$CFG->prefix}glossary_alias DROP INDEX entryid;",false);
 
351
      execute_sql("ALTER TABLE {$CFG->prefix}glossary_categories DROP INDEX glossaryid;",false); 
 
352
      execute_sql("ALTER TABLE {$CFG->prefix}glossary_comments DROP INDEX entryid;",false);
 
353
      execute_sql("ALTER TABLE {$CFG->prefix}glossary_comments DROP INDEX userid;",false); 
 
354
      execute_sql("ALTER TABLE {$CFG->prefix}glossary_entries DROP INDEX glossaryid;",false);
 
355
      execute_sql("ALTER TABLE {$CFG->prefix}glossary_entries DROP INDEX userid;",false); 
 
356
      execute_sql("ALTER TABLE {$CFG->prefix}glossary_entries DROP INDEX concept;",false);
 
357
      execute_sql("ALTER TABLE {$CFG->prefix}glossary_entries_categories DROP INDEX entryid;",false); 
 
358
      execute_sql("ALTER TABLE {$CFG->prefix}glossary_entries_categories DROP INDEX categoryid;",false);
 
359
      execute_sql("ALTER TABLE {$CFG->prefix}glossary_ratings DROP INDEX userid;",false); 
 
360
      execute_sql("ALTER TABLE {$CFG->prefix}glossary_ratings DROP INDEX entryid;",false);
 
361
 
349
362
      modify_database('','ALTER TABLE prefix_glossary ADD INDEX course (course);');
350
363
      modify_database('','ALTER TABLE prefix_glossary_alias ADD INDEX entryid (entryid);');
351
364
      modify_database('','ALTER TABLE prefix_glossary_categories ADD INDEX glossaryid (glossaryid);');
360
373
      modify_database('','ALTER TABLE prefix_glossary_ratings ADD INDEX entryid (entryid);');
361
374
 
362
375
  }
 
376
 
 
377
  //Delete orphaned categories (bug 2140)
 
378
  if ($oldversion < 2005011100) {
 
379
      $categories = get_records('glossary_categories', '', '', '', 'id, glossaryid');
 
380
      if ($categories) {
 
381
          foreach ($categories as $category) {
 
382
              $glossary = get_record('glossary', 'id', "$category->glossaryid");
 
383
              if (!$glossary) {
 
384
                  delete_records('glossary_categories', 'id', "$category->id");
 
385
              }
 
386
          }
 
387
      }
 
388
  }
 
389
 
 
390
  //Allowprintview flag
 
391
  if ($oldversion < 2005011200) {
 
392
      table_column('glossary','','allowprintview','tinyint','2', 'unsigned', '1', '', 'allowcomments');
 
393
      $glossaries = get_records('glossary', '', '', '', 'id, name');
 
394
      if ($glossaries) {
 
395
          foreach ($glossaries as $glossary) { 
 
396
              set_field('glossary', 'allowprintview', '1', 'id', "$glossary->id");
 
397
          }
 
398
      }
 
399
  }
 
400
 
 
401
  if ($oldversion < 2005031001) {
 
402
      modify_database('',"INSERT INTO prefix_log_display VALUES ('glossary', 'view entry', 'glossary_entries', 'concept');");
 
403
  }
363
404
    
 
405
    if ($oldversion < 2005041100) { // replace wiki-like with markdown
 
406
        include_once( "$CFG->dirroot/lib/wiki_to_markdown.php" );
 
407
        $wtm = new WikiToMarkdown();
 
408
        // update glossary_entries->definition
 
409
        $sql = "select course from {$CFG->prefix}glossary,{$CFG->prefix}glossary_entries ";
 
410
        $sql .= "where {$CFG->prefix}glossary.id = {$CFG->prefix}glossary_entries.glossaryid ";
 
411
        $sql .= "and {$CFG->prefix}glossary_entries.id = ";
 
412
        $wtm->update( 'glossary_entries','definition','format' );
 
413
        // update glossary_comments->text
 
414
        $sql = "select course from {$CFG->prefix}glossary,{$CFG->prefix}glossary_entries,{$CFG->prefix}glossary_comments ";
 
415
        $sql .= "where {$CFG->prefix}glossary.id = {$CFG->prefix}glossary_entries.glossaryid ";
 
416
        $sql .= "and {$CFG->prefix}glossary_entries.id = {$CFG->prefix}glossary_comments.entryid ";
 
417
        $sql .= "and {$CFG->prefix}glossary_comments.id = ";
 
418
        $wtm->update( 'glossary_comments','text','format',$sql );
 
419
    }
 
420
 
364
421
  return true;
365
422
}
366
423