1 |
<?php |
1 |
<?php |
2 |
|
2 |
|
3 |
/** |
3 |
/** |
4 |
* Contains functions used during the database migration process. |
4 |
* Contains functions used during the database migration process. |
5 |
* |
5 |
* |
6 |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
6 |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
7 |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
7 |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
8 |
* @copyright (c)2003, 2004 Tamlyn Rhodes |
8 |
* @copyright (c)2003, 2004 Tamlyn Rhodes |
9 |
* @version $Id: migrate.inc.php,v 1.2 2004/12/15 17:04:56 tamlyn Exp $ |
9 |
* @version $Id: migrate.inc.php,v 1.2 2004/12/15 17:04:56 tamlyn Exp $ |
10 |
*/ |
10 |
*/ |
11 |
|
11 |
|
12 |
|
12 |
|
13 |
function setPerms($obj) { |
13 |
function setPerms($obj) { |
14 |
$obj->permissions = 0; |
14 |
$obj->permissions = 0; |
15 |
if(!empty($_POST["sgGrpRead"])) $obj->permissions |= SG_GRP_READ; |
15 |
if(!empty($_POST["sgGrpRead"])) $obj->permissions |= SG_GRP_READ; |
16 |
if(!empty($_POST["sgGrpEdit"])) $obj->permissions |= SG_GRP_EDIT; |
16 |
if(!empty($_POST["sgGrpEdit"])) $obj->permissions |= SG_GRP_EDIT; |
17 |
if(!empty($_POST["sgGrpAdd"])) $obj->permissions |= SG_GRP_ADD; |
17 |
if(!empty($_POST["sgGrpAdd"])) $obj->permissions |= SG_GRP_ADD; |
18 |
if(!empty($_POST["sgGrpDelete"])) $obj->permissions |= SG_GRP_DELETE; |
18 |
if(!empty($_POST["sgGrpDelete"])) $obj->permissions |= SG_GRP_DELETE; |
19 |
if(!empty($_POST["sgWldRead"])) $obj->permissions |= SG_WLD_READ; |
19 |
if(!empty($_POST["sgWldRead"])) $obj->permissions |= SG_WLD_READ; |
20 |
if(!empty($_POST["sgWldEdit"])) $obj->permissions |= SG_WLD_EDIT; |
20 |
if(!empty($_POST["sgWldEdit"])) $obj->permissions |= SG_WLD_EDIT; |
21 |
if(!empty($_POST["sgWldAdd"])) $obj->permissions |= SG_WLD_ADD; |
21 |
if(!empty($_POST["sgWldAdd"])) $obj->permissions |= SG_WLD_ADD; |
22 |
if(!empty($_POST["sgWldDelete"])) $obj->permissions |= SG_WLD_DELETE; |
22 |
if(!empty($_POST["sgWldDelete"])) $obj->permissions |= SG_WLD_DELETE; |
23 |
|
23 |
|
24 |
$obj->groups = $_REQUEST["sgGroups"]; |
24 |
$obj->groups = $_REQUEST["sgGroups"]; |
25 |
$obj->owner = $_REQUEST["sgOwner"]; |
25 |
$obj->owner = $_REQUEST["sgOwner"]; |
26 |
|
26 |
|
27 |
return $obj; |
27 |
return $obj; |
28 |
} |
28 |
} |
29 |
|
29 |
|
30 |
|
30 |
|
31 |
function convertDirectory ($path, $io_in, $io_out) |
31 |
function convertDirectory ($path, $io_in, $io_out) |
32 |
{ |
32 |
{ |
33 |
if (is_dir($path)) { |
33 |
if (is_dir($path)) { |
34 |
$gallery = $io_in->getGallery($path); |
34 |
$gallery = $io_in->getGallery($path); |
35 |
echo "<ul><li>Checking $path<br />\n"; |
35 |
echo "<ul><li>Checking $path<br />\n"; |
36 |
if($gallery) { |
36 |
if($gallery) { |
37 |
if($gallery->summary != "" && empty($_REQUEST["convertOverwrite"])) |
37 |
if($gallery->summary != "" && empty($_REQUEST["convertOverwrite"])) |
38 |
echo "Did NOT overwrite non-empty summary in $path<br />\n"; |
38 |
echo "Did NOT overwrite non-empty summary in $path<br />\n"; |
39 |
else { |
39 |
else { |
40 |
if($_REQUEST["convertType"]!='none') |
40 |
if($_REQUEST["convertType"]!='none') |
41 |
$gallery->summary = $gallery->desc; |
41 |
$gallery->summary = $gallery->desc; |
42 |
if($_REQUEST["convertType"]=='move') |
42 |
if($_REQUEST["convertType"]=='move') |
43 |
$gallery->desc = ""; |
43 |
$gallery->desc = ""; |
44 |
} |
44 |
} |
45 |
|
45 |
|
46 |
$gallery = setPerms($gallery); |
46 |
$gallery = setPerms($gallery); |
47 |
|
47 |
|
48 |
for($i=0; $i<count($gallery->images); $i++) |
48 |
for($i=0; $i<count($gallery->images); $i++) |
49 |
$gallery->images[$i] = setPerms($gallery->images[$i]); |
49 |
$gallery->images[$i] = setPerms($gallery->images[$i]); |
50 |
|
50 |
|
51 |
if($io_out->putGallery($gallery)) |
51 |
if($io_out->putGallery($gallery)) |
52 |
echo "Successfully converted $path<br />\n"; |
52 |
echo "Successfully converted $path<br />\n"; |
53 |
else |
53 |
else |
54 |
echo "Problem saving data file for $path<br />\n"; |
54 |
echo "Problem saving data file for $path<br />\n"; |
55 |
} else |
55 |
} else |
56 |
echo "Skipping $path<br />\n"; |
56 |
echo "Skipping $path<br />\n"; |
57 |
$d = dir($path); |
57 |
$d = dir($path); |
58 |
while (($file = $d->read()) !== false) { |
58 |
while (($file = $d->read()) !== false) { |
59 |
if ($file == '.' || $file == '..') continue; |
59 |
if ($file == '.' || $file == '..') continue; |
60 |
$path = $d->path."/".$file; |
60 |
$path = $d->path."/".$file; |
61 |
if (is_dir($path)) { |
61 |
if (is_dir($path)) { |
62 |
convertDirectory($path); |
62 |
convertDirectory($path); |
63 |
} |
63 |
} |
64 |
} |
64 |
} |
65 |
echo "</li></ul>\n"; |
65 |
echo "</li></ul>\n"; |
66 |
} |
66 |
} |
67 |
} |
67 |
} |
68 |
|
68 |
|
69 |
//output functions |
69 |
//output functions |
70 |
function setupHeader($var) |
70 |
function setupHeader($var) |
71 |
{ |
71 |
{ |
72 |
echo "\n</p>\n\n<h2>{$var}</h2>\n\n<p>\n"; |
72 |
echo "\n</p>\n\n<h2>{$var}</h2>\n\n<p>\n"; |
73 |
} |
73 |
} |
74 |
|
74 |
|
75 |
/** |
75 |
/** |
76 |
* Print an information message. Always returns true. |
76 |
* Print an information message. Always returns true. |
77 |
* @return true |
77 |
* @return true |
78 |
*/ |
78 |
*/ |
79 |
function setupMessage($var) |
79 |
function setupMessage($var) |
80 |
{ |
80 |
{ |
81 |
echo "{$var}.<br />\n"; |
81 |
echo "{$var}.<br />\n"; |
82 |
return true; |
82 |
return true; |
83 |
} |
83 |
} |
84 |
|
84 |
|
85 |
/** |
85 |
/** |
86 |
* Print an error message. Always returns false. |
86 |
* Print an error message. Always returns false. |
87 |
* @return false |
87 |
* @return false |
88 |
*/ |
88 |
*/ |
89 |
function setupError($var) |
89 |
function setupError($var) |
90 |
{ |
90 |
{ |
91 |
echo "<span class=\"error\">{$var}</span>.<br />\n"; |
91 |
echo "<span class=\"error\">{$var}</span>.<br />\n"; |
92 |
return false; |
92 |
return false; |
93 |
} |
93 |
} |
94 |
|
94 |
|
95 |
?> |
95 |
?> |