Esempio n. 1
0
 /**
  * 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()
 {
     $user = Akun::model()->find('username=?', array($this->username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->password !== crypt($this->password, $user->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->errorCode = self::ERROR_NONE;
             $this->setState('role', $user->kode_role);
             if ($user->kode_role != '1' && $user->kode_role != '2') {
                 if ($user->kode_role != '6') {
                     $this->setState('id_personil', $user->id_personil);
                     $puskaji = Bidang::findPuskajiByBidang($user->id_personil);
                     $this->setState('puskaji', $puskaji->id);
                     $bidang = Bidang::findBidangByPersonil($user->id_personil);
                     $this->setState('bidang', $bidang[0]['id']);
                 }
             }
             //$this->setState('kabupaten',$user->kode_kabkot);
             //$this->setState('password',$user->password);
         }
     }
     return !$this->errorCode;
     //if(!isset($users[$this->username]))
     //	$this->errorCode=self::ERROR_USERNAME_INVALID;
     //elseif($users[$this->username]!==$this->password)
     //	$this->errorCode=self::ERROR_PASSWORD_INVALID;
     //else
     //	$this->errorCode=self::ERROR_NONE;
     //return !$this->errorCode;
 }
Esempio n. 2
0
?>
    </thead>
    <tfoot>
      <tr>
      </tr>
    </tfoot>
    <tbody>
    	<?php 
$ii = 1;
foreach ($dataProvider as $data) {
    echo "<tr id=\"\">";
    echo "<td>" . $ii++ . "</td>";
    $pers = Personil::model()->findByPk($data->id_personil);
    echo "<td>" . $pers['nama'] . "</td>";
    echo "<td class=\"text-left\">" . $data->username . "</td>";
    $role = Akun::model()->getRole($data->kode_role);
    echo "<td class=\"text-left\">" . $role . "</td>";
    if (Yii::app()->user->getState('role') == Akun::ADMIN) {
        echo "<td class=\"text-left\">" . CHtml::link('Ubah', array('Akun/update', 'id' => $data->id)) . " |" . CHtml::link('Hapus', array('Akun/delete', 'id' => $data->id), array('submit' => array('Akun/delete', 'id' => $data->id), 'class' => 'delete', 'confirm' => 'Anda yakin untuk menghapus akun?')) . "</td>";
    }
    echo "</tr>";
}
?>
    </tbody>
  </table>

</div>
</div>

<link rel="stylesheet" type="text/css" href="<?php 
echo Yii::app()->request->baseUrl;
Esempio n. 3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Akun the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Akun::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }