/** * 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)); }
public function callback() { if (!$this->fb->generateSessionFromRedirect()) { return Redirect::route('home')->with('flash_error', 'Failed to connect on Facebook.')->with('flash_color', '#c0392b'); } $user_fb = $this->fb->getGraph(); if (empty($user_fb)) { return Redirect::route('home')->with('flash_error', 'Failed to get data on Facebook.')->with('flash_color', '#c0392b'); } $user = User::whereUidFb($user_fb->getProperty('id'))->first(); if (empty($user)) { $user_profile = new UserProfile(); $user_profile->name = $user_fb->getProperty('name'); $user_profile->birthday = date(strtotime($user_fb->getProperty('birthday'))); $user_profile->photo = 'http://graph.facebook.com/' . $user_fb->getProperty('id') . '/picture?type=large'; $user_profile->save(); $user = new User(); $user->user_profile_id = $user_profile->id; $user->privilage = 1; $user->email = $user_fb->getProperty('email'); $user->uid_fb = $user_fb->getProperty('id'); $user->save(); } $user->access_token_fb = $this->fb->getToken(); $user->save(); Auth::login($user); return Redirect::route('home')->with('flash_error', 'Successfully logged in using Facebook.')->with('flash_color', '#27ae60'); }
public function actionAddcompany() { $companyModel = new Company(); $userLoginModel = new UserLogin(); $userProfileModel = new UserProfile(); if (isset($_POST['Company'])) { $companyModel->attributes = $_POST['Company']; $userLoginModel->attributes = $_POST['UserLogin']; $userProfileModel->attributes = $_POST['UserProfile']; if ($companyModel->validate()) { if ($companyModel->save()) { $userLoginModel->UserRoleID = 2; // $userLoginModel->LoginEmail = '*****@*****.**'; $userLoginModel->UserPassword = md5($userLoginModel->UserPassword); $userLoginModel->IsPasswordReset = 1; $userLoginModel->IsActive = 1; $userLoginModel->save(); $userProfileModel->UserLoginID = $userLoginModel->UserLoginID; $userProfileModel->CompanyID = $companyModel->CompanyID; // $userProfileModel->FirstName = 'Test'; // $userProfileModel->LastName = 'test'; $userProfileModel->AgreeToTerms = 0; $userProfileModel->IsFacilitator = 0; $userProfileModel->save(); $this->redirect(Yii::app()->createUrl('admin/setup', array('id' => $companyModel->CompanyID))); } } } $this->render('add-company', array('companyModel' => $companyModel, 'userLoginModel' => $userLoginModel, 'userProfileModel' => $userProfileModel)); }
public function save($username, $email, $password, $passwordConfirmation) { $user = new User($username, $email); $user->password = $password; $user->passwordConfirmation = $passwordConfirmation; try { $key = $user->save(); $profile = new UserProfile; $profile->user = $user; $profile->save(); $mail = $this->mail(); $mail->username = $username; $mail->activationURL = CoOrg::createFullURL(array('user/activate', $username, $key)); $mail->site = CoOrg::config()->get('site/title'); $mail->to($email)->subject(t('Complete your registration')) ->send('mails/registration'); $this->notice(t('We have sent an email to confirm your registration')); $this->redirect('/'); } catch (ValidationException $e) { $this->error(t('We could not complete your registration')); $this->user = $user; $this->render('create'); } }
public function postAdminAccount() { $data = Input::all(); //return View::make('install.done'); try { $user = Sentry::createUser(array('email' => $data['email'], 'password' => $data['password'], 'activated' => true, 'first_name' => $data['first_name'], 'last_name' => $data['last_name'])); $group = Sentry::findGroupByName('admin'); $user->addGroup($group); $quicknote = new \Quicknote(); $quicknote->user_id = $user->id; $quicknote->save(); $userProfile = new \UserProfile(); $userProfile->id = $user->id; $userProfile->save(); $imageResult = App::make('AuthController')->{'createUserImage'}($user->id, $data['first_name'][0], $data['last_name'][0]); $installationDate = date('Y-m-d H:i:s'); $installationHost = Request::server('PATH_INFO'); $new92fiveConfig = new NewConfig(); $new92fiveConfig->toFile(app_path() . '/config/92five.php', ['install' => true, 'version' => '1.0', 'installationDate' => $installationDate, 'installationHost' => $installationHost]); return View::make('install.done'); } catch (Exception $e) { Log::error('Something Went Wrong in Install Controller Repository - addUserWithDetails():' . $e->getMessage()); throw new Exception('Something Went Wrong in Install Controller Repository - addUserWithDetails()'); } }
public function run() { $model = new UserProfile(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['UserProfile'])) { $model->attributes = $_POST['UserProfile']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function nullableFieldsSavedAsNull() { $user = new UserProfile(); $user->facebook_profile = ' '; $user->twitter_profile = 'michaeldyrynda'; $user->linkedin_profile = ''; $user->array_casted = []; $user->save(); $this->assertSame(' ', $user->facebook_profile); $this->assertSame('michaeldyrynda', $user->twitter_profile); $this->assertNull($user->linkedin_profile); $this->assertNull($user->array_casted); $this->assertNull(null); }
/** * @return bool */ public function install() { if ($this->hasErrors()) { return false; } $config = (require Yii::getPathOfAlias('application.config') . DIRECTORY_SEPARATOR . 'main.php'); $conn = new CDbConnection($config['components']['db']['connectionString'], $config['components']['db']['username'], $config['components']['db']['password']); $conn->charset = 'utf8'; Yii::app()->setComponent('db', $conn); $model = User::model()->findByPk(1); if (!$model) { $model = new User(); } // Set user data $model->username = $this->adminLogin; $model->email = $this->adminEmail; $model->password = $this->adminPassword; $model->created_at = date('Y-m-d H:i:s'); $model->last_login = date('Y-m-d H:i:s'); $model->save(false); // Create user profile $profile = new UserProfile(); $profile->user_id = $model->id; $profile->full_name = $model->username; $profile->save(); // Translate attributes $attrsData = array('Rms power' => 'Суммарная мощность', 'Monitor dimension' => 'Разрешение', 'Corpus material' => 'Материал', 'View angle' => 'Угол обзора', 'Sound type' => 'Тип', 'Manufacturer' => 'Производитель', 'Processor manufacturer' => 'Тип процессора', 'Phone platform' => 'Платформа', 'Freq' => 'Частота процессора', 'Phone weight' => 'Вес', 'Memmory' => 'Объем памяти', 'Phone display' => 'Диагональ', 'Memmory type' => 'Тип памяти', 'Phone camera' => 'Камера', 'Screen' => 'Диагональ', 'Tablet screen size' => 'Диагональ', 'Video' => 'Видео', 'Memmory size' => 'Объем памяти', 'Screen dimension' => 'Разрешение', 'Monitor diagonal' => 'Диагональ', 'Weight' => 'Вес'); foreach ($attrsData as $key => $val) { Yii::app()->db->createCommand("UPDATE StoreAttributeTranslate SET title='{$val}' WHERE title='{$key}'")->execute(); } // Translate product types $typesData = array('laptop' => 'Ноутбук', 'computer_sound' => 'Акустика', 'monitor' => 'Монитор', 'phone' => 'Телефон', 'tablet' => 'Планшет'); foreach ($typesData as $key => $val) { Yii::app()->db->createCommand("UPDATE StoreProductType SET name='{$val}' WHERE name='{$key}'")->execute(); } // Display all attributes on compare page Yii::app()->db->createCommand("UPDATE StoreAttribute SET use_in_compare=1")->execute(); $filters = array('processor_manufacturer', 'screen', 'corpus_material', 'sound_type', 'monitor_diagonal', 'phone_platform'); foreach ($filters as $name) { Yii::app()->db->createCommand("UPDATE StoreAttribute SET use_in_filter=1 WHERE name='{$name}'")->execute(); } // Update site settings $siteName = Yii::app()->db->quoteValue($this->siteName); Yii::app()->db->createCommand("UPDATE SystemSettings t SET t.value={$siteName} WHERE t.key='siteName'")->execute(); Yii::app()->db->createCommand("UPDATE SystemSettings t SET t.value='12,18,24' WHERE t.key='productsPerPage'")->execute(); Yii::app()->db->createCommand("UPDATE SystemSettings t SET t.value='30' WHERE t.key='productsPerPageAdmin'")->execute(); $this->createDiscount(); $this->createPopularProducts(); return true; }
public static function registerUser($input) { $confirmation_code = str_random(30); $input = (object) $input; $user = new \User(); $user->role = '5'; $user->username = $input->username; $user->email = $input->email; $user->password = \Hash::make($input->password); $user->confirmation_code = $confirmation_code; $user->save(); $profile = new \UserProfile(); $profile->id_user = $user->id; $profile->save(); \Mail::send('warauth::emails.verify.verify', ['confirmation_code' => $confirmation_code], function ($message) use($user) { $message->to($user->email, $user->username)->subject('verification your email address'); }); \Session::flash('register', 'Thanks for sign up to squidrop please check your email addres<br/>for verification your account.'); }
public function testProfile() { $profile = new UserProfile; $profile->user = User::getUserByName('no-profile'); $profile->gender = PROPERTY_GENDER_MALE; $profile->birthDate = '2010-3-21'; try { $profile->save(); } catch (ValidationException $e) { var_dump($profile->avatar_error); } $user = User::getUserByName('no-profile'); $userP = $user->profile; $this->assertEquals(PROPERTY_GENDER_MALE, $userP->gender); $this->assertEquals('2010-03-21', date('Y-m-d', $userP->birthDate)); $this->assertNull($userP->firstName); $this->assertNull($userP->lastName); $this->assertNull($userP->intrests); $this->assertNull($userP->website); $this->assertNull($userP->biography); $userP->firstName = 'No'; $userP->lastName = 'Profile'; $userP->intrests = 'Reading, Programming, Opensource, and more'; $userP->biography = 'A user without profile (not anymore)'; $userP->website = 'somesite.in.the.wild/some/link'; $userP->save(); $profile = UserProfile::get('no-profile'); $this->assertEquals('No', $userP->firstName); $this->assertEquals('Profile', $userP->lastName); $this->assertEquals('Reading, Programming, Opensource, and more', $userP->intrests); $this->assertEquals('http://somesite.in.the.wild/some/link', $userP->website); $this->assertEquals('A user without profile (not anymore)', $userP->biography); }
/** * {@inheritDoc} * @see PluggableUserModule::createUserProfile() */ public function createUserProfile(IPluggableWebUser $user) { try { $profile = new UserProfile(); $profile->user_status_id = 'ACT'; $profile->pseudo = $user->getName(); $profile->hash = sha1($user->getName()); $profile->created = date('Y-m-d H:i:s'); if ($profile->save()) { // no user record needed return $profile; } } catch (CException $e) { // silent } return null; }
echo "<script>window.opener.location.href='" . Yii::app()->baseUrl . "/index.php/user/dashboard/';window.close();</script>"; } else { $length = 06; $chars = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z')); shuffle($chars); $password = implode(array_slice($chars, 0, $length)); $model = new User(); $model->username = $user->name; $model->password = $password; $model->email = $user->email; $model->user_type = 1; $model->is_active = 1; $model->save(); $Id = Yii::app()->db->getLastInsertId(); $profile_pic = "http://graph.facebook.com/" . $user->id . "/picture"; $userProfile = new UserProfile(); $userProfile->user_id = $Id; $userProfile->first_name = $user->first_name; $userProfile->last_name = $user->last_name; $userProfile->image = $profile_pic; $userProfile->join_date = date('Y-m-d'); $userProfile->save(false); Yii::app()->request->cookies['username'] = new CHttpCookie('username', $user->name); Yii::app()->request->cookies['userId'] = new CHttpCookie('userId', $Id); Yii::app()->request->cookies['userType'] = new CHttpCookie('userType', 1); Yii::app()->user->setFlash('success', "You Are Now Logged With Facebook Account"); echo "<script>window.opener.location.href='" . Yii::app()->baseUrl . "/index.php/user/dashboard/';window.close();</script>"; } } else { echo "The state does not match. You may be a victim of CSRF."; }
protected function createUserAndProfile($username, $con = null) { // no user with this username if (null === $con) { $con = Propel::getConnection(sfGuardUserPeer::DATABASE_NAME); } try { $con->begin(); // create a new user object $user = new sfGuardUser(); $user->setUsername($username); $user->setIsActive(1); $user->setAlgorithm(''); $user->save($con); // do we have a profile in the system with this net_id? // this could happen if the profile was added manually by an admin $userProfile = UserProfilePeer::selectByNetIdWithNoUserId($username); if ($userProfile) { // there is already a dangling user profile with this net id, link the user with the profile $userProfile->setUserId($user->getId()); $userProfile->save($con); } else { // make a new user profile $userProfile = new UserProfile(); $userProfile->setUserId($user->getId()); $userProfile->setNetId($user->getUsername()); $userProfile->save($con); } $con->commit(); } catch (PropelException $e) { $con->rollback(); throw $e; } return $user; }
public function actionLogin() { if (!Yii::app()->user->isGuest) { $this->redirect(Yii::app()->createUrl('id' . Yii::app()->user->id)); } $this->layout = 'authorization'; $model = new LoginForm(); $user = new User(); $profile = new UserProfile(); // if it is ajax validation request if (isset($_POST['ajax']) && $_POST['ajax'] === 'register-form') { echo CActiveForm::validate($user); Yii::app()->end(); } if (isset($_POST['User'])) { $user->attributes = $_POST['User']; $user->salt = time(); $user->login = $user->email; $password = $user->password; if ($_POST['password_repeat'] != $user->password) { $user->addError('password', 'Пароли не совпадают'); } if (isset($_POST['UserProfile'])) { $profile->attributes = $_POST['UserProfile']; $profile->birth_date = mktime(0, 0, 0, (int) $_POST['UserProfile']['birth_date'][1], (int) $_POST['UserProfile']['birth_date'][0], (int) $_POST['UserProfile']['birth_date'][2]); } $profile->scenario = 'register'; if (!$user->hasErrors() && $profile->validate() && $user->save()) { //TODO: $user->validate() $profile->tryGravatar = true; $profile->third_name = ''; $profile->city_id = '1'; $profile->family = '0'; $profile->user_id = $user->id; $profile->save(); } $_POST['LoginForm'] = array('login' => $user->email, 'password' => $password); } // collect user input data if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; // validate user input and redirect to the previous page if valid if ($model->validate() && $model->login()) { if (!isset($_GET['back'])) { $this->redirect(Yii::app()->createUrl('id' . Yii::app()->user->id)); } else { $this->redirect(base64_decode(urldecode($_GET['back']))); } } } // display the login form $this->render('login', array('model' => $model, 'user' => $user, 'profile' => $profile)); }
/** * Creates a new User Login. * If creation is successful, the browser will be redirected to the 'index' page. * author wawan */ public function actionCreateUser() { $model = new Userlogin(); $user_profile = new UserProfile(); //componen user option $profile = Yii::$app->getUserOpt->Profile_user(); $usercreate = $profile->username; $model->scenario = Userlogin::SCENARIO_USER; if ($model->load(Yii::$app->request->post()) && $user_profile->load(Yii::$app->request->post())) { $post = Yii::$app->request->post(); $datapostion = $post['Userlogin']['POSITION_LOGIN']; if ($datapostion == 1) { $auth = "SALESMAN"; // auth key untuk salesmen } elseif ($datapostion == 2) { $auth = "SALES PROMOTION"; // auth key untuk sales promotion } elseif ($datapostion == 3) { $auth = "CUSTOMER"; // auth key untuk Customers } elseif ($datapostion == 4) { $auth = "DISTRIBUTOR"; // auth key untuk Customers } elseif ($datapostion == 5) { $auth = "FACTORY PABRIK"; // auth key untuk Customers } elseif ($datapostion == 6) { $auth = "OUTSOURCE"; // auth key untuk Customers } $model->POSITION_LOGIN = $datapostion; $model->POSITION_SITE = "CRM"; // untuk login crm $pass = $model->password_hash; $security = Yii::$app->security->generatePasswordHash($pass); $authkey = Yii::$app->security->generatePasswordHash($auth); $model->password_hash = $security; $model->auth_key = $authkey; $model->save(); $user_profile->ID_USER = $model->id; $user_profile->CREATED_BY = $usercreate; $user_profile->CREATED_AT = date("Y-m-d H:i:s"); $user_profile->save(); return $this->redirect(['index?tab=4']); } else { return $this->renderAjax('_usercreate', ['model' => $model, 'user_profile' => $user_profile]); } }
public function executeEdit($request) { $userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', null, 'subscriber'); $this->miles = true; $this->kilo = false; if ($userId) { $this->user = UsersPeer::retrieveByPK($userId); } $this->forward404Unless($this->user); if ($this->user) { $profile = UserProfilePeer::retrieveByPK($this->user->getUserId()); if ($profile->getMiles() == 1) { $this->miles = true; $this->kilo = false; } else { $this->miles = false; $this->kilo = true; } } if (!$profile) { $profile = new UserProfile(); $profile->setUserId($this->user->getUserId()); $profile->setMiles(1); } $this->user->setUserProfile($profile); if ($request->isMethod('post')) { $userName = $this->getRequestParameter('userName'); $fname = $this->getRequestParameter('fname'); $lname = $this->getRequestParameter('lname'); $email = $this->getRequestParameter('email'); $bday = join("/", $this->getRequestParameter('bday')); $weight = $this->getRequestParameter('weight'); $height = $this->getRequestParameter('height'); $zip = $this->getRequestParameter('zip'); $units = $this->getRequestParameter('units'); $country = $this->getRequestParameter('country'); $city = $this->getRequestParameter('city'); $state = $this->getRequestParameter('state'); // sfContext::getInstance()->getLogger()->info($message); //make sure have profile if (!$this->user->getUserProfile()) { $profile = UserProfilePeer::retrieveByPK($user->getUserId()); if ($profile) { $this->user->setUserProfile($profile); } else { $profile = new UserProfile(); $profile->setUserId($user->getUserId()); $profile->setMiles(1); $profile->save(); $this->user->setUserProfile($profile); } } // pre-populate country, state and city in order to filter select boxes $profile = $this->user->getUserProfile(); //set up profile data $profile->setBirthdate($bday); $profile->setWeight($weight); $profile->setHeight($height); $profile->setZip($zip); $profile->setCountry($country); $profile->setState($state); $profile->setCity($city); if ($units && count($units) > 0) { $u = $units[0]; if ($u == "kilo") { $profile->setMiles(0); } else { $profile->setMiles(1); } } else { $profile->setMiles(1); } //set up user $this->user->setUsername($userName); $this->user->setFname($fname); $this->user->setLname($lname); $this->user->setEmail($email); $this->user->setUserProfile($profile); $this->user->save(); $profile->save(); //set mileage preference $this->getUser()->setAttribute('mileage', $profile->getMiles(), 'subscriber'); return $this->redirect('users/profile'); } }
public function actionSignup() { $model = new User(); //uncomment the following code to enable ajax-based validation if (isset($_POST['ajax']) && $_POST['ajax'] === 'user-signup-form') { echo CActiveForm::validate($model); Yii::app()->end(); } if (isset($_POST['User'])) { $model->attributes = $_POST['User']; //print_r($model->attributes); return; if ($model->validate()) { $model->password = md5($_POST['User']['password']); $model->is_active = 1; if ($model->save()) { $userId = Yii::app()->db->getLastInsertID(); $userprofile = new UserProfile(); $userprofile->user_id = $userId; $userprofile->join_date = date('Y-m-d'); $userprofile->save(false); /*$email = Yii::app()->email; $email->from = '*****@*****.**'; $email->to = $model->email; $email->subject = "Welcome"; $email->message = "Welcome in Social Property"; $email->send();*/ echo '<script type="text/javascript">window.top.location.href = "' . Yii::app()->baseUrl . '"; </script>'; } } } $this->layout = 'empty'; $this->render('signup', array('model' => $model)); }
public function actionIsSkip() { $userid = Yii::app()->session['login']['id']; $newprofile = UserProfile::model()->findByAttributes(array('user_id' => $userid)); if (isset($newprofile)) { $newprofile->updatedby = $userid; $newprofile->updateddate = date('Y-m-d G:i:s'); } else { $newprofile = new UserProfile(); $newprofile->user_id = $userid; $newprofile->createdby = $userid; $newprofile->createddate = date('Y-m-d G:i:s'); $newprofile->updatedby = $userid; $newprofile->updateddate = date('Y-m-d G:i:s'); } $skip = $_POST['skip']; $newprofile->IsCompleted = $skip; $newprofile->save(false); $finaos = UserFinao::model()->findByAttributes(array('userid' => $userid)); if (isset($finaos)) { echo "motivationmesg"; } else { echo "newfinao"; } }
public function actionChangePic() { $id = Yii::app()->session['login']['id']; $name = $_FILES['file']['tmp_name']; $b = Yii::getPathOfAlias('application'); $numb = rand(); //$model= UserProfile::model()->findByAttributes(array('user_id'=>$id)); if (isset($_POST['usertileid'])) { $usertileid = $_POST['usertileid']; $model = TilesInfo::model()->findByAttributes(array('tile_id' => $usertileid, 'createdby' => $id)); $tilename = $_POST['tilename']; $c = str_replace('protected', 'images/tiles', $b); $filename = "temptile-" . $id . "-" . $numb . "-" . str_replace(' ', '', $tilename) . ".jpg"; } else { $model = UserProfile::model()->findByAttributes(array('user_id' => $id)); if (empty($model)) { $model = new UserProfile(); $model->createdby = $id; $model->createddate = date('Y-m-d G:i:s'); $model->updatedby = $id; $model->updateddate = date('Y-m-d G:i:s'); } else { /*if($model->profile_bg_image != "") { if(file_exists("images/uploads/backgroundimages/".$model->profile_bg_image)) unlink("images/uploads/backgroundimages/".$model->profile_bg_image); }*/ $model->updatedby = $id; $model->updateddate = date('Y-m-d G:i:s'); $c = str_replace('protected', 'images/uploads/backgroundimages', $b); $filename = "tempbg-" . $id . "-" . $numb . "-" . str_replace(' ', '', $_FILES["file"]["name"]); } } /*$name = $_FILES['file']['tmp_name']; $b=Yii::getPathOfAlias('application'); $numb = rand(); $c=str_replace('protected','images/uploads/backgroundimages',$b); //$model->profile_bg_image = $id."-".str_replace(' ','',$_FILES["file"]["name"]); $filename = "tempbg-" .$id."-".$numb."-".str_replace(' ','',$_FILES["file"]["name"]); */ if (isset($_POST['usertileid'])) { $filepath = $c . "/" . $filename; //echo $filepath; //exit; $model->temp_tile_imageurl = $filename; //$model->user_id = $id; $model->save(false); move_uploaded_file($_FILES["tileimagefile"]["tmp_name"], $filepath); //move_uploaded_file(str_replace(' ','',$tilename),$filepath); } else { $filepath = $c . "/" . $filename; $model->temp_profile_bg_image = $filename; $model->user_id = $id; if ($model->save(false)) { $login = Yii::app()->session['login']; $login["bgImage"] = $model->profile_bg_image; Yii::app()->session['login'] = $login; } move_uploaded_file($_FILES["file"]["tmp_name"], $filepath); //print_r($model->image_name); //exit; } chmod($filepath, 0777); if (file_exists($filepath)) { list($sourceWidth, $sourceHeight) = getimagesize($filepath); if (isset($_POST['usertileid'])) { if ($sourceWidth >= 440 && $sourceHeight >= 320) { if ($sourceWidth == 440 && $sourceHeight == 320) { if ($model->tile_imageurl != "" && $model->Is_customtile == 1) { if (file_exists(Yii::app()->basePath . "/../images/tiles/" . $model->tile_imageurl)) { unlink(Yii::app()->basePath . "/../images/tiles/" . $model->tile_imageurl); } } $model->tile_imageurl = $filename; if ($model->save(false)) { if (file_exists(Yii::app()->basePath . "/../images/tiles/" . $model->temp_tile_imageurl)) { unlink(Yii::app()->basePath . "/../images/tiles/" . $model->temp_tile_imageurl); } $this->redirect(Yii::app()->createUrl('finao/motivationmesg')); } } else { if ($sourceWidth > 440) { $ext = substr(strrchr($model->temp_tile_imageurl, '.'), 1); $ext = strtolower($ext); $this->createImagetofixbodysize(Yii::app()->basePath . "/../images/tiles/" . $model->temp_tile_imageurl, 600, $ext); } $this->redirect(Yii::app()->createUrl('finao/motivationmesg', array('tileimageupload' => $model->tile_id))); } } else { $this->redirect(Yii::app()->createUrl('finao/motivationmesg', array('tileerrormesg' => $model->tile_id))); } } else { if ($sourceWidth >= 980 && $sourceHeight >= 350) { if ($sourceWidth == 980 && $sourceHeight == 350) { if ($model->profile_bg_image != "") { if (file_exists(Yii::app()->basePath . "/../images/uploads/backgroundimages/" . $model->profile_bg_image)) { unlink(Yii::app()->basePath . "/../images/uploads/backgroundimages/" . $model->profile_bg_image); } } $model->profile_bg_image = $filename; if ($model->save(false)) { if (file_exists(Yii::app()->basePath . "/../images/uploads/backgroundimages/" . $model->temp_profile_bg_image)) { unlink(Yii::app()->basePath . "/../images/uploads/backgroundimages/" . $model->temp_profile_bg_image); } $this->redirect(Yii::app()->createUrl('finao/motivationmesg')); } } else { /** Fixing width size to body container **/ if ($sourceWidth > 1000) { $ext = substr(strrchr($model->temp_profile_bg_image, '.'), 1); $ext = strtolower($ext); $this->createImagetofixbodysize(Yii::app()->basePath . "/../images/uploads/backgroundimages/" . $model->temp_profile_bg_image, 1000, $ext); } $this->redirect(Yii::app()->createUrl('finao/motivationmesg', array('imgupload' => 1))); } } else { $this->redirect(Yii::app()->createUrl('finao/motivationmesg', array('errormsg' => 1))); } } } }
public function save() { if ($this->validate()) { $changed = false; if ($this->is_new) { $this->password = $this->hashPassword($this->password); $this->password_confirmation = $this->password; $this->activation_code = md5(time() . $this->nickname . $this->email . rand(10000, 99999)); $this->cookie = md5(time() . $this->nickname . $this->email . $this->activation_code . rand(10000, 99999)); $this->version = 1; $changed = true; } else { if ($this->changed_password) { $this->password = $this->hashPassword($this->password); $this->password_confirmation = $this->password; } if (!$this->cookie) { $this->cookie = md5(time() . $this->nickname . $this->email . $this->activation_code . rand(10000, 99999)); } // Update version if ($this->calculateHash() != $this->hash) { $this->version++; $changed = true; } } if ($this->activated && !$this->affiliate_code) { $this->affiliate_code = uniqid(); } $result = parent::save(self::table); if ($result) { if ($changed) { Website::triggerAll($this); } $this->sync_forums(); if ($this->activated and $this->allow_emails) { $this->newzapp_signup(); } $id = mysql_real_escape_string($this->id); $user_profile = UserProfile::find("user_profiles.user_id = '{$id}'"); if (!$user_profile) { // Create a profile for the user $user_profile = new UserProfile(); $user_profile->user_id = $this->id; $user_profile->save(); } } return $result; } else { return false; } }
public function actionCreate() { // check permissions // if (!Yii::app()->user->checkAccess('manageUser')) { // Helper::authException(); // } // models $UserLogin = new UserLogin(); $UserProfile = new UserProfile(); $criteria3 = new CDbCriteria(); $criteria3->condition = '(companyID = :companyID AND IsActive=1)'; $criteria3->params = array(':companyID' => Yii::app()->user->companyID); $criteria3->order = 'Email'; $userManagers = UserProfile::model()->with('userLogin')->findAllByAttributes(array(), $criteria3); $managersArray = array(); $managersArray[0] = "Please Select..."; foreach ($userManagers as $UserManager) { //if ($UserManager->ManagerEmail == '') { //$managersArray[$UserManager->Email] = $UserManager->Email; $managersArray[$UserManager->Email] = $UserManager->Email; //} elseif (Helper::hasRole('lacekAdministrator')) { // $rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc; // } } // add default (empty value) to front of array $managerArray = $managersArray; // role array for select $userRoles = UserRole::model()->findAll(); $rolesArray = array(); foreach ($userRoles as $UserRole) { if ($UserRole->RoleType != 'lacekAdministrator') { $rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc; } elseif (Helper::hasRole('lacekAdministrator')) { $rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc; } } // add default (empty value) to front of array $rolesArray = $rolesArray; // form processing if (isset($_POST['UserLogin'], $_POST['UserProfile'])) { // redirect to the dashboard if 'Cancel' button clicked if (isset($_POST['button-cancel'])) { $this->redirect($this->createUrl('user/dashboard')); } // set UserLogin attributes and scenario $UserLogin->attributes = $_POST['UserLogin']; $UserLogin->IsPasswordReset = 1; // force password reset on first login $UserLogin->IsActive = 1; $UserLogin->scenario = 'create'; $UserLogin->UserRoleID = 1; // set UserProfile attributes $UserProfile->attributes = $_POST['UserProfile']; $UserProfile->CompanyID = Yii::app()->user->companyID; $UserProfile->Email = $UserLogin->LoginEmail; // validate form submission $valid = $UserLogin->validate(); $valid = $UserProfile->validate() && $valid; if ($valid) { // save UserLogin if (!$UserLogin->save(false)) { throw new CHttpException(400, 'Error when trying to create user.'); } // save UserProfile $UserProfile->UserLoginID = $UserLogin->UserLoginID; // set newly generated EventID if (!$UserProfile->save(false)) { throw new CHttpException(400, 'Error when trying to create user.'); } if ($UserProfile->ManagerEmail) { $UserProfilex = UserProfile::model()->findByAttributes(array('Email' => $UserProfile->ManagerEmail)); $candidateModel = new Candidate(); $candidateModel->CompanyID = $UserProfile->CompanyID; $candidateModel->EmployeeID = $UserProfile->EmployeeID; $candidateModel->FirstName = $UserProfile->FirstName; $candidateModel->MiddleName = $UserProfile->MiddleName; $candidateModel->LastName = $UserProfile->LastName; $candidateModel->Title = $UserProfile->Title; $candidateModel->Email = $UserProfile->Email; $candidateModel->CompanyPositionID = 1; $candidateModel->HireDate = date("Y-m-d"); $candidateModel->PositionDate = date("Y-m-d"); $candidateModel->IsActive = 1; $candidateModel->UserProfileID = $UserProfilex->UserProfileID; //$candidateModel->UserProfileId=2; //print_r($candidateModel); // die($UserProfilex->UserProfileID); // if ($candidateModel->validate()) { // if ($candidateModel->save()) { $candidateModel->save(); $performanceModel = new Performance(); $ratingModel = new Rating(); $planningModel = new Planning(); $currentYear = date('Y'); // insert new record $performanceModel->CandidateID = $candidateModel->CandidateID; $performanceModel->PerformanceYear = $currentYear; $ratingModel->CandidateID = $candidateModel->CandidateID; $ratingModel->RatingYear = $currentYear; $planningModel->CandidateID = $candidateModel->CandidateID; $planningModel->PlanningYear = $currentYear; $planningModel->CurrentPositionLevel = 3; $planningModel->NextStepPositionLevel = 3; $planningModel->LongTermPositionLevel = 3; $performanceModel->save(); $ratingModel->save(); $planningModel->save(); //} //} // else //{ // $errores = $candidateModel->getErrors(); // print_r($errores); // die(); // } } // set success message for user Yii::app()->user->setFlash('success', 'A new user was successfully created.'); // return to empty create user form if adding another, else go to user dashboard if (isset($_POST['button-submit-add'])) { $this->redirect($this->createUrl('user/create')); } else { $this->redirect($this->createUrl('user/dashboard')); } } } // clear password $UserLogin->UserPassword = null; // render view $this->render('create', array('UserLogin' => $UserLogin, 'UserProfile' => $UserProfile, 'rolesArray' => $rolesArray, 'managersArray' => $managerArray)); }
/** * Create User */ public function authCreateUser() { $data = Input::all(); try { // Find the user using the user id $user = Sentry::getUserProvider()->findByLogin($data['email']); // Attempt to activate the user $result = $user->attemptActivation($data['token']); //Assign the data $user->password = $data['password']; $user->first_name = ucfirst($data['first_name']); $user->last_name = ucfirst($data['last_name']); //Generate the profile pic $result = static::createUserImage($user->id, $user->first_name, $user->last_name); // Create a row for user in Quick Note Table $quicknote = new Quicknote(); $quicknote->user_id = $user->id; $quicknote->save(); //Create a row for user in User Profile Table $userProfile = new UserProfile(); $userProfile->id = $user->id; $userProfile->save(); //Update the user and save all data if ($user->save()) { //Redirect the user to the login page with appropriate display message return Redirect::to('login')->with('message', 'success103'); } else { Log::error('Something Went Wrong Exception - Creating User for email ' . $data['email']); throw new SomeThingWentWrongException(); } } catch (UserNotFoundException $e) { throw new UserNotFoundException(); } catch (UserAlreadyActivatedException $e) { Log::error('Something Went Wrong Exception - User is already activated for email ' . $data['email']); throw new SomeThingWentWrongException(); } }
public function actionCreate() { // check permissions // if (!Yii::app()->user->checkAccess('manageUser')) { // Helper::authException(); // } // models $UserLogin = new UserLogin(); $UserProfile = new UserProfile(); // role array for select $userRoles = UserRole::model()->findAll(); $rolesArray = array(); foreach ($userRoles as $UserRole) { if ($UserRole->RoleType != 'godAdministrator') { $rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc; } elseif (Helper::hasRole('godAdministrator')) { $rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc; } } // add default (empty value) to front of array $rolesArray = array('' => '') + $rolesArray; // form processing if (isset($_POST['UserLogin'], $_POST['UserProfile'])) { // redirect to the dashboard if 'Cancel' button clicked if (isset($_POST['button-cancel'])) { $this->redirect($this->createUrl('user/dashboard')); } // set UserLogin attributes and scenario $UserLogin->attributes = $_POST['UserLogin']; $UserLogin->IsPasswordReset = 1; // force password reset on first login $UserLogin->IsActive = 1; $UserLogin->scenario = 'create'; // set UserProfile attributes $UserProfile->attributes = $_POST['UserProfile']; $UserProfile->CompanyID = Yii::app()->user->companyID; // validate form submission $valid = $UserLogin->validate(); $valid = $UserProfile->validate() && $valid; if ($valid) { // save UserLogin if (!$UserLogin->save(false)) { throw new CHttpException(400, 'Error when trying to create user.'); } // save UserProfile $UserProfile->UserLoginID = $UserLogin->UserLoginID; // set newly generated EventID if (!$UserProfile->save(false)) { throw new CHttpException(400, 'Error when trying to create user.'); } // set success message for user Yii::app()->user->setFlash('success', 'A new user was successfully created.'); // return to empty create user form if adding another, else go to user dashboard if (isset($_POST['button-submit-add'])) { $this->redirect($this->createUrl('user/create')); } else { $this->redirect($this->createUrl('user/dashboard')); } } } // clear password $UserLogin->UserPassword = null; // render view $this->render('create', array('UserLogin' => $UserLogin, 'UserProfile' => $UserProfile, 'rolesArray' => $rolesArray)); }
public function actionGetReginfo() { Yii::import('ext.runactions.components.ERunActions'); $firstname = $_POST['fname']; $lastname = $_POST['lname']; $username = isset($_POST['uname']) ? $_POST['uname'] : ""; $email = $_POST['email']; $pwd = $_POST['pwd']; $gender = isset($_POST['gender']) ? $_POST['gender'] : ""; $socialid = $_POST['socialid']; $dob = Yii::app()->dateFormatter->format('yyyy-M-dd', strtotime($_POST['dob'])); $zip = $_POST['zip']; $user = User::model()->findByAttributes(array('email' => $email)); $model = new User(); if ($email == '' || $pwd == '') { echo "Enter fields"; } elseif ($user['email'] != '') { echo "You are already subscribed or your account may not be activated"; } else { if (isset(Yii::app()->session['userinfo'])) { if (isset(Yii::app()->session['login'])) { $id = Yii::app()->session['login']['id']; $model = User::model()->findByPk($id); $model->secondary_email = $email; $model->updatedby = $id; $model->updatedate = date('Y-m-d G:i:s'); } else { $model = new User(); $model->fname = $firstname; $model->lname = $lastname; $model->uname = $username; $model->email = $email; $model->password = md5($pwd); $model->gender = $gender; $model->dob = $dob; $model->zipcode = $zip; $model->usertypeid = 1; } $socialid = Yii::app()->session['userinfo']['SocialNetworkID']; $model->socialnetworkid = $socialid; $social = Yii::app()->session['userinfo']['SocialNetwork']; $model->socialnetwork = $social; /* Modified on 10-1-13 to get image from facebook reg becoz we r nt getng image for other social networks*/ if ($model->socialnetwork == "facebook") { /************* Awber code *******************/ $url = "http://www.aweber.com/scripts/addlead.pl"; $data = http_build_query(array("meta_web_form_id" => "1185568484", "meta_split_id" => "", "listname" => "finao_fbreges", "redirect" => "", "meta_adtracking" => "FBREG", "meta_message" => "1", "meta_required" => "email", "meta_tooltip" => "", "email" => $email)); $this->post_send($url, $data); /************* END of Awber code *******************/ $image = Yii::app()->session['userinfo']['photourl']; $rnd = rand(0, 9999); $img_file = file_get_contents($image); $file_loc = Yii::app()->basePath . '/../images/uploads/profileimages/' . $rnd . '.jpg'; $file_handler = fopen($file_loc, 'w'); if (fwrite($file_handler, $img_file) == false) { echo 'error'; } fclose($file_handler); $img = "images/uploads/profileimages/" . $rnd . '.jpg'; $image = Yii::app()->image->load($img); $image->resize(140, 140); $image->save("images/uploads/backgroundimages/" . $model->profile_bg_image); $model->profile_image = $rnd . '.jpg'; } else { $model->profile_image = 'default-yahoo.jpg'; } $model->status = 1; if ($gender != '') { $model->gender = $gender; } if (isset(Yii::app()->session['login'])) { if ($model->save(false)) { if ($saved) { if (isset(Yii::app()->session['login'])) { unset(Yii::app()->session['login']); } $login["id"] = $model->userid; $login["username"] = $model->uname; $login["socialnetworkid"] = $model->socialnetworkid; $login["superuser"] = $model->superuser; if ($model->usertypeid == 1) { $login["userType"] = "parent"; } if ($model->usertypeid == 3) { $login["userType"] = "organization"; } Yii::app()->session['login'] = $login; echo "frnds redirect"; } } } else { if ($model->save(false)) { /* Added on 10-1-13 to save fb details in login details. This is used for normal register want to invite his friends*/ $command = Yii::app()->db->createCommand(); $saved = $command->insert('ha_logins', array('userId' => $model->userid, 'loginProvider' => $model->socialnetwork, 'loginProviderIdentifier' => $model->socialnetworkid)); if ($saved) { $userdet = array(); $userdet['firstname'] = $model->fname; $userdet['lastname'] = $model->lname; $userdet['email'] = $model->email; $userdet['password'] = "******"; $userdet['store_id'] = 1; $userdet['website_id'] = 1; $url1 = Yii::app()->createAbsoluteUrl('site/Processshopreg', array('userdet' => $userdet)); ERunActions::touchUrl($url1); //$login = array(); if (isset(Yii::app()->session['login'])) { unset(Yii::app()->session['login']); } $login["id"] = $model->userid; $login["username"] = $uname; $login["socialnetworkid"] = $model->socialnetworkid; $login["superuser"] = $model->superuser; if ($model->usertypeid == 1) { $login["userType"] = "parent"; } if ($model->usertypeid == 3) { $login["userType"] = "organization"; } Yii::app()->session['login'] = $login; //$this->redirect('site/index'); echo "fb registration success"; } } } } else { if (isset(Yii::app()->session['login'])) { echo "Loged user"; exit; } $model->fname = $firstname; $model->lname = $lastname; $model->uname = $username; $model->email = $email; $model->password = md5($pwd); $model->dob = $dob; $model->zipcode = $zip; $model->usertypeid = 63; if ($socialid != 0) { $model->status = 1; } else { $model->status = 0; } $model->superuser = 0; $model->socialnetworkid = $socialid; /*$model->socialnetwork = "facebook";*/ if ($gender != '') { $model->gender = $gender; } $model->activkey = ""; //md5(uniqid(rand(), true)); $model->status = 1; $model->createtime = date('Y-m-d G:i:s'); $model->createdby = 1; $mageid = $this->processshopreg($firstname, $lastname, $email, $pwd); if ($mageid != '') { $model->mageid = $mageid; } if ($model->save(false)) { /* $mageid = $this->processshopreg($firstname,$lastname,$email,$pwd); if(!$mageid == 'exists') { $model->mageid = $mageid; //echo $mageid; exit; $model->save(); } */ if ($model->socialnetworkid != 0) { $image = "http://graph.facebook.com/" . $model->socialnetworkid . "/picture?type=normal"; $img_file = file_get_contents($image); $file_loc = Yii::app()->basePath . '/../images/uploads/profileimages/' . $model->userid . '.jpg'; $file_handler = fopen($file_loc, 'w'); if (fwrite($file_handler, $img_file) == false) { echo 'error'; } fclose($file_handler); $img = "images/uploads/profileimages/" . $model->userid . '.jpg'; $image = Yii::app()->image->load($img); $image->resize(140, 140); $image->save("images/uploads/profileimages/" . $model->userid . '.jpg'); $newuserprofile = new UserProfile(); $newuserprofile->user_id = $model->userid; $newuserprofile->profile_image = $model->userid . '.jpg'; $newuserprofile->createdby = $model->userid; $newuserprofile->createddate = date('Y-m-d G:i:s'); $newuserprofile->updatedby = $model->userid; $newuserprofile->updateddate = date('Y-m-d G:i:s'); $newuserprofile->IsCompleted = ""; $newuserprofile->save(false); $login = array(); if (isset(Yii::app()->session['login'])) { unset(Yii::app()->session['login']); } if (isset(Yii::app()->session['userinfo'])) { unset(Yii::app()->session['userinfo']); } $login["id"] = $model->userid; $login["username"] = $model->fname . ' ' . $model->lname; $login["email"] = $model->email; $login["socialnetworkid"] = $model->socialnetworkid; $login["superuser"] = $model->superuser; $userprofile = UserProfile::model()->findByAttributes(array('user_id' => $model->userid)); $login["profImage"] = isset($userprofile->profile_image) ? $userprofile->profile_image : ""; $login["bgImage"] = isset($userprofile->profile_bg_image) ? $userprofile->profile_bg_image : ""; Yii::app()->session['login'] = $login; echo "fb registration success"; } else { if (isset(Yii::app()->session['login'])) { unset(Yii::app()->session['login']); } $login = array(); $login["id"] = $model->userid; $login["username"] = $model->uname; $login["socialnetworkid"] = $model->socialnetworkid; $login["superuser"] = $model->superuser; if ($model->usertypeid == 1) { $login["userType"] = "parent"; } if ($model->usertypeid == 3) { $login["userType"] = "organization"; } Yii::app()->session['login'] = $login; echo "reg success"; } } else { echo "Enter the fields correctly"; } } } }
/** * Saves the form to a new user. * @return boolean */ public function saveToUser() { if ($this->validate()) { $transaction = UserProfile::model()->getDbConnection()->beginTransaction(); try { $profile = new UserProfile(); $profile->user_status_id = 'ACT'; $profile->pseudo = $this->pseudo; $profile->hash = sha1($this->pseudo); $profile->created = date('Y-m-d H:i:s'); if ($profile->save()) { $user = new UserUser(); $user->user_profile_id = $profile->user_profile_id; $user->userProfile = $profile; $user->hash_salt = self::genSalt(); $user->hash_password = self::hash($this->password, $user->hash_salt); $user->email = $this->usermail; $user->hash_email = sha1($this->usermail); $user->registered = date('Y-m-d H:i:s'); $user->last_login = date('Y-m-d H:i:s'); if ($user->save()) { $this->user = $user; $transaction->commit(); return true; } else { $transaction->rollback(); foreach ($user->getErrors() as $errorlist) { foreach ($errorlist as $error) { $this->addError('pseudo', $error); } } return false; } } else { foreach ($profile->getErrors() as $errorlist) { foreach ($errorlist as $error) { $this->addError('pseudo', $error); } } } } catch (CDbException $e) { $this->addError('pseudo', $e->getMessage()); try { $transaction->rollback(); } catch (CDbException $e2) { // nothing to do } return false; } } return false; }