pathSync.php
1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* This page will be used to sync the old documents and folders table entries to the new ones
* This involves:
* o creating the parent_folder_ids and full_path entries for the existing documents that don't have them
* o creating the parent_folder_ids and full_path entries for the existing folders that don't have them
*
* @author Rob Cherry, Jam Warehouse South Africa (Pty) Ltd
* @date 21 February 2003
* @package sync
*/
require_once("../config/dmsDefaults.php");
require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
$aFolders = Folder::getList("parent_folder_ids IS NULL");
$aDocuments = Document::getList("parent_folder_ids IS NULL");
//update the folders
for ($i = 0; $i < count($aFolders); $i++) {
$oFolder = $aFolders[$i];
echo "Updating folder: " . $oFolder->getName() . "<br>";
updateFolder($oFolder);
}
echo "<br>";
//update the documents
for ($i = 0; $i < count($aDocuments); $i++) {
$oDocument = $aDocuments[$i];
echo "Updating document: " . $oDocument->getName() . "<br>";
$oDocument->update(true);
}
function updateFolder($oFolder) {
global $default, $lang_err_database, $lang_err_object_key;
$sFullPath = $oFolder->generateFullFolderPath($oFolder->getParentID());
$sFullPath = substr($sFullPath,1,strlen($sFullPath));
$sParentIDs = $oFolder->generateParentFolderIDS($oFolder->getParentID());
$sParentIDs = substr($sParentIDs,1,strlen($sParentIDs));
$sql = $default->db;
//root folders won't get anything added to them
if (strlen($sFullPath) > 0) {
$sql->query("UPDATE " . $default->owl_folders_table . " SET " .
"full_path = '" . addslashes($sFullPath) . "', " .
"parent_folder_ids = '" . addslashes($sParentIDs) . "' " .
"WHERE id = " . $oFolder->getID());
}
}
?>