Permalink
Browse files

user is managed in Module::run, now called in all child classes

  • Loading branch information...
1 parent 76d7b43 commit ae70660231baeacd3774a72d6f4a320c42a6af04 @minirop committed Jan 23, 2012
View
@@ -66,6 +66,7 @@
'IN_ACCOUNT' => false,
'IN_POST' => false,
'IN_HELP' => false,
+ 'IN_ADMIN' => false,
));
// lang
View
@@ -32,6 +32,7 @@
$lang['register-title'] = 'Registration';
$lang['register-button'] = 'Register';
$lang['edit-image'] = 'Edit this image';
+$lang['admin'] = 'Admin';
$lang[''] = '';
$lang[''] = '';
?>
View
@@ -32,7 +32,7 @@
$lang['register-title'] = 'Inscription';
$lang['register-button'] = 'S\'incrire';
$lang['edit-image'] = 'Editer cette image';
-$lang[''] = '';
+$lang['admin'] = 'Admin';
$lang[''] = '';
$lang[''] = '';
$lang[''] = '';
@@ -3,6 +3,8 @@ class Account extends Module
{
public function run($data)
{
+ parent::run($data);
+
$this->tpl->set('IN_ACCOUNT', true);
$this->tpl->set('USER', $this->user);
@@ -13,6 +13,8 @@ public function __construct()
public function run($data)
{
+ parent::run($data);
+
$this->tpl->set('SUB_TITLE', 'ERROR');
$this->tpl->set('ERR_MSG', (count($data) && isset($this->messages[$data[0]]) ? $this->messages[$data[0]] : $this->messages['00']));
$this->tpl->set('MODULE', 'error.html');
@@ -3,6 +3,8 @@ class Help extends Module
{
public function run($data)
{
+ parent::run($data);
+
$this->tpl->set('IN_HELP', true);
$this->tpl->set('MODULE', 'help.html');
}
@@ -3,6 +3,8 @@ class Image extends Module
{
public function run($data)
{
+ parent::run($data);
+
if(!count($data) || !$this->user)
{
header('location:'.$this->config['root_path'].'/account');
@@ -3,6 +3,8 @@ class Index extends Module
{
public function run($data)
{
+ parent::run($data);
+
$req = $this->db->query('SELECT COUNT(*) FROM `images`');
$total_images = $req->fetchColumn(0);
$req->closeCursor();
@@ -3,6 +3,8 @@ class Mail extends Module
{
public function run($data)
{
+ parent::run($data);
+
if(!count($data))
{
header('location:'.$this->config['root_path'].'/post');
@@ -1,9 +1,19 @@
<?php
-abstract class Module
+class Module
{
public $tpl = null;
public $db = null;
- abstract public function run($data);
+ public function run($data)
+ {
+ if($this->user)
+ {
+ $this->tpl->set('IS_CONNECTED', 1);
+ if(!empty($this->user['isModo']))
+ $this->tpl->set('IS_MODO', 1);
+ if(!empty($this->user['isAdmin']))
+ $this->tpl->set('IS_ADMIN', 1);
+ }
+ }
}
?>
@@ -3,14 +3,7 @@ class Post extends Module
{
public function run($data)
{
- if($this->user)
- {
- $this->tpl->set('IS_CONNECTED', 1);
- if(!empty($this->user['isModo']))
- $this->tpl->set('IS_MODO', 1);
- if(!empty($this->user['isAdmin']))
- $this->tpl->set('IS_ADMIN', 1);
- }
+ parent::run($data);
$this->tpl->set('IN_POST', true);
$this->tpl->set('SEARCH', '');
@@ -3,6 +3,8 @@ class Profile extends Module
{
public function run($data)
{
+ parent::run($data);
+
$error = '';
if(count($data))
{
@@ -3,6 +3,8 @@ class Search extends Module
{
public function run($data)
{
+ parent::run($data);
+
if(!empty($_POST['keyword']))
{
$search = str_replace(' ', '+', $_POST['keyword']);
View
@@ -26,6 +26,9 @@
<span<if cond="{$IN_ACCOUNT} == true"> class="active"</if>><a href="{ROOT_PATH}/account" title="">{LANG['my-account']}</a></span>
<span<if cond="{$IN_POST} == true"> class="active"</if>><a href="{ROOT_PATH}/post" title="">{LANG['posts']}</a></span>
<span<if cond="{$IN_HELP} == true"> class="active"</if>><a href="{ROOT_PATH}/help" title="">{LANG['help']}</a></span>
+ <if cond="!empty({$IS_ADMIN})">
+ <span<if cond="{$IN_ADMIN} == true"> class="active"</if>><a href="{ROOT_PATH}/admin" title="">{LANG['admin']}</a></span>
+ </if>
</td>
</tr>
<tr>

0 comments on commit ae70660

Please sign in to comment.