コード例 #1
0
ファイル: Authentication.php プロジェクト: sawh/ostepu-system
 /**
  * Logs in a user.
  *
  * @param string $username
  * @param string $password
  * @return true if login is successful
  */
 public function loginUser($username, $password)
 {
     global $databaseURI;
     $databaseURL = "{$databaseURI}/user/user/{$username}";
     $user = http_get($databaseURL, false, $message);
     $user = json_decode($user, true);
     // check if user exists
     if ($message != "404" && empty($user) == false) {
         // create passwordhash with salt as suffix
         if (isset($user['failedLogins']) && time() - $user['failedLogins'] < 15) {
             $waitSeconds = 15 - (time() - $user['failedLogins']);
             return MakeNotification("error", "Die Anmeldung ist für {$waitSeconds} Sekunden gesperrt!!!");
         }
         if (isset($user['salt'])) {
             $password = $this->hashData('sha256', $password . $user['salt']);
             if (isset($user['password']) && $password == $user['password']) {
                 // save logged in uid
                 $_SESSION['UID'] = $user['id'];
                 $refresh = $this->refreshSession();
                 return $refresh;
             } else {
                 $userid = $user['id'];
                 $databaseURL = "{$databaseURI}/user/user/{$userid}/IncFailedLogin";
                 $user = http_get($databaseURL, false, $message);
             }
         }
     }
     return false;
 }
コード例 #2
0
ファイル: Error.php プロジェクト: sawh/ostepu-system
<?php

/**
 * @file Error.php
 *
 * @author Ralf Busch
 */
include_once 'include/Boilerplate.php';
include_once dirname(__FILE__) . '/../Assistants/Language.php';
if (isset($_GET['msg'])) {
    $msg = cleanInput($_GET['msg']);
}
if (isset($msg) && $msg == "403") {
    header("HTTP/1.0 403 Access Forbidden");
    $notifications[] = MakeNotification("error", "403: Access Forbidden");
} elseif (isset($msg) && $msg == "404") {
    header("HTTP/1.0 404 Not Found");
    $notifications[] = MakeNotification("error", "404: Not Found!");
} elseif (isset($msg) && $msg == "409") {
    header("HTTP/1.0 404 Not Found");
    $notifications[] = MakeNotification("error", "409: Conflict!");
} else {
    header("HTTP/1.0 403 Not Found");
    $notifications[] = MakeNotification("error", "403: " . $msg);
}
$h = Template::WithTemplateFile('include/Header/Header.template.html');
$h->bind(array("name" => "Übungsplattform", "backTitle" => "Startseite", "backURL" => "index.php", "hideLogoutLink" => "true", "notificationElements" => $notifications));
// wrap all the elements in some HTML and show them on the page
$w = new HTMLWrapper($h);
$w->set_config_file('include/configs/config_default.json');
$w->show();
コード例 #3
0
ファイル: FormEvaluator.php プロジェクト: sawh/ostepu-system
 /**
  * Evaluate the form.
  *
  * @param bool $cleanInput (optional) True if the form values should be
  * sanitized, false otherwise.
  * @return bool True if all values marked as required were found,
  * false otherwise
  */
 public function evaluate($cleanInput = false)
 {
     $foundAllRequired = true;
     $this->cleanInput = $cleanInput;
     foreach ($this->values as $value) {
         $key = $value['key'];
         $type = $value['type'];
         $required = $value['required'];
         $messageType = $value['messageType'];
         $message = $value['message'];
         if ($type == 'string') {
             $oneOf = $value['oneOf'];
             $notIn = $value['notIn'];
             $length = $value['length'];
             // check if the value for $key is valid
             $result = $this->evaluateString($key, $required, $length, $oneOf, $notIn);
         } elseif ($type == 'number') {
             $range = $value['range'];
             $notIn = $value['notIn'];
             // check if the value for $key is valid
             $result = $this->evaluateNumber($key, $required, $range, $notIn);
         } elseif ($type == 'array') {
             $options = $value['options'];
             // check if the value for $key is valid
             $result = $this->evaluateArray($key, $required, $options);
         } elseif ($type == 'integer') {
             $range = $value['range'];
             $notIn = $value['notIn'];
             // check if the value for $key is valid
             $result = $this->evaluateInteger($key, $required, $range, $notIn);
         } elseif ($type == 'email') {
             $result = $this->evaluateEmail($key, $required);
         }
         if ($result === false) {
             // the value for $key is invalid
             // if the value was not required, we don't care
             $success = $required ? $result : true;
             // remember if we failed before
             $foundAllRequired &= $success;
             // create a notification
             $this->notifications[] = MakeNotification($value['messageType'], $value['message']);
         } else {
             $this->insertValue($key, $result);
         }
     }
     return $foundAllRequired;
 }
コード例 #4
0
ファイル: AssignMake.php プロジェクト: sawh/ostepu-system
                    $noSubmission[$exercise] = array_diff($users[$exercise], $submitted[$exercise]);
                }
                unset($submitted);
                unset($users);
                $failure = false;
                foreach ($noSubmission as $exercise => $exerciseUsers) {
                    foreach ($exerciseUsers as $user) {
                        if (createSubmission($user, $exercise) === null) {
                            $failure = true;
                            break;
                        }
                    }
                    if ($failure) {
                        break;
                    }
                }
                if (!$failure) {
                    $assignMakeNotifications[] = MakeNotification("success", Language::Get('main', 'successMake', $langTemplate));
                } else {
                    $assignMakeNotifications[] = MakeNotification("error", Language::Get('main', 'errorMake', $langTemplate));
                }
            } else {
                $assignMakeNotifications[] = MakeNotification("error", Language::Get('main', 'errorMake', $langTemplate));
            }
        } else {
            $assignMakeNotifications[] = MakeNotification("error", Language::Get('main', 'errorMake', $langTemplate));
        }
    } else {
        $assignMakeNotifications[] = MakeNotification("error", Language::Get('main', 'errorMake', $langTemplate));
    }
}
コード例 #5
0
ファイル: TutorUpload.php プロジェクト: sawh/ostepu-system
                    $successmsg = Language::Get('main', 'sucessFileUpload', $langTemplate);
                    $notifications[] = MakeNotification('success', $successmsg);
                } else {
                    $errors = @json_decode($error);
                    if ($errors !== null) {
                        foreach ($errors as $err) {
                            $notifications[] = MakeNotification('error', $err);
                        }
                    } else {
                        $errormsg = Language::Get('main', 'unknownError', $langTemplate);
                        $notifications[] = MakeNotification('error', $errormsg);
                    }
                }
            } else {
                $errormsg = Language::Get('main', 'invalidFileType', $langTemplate);
                $notifications[] = MakeNotification('error', $errormsg);
            }
        }
    }
}
// load tutorUpload data from GetSite
$URL = $getSiteURI . "/tutorupload/user/{$uid}/course/{$cid}";
$tutorUpload_data = http_get($URL, true);
$tutorUpload_data = json_decode($tutorUpload_data, true);
$tutorUpload_data['filesystemURI'] = $filesystemURI;
$tutorUpload_data['cid'] = $cid;
$user_course_data = $tutorUpload_data['user'];
$menu = MakeNavigationElement($user_course_data, PRIVILEGE_LEVEL::TUTOR, true);
// construct a new header
$h = Template::WithTemplateFile('include/Header/Header.template.html');
$h->bind($user_course_data);
コード例 #6
0
                if ($message == "201") {
                    $addUserNotifications[] = MakeNotification('success', Language::Get('main', 'successAddUser', $langTemplate));
                } else {
                    $addUserNotifications[] = MakeNotification('error', Language::Get('main', 'errorAddUser', $langTemplate));
                }
            } else {
                $addUserNotifications[] = MakeNotification('error', Language::Get('main', 'invalidUserId', $langTemplate));
            }
        } else {
            if (!isset($addUserNotifications)) {
                $addUserNotifications = array();
            }
            $addUserNotifications = $addUserNotifications + $f->notifications;
        }
    } else {
        $notifications[] = MakeNotification('error', Language::Get('main', 'invalidAction', $langTemplate));
    }
}
// load CourseManagement data from GetSite
$URI = $getSiteURI . "/coursemanagement/user/{$uid}/course/{$cid}";
$courseManagement_data = http_get($URI, true);
$courseManagement_data = json_decode($courseManagement_data, true);
$dataList = array();
foreach ($courseManagement_data['users'] as $key => $user) {
    $dataList[] = array('pos' => $key, 'userName' => $user['userName'], 'lastName' => $user['lastName'], 'firstName' => $user['firstName']);
}
$sortTypes = array('lastName', 'firstName', 'userName');
if (!isset($_POST['sortUsers'])) {
    $_POST['sortUsers'] = null;
}
$_POST['sortUsers'] = in_array($_POST['sortUsers'], $sortTypes) ? $_POST['sortUsers'] : $sortTypes[0];
コード例 #7
0
ファイル: UploadHistory.php プロジェクト: sawh/ostepu-system
}
// updates the selectedSubmissions for the group
if (isset($_POST['updateSelectedSubmission'])) {
    $obj = json_decode($_POST['updateSelectedSubmission'], true);
    // bool which is true if any error occured
    $RequestError = false;
    $message = null;
    updateSelectedSubmission($databaseURI, $obj['leaderId'], $obj['id'], $obj['exerciseId'], $message, 1);
    if ($message != "201") {
        $RequestError = true;
    }
    // shows notification
    if ($RequestError == false) {
        $uploadHistoryNotifications[] = MakeNotification("success", Language::Get('main', 'successSelectSubmission', $langTemplate));
    } else {
        $uploadHistoryNotifications[] = MakeNotification("error", Language::Get('main', 'errorSelectSubmission', $langTemplate));
    }
}
// loads data for the settings element
$URL = $getSiteURI . "/uploadhistoryoptions/user/{$uid}/course/{$cid}";
$uploadHistoryOptions_data = http_get($URL, true);
$uploadHistoryOptions_data = json_decode($uploadHistoryOptions_data, true);
$dataList = array();
foreach ($uploadHistoryOptions_data['users'] as $key => $user) {
    $dataList[] = array('pos' => $key, 'userName' => $user['userName'], 'lastName' => $user['lastName'], 'firstName' => $user['firstName']);
}
$sortTypes = array('lastName', 'firstName', 'userName');
if (!isset($_POST['sortUsers'])) {
    $_POST['sortUsers'] = null;
}
$_POST['sortUsers'] = in_array($_POST['sortUsers'], $sortTypes) ? $_POST['sortUsers'] : $sortTypes[0];
コード例 #8
0
ファイル: Condition.php プロジェクト: sawh/ostepu-system
                $URI = $databaseURI . "/approvalcondition/approvalcondition/" . $approvalConditionId;
                http_put_data($URI, $newApprovalConditionSettings, true, $message);
                if ($message != "201") {
                    $notifications[] = MakeNotification("error", Language::Get('main', 'errorSetCondition', $langTemplate));
                    $RequestError = true;
                }
            } else {
                $notifications[] = MakeNotification("warning", Language::Get('main', 'invalidInput', $langTemplate));
                $RequestError = true;
            }
        }
        // creates a notification depending on RequestError
        if ($RequestError) {
            $notifications[] = MakeNotification("error", Language::Get('main', 'errorSetConditions', $langTemplate));
        } else {
            $notifications[] = MakeNotification("success", Language::Get('main', 'successSetConditions', $langTemplate));
        }
    }
}
if (isset($_GET['downloadConditionCsv'])) {
    $cid = cleanInput($_GET['downloadConditionCsv']);
}
if (isset($_GET['downloadConditionPdf'])) {
    $cid = cleanInput($_GET['downloadConditionPdf']);
}
// load user data from the database
$URL = $getSiteURI . "/condition/user/{$uid}/course/{$cid}";
$condition_data = http_get($URL, true);
$condition_data = json_decode($condition_data, true);
$user_course_data = $condition_data['user'];
$menu = MakeNavigationElement($user_course_data, PRIVILEGE_LEVEL::ADMIN, true);
コード例 #9
0
ファイル: AssignManually.php プロジェクト: sawh/ostepu-system
                // "unassigned" can't obtain proposals (-1 -> "unassiged")
                if ($selectedTutorID != -1) {
                    foreach ($proposals as $props) {
                        // assign to selected tutor
                        $sub = new Submission();
                        $sub->setId($props);
                        $marking = new Marking();
                        $marking->setSubmission($sub);
                        $marking->setStatus(1);
                        $marking->setTutorId($selectedTutorID);
                        $markings[] = $marking;
                    }
                }
            }
            $URI = $serverURI . "/logic/LMarking/marking";
            http_post_data($URI, Marking::encodeMarking($markings), true, $message);
            if ($message == "201" || $message == "200") {
                $msg = Language::Get('main', 'successAssignment', $langTemplate);
                $assignManuallyNotifications[] = MakeNotification("success", $msg);
            } else {
                $msg = Language::Get('main', 'errorAssignment', $langTemplate);
                $assignManuallyNotifications[] = MakeNotification("error", $msg);
            }
        } else {
            if (!isset($assignManuallyNotifications)) {
                $assignManuallyNotifications = array();
            }
            $assignManuallyNotifications = $assignManuallyNotifications + $f->notifications;
        }
    }
}
コード例 #10
0
ファイル: MarkingTool.php プロジェクト: sawh/ostepu-system
            }
            if ($hasChangedSubmission) {
                if ($RequestErrorSubmission) {
                    //$msg = "Beim Speichern für ".$userName." ist ein Fehler aufgetreten.";
                    $msg = Language::Get('main', 'errorSaveSubmission', $langTemplate);
                    if (!isset($GroupNotificationElements[$key])) {
                        $GroupNotificationElements[$key] = array();
                    }
                    $GroupNotificationElements[$key][] = MakeNotification("error", $msg);
                } else {
                    //$msg = "Die Korrektur für ".$userName." wurde erfolgreich gespeichert.";
                    $msg = Language::Get('main', 'editedSubmission', $langTemplate);
                    if (!isset($GroupNotificationElements[$key])) {
                        $GroupNotificationElements[$key] = array();
                    }
                    $GroupNotificationElements[$key][] = MakeNotification("success", $msg);
                }
            }
        }
    }
}
if (!isset($tutorID) && !isset($_POST['action']) && !isset($_GET['downloadCSV'])) {
    $tutorID = $uid;
}
// create URI for GetSite
$URI = $getSiteURI . "/markingtool/user/{$uid}/course/{$cid}/exercisesheet/{$sid}";
if (isset($tutorID)) {
    $URI .= "/tutor/{$tutorID}";
}
if (isset($statusID)) {
    $URI .= "/status/{$statusID}";
コード例 #11
0
            $newTutor = array('tutorId' => $tutorID);
            $data['tutors'][] = $newTutor;
        }
        // adds all unassigned submissions to the request body
        if (!empty($tutorAssign_data['tutorAssignments'])) {
            foreach ($tutorAssign_data['tutorAssignments'] as $tutorAssignment) {
                if ($tutorAssignment['tutor']['userName'] == "unassigned") {
                    foreach ($tutorAssignment['submissions'] as $submission) {
                        unset($submission['unassigned']);
                        $data['unassigned'][] = $submission;
                    }
                }
            }
        }
        $data = json_encode($data);
        $URI = $logicURI . "/tutor/auto/group/course/{$cid}/exercisesheet/{$sid}";
        http_post_data($URI, $data, true, $message);
        if ($message == "201" || $message == "200") {
            $msg = Language::Get('main', 'successAssignment', $langTemplate);
            $assignAutomaticallyNotifications[] = MakeNotification("success", $msg);
        } else {
            $msg = Language::Get('main', 'errorAssignment', $langTemplate);
            $assignAutomaticallyNotifications[] = MakeNotification("error", $msg);
        }
    } else {
        if (!isset($assignAutomaticallyNotifications)) {
            $assignAutomaticallyNotifications = array();
        }
        $assignAutomaticallyNotifications = $assignAutomaticallyNotifications + $f->notifications;
    }
}
コード例 #12
0
ファイル: Student.php プロジェクト: sawh/ostepu-system
    // extractes the studentId of the submission
    $URI = $databaseURI . "/submission/" . $suid;
    $submission = http_get($URI, true);
    $submission = json_decode($submission, true);
    // only deletes the submission if it belongs to the user
    if ($submission['studentId'] == $uid) {
        $URI = $databaseURI . "/selectedsubmission/submission/" . $suid;
        http_delete($URI, true, $message);
        // todo: treat the case if the previous operation failed
        $submissionUpdate = Submission::createSubmission($suid, null, null, null, null, null, null, 0);
        $URI = $databaseURI . "/submission/submission/" . $suid;
        http_put_data($URI, Submission::encodeSubmission($submissionUpdate), true, $message2);
        if ($message == "201" && $message2 == 201) {
            $notifications[] = MakeNotification("success", Language::Get('main', 'successDeleteSubmission', $langTemplate));
        } else {
            $notifications[] = MakeNotification("error", Language::Get('main', 'errorDeleteSubmission', $langTemplate));
        }
    }
} elseif (isset($_POST['downloadMarkings'])) {
    downloadMarkingsForSheet($uid, $_POST['downloadMarkings']);
}
// load tutor data from GetSite
$URI = $getSiteURI . "/student/user/{$uid}/course/{$cid}";
$student_data = http_get($URI, true);
$student_data = json_decode($student_data, true);
$student_data['filesystemURI'] = $filesystemURI;
$student_data['cid'] = $cid;
$student_data['uid'] = $uid;
$user_course_data = $student_data['user'];
$menu = MakeNavigationElement($user_course_data, PRIVILEGE_LEVEL::STUDENT);
// construct a new header
コード例 #13
0
ファイル: CreateSheet.php プロジェクト: sawh/ostepu-system
                } else {
                    $errormsg = Language::Get('main', 'errorCreateSheet', $langTemplate);
                }
                array_push($notifications, MakeNotification('error', $errormsg));
                // delete exercisesheet if exercises are going wrong
                if ($_POST['action'] == 'new') {
                    http_delete($logicURI . '/DB/exercisesheet/exercisesheet/' . $output['id'], true, $message);
                }
            }
        } else {
            if ($_POST['action'] == 'edit') {
                $errormsg = Language::Get('main', 'errorEditSheet', $langTemplate);
            } else {
                $errormsg = Language::Get('main', 'errorCreateSheet', $langTemplate);
            }
            array_push($notifications, MakeNotification('error', $errormsg));
        }
    } else {
        $notifications = array_merge($notifications, $f->notifications);
    }
}
if (isset($sid)) {
    $URL = $databaseURI . "/exercisesheet/exercisesheet/{$sid}/exercise";
    $sheet_data = http_get($URL, true);
    $sheet_data = json_decode($sheet_data, true);
}
$menu = MakeNavigationElement($createsheetData['user'], PRIVILEGE_LEVEL::LECTURER, true);
// construct a new header
$h = Template::WithTemplateFile('include/Header/Header.template.html');
$h->bind($createsheetData['user']);
$h->bind(array("name" => $createsheetData['user']['courses'][0]['course']['name'], "notificationElements" => $notifications, "navigationElement" => $menu));
コード例 #14
0
ファイル: Login.php プロジェクト: sawh/ostepu-system
    // if a hidden Post named back and the php file exists set backurl
    if (isset($_POST['back']) && file_exists(parse_url($_POST['back'], PHP_URL_PATH))) {
        $input['back'] = $_POST['back'];
    } else {
        $input['back'] = "index.php";
    }
    // log in user and return result
    $signed = $auth->loginUser($input['username'], $input['password']);
    if ($signed === true) {
        header('Location: ' . $input['back']);
        exit;
    } else {
        if ($signed !== false) {
            $notifications[] = $signed;
        } else {
            $notifications[] = MakeNotification("error", Language::Get('main', 'errorLogin', $langTemplate));
        }
    }
} else {
    $notifications = array();
}
// check if already logged in
if (Authentication::checkLogin()) {
    header('Location: index.php');
    exit;
}
// construct a new header
$h = Template::WithTemplateFile('include/Header/Header.template.html');
$h->bind(array("backTitle" => Language::Get('main', 'changeCourse', $langTemplate), "name" => Language::Get('main', 'title', $langTemplate), "hideBackLink" => "true", "hideLogoutLink" => "true", "notificationElements" => $notifications));
// construct a login element
$userLogin = Template::WithTemplateFile('include/Login/Login.template.html');
コード例 #15
0
ファイル: Boilerplate.php プロジェクト: sawh/ostepu-system
 *
 * @todo Configuration for logic controller uri could go here.
 */
$notifications = array();
$startup_error = error_get_last();
include_once dirname(__FILE__) . '/Authorization.php';
include_once dirname(__FILE__) . '/HTMLWrapper.php';
include_once dirname(__FILE__) . '/Template.php';
include_once dirname(__FILE__) . '/../../Assistants/Logger.php';
include_once dirname(__FILE__) . '/Helpers.php';
include_once dirname(__FILE__) . '/../../Assistants/Language.php';
if (file_exists(dirname(__FILE__) . '/Config.php')) {
    include_once dirname(__FILE__) . '/Config.php';
}
if ($startup_error !== null) {
    $notifications[] = MakeNotification('error', $startup_error['message']);
    unset($startup_error);
}
if (isset($_GET['cid'])) {
    $cid = $_GET['cid'];
} else {
    Logger::Log('no course id!\\n');
}
if (isset($_SESSION['UID'])) {
    $uid = $_SESSION['UID'];
} else {
    Logger::Log('no user id!\\n');
}
if (isset($_GET['sid'])) {
    $sid = $_GET['sid'];
} else {
コード例 #16
0
ファイル: Admin.php プロジェクト: sawh/ostepu-system
include_once dirname(__FILE__) . '/../Assistants/LArraySorter.php';
global $globalUserData;
Authentication::checkRights(PRIVILEGE_LEVEL::ADMIN, $cid, $uid, $globalUserData);
$langTemplate = 'Admin_Controller';
Language::loadLanguageFile('de', $langTemplate, 'json', dirname(__FILE__) . '/');
$sheetNotifications = array();
if (isset($_POST['action'])) {
    if ($_POST['action'] == "ExerciseSheetLecturer" && isset($_POST['deleteSheetWarning'])) {
        $sheetNotifications[$_POST['deleteSheetWarning']][] = MakeNotification("warning", Language::Get('main', 'askDeleteSubmission', $langTemplate));
    } elseif ($_POST['action'] == "ExerciseSheetLecturer" && isset($_POST['deleteSheet'])) {
        $URL = $logicURI . "/exercisesheet/exercisesheet/{$_POST['deleteSheet']}";
        $result = http_delete($URL, true, $message);
        if ($message == 201) {
            $sheetNotifications[$_POST['deleteSheet']][] = MakeNotification('success', Language::Get('main', 'successDeleteSubmission', $langTemplate));
        } else {
            $sheetNotifications[$_POST['deleteSheet']][] = MakeNotification('error', Language::Get('main', 'errorDeleteSubmission', $langTemplate));
        }
    }
}
// load GetSite data for Admin.php
$URL = $getSiteURI . "/admin/user/{$uid}/course/{$cid}";
$admin_data = http_get($URL, true);
$admin_data = json_decode($admin_data, true);
$admin_data['filesystemURI'] = $filesystemURI;
$admin_data['cid'] = $cid;
$user_course_data = $admin_data['user'];
$menu = MakeNavigationElement($user_course_data, PRIVILEGE_LEVEL::ADMIN);
// construct a new header
$h = Template::WithTemplateFile('include/Header/Header.template.html');
$h->bind($user_course_data);
$h->bind(array("name" => $user_course_data['courses'][0]['course']['name'], "backTitle" => Language::Get('main', 'changeCourse', $langTemplate), "backURL" => "index.php", "notificationElements" => $notifications, "navigationElement" => $menu));
コード例 #17
0
ファイル: Upload.php プロジェクト: sawh/ostepu-system
$hasStarted = null;
if (isset($upload_data['exerciseSheet']['endDate']) && isset($upload_data['exerciseSheet']['startDate'])) {
    // bool if endDate of sheet is greater than the actual date
    $isExpired = date('U') > date('U', $upload_data['exerciseSheet']['endDate']);
    // bool if startDate of sheet is greater than the actual date
    $hasStarted = date('U') > date('U', $upload_data['exerciseSheet']['startDate']);
    if ($isExpired) {
        $allowed = 0;
        if (isset($user_course_data['courses'][0]['course'])) {
            $obj = Course::decodeCourse(Course::encodeCourse($user_course_data['courses'][0]['course']));
            $allowed = Course::containsSetting($obj, 'AllowLateSubmissions');
        }
        ///set_error("Der Übungszeitraum ist am ".date('d.m.Y  -  H:i', $upload_data['exerciseSheet']['endDate'])." abgelaufen!");
        if ($allowed === null || $allowed == 1) {
            $msg = Language::Get('main', 'expiredExercisePerionDesc', $langTemplate, array('endDate' => date('d.m.Y  -  H:i', $upload_data['exerciseSheet']['endDate'])));
            $notifications[] = MakeNotification('warning', $msg);
        } else {
            set_error(Language::Get('main', 'expiredExercisePerion', $langTemplate, array('endDate' => date('d.m.Y  -  H:i', $upload_data['exerciseSheet']['endDate']))));
        }
    } elseif (!$hasStarted) {
        set_error(Language::Get('main', 'noStartedExercisePeriod', $langTemplate, array('startDate' => date('d.m.Y  -  H:i', $upload_data['exerciseSheet']['startDate']))));
    }
} else {
    set_error(Language::Get('main', 'noExercisePeriod', $langTemplate));
}
//$formdata = file_get_contents('FormSample.json');
$URL = $serverURI . "/DB/DBForm/form/exercisesheet/{$sid}";
$formdata = http_get($URL, true);
$formdata = Form::decodeForm($formdata);
if (!is_array($formdata)) {
    $formdata = array($formdata);
コード例 #18
0
            }
        } 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;
            }
        }
    }
}
// load user data from the database
$databaseURI = $getSiteURI . "/accountsettings/user/{$uid}";
$accountSettings_data = http_get($databaseURI, true);
$accountSettings_data = json_decode($accountSettings_data, true);
// construct a new header
$h = Template::WithTemplateFile('include/Header/Header.template.html');
$h->bind($accountSettings_data);
$h->bind(array("name" => Language::Get('main', 'accountSettings', $langTemplate), "backTitle" => Language::Get('main', 'course', $langTemplate), "backURL" => "index.php", "notificationElements" => $notifications));
コード例 #19
0
ファイル: AssignRemove.php プロジェクト: sawh/ostepu-system
<?php

// removes all tutor assignments by deleting all markings of the exercisesheet
if (isset($_POST['action']) && $_POST['action'] == "AssignRemoveWarning") {
    $assignRemoveNotifications[] = MakeNotification("warning", Language::Get('main', 'askUnassign', $langTemplate));
} elseif (isset($_POST['action']) && $_POST['action'] == "AssignRemove") {
    $URI = $databaseURI . "/marking/exercisesheet/" . $sid;
    http_delete($URI, true, $message);
    if ($message == "201") {
        $msg = Language::Get('main', 'successUnassign', $langTemplate);
        $assignRemoveNotifications[] = MakeNotification("success", $msg);
    } else {
        $msg = Language::Get('main', 'errorUnassign', $langTemplate);
        $assignRemoveNotifications[] = MakeNotification("error", $msg);
    }
}