classes/install/Install.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00020 // $Id$
00021 
00022 
00023 // Default installation data
00024 define('INSTALLER_DEFAULT_SITE_TITLE', 'common.openConferenceSystems');
00025 define('INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH', 6);
00026 
00027 import('install.PKPInstall');
00028 
00029 class Install extends PKPInstall {
00030 
00038    function Install($params, $descriptor = 'install.xml', $isPlugin = false) {
00039       parent::PKPInstall($descriptor, $params, $isPlugin);
00040    }
00041 
00042    //
00043    // Installer actions
00044    //
00045 
00050    function getCreateDirectories() {
00051       $directories = parent::getCreateDirectories();
00052       $directories[] = 'conferences';
00053       return $directories;
00054    }
00055 
00060    function createData() {
00061       // Add initial site data
00062       $locale = $this->getParam('locale');
00063       $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
00064       $site = new Site();
00065       $site->setRedirect(0);
00066       $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
00067       $site->setPrimaryLocale($locale);
00068       $site->setInstalledLocales($this->installedLocales);
00069       $site->setSupportedLocales($this->installedLocales);
00070       if (!$siteDao->insertSite($site)) {
00071          $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
00072          return false;
00073       }
00074 
00075       $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
00076       $siteSettingsDao->updateSetting('title', array($locale => __(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
00077       $siteSettingsDao->updateSetting('contactName', array($locale => __(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
00078       $siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true);
00079 
00080       // Add initial site administrator user
00081       $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
00082       $user = new User();
00083       $user->setUsername($this->getParam('adminUsername'));
00084       $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
00085       $user->setFirstName($user->getUsername());
00086       $user->setLastName('');
00087       $user->setEmail($this->getParam('adminEmail'));
00088       if (!$userDao->insertUser($user)) {
00089          $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
00090          return false;
00091       }
00092 
00093       $roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn);
00094       $role = new Role();
00095       $role->setConferenceId(0);
00096       $role->setUserId($user->getId());
00097       $role->setRoleId(ROLE_ID_SITE_ADMIN);
00098       if (!$roleDao->insertRole($role)) {
00099          $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
00100          return false;
00101       }
00102 
00103       // Install email template list and data for each locale
00104       $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
00105       $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
00106       foreach ($this->installedLocales as $locale) {
00107          $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
00108       }
00109 
00110       // Add initial plugin data to versions table
00111       $versionDao =& DAORegistry::getDAO('VersionDAO');
00112       import('site.VersionCheck');
00113       $categories = PluginRegistry::getCategories();
00114       foreach ($categories as $category) {
00115          PluginRegistry::loadCategory($category, true);
00116          $plugins = PluginRegistry::getPlugins($category);
00117          foreach ($plugins as $plugin) {
00118             $versionFile = $plugin->getPluginPath() . '/version.xml';
00119 
00120             if (FileManager::fileExists($versionFile)) {
00121                $versionInfo =& VersionCheck::parseVersionXML($versionFile);
00122                $pluginVersion = $versionInfo['version'];
00123                $pluginVersion->setCurrent(1);
00124                $versionDao->insertVersion($pluginVersion);
00125             }  else {
00126                $pluginVersion = new Version();
00127                $pluginVersion->setMajor(1);
00128                $pluginVersion->setMinor(0);
00129                $pluginVersion->setRevision(0);
00130                $pluginVersion->setBuild(0);
00131                $pluginVersion->setDateInstalled(Core::getCurrentDate());
00132                $pluginVersion->setCurrent(1);
00133                $pluginVersion->setProductType('plugins.' . $category);
00134                $pluginVersion->setProduct(basename($plugin->getPluginPath()));
00135                $versionDao->insertVersion($pluginVersion);
00136             }
00137          }
00138       }
00139 
00140       return true;
00141    }
00142 }
00143 
00144 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7