これが私がやろうとしていることです。左側のメニューをグループ ベースにしたい。グループにメニューを表示する権限を与えた場合、そのグループに表示されるはずです。
質問の詳細に進む前に。これまでに行ったことと、この特定のメニュー グループのアクセス許可をどこに適用しているかを示したいと思います。
My_Controller.php
コア フォルダーで名前が付けられたベース コントローラーは次のとおりです。
私のMain
コントローラーは から拡張されましたMy_Controller
。
これがMy_Controller
コーディングです。
<?php
/**
* Created by JetBrains PhpStorm.
* User: SBPS
* Date: 3/13/13
* Time: 4:55 PM
* To change this template use File | Settings | File Templates.
*/
class My_Controller extends CI_Controller{
function __construct(){
parent::__construct();
}
public function UserGroups(){
$UserID=1;
$this->load->model('ui_components/Left_menu_cpanel');
$Groups=$this->Left_menu_cpanel->get_user_groups($UserID);
return $Groups;
}
}
これが私のMain
コントローラーです。
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Main extends My_Controller {
/*
* Main Controller
* Designed By: Kifayat Ullah
* Purpose: To work as a main Control Panel for the Authenticated users
*/
public function index() {
if(!$this->session->userdata('UserID')
|| $this->session->userdata('UserID')<=0){
redirect('user_management/login_form');
}// end of session check
// Prepare the LeftHandSide Menu Object and Send it to the View for Display
$this->load->model('ui_components/Left_menu_cpanel');
$UserGroups=$this->UserGroups();
// retrive menu List object
// Pass the name of the view that you want to load
$data['main_container']='tamplet_includes/tamplet_main_container_tags';
$data['UserGroups']=$UserGroups;
//$data['UserGroups']=$this->UserGroups();
$this->load->view('SystemView',$data);
//var_dump($UserGroups);
}
function UserAdditionForm(){
echo 'hello';
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
今度はモデルの番です。
名前付きのベース モデルはMy_Model.php
コア フォルダーにあります。Myleft_menu_cpanel
は から拡張されていMy_Model.php
ます。
My_Model.php
ベース モデル ファイル:
<?php
/**
* Created by JetBrains PhpStorm.
* User: SBPS
* Date: 3/19/13
* Time: 3:13 PM
* To change this template use File | Settings | File Templates.
*/
class My_Model extends CI_Model{
function __construct(){
parent::__construct();
}
public function get_user_groups($UserID){
//$UserID=1; // We will Update this UserID Later
$this->load->helper('security');
$this->db->select('*');
$this->db->from('sys_user_accounts');
$this->db->join('sys_user_groups_memberships', 'sys_user_groups_memberships.UserID = sys_user_accounts.UserID', 'INNER');
$this->db->where('sys_user_accounts.UserID', $UserID);
$this->db->join('sys_user_groups', 'sys_user_groups.GroupID = sys_user_groups_memberships.GroupID', 'INNER');
$query = $this->db->get();
return $query->result(); // return all forms list
}
}
left_menu_cpanel.php
モデルファイル:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Left_menu_cpanel extends My_Model {
function __construct()
{
parent::__construct();
}
// This function returns true if a user authenticaton is successfull
public function get_left_menu_items($GroupID){
//$GroupID=1; // We need update this to a Group Array from the users permissions list
$this->load->helper('security');
$this->db->distinct();
$this->db->select('*');
$this->db->from('sys_group_roles_forms_view');
$this->db->where('GroupID', $GroupID);
$query = $this->db->get();
return $query->result(); // return all forms list
}// end of authenticate function
}//end of class
/* End of file left_menu_cpanel.php.php */
/* Location: ./application/models/user_management/left_menu_cpanel.php.php */
?>
マイテーブルの構造sys_group_roles_forms_view
じぶんのsys_user_groups
ユーザーは複数のグループに所属でき、グループは複数のユーザーを持つことができます。
今、私はすべての詳細を投稿したと思うので、
したがって、私の質問は、特定のタブを表示するグループに許可を与えた場合、その許可が2つ以上のグループに与えられた場合、タブのみが1回表示されるはずです。
しかし、ユーザーは 3 つの異なるグループに属しているため、この理由でタブを 3 回繰り返しています。しかし、私はそれが一度だけ欲しいです。
タブとは、左側のメニューが 3 回繰り返されることを意味します。
私は解決策をネットで検索しようとしましたが、明確な機能の解決策を得ました。しかし、私が試したようにその機能は機能していません。
その機能が機能しない理由を理解させてください。私のシナリオで機能する場合、その機能を適用する方法は??