X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2FBarrel.php;h=a1ba57438913e4f535075da97cef156a2cb7e750;hb=4be8b457f133dca97f43ef944c14452d6a929aa6;hp=2379561b86733e1dd251d7171ea7d0bc6d1a3d3c;hpb=fcc3110e8eee6ce903281d41f0e4b24e45f986dd;p=diogenes.git diff --git a/include/Barrel.php b/include/Barrel.php index 2379561..a1ba574 100644 --- a/include/Barrel.php +++ b/include/Barrel.php @@ -87,7 +87,7 @@ class Diogenes_Barrel $this->flags = new flagset($flags); $this->options = new Diogenes_Barrel_Options($this->alias); - $this->spool = new DiogenesSpool($this,$this->alias); + $this->spool = new Diogenes_VCS_Spool($this,$this->alias); $this->readTree(); } @@ -277,6 +277,7 @@ class Diogenes_Barrel /** Create a page with the given path, and return its PID. * * @param $path + * @param $caller */ function makePath($path, &$caller) { @@ -300,6 +301,46 @@ class Diogenes_Barrel } + /** Recursively delete a given path. + * + * @param $path + * @param $caller + */ + function rmPath($path, &$caller) + { + global $globals; + + if (!$path) { + $caller->info("rmPath: will not delete from root!"); + return false; + } + $curpid = $this->getPID($path); + if (!$curpid) { + $caller->info("rmPath: could not find '$path'"); + return false; + } + + // lookup children + $res = $globals->db->query("select PID from {$this->table_page} where parent=$curpid"); + $children = array(); + while (list($child) = mysql_fetch_row($res)) + array_push($children, $child); + mysql_free_result($res); + + // recurse into children + foreach ($children as $child) + { + $childpath = $this->getLocation($child); + if ($childpath) { + if (!$this->rmPath($childpath, $caller)) + return false; + } + } + + // delete this page + return Diogenes_Barrel_Page::delete($this, $curpid, $caller); + } + /** Compile the directory tree */ function compileTree()