public function handleForm(Context $context, $action)
 {
     //TODO: Check user level >= ADMIN
     if ($action == "savePassword") {
         if (isset($_POST['newpass']) && $_POST['newpass'] != "" && (isset($_POST['confpass']) && $_POST['confpass'] != "")) {
             $newPassword = $_POST['newpass'];
             $confirmPassword = $_POST['confpass'];
             if ($newPassword = $confirmPassword) {
                 UserDao::updateUserPassword($_POST['userid'], $newPassword);
                 $context->addMessage("Password Successfully Changed.");
             } else {
                 $context->addError("Passwords Don't Match.");
             }
         } else {
             $context->addError("Required Field Left Blank.");
         }
     } else {
         if ($action == "saveEmail") {
             if (isset($_POST['email']) && $_POST['email'] != "") {
                 $email = $_POST['email'];
                 UserDao::updateUserEmail($_POST['userid'], $email);
                 $context->addMessage("Email Successfully Changed.");
             } else {
                 $context->addError("Required Field Left Blank.");
             }
         } else {
             if ($action == "saveUserLevel") {
                 if (isset($_POST['level']) && $_POST['level'] != "") {
                     $userlevel = $_POST['level'];
                     UserDao::updateUserLevel($_POST['userid'], $userlevel);
                     $context->addMessage("User Level Successfully Changed.");
                 } else {
                     $context->addError("Required Field Left Blank.");
                 }
             } else {
                 if ($action == "saveNotes") {
                     if (isset($_POST['notes']) && $_POST['notes'] != "") {
                         $notes = $_POST['notes'];
                         UserDao::updateUserNotes($_POST['userid'], $notes);
                         $context->addMessage("Notes Successfully Changed.");
                     } else {
                         $context->addError("Required Field Left Blank.");
                     }
                 } else {
                     if ($action == "saveName") {
                         if (isset($_POST['name']) && $_POST['name'] != "") {
                             $name = $_POST['name'];
                             UserDao::updateName($_POST['userid'], $name);
                             $context->addMessage("Name Successfully Changed.");
                         } else {
                             $context->addError("Required Field Left Blank.");
                         }
                     } else {
                         $context->addError("Incorrect Action.");
                     }
                 }
             }
         }
     }
 }
 public function handleForm(Context $context, $action)
 {
     if (UserDao::getUserByUsername(SessionUtil::getUsername())->userlevel == RES_USERLEVEL_ADMIN) {
         if ($action == "deleteWarning") {
             $warning = WarningDao::getWarningByID($_POST['warnId']);
             if ($warning != null) {
                 WarningDao::deleteWarning($warning->id);
                 $context->addMessage("Successfully deleted warning.");
             } else {
                 $context->addError("No such warning.");
             }
         } else {
             $context->addError("Incorrect Action.");
         }
     } else {
         $context->addError("Not Authorized.");
     }
 }
 public function handleForm(Context $context, $action)
 {
     if ($action == "createUser") {
         if (isset($_POST['username']) && $_POST['username'] != "" && (isset($_POST['userlevel']) && $_POST['userlevel'] != "") && (isset($_POST['name']) && $_POST['name'] != "") && (isset($_POST['email']) && $_POST['email'] != "")) {
             $password = "";
             if (Config::login_type == LOGIN_TYPE_DB) {
                 $password = CryptoUtil::generatePassword(9, 4);
             }
             UserDao::createUser($_POST['username'], $_POST['name'], $_POST['email'], $_POST['userlevel'], $password);
             $message = "Created User -- Username: "******" Password: "******"Required Field Left Blank.");
         }
     } else {
         $context->addError("Incorrect Action.");
     }
 }
 public function handleForm(Context $context, $action)
 {
     if (UserDao::getUserByUsername(SessionUtil::getUsername())->userlevel == RES_USERLEVEL_ADMIN) {
         if ($action == "createWarning") {
             if (isset($_POST['userId']) && $_POST['userId'] != "" && (isset($_POST['reason']) && $_POST['reason'] != "") && (isset($_POST['type']) && $_POST['type'] != "")) {
                 $user = UserDao::getUserByID($_POST['userId']);
                 if ($user != null) {
                     $warning = WarningDao::warnUser($_POST['userId'], $_POST['reason'], $_POST['type']);
                     EmailUtil::sendWarningNoticeToUser($warning);
                     $context->addMessage("Successfully warned " . $user);
                 } else {
                     $context->addError("No such user.");
                 }
             } else {
                 $context->addError("Required field left blank.");
             }
         } else {
             $context->addError("Incorrect Action.");
         }
     } else {
         $context->addError("Not Authorized.");
     }
 }