From 908db125b895b963213e75c16d6428d36e866b04 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 22 Sep 2007 22:24:59 +0200 Subject: [PATCH] PlWizard tabs are fully clickable Add hasPerm() and hasPerms() in templates to easily check user permissions Signed-off-by: Florent Bruneau --- ChangeLog | 2 +- classes/platalpage.php | 14 ++++++++++++++ htdocs/css/default.css | 4 ++-- htdocs/css/keynote.css | 4 ++-- htdocs/css/openweb.css | 4 ++-- modules/events.php | 4 ++-- templates/core/plwizard.tpl | 22 +++++++++++++++------- templates/events/index.tpl | 2 +- templates/include/minifiche.tpl | 2 +- templates/include/plview.trombi.tpl | 2 +- templates/include/tips.tpl | 2 +- templates/include/trombi.tpl | 2 +- templates/lists/header_listes.tpl | 4 ++-- templates/newsletter/show.tpl | 2 +- templates/platal/review.tpl | 8 +++++++- templates/profile/profile.tpl | 2 +- templates/search/quick.tpl | 6 +++--- templates/skin/common.header.tpl | 2 +- templates/skin/common.menu.tpl | 2 +- templates/xnet/skin.tpl | 10 +++++----- 20 files changed, 64 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index fdc829b..3c4597b 100644 --- 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: diff --git a/classes/platalpage.php b/classes/platalpage.php index f89f279..42b6fcd 100644 --- a/classes/platalpage.php +++ b/classes/platalpage.php @@ -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) diff --git a/htdocs/css/default.css b/htdocs/css/default.css index 6e6ba22..8fcfbfe 100644 --- a/htdocs/css/default.css +++ b/htdocs/css/default.css @@ -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; } diff --git a/htdocs/css/keynote.css b/htdocs/css/keynote.css index c0519b7..a7ca629 100644 --- a/htdocs/css/keynote.css +++ b/htdocs/css/keynote.css @@ -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; } diff --git a/htdocs/css/openweb.css b/htdocs/css/openweb.css index a1a39e8..950a1fb 100644 --- a/htdocs/css/openweb.css +++ b/htdocs/css/openweb.css @@ -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; } diff --git a/modules/events.php b/modules/events.php index d26c517..fbe8eef 100644 --- a/modules/events.php +++ b/modules/events.php @@ -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); diff --git a/templates/core/plwizard.tpl b/templates/core/plwizard.tpl index 8cc54ee..095765d 100644 --- a/templates/core/plwizard.tpl +++ b/templates/core/plwizard.tpl @@ -57,13 +57,21 @@
{foreach from=$pages item=title key=id} -
- {if $stateless || $id gt $current} - {/if} - {$title} - {if $stateless || $id gt $current}{/if} -
+ {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} + > + {$title} + {/foreach}
diff --git a/templates/events/index.tpl b/templates/events/index.tpl index 7b02de3..4c2e269 100644 --- a/templates/events/index.tpl +++ b/templates/events/index.tpl @@ -174,7 +174,7 @@ Bienvenue {$smarty.session.prenom}{if $birthday} {/if}
- {if $smarty.session.perms->hasFlag('admin')} + {if hasPerm('admin')} {icon name=page_edit title="Editer cet article"} {/if} {icon name=cross title="Cacher cet article"} diff --git a/templates/include/minifiche.tpl b/templates/include/minifiche.tpl index 6149550..c2ae7a0 100644 --- a/templates/include/minifiche.tpl +++ b/templates/include/minifiche.tpl @@ -73,7 +73,7 @@ {/if} {/if} - {if $smarty.session.perms->hasFlag('admin')} + {if hasPerm('admin')} [{if !$c.wasinscrit && !$c.dcd} {* *}{icon name=email title="marketter user"} diff --git a/templates/include/plview.trombi.tpl b/templates/include/plview.trombi.tpl index d58f3c1..97f44c1 100644 --- a/templates/include/plview.trombi.tpl +++ b/templates/include/plview.trombi.tpl @@ -35,7 +35,7 @@  [ PHOTO ] - {if $trombi_with_admin && $smarty.session.perms->hasFlag('admin')} + {if $trombi_with_admin && hasPerm('admin')} {icon name=wrench title="[admin]"} {/if}
diff --git a/templates/include/tips.tpl b/templates/include/tips.tpl index cba139f..d274923 100644 --- a/templates/include/tips.tpl +++ b/templates/include/tips.tpl @@ -26,7 +26,7 @@ {/if} {icon name=lightbulb} {if !$tips.special} Astuce : {$tips.titre} - {if $smarty.session.perms->hasFlag('admin') && !$tips.special && !$nochange} + {if hasPerm('admin') && !$tips.special && !$nochange} {icon name="page_edit" title="Editer"} {/if} {else} diff --git a/templates/include/trombi.tpl b/templates/include/trombi.tpl index fcea502..91a0c3e 100644 --- a/templates/include/trombi.tpl +++ b/templates/include/trombi.tpl @@ -31,7 +31,7 @@  [ PHOTO ] - {if $trombi_admin && $smarty.session.perms->hasFlag('admin') && !$urlmainsite} + {if $trombi_admin && hasPerm('admin') && !$urlmainsite} {icon name=wrench title="[admin]"} {/if} diff --git a/templates/lists/header_listes.tpl b/templates/lists/header_listes.tpl index c50398a..d5b4e2d 100644 --- a/templates/lists/header_listes.tpl +++ b/templates/lists/header_listes.tpl @@ -46,7 +46,7 @@ {/if} - {if $details.own || $smarty.session.perms->hasFlagCombination('admin,groupadmin')} + {if $details.own || hasPerms('admin,groupadmin')} Administrer la liste : @@ -73,7 +73,7 @@ {/if} - {if $smarty.session.perms->hasFlagCombination('admin,groupadmin')} + {if hasPerms('admin,groupadmin')} Administrer (avancé) : diff --git a/templates/newsletter/show.tpl b/templates/newsletter/show.tpl index 71f2160..3d5fcc5 100644 --- a/templates/newsletter/show.tpl +++ b/templates/newsletter/show.tpl @@ -30,7 +30,7 @@ {else} [version Texte] {/if} - {if $smarty.session.perms->hasFlag('admin')} + {if hasPerm('admin')} [Editer] {/if}

diff --git a/templates/platal/review.tpl b/templates/platal/review.tpl index daddfd6..1b91280 100644 --- a/templates/platal/review.tpl +++ b/templates/platal/review.tpl @@ -20,9 +20,15 @@ {* *} {**************************************************************************} + {if $cacheExists} {include wiki=$article} -{elseif $smarty.session.perms->hasFlag('admin')} +{if hasPerm('admin')} + +{/if} +{elseif hasPerm('admin')} La page wiki associée n'existe pas. Il faut l'éditer. {else}

La page n'existe pas

diff --git a/templates/profile/profile.tpl b/templates/profile/profile.tpl index 4b73b91..0bd7392 100644 --- a/templates/profile/profile.tpl +++ b/templates/profile/profile.tpl @@ -69,7 +69,7 @@ function chgMainWinLoc(strPage) {icon name=cross title="Retirer de mes contacts"} {/if} - {if $smarty.session.perms->hasFlag('admin')} + {if hasPerm('admin')} {icon name=wrench title="administrer user"} {/if} diff --git a/templates/search/quick.tpl b/templates/search/quick.tpl index 25a4b1b..ced185a 100644 --- a/templates/search/quick.tpl +++ b/templates/search/quick.tpl @@ -22,7 +22,7 @@ {include file=search/quick.form.tpl show_js=1} -{if $smarty.session.perms->hasFlag('user')} +{if hasPerm('user')}

Voir le trombi d'une promotion


@@ -91,7 +91,7 @@ Il est conseillé d'omettre les particules car il est possible que celles-ci ne notre base de données.

-{if $smarty.session.perms->hasFlag('user')} +{if hasPerm('user')}

Raccourcis...

Un certain nombre de raccourcis permettent d'accéder plus rapidement au contenu du site : @@ -99,7 +99,7 @@ notre base de données.

  • fiche:prenom.nom.promo ouvre la fiche du camarade indiquée ;
  • ref:prenom.nom.promo ouvre la fiche référent du camarade indiquée ;
  • doc:phrase recherche phrase dans la documentation du site ;
  • - {if $smarty.session.perms->hasFlag('admin')} + {if hasPerm('admin')}
  • admin:prenom.nom.promo ouvre la fiche d'administration du camarade indiquée ;
  • ax:prenom.nom.promo ouvre la fiche ax du camarade concerné.
  • {/if} diff --git a/templates/skin/common.header.tpl b/templates/skin/common.header.tpl index eef5989..f4ccbcf 100644 --- a/templates/skin/common.header.tpl +++ b/templates/skin/common.header.tpl @@ -28,7 +28,7 @@ - {if $smarty.session.perms->hasFlag('user')} + {if hasPerm('user')} {/if} diff --git a/templates/skin/common.menu.tpl b/templates/skin/common.menu.tpl index a5e6277..40971ea 100644 --- a/templates/skin/common.menu.tpl +++ b/templates/skin/common.menu.tpl @@ -75,7 +75,7 @@ -{if $smarty.session.perms->hasFlag('admin')} +{if hasPerm('admin')} diff --git a/templates/xnet/skin.tpl b/templates/xnet/skin.tpl index 2378766..4aa1686 100644 --- a/templates/xnet/skin.tpl +++ b/templates/xnet/skin.tpl @@ -136,16 +136,16 @@ {/foreach} - {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])}
    voir le site en tant que... @@ -225,7 +225,7 @@ {/if} - {if $smarty.session.perms->hasFlag('admin')} + {if hasPerm('admin')} Gérer les groupes {icon name=wrench title="Administration"} -- 2.1.4