Yii Framework Forum: Manajemen User Sederhana - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Manajemen User Sederhana Rate Topic: -----

#1 User is offline   M Hermansyah 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 25-August 13

Posted 09 February 2014 - 01:32 AM

Buat agan-agan sesama new comer Yii,
Sekarang saatnya maju dari static-user demo/demo, admin/admin ke dynamic berbasis database (mis MySQL) menggunakan module yii-user (lihat atau lebih baru sih mending ke).

Gak perlu buat tabel mysql, karena sudah disiapkan schema.mysql.sql di file yg akan didownload. Tinggal diimport saja.

Langkah step by step (yang sdh berhasil saya implementasi di web, silahkan dicoba lagsung):
1. download source di.
2. ekstrak dan letakkan semua file satu folder /modules ke direktori /protected
3. edit /protected/config/main.php sbb:
..
        'import'=>array(
		...,
                ....,
                'application.modules.user.models.*',
                'application.modules.user.components.*',
	),
        'modules'=>array(
		'user' => array(
                            'tableUsers' => 'tbl_users',
                            'tableProfiles' => 'tbl_profiles',
                            'tableProfileFields' => 'tbl_profiles_fields',
                            ),
                  // uncomment the following to enable the Gii tool
                   /*
                    'gii'=>array(
                        'generatorPaths' => array('bootstrap.gii'),
			 'class'=>'system.gii.GiiModule',
			 'password'=>$ini_array['system']['Password'],
			// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
             		),
                   */
         	),
        // application components
	'components'=>array(
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
                        'loginUrl' => array('/user/login'),
		),
...

4. buka aplikasi mysql (mis. phpmyadmin), lalu Import utk buat tabel2 yg diperlukan, arahkan ke /protected/modules/user/data dan pilih schema.mysql lalu GO.
5. Terakhir tambahkan (bisa juga disesuikan dg existing layout Anda) /protected/views/layouts/main.php:
..
array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->profileUrl, 'label'=>Yii::app()->getModule('user')->t("Profile"), 'visible'=>!Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->logoutUrl, 'label'=>Yii::app()->getModule('user')->t("Logout").' ('.Yii::app()->user->name.')', 'visible'=>!Yii::app()->user->isGuest),
...

6. Kalau mau merubah tampilan view, mis tampilan form Register langsung ke /protected/modules/user/views/user/registration.php. Demikian juga utk controller dan model hrs ke /protected/modules/user/controller dan /protected/modules/user/models, bukan ke protected/controller atau protected/models.
7. That's it..semoga berhasil ya..
8. Testing time..! Klo gak ada error waktu web dpanggil dengan broser, akan muncul link Login. Coba username: demo/demo atau admin/admin. Lalu klik link Profile utk mengubah semua data user.

Catatan: Jika semua sdh jalan, layout yg sdh jalan sebelumnya tidak terganggu. DI web saya menggunakan ekstensi mbmenu dan gak ada pengaruh.

Salam hangat,
mh
--rev.1.10-02
0

#2 User is offline   ulie 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 14-March 14

Posted 24 March 2014 - 10:53 PM

saya barusan nyoba..
tapi ada error seperti ini, knp ya ??
"include(Controller.php): failed to open stream: No such file or directory"
::)
0

#3 User is offline   M Hermansyah 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 25-August 13

Posted 27 March 2014 - 06:03 PM

View Postulie, on 24 March 2014 - 10:53 PM, said:

saya barusan nyoba..
tapi ada error seperti ini, knp ya ??
"include(Controller.php): failed to open stream: No such file or directory"
::)


Boleh tahu lebih detail? Error terjadi waktu buka apa?
Salam,
MH
0

#4 User is offline   reza baim 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 22-April 14

Posted 27 April 2014 - 11:52 PM

itu buat apaan yah gan, saya masih kurang paham baru belajar bgt yii soal.a heh
0

#5 User is offline   Tukijo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 21-May 14
  • Location:Magelang, Jawa Tengah

Posted 22 May 2014 - 09:17 PM

Alhamdulillah saya berhasil. Mkasih untuk sharenya.

Selanjutnya, untuk edit VCM usernya saya lom paham, hehee... :D
(Kebetulan saya coba di Yii Heart, tidak ada trouble). Hanya lom bisa tampil form registrasi. Masih login dengan demo/demo; admin/admin.
Sya coba lagi, tengkiu master...
0

#6 User is offline   M Hermansyah 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 25-August 13

Posted 30 May 2014 - 02:19 AM

View Postreza baim, on 27 April 2014 - 11:52 PM, said:

itu buat apaan yah gan, saya masih kurang paham baru belajar bgt yii soal.a heh

ini utk membuat web kita punya pengelolaan user. user bisa register dan activasi sendiri. kita bisa administrasi user. dst..selamat memulai deh
0

#7 User is offline   M Hermansyah 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 25-August 13

Posted 30 May 2014 - 02:26 AM

View PostTukijo, on 22 May 2014 - 09:17 PM, said:

Selanjutnya, untuk edit VCM usernya saya lom paham, hehee... :D
(Kebetulan saya coba di Yii Heart, tidak ada trouble). Hanya lom bisa tampil form registrasi. Masih login dengan demo/demo; admin/admin.

Klo untuk edit hak user, source code di protected/views/layout/main.php modif jadi gini, sesuaikan dg kebutuhan aja:

<div id="mainMbMenu">

<?php Yii::app()->getModule('user');
if(UserModule::isAdmin()) {
$this->widget('application.extensions.mbmenu.MbMenu',array(
			'items'=>array(
				array('label'=>'Berita', 'url'=>array('/berita/')),
				array('label'=>'Galeri Foto', 'url'=>array('/foto/')),
				array('label'=>'Layar Video', 'url'=>array('/video/')),
				array('label'=>'Aktivitas', 
                                    'items'=>array(
				array('label'=>'Climbing Academy', 'url'=>array('')),
				array('label'=>'Indonesian Climbing Expedition', 'url'=>('https://www.facebook.com/pages/INDONESIA-CLIMBING-EXPEDITION/204331689690387'),'linkOptions'=>array('target'=>'_BLANK')),
				array('label'=>'Pendataan Tebing', 'url'=>('http://katalog.panjattebing.org'),'linkOptions'=>array('target'=>'_BLANK')),
				array('label'=>'Wisata Panjat Tebing', 'url'=>array('')),
				array('label'=>'Konservasi Tebing', 'url'=>array('')),
				array('label'=>'Vertical Rescue Network', 'url'=>array('')),
                                        ),
                                    ),
				array('label'=>'Tentang Kita', 
                                      'items'=>array(
                               // array('label'=>'Organisasi', 'url'=>array('')),
				//array('label'=>'Komisariat', 'url'=>array('')),
                                array('label'=>'Sekretariat', 'url'=>array('/site/page', 'view'=>'address')),
                                array('label'=>'Hubungi Kami', 'url'=>array('/site/contact')),
                                //array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),
//				array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
				          ),
                                    ),
                                array('label'=>'mp-S.T.O.R.E', 
                                    'items'=>array(
				array('label'=>'Alat Panjat', 'url'=>array('/store/alatpanjat')),
				array('label'=>'Pakaian Manjat', 'url'=>array('/store/pakaian')),
				array('label'=>'Aksesori Manjat', 'url'=>array('/store/aksesori')),
                                array('label'=>'Pelatihan Panjat Tebing', 'url'=>array('/store/pelatihan')),
                                array('label'=>'Trip Manjat', 'url'=>array('/store/adventure')),
                                        ),
                                    ),
                               // array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("SignUp?"), 'visible'=>Yii::app()->user->isGuest),
                                array('label'=>'Menu '.Yii::app()->user->name.'', 
                                      'items'=>array(
				array('label'=>'Admin News/Foto/Video',
                                            'items'=>array(
                                                array('label'=>'Daftar N/F/V', 'url'=>array('/news/admin'), 'visible'=>!Yii::app()->user->isGuest),
                                                array('label'=>'Moderate Tulisan', 'url'=>array('/publish/admin'), 'visible'=>!Yii::app()->user->isGuest),
                                                array('label'=>'Input N/F/V', 'url'=>array('/news/create'), 'visible'=>!Yii::app()->user->isGuest),
                                             ),
                                            ),
                                array('label'=>'Admin Store',
                                            'items'=>array(
                                                array('label'=>'Daftar Barang', 'url'=>array('/store/admin'), 'visible'=>!Yii::app()->user->isGuest),
                                                array('label'=>'Display Barang', 'url'=>array('/store/create'), 'visible'=>!Yii::app()->user->isGuest),
                                             ),
                                            ),
                                array('label'=>'Admin Surat',
                                            'items'=>array(
                                                array('label'=>'Daftar Surat', 'url'=>array('/surat/admin'), 'visible'=>!Yii::app()->user->isGuest),
                                                array('label'=>'Buat Surat', 'url'=>array('/surat/create'), 'visible'=>!Yii::app()->user->isGuest),
                                             ),
                                            ),
                                array('label'=>'Admin Keuangan',
                                            'items'=>array(
                                                array('label'=>'Daftar Jurnal', 'url'=>array('/jurnal/admin'), 'visible'=>!Yii::app()->user->isGuest),
                                                array('label'=>'Jurnal Keluar', 'url'=>array('/jurnal/create'), 'visible'=>!Yii::app()->user->isGuest),
                                                array('label'=>'Jurnal Masuk', 'url'=>array('/jurnal/masuk'), 'visible'=>!Yii::app()->user->isGuest),
                                             ),
                                            ),
array('url'=>Yii::app()->getModule('user')->profileUrl, 'label'=>Yii::app()->getModule('user')->t("Profile"), 'visible'=>!Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->logoutUrl, 'label'=>Yii::app()->getModule('user')->t("Logout").' ('.Yii::app()->user->name.')', 'visible'=>!Yii::app()->user->isGuest),
//                                array('label'=>'Logout', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest),
                                       ),
                                ),
			),
		));
}
else
{
 ?>

		<?php $this->widget('application.extensions.mbmenu.MbMenu',array(
			'items'=>array(
				array('label'=>'Berita', 'url'=>array('/berita/')),
				array('label'=>'Galeri Foto', 'url'=>array('/foto/')),
				array('label'=>'Layar Video', 'url'=>array('/video/')),
				array('label'=>'Aktivitas', 
                                    'items'=>array(
				array('label'=>'Climbing Academy', 'url'=>array('')),
				array('label'=>'Indonesian Climbing Expedition', 'url'=>('https://www.facebook.com/pages/INDONESIA-CLIMBING-EXPEDITION/204331689690387'),'linkOptions'=>array('target'=>'_BLANK')),
				array('label'=>'Pendataan Tebing', 'url'=>('http://katalog.panjattebing.org'),'linkOptions'=>array('target'=>'_BLANK')),
				array('label'=>'Wisata Panjat Tebing', 'url'=>array('')),
				array('label'=>'Konservasi Tebing', 'url'=>array('')),
				array('label'=>'Vertical Rescue Network', 'url'=>array('')),
                                        ),
                                    ),
				array('label'=>'Tentang Kita', 
                                      'items'=>array(
                               array('label'=>'Sekretariat', 'url'=>array('/site/page', 'view'=>'address')),
                                array('label'=>'Hubungi Kami', 'url'=>array('/site/contact')),
                                //array('url'=>Yii::app()->getModule('user')->loginUrl, 'label'=>Yii::app()->getModule('user')->t("Login"), 'visible'=>Yii::app()->user->isGuest),
//                                array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest),
//				array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
				          ),
                                    ),
                                array('label'=>'mp-S.T.O.R.E', 
                                    'items'=>array(
				array('label'=>'Alat Panjat', 'url'=>array('/store/alatpanjat')),
				array('label'=>'Pakaian Manjat', 'url'=>array('/store/pakaian')),
				array('label'=>'Aksesori Manjat', 'url'=>array('/store/aksesori')),
                                array('label'=>'Pelatihan Panjat Tebing', 'url'=>array('/store/pelatihan')),
                                array('label'=>'Trip Manjat', 'url'=>array('/store/adventure')),
                                        ),
                                    ),
                                //array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("SignUp?"), 'visible'=>Yii::app()->user->isGuest),
                                array('label'=>'Menu '.Yii::app()->user->name.'', 
                                      'items'=>array(
				array('label'=>'Admin News/Foto/Video',
                                            'items'=>array(
                                                array('label'=>'Daftar N/F/V', 'url'=>array('/news/admin'), 'visible'=>!Yii::app()->user->isGuest),
                                                array('label'=>'Input N/F/V', 'url'=>array('/news/create'), 'visible'=>!Yii::app()->user->isGuest),
                                             ),
                                            ),
array('url'=>Yii::app()->getModule('user')->profileUrl, 'label'=>Yii::app()->getModule('user')->t("Profile"), 'visible'=>!Yii::app()->user->isGuest),
array('url'=>Yii::app()->getModule('user')->logoutUrl, 'label'=>Yii::app()->getModule('user')->t("Logout").' ('.Yii::app()->user->name.')', 'visible'=>!Yii::app()->user->isGuest),
//                                array('label'=>'Logout', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest),
                                       ),
                                ),
			),
		));
} //end-else
 ?>

	</div><!-- mainMbMenu-->

0

#8 User is offline   Tukijo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 21-May 14
  • Location:Magelang, Jawa Tengah

Posted 02 June 2014 - 04:58 AM

Siap. Terima kasih master, saya coba-coba dahulu, jika berhasil saya share.
(Mf jika respon saya lama).
0

#9 User is offline   iph 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 11-November 13

Posted 22 June 2014 - 09:48 PM

waktu akan install melalui url nya, sy dapat warning spt ini "include(Controller.php): failed to open stream: No such file or directory" mohon bantuannya.
0

#10 User is offline   enggok 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 10-June 14

Posted 23 June 2014 - 09:15 PM

master sekalian share database nya biar enak nyoba nya??? plizz
0

#11 User is offline   ikhsanww 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 09-July 14

Posted 09 July 2014 - 08:46 PM

hi agan agan, ane mau nanya nih. Mohon bantuan dan bimbingannya ya. Agak OOT mungkin

ane ngikutin tutorial disini :
http://www.yiiframew...ior#add-comment


tapi begitu dijalanin ada error seperti ini :
Fatal error: Uncaught exception 'CException' with message 'Application base path "C:\xampp\htdocs\tes\protected\config\/main.php" is not a valid directory.' in C:\xampp\htdocs\yii\framework\base\CApplication.php:262 Stack trace: #0 C:\xampp\htdocs\yii\framework\base\CApplication.php(136): CApplication->setBasePath('C:\xampp\htdocs...') #1 C:\xampp\htdocs\yii\framework\YiiBase.php(125): CApplication->__construct('C:\xampp\htdocs...') #2 C:\xampp\htdocs\yii\framework\YiiBase.php(98): YiiBase::createApplication('CWebApplication', 'C:\xampp\htdocs...') #3 C:\xampp\htdocs\tes\index.php(13): YiiBase::createWebApplication('C:\xampp\htdocs...') #4 {main} thrown in C:\xampp\htdocs\yii\framework\base\CApplication.php on line 262

Kira kira apa yag salah ya ? makasih mastah mastah :D
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users