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()
 {
     /**
      * @var $user XfUser
      */
     $user = XfUser::model()->find('LOWER(username)=?', array(strtolower($this->username)));
     $xfAuth = new XfAuthentication();
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$xfAuth->checkAuth($this->username, $this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $userInfo = $xfAuth->login($this->username, $this->password);
             //var_dump($userInfo);die;
             if ($userInfo) {
                 $this->_id = $userInfo['user_id'];
                 $this->username = $userInfo['username'];
                 Rights::assign($user['role'], $this->_id);
                 $this->errorCode = self::ERROR_NONE;
             } else {
                 $this->errorCode = self::ERROR_USERNAME_INVALID;
             }
         }
     }
     //unset($xfAuth);
     return !$this->errorCode;
 }
Exemple #2
0
 public function actionView()
 {
     $this->layout = 'profile';
     $username = $_GET['username'];
     $user = XfUser::model()->find("username='******'");
     $db = Yii::app()->db;
     $sql = "SELECT v.id,v.title,v.body,v.image,v.link_youtube,v.view,t.username FROM {{video}} v INNER JOIN {{teacher}} t ON v.teacher_id = t.id WHERE v.status = 1 AND t.username = '******' ORDER BY v.id DESC LIMIT 0,4";
     $cmd = $db->createCommand($sql);
     $dataReader = $cmd->query();
     $video = array();
     foreach ($dataReader as $item) {
         $video[] = $item;
     }
     $this->render('view', array('user' => $user, 'video' => $video));
 }
Exemple #3
0
	<div class="row">
		<?php 
echo $form->label($model, 'status');
?>
		<?php 
echo $form->textField($model, 'status');
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'user_id');
?>
		<?php 
echo $form->dropDownList($model, 'user_id', GxHtml::listDataEx(XfUser::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All')));
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'create_time');
?>
		<?php 
echo $form->textField($model, 'create_time');
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'update_time');
Exemple #4
0
 /**
  * @static
  * @param $user_id
  * @return string
  * Get ảnh avatar thành viên
  */
 public static function get_picture_href($user_id)
 {
     if (file_exists(Yii::getPathOfAlias('webroot') . 'data/avatars/m/0/' . $user_id . '.jpg')) {
         return Yii::app()->baseUrl . '/forum/data/avatars/m/0/' . $user_id . '.jpg';
     } else {
         $user = XfUser::model()->findByPk($user_id);
         if ($user) {
             if ($user->gender == 'male') {
                 return Yii::app()->baseUrl . '/forum/styles/default/xenforo/avatars/avatar_male_m.png';
             } elseif ($user->gender == 'female') {
                 return Yii::app()->baseUrl . '/forum/styles/default/xenforo/avatars/avatar_female_m.png';
             } else {
                 return Yii::app()->baseUrl . '/forum/styles/default/xenforo/avatars/avatar_m.png';
             }
         }
         return Yii::app()->baseUrl . '/forum/styles/default/xenforo/avatars/avatar_m.png';
     }
 }
Exemple #5
0
$this->menu = array(array('label' => 'Danh sách', 'url' => array('admin')), array('label' => 'Tạo mới', 'url' => array('create')));
/*Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('news-grid', {
		data: $(this).serialize()
	});
	return false;
});
");*/
?>

<h1>Tin tức</h1>
<?php 
/*echo GxHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button')); */
?>
<!--
<div class="search-form">
<?php 
/*$this->renderPartial('_search', array(
	'model' => $model,
)); */
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'news-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('title', array('name' => 'create_time', 'value' => 'date("d/m/Y",$data->create_time)'), array('name' => 'user_id', 'value' => 'GxHtml::valueEx($data->user)', 'filter' => GxHtml::listDataEx(XfUser::model()->findAllAttributes(null, true))), array('class' => 'CButtonColumn', 'template' => '{update}{delete}'))));
Exemple #6
0
$this->menu = array(array('label' => 'Danh sách', 'url' => array('admin')), array('label' => 'Tạo mới', 'url' => array('create')));
/*Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('page-grid', {
		data: $(this).serialize()
	});
	return false;
});
");*/
?>

<h1>Trang tĩnh</h1>
<!--
<?php 
/*echo GxHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button')); */
?>
<div class="search-form">
<?php 
/*$this->renderPartial('_search', array(
	'model' => $model,
)); */
?>
</div>--><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'page-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'title', 'value' => 'CHtml::link($data->title,Yii::app()->baseUrl."/page/".Lnt::safeTitle($data->title)."-".$data->id.".html")', 'type' => 'html'), array('name' => 'user_id', 'value' => 'GxHtml::valueEx($data->user)', 'filter' => GxHtml::listDataEx(XfUser::model()->findAllAttributes(null, true))), array('name' => 'create_time', 'value' => 'date("d/m/Y",$data->create_time)'), array('class' => 'CButtonColumn', 'template' => '{update},{delete}'))));