Skip to main content

gmn caranya buat menu untuk byk user (session)

3 replies [Last post]
mumet sm CI... tolong di reply dong pertanyaan q...
vick88's picture
User offline. Last seen 6 weeks 17 min ago. Offline
Joined: 02/06/2011

tmn2 master CI ...

mnt tlg dong, q binggung gmn cara membuat menu dengan cara navigasi untuk multi user

ini code menu 1 user :

mksh byk bantuanya...
NB : buat TA saya nih...

now... what????
zawaruddin's picture
User offline. Last seen 1 week 3 days ago. Offline
Joined: 02/28/2011
bisa dibilang sama dengan

bisa dibilang sama dengan yang kamu maksud, cuma ide menu dari saya, menunya ditaruh dalam database, sehingga saat user telah login, aplikasi sudah menentukan menu mana yang harus ditampilkan untuk jenis user tertentu...
misal
User dosen dengan kode D1, hanya bisa mengakses menu A, B, C, D
User Mahasiswa dg kode M1, hanya bisa mengakses menu C, D, E, F

*klo kurang jelas, ntar aq kasih contohnya....

------------------------------------------------------------
Go..Go..Go.. CodeIgniter

Visit My Blog @ zawaruddin.blogspot.com

now... what????
zawaruddin's picture
User offline. Last seen 1 week 3 days ago. Offline
Joined: 02/28/2011
kalau menurut saya menu-menu

kalau menurut saya menu-menu untuk tiap user lebih baik ditaruh datal database, sehingga saat di view hanya tinggal manggil (tentunya lewat controller dulu)...

contoh database nya...

/*==============================================================*/
/* DBMS name:      PostgreSQL                                  */
/* Created on:     08/03/2011 14:55:17                          */
/*==============================================================*/
drop index MENU_PK;
drop table MENU;
drop index USER_JOB_FK;
drop index USER_ACCOUNT_PK;
drop table USER_ACCOUNT;
drop index RELATIONSHIP_3_FK;
drop index HAD_USER_FK;
drop index USER_MENU_PK;
drop table USER_MENU;
drop index USER_POSITION_PK;
drop table USER_POSITION;
*==============================================================*/
/* Table: MENU                                                  */
/*==============================================================*/
create table MENU (
   NO_MENU              INT4                 not null,
   NM_MENU              VARCHAR(100)         null,
   PARENT_MENU          INT4                 null,
   LINK_MENU            VARCHAR(255)         null,
   DESC_MENU            VARCHAR(255)         null,
   IS_PARENT            BOOL                 null,
   constraint PK_MENU primary key (NO_MENU)
);
/*==============================================================*/
/* Index: MENU_PK                                               */
/*==============================================================*/
create unique index MENU_PK on MENU (
NO_MENU
);
/*==============================================================*/
/* Table: USER_ACCOUNT                                          */
/*==============================================================*/
create table USER_ACCOUNT (
   USERNAME             VARCHAR(20)          not null,
   CD_POSITION          INT2                 not null,
   NM_USER              VARCHAR(50)          null,
   USER_PASSWORD        VARCHAR(32)          null,
   STATUS_USER          BOOL                 null,
   constraint PK_USER_ACCOUNT primary key (USERNAME)
);
 
/*==============================================================*/
/* Index: USER_ACCOUNT_PK                                       */
/*==============================================================*/
create unique index USER_ACCOUNT_PK on USER_ACCOUNT (
USERNAME
);
 
/*==============================================================*/
/* Index: USER_JOB_FK                                           */
/*==============================================================*/
create  index USER_JOB_FK on USER_ACCOUNT (
CD_POSITION
);
 
/*==============================================================*/
/* Table: USER_MENU                                             */
/*==============================================================*/
create table USER_MENU (
   NO_MENU              INT4                 not null,
   CD_POSITION          INT2                 not null,
   constraint PK_USER_MENU primary key (NO_MENU, CD_POSITION)
);
 
/*==============================================================*/
/* Index: USER_MENU_PK                                          */
/*==============================================================*/
create unique index USER_MENU_PK on USER_MENU (
NO_MENU,
CD_POSITION
);
 
/*==============================================================*/
/* Index: HAD_USER_FK                                           */
/*==============================================================*/
create  index HAD_USER_FK on USER_MENU (
NO_MENU
);
 
/*==============================================================*/
/* Index: RELATIONSHIP_3_FK                                     */
/*==============================================================*/
create  index RELATIONSHIP_3_FK on USER_MENU (
CD_POSITION
);
 
/*==============================================================*/
/* Table: USER_POSITION                                         */
/*==============================================================*/
create table USER_POSITION (
   CD_POSITION          INT2                 not null,
   NM_POSITION          VARCHAR(50)          null,
   constraint PK_USER_POSITION primary key (CD_POSITION)
);
 
/*==============================================================*/
/* Index: USER_POSITION_PK                                      */
/*==============================================================*/
create unique index USER_POSITION_PK on USER_POSITION (
CD_POSITION
);
 
alter table USER_ACCOUNT
   add constraint FK_USER_ACC_USER_JOB_USER_POS foreign key (CD_POSITION)
      references USER_POSITION (CD_POSITION)
      on delete restrict on update restrict;
 
alter table USER_MENU
   add constraint FK_USER_MEN_HAD_USER_MENU foreign key (NO_MENU)
      references MENU (NO_MENU)
      on delete restrict on update restrict;
 
alter table USER_MENU
   add constraint FK_USER_MEN_RELATIONS_USER_POS foreign key (CD_POSITION)
      references USER_POSITION (CD_POSITION)
      on delete restrict on update restrict;

pada tabel menu :
contoh isi tabel menu

1 |'Lihat SKS'  |0|''|'Parent Menu untuk Lihat SKS'|'t'|
11|'Semester 1' |1|'view_sks/1'|'View SKS smt 1'|'f'|
12|'Semester 2' |1|'view_sks/2'|'View SKS smt 2'|'f'|
2 |'Lihat Kelas'|0|''|'Parent Menu untuk Lihat Kelas'|'t'|
21|'Kelas A'    |2|'view_kelas/a'|'View Kelas B'|'f'|
22|'Kelas B'    |2|'view_kelas/b'|'View Kelas B'|'f'|

pada tabel user_account :
contoh isi tabel user_account
'zawa'|0|'Zawaruddin'|''|'t'|
'devi'|1|'Devi Miraj'|'yyyyyy'|'t'|
'Muna'|2|'Maemunah'|'zzzz'|'t'|

pada tabel user_position :
contoh isi tabel user_position

0|'Administrator'|
1|'Dosen'|
2|'Mahasiswa'|

jadi untuk menu dapat digolongkan bedasarkan user_positionnya...
isi pada tabel user_menu:

1 |0|
11|0|
12|0|
2 |0|
21|0|
22|0|
1 |2|
11|2|
12|2|
2 |1|
21|1|
22|1|

jadi pas coding d view g usah memilih menu lagi user untuk dosen/mahasiswa/siapapun lagi, cukup panggil user_menu yg sesuai dengan posisi user yg login....

***kalo kurang jelas ntar sambung lagi... ^^

------------------------------------------------------------
Go..Go..Go.. CodeIgniter

Visit My Blog @ zawaruddin.blogspot.com

mumet sm CI... tolong di reply dong pertanyaan q...
vick88's picture
User offline. Last seen 6 weeks 17 min ago. Offline
Joined: 02/06/2011
to zawarrudin

saya semakin binggung

krn saya pemula, jd cara berfikirnya masih simple sekali

ini struktur table user :

(id_user int(1) PRIMARY KEY,
username varchar(32),
password varchar(32),
status varchar(20) NO)

ini record-nya user :

(1 admin admin admin
2 student student D3
3 student student D4
4 dosen dosen Penguji
5 dosen dosen Pembimbing)

setiap user memiliki page tertentu, dgn menu yg berbeda2...

sy sudah membuat VIEW NAVIGASI seperti ini

<ul id="menu_tab">	
	<?php if($status=="admin") { ?>
		<li id="tab_mahasiswa"><?php echo anchor('mahasiswa', 'Daftar Mahasiswa TA');?></li>
		<li id="tab_histori"><?php echo anchor('histori', 'Histori');?></li>
		<li id="tab_dosen"><?php echo anchor('dosen', 'Dosen');?></li>
		<li id="tab_absen"><?php echo anchor('absen', 'Absen');?></li>
		<li id="tab_rekap"><?php echo anchor('rekap', 'Rekap');?></li>
		<li id="tab_kelas"><?php echo anchor('cari', 'Cari');?></li>
		<li id="tab_semester"><?php echo anchor('jadwal', 'Jadwal');?></li>
		<li id="tab_kelas"><?php echo anchor('kelas', 'Kelas');?></li>
 
	<?php } else if($status=="D3") { ?>
		<li id="tab_mahasiswa"><?php echo anchor('mahasiswa', 'Daftar Mahasiswa TA');?></li>
		<li id="tab_histori"><?php echo anchor('histori', 'Histori');?></li>
 
	<?php }  ?>
		<li id="tab_logout"><?php echo anchor('login/process_logout', 'Logout', array('onclick' => "return confirm('Anda yakin akan logout?')"));?></li>
</ul>

maaf klo membingungkan...

Premium Drupal Themes by Adaptivethemes