本文整理汇总了PHP中UserProfile::model方法的典型用法代码示例。如果您正苦于以下问题:PHP UserProfile::model方法的具体用法?PHP UserProfile::model怎么用?PHP UserProfile::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserProfile
的用法示例。
在下文中一共展示了UserProfile::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProfileChange
public function testProfileChange()
{
Yii::import('application.modules.users.models.*');
$this->adminLogin();
// Set empty profile data
$this->open('users/profile');
$this->type('UserProfile[full_name]', '');
$this->type('User[email]', '');
$this->clickAtAndWait("//input[@type='submit' and @value='Сохранить']");
$this->assertTrue($this->isTextPresent('Необходимо заполнить поле «Полное Имя»'));
$this->assertTrue($this->isTextPresent('Необходимо заполнить поле «Email»'));
// Set normal random data
$time = time();
$this->type('UserProfile[full_name]', 'fullname' . $time);
$this->type('User[email]', 'admin.' . $time . '@localhost.loc');
$this->clickAtAndWait("//input[@type='submit' and @value='Сохранить']");
$this->assertTrue($this->isTextPresent('Изменения успешно сохранены.'));
// Check if data really saved
$profile = UserProfile::model()->findByAttributes(array('user_id' => 1));
$user = User::model()->findByAttributes(array('id' => 1));
$this->assertTrue($profile->full_name == 'fullname' . $time);
$this->assertTrue($user->email == 'admin.' . $time . '@localhost.loc');
// Change password
$this->type('ChangePasswordForm[current_password]', 'admin');
$this->type('ChangePasswordForm[new_password]', 'admin');
$this->clickAtAndWait("//input[@type='submit' and @value='Изменить']");
$this->assertTrue($this->isTextPresent('Пароль успешно изменен.'));
// Try to set wrong password
$this->type('ChangePasswordForm[current_password]', mt_rand(1, 10));
$this->clickAtAndWait("//input[@type='submit' and @value='Изменить']");
$this->assertTrue($this->isTextPresent('Ошибка проверки текущего пароля'));
}
示例2: actionShow
public function actionShow($id, $mid)
{
//$photos = Photos::model();
//$photo = $photos->findByPk($mid);
$ap = Bookmarks::model()->findAll(array('select' => 'content_id', 'condition' => 'owner_id = :id AND type = 1', 'params' => array(':id' => $id)));
$count = count($ap);
foreach ($ap as $ind => $ph) {
if ($ph['content_id'] == $mid) {
$num = $ind + 1;
if ($ind == 0) {
$prev = $ap[$count - 1]['content_id'];
} else {
$prev = $ap[$ind - 1]['content_id'];
}
if ($ind == $count - 1) {
$next = $ap[0]['content_id'];
} else {
$next = $ap[$ind + 1]['content_id'];
}
}
}
$aroundInfo = array('num' => $num, 'count' => $count, 'prev' => $prev, 'next' => $next);
$myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id);
$myPage = $id == Yii::app()->user->id;
$comments = Comments::model()->getLast('photos', $mid, 10);
$comments = array_reverse($comments);
$photo = Photos::model()->findByPk($mid);
$this->renderPartial('_show_photo', array('photo' => $photo, 'nav_link' => 'show', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'photos'));
}
示例3: actionShowPosts
public function actionShowPosts($id, $mid, $sid)
{
$posts = Posts::model()->findByPk($sid);
$multimedia = json_decode($posts->multimedia);
$count = count($multimedia);
foreach ($multimedia as $ind => $file) {
if ($file->nomber == $mid) {
$num = $ind + 1;
if ($ind == 0) {
$prev = $multimedia[$count - 1]->nomber . '/' . $sid;
} else {
$prev = $multimedia[$ind - 1]->nomber . '/' . $sid;
}
if ($ind == $count - 1) {
$next = $multimedia[0]->nomber . '/' . $sid;
} else {
$next = $multimedia[$ind + 1]->nomber . '/' . $sid;
}
$current_photo = $file;
}
}
$myPage = $id == Yii::app()->user->id;
$myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id);
$ext = Files::model()->findByPk($current_photo->id)->extension;
$aroundInfo = array('num' => $num, 'count' => $count, 'prev' => $prev, 'next' => $next);
$comments = Comments::model()->getLast('posts_' . $sid, $mid, 10);
$comments = array_reverse($comments);
$file = array('id' => $current_photo->id, 'file' => $current_photo->id, 'image' => array('extension' => $ext), 'description' => '', 'upload_date' => $current_photo->upload_date);
$this->renderPartial('show_photo', array('photo' => $file, 'nav_link' => 'showposts', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'posts_' . $sid, 'comments_item_id' => $mid));
}
示例4: actionProfile
public function actionProfile()
{
$id = Yii::app()->user->id;
if (!isset($_SESSION['filemanager'])) {
$_SESSION['filemanager'] = true;
}
$_SESSION['currentFolder'] = 'user/';
$model = $this->loadModel($id);
$modelProfile = UserProfile::model()->exists('userid=' . $id) ? UserProfile::model()->findByPk($id) : new UserProfile();
$role = Yii::app()->request->getPost('role');
$postUser = Yii::app()->request->getPost('User');
$postProfile = Yii::app()->request->getPost('UserProfile');
if (isset($postUser) && isset($postProfile)) {
Yii::import('application.modules.backend.controllers.UserController');
//do hàm contruct của UserController(extends controllers) lỗi ko cho phép null iduser nên thêm vào để ko xảy ra lỗi này
//mục đích là dùng dc hàm saveUserInfo trong UserController nên ko ảnh hưởng gì
$UserControllerTemp = new UserController(2);
if ($UserControllerTemp->saveUserInfo($model, $modelProfile, $postUser, $postProfile, $role, false)) {
Yii::app()->user->setFlash('success', Yii::t('user', 'Update user\'s info successfully.'));
} else {
Yii::app()->user->setFlash('error', Yii::t('user', 'Update user\'s info fail. Please try it later.'));
}
}
$this->render('profile', array('model' => $model, 'modelProfile' => $modelProfile, 'role' => User::model()->getRoleUser($model->id)));
}
示例5: actionDeleteuser
function actionDeleteuser($id)
{
$user = User::model()->findByPk($id);
$userProfile = UserProfile::model()->find('user_id=:id', array(':id' => $id));
$userProfile->delete();
$user->delete();
$this->redirect(array('admin/index'));
}
示例6: loadModel
/**
* 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 = UserProfile::model()->findByPk((int) $id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例7: actionIndex
public function actionIndex($id)
{
Yii::app()->clientScript->registerScript('global_user_id', 'var glUserId = ' . $id . ';', CClientScript::POS_HEAD);
$user = UserProfile::model()->getUserProfile($id);
$myPage = Yii::app()->user->id == $id;
$videos = Videos::model()->findAll('user_id=:id', array(':id' => $id));
$videos_count = count($videos);
$this->render('index', array('profile' => $user, 'myPage' => $myPage, 'videos' => $videos, 'videos_count' => $videos_count));
}
示例8: getDistrictBYUserid
public static function getDistrictBYUserid($user_id)
{
$value = UserProfile::model()->findByAttributes(array('user_id' => $user_id));
if (empty($value->district_id)) {
return 13;
} else {
return $value->district_id;
}
}
示例9: actionAdd
public function actionAdd()
{
MainUtil::checkLicenseLimit();
if (EnvUtil::submitCheck("userSubmit")) {
$origPass = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING);
$_POST["salt"] = StringUtil::random(6);
$_POST["password"] = !empty($origPass) ? md5(md5($origPass) . $_POST["salt"]) : "";
$_POST["createtime"] = TIMESTAMP;
$_POST["guid"] = StringUtil::createGuid();
$this->dealWithSpecialParams();
$data = User::model()->create();
$newId = User::model()->add($data, true);
if ($newId) {
UserCount::model()->add(array("uid" => $newId));
$ip = Ibos::app()->setting->get("clientip");
UserStatus::model()->add(array("uid" => $newId, "regip" => $ip, "lastip" => $ip));
UserProfile::model()->add(array("uid" => $newId));
if (!empty($_POST["auxiliarydept"])) {
$deptIds = StringUtil::getId($_POST["auxiliarydept"]);
$this->handleAuxiliaryDept($newId, $deptIds, $_POST["deptid"]);
}
if (!empty($_POST["auxiliarypos"])) {
$posIds = StringUtil::getId($_POST["auxiliarypos"]);
$this->handleAuxiliaryPosition($newId, $posIds, $_POST["positionid"]);
}
$newUser = User::model()->fetchByPk($newId);
$users = UserUtil::loadUser();
$users[$newId] = UserUtil::wrapUserInfo($newUser);
User::model()->makeCache($users);
OrgUtil::update();
OrgUtil::hookSyncUser($newId, $origPass, 1);
$this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("user/index"));
} else {
$this->error(Ibos::lang("Add user failed"), $this->createUrl("user/index"));
}
} else {
$deptid = "";
$manager = "";
$account = Ibos::app()->setting->get("setting/account");
if ($account["mixed"]) {
$preg = "[0-9]+[A-Za-z]+|[A-Za-z]+[0-9]+";
} else {
$preg = "^[A-Za-z0-9\\!\\@\\#\$\\%\\^\\&\\*\\.\\~]{" . $account["minlength"] . ",32}\$";
}
if ($deptid = EnvUtil::getRequest("deptid")) {
$deptid = StringUtil::wrapId(EnvUtil::getRequest("deptid"), "d");
$manager = StringUtil::wrapId(Department::model()->fetchManagerByDeptid(EnvUtil::getRequest("deptid")), "u");
}
$this->setPageTitle(Ibos::lang("Add user"));
$this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Organization"), "url" => $this->createUrl("department/index")), array("name" => Ibos::lang("User manager"), "url" => $this->createUrl("user/index")), array("name" => Ibos::lang("Add user"))));
$this->render("add", array("deptid" => $deptid, "manager" => $manager, "passwordLength" => $account["minlength"], "preg" => $preg));
}
}
示例10: init
public function init()
{
if (!Yii::app()->user->isGuest) {
if (is_null($this->user_id)) {
$this->user_id = Yii::app()->user->id;
}
//TODO: store name in session
$this->me = UserProfile::model()->find('user_id=:iid', array(':iid' => Yii::app()->user->id));
}
if (!is_null($this->user_id)) {
$this->users = $this->me->getFriends();
}
}
示例11: authenticate
/**
* 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()
{
// find user record by email address (username)
$UserLogin = UserLogin::model()->findByAttributes(array('LoginEmail' => $this->username, 'IsActive' => 1));
if ($UserLogin === null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} else {
if ($UserLogin->UserPassword !== md5($this->password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
$this->errorCode = self::ERROR_NONE;
// set user login ID
$this->userLoginID = $UserLogin->UserLoginID;
// assign user role in auth manager
$userRole = UserRole::model()->findByPk($UserLogin->UserRoleID)->RoleType;
$currentRoles = Yii::app()->authManager->getRoles($this->userLoginID);
if (!array_key_exists($userRole, $currentRoles)) {
// remove old role if role changes
if (!empty($currentRoles)) {
AuthAssignment::model()->deleteAll('userid = :userid', array('userid' => $this->userLoginID));
}
Yii::app()->authManager->assign($userRole, $this->userLoginID);
Yii::app()->authManager->save();
}
// UserProfile
//$UserProfile = UserProfile::model()->findByAttributes(array('UserLoginID'=>$UserLogin->UserLoginID));
$UserProfile = UserProfile::model()->with('companies')->findByAttributes(array('UserLoginID' => $UserLogin->UserLoginID));
// echo '<pre>';
// print_r($UserProfile);
// die();
// create session variables
$this->setState('fullName', sprintf('%s %s', $UserProfile->FirstName, $UserProfile->LastName));
// full user name
$this->setState('companyID', $UserProfile->CompanyID);
// user email
$this->setState('userProfileID', $UserProfile->UserProfileID);
// user email
$this->setState('email', $UserLogin->LoginEmail);
// user email
$this->setState('companyName', $UserProfile->companies->CompanyName);
// user email
$this->setState('agreeToTerms', $UserProfile->AgreeToTerms);
// user email
$this->setState('isFacilitator', $UserProfile->IsFacilitator);
// user email
$this->setState('UserRoleID', $UserLogin->UserRoleID);
// user email
}
}
return !$this->errorCode;
}
示例12: beforeAction
function beforeAction($action)
{
Yii::app()->clientScript->registerScriptFile('/static/js/jquery-ui/i18n.min.js');
Yii::app()->clientScript->registerScriptFile('/static/js/jquery-ui/i18n/' . Yii::app()->language . '.min.js');
parent::beforeAction($action);
if (Yii::app()->user->isGuest) {
if (Yii::app()->controller->action->id != 'login') {
$this->redirect(Yii::app()->createUrl('my/login', array('back' => urlencode(base64_encode($_SERVER['REQUEST_URI'])))));
}
} else {
$this->myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id);
}
return true;
}
示例13: actionShow
public function actionShow($id, $mid)
{
Yii::app()->clientScript->registerScript('global_user_id', 'var glUserId = ' . $id . ';', CClientScript::POS_HEAD);
$user = UserProfile::model()->getUserProfile($id);
$myPage = Yii::app()->user->id == $id;
if ($album = Albums::model()->find('user_id=:user_id AND id = :album_id', array('user_id' => $id, 'album_id' => $mid))) {
$model = Photos::model();
$photos = $model->LoadLimited($mid, 0);
$list = $this->renderPartial('//profile/aphotos/photos_list', array('photos' => $photos, 'user_id' => $id), true);
$this->render('photos', array('model' => $model, 'profile' => $user, 'myPage' => $myPage, 'album' => $album, 'photos_count' => count($photos), 'list' => $list));
} else {
echo 'Альбом не существует.';
}
}
示例14: getProfilePic
public static function getProfilePic()
{
$filename = Yii::app()->baseUrl . "/images/no-image.jpg";
if (isset(Yii::app()->session['login']['profImage']) && Yii::app()->session['login']['profImage'] != "") {
$filename = Yii::app()->baseUrl . "/images/uploads/profileimages/" . Yii::app()->session['login']['profImage'];
if (!file_exists(Yii::app()->basePath . "/../images/uploads/profileimages/" . Yii::app()->session['login']['profImage'])) {
$userprofile = UserProfile::model()->findByAttributes(array('user_id' => Yii::app()->session['login']['id']));
$filename = Yii::app()->baseUrl . "/images/uploads/profileimages/" . $userprofile->profile_image;
if (!file_exists(Yii::app()->basePath . "/../images/uploads/profileimages/" . $userprofile->profile_image)) {
$filename = Yii::app()->baseUrl . "/images/no-image.jpg";
}
}
}
return $filename;
}
示例15: actionIndex
public function actionIndex()
{
$model = UserProfile::model()->findByPk(Yii::app()->user->id);
if (isset($_POST['UserProfile'])) {
$model->attributes = $_POST['UserProfile'];
if ($model->validate()) {
if (isset($_FILES['UserProfile']['name']['image']) && is_uploaded_file($_FILES['UserProfile']['tmp_name']['image'])) {
$model->upload($_FILES['UserProfile']);
}
$model->save();
Yii::app()->user->setFlash('updateProfile', 'Info anda berhasil dirubah.');
}
}
$this->render('index', array('model' => $model));
}