3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
6 * Galette 0.8 upgrade script
10 * Copyright © 2014 The Galette Team
12 * This file is part of Galette (http://galette.eu).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
34 * @link http://galette.eu
35 * @since Available since 0.8 - 2014-01-04
38 namespace Galette\Updates
;
41 use Galette\Updater\AbstractUpdater
;
44 * Galette 0.8 upgrade script
49 * @author Johan Cwiklinski <johan@x-tnd.be>
50 * @copyright 2014 The Galette Team
51 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
52 * @link http://galette.eu
53 * @since Available since 0.8 - 2014-01-04
55 class UpgradeTo08
extends AbstractUpdater
57 protected $db_version = '0.80';
62 public function __construct()
64 parent
::__construct();
65 $this->setSqlScripts('0.80');
73 protected function update()
87 if (!file_exists(GALETTE_ROOT
. 'data')) {
88 $created = @mkdir
(GALETTE_ROOT
. 'data');
93 GALETTE_ROOT
. 'data',
94 _T("Unable to create main datadir in %path!")
101 foreach ($dirs as $dir) {
102 $path = GALETTE_ROOT
. 'data/' . $dir;
103 if (!file_exists($path)) {
104 $created = @mkdir
($path);
110 _T("Unable to create datadir in %dir!")
115 $this->_moveDataDir($dir);
118 return !$this->hasErrors();
122 * Move data directory
124 * @param string $dirname Directory name to move
128 private function _moveDataDir($dirname)
130 //all directories should not be moved
137 if (!in_array($dirname, $nomove)) {
138 $origdir = GALETTE_ROOT
. $dirname . '/';
139 $destdir = GALETTE_DATA_PATH
. $dirname . '/';
142 //move directory contents
145 if (GALETTE_LOGS_PATH
=== $destdir && file_exists($origdir)) {
150 if (GALETTE_EXPORTS_PATH
=== $destdir && file_exists($origdir)) {
155 if (GALETTE_IMPORTS_PATH
=== $destdir && file_exists($origdir)) {
160 if (GALETTE_PHOTOS_PATH
=== $destdir && file_exists($origdir)) {
165 if (GALETTE_ATTACHMENTS_PATH
=== $destdir
166 && file_exists($origdir)
172 if (GALETTE_FILES_PATH
=== $destdir && file_exists($origdir)) {
181 while (($entry = $d->read()) !== false) {
182 if ($entry != '.' && $entry != '..') {
183 $moved = @rename
($origdir . $entry, $destdir . $entry);
190 _T("File %file has not been moved :-/")
199 $this->addReportEntry(
203 _T("Directory %dir has been moved!")
208 //remove old directory?
209 //maybe it would be done by the user
215 _T("Directory %dir has not been moved :(")
220 $this->addReportEntry(
224 _T("Directory %dir is not in its original path and will not be moved.")