/** * 登录后获取用户相关的用户信息为actionLogin方法提供使用 * @param int $UID */ private function getSuccess($UID = 0) { $userInfo = new Userinfo(); $userInfo->getInfo($UID); Yii::app()->session->add("USER_INFO", $userInfo->getInfo($UID)); return true; }
public function actionEditinfo() { $userinfoModel = new Userinfo(); $userInfo = $userinfoModel->findByPk(Yii::app()->session['uid']); if ($userInfo != NULL) { $userinfoModel = $userInfo; } if (isset($_POST['Userinfo'])) { $userinfoModel->attributes = $_POST['Userinfo']; if ($userinfoModel->validate()) { if ($userinfoModel->save()) { $this->redirect(array('myinfo')); } else { Yii::app()->user->setFlash('edituserinfoerror', 'Sorry,系统错误,修改失败。:('); $this->redirect(array('myinfo')); } } } $data = array("userinfoModel" => $userinfoModel); $this->render("editinfo", $data); }
public function postReading() { //Get the title from the url $title = urldecode(Request::segment(2)); //Get variables $comic = Comicbooks::series($title)->select('comicdb_books.id')->first(); $userExist = Userinfo::userbook(Auth::id(), $comic->id)->first(); //If the comic exists if (!is_null($comic->id)) { //If the user doesn't exist in the userinfo table (meaning they haven't marked anything as read/to read yet) if (is_null($userExist)) { //Add a new row of data for the user Userinfo::insert(array('book_id_FK' => $comic->id, 'user_id_FK' => Auth::id(), 'reading_status' => Input::get('reading_status'))); return Redirect::back(); } else { //Update the row of data for the user Userinfo::where('user_id_FK', '=', Auth::id())->where('book_id_FK', '=', $comic->id)->update(array('reading_status' => Input::get('reading_status'))); return Redirect::back(); } } else { return Redirect::back()->with('postMsg', 'An error occurred. Please try again.'); } }
/** * 学籍卡片 * @return array */ public function userinfo() { $userinfo = new Userinfo($this->cookie); return $userinfo->get(); }
/** * Remove a comicbook series from the database * DELETE /content/{title} * * @param string $title * @return Response */ public function destroy($title) { //Instance of Comicbooks model $comic = new Comicbooks(); $book_id = $comic->series($title)->select('comicdb_books.id')->distinct()->get(); $delete_comic = $comic->findOrFail($book_id[0]->id); //If the comicbook series exists if ($delete_comic) { //Delete any instance of it in the Userinfo table (tracks unread/to read list) Userinfo::where('book_id_FK', '=', $book_id[0]->id)->delete(); //Delete any instance of it in the comicbook issues table Comicissues::where('book_id', '=', $book_id[0]->id)->delete(); //Delete the comicbook series in the comicbook books table $delete_comic->delete($book_id[0]->id); return Redirect::to('browse')->with('postMsg', 'The book has been deleted.'); } else { return Redirect::to(URL::previous())->with('postMsg', 'Whoops! Looks like you got some errors.'); } }
public function saveInfo($id) { echo "<pre>"; print_r($_POST); die; if (isset($_POST['Userinfo']) && !empty($_POST['Userinfo'])) { if ($_POST['Userinfo']['form_type'] == "profession") { $post = new Userinfo(); $post->category_id = $_POST['Userinfo']['category_id']; $post->skill_levell = $_POST['Userinfo']['skill_levell']; $post->skill_id = $_POST['Userinfo']['skill_id']; $post->secondary_talent = $_POST['Userinfo']['secondary_talent']; $post->save(); } elseif ($_POST['Userinfo']['form_type'] == "basic") { //echo"<pre>";print_r($_POST);die; $post = new Userinfo(); //$post->name=$_POST['Userinfo']['name']; //$post->email=$_POST['Userinfo']['email']; $post->dob = $_POST['Userinfo']['phone']; $post->gender = $_POST['Userinfo']['gender']; $post->nationality = $_POST['Userinfo']['nationality']; $post->education = $_POST['Userinfo']['education']; $post->school_name = $_POST['Userinfo']['school_name']; $post->date = $_POST['Userinfo']['date']; $post->field_of_study = $_POST['Userinfo']['field_of_study']; $post->description = $_POST['Userinfo']['description']; $post->save(); //$userPost= new User(); $userPost = User::model()->findByPk(50); if (!empty($_POST['Userinfo']['name'])) { $userPost->first_name = $_POST['Userinfo']['name']; } if (!empty($_POST['Userinfo']['email'])) { $userPost->first_name = $_POST['Userinfo']['email']; } $userPost->save(); } elseif ($_POST['Userinfo']['form_type'] == "experience") { //echo"<pre>";print_r($_POST);die; $post = new Userinfo(); //$post->name=$_POST['Userinfo']['name']; //$post->email=$_POST['Userinfo']['email']; $post->company_name = $_POST['Userinfo']['company_name']; $post->position = $_POST['Userinfo']['position']; $post->experience = $_POST['Userinfo']['experience']; $post->exp_description = $_POST['Userinfo']['exp_description']; $post->save(); } elseif ($_POST['Userinfo']['form_type'] == "awards") { //echo"<pre>";print_r($_POST);die; $post = new Userinfo(); //$post->name=$_POST['Userinfo']['name']; //$post->email=$_POST['Userinfo']['email']; $post->award_title = $_POST['Userinfo']['award_title']; $post->award = $_POST['Userinfo']['award']; $post->year = $_POST['Userinfo']['year']; $post->award_description = $_POST['Userinfo']['award_description']; $post->save(); } elseif ($_POST['Userinfo']['form_type'] == "interests") { //echo"<pre>";print_r($_POST);die; $post = new Userinfo(); $post->interests = $_POST['Userinfo']['interests']; $post->save(); } elseif ($_POST['Userinfo']['form_type'] == "privacy") { //echo"<pre>";print_r($_POST);die; $post = new Userinfo(); $post->message = $_POST['Userinfo']['message']; $post->connect = $_POST['Userinfo']['connect']; $post->see_phone = $_POST['Userinfo']['see_phone']; $post->see_dob = $_POST['Userinfo']['see_dob']; $post->save(); } return true; } }
public function destroy($id) { //Message that's returned $msg = '<div class="alert alert-warning alert-dismissible col-md-12" role="alert"> <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> User Deleted! </div>'; //Delete userinfo with that user's data Userinfo::deleteUser($id); //Delete user User::findOrFail($id); User::destroy($id); return Redirect::to('admin')->with('message', $msg); }
public function actionUserinfoUpdate($id = 0) { if (!($resutl = $this->_validUserRequest($id))) { $this->redirect(array('user/view', 'id' => $id)); } $model = new Userinfo(); // uncomment the following code to enable ajax-based validation /* if(isset($_POST['ajax']) && $_POST['ajax']==='userinfo-UserinfoUpdate-form') { echo CActiveForm::validate($model); Yii::app()->end(); } */ if (isset($_POST['Userinfo'])) { try { $model = Userinfo::model()->with('userRel')->findByPk(Yii::app()->getId()); if ($model == NULL) { $model = new Userinfo(); $model->attributes = $_POST['Userinfo']; } else { $model->attributes = $_POST['Userinfo']; } if ($model->save()) { $this->render('view', array('model' => $model)); } else { $this->render('UserinfoUpdate', array('model' => $model)); } //echo '<pre>'; var_dump($model); echo '</pre>'; die(); } catch (Exception $e) { throw new CHttpException(404, 'The requested page does not exist.'); } } $this->render('UserinfoUpdate', array('model' => $model)); }
public function getSeries($book) { //Page Title $data['book_title'] = $book; //Get the first result of book series query $data['book'] = Comicbooks::series($book)->select('comicdb_books.id')->distinct()->first(); //If it's not null... if ($data['book']) { //Get book information $data['book_info'] = Comicbooks::series($book)->select('publisher_name', 'book_description')->distinct()->get(); $data['book_genre'] = Comicbooks::series($book)->select('genre_name')->distinct()->get(); $data['book_issues'] = Comicbooks::series($book)->select('issue_id', 'cover_image', 'book_id')->distinct()->get(); $data['book_characters'] = Comicbooks::bookcharacters($book)->select('character_name')->distinct()->get(); $comic = Comicbooks::series($book)->select('comicdb_books.id')->first(); $read = Userinfo::where('book_id_FK', $comic->id)->where('user_id_FK', Auth::id())->select('read_status', 'reading_status')->first(); //If read variable isn't empty if ($read != '') { switch ($read->read_status) { case 0: $data['read_msg'] = 'MARK AS READ'; $data['read_status'] = 1; break; case 1: $data['read_msg'] = 'MARK AS UNREAD'; $data['read_status'] = 0; break; } switch ($read->reading_status) { case 0: $data['reading_msg'] = 'ADD TO READLIST'; $data['reading_status'] = 1; break; case 1: $data['reading_msg'] = 'REMOVE FROM READLIST'; $data['reading_status'] = 0; break; } } else { $data['read_msg'] = 'MARK AS READ'; $data['read_status'] = 1; $data['reading_msg'] = 'ADD TO READLIST'; $data['reading_status'] = 1; } $this->layout->content = View::make('series', $data); } else { //Redirect to the error page if the book series it doesn't exist return Redirect::to('error'); } }
public function loadModelByUserId($id) { $model = Userinfo::model()->findByAttributes(array('user_id' => $id)); //throw new CHttpException(404,'The requested page does not exist.'); return $model; }
protected function getUserinfo($uid) { $userModel = new User(); $userInfoModel = new Userinfo(); $attr = array('condition' => "id=:id", 'params' => array(':id' => $uid)); $user = $userModel->find($attr); $attrInfo = array('condition' => "user_id=:id", 'params' => array(':id' => $uid)); $userInfo = $userInfoModel->find($attrInfo); $account['user'] = $user->getAttributes(); $account['info'] = $userInfo->getAttributes(); return $account; }
/** * 添加 User 后台用户 */ public function actionAdduser() { $UserModel = new Account(); $SQL = array('select' => 'name,id'); $DownList = Role::model()->findAll($SQL); $List = array(); foreach ($DownList as $key => $value) { $List[$value->id] = $value->name; } if ($_POST) { $Post = $_POST['Account']; $UserModel->roleId = $Post['roleId']; $UserModel->account = $Post['account']; $UserModel->password = $Post['password']; $UserModel->time = date('Y-m-d H:i:s', time()); $UserModel->type = 0; if ($UserModel->save(false)) { $UID = $UserModel->attributes['id']; $User = new Userinfo(); $User->accountId = $UID; $User->niekname = $Post['niekname']; $User->website = $Post['website']; $User->describe = $Post['describe']; $User->time = date('Y-m-d H:i:s', time()); $User->QQ = $Post['QQ']; if ($User->save(false)) { Yii::app()->user->setFlash('modify', '用户新增成功!'); } } } $this->render('add_user', array('Model' => $UserModel, 'List' => $List)); }