1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
9	header("location: index.php");
10	exit;
11}
12
13/**
14 * Move h5p assets to the new dir if it doesn't exist
15 *
16 * @param Installer $installer
17 */
18function upgrade_20190123_h5p_move_storage_assets_to_new_dir_tiki($installer)
19{
20	$newH5Pdir = 'storage/public/h5p';
21
22	if (! is_dir($newH5Pdir)) {
23		if (mkdir($newH5Pdir)) {
24			foreach (['cachedassets', 'content', 'exports','libraries','temp'] as $dir) {
25				if (is_dir('storage/public/' . $dir)) {
26					rename('storage/public/' . $dir, $newH5Pdir . '/' . $dir);
27				}
28			}
29		}
30	}
31}
32