Project

General

Profile

« Previous | Next » 

Revision 1772

Added by Dietmar about 12 years ago

  1. fixed show e-mail in submission overview
    ! set title to tooltip if you add a pageX
    ! optimize upgrade-script, add new fields to user table

View differences:

upgrade-script.php
161 161
	echo $msg;
162 162
}
163 163

  
164
// analyze/check database tables
165
function mysqlCheckTables( $dbName )
166
{
167
    global $aTable;
168
    $table_prefix = TABLE_PREFIX;
169
    $sql = "SHOW TABLES FROM " . $dbName;
170
    $result = @mysql_query( $sql );
171
    $data = array();
172
    $x = 0;
173

  
174
    while( ( $row = mysql_fetch_array( $result, MYSQL_NUM ) ) == true )
175
    {
176
        $tmp = str_replace($table_prefix, '', $row[0]);
177

  
178
        if( stristr( $row[0], $table_prefix )&& in_array($tmp,$aTable) )
179
        {
180
            $sql = "CHECK TABLE " . $dbName . '.' . $row[0];
181
            $analyze = mysql_query( $sql );
182
            $rowFetch = mysql_fetch_array( $analyze, MYSQL_ASSOC );
183
            $data[$x]['Op'] = $rowFetch["Op"];
184
            $data[$x]['Msg_type'] = $rowFetch["Msg_type"];
185
            $msgColor = '<span class="error">';
186
            $data[$x]['Table'] = $row[0];
187
           // print  " ";
188
            $msgColor = ($rowFetch["Msg_text"] == 'OK') ? '<span class="ok">' : '<span class="error">';
189
            $data[$x]['Msg_text'] = $msgColor.$rowFetch["Msg_text"].'</span>';
190
           // print  "<br />";
191
            $x++;
192
        }
164
/**
165
 * add_modify_field_in_database()
166
 *
167
 * @param mixed $sTable
168
 * @param mixed $sField
169
 * @param mixed $sDescription
170
 * @return
171
 */
172
function add_modify_field_in_database($sTable,$sField,$sDescription){
173
    global $database,$OK,$FAIL,$bDebugModus;
174
    $aDebugMessage = array();
175
	if(!$database->field_exists($sTable,$sField)) {
176
		$aDebugMessage[] = "<span>Adding field $sField to $sTable table</span>";
177
		$aDebugMessage[] = ($database->field_add($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
178
	} else {
179
		$aDebugMessage[] = "<span>Modify field $sField to $sTable table</span>";
180
		$aDebugMessage[] = ($database->field_modify($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
181
	}
182
    if($bDebugModus) {
183
        echo implode(PHP_EOL,$aDebugMessage);
193 184
    }
194
    return $data;
185
    return;
195 186
}
196 187

  
197
// check existings tables for upgrade or install
188
/**
189
 * check existings tables for upgrade or install
190
 *
191
 * check_wb_tables()
192
 *
193
 * @return
194
 */
198 195
function check_wb_tables()
199 196
{
200 197
    global $database,$aPackage;
......
449 446
    $cfg = array(
450 447
    	'sec_anchor' => defined('SEC_ANCHOR') ? SEC_ANCHOR : 'section_'
451 448
    );
452

  
453 449
   $aDebugMessage[] = (db_update_key_value( 'settings', $cfg ) ? " $OK<br />" : " $FAIL!<br />");
454 450

  
455

  
456 451
    /**********************************************************
457 452
     *  - Adding redirect timer to settings table
458 453
     */
......
558 553
echo '</div>';
559 554

  
560 555
$aDebugMessage = array();
561
if(version_compare(WB_REVISION, REVISION, '<'))
556
if(version_compare(WB_REVISION, REVISION, '<='))
562 557
{
563 558
    echo '<div style="margin-left:2em;">';
564 559
	/**********************************************************
......
584 579
	$table_name = TABLE_PREFIX.'mod_menu_link';
585 580
	$field_name = 'redirect_type';
586 581
	$description = "INT NOT NULL DEFAULT '301' AFTER `target_page_id`";
587
	if(!$database->field_exists($table_name,$field_name)) {
588
		echo "<span>Adding field redirect_type to mod_menu_link table</span>";
589
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
590
	} else {
591
		echo "<span>Modify field redirect_type to mod_menu_link table</span>";
592
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
593
	}
582
    add_modify_field_in_database($table_name,$field_name,$description);
594 583

  
584
    if($bDebugModus) {
585
        echo implode(PHP_EOL,$aDebugMessage);
586
        $aDebugMessage = array();
587
    }
588

  
595 589
    echo "<h4>Adding/updating field on table pages</h4>";
596 590
	/**********************************************************
597 591
	 *  - Add field "page_trail" to table "pages"
......
599 593
	$table_name = TABLE_PREFIX.'pages';
600 594
	$field_name = 'page_trail';
601 595
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
602
	echo "<span>Modify field page_trail to pages table</span>";
603
	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
596
    add_modify_field_in_database($table_name,$field_name,$description);
604 597

  
605 598
	/**********************************************************
606 599
     *  - Add field "page_icon" to table "pages"
......
608 601
	$table_name = TABLE_PREFIX.'pages';
609 602
	$field_name = 'page_icon';
610 603
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `page_title`";
611
	if(!$database->field_exists($table_name,$field_name)) {
612
		echo "<span>Adding field page_icon to pages table</span>";
613
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
614
	} else {
615
		echo "<span>Modify field page_icon to pages table</span>";
616
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
617
	}
604
    add_modify_field_in_database($table_name,$field_name,$description);
618 605

  
619 606
	/**********************************************************
620 607
	 *  - Add field "page_code" to table "pages"
......
622 609
	$table_name = TABLE_PREFIX.'pages';
623 610
	$field_name = 'page_code';
624 611
	$description = "INT NOT NULL DEFAULT '0' AFTER `language`";
625
	if(!$database->field_exists($table_name,$field_name)) {
626
		echo "<span>Adding field page_code to pages table</span>";
627
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
628
	} else {
629
		echo "<span>Modify field page_code to pages table</span>";
630
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
631
	}
612
    add_modify_field_in_database($table_name,$field_name,$description);
632 613

  
633 614
	/**********************************************************
634 615
     *  - Add field "menu_icon_0" to table "pages"
......
636 617
	$table_name = TABLE_PREFIX.'pages';
637 618
	$field_name = 'menu_icon_0';
638 619
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_title`";
639
	if(!$database->field_exists($table_name,$field_name)) {
640
		echo "<span>Adding field menu_icon_0 to pages table</span>";
641
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
642
	} else {
643
		echo "<span>Modify field menu_icon_0 to pages table</span>";
644
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
645
	}
620
    add_modify_field_in_database($table_name,$field_name,$description);
646 621

  
647 622
	/**********************************************************
648 623
	 *  - Add field "menu_icon_1" to table "pages"
......
650 625
	$table_name = TABLE_PREFIX.'pages';
651 626
	$field_name = 'menu_icon_1';
652 627
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_0`";
653
	if(!$database->field_exists($table_name,$field_name)) {
654
		echo "<span>Adding field menu_icon_1 to pages table</span>";
655
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
656
	} else {
657
		echo "<span>Modify field menu_icon_1 to pages table</span>";
658
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
659
	}
628
    add_modify_field_in_database($table_name,$field_name,$description);
660 629

  
661 630
	/**********************************************************
662 631
	 *  - Add field "tooltip" to table "pages"
......
664 633
	$table_name = TABLE_PREFIX.'pages';
665 634
	$field_name = 'tooltip';
666 635
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '' AFTER `menu_icon_1`";
667
	if(!$database->field_exists($table_name,$field_name)) {
668
		echo "<span>Adding field tooltip to pages table</span>";
669
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
670
	} else {
671
		echo "<span>Modify field tooltip to pages table";
672
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
673
	}
636
    add_modify_field_in_database($table_name,$field_name,$description);
674 637

  
675 638
	/**********************************************************
676 639
	 *  - Add field "admin_groups" to table "pages"
......
678 641
	$table_name = TABLE_PREFIX.'pages';
679 642
	$field_name = 'admin_groups';
680 643
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
681
	echo "<span>Modify field admin_groups to pages table";
682
	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
644
    add_modify_field_in_database($table_name,$field_name,$description);
683 645

  
684 646
	/**********************************************************
685 647
	 *  - Add field "admin_users" to table "pages"
......
687 649
	$table_name = TABLE_PREFIX.'pages';
688 650
	$field_name = 'admin_users';
689 651
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
690
	echo "<span>Modify field admin_users to pages table</span>";
691
	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
652
    add_modify_field_in_database($table_name,$field_name,$description);
692 653

  
693 654
	/**********************************************************
694 655
	 *  - Add field "viewing_groups" to table "pages"
......
696 657
	$table_name = TABLE_PREFIX.'pages';
697 658
	$field_name = 'viewing_groups';
698 659
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT '1'";
699
	echo "<span>Modify field viewing_groups to pages table</span>";
700
	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
660
//	echo "<span>Modify field viewing_groups to pages table</span>";
661
//	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
662
    add_modify_field_in_database($table_name,$field_name,$description);
701 663

  
702 664
	/**********************************************************
703 665
	 *  - Add field "viewing_users" to table "pages"
......
705 667
	$table_name = TABLE_PREFIX.'pages';
706 668
	$field_name = 'viewing_users';
707 669
	$description = "VARCHAR( 512 ) NOT NULL DEFAULT ''";
708
	echo "<span>Modify field viewing_users to pages table";
709
	echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
670
    add_modify_field_in_database($table_name,$field_name,$description);
710 671

  
711 672
	/**********************************************************
712 673
     *  - Add field "custom01" to table "pages"
......
714 675
	$table_name = TABLE_PREFIX.'pages';
715 676
	$field_name = 'custom01';
716 677
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
717
	if(!$database->field_exists($table_name,$field_name)) {
718
		echo "<span>Adding field custom01 to pages table</span>";
719
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
720
	} else {
721
		echo "<span>Modify field custom01 to pages table</span>";
722
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
723
	}
678
    add_modify_field_in_database($table_name,$field_name,$description);
724 679

  
725 680
	/**********************************************************
726 681
     *  - Add field "custom02" to table "pages"
......
728 683
	$table_name = TABLE_PREFIX.'pages';
729 684
	$field_name = 'custom02';
730 685
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT '' ";
731
	if(!$database->field_exists($table_name,$field_name)) {
732
		echo "<span>Adding field custom02 to pages table</span>";
733
		echo ($database->field_add($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
734
	} else {
735
		echo "<span>Modify field custom02 to pages table</span>";
736
		echo ($database->field_modify($table_name, $field_name, $description) ? " $OK<br />" : " $FAIL!<br />");
737
	}
686
    add_modify_field_in_database($table_name,$field_name,$description);
738 687

  
688
    if($bDebugModus) {
689
        echo implode(PHP_EOL,$aDebugMessage);
690
        $aDebugMessage = array();
691
    }
692

  
739 693
    /**********************************************************
740 694
     * modify wrong strucre on table sections
741 695
     * wrong structure let crash wb
......
743 697
	echo "<h4>Change field structure on table sections</h4>";
744 698
	$table_name = TABLE_PREFIX.'sections';
745 699
	$description = "VARCHAR( 255 ) NOT NULL DEFAULT ''";
746
	echo "<span>Modify field module on sections table</span>";
747
	echo ($database->field_modify($table_name, 'module', $description) ? " $OK<br />" : " $FAIL!<br />");
748
	echo "<span>Modify field block on sections table</span>";
749
	echo ($database->field_modify($table_name, 'block', $description) ? " $OK<br />" : " $FAIL!<br />");
750
	echo "<span>Modify field publ_start on sections table</span>";
751
	echo ($database->field_modify($table_name, 'publ_start', $description) ? " $OK<br />" : " $FAIL!<br />");
752
	echo "<span>Modify field publ_end on sections table</span>";
753
	echo ($database->field_modify($table_name, 'publ_end', $description) ? " $OK<br />" : " $FAIL!<br />");
700
	$aDebugMessage[] = "<span>Modify field module on sections table</span>";
701
	$aDebugMessage[] = ($database->field_modify($table_name, 'module', $description) ? " $OK<br />" : " $FAIL!<br />");
702
	$aDebugMessage[] = "<span>Modify field block on sections table</span>";
703
	$aDebugMessage[] = ($database->field_modify($table_name, 'block', $description) ? " $OK<br />" : " $FAIL!<br />");
704
	$aDebugMessage[] = "<span>Modify field publ_start on sections table</span>";
705
	$aDebugMessage[] = ($database->field_modify($table_name, 'publ_start', $description) ? " $OK<br />" : " $FAIL!<br />");
706
	$aDebugMessage[] = "<span>Modify field publ_end on sections table</span>";
707
	$aDebugMessage[] = ($database->field_modify($table_name, 'publ_end', $description) ? " $OK<br />" : " $FAIL!<br />");
754 708

  
709
    if($bDebugModus) {
710
        echo implode(PHP_EOL,$aDebugMessage);
711
        $aDebugMessage = array();
712
    }
713

  
714
	/**********************************************************
715
     *   `confirm_code` VARCHAR(32) NOT NULL DEFAULT '',
716
     *   `confirm_timeout` INT(11) NOT NULL DEFAULT '0',
717
     */
718
	echo "<h4>Change field structure on table users</h4>";
719
	$table_name = TABLE_PREFIX.'users';
720
	$field_name = 'confirm_code';
721
	$description = "VARCHAR( 32 ) NOT NULL DEFAULT '' AFTER `password` ";
722
    add_modify_field_in_database($table_name,$field_name,$description);
723

  
724
	$table_name = TABLE_PREFIX.'users';
725
	$field_name = 'confirm_timeout';
726
	$description = "INT(11) NOT NULL DEFAULT '0' AFTER `confirm_code` ";
727
    add_modify_field_in_database($table_name,$field_name,$description);
728

  
729
    if($bDebugModus) {
730
        echo implode(PHP_EOL,$aDebugMessage);
731
    }
755 732
    echo '</div>';
756 733

  
757 734
}
758 735

  
759
if($bDebugModus) {
760
    echo implode(PHP_EOL,$aDebugMessage);
761
}
762 736
$aDebugMessage = array();
763 737
/**********************************************************
764 738
 * This part with changing in mod_wysiwyg will be removed in the final version
......
929 903
     * upgrade modules if newer version is available
930 904
     * $aModuleList list of proofed modules
931 905
     */
932
    $sModuleList = 'news,wysiwyg,form';
906
    $sModuleList = 'news,wysiwyg,form,any';
933 907
    $aModuleList = explode(',', (defined('MODULES_UPGRADE_LIST') ? MODULES_UPGRADE_LIST : $sModuleList));
934 908
    echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>';
935 909
//	$aModuleList = array('news');

Also available in: Unified diff