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
33 * @link http://galette.eu
34 * @since Available since 0.8 - 2014-01-04
37 namespace Galette\Updates
;
40 use Galette\Updater\AbstractUpdater
;
43 * Galette 0.8 upgrade script
48 * @author Johan Cwiklinski <johan@x-tnd.be>
49 * @copyright 2014 The Galette Team
50 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
51 * @link http://galette.eu
52 * @since Available since 0.8 - 2014-01-04
54 class UpgradeTo08
extends AbstractUpdater
56 protected $db_version = '0.80';
61 public function __construct()
63 parent
::__construct();
64 $this->setSqlScripts('0.80');
72 protected function update()
86 if (!file_exists(GALETTE_ROOT
. 'data')) {
87 $created = @mkdir
(GALETTE_ROOT
. 'data');
92 GALETTE_ROOT
. 'data',
93 _T("Unable to create main datadir in %path!")
100 foreach ($dirs as $dir) {
101 $path = GALETTE_ROOT
. 'data/' . $dir;
102 if (!file_exists($path)) {
103 $created = @mkdir
($path);
109 _T("Unable to create datadir in %dir!")
114 $this->_moveDataDir($dir);
117 return !$this->hasErrors();
121 * Move data directory
123 * @param string $dirname Directory name to move
127 private function _moveDataDir($dirname)
129 //all directories should not be moved
136 if (!in_array($dirname, $nomove)) {
137 $origdir = GALETTE_ROOT
. $dirname . '/';
138 $destdir = GALETTE_DATA_PATH
. $dirname . '/';
141 //move directory contents
144 if (GALETTE_LOGS_PATH
=== $destdir && file_exists($origdir)) {
149 if (GALETTE_EXPORTS_PATH
=== $destdir && file_exists($origdir)) {
154 if (GALETTE_IMPORTS_PATH
=== $destdir && file_exists($origdir)) {
159 if (GALETTE_PHOTOS_PATH
=== $destdir && file_exists($origdir)) {
164 if (GALETTE_ATTACHMENTS_PATH
=== $destdir
165 && file_exists($origdir)
171 if (GALETTE_FILES_PATH
=== $destdir && file_exists($origdir)) {
180 while (($entry = $d->read()) !== false) {
181 if ($entry != '.' && $entry != '..') {
182 $moved = @rename
($origdir . $entry, $destdir . $entry);
189 _T("File %file has not been moved :-/")
198 $this->addReportEntry(
202 _T("Directory %dir has been moved!")
207 //remove old directory?
208 //maybe it would be done by the user
214 _T("Directory %dir has not been moved :(")
219 $this->addReportEntry(
223 _T("Directory %dir is not in its original path and will not be moved.")