/** * Connects to the DB, gets the data from DB * and creates an array of users which were stored in DB * @param nothing * @return true, if the array containing users was created, false if an error appeared */ public function generateArray() { try { $userArr = DB::getInstance()->getUsersList(); // Connect to DB and get users foreach ($userArr as $oneUser) { // For each row that represents one user $user = new User(); $x = 0; // Counter foreach ($oneUser as $userData) { // Set user data. Each cell in the row represents user's data if ($x == 1) { $user->setUsername($userData); } elseif ($x == 2) { $user->setPassword($userData); } elseif ($x == 3) { $user->setFirstName($userData); } elseif ($x == 4) { $user->setLastName($userData); } elseif ($x == 5) { $user->setEmailAddress($userData); } elseif ($x == 6) { $user->setDescription($userData); } $x++; } $this->addUserToArray($user); } return true; } catch (\Exception $e) { // Catch exception return false; } }
protected function createUser() { $user = new User(); $user->setFirstName('John'); $user->setLastName('Smith Jr.'); $user->setEmailAddress('*****@*****.**'); $user->setDateCreated(new fTimestamp()); $user->setHashedPassword('8njsbck'); return $user; }
public static function createUser() { $timecode = substr(md5(microtime()), 0, 5); $role = new Role('ROLE_USER', null, 'false'); $result = new User(); $result->setUsername('test_' . $timecode); $result->setPassword($timecode); $result->setEmailAddress('test@' . $timecode . '.com'); $result->setFullname('User ' . $timecode); $result->setTenantId('organization_1'); $result->setEnabled('true'); $result->addRole($role); return $result; }
public function import($adminUserId) { $count = 0; $add_method = $this->getValue('add_method'); $file = $this->getValue('file'); $delimiter = $this->getValue('delimiter'); $skipHeader = $this->getValue('skipHeader'); $fp = fopen($file->getTempName(), 'r'); if ($fp) { if ($add_method == self::REPLACE) { $c = new Criteria(); $c->add(UserPeer::ID, $adminUserId, Criteria::NOT_EQUAL); UserPeer::doDelete($c); } while ($data = fgetcsv($fp, 0, $delimiter)) { if (empty($data[0]) || count($data) < 7) { continue; } if ($skipHeader) { $skipHeader = false; continue; } try { $user = new User(); $user->setFamilyName($data[0]); $user->setSurname($data[1]); $user->setBirthdate($data[2]); $user->setCardNumber($data[3]); $user->setEmailAddress($data[4]); $user->setAddress($data[5]); $user->setPhoneNumber($data[6]); $user->autoCorrectNames(); $user->autoSetLogin(); $user->save(); ++$count; } catch (Exception $ex) { } } fclose($fp); return $count; } return false; }
public function executeNewuser(sfWebRequest $request) { $this->form = new UserForm(); // check if the data is coming from POST method if ($request->isMethod('post')) { // bind the form $this->form->bind($request->getParameter($this->form->getName())); $captcha = new reCaptcha(); $responsecaptcha = $captcha->recaptcha_check_answer($_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); //check capcha if (!$responsecaptcha->is_valid) { $this->getUser()->setFlash('message', 'Invalid Sequrity Code,Please enter again'); } else { $formData = $this->form->getValues(); $checkUsernameAndEmail = Doctrine::getTable('User')->func_checkUsernameAndEmail($formData['email_address'], $formData['username']); if (count($checkUsernameAndEmail)) { $this->getUser()->setFlash('message', 'UserName or Email is already taken'); } else { $user = new User(); $user->setUsername($formData['username']); $getSalt = Doctrine::getTable('User')->func_generateSalt(); $getPassword = Doctrine::getTable('User')->func_generatePassword($getSalt, $formData['pass']); $user->setSalt($getSalt); $user->setPass($getPassword); $user->setIsActive(0); $user->setFirstName($formData['first_name']); $user->setLastName($formData['last_name']); $user->setEmailAddress($formData['email_address']); $user->save(); Doctrine::getTable('User')->func_sendVerificationEmail($formData['first_name'], $formData['email_address'], $getSalt); $this->getUser()->setFlash('message', 'Thanks for registration. Account activation link has been sent into your email address.'); $this->redirect('@login'); } // if the username and email does not exist } } // check if the method is POST }
public function testInsertSetNullNotNullColumnWithDefault() { $user = new User(); $user->setFirstName('testInsertSetNullNotNullColumnWithDefault'); $user->setMiddleInitial(NULL); $user->setLastName('User'); $user->setEmailAddress('*****@*****.**'); $user->setDateCreated(new fTimestamp()); $user->setHashedPassword('abcdefgh'); $user->store(); $this->assertEquals(1, self::$db->query('SELECT * FROM %r WHERE first_name = %s', fORM::tablize('User'), 'testInsertSetNullNotNullColumnWithDefault')->countReturnedRows()); $user->delete(); }
$app->get('/signup', function () use($app) { if (App::userLoggedIn()) { $app->flash('error', 'You are already logged in'); $app->redirect('/'); } $app->log->info("Slim-Skeleton '/' route"); $app->render('signup.twig'); }); $app->post('/signup', function () use($app) { $emailAddress = strtolower(filter_var($app->request()->post('email'), FILTER_SANITIZE_STRING)); $password = filter_var($app->request()->post('password'), FILTER_SANITIZE_STRING); $firstName = filter_var($app->request()->post('firstName'), FILTER_SANITIZE_STRING); $lastName = filter_var($app->request()->post('lastName'), FILTER_SANITIZE_STRING); $user = new User(); $user->setFirstName($firstName); $user->setLastName($lastName); $user->setEmailAddress($emailAddress); $user->setPassword(password_hash($password, PASSWORD_BCRYPT)); $user->setUUID(UUID::v4()); if ($user->save()) { $app->flash('info', 'Signup successful. You may login now!'); $app->redirect('/login'); } else { $app->flash('error', 'Something went wrong!'); $app->redirect('/signup'); } }); $app->get('/logout', function () use($app) { unset($_SESSION['user']); $app->redirect('/login'); });
$_SESSION['UserSalt'] = $User->getSalt(); } else { $User = new User(NULL, $lang->g('LabelNewUser')); } if (array_key_exists('hidAction', $_POST) && $_POST['hidAction'] == 'UserView') { if (array_key_exists('txtUserName', $_POST)) { $User->setUserName(Utils::NullIfEmpty($_POST['txtUserName'])); } if (array_key_exists('hidPassword', $_POST)) { $User->setPassword(Utils::NullIfEmpty($_POST['hidPassword'])); $User->setSalt(Utils::NullIfEmpty($_SESSION['UserSalt'])); } $User->setFirstName(Utils::NullIfEmpty($_POST['txtFirstName'])); $User->setInsertion(Utils::NullIfEmpty($_POST['txtInsertion'])); $User->setLastName(Utils::NullIfEmpty($_POST['txtLastName'])); $User->setEmailAddress(Utils::NullIfEmpty($_POST['txtEmailAddress'])); $User->setLanguage(Utils::NullIfEmpty($_POST['selectLanguage'])); $User->setDateDisplayOptions($_POST['selectDateformat']); $User->setImageview(Utils::NullIfEmpty($_POST['selectImageview'])); if ($CurrentUser->hasPermission(RIGHT_USER_RIGHTS)) { $getrights = array(); foreach (Rights::getDefinedRights() as $k => $v) { if (array_key_exists('chk' . $k, $_POST)) { $getrights[] = $v; } } $User->setRights($getrights); } if (array_key_exists('radGender', $_POST)) { switch (intval($_POST['radGender'])) { case GENDER_FEMALE: