/** * 初期データを読み込む * * @param string $dbDataPattern 初期データのパターン * @param string $currentTheme テーマ名 * @return bool */ protected function _load_default_data_pattern($dbDataPattern, $currentTheme = '') { list($theme, $pattern) = explode('.', $dbDataPattern); if (!$this->BcManager->checkDefaultDataPattern($pattern, $theme)) { $this->setMessage('初期データのバージョンが違うか、初期データの構造が壊れています。', true); return false; } $excludes = array('plugins', 'dblogs', 'users'); $User = ClassRegistry::init('User'); /* データを削除する */ $this->BcManager->resetAllTables(null, $excludes); $result = true; /* コアデータ */ if (!$this->BcManager->loadDefaultDataPattern('default', null, $pattern, $theme, 'core', $excludes)) { $result = false; $this->log($dbDataPattern . " の初期データのロードに失敗しました。"); } /* プラグインデータ */ $corePlugins = Configure::read('BcApp.corePlugins'); $plugins = array_merge($corePlugins, BcUtil::getCurrentThemesPlugins()); foreach ($plugins as $plugin) { $this->BcManager->loadDefaultDataPattern('default', null, $pattern, $theme, $plugin, $excludes); } if (!$result) { /* 指定したデータセットでの読み込みに失敗した場合、コアのデータ読み込みを試みる */ if (!$this->BcManager->loadDefaultDataPattern('default', null, 'default', 'core', 'core', $excludes)) { $this->log("コアの初期データのロードに失敗しました。"); $result = false; } foreach ($corePlugins as $corePlugin) { if (!$this->BcManager->loadDefaultDataPattern('default', null, 'default', 'core', $corePlugin, $excludes)) { $this->log("コアのプラグインの初期データのロードに失敗しました。"); $result = false; } } if ($result) { $this->setMessage('初期データの読み込みに失敗しましたので baserCMSコアの初期データを読み込みました。', true); } else { $this->setMessage('初期データの読み込みに失敗しました。データが不完全な状態です。正常に動作しない可能性があります。', true); } } clearAllCache(); // メール受信テーブルの作成 App::uses('MailMessage', 'Mail.Model'); $MailMessage = new MailMessage(); if (!$MailMessage->reconstructionAll()) { $this->log('メールプラグインのメール受信用テーブルの生成に失敗しました。'); $result = false; } clearAllCache(); ClassRegistry::flush(); BcSite::flash(); if ($currentTheme) { $siteConfigs = array('SiteConfig' => array('theme' => $currentTheme)); $this->SiteConfig->saveKeyValue($siteConfigs); } if (!$this->Page->createAllPageTemplate()) { $result = false; $this->log('初期データの読み込み中にページテンプレートの生成に失敗しました。' . '「Pages」フォルダに書き込み権限が付与されていない可能性があります。' . '権限設定後、テーマの適用をやり直すか、表示できないページについて固定ページ管理より更新処理を行ってください。'); } // システムデータの初期化 // TODO $this->BcManager->initSystemData() は、$this->Page->createAllPageTemplate() の // 後に呼出さないと $this->Page の実体が何故か AppModel にすりかわってしまい、 // createAllPageTemplate メソッドが呼び出せないので注意 if (!$this->BcManager->initSystemData(null, array('excludeUsers' => true))) { $result = false; $this->log('システムデータの初期化に失敗しました。'); } // ユーザーデータの初期化 $UserGroup = ClassRegistry::init('UserGroup'); $adminGroupId = $UserGroup->field('id', array('UserGroup.name' => 'admins')); $users = $User->find('all', array('recursive' => -1)); foreach ($users as $user) { $user['User']['user_group_id'] = $adminGroupId; unset($user['User']['password']); if (!$User->save($user)) { $result = false; $this->log('ユーザーデータの初期化に失敗しました。手動で各ユーザーのユーザーグループの設定を行なってください。'); } if (!$User->applyDefaultFavorites($user['User']['id'], $user['User']['user_group_id'])) { $result = false; $this->log('ユーザーのよく使う項目データの初期化に失敗しました。手動で各ユーザーのよく使う項目の設定を行なってください。'); } } $Db = ConnectionManager::getDataSource('default'); if ($Db->config['datasource'] == 'Database/BcPostgres') { $Db->updateSequence(); } // システム基本設定の更新 $siteConfigs = array('SiteConfig' => array('email' => $this->siteConfigs['email'], 'google_analytics_id' => $this->siteConfigs['google_analytics_id'], 'first_access' => null, 'version' => $this->siteConfigs['version'])); $this->SiteConfig->saveKeyValue($siteConfigs); return $result; }
* @copyright Copyright (c) baserCMS Users Community * @link http://basercms.net baserCMS Project * @package Mail.Config * @since baserCMS v 0.1.0 * @license http://basercms.net/license/index.html */ /** * データベース初期化 */ $this->Plugin->initDb('Mail'); /** * メッセージテーブル構築 */ App::uses('MailMessage', 'Mail.Model'); $MailMessage = new MailMessage(); $MailMessage->reconstructionAll(); /** * 必要フォルダ初期化 */ $filesPath = WWW_ROOT . 'files'; $savePath = $filesPath . DS . 'mail'; $limitedPath = $savePath . DS . 'limited'; if (is_writable($filesPath) && !is_dir($savePath)) { mkdir($savePath); } if (!is_writable($savePath)) { chmod($savePath, 0777); } if (is_writable($savePath) && !is_dir($limitedPath)) { mkdir($limitedPath); }