+ /**
+ * Deletes all shared folders pointing to the specifc path
+ *
+ */
+ public static function deleteShares($name) {
+ global $xmlConfig;
+ $tmp = new OMVModuleZFSDataset($name);
+ $reldirpath = OMVModuleZFSUtil::getReldirpath($tmp->getMountPoint());
+ $poolname = OMVModuleZFSUtil::getPoolname($name);
+ $pooluuid = OMVModuleZFSUtil::getUUIDbyName($poolname);
+ $xpath = "//system/fstab/mntent[fsname='" . $pooluuid . "']";
+ $mountpoint = $xmlConfig->get($xpath);
+ $mntentuuid = $mountpoint['uuid'];
+ $xpath = "//system/shares/sharedfolder[mntentref='" . $mntentuuid . "' and reldirpath='" . $reldirpath . "']";
+ $xmlConfig->delete($xpath);
+ $dispatcher = &OMVNotifyDispatcher::getInstance();
+ $dispatcher->notify(OMV_NOTIFY_CREATE,"org.openmediavault.system.shares.sharedfolder");
+ }
+
+ /**
+ * Get the relative path by complete path
+ *
+ * @return string Relative path of the complet path
+ */
+ public static function getReldirpath($path) {
+ $subdirs = preg_split('/\//',$path);
+ $reldirpath = "";
+ for ($i=2;$i<count($subdirs);$i++) {
+ $reldirpath .= $subdirs[$i] . "/";
+ }
+ return(rtrim($reldirpath, "/"));
+
+ }
+