PlWizard tabs are fully clickable
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 22 Sep 2007 20:24:59 +0000 (22:24 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 22 Sep 2007 20:24:59 +0000 (22:24 +0200)
Add hasPerm() and hasPerms() in templates to easily check user permissions

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
20 files changed:
ChangeLog
classes/platalpage.php
htdocs/css/default.css
htdocs/css/keynote.css
htdocs/css/openweb.css
modules/events.php
templates/core/plwizard.tpl
templates/events/index.tpl
templates/include/minifiche.tpl
templates/include/plview.trombi.tpl
templates/include/tips.tpl
templates/include/trombi.tpl
templates/lists/header_listes.tpl
templates/newsletter/show.tpl
templates/platal/review.tpl
templates/profile/profile.tpl
templates/search/quick.tpl
templates/skin/common.header.tpl
templates/skin/common.menu.tpl
templates/xnet/skin.tpl

index fdc829b..3c4597b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,13 +28,13 @@ Bug/Wish:
 
     * Carnet:
         - #682: Can quick search in contact list                           -FRU
-        - #713: Can run the site in a degraded mode                        -FRU
 
     * Core:
         - #665: Fix text alignment                                         -FRU
         - #674: MiniWiki xhtml validation                                  -FRU
         - #678: PlUpload filename detection                                -FRU
         - #690: Improves SMTP pass privacy policy                          -FRU
+        - #713: Can run the site in a degraded mode                        -FRU
         - #717: Allow TLD with length up to 6 characters in emails         -FRU
 
     * Emails:
index f89f279..42b6fcd 100644 (file)
@@ -92,6 +92,7 @@ abstract class PlatalPage extends Smarty
         $this->register_prefilter('trimwhitespace');
         $this->register_prefilter('form_force_encodings');
         $this->register_prefilter('wiki_include');
+        $this->register_prefilter('if_has_perms');
         $this->assign('xorg_errors', $this->_errors);
         $this->assign('xorg_failure', $this->_failure);
         $this->assign('globals', $globals);
@@ -351,6 +352,19 @@ function wiki_include($source, &$smarty)
 }
 
 // }}}
+//{{{ function hasPerm
+
+function if_has_perms($source, &$smarty)
+{
+    $source = preg_replace('/\{if([^}]*) (\!?)hasPerms\(([^)]+)\)([^}]*)\}/',
+                           '{if\1 \2$smarty.session.perms->hasFlagCombination(\3)\4}',
+                           $source);
+    return preg_replace('/\{if([^}]*) (\!?)hasPerm\(([^)]+)\)([^}]*)\}/',
+                        '{if\1 \2($smarty.session.perms && $smarty.session.perms->hasFlag(\3))\4}',
+                        $source);
+}
+
+// }}}
 // {{{
 
 function form_force_encodings($source, &$smarty)
index 6e6ba22..8fcfbfe 100644 (file)
@@ -320,13 +320,13 @@ div.long td.rt { width: 65%; }
     background-color: #777;
 }
 
-.wizard .wiz_header .wiz_tab a {
+.wizard .wiz_header a {
     color: #000;
     text-decoration: none;
     vertical-align: middle;
 }
 
-.wizard .wiz_header .active a {
+.wizard .wiz_header a.active {
     color: #fff;
 }
 
index c0519b7..a7ca629 100644 (file)
@@ -332,13 +332,13 @@ div.long td.rt { width: 65%; }
     background-color: #777;
 }
 
-.wizard .wiz_header .wiz_tab a {
+.wizard .wiz_header a {
     color: #000;
     text-decoration: none;
     vertical-align: middle;
 }
 
-.wizard .wiz_header .active a {
+.wizard .wiz_header a.active {
     color: #fff;
 }
 
index a1a39e8..950a1fb 100644 (file)
@@ -311,13 +311,13 @@ div.long td.rt { width: 65%; }
     background-color: #777;
 }
 
-.wizard .wiz_header .wiz_tab a {
+.wizard .wiz_header a {
     color: #000;
     text-decoration: none;
     vertical-align: middle;
 }
 
-.wizard .wiz_header .active a {
+.wizard .wiz_header a.active {
     color: #fff;
 }
 
index d26c517..fbe8eef 100644 (file)
@@ -40,7 +40,7 @@ class EventsModule extends PLModule
     {
         global $globals;
         // Add a new special tip when changing plat/al version
-//        if ($globals->version != S::v('last_version') && is_null($exclude)) {
+        if ($globals->version != S::v('last_version') && is_null($exclude)) {
             XDB::execute('UPDATE auth_user_quick
                              SET last_version = {?}
                            WHERE user_id = {?}',
@@ -57,7 +57,7 @@ class EventsModule extends PLModule
                          'promo_max' => 0,
                          'state'     => 'active',
                          'special'   => true);
-  //      }
+        }
 
         $exclude  = is_null($exclude) ? '' : ' AND id != ' . $exclude . ' ';
         $priority = rand(0, 510);
index 8cc54ee..095765d 100644 (file)
 <div class="wizard" style="clear: both">
   <div class="wiz_header">
     {foreach from=$pages item=title key=id}
-    <div class="wiz_tab {if $id eq $current}active{/if} {if !$stateless && $current gt $id}grayed{/if}"
-         style="float: left; width: {$tab_width}%" id="wiz_tab_{$lookup[$id]}">
-      {if $stateless || $id gt $current}
-        <a href="{$wiz_baseurl}/{$lookup[$id]}" onclick="return changePage(this, '{$lookup[$id]}')">{/if}
-      {$title}
-      {if $stateless || $id gt $current}</a>{/if}
-    </div>
+    {if $stateless || $id gt $current}
+    {assign var=tag value="a"}
+    {else}
+    {assign var=tag value="div"}
+    {/if}
+    <{$tag} class="wiz_tab {if $id eq $current}active{/if} {if !$stateless && $current gt $id}grayed{/if}"
+            style="display: block; float: left; width: {$tab_width}%; vertical-align: middle"
+            id="wiz_tab_{$lookup[$id]}"
+            {if $tag eq "a"}
+            href="{$wiz_baseurl}/{$lookup[$id]}"
+            onclick="return changePage(this, '{$lookup[$id]}')"
+            {/if}
+            >
+      <span style="vertical-align: middle">{$title}</span>
+    </{$tag}>
     {/foreach}
     <div style="clear: both"></div>
   </div>
index 7b02de3..4c2e269 100644 (file)
@@ -174,7 +174,7 @@ Bienvenue {$smarty.session.prenom}{if $birthday}
           {/if}
         </div>
         <div style="float:right">
-          {if $smarty.session.perms->hasFlag('admin')}
+          {if hasPerm('admin')}
           <a href="admin/events/edit/{$ev.id}">{icon name=page_edit title="Editer cet article"}</a>
           {/if}
           <a href="events/read/{$ev.id}{if $previd}/newsid{$previd}{/if}" onclick="return readEvent('{$ev.id}')">{icon name=cross title="Cacher cet article"}</a>
index 6149550..c2ae7a0 100644 (file)
@@ -73,7 +73,7 @@
     {/if}
     {/if}
 
-    {if $smarty.session.perms->hasFlag('admin')}
+    {if hasPerm('admin')}
       [{if !$c.wasinscrit && !$c.dcd}
         <a href="marketing/private/{$c.user_id}">{*
           *}{icon name=email title="marketter user"}</a>
index d58f3c1..97f44c1 100644 (file)
@@ -35,7 +35,7 @@
       <a href="{$mainsiteurl}profile/{$p.forlife}" class="popup2">
         <img src="photo/{$p.forlife}" width="110" alt=" [ PHOTO ] " />
       </a>
-      {if $trombi_with_admin && $smarty.session.perms->hasFlag('admin')}
+      {if $trombi_with_admin && hasPerm('admin')}
       <a href="{$mainsiteurl}admin/trombino/{$p.user_id}">{icon name=wrench title="[admin]"}</a>
       {/if}
       <br />
index cba139f..d274923 100644 (file)
@@ -26,7 +26,7 @@
 {/if}
   <legend>{icon name=lightbulb} {if !$tips.special}
     Astuce&nbsp;: {$tips.titre}
-    {if $smarty.session.perms->hasFlag('admin') && !$tips.special && !$nochange}
+    {if hasPerm('admin') && !$tips.special && !$nochange}
     <a href="admin/tips/edit/{$tips.id}">{icon name="page_edit" title="Editer"}</a>
     {/if}
   {else}
index fcea502..91a0c3e 100644 (file)
@@ -31,7 +31,7 @@
       <a href="{if $urlmainsite}{$urlmainsite}{/if}profile/{$p.forlife}" class="popup2">
         <img src="{$globals->baseurl}/photo/{$p.forlife}" width="110" alt=" [ PHOTO ] " />
       </a>
-      {if $trombi_admin && $smarty.session.perms->hasFlag('admin') && !$urlmainsite}
+      {if $trombi_admin && hasPerm('admin') && !$urlmainsite}
       <a href="admin/trombino/{$p.user_id}">
         {icon name=wrench title="[admin]"}</a>
       {/if}
index c50398a..d5b4e2d 100644 (file)
@@ -46,7 +46,7 @@
       {/if}
     </td>
   </tr>
-  {if $details.own || $smarty.session.perms->hasFlagCombination('admin,groupadmin')}
+  {if $details.own || hasPerms('admin,groupadmin')}
   <tr>
     <td><strong>Administrer la liste :</strong></td>
     <td>
@@ -73,7 +73,7 @@
     </td>
   </tr>
   {/if}
-  {if $smarty.session.perms->hasFlagCombination('admin,groupadmin')}
+  {if hasPerms('admin,groupadmin')}
 
   <tr>
     <td><strong>Administrer (avancé) :</strong></td>
index 71f2160..3d5fcc5 100644 (file)
@@ -30,7 +30,7 @@
   {else}
   [<a href='nl/show/{$nl->id()}?text=1'>version Texte</a>]
   {/if}
-  {if $smarty.session.perms->hasFlag('admin')}
+  {if hasPerm('admin')}
   [<a href='admin/newsletter/edit/{$nl->id()}'>Editer</a>]
   {/if}
 </p>
index daddfd6..1b91280 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
+
 {if $cacheExists}
 {include wiki=$article}
-{elseif $smarty.session.perms->hasFlag('admin')}
+{if hasPerm('admin')}
+<div class="center">
+  <a href="{$article|replace:'.':'/'}?action=edit">{icon name="page_edit" title="Editer la page"} Mettre à jour la page</a>
+</div>
+{/if}
+{elseif hasPerm('admin')}
 La page wiki associée n'existe pas. <a href="{$article|replace:'.':'/'}?action=edit">Il faut l'éditer</a>.
 {else}
 <p class="erreur">La page n'existe pas</p>
index 4b73b91..0bd7392 100644 (file)
@@ -69,7 +69,7 @@ function chgMainWinLoc(strPage)
       <a href="javascript:chgMainWinLoc('carnet/contacts?action=retirer&amp;user={$x.forlife}')">
         {icon name=cross title="Retirer de mes contacts"}</a>
       {/if}
-      {if $smarty.session.perms->hasFlag('admin')}
+      {if hasPerm('admin')}
       <a href="javascript:chgMainWinLoc('admin/user/{$x.forlife}')">
         {icon name=wrench title="administrer user"}</a>
       {/if}
index 25a4b1b..ced185a 100644 (file)
@@ -22,7 +22,7 @@
 
 {include file=search/quick.form.tpl show_js=1}
 
-{if $smarty.session.perms->hasFlag('user')}
+{if hasPerm('user')}
 <h1>Voir le trombi d'une promotion</h1>
 
 <div id="message" style="position:absolute;"></div><br />
@@ -91,7 +91,7 @@ Il est conseillé d'omettre les particules car il est possible que celles-ci ne
 notre base de données.
 </p>
 
-{if $smarty.session.perms->hasFlag('user')}
+{if hasPerm('user')}
 <h2>Raccourcis...</h2>
 <p>
   Un certain nombre de raccourcis permettent d'accéder plus rapidement au contenu du site :
@@ -99,7 +99,7 @@ notre base de données.
     <li><code>fiche:prenom.nom.promo</code> ouvre la fiche du camarade indiquée&nbsp;;</li>
     <li><code>ref:prenom.nom.promo</code> ouvre la fiche référent du camarade indiquée&nbsp;;</li>
     <li><code>doc:phrase</code> recherche <em>phrase</em> dans la documentation du site&nbsp;;</li>
-    {if $smarty.session.perms->hasFlag('admin')}
+    {if hasPerm('admin')}
     <li><code>admin:prenom.nom.promo</code> ouvre la fiche d'administration du camarade indiquée&nbsp;;</li>
     <li><code>ax:prenom.nom.promo</code> ouvre la fiche ax du camarade concerné.</li>
     {/if}
index eef5989..f4ccbcf 100644 (file)
@@ -28,7 +28,7 @@
     <link rel="index"  href="" />
     <link rel="author" href="changelog" />
     <link rel="search" href="search" />
-    {if $smarty.session.perms->hasFlag('user')}
+    {if hasPerm('user')}
     <link rel="search" type="application/opensearchdescription+xml" href="http://www.polytechnique.org/xorg.opensearch.xml" title="Annuaire Polytechnique.org" />
     {/if}
     <link rel="help"   href="Xorg/FAQ" />
index a5e6277..40971ea 100644 (file)
@@ -75,7 +75,7 @@
 <div class="menu_item"><a href="Xorg/NousContacter">Nous contacter</a></div>
 <div class="menu_item"><a href="send_bug" class="popup2">Signaler un bug</a></div>
 
-{if $smarty.session.perms->hasFlag('admin')}
+{if hasPerm('admin')}
 <div class="menu_title">***</div>
 <div class="menu_item"><a href="marketing">Marketing</a></div>
 <div class="menu_item"><a href="admin/">Administration</a></div>
index 2378766..4aa1686 100644 (file)
           {/foreach}
         </td>
         <td class="breadcrumb">
-          {if $asso && ($is_admin || $smarty.session.suid.perms eq 'admin' || $smarty.session.suid.may_update[$asso.id])}
+          {if $asso && ($is_admin || $smarty.session.suid.perms->hasFlag('admin') || $smarty.session.suid.may_update[$asso.id])}
           <div style="float: right">
             <form method="post" action="{$platal->ns}change_rights">
               <div style="display: inline">
                 <small>voir le site en tant que...
                 <select name="right" onchange="this.form.submit()" style="margin: 0; padding: 0">
-                  {if $smarty.session.perms->hasFlag('admin') || $smarty.session.suid.perms->hasFlag('admin')}
-                  <option value="admin" {if $smarty.session.perms->hasFlag('admin')}selected="selected"{/if}>Administrateur</option>
+                  {if hasPerm('admin') || $smarty.session.suid.perms->hasFlag('admin')}
+                  <option value="admin" {if hasPerm('admin')}selected="selected"{/if}>Administrateur</option>
                   {/if}
-                  <option value="anim" {if $is_admin && !$smarty.session.perms->hasFlag('admin')}selected="selected"{/if}>Animateur</option>
+                  <option value="anim" {if $is_admin && !hasPerm('admin')}selected="selected"{/if}>Animateur</option>
                   <option value="member" {if !$is_admin && $is_member}selected="selected"{/if}>Membre</option>
                   <option value="logged" {if !$is_admin && !$is_member}selected="selected"{/if}>Non-membre</option>
                 </select>
               {/if}
             </td>
             <td class="right" style="vertical-align: middle">
-              {if $smarty.session.perms->hasFlag('admin')}
+              {if hasPerm('admin')}
               <a href="admin" title="Administration des groupes">
                 Gérer les groupes
                 {icon name=wrench title="Administration"}