Changeset 745


Ignore:
Timestamp:
Sep 10, 2015, 9:51:23 PM (9 years ago)
Author:
chronos
Message:
  • Added: More appmodule install/uninstallation.
Location:
trunk/Modules
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Map/Map.php

    r738 r745  
    231231      'Filter' => '1',
    232232    ));
    233 
    234   }
    235 }
     233  }
     234
     235  function DoInstall()
     236  {
     237    $this->System->Database->query("CREATE TABLE IF NOT EXISTS `MapPosition` (
     238  `Id` int(11) NOT NULL AUTO_INCREMENT,
     239  `Name` varchar(255) NOT NULL,
     240  `Pos` varchar(255) NOT NULL,
     241  PRIMARY KEY (`Id`)
     242) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     243  }
     244
     245  function DoUninstall()
     246  {
     247    $this->Database->query('DROP TABLE `MapPosition`');
     248  }
     249}
  • trunk/Modules/Subject/Subject.php

    r740 r745  
    1111    $this->License = 'GNU/GPL';
    1212    $this->Description = 'Subject management';
    13     $this->Dependencies = array('User');
     13    $this->Dependencies = array('User', 'Map');
    1414  }
    1515
     
    116116    ));
    117117  }
     118
     119  function DoInstall()
     120  {
     121    $this->Database->query("CREATE TABLE IF NOT EXISTS `Subject` (
     122  `Id` int(11) NOT NULL AUTO_INCREMENT,
     123  `Name` varchar(64) NOT NULL DEFAULT '',
     124  `AddressStreet` varchar(64) NOT NULL DEFAULT '',
     125  `AddressTown` varchar(64) NOT NULL DEFAULT '',
     126  `AddressPSC` int(11) NOT NULL DEFAULT '0',
     127  `AddressCountry` int(11) NOT NULL,
     128  `IC` varchar(32) NOT NULL,
     129  `DIC` varchar(32) NOT NULL DEFAULT '',
     130  `PayVAT` int(11) NOT NULL,
     131  `MapPosition` int(11) DEFAULT NULL,
     132  `WWW` varchar(255) NOT NULL,
     133  `Note` varchar(255) NOT NULL,
     134  PRIMARY KEY (`Id`)
     135) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     136    $this->Database->query("CREATE TABLE IF NOT EXISTS `Contact` (
     137  `Id` int(11) NOT NULL AUTO_INCREMENT,
     138  `Category` int(11) NOT NULL,
     139  `Value` varchar(255) NOT NULL,
     140  `Subject` int(11) DEFAULT NULL,
     141  `User` int(11) DEFAULT NULL,
     142  `Description` varchar(255) NOT NULL,
     143  `Receive` tinyint(1) NOT NULL,
     144  PRIMARY KEY (`Id`)
     145) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     146    $this->System->Database->query("CREATE TABLE IF NOT EXISTS `ContactCategory` (
     147  `Id` int(11) NOT NULL AUTO_INCREMENT,
     148  `Name` varchar(255) NOT NULL,
     149  PRIMARY KEY (`Id`)
     150) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;");
     151
     152    $this->Database->query("ALTER TABLE `Subject`
     153ADD CONSTRAINT `Subject_ibfk_1` FOREIGN KEY (`AddressCountry`) REFERENCES `Country` (`Id`),
     154ADD CONSTRAINT `Subject_ibfk_2` FOREIGN KEY (`MapPosition`) REFERENCES `MapPosition` (`Id`);");
     155    $this->Database->query("ALTER TABLE `Contact`
     156    ADD CONSTRAINT `Contact_ibfk_1` FOREIGN KEY (`Category`) REFERENCES `ContactCategory` (`Id`),
     157    ADD CONSTRAINT `Contact_ibfk_2` FOREIGN KEY (`Subject`) REFERENCES `Subject` (`Id`),
     158    ADD CONSTRAINT `Contact_ibfk_3` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);");
     159  }
     160
     161  function DoUninstall()
     162  {
     163    $this->Database->query('DROP TABLE `Contact`');
     164    $this->Database->query('DROP TABLE `ContactCategory`');
     165    $this->Database->query('DROP TABLE `Subject`');
     166  }
    118167}
  • trunk/Modules/Wiki/Wiki.php

    r738 r745  
    1818  {
    1919    parent::Install();
    20     $this->Database->Query("'CREATE TABLE IF NOT EXISTS `WikiPage` (
     20    $this->Database->Query('CREATE TABLE IF NOT EXISTS `WikiPage` (
    2121    `Id` int(11) NOT NULL AUTO_INCREMENT,
    2222    `Name` varchar(255) NOT NULL,
     
    2626    UNIQUE KEY `Name` (`Name`),
    2727    KEY `VisibleInMenu` (`VisibleInMenu`)
    28 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
    29     CREATE TABLE IF NOT EXISTS `WikiPageContent` (
     28) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1');
     29    $this->Database->Query('CREATE TABLE IF NOT EXISTS `WikiPageContent` (
    3030    `Id` int(11) NOT NULL AUTO_INCREMENT,
    3131    `Page` int(11) NOT NULL,
     
    3636    KEY `User` (`User`),
    3737    KEY `Page` (`Page`)
    38 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
    39     ALTER TABLE `WikiPageContent`
     38) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1');
     39    $this->Database->Query('ALTER TABLE `WikiPageContent`
    4040ADD CONSTRAINT `WikiPageContent_ibfk_2` FOREIGN KEY (`Page`) REFERENCES `WikiPage` (`Id`),
    41 ADD CONSTRAINT `WikiPageContent_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`ID`);'");
     41ADD CONSTRAINT `WikiPageContent_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`ID`)');
    4242  }
    4343
    4444  function DoUnInstall()
    4545  {
    46     $this->Database->query("DELETE TABLE `WikiPageContent`; '.
    47       'DELETE TABLE `WikiPage`;");
    48     parent::UnInstall();
     46    $this->Database->query('DELETE TABLE `WikiPageContent`');
     47    $this->Database->query('DELETE TABLE `WikiPage`;');
    4948  }
    5049
     
    6564      $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki');
    6665      $this->System->RegisterMenuItem(array(
    67           'Title' => $DbRow['Name'],
    68           'Hint' => '',
    69           'Link' => $this->System->Link('/'.$DbRow['NormalizedName'].'/'),
    70           'Permission' => LICENCE_ANONYMOUS,
    71           'Icon' => '',
     66        'Title' => $DbRow['Name'],
     67        'Hint' => '',
     68        'Link' => $this->System->Link('/'.$DbRow['NormalizedName'].'/'),
     69        'Permission' => LICENCE_ANONYMOUS,
     70        'Icon' => '',
    7271      ), 2);
    7372    }
Note: See TracChangeset for help on using the changeset viewer.