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