Commit 6dd4aa36ba5ef96f691c6fbeeecd6fcfb48c129a
Exists in
master
and in
106 other branches
Merge branch 'master' into simplified-view-checkbox
Showing
5 changed files
with
54 additions
and
3 deletions
Show diff stats
php/classes/SharedObjectMgrAbstract.php
... | ... | @@ -80,6 +80,19 @@ abstract class SharedObjectMgrAbstract { |
80 | 80 | |
81 | 81 | return array('success' => TRUE, 'object_id' => $newId); |
82 | 82 | } |
83 | + | |
84 | + public function createFolder($folder_name) { | |
85 | + $folder_path = $this->getFolderDirPath($folder_name); | |
86 | + if (is_dir($folder_path)) { | |
87 | + return FALSE; | |
88 | + } | |
89 | + | |
90 | + mkdir($folder_path); | |
91 | + chgrp($folder_path, APACHE_USER); | |
92 | + chmod($folder_path, 0775); | |
93 | + | |
94 | + return is_dir($folder_path); | |
95 | + } | |
83 | 96 | |
84 | 97 | public function getRootDirPath() { |
85 | 98 | return SHAREDPATH . "/" . $this->rootdirname; |
... | ... | @@ -158,4 +171,4 @@ abstract class SharedObjectMgrAbstract { |
158 | 171 | } |
159 | 172 | } |
160 | 173 | |
161 | -?> | |
162 | 174 | \ No newline at end of file |
175 | +?> | ... | ... |
php/classes/SharedObjectTreeFile.php
... | ... | @@ -50,9 +50,32 @@ class SharedObjectTreeFile { |
50 | 50 | $objectNode->setAttribute($key, $value); |
51 | 51 | } |
52 | 52 | } |
53 | - | |
53 | + $this->doc->save($this->getFilePath()); | |
54 | 54 | |
55 | 55 | //Remove obsolete folders and objects |
56 | + $folders = $this->getFolders($object_type); | |
57 | + foreach ($folders as $folder) { | |
58 | + $folderNode = $this->getObjectFolderNode($object_type, $folder["name"]); | |
59 | + if (!isset($folderNode)) { | |
60 | + continue; | |
61 | + } | |
62 | + if (!array_key_exists($folder["name"], $objects)) { | |
63 | + $folderNode->parentNode->removeChild($folderNode); | |
64 | + } | |
65 | + else { | |
66 | + $objectNodes = $folderNode->getElementsByTagName($object_type); | |
67 | + $to_remove = array(); | |
68 | + foreach ($objectNodes as $objectNode) { | |
69 | + $idAtt = $objectNode->getAttribute('xml:id'); | |
70 | + if (!in_array($idAtt, $objects[$folder["name"]])) { | |
71 | + $to_remove[] = $objectNode; | |
72 | + } | |
73 | + } | |
74 | + foreach ($to_remove as $node) { | |
75 | + $folderNode->removeChild($node); | |
76 | + } | |
77 | + } | |
78 | + } | |
56 | 79 | |
57 | 80 | $this->doc->save($this->getFilePath()); |
58 | 81 | ... | ... |
php/classes/SharedObjectsMgr.php
... | ... | @@ -57,6 +57,18 @@ class SharedObjectsMgr { |
57 | 57 | |
58 | 58 | return $this->treeFile->getFolders($object_type); |
59 | 59 | } |
60 | + | |
61 | + public function createFolder($object_type, $folder_name) { | |
62 | + if (!array_key_exists($object_type, $this->sharedObjectsMgr) || !isset($this->sharedObjectsMgr[$object_type])) { | |
63 | + return array('success' => FALSE, 'message' => 'Unknown type'); | |
64 | + } | |
65 | + | |
66 | + if (!$this->sharedObjectsMgr[$object_type]->createFolder($folder_name)) { | |
67 | + return array('success' => FALSE, 'message' => 'Cannot create folder '.$folder_name); | |
68 | + } | |
69 | + | |
70 | + return $this->updateTree(); | |
71 | + } | |
60 | 72 | |
61 | 73 | public function isNameAlreadyUsed($object_type, $name) { |
62 | 74 | if (!array_key_exists($object_type, $this->sharedObjectsMgr) || !isset($this->sharedObjectsMgr[$object_type])) |
... | ... | @@ -96,4 +108,4 @@ class SharedObjectsMgr { |
96 | 108 | } |
97 | 109 | } |
98 | 110 | |
99 | -?> | |
100 | 111 | \ No newline at end of file |
112 | +?> | ... | ... |
php/config.php
... | ... | @@ -87,6 +87,7 @@ define('RemoteData', DATAPATH.'/RemoteData/'); |
87 | 87 | define('Functions', DATAPATH.'/Functions/'); |
88 | 88 | define('Hst', DATAPATH.'/Hst/'); |
89 | 89 | define('SpecialSettingsDir',DATAPATH.'/SpecialSettings/'); |
90 | +define('CommonLib', DATAPATH.'/compilation/lib/'); | |
90 | 91 | |
91 | 92 | // General Info files |
92 | 93 | define('orbitsXml',LocalData.'/Orbites.xml'); | ... | ... |