/** * Authenticates a user. * The example implementation makes sure if the username and password * are both 'demo'. * In practical applications, this should be changed to authenticate * against some persistent user identity storage (e.g. database). * @return boolean whether authentication succeeds. */ public function authenticate() { $admin = TAdmin::model()->findByAttributes(array('username' => $this->username)); $anggota = TAnggota::model()->findByAttributes(array('username' => $this->username)); $perusahaan = TPerusahaan::model()->findByAttributes(array('username' => $this->username)); if ($admin !== null) { if ($admin->password != $this->password) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->errorCode = self::ERROR_NONE; } } else { if ($anggota !== null) { if ($anggota->password != $this->password) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->errorCode = self::ERROR_NONE; } } else { if ($perusahaan !== null) { if ($perusahaan->password != $this->password) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->errorCode = self::ERROR_NONE; } } } } return !$this->errorCode; }
public static function isAdmin() { $model = TAdmin::model()->findByAttributes(array('username' => Yii::app()->user->id, 'role' => 'admin')); if ($model !== null) { return true; } else { return false; } }
public function actionIndex() { if (TPerusahaan::isPerusahaan()) { $this->redirect(array('TPerusahaan/profil')); } if (TAnggota::isAnggota()) { $this->redirect(array('TAnggota/profil')); } if (TAdmin::isAdmin()) { $this->redirect(array('TAdmin/profil')); } }
public function actionGantipassword() { $this->layout = '//layouts/akun/main'; if (isset($_POST['password_baru'])) { $member = TAdmin::model()->findByAttributes(array('username' => Yii::app()->user->id)); $member->password = $_POST['password_baru']; $member->save(); } $this->render('gantipassword'); }
/css/main.css"> <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?> /css/form.css"> <title><?php echo CHtml::encode($this->pageTitle); ?> </title> </head> <body> <?php $this->widget('booster.widgets.TbNavbar', array('brand' => '', 'fixed' => false, 'fluid' => true, 'items' => array(array('class' => 'booster.widgets.TbMenu', 'type' => 'navbar', 'items' => array(array('label' => 'Home', 'url' => array('site/index'), 'icon' => 'home'), array('label' => 'Daftar Pekerja', 'url' => array('TAnggota/create'), 'icon' => 'user', 'visible' => Yii::app()->user->isGuest), array('label' => 'Daftar Perusahaan', 'url' => array('TKonfirmasiPerusahaan/create'), 'icon' => 'list', 'visible' => Yii::app()->user->isGuest), array('label' => 'Dashboard', 'url' => array('/TAnggota/profil'), 'icon' => 'list', 'visible' => TAnggota::isAnggota()), array('label' => 'Dashboard', 'url' => array('/TPerusahaan/profil'), 'icon' => 'list', 'visible' => TPerusahaan::isPerusahaan()), array('label' => 'Dashboard', 'url' => array('/TAdmin/profil'), 'icon' => 'list', 'visible' => TAdmin::isAdmin()), array('label' => 'Logout (' . Yii::app()->user->id . ')', 'url' => array('/site/logout'), 'icon' => 'off', 'visible' => !Yii::app()->user->isGuest), array('label' => 'Sign In', 'url' => array('site/login'), 'icon' => 'off', 'linkOptions' => array('class' => 'pull-right'), 'visible' => Yii::app()->user->isGuest)))))); ?> <?php $this->widget('booster.widgets.TbCarousel', array('items' => array(array('image' => Yii::app()->request->baseUrl . '/images/14.jpg', 'label' => '', 'caption' => ''), array('image' => Yii::app()->request->baseUrl . '/images/12.jpg', 'label' => '', 'caption' => ''), array('image' => Yii::app()->request->baseUrl . '/images/13.jpg', 'label' => '', 'caption' => '')))); ?> <?php echo $content; ?> <div class="clear"></div> <div id="footer" > <div id="depan" class="width: 1000px;">
<div style="padding:0px 15px;"> <div class="row"> <div class="col-xs-2"> <?php if (TPerusahaan::isPerusahaan()) { ?> <?php $this->widget('booster.widgets.TbMenu', array('type' => 'list', 'stacked' => true, 'items' => array(array('label' => 'Dashboard', 'icon' => 'user', 'url' => array('TPerusahaan/profil')), '--------------', array('label' => 'Buat Lowongan', 'icon' => 'plus', 'url' => array('/TPermintaanPerusahaan/create')), array('label' => 'Lowongan Terbit', 'icon' => 'certificate', 'url' => array('/TPermintaanPerusahaan/admin')), array('label' => 'Lowongan Masuk', 'icon' => 'arrow-down', 'url' => array('/TPesan/admin')), '--------------', array('label' => 'Logout', 'icon' => 'off', 'url' => array('/diklat/rekapdiklat'))))); ?> <?php } ?> <?php if (TAdmin::isAdmin()) { ?> <?php $this->widget('booster.widgets.TbMenu', array('type' => 'list', 'stacked' => true, 'items' => array(array('label' => 'Dashboard', 'icon' => 'user', 'url' => array('TAdmin/profil')), array('label' => 'Angota', 'url' => array('/TAnggota/admin'), 'icon' => 'book'), array('label' => 'Perusahaan', 'url' => array('/TPerusahaan/admin'), 'icon' => 'certificate'), array('label' => 'Peta', 'url' => array('peta/index'), 'icon' => 'map-marker'), array('label' => 'Ganti Password', 'url' => array('TAdmin/gantipassword'), 'icon' => 'cog'), array('label' => 'Login', 'url' => array('/site/login'), 'visible' => Yii::app()->user->isGuest), array('label' => 'Logout (' . Yii::app()->user->id . ')', 'url' => array('/site/logout'), 'icon' => 'off', 'visible' => !Yii::app()->user->isGuest)))); ?> <?php } ?> <?php if (TAnggota::isAnggota()) { $model = new TAnggota(); print $model->getImage(); ?> <hr>