Exemple #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()
 {
     /*$users=array(
     			// username => password
     			'demo'=>'demo',
     			'admin'=>'admin',
     		);
     		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;*/
     $user = UserAdmin::model()->find('LOWER(username)=?', array(strtolower($this->username)));
     if ($user == null) {
         $this->errorCOde = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->validatePassword($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id_user;
             $this->username = $user->username;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
 /**
  * Authenticates a Student.
  * 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 Student identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     if (strpos($this->username, "@")) {
         $user = UserAdmin::model()->findByAttributes(array('email' => $this->username));
     } else {
         $user = UserAdmin::model()->findByAttributes(array('username' => $this->username));
     }
     if ($user === null) {
         // No user found!
         //$this->errorCode = self::ERROR_USERNAME_INVALID;
         if (strpos($this->username, "@")) {
             $this->errorCode = self::ERROR_EMAIL_INVALID;
         } else {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         }
     } else {
         if ($user->password !== SHA1($this->password)) {
             // Invalid password!
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($user->status == 2) {
                 $this->errorCode = self::ERROR_STATUS_NOTACTIV;
             } else {
                 if ($user->status == 3) {
                     $this->errorCode = self::ERROR_STATUS_BAN;
                 } else {
                     if ($user->status == 4) {
                         $this->errorCode = self::ERROR_STATUS_EXPIRE;
                     } else {
                         // Okay!
                         Yii::app()->db->createCommand('UPDATE {{user_admin}} SET `lastvisitDate` = NOW() WHERE id=' . $user->id)->execute();
                         $this->errorCode = self::ERROR_NONE;
                         // Store the role in a session:
                         $this->setState('group', $user->group_id);
                         $this->setState('email', $user->email);
                         $this->setState('fullname', $user->name);
                         $this->setState('user_type', $user->user_type);
                         $this->_id = $user->id;
                         Yii::app()->db->createCommand('UPDATE {{yiisession}} SET `userId` = ' . $user->id . ', userType=1 WHERE id="' . session_id() . '"')->execute();
                     }
                 }
             }
         }
     }
     return !$this->errorCode;
 }
Exemple #3
0
 public static function get_picture_grid($id)
 {
     $value = UserAdmin::model()->findByAttributes(array('id' => $id));
     $filePath = Yii::app()->basePath . '/../uploads/profile_picture/' . $value->profile_picture;
     if (is_file($filePath) && file_exists($filePath)) {
         return CHtml::image(Yii::app()->baseUrl . '/uploads/profile_picture/' . $value->profile_picture, 'Profile Picture', array('alt' => $value->name, 'class' => 'nav-user-photo', 'title' => $value->name, 'style' => 'width:50px;'));
     } else {
         return CHtml::image(Yii::app()->baseUrl . '/uploads/profile_picture/profile.jpg', 'Profile Picture', array('alt' => $value->name, 'class' => 'nav-user-photo', 'title' => $value->name, 'style' => 'width:50px;'));
     }
 }
Exemple #4
0
<?php

$this->pageTitle = "Online Admin Users - " . Yii::app()->name;
$this->breadcrumbs = array('Online Admin Users' => array('admin'), 'Manage');
?>
<div class="widget-box">
    <div class="widget-header">
        <h5>Manage Online Admin Users</h5>
        <div class="widget-toolbar">
            <a data-action="settings" href="#"><i class="icon-cog"></i></a>
            <a data-action="reload" href="#"><i class="icon-refresh"></i></a>
            <a data-action="collapse" href="#"><i class="icon-chevron-up"></i></a>
            <a data-action="close" href="#"><i class="icon-remove"></i></a>
        </div>
    </div><!--/.widget-header -->
    <div class="widget-body">
        <div class="widget-main">
            <?php 
$this->widget('bootstrap.widgets.TbGridView', array('type' => TbHtml::GRID_TYPE_HOVER, 'id' => 'user-group-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('header' => 'Name', 'name' => 'userId', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode(UserAdmin::get_user_name($data->userId)), array("/userAdmin/view","id"=>$data->userId))', 'filter' => CHtml::activeDropDownList($model, 'userId', CHtml::listData(UserAdmin::model()->findAll(array('condition' => '', "order" => "name")), 'id', 'name'), array('empty' => 'All')), 'htmlOptions' => array('style' => "text-align:left;", 'title' => 'Full Name')), array('name' => 'expire', 'type' => 'raw', 'value' => 'AuditTrail::returnInterval(OnlineUser::get_ts_time($data->expire),OnlineUser::get_current_time())'), array('header' => 'Shut down', 'type' => 'raw', 'value' => 'OnlineUser::shut_down($data->userId)', 'htmlOptions' => array('style' => "text-align:center;width:100px;")))));
?>
        </div>
    </div><!--/.widget-body -->
</div><!--/.widget-box -->
Exemple #5
0
<?php

$this->pageTitle = 'Admin Visitors - ' . Yii::app()->name;
$this->breadcrumbs = array('Admin Visitors' => array('admin'), 'Manage');
Yii::app()->clientScript->registerScript('re-install-date-picker', "\nfunction reinstallDatePicker(id, data) {\n    \$('#datepicker1').datepicker();\n    \$('#datepicker2').datepicker();\n}\n");
?>
<div class="widget-box">
    <div class="widget-header">
        <h5>Admin Visitors</h5>
        <div class="widget-toolbar">
            <a data-action="settings" href="#"><i class="icon-cog"></i></a>
            <a data-action="reload" href="#"><i class="icon-refresh"></i></a>
            <a data-action="collapse" href="#"><i class="icon-chevron-up"></i></a>
            <a data-action="close" href="#"><i class="icon-remove"></i></a>
        </div>
        <div class="widget-toolbar">
            <?php 
echo CHtml::link('<i class="icon-trash"></i>', array('truncate'), array('data-rel' => 'tooltip', 'title' => 'Truncate Admin Data', 'data-placement' => 'bottom'));
?>
        </div>
    </div><!--/.widget-header -->
    <div class="widget-body">
        <div class="widget-main">
            <?php 
$this->widget('bootstrap.widgets.TbGridView', array('type' => TbHtml::GRID_TYPE_HOVER, 'id' => 'visitor-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'user_id', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode(UserAdmin::get_user_name($data->user_id)), array("/userAdmin/view","id"=>$data->user_id))', 'filter' => CHtml::activeDropDownList($model, 'user_id', CHtml::listData(UserAdmin::model()->findAll(array('condition' => '', "order" => "name")), 'id', 'name'), array('empty' => 'All')), 'htmlOptions' => array('style' => "text-align:left;")), 'user_name', 'page_title', 'page_link', array('name' => 'server_time', 'value' => 'AuditTrail::get_date_time($data->server_time)', 'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'server_time', 'htmlOptions' => array('id' => 'datepicker2', 'size' => '10'), 'i18nScriptFile' => 'jquery.ui.datepicker-en.js', 'defaultOptions' => array('showOn' => 'focus', 'dateFormat' => 'yy-mm-dd', 'showOtherMonths' => true, 'selectOtherMonths' => true, 'changeMonth' => true, 'changeYear' => true, 'showButtonPanel' => false)), true), 'htmlOptions' => array('style' => "text-align:center;")), 'browser', 'visitor_ip', array('header' => 'Actions', 'template' => '{delete}', 'class' => 'bootstrap.widgets.TbButtonColumn'))));
?>
        </div>
    </div><!--/.widget-body -->
</div><!--/.widget-box -->
Exemple #6
0
<?php

$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('action' => Yii::app()->createUrl($this->route), 'method' => 'get'));
echo $form->dropDownListControlGroup($model, 'parent', CHtml::listData(DocumentCategory::model()->findAll(array('condition' => 'parent=0', "order" => "title")), 'id', 'title'), array('empty' => '--please select--', 'class' => 'span5'));
echo $form->textFieldControlGroup($model, 'title', array('class' => 'span5', 'maxlength' => 255));
echo $form->dropDownListControlGroup($model, 'published', array('' => 'All', '1' => 'Yes', '0' => 'No'), array('class' => 'span5'));
echo $form->dropDownListControlGroup($model, 'created_by', CHtml::listData(UserAdmin::model()->findAll(array('select' => 'id, name', 'condition' => '', "order" => "name")), 'id', 'name'), array('empty' => '--please select--', 'class' => 'span5'));
?>
<div class="form-actions">
    <?php 
echo TbHtml::submitButton('Search', array('color' => TbHtml::BUTTON_COLOR_PRIMARY));
?>
    <?php 
echo TbHtml::resetButton('Reset', array('color' => TbHtml::BUTTON_COLOR_INFO));
?>
</div>
<?php 
$this->endWidget();
Exemple #7
0
 public static function get_user_type($user_id, $user_type)
 {
     if ($user_type == 0) {
         $value = User::model()->findByAttributes(array('id' => $user_id));
     } else {
         $value = UserAdmin::model()->findByAttributes(array('id' => $user_id));
     }
     if (empty($value->name)) {
         return 'Not set!';
     } else {
         return $value->name;
     }
 }
Exemple #8
0
<?php

/* @var $this AuditTrailController */
/* @var $model AuditTrail */
$this->pageTitle = 'Audit Trail Admin Users - ' . Yii::app()->name;
$this->breadcrumbs = array('Audit Trails Admin Users' => array('admin'), 'Manage');
?>
<div class="widget-box">
    <div class="widget-header">
        <h5>Audit Trail Admin Users</h5>
        <div class="widget-toolbar">
            <a data-action="settings" href="#"><i class="icon-cog"></i></a>
            <a data-action="reload" href="#"><i class="icon-refresh"></i></a>
            <a data-action="collapse" href="#"><i class="icon-chevron-up"></i></a>
            <a data-action="close" href="#"><i class="icon-remove"></i></a>
        </div>
    </div><!--/.widget-header -->
    <div class="widget-body">
        <div class="widget-main">
            <?php 
$this->widget('bootstrap.widgets.TbGridView', array('id' => 'audit-trail-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'user_id', 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode(UserAdmin::get_name($data->user_id)), array("/userAdmin/view","id"=>$data->user_id))', 'filter' => CHtml::activeDropDownList($model, 'user_id', CHtml::listData(UserAdmin::model()->findAll(array('condition' => '', "order" => "name")), 'id', 'name'), array('empty' => 'All')), 'htmlOptions' => array('style' => "text-align:left;width:250px;", 'title' => 'Name')), array('name' => 'login_time', 'type' => 'raw', 'value' => 'AuditTrail::get_date_time($data->login_time)', 'htmlOptions' => array('style' => "text-align:left;width:250px;", 'title' => 'Login time')), array('name' => 'logout_time', 'type' => 'raw', 'value' => 'AuditTrail::get_date_time($data->logout_time)', 'htmlOptions' => array('style' => "text-align:left;width:250px;", 'title' => 'Logout time')), array('header' => 'Duration', 'type' => 'raw', 'value' => 'AuditTrail::returnInterval($data->login_time,$data->logout_time)'), array('header' => 'Actions', 'template' => '{delete}', 'class' => 'bootstrap.widgets.TbButtonColumn', 'htmlOptions' => array('style' => "text-align:center;width:80px;", 'title' => 'Actions')))));
?>
 
        </div>
    </div><!--/.widget-body -->
</div><!--/.widget-box -->               
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = UserAdmin::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }