当前位置: 首页>>代码示例>>PHP>>正文


PHP UserProfile::setUser方法代码示例

本文整理汇总了PHP中UserProfile::setUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserProfile::setUser方法的具体用法?PHP UserProfile::setUser怎么用?PHP UserProfile::setUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserProfile的用法示例。


在下文中一共展示了UserProfile::setUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionRegister

 /**
  * Creates account for new users
  */
 public function actionRegister()
 {
     if (!Yii::app()->user->isGuest) {
         Yii::app()->request->redirect('/');
     }
     $user = new User('register');
     $profile = new UserProfile();
     if (Yii::app()->request->isPostRequest && isset($_POST['User'], $_POST['UserProfile'])) {
         $user->attributes = $_POST['User'];
         $profile->attributes = $_POST['UserProfile'];
         $valid = $user->validate();
         $valid = $profile->validate() && $valid;
         if ($valid) {
             $user->save();
             $profile->save();
             $profile->setUser($user);
             // Add user to authenticated group
             Yii::app()->authManager->assign('Authenticated', $user->id);
             $this->addFlashMessage(Yii::t('UsersModule.core', 'Спасибо за регистрацию на нашем сайте.'));
             // Authenticate user
             $identity = new UserIdentity($user->username, $_POST['User']['password']);
             if ($identity->authenticate()) {
                 Yii::app()->user->login($identity, Yii::app()->user->rememberTime);
                 Yii::app()->request->redirect($this->createUrl('/users/profile/index'));
             }
         }
     }
     $this->render('register', array('user' => $user, 'profile' => $profile));
 }
开发者ID:kolbensky,项目名称:rybolove,代码行数:32,代码来源:RegisterController.php

示例2: getAllFriends

 public function getAllFriends(User $user)
 {
     $con = Connection::createConnection();
     $result = mysql_query("SELECT u1.id as user_id, u1.username as user_name, u2.* FROM user u1, userprofile u2 where u1.id = u2.id AND u1.id != {$user->id}");
     $friendList = array();
     while ($row = mysql_fetch_array($result)) {
         $userProfile = new UserProfile();
         $tempUser = new User();
         //setting user
         $tempUser->id = $row['user_id'];
         $tempUser->username = $row['user_name'];
         $userProfile->setUser($tempUser);
         //Setting user profile
         $userProfile->id = $row['id'];
         $userProfile->age = $row['age'];
         $userProfile->country = $row['country'];
         $userProfile->favgame = $row['favgame'];
         $userProfile->humour = $row['humour'];
         $userProfile->imgurl = $row['imgurl'];
         $userProfile->job = $row['job'];
         $userProfile->language = $row['language'];
         $userProfile->politicalview = $row['politicalview'];
         $userProfile->religion = $row['religion'];
         $userProfile->school = $row['school'];
         array_push($friendList, $userProfile);
     }
     return $friendList;
 }
开发者ID:rahulkamra,项目名称:Artifact,代码行数:28,代码来源:FriendsDAO.php

示例3: getSpyQuestion

 public function getSpyQuestion($user, $gameProgress)
 {
     $con = Connection::createConnection();
     //first we need to check weather that person has spied him already or not
     $spy = ServerConstants::SPY;
     if ($this->canSpy($gameProgress)) {
         $friendUser = $gameProgress->friend->user;
         $result = mysql_query("select * from userprofile where userprofile.userid !={$friendUser->id} order by rand() limit 2");
         $dataArray = array();
         while ($row = mysql_fetch_array($result)) {
             $userprofile = new UserProfile();
             $userprofile->id = $row['id'];
             $userprofile->setUser($user);
             $userprofile->age = $row['age'];
             $userprofile->country = $row['country'];
             $userprofile->favgame = $row['favgame'];
             $userprofile->humour = $row['humour'];
             $userprofile->imgurl = $row['imgurl'];
             $userprofile->job = $row['job'];
             $userprofile->language = $row['language'];
             $userprofile->politicalview = $row['politicalview'];
             $userprofile->religion = $row['religion'];
             $userprofile->school = $row['school'];
             array_push($dataArray, $userprofile);
         }
         /* Getting data of friend whom we want to spy i.e. the right options */
         $friendProfile = $gameProgress->friend;
         array_push($dataArray, $friendProfile);
         Connection::closeConnection($con);
         return $dataArray;
     } else {
         Connection::closeConnection($con);
         return null;
     }
 }
开发者ID:rahulkamra,项目名称:Artifact,代码行数:35,代码来源:GameDAO.php

示例4: getUserProfile

 /**
  *
  * @param <User> $user
  * @return <UserProfile>
  * @SQL Select * From userprofile Where userid=1
  */
 public function getUserProfile(User $user)
 {
     $con = Connection::createConnection();
     $result = mysql_query("Select * From userprofile Where userid={$user->id}");
     $tempArray = mysql_fetch_array($result);
     if (mysql_num_rows($result) == 1) {
         $userprofile = new UserProfile();
         $userprofile->id = $tempArray['id'];
         $userprofile->setUser($user);
         $userprofile->age = $tempArray['age'];
         $userprofile->country = $tempArray['country'];
         $userprofile->favgame = $tempArray['favgame'];
         $userprofile->humour = $tempArray['humour'];
         $userprofile->imgurl = $tempArray['imgurl'];
         $userprofile->job = $tempArray['job'];
         $userprofile->language = $tempArray['language'];
         $userprofile->politicalview = $tempArray['politicalview'];
         $userprofile->religion = $tempArray['religion'];
         $userprofile->school = $tempArray['school'];
     }
     Connection::closeConnection($con);
     return $userprofile;
 }
开发者ID:rahulkamra,项目名称:Artifact,代码行数:29,代码来源:UserProfileDAO.php


注:本文中的UserProfile::setUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。