/// $notifications[] = MakeNotification("success", "Das Passwort wurde geändert!");
                        Authentication::logoutUser();
                    }
                } else {
                    $notifications[] = MakeNotification("error", Language::Get('main', 'differentPasswords', $langTemplate));
                }
            } else {
                $notifications[] = MakeNotification("error", Language::Get('main', 'incorrectOldPassword', $langTemplate));
            }
        } else {
            $notifications = $notifications + $f->notifications;
        }
    } else {
        if ($_POST['action'] == "SetAccountInfo") {
            $f = new FormEvaluator($_POST);
            $f->checkStringForKey('language', FormEvaluator::OPTIONAL, 'warning', '???.');
            if ($f->evaluate(true)) {
                $foundValues = $f->foundValues;
                $language = $foundValues['language'];
                $newUserSettings = User::encodeUser(User::createUser($uid, null, null, null, null, null, null, null, null, null, null, null, null, null, $language));
                $URI = $databaseURI . "/user/" . $uid;
                http_put_data($URI, $newUserSettings, true, $message);
                if ($message == "201") {
                    $notifications[] = MakeNotification("success", Language::Get('main', 'languageChanged', $langTemplate));
                }
            } else {
                $notifications = $notifications + $f->notifications;
            }
        }
    }
}
             http_delete($url, true, $message);
             // show notification
             if ($message == "201") {
                 $revokeRightsNotifications[] = MakeNotification("success", Language::Get('main', 'successRemoveUser', $langTemplate));
             }
         } else {
             // otherwise show conflict page
             set_error("409");
             exit;
         }
     } else {
         $revokeRightsNotifications[] = MakeNotification("error", Language::Get('main', 'noSelectedUser', $langTemplate));
     }
 } elseif ($_POST['action'] == "AddUser") {
     $f = new FormEvaluator($_POST);
     $f->checkStringForKey('userName', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidUserName', $langTemplate), array('min' => 1));
     $f->checkIntegerForKey('rights', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidCourseStatus', $langTemplate), array('min' => 0, 'max' => 2));
     if ($f->evaluate(true)) {
         $foundValues = $f->foundValues;
         $userName = $foundValues['userName'];
         $rights = $foundValues['rights'];
         $URL = $databaseURI . '/user/user/' . $userName;
         $user = http_get($URL, true);
         $user = json_decode($user, true);
         if (isset($user['id'])) {
             $userId = $user['id'];
             $newUser = User::createCourseStatus($userId, $cid, $rights);
             $newUser = User::encodeUser($newUser);
             $URL = $databaseURI . '/coursestatus';
             http_post_data($URL, $newUser, true, $message);
             if ($message == "201") {
Exemple #3
0
            $processes = json_decode(Process::encodeProcess($processors), true);
            #############################
            ### end create_processors ###
            #############################
            #endregion
        }
        $sheet_data['exercises'] = json_decode(Exercise::encodeExercise($exercises), true);
    }
}
if (isset($_POST['action'])) {
    // && $_POST['action'] == "new"
    $timestamp = time();
    $errorInSent = false;
    // validate all sheet data
    $f = new FormEvaluator($_POST);
    $f->checkStringForKey('sheetName', FormEvaluator::REQUIRED, 'error', Language::Get('main', 'invalidSheetName', $langTemplate));
    $f->checkStringForKey('startDate', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidPeriodBegin', $langTemplate));
    $f->checkStringForKey('endDate', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidPeriodEnd', $langTemplate));
    // check if defaultGroupSize is bigger than standard groupsize 10
    if ($createsheetData['user']['courses'][0]['course']['defaultGroupSize'] < 10) {
        $maxgroup = 10;
    } else {
        $maxgroup = $createsheetData['user']['courses'][0]['course']['defaultGroupSize'];
    }
    $f->checkIntegerForKey('groupSize', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidGroupSize', $langTemplate), array('min' => 0, 'max' => $maxgroup));
    /*$f->checkArrayOfArraysForKey('exercises',
      FormEvaluator::REQUIRED,
      'warning',
      'Bitte erstellen Sie mindestens eine Aufgabe.');*/
    // check if startDate is not later than endDate and if it matches format
    $correctDates = true;
Exemple #4
0
 // bool which is true if any error occured
 $RequestErrorMarking = false;
 $RequestErrorSubmission = false;
 $hasChangedMarking = false;
 $hasChangedSubmission = false;
 foreach ($exercises as $exerciseId => $exercise) {
     $maxPoints = cleanInput($exercise['maxPoints']);
     $submissionID = cleanInput($exercise['submissionID']);
     $markingID = cleanInput($exercise['markingID']);
     $userName = isset($exercise['user']) ? $exercise['user'] : '******';
     if (isset($exercise['points'])) {
         $exercise['points'] = str_replace(',', '.', $exercise['points']);
     }
     $f = new FormEvaluator($exercise);
     $f->checkNumberForKey('points', FormEvaluator::OPTIONAL, 'warning', Language::Get('main', 'invalidPoints', $langTemplate), array('min' => 0));
     $f->checkStringForKey('tutorComment', FormEvaluator::OPTIONAL, 'warning', Language::Get('main', 'invalidComment', $langTemplate), array('min' => 1));
     /**
      * @todo get maxStatusID for FormEvaluator.
      */
     $f->checkIntegerForKey('status', FormEvaluator::OPTIONAL, 'warning', Language::Get('main', 'invalidStatus', $langTemplate), array('min' => 0, 'max' => $maxMarkingStatus));
     $f->checkIntegerForKey('accepted', FormEvaluator::OPTIONAL, 'warning', Language::Get('main', 'invalidAcceptance', $langTemplate), array('min' => 0, 'max' => 1));
     if ($f->evaluate(true)) {
         $foundValues = $f->foundValues;
         $changed = false;
         $points = isset($foundValues['points']) ? $foundValues['points'] : null;
         if ($points > $maxPoints) {
             $msg = Language::Get('main', 'tooManyPoints', $langTemplate, array('maxPoints' => $maxPoints));
             if (!isset($GroupNotificationElements[$key])) {
                 $GroupNotificationElements[$key] = array();
             }
             $GroupNotificationElements[$key][] = MakeNotification("warning", $msg);
Exemple #5
0
                 http_put_data($url, $data, true, $message);
                 if ($message == "201") {
                     $notifications[] = MakeNotification("success", Language::Get('main', 'successSetAdmin', $langTemplate));
                 } else {
                     $notifications[] = MakeNotification("error", Language::Get('main', 'errorSetAdmin', $langTemplate));
                 }
             } else {
                 $notifications[] = MakeNotification("success", Language::Get('main', 'successSetAdmin', $langTemplate));
             }
         }
     }
 }
 // creates a new user
 if ($_POST['action'] == "CreateUser") {
     $f = new FormEvaluator($_POST);
     $f->checkStringForKey('lastName', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidLastName', $langTemplate), array('min' => 1));
     $f->checkStringForKey('firstName', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidFirstName', $langTemplate), array('min' => 1));
     $f->checkStringForKey('userName', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidUserName', $langTemplate), array('min' => 1));
     $f->checkEmailForKey('email', FormEvaluator::OPTIONAL, false, 'warning', Language::Get('main', 'invalidMail', $langTemplate));
     $f->checkStringForKey('password', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidPassword', $langTemplate), array('min' => 6));
     $f->checkStringForKey('passwordRepeat', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidPasswordRepeat', $langTemplate), array('min' => 6));
     if ($f->evaluate(true)) {
         $foundValues = $f->foundValues;
         $lastName = $foundValues['lastName'];
         $firstName = $foundValues['firstName'];
         $email = isset($foundValues['email']) ? $foundValues['email'] : null;
         $userName = $foundValues['userName'];
         $password = $foundValues['password'];
         $passwordRepeat = $foundValues['passwordRepeat'];
         // both passwords are equal
         if ($password == $passwordRepeat) {