Revize 86
Přidáno uživatelem Tomáš Dulík před více než 16 roky(ů)
freenetis/trunk/kohana/application/libraries/MY_Controller.php | ||
---|---|---|
<?php
|
||
|
||
|
||
class Controller extends Controller_Core {
|
||
public $gacl_class;
|
||
private $myMenu;
|
||
public $arr;
|
||
|
||
|
||
public function __construct(){
|
||
|
||
|
||
parent::__construct();
|
||
//authentication goes here for example
|
||
|
||
if (!$this->session->get('user_id', 0) && url_lang::current()!='login' && url_lang::current()!='registration' && url_lang::current()!='accounts/parse_ebank_account')
|
||
if (!$this->session->get('user_id', 0) && url_lang::current()!='login' && url_lang::current()!='registration' && url_lang::current()!='accounts/parse_ebank_account')
|
||
{
|
||
// Not logged in - redirect to login page
|
||
$this->session->set_flash('err_message', url_lang::lang('texts.Must be logged in'));
|
||
... | ... | |
}
|
||
require_once(APPPATH.'vendors/phpgacl/gacl.class.php');
|
||
$this->gacl_class = new gacl();
|
||
|
||
|
||
}
|
||
|
||
/* public function do_something(){
|
||
//method available in all controllers
|
||
}*/
|
||
|
||
public function render_menu ($active = null)
|
||
|
||
public function render_menu ($active = null)
|
||
{
|
||
|
||
|
||
//verze 2
|
||
/*$this->myMenu = '';
|
||
$model = new Menu_Model;
|
||
... | ... | |
$arr[$i]['id'] = $menu->id;
|
||
$arr[$i]['master_id'] = $menu->master_id;
|
||
$i++;
|
||
}
|
||
}
|
||
$myMenu = $this->create_menu($arr,0);
|
||
return str_replace('<ul></ul>', '', $myMenu);*/
|
||
|
||
|
||
if ($this->session->get('member_login')==$this->session->get('username')) $url = 'members/show/'.$this->session->get('member_id');
|
||
else $url = 'users/show/'.$this->session->get('user_id');
|
||
|
||
|
||
$myMenu = '';
|
||
$myMenu .= '<ul>';
|
||
|
||
$myMenu .= ' <li class="account"><h2>'.url_lang::lang('texts.My account').'</h2>
|
||
|
||
$myMenu .= ' <li class="account"><h2>'.url_lang::lang('texts.My profile').'</h2>
|
||
<ul>
|
||
<li>'.html::anchor(url_lang::base().$url, url_lang::lang('texts.My account')).'</li>';
|
||
|
||
<li>'.html::anchor(url_lang::base().$url, url_lang::lang('texts.My profile')).'</li>';
|
||
|
||
if ($this->gacl_class->acl_check('menu', 'my_users', 'all', $_SESSION['username'])) $myMenu .= '<li>'.html::anchor(url_lang::base().'members/users/'.$this->session->get('member_id'), url_lang::lang('texts.My users')).'</li>';
|
||
|
||
if ($this->gacl_class->acl_check('menu', 'my_transfers', 'all', $_SESSION['username'])) $myMenu .= '<li>'.html::anchor(url_lang::base().'accounts/transfers/'.$this->session->get('member_id'), url_lang::lang('texts.My transfers')).'</li>';
|
||
|
||
if ($this->gacl_class->acl_check('menu', 'my_transfers', 'all', $_SESSION['username'])) $myMenu .= '<li>'.html::anchor(url_lang::base().'accounts/transfers/'.$this->session->get('member_id'), url_lang::lang('texts.My transfers')).'</li>';
|
||
if ($this->gacl_class->acl_check('menu', 'my_devices', 'all', $_SESSION['username'])) $myMenu .= ' <li>'.html::anchor(url_lang::base().'devices/show_my', url_lang::lang('texts.My devices')).'</li>';
|
||
$myMenu .= ' </ul>
|
||
</li>';
|
||
$acc_menu = '';
|
||
if ($this->gacl_class->acl_check('menu', 'unconfirmed_works', 'all', $_SESSION['username'])) $acc_menu = '<li>'.html::anchor(url_lang::base().'works/uncorfirmed/', url_lang::lang('texts.Unconfirmed works')).'</li>';
|
||
|
||
if ($this->gacl_class->acl_check('menu', 'unconfirmed_works', 'all', $_SESSION['username'])) $acc_menu = '<li>'.html::anchor(url_lang::base().'works/uncorfirmed/', url_lang::lang('texts.Unconfirmed works')).'</li>';
|
||
|
||
if ($this->gacl_class->acl_check('menu', 'unidentified_transfers', 'all', $_SESSION['username'])) $acc_menu .= '<li style="padding-bottom:8px;">'.html::anchor(url_lang::base().'accounts/unidentified_transfers/', url_lang::lang('texts.Unidentified transfers')).'</li>';
|
||
|
||
|
||
if ($this->gacl_class->acl_check('menu', 'accounts', 'all', $_SESSION['username'])) $acc_menu .= '<li>'.html::anchor(url_lang::base().'accounts/main_accounts/master', url_lang::lang('texts.Bank account')).'</li>
|
||
<li>'.html::anchor(url_lang::base().'accounts/main_accounts/infrastructure', url_lang::lang('texts.Infrastructure account')).'</li>
|
||
<li>'.html::anchor(url_lang::base().'accounts/main_accounts/operating', url_lang::lang('texts.Operating account')).'</li>';
|
||
|
||
|
||
if ($acc_menu != '') $myMenu .= '<li class="transfer"><h2>'.url_lang::lang('texts.Transfers').'</h2>
|
||
<ul>
|
||
<ul>
|
||
'.$acc_menu.'
|
||
</ul>
|
||
</li>';
|
||
|
||
|
||
if ($this->gacl_class->acl_check('menu', 'users_members', 'all', $_SESSION['username'])) $myMenu .= '<li class="users"><h2>'.url_lang::lang('texts.Users').'</h2>
|
||
<ul>
|
||
<li>'.html::anchor(url_lang::base().'members', url_lang::lang('texts.Members')).'</li>
|
||
... | ... | |
</ul>
|
||
</li>
|
||
';
|
||
|
||
|
||
$myMenu .= '</ul>';
|
||
|
||
|
||
return $myMenu;
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|
||
public function create_menu($arr,$master)
|
||
{
|
||
|
||
|
||
$this->myMenu .= '<ul>';
|
||
|
||
|
||
foreach ($arr as $ind=>$val) {
|
||
//echo $ind."<br>";
|
||
if ($val['master_id'] == $master) {
|
||
... | ... | |
}
|
||
}
|
||
$this->myMenu .= '</ul>';
|
||
|
||
|
||
return $this->myMenu;
|
||
}
|
||
|
||
|
||
|
||
|
||
public function error($message = null)
|
||
{
|
||
if (is_numeric($message))
|
||
... | ... | |
case 1:
|
||
$message = url_lang::lang('texts.You dont have the permissions.');
|
||
break;
|
||
|
||
|
||
}
|
||
}
|
||
if (!isset($message)) $message = url_lang::lang('texts.ID is required.');
|
||
|
||
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
$view->header->title = url_lang::lang('texts.Error'.' - '.$message);
|
||
$view->header->title = url_lang::lang('texts.Error'.' - '.$message);
|
||
$view->header->menu = Controller::render_menu();
|
||
|
||
$view->content = new View('errors');
|
||
|
||
$view->content = new View('errors');
|
||
$view->content->required = $message;
|
||
|
||
$view->footer = new View('base/footer');
|
||
|
||
|
||
$view->footer = new View('base/footer');
|
||
|
||
$view->render(TRUE);
|
||
exit;
|
||
}
|
||
... | ... | |
$group_id = 33;
|
||
break;
|
||
}
|
||
|
||
|
||
|
||
|
||
$group_arr = array();
|
||
/*
|
||
$aro = array();
|
||
... | ... | |
$aro['section_value'] = 'all';
|
||
*/
|
||
$group_arr['group_id'] = $group_id;
|
||
|
||
|
||
if ($is_edit)
|
||
{
|
||
// editation of phpgacl ARO
|
||
// $aro_data->insert_aro($aro,$user_id);
|
||
|
||
|
||
$aro_group_data->insert_data($group_arr, $user_id);
|
||
}
|
||
else
|
||
... | ... | |
$aro_group_data->insert_data($group_arr);
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
?>
|
Také k dispozici: Unified diff
V souboru MY_Controller.php nahrazen řetězec "My account" řetězcem "My profile", slovo "account" se totiž plete s účetním účtem.