function Start() { // If validation request if (isset($_GET['validate'])) { $token = $_GET['validate']; $userId = jf::LoadGeneralSetting("activation_{$token}"); if (!jf::$XUser->UserIDExists($userId)) { $errorString = "Invalid validation token"; } else { if (jf::$XUser->IsActive($userId)) { $errorString = "Your account is already activated"; } else { jf::$XUser->Activate($userId); jf::DeleteGeneralSetting("activation_{$token}"); $this->Success = "Your account is successfully activated"; } } } // If sign up request if (isset($_POST["Username"])) { $username = $_POST['Username']; $password = $_POST['Password']; $email = $_POST['Email']; if (!preg_match('/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/', $email)) { $errorString = "Invalid email address."; } elseif (jf::$XUser->UserID($username)) { $errorString = "User already exists."; } elseif ($_POST['Confirm'] != $password) { $errorString = "Passwords does not match."; } if (!isset($errorString)) { $userId = jf::$XUser->CreateUser($username, $password, $email); $roleId = jf::$RBAC->Roles->TitleId(self::ROLE_NAME); jf::$RBAC->Users->Assign($roleId, $userId); // Assign role to the newly created user // Send activation email if ($this->activationMail($email, $userId, $username)) { $this->Success = "Signup successful. Check your email for activation link."; } else { $errorString = "Could not send confirmation email."; } } } if (isset($errorString)) { $this->Error = $errorString; } return $this->Present(); }
function Start() { $this->Username = jf::$XUser->Username(); if (isset($_GET['validate'])) { $token = $_GET['validate']; $UserID = jf::LoadGeneralSetting("activation_{$token}"); if (!jf::$XUser->UserIDExists($UserID)) { $ErrorString = "Invalid validation token."; } else { if (jf::$XUser->IsActive($UserID)) { $ErrorString = "Your account is already activated"; } else { jf::$XUser->Activate($UserID); jf::DeleteGeneralSetting("activation_{$token}"); $this->Success = "Your account is succesfully activated. You may now login."; } } } if (isset($_POST["Username"])) { $Username = $_POST['Username']; $Password = $_POST['Password']; $Email = $_POST['Email']; if (!preg_match('/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/', $Email)) { $ErrorString = "Invalid email address."; } elseif (jf::$XUser->UserID($Username)) { $ErrorString = "User already exists."; } elseif ($_POST['Confirm'] != $Password) { $ErrorString = "Password retype does not match."; } if (!isset($ErrorString)) { $UserID = jf::$XUser->CreateUser($Username, $Password, $Email); if ($this->ActivationMail($Email, $UserID, $Username)) { $this->Success = true; } else { $ErrorString = "Could not send confirmation email."; } } } if (isset($ErrorString)) { $this->Error = $ErrorString; } return $this->Present(); }
/** * @depends testSaveGeneral */ function testDeleteGeneral() { jf::SaveGeneralSetting("some_name", "some_value"); $this->assertTrue(jf::DeleteGeneralSetting("some_name")); }