Moving to GitHub.
[platal.git] / classes / xnet.php
index 88c600c..1251ba6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -23,55 +23,47 @@ class Xnet extends Platal
 {
     public function __construct()
     {
-        $modules = func_get_args();
-        parent::__construct($modules);
+        parent::__construct(
+            'xnet',
 
-        global $globals;
-        if ($globals->asso()) {
-            if ($p = strpos($this->path, '/')) {
-                $this->ns   = substr($this->path, 0, $p).'/';
-                $this->path = '%grp'.substr($this->path, $p);
-            } else {
-                $this->ns   = $this->path.'/';
-                $this->path = '%grp';
-            }
-        }
+            'bandeau',
+            'geoloc',
+            'payment',
+            'xnetevents',
+            'xnetgrp',
+            'xnetlists',
+            'xnetnl'
+        );
     }
 
-    protected function find_nearest_key($key, array &$array)
+    public function hook_map($name)
     {
-        global $globals;
-        if (in_array('%grp', array_keys($array)) &&  $key == $globals->asso('diminutif')) {
-            return '%grp';
+        if ($name == 'grp') {
+            global $globals;
+            if ($globals->asso()) {
+                return $globals->asso('shortname');
+            }
         }
-        return parent::find_nearest_key($key, $array);
-    }
-
-    protected function near_hook()
-    {
-        global $globals;
-        $link = str_replace('%grp', $globals->asso('diminutif'), parent::near_hook());
-        if ($link != $this->path) {
-            return $link;
-        }   
-        return null; 
+        return null;
     }
 
     protected function find_hook()
     {
         $ans = parent::find_hook();
-        if ($ans && $this->ns) {
-            $this->path    = $this->ns . substr($this->path, 5);
-            $this->argv[0] = $this->ns . substr($this->argv[0], 5);
-        }
+        $this->https = false;
         return $ans;
     }
 
-    protected function force_login(&$page)
+    public function force_login(PlPage $page)
     {
-        http_redirect(S::v('loginX'));
+        $redirect = S::v('loginX');
+        if (!$redirect) {
+            $page->trigError('Impossible de s\'authentifier. Problème de configuration de plat/al.');
+            return;
+        }
+        http_redirect($redirect);
     }
 }
 
-// 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:
 ?>