Ejemplo n.º 1
0
 function generateHTML()
 {
     $login = LoginDao::getLoginByUsername(SessionUtil::getUsername());
     if ($login->getType() == Login::CLIENT) {
         $client = ClientDao::getClientByLogin($login);
         return $this->context->getErrorHTML() . "<div class=\"centered\">\n\t\t\n\t\t\t\t<h3>Login</h3>\n\t\t\t\t\n\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"changePassword\" />\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"password\" placeholder=\"Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Repeat Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"repeatpassword\" placeholder=\"Repeat Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<input type=\"submit\" value=\"Change Password\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t</form>\n\t\t\t\t\n\t\t\t\t<h3>Account Info</h3>\n\t\t\t\t\n\t\t\t\t<div style=\"width: 45%; margin-left: auto; margin-right: auto;\">\n\t\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t\t<div style=\"float: left; text-align: left;\">\n\t\t\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"updateAccount\" />\n\t\t\t\t\t\t\t<label for=\"name\" class=\"above\">Name</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"name\" placeholder=\"Name\" value=\"" . $client->getName() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<label for=\"email\" class=\"above\">Email</label>\n\t\t\t\t\t\t\t<input type=\"email\" name=\"email\" placeholder=\"Email\" value=\"" . $client->getEmail() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<label for=\"phone\" class=\"above\">Phone</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"phone\" placeholder=\"Phone\" value=\"" . $client->getPhone() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div style=\"float: right; text-align: right;\">\n\t\t\t\t\t\t\t<br /><label for=\"address\" class=\"above\">Address</label>\n\t\t\t\t\t\t\t<textarea name=\"address\" rows=\"3\" cols=\"23\" class=\"text bluefocus\">" . $client->getAddress() . "</textarea>\n\t\t\t\t\t\t\t<br /><br /><input type=\"submit\" value=\"Update Account\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</form>\n\t\t\t\t</div>\n\t\t\t\n\t\t\t</div>";
     } else {
         if ($login->getType() == Login::ADREP) {
             $adrep = AdRepDao::getAdRepByLogin($login);
             return $this->context->getErrorHTML() . "<div class=\"centered\">\n\t\t\n\t\t\t\t<h3>Login Info</h3>\n\t\t\t\t\n\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"changePassword\" />\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"password\" placeholder=\"Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Repeat Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"repeatpassword\" placeholder=\"Repeat Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<input type=\"submit\" value=\"Change Password\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t</form>\n\t\t\t\t\n\t\t\t\t<h3>Account Info (Ad Rep)</h3>\n\t\t\t\t\n\t\t\t\t<div style=\"width: 45%; margin-left: auto; margin-right: auto;\">\n\t\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t\t<div style=\"float: left; text-align: left;\">\n\t\t\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"updateAccount\" />\n\t\t\t\t\t\t\t<label for=\"name\" class=\"above\">Name</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"name\" placeholder=\"Name\" value=\"" . $adrep->getName() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<label for=\"email\" class=\"above\">Email</label>\n\t\t\t\t\t\t\t<input type=\"email\" name=\"email\" placeholder=\"Email\" value=\"" . $adrep->getEmail() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div style=\"float: right; text-align: right;\">\n\t\t\t\t\t\t\t<label for=\"phone\" class=\"above\">Phone</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"phone\" placeholder=\"Phone\" value=\"" . $adrep->getPhone() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<br /><br /><input type=\"submit\" value=\"Update Account\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</form>\n\t\t\t\t</div>\n\t\t\t\n\t\t\t</div>";
         } else {
             return $this->context->getErrorHTML() . "<div class=\"centered\">\n\t\t\t\n\t\t\t\t<h3>Login Info</h3>\n\t\t\t\t\n\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"changePassword\" />\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"password\" placeholder=\"Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Repeat Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"repeatpassword\" placeholder=\"Repeat Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<input type=\"submit\" value=\"Change Password\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t</form>\n\t\t\t\t\n\t\t\t\t<h3>Account Info</h3>\n\t\t\t\t\n\t\t\t\t<div class=\"centered error\">Unknown Account Type</div>\n\t\t\t\n\t\t\t</div>";
         }
     }
 }
Ejemplo n.º 2
0
 public function handleForm(Context $context, $action)
 {
     if ($action == "changePassword") {
         if ($_POST['password'] != "" && $_POST['repeatpassword'] != "") {
             $sessionLogin = LoginDao::getLoginByUsername(SessionUtil::getUsername());
             if ($_POST['password'] == $_POST['repeatpassword']) {
                 LoginDao::updateUserPassword($sessionLogin, $_POST['password']);
             } else {
                 $context->addError("Passwords don't match.");
             }
         } else {
             $context->addError("Required field left blank.");
         }
     } else {
         if ($action == "updateAccount") {
             if ($_POST['name'] != "" && $_POST['email'] != "" && $_POST['phone'] != "") {
                 $sessionLogin = LoginDao::getLoginByUsername(SessionUtil::getUsername());
                 if ($sessionLogin->getType() == Login::ADREP) {
                     $adrep = AdRepDao::getAdRepByLogin($sessionLogin);
                     AdRepDao::updateAdRep($adrep, $_POST['name'], $_POST['email'], $_POST['phone']);
                 } else {
                     if ($sessionLogin->getType() == Login::CLIENT) {
                         if ($_POST['address'] != "") {
                             $client = ClientDao::getClientByLogin($sessionLogin);
                             ClientDao::updateClient($client, $_POST['name'], $_POST['email'], $_POST['phone'], $_POST['address']);
                         } else {
                             $context->addError("Required field left blank.");
                         }
                     } else {
                         $context->addError("Unknown Account Type.");
                     }
                 }
             } else {
                 $context->addError("Required field left blank.");
             }
         } else {
             $context->addError("Incorrect Action.");
         }
     }
 }