Example #1
0
 /**
  * Logs in the user using the given username and password in the model.
  * @return boolean whether login is successful
  */
 public function login()
 {
     if ($this->_identity === null) {
         $this->_identity = new UserIdentity($this->username, $this->password);
         $this->_identity->authenticate();
     }
     if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
         $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
         // 30 days
         Yii::app()->user->login($this->_identity, $duration);
         $userInfo = UserModel::model()->find('username=:username', array(':username' => $this->username));
         Yii::app()->session['userInfo'] = array('uid' => $userInfo->uid, 'username' => $userInfo->username, 'nickname' => $userInfo->nickname, 'group_id' => $userInfo->group_id);
         //log
         $log = new ActiveRecordLog();
         $log->description = Yii::t('admin/activeLog', 'User {username} login', array('username' => Yii::app()->user->Name));
         $log->action = 'LOGIN';
         $log->model = __CLASS__;
         $log->idModel = $userInfo->uid;
         $log->field = '';
         $log->created_at = new CDbExpression('NOW()');
         $log->username = Yii::app()->user->id;
         $log->save();
         return true;
     } else {
         return false;
     }
 }
Example #2
0
 public function userAuthenticateWifi($msisdn)
 {
     if ($msisdn) {
         // get user info from phone
         $user = UserModel::model()->findByAttributes(array("phone" => $msisdn));
         if ($user) {
             if (!empty($user->suggested_list)) {
                 $this->setState('_user', array('id' => $user->id, 'suggested_list' => $user->suggested_list));
             } else {
                 $this->setState('_user', array('phone' => $msisdn, 'suggested_list' => ""));
             }
         } else {
             $this->setState('_user', array('phone' => $msisdn, 'suggested_list' => ""));
         }
         $this->_msisdn = $msisdn;
         $this->setState('msisdn', $msisdn);
         $package = WapUserSubscribeModel::model()->getUserSubscribe($this->_msisdn);
         // get user_subscribe record by phone
         if ($package) {
             $packageObj = WapPackageModel::model()->findByPk($package->package_id);
             $this->setState('package', $packageObj->code);
         }
         self::_logDetectMSISDN($msisdn, 'wifi');
         $this->errorCode = self::ERROR_NONE;
     } else {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     }
     return !$this->errorCode;
 }
 public function ajaxAction($command = '', $params = array())
 {
     switch ($command) {
         case 'view_accountlist':
             $userlist = UserModel::model()->getRows();
             $this->setVar("userlist", $userlist);
             $this->loadView("admin/accounts_list");
             break;
         case 'json_user':
             $user = UserModel::model()->getRowFromPk($_GET['user_id']);
             echo $user->toJSON();
             break;
         case 'post_delete':
             $user_id = $_POST['user_id'];
             $user = UserModel::model()->getRowFromPk($user_id);
             $user->delete();
             break;
         case 'post_add':
             $user = UserModel::model();
             $user->user_name = $_POST['user_name'];
             $user->email = $_POST['email'];
             $user->plain_pass = $_POST['pass'];
             $user->pass = $_POST['pass'];
             $user->pass_confirm = $_POST['pass_confirm'];
             $user->privilege = $_POST['privilege'];
             $user->useRuleSet("admin_new");
             if ($user->save()) {
                 echo '0';
             } else {
                 echo join('<br>', $user->getErrors());
             }
             break;
         case 'post_edit':
             $user = UserModel::model()->getRowFromPk($_POST['user_id']);
             if (!$user) {
                 echo "Bad ID";
                 BTApp::end();
             }
             $user->user_name = $_POST['user_name'];
             $user->email = $_POST['email'];
             if ($_POST['pass']) {
                 $user->plain_pass = $_POST['pass'];
                 $user->pass = $_POST['pass'];
                 $user->pass_confirm = $_POST['pass_confirm'];
             } else {
                 //to satisfy the validation
                 $user->pass = $user->pass;
                 $user->pass_confirm = $user->pass;
             }
             $user->privilege = $_POST['privilege'];
             $user->useRuleSet("admin_edit");
             if ($user->save()) {
                 echo '0';
             } else {
                 echo join('<br>', $user->getErrors());
             }
             break;
     }
 }
 public function actionIndex()
 {
     $model = UserModel::model()->findByPk(Yii::app()->user->id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $this->render('index', array('model' => $model));
 }
Example #5
0
 protected function createUserIfNotExist()
 {
     $user = UserModel::model()->getByAttr('email', $this->user_email);
     if ($user->isNewRecord()) {
         $user->setAttributes(array('email' => $this->user_email));
         $user->save();
     }
     $this->aAttributes['user_id'] = UserModel::model()->getByAttr('email', $this->user_email)->getAttributeValue('id');
 }
Example #6
0
 public function __construct($id, $module = null)
 {
     parent::__construct($id, $module = null);
     if (Yii::app()->user->isGuest) {
         $this->redirect(array('site/login'));
     } else {
         $userInfo = UserModel::model()->find('username=:username', array(':username' => Yii::app()->user->name));
         Yii::app()->session['userInfo'] = array('uid' => $userInfo->uid, 'username' => $userInfo->username, 'nickname' => $userInfo->nickname, 'group_id' => $userInfo->group_id);
     }
 }
Example #7
0
 public function actionProfile()
 {
     $model = UserModel::model()->find(array('condition' => 'username=:username', 'params' => array(':username' => Yii::app()->user->id)));
     if (isset($_POST['UserModel'])) {
         $model->attributes = $_POST['UserModel'];
         if ($model->validate()) {
             $model->save();
             $this->redirect(array('group/user'));
         }
     }
     $this->render('/user/profile', array('model' => $model));
 }
Example #8
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()
 {
     $models = UserModel::model()->findAll();
     $users = CHtml::listData($models, 'user_email', 'user_password');
     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;
 }
 public function actionAddCall()
 {
     if (isset($_POST['RequestCall']) && !empty($_POST['RequestCall'])) {
         $cost = 0;
         if ($_POST['RequestCall']['type'] == RequestCall::TYPE_SIMPLE) {
             $cost = 300;
         } elseif ($_POST['RequestCall']['type'] == RequestCall::TYPE_DIFFICULT) {
             $cost = 500;
         } elseif ($_POST['RequestCall']['type'] == RequestCall::TYPE_VERY_DIFFICULT) {
             $cost = 1000;
         }
         $user = UserModel::model()->client()->findByPk(Yii::app()->user->id);
         if ($user) {
             if ($user->balance - $cost < 0) {
                 Yii::app()->user->setFlash('error', 'Недостаточно средств! пополните баланс и закажите звонок');
                 $this->refresh();
             } else {
                 Yii::app()->user->setFlash('success', 'Звонок заказан! с вашего счета снято ' . $cost . 'руб');
                 $user->balance = $user->balance - $cost;
                 $user->save(false);
             }
         }
         $model = new RequestCall();
         $model->setAttributes($_POST['RequestCall']);
         $model->user_id = Yii::app()->user->id;
         $model->status = 1;
         $model->save();
         $image = CUploadedFile::getInstance($model, 'file');
         if ($image) {
             if (!is_dir('uploads/phoneDocument/images')) {
                 mkdir('uploads/phoneDocument/images', 0777, true);
             }
             $ext = explode('.', $image->name);
             $model->file = Yii::app()->user->id . '_' . md5(time()) . '.' . $ext[1];
             $image->saveAs('uploads/phoneDocument/images/' . $model->file);
             $model->save(false);
         }
     }
     $jurist = UserModel::model()->jurist()->findByPk(Yii::app()->user->id);
     if (Yii::app()->user->isGuest) {
         Yii::app()->user->setFlash('error', 'Заказать звонок может только зарегестрированный пользователь');
         $this->redirect($this->createUrl('site/index'));
     }
     if ($jurist !== null) {
         Yii::app()->user->setFlash('error', 'Заказать звонок может только пользователь');
         $this->redirect($this->createUrl('cabinet/index'));
     }
     $this->render('newRequest', ['model' => new RequestCall()]);
 }
Example #10
0
 public function actionPswd()
 {
     $userInfo = Yii::app()->session['userInfo'];
     $model = UserModel::model()->find(array('condition' => 'uid=:uid', 'params' => array(':uid' => $userInfo['uid'])));
     $model->scenario = 'pswd';
     if (isset($_POST['UserModel'])) {
         $model->attributes = $_POST['UserModel'];
         if ($model->validate()) {
             $model->pswd = md5($_POST['UserModel']['newpswd']);
             $model->save();
             ShowMessage::success('修改成功!', Yii::app()->createUrl('user/pswd'));
         }
     }
     $this->render('pswd', array('model' => $model));
 }
Example #11
0
 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = UserModel::model()->find('LOWER(email)=?', [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;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
Example #12
0
 public function actionDelete($id)
 {
     $model = UserModel::model()->findByPk($id);
     if ($model) {
         if ($model->info) {
             $model->info->delete();
         }
         if ($model->schooling) {
             $model->schooling->delete();
         }
         if ($model->contact) {
             $model->contact->delete();
         }
         $model->delete();
     }
 }
Example #13
0
 public function authenticate()
 {
     $record = UserModel::model()->findByAttributes(array('email' => $this->username));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->password !== $this->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->_id;
             //$this->setState('title', $record->title);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
Example #14
0
 public function actionForget()
 {
     $model = new UserForm('foget');
     $msg = '';
     if (!empty($_POST['UserForm'])) {
         $model->attributes = $_POST['UserForm'];
         if ($model->validate()) {
             $user = new UserModel();
             $user->password = UserModel::model()->cryptPass($pass = UserModel::model()->genPassword());
             $user->save();
             Yii::app()->email->send($model->email, 'Новый пароль', 'Ваш новый пароль:' . $pass);
             $msg = 'Новый пароль отправлен Вам на почту.';
         }
     }
     $this->render('forget', ['model' => $model, 'msg' => $msg]);
 }
Example #15
0
 public function actionLogin()
 {
     $connection = Yii::app()->db;
     $email = $_REQUEST['email'];
     $password = $_REQUEST['pwd'];
     $user = UserModel::model()->find('email=:email and password=:pwd', array(':email' => $email, ':pwd' => $password));
     if (isset($user)) {
         //邮箱密码正确,找到名字对应的_id。
         $sql = "select _id from tbl_user where email = :email";
         $command = $connection->createCommand($sql);
         $tmp = $command->query(array(':email' => $email))->readAll();
         echo json_encode(array('result' => 1, 'res' => $tmp[0]["_id"]));
     } else {
         echo json_encode(array('result' => 0, 'comment' => 'login fail'));
     }
 }
Example #16
0
 /**
  * Logs in the user using the given username and password in the model.
  * @return boolean whether login is successful
  */
 public function login()
 {
     if ($this->_identity === null) {
         $this->_identity = new UserIdentity($this->username, $this->password);
         $this->_identity->authenticate();
     }
     if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
         $duration = $this->rememberMe ? 3600 * 24 * 30 : 0;
         // 30 days
         Yii::app()->user->login($this->_identity, $duration);
         $usermodel = UserModel::model()->findByAttributes(array('user_email' => $this->username));
         Yii::app()->session['userlevel'] = $usermodel->user_level;
         Yii::app()->session['userid'] = $usermodel->user_id;
         return true;
     } else {
         return false;
     }
 }
Example #17
0
 public function actionGetPopupPlaylist()
 {
     $this->layout = false;
     $phone = Yii::app()->request->getParam('phone', '');
     $songId = Yii::app()->request->getParam('song_id', 0);
     $playlist = array();
     /* if(!empty($phone))
     			$playlist = WapPlaylistModel::model()->getPlaylistByPhone($phone); */
     $user = UserModel::model()->find("phone=" . $phone);
     if ($user) {
         $userId = $user->id;
         $playlist = WapPlaylistModel::model()->getPlaylistByUser($userId, $phone, 100, 0);
     } else {
         $userId = null;
         $playlist = WapPlaylistModel::model()->getPlaylistByPhone($phone, 100, 0);
     }
     $this->render('playlist', array('playlist' => $playlist, 'songId' => $songId, 'phone' => $phone));
 }
 public function actionView()
 {
     $playlistId = Yii::app()->request->getParam('id');
     $playlist = WapPlaylistModel::model()->published()->findByPk($playlistId);
     $user_msisdn = $playlist->msisdn;
     if (!$playlist) {
         $this->forward("/site/error", true);
     }
     $songsOfPlaylist = WapPlaylistModel::model()->getSongs($playlistId);
     //samge user
     $countPlSameUser = WapPlaylistModel::model()->countPlaylistByPhone($this->userPhone);
     $playlistPages = new CPagination($countPlSameUser);
     $pageSize = Yii::app()->params['pageSize'];
     $playlistPages->setPageSize($pageSize);
     $currentPage = $playlistPages->getCurrentPage();
     $playlistsSameUser = WapPlaylistModel::model()->getSamePlaylistByPhone($playlist->id, $this->userPhone, $currentPage * $pageSize, $pageSize);
     $errorCode = 'success';
     $errorDescription = '';
     //for show price
     $checkPlay = WapUserTransactionModel::model()->checkCharging24h($this->userPhone, $this->userPhone, $playlistId, 'play_album');
     $userSub = $this->userSub;
     //WapUserSubscribeModel::model()->getUserSubscribe($phone);
     if ($checkPlay) {
         $playPrice = 0;
     } else {
         if ($userSub) {
             $playPrice = 0;
         }
     }
     if ($checkPlay) {
         $playPrice = 0;
     }
     // 		$registerText = WapAlbumModel::model()->getCustomMetaData('REG_TEXT');
     $this->itemName = $playlist->name;
     $this->artist = "Chacha";
     //$playlist->username;
     $this->thumb = UserModel::model()->getThumbnailUrl('s1', $playlist->user_id);
     $this->url = URLHelper::buildFriendlyURL("playlist", $playlist->id, Common::makeFriendlyUrl($playlist->name));
     $this->description = $playlist->name;
     $this->render('view', array('playlist' => $playlist, 'songsOfPlaylist' => $songsOfPlaylist, 'playlistsSameUser' => $playlistsSameUser, 'playlistPages' => $playlistPages, 'errorCode' => $errorCode, 'errorDescription' => $errorDescription, 'userSub' => $userSub, 'user_msisdn' => $user_msisdn));
 }
 public function actionIndex()
 {
     $model = new UserModel();
     if (isset($_POST['UserModel'])) {
         $model->attributes = $_POST['UserModel'];
         $model->username = $model->email;
         if ($model->validate()) {
             $record = UserModel::model()->findByAttributes(array('email' => $model->email));
             if ($record !== null) {
                 $this->render('error', array('type' => 'repeate'));
                 exit;
             } else {
                 if ($model->save()) {
                     //$this->redirect(array('style/index','id'=>$model->_id));
                     $this->redirect(array('login/index'));
                 }
                 $this->refresh();
             }
         }
     }
     $this->render('index', array('model' => $model));
 }
Example #20
0
<table class="playlist tablelist">
    <?php 
$currentPage = Yii::app()->request->getParam('ps', 1);
$number = ($currentPage - 1) * yii::app()->params['pageSize'] + 1;
foreach ($playlists as $playlist) {
    $playlistLink = yii::app()->createUrl('playlist/detail', array('id' => $playlist->id, 'baseid' => NULL, 'url_key' => Common::makeFriendlyUrl($playlist->name), array('class' => 'avatar')));
    if ($playlist->id) {
        $avatarImage = CHtml::image(UserModel::model()->getThumbnailUrl(50, $playlist->user_id), 'avatar', array('class' => 'avatar'));
    } else {
        $avatarImage = CHtml::image('/css/wap/images/icon/clip-50.png', 'avatar');
    }
    ?>
	<tr><td width="65px">              
			<?php 
    echo $avatarImage;
    ?>
		</td>        
        <td class="itemwrap" onclick="document.location = '<?php 
    echo $playlistLink;
    ?>
'">
            <p class="m0 fontB">
                <a href="<?php 
    echo $playlistLink;
    ?>
"><?php 
    echo WapCommonFunctions::substring($playlist->name, ' ', 6);
    ?>
</a>
            </p>
			
Example #21
0
 public function rules()
 {
     return [['email', 'email'], ['email, name, type', 'required', 'on' => 'reg_client'], ['name, surname, email, type', 'required', 'on' => 'reg_jurist'], ['type', 'in', 'range' => array_keys(UserModel::model()->arr_of_type), 'on' => 'reg_client, reg_jurist'], ['email, pass', 'required', 'on' => 'login'], ['email', 'required', 'on' => 'forget'], ['email', 'exist', 'on' => 'forget', 'className' => 'UserModel', 'attributeName' => 'email', 'message' => 'Данной Электронной почты нет в базе']];
 }
Example #22
0
 public function actionPayLawyer($lawyerId, $answerId)
 {
     $question = QuestionModel::model()->findByPk($answerId);
     $user = UserModel::model()->findByPk($lawyerId);
     $cost = $question->cost * 0.7;
     $user->balance = $user->balance + $cost;
     $user->save(false);
     $question->status = QuestionModel::STATUS_CLOSE;
     $question->save(false);
     Yii::app()->user->setFlash('success', 'Спасибо вашь вопрос закрыт!');
     $this->redirect($this->createUrl('question/index'));
 }
Example #23
0
				<?php 
    } elseif (isset($flashes['success'])) {
        ?>
				<div class="info">
					<?php 
        echo $flashes['success'];
        ?>
				</div>
				<?php 
    }
}
?>
	</div>
</div>
<?php 
$user = UserModel::model()->jurist()->findByPk(Yii::app()->user->id);
if (!$user) {
    echo CHtml::linkButton('Задать вопрос юристу', ['href' => $this->createUrl('add'), 'style' => 'margin-bottom: 15px;
    display: block;'], 'Задать вопрос');
}
echo '<br>';
$this->widget('zii.widgets.jui.CJuiTabs', array('tabs' => array('Все' => $this->renderPartial('tabs/all', ['dataProvider' => $dataProvider], $this), 'Платные' => $this->renderPartial('tabs/cost', ['dataProvider' => $dataProvider], $this), 'Бесплатные' => $this->renderPartial('tabs/free', ['dataProvider' => $dataProvider], $this), 'Нерешенные' => $this->renderPartial('tabs/new', ['dataProvider' => $dataProvider], $this)), 'options' => array('collapsible' => true)));
?>
<script type="text/javascript">
	$(function () {
		var content = $('tbody'),
			ch = content.height() + content.offset().top;
		if (ch < $(window).height()) {
			content.height($(window).height() - content.offset().top - 94)
		}
	})
Example #24
0
    ?>
'><?php 
    echo Yii::t("wap", "Tạo tài khoản");
    ?>
</a>
        </div>
    </div>
    <?php 
}
?>
    <?php 
if ($this->userPhone) {
    ?>
    <p class='message-login'>
        <?php 
    $user_name = UserModel::model()->findByAttributes(array('phone' => $this->userPhone))->username;
    $user_name = isset($user_name) ? $user_name : $this->userPhone;
    ?>
        <?php 
    echo Yii::t("wap", "Hi");
    ?>
: <a class='mobile' href="<?php 
    echo Yii::app()->createUrl('/account/view');
    ?>
"><?php 
    echo $user_name;
    ?>
</a>
    </p>
    <?php 
}
Example #25
0
 public function actionAdd()
 {
     /**
      * @var CWebApplication $app
      * @var Document $costDocument
      */
     if (Yii::app()->user->isGuest) {
         Yii::app()->user->setFlash('error', 'Заказать документ может только зарегестрированный пользователь');
         $this->redirect($this->createUrl('site/index'));
     }
     $app = Yii::app();
     $view = 'document';
     $id = $app->user->getState('document_id');
     $model = null;
     $user = UserModel::model()->findByPk($app->user->id);
     if (!$id) {
         $document = new Document();
         if (!empty($_POST['Document'])) {
             $document->attributes = $_POST['Document'];
             $image = CUploadedFile::getInstance($document, 'file');
             $document->user_id = Yii::app()->user->id;
             $document->status = 0;
             if ($document->save()) {
                 if ($image) {
                     if (!is_dir('uploads/document/images')) {
                         mkdir('uploads/document/images', 0777, true);
                     }
                     $ext = explode('.', $image->name);
                     $document->file = Yii::app()->user->id . '_' . md5(time()) . '.' . $ext[1];
                     $image->saveAs('uploads/document/images/' . $document->file);
                     $document->save(false);
                 }
                 $app->user->setState('document_id', $document->id);
                 $view = 'document_user_info';
                 $document = new DocumentUser();
             }
         }
         $model = $document;
     } elseif (null !== ($document = Document::model()->findByPk($id)) && !$document->document_user) {
         $document_user = new DocumentUser();
         $view = 'document_user_info';
         if (!empty($_POST['DocumentUser'])) {
             $document_user->attributes = $_POST['DocumentUser'];
             $document_user->document_id = $document->id;
             if ($document_user->save()) {
                 $view = 'document_pay';
                 $document_user = $user;
             }
         }
         $model = $document_user;
     } else {
         $model = $user;
         if (isset($_POST['payment']) && !empty($_POST['payment'])) {
             $balance = $model->balance - $_POST['payment'];
             if ($balance < 0) {
                 Yii::app()->user->setFlash('error', 'Недостаточно денег на счету');
             } else {
                 $billing = new TransModel();
                 $billing->user_id = $id;
                 $billing->service_id = $_POST['other_payment_type'];
                 $billing->summ = $_POST['payment'];
                 $billing->status = TransModel::STATUS_PAYMENT;
                 $billing->remark = 'Вывод средств';
                 $billing->date_add = date('Y-m-d H:i:s');
                 $billing->currency_id = 1;
                 $model->balance = $balance;
                 $model->save(false);
                 $billing->save(false);
                 $documentId = $app->user->getState('document_id');
                 $costDocument = Document::model()->findByPk($documentId);
                 $costDocument->cost = $_POST['payment'];
                 $costDocument->save(false);
                 Yii::app()->user->setFlash('success', 'Успешно! Ожидайте юрист с вами свяжется!');
                 $app->user->setState('document_id', null);
                 $this->refresh();
             }
         }
         $view = 'document_pay';
     }
     $this->render($view, ['model' => $model]);
 }
Example #26
0
 public function actionJurist()
 {
     $this->render('jlist', ['lists' => UserModel::model()->jurist()->findAll()]);
 }
Example #27
0
<?php

/**
 * @var CActiveDataProvider $dataProvider
 */
$cr = new CDbCriteria();
$cr->compare('type', QuestionModel::TYPE_NEW);
if (UserModel::model()->client()->findByPk(Yii::app()->user->id) !== null) {
    $cr->compare('user_id', Yii::app()->user->id);
}
$cr->compare('status', QuestionModel::STATUS_NEW);
$this->widget('zii.widgets.grid.CGridView', array('dataProvider' => new CActiveDataProvider('QuestionModel', ['criteria' => $cr]), 'htmlOptions' => ['class' => 'grid-view question'], 'selectionChanged' => "function(id){window.location='" . $this->createUrl('answer', array('id' => '')) . "' + \$.fn.yiiGridView.getSelection(id);}", 'columns' => [['name' => 'id', 'visible' => false], ['name' => 'user_id', 'value' => function ($data) {
    $user = UserInfo::model()->findByAttributes(['user_id' => $data->user_id]);
    if ($user) {
        return $user->fio();
    }
}], 'title', 'text', 'city', ['class' => 'CButtonColumn', 'template' => '{view}', 'viewButtonOptions' => ['title' => 'Просмотреть Вопрос'], 'viewButtonUrl' => 'Yii::app()->controller->createUrl("answer",array("id"=>$data->id))']]));
Example #28
0
 public function actionUserUpdate($id)
 {
     $model = UserModel::model()->findByPk($id);
     $group = GroupModel::model()->findall();
     foreach ($group as $v) {
         $groupList[$v->group_id] = $v->name;
     }
     if (isset($_POST['UserModel'])) {
         $model->attributes = $_POST['UserModel'];
         $model->scenario = 'update';
         if ($model->validate()) {
             if ($_POST['UserModel']['newPswd']) {
                 $model->pswd = md5($_POST['UserModel']['newPswd']);
             }
             $model->save();
             $this->redirect(array('group/user'));
         }
     }
     $this->render('userUpdate', array('model' => $model, 'group' => $groupList));
 }
 /**
  * bai hat yeu thich
  */
 public function actionFavAlbum()
 {
     $phone = yii::app()->user->getState('msisdn');
     $cri = new CDbCriteria();
     $cri->condition = " phone = {$phone}";
     $user = UserModel::model()->find($cri);
     $uid = $user->id;
     $limit = Yii::app()->params['pageSize'];
     $pageSize = Yii::app()->params['pageSize'];
     $page = Yii::app()->request->getParam('page', 1);
     $offset = ($page - 1) * $limit;
     $countAlbum = WapAlbumModel::model()->countFavAlbum($uid);
     $albumPages = new CPagination($countAlbum);
     $albumPages->setPageSize($pageSize);
     $favalbum = WapAlbumModel::model()->getFavAlbum($phone, $limit, $offset);
     $headerText = Yii::t('chachawap', 'Album yêu thích');
     $link = $link = Yii::app()->createUrl("/account/favalbum");
     $this->render('albumlist', array('albums' => $favalbum, 'link' => $link, 'type' => "list", 'headerText' => $headerText, 'albumPages' => $albumPages));
 }
 public function ViewAsAction()
 {
     BTAuth::require_user();
     if (!BTAuth::authUser()->isAdmin()) {
         //normal user
         error404();
     }
     $id = $_GET['id'];
     $user = UserModel::model()->getRowFromPk($id);
     $inject = false;
     if ($user) {
         if (BTAuth::authUser()->isAdmin()) {
             //allow super admin to view anyone
             $inject = true;
         }
     }
     if ($inject) {
         setcookie("user_inject", $id, time() + 60 * 60 * 24, "/", $_SERVER['HTTP_HOST']);
         header("Location: /overview");
     } else {
         setcookie("user_inject", '', time() - 60 * 60 * 24, "/", $_SERVER['HTTP_HOST']);
         header("Location: /overview");
     }
 }