oops typo
authorx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 20 Mar 2007 23:53:15 +0000 (23:53 +0000)
committerx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 20 Mar 2007 23:53:15 +0000 (23:53 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1591 839d8a87-29fc-0310-9880-83ba4fa771e5

classes/platalpage.php
modules/xnet.php
modules/xnetgrp.php
templates/xnet/skin.tpl

index 1dd77ca..e3cf01f 100644 (file)
@@ -27,6 +27,7 @@ class PlatalPage extends Smarty
     private $_tpl;
     private $_errors;
     private $_failure;
+    private $_jsonVars;
 
     // {{{ function PlatalPage()
 
@@ -49,6 +50,7 @@ class PlatalPage extends Smarty
         $this->_page_type = $type;
         $this->_tpl       = $tpl;
         $this->_errors    = array();
+        $this->_jsonVars  = array();
         $this->_failure   = false;
 
         $this->register_prefilter('at_to_globals');
@@ -90,6 +92,10 @@ class PlatalPage extends Smarty
         $this->assign('xorg_failure', $this->_failure);
         $this->assign('globals', $globals);
 
+        if (Env::has('json') && count($this->_jsonVars)) {
+            return $this->jsonDisplay();
+        }
+        
         if (Env::v('display') == 'light') {
             $this->_page_type = SIMPLE;
         } elseif (Env::v('display') == 'raw') {
@@ -114,6 +120,9 @@ class PlatalPage extends Smarty
         $this->register_outputfilter('hide_emails');
         $this->addJsLink('wiki.js');
         header("Accept-Charset: utf-8");
+        if (Env::v('forceXml')) {
+            header("Content-Type: text/xml; charset=utf-8");
+        }
 
         if (!$globals->debug) {
             error_reporting(0);
@@ -219,6 +228,40 @@ class PlatalPage extends Smarty
     }
 
     // }}}
+    // {{{ function jsonDisplay
+    protected function jsonDisplay()
+    {
+        header("Content-type: text/javascript; charset=utf-8");
+        array_walk_recursive($this->_jsonVars, "escape_xorgDB");
+        $jsonbegin = Env::v('jsonBegin');
+        $jsonend = Env::v('jsonEnd');
+        if (Env::has('jsonVar')) {
+            $jsonbegin = Env::v('jsonVar').' = ';
+            $jsonend = ';';
+        } elseif (Env::has('jsonFunc')) {
+            $jsonbegin = Env::v('jsonFunc').'(';
+            $jsonend = ');';
+        }
+        echo $jsonbegin, json_encode($this->_jsonVars), $jsonend;
+        exit;
+    }
+    // }}}
+    // {{{ function jsonAssign
+    public function jsonAssign($var, $value)
+    {
+        $this->_jsonVars[$var] = $value;
+    }
+}
+
+function escape_xorgDB(&$item, $key)
+{
+    if (is_a($item, 'XOrgDBIterator')) {
+        $expanded = array();
+        while ($a = $item->next()) {
+            $expanded[] = $a;
+        }
+        $item = $expanded;
+    }
 }
 
 // {{{ function escape_html ()
index 7d73eb2..66972df 100644 (file)
@@ -32,6 +32,7 @@ class XnetModule extends PLModule
             'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC),
             'plan'      => $this->make_hook('plan',      AUTH_PUBLIC),
             'photo'     => $this->make_hook('photo',     AUTH_MDP),
+            'autologin' => $this->make_hook('autologin', AUTH_MDP),
         );
     }
 
@@ -196,6 +197,13 @@ class XnetModule extends PLModule
 
         $page->setType($cat);
     }
+    
+    function handler_autologin(&$page)
+    {
+        header("Content-type: text/javascript; charset=utf-8");
+        echo '$.ajax({ url: "index?forceXml=1", dataType: "xml", success: function(xml) { $("body").empty(); $("body",xml).prependTo("body"); }});';
+        exit;
+    }
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index f37d9ba..9eb51e0 100644 (file)
@@ -409,7 +409,7 @@ class XnetGrpModule extends PLModule
                            m.perms='admin' AS admin,
                            m.origine='X' AS x,
                            u.perms!='pending' AS inscrit,
-                           m.uid, e.email AS actif
+                           m.uid, IF(e.email IS NULL,NULL,1) AS actif
                      FROM  groupex.membres AS m
                 LEFT JOIN  auth_user_md5   AS u ON ( u.user_id = m.uid )
                 LEFT JOIN  aliases         AS a ON ( a.id = m.uid AND a.type='a_vie' )
@@ -420,6 +420,7 @@ class XnetGrpModule extends PLModule
                  ORDER BY  $tri
                     LIMIT  {?},{?}", $globals->asso('id'), $ofs*NB_PER_PAGE, NB_PER_PAGE);
         $page->assign('ann', $ann);
+        $page->jsonAssign('ann', $ann);
     }
 
     function handler_trombi(&$page, $num = 1)
index 0993ed4..1babec4 100644 (file)
               {list_all_my_groups}
               {if !$smarty.session.auth}
               <div>Me connecter :</div>
-              <a class='gp' href="login/{if $platal-pl_self() eq 'exit'}index{else}{$platal->pl_self()}{/if}">polytechnicien</a>
+              <a class='gp' href="login/{if $platal->pl_self() eq 'exit'}index{else}{$platal->pl_self()}{/if}">polytechnicien</a>
               {/if}
             </td>
             <td class="right" style="vertical-align: middle">