Release plat/al core v1.1.13
[platal.git] / classes / plwikipage.php
index 6f28191..19cb736 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -64,6 +64,18 @@ class PlWikiPage
         return self::workDir() . '/cache_' . $this->name . '.tpl';
     }
 
+    /** Remove the cache for the current page.
+     */
+    public function removePageCache()
+    {
+        @unlink($this->cacheFilename());
+        global $globals;
+        $page = glob($globals->spoolroot . '/spool/templates_c/*cache_' . $this->name . '.tpl.php');
+        if (count($page) > 0) {
+            @unlink($page[0]);
+        }
+    }
+
     /** Fetch the content of the wiki page.
      */
     private function fetchContent()
@@ -392,10 +404,11 @@ class PlWikiPage
           case 'public':
             return true;
           case 'logged':
-          case 'mdp':
             return S::logged();
+          case 'mdp':
+            return S::identified();
           case 'admin':
-            return S::has_perms();
+            return S::admin();
           default:
             return false;
         }
@@ -409,11 +422,19 @@ class PlWikiPage
           case 'public':
             return;
           case 'logged':
-            Platal::session()->start(AUTH_PUBLIC + 1);
-            return;
+            $ok = Platal::session()->start(AUTH_PUBLIC + 1);
+            break;
           default:
-            Platal::session()->start(Platal::session()->sureLevel());
-            return;
+            $ok = Platal::session()->start(Platal::session()->sureLevel());
+            break;
+        }
+        if (!$ok) {
+            global $platal;
+            $page =& Platal::page();
+            $platal->force_login($page);
+        } else if ($perm == 'admin' && !S::admin()) {
+            global $platal;
+            $platal->error403();
         }
     }
 
@@ -461,5 +482,5 @@ class PlWikiPage
     }
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
 ?>