public function testFloatParam() { $this->assertNull(Request::float('null')); $this->assertSame(Request::float('a'), 0.0); $this->assertSame(Request::float('c'), -23.0); $this->assertSame(Request::float('d'), 12.7); $this->assertSame(Request::float('e'), 3.14); $this->assertNull(Request::float('v1')); }
/** * Saves the given user list to database. * * @param String $userlistId user list to save */ public function save_action($userlistId = '') { CSRFProtection::verifyUnsafeRequest(); $userlist = new AdmissionUserList($userlistId); $userlist->setName(Request::get('name'))->setFactor(Request::float('factor'))->setUsers(Request::getArray('users'))->setOwnerId($GLOBALS['user']->id); if ($userlist->store()) { PageLayout::postSuccess(_('Die Personenliste wurde gespeichert.')); } else { PageLayout::postError(_('Die Personenliste konnte nicht gespeichert werden.')); } $this->redirect('admission/userlist'); }
function store_action($config_id, $isGroupConfig) { if (Request::float('upload_size') && Request::float('quota_size')) { if($config_id == 0){ $data['id'] = ''; $data['usergroup'] = Request::get('group'); }else{ $data['id'] = $config_id; } $data['upload_quota'] = $this->sizeInByte(Request::float('upload_size'), Request::get('unitUpload')); $data['quota'] = $this->sizeInByte(Request::float('quota_size'), Request::get('unitQuota')); if($isGroupConfig == false){ $data['is_group_config'] = 0; }else{ $data['is_group_config'] = 1; } if ($data['upload_quota'] <= $data['quota'] && $data['quota'] >= 0 && $data['upload_quota'] >= 0) { $data['upload_forbidden'] = '0'; $data['quota_unit'] = Request::get('unitQuota'); $data['upload_unit'] = Request::get('unitUpload'); $data['datetype_id'] = Request::intArray('datetype'); if(DocUsergroupConfig::setConfig($data)){ $message = 'Das Speichern der Einstellungen war erfolgreich. '; PageLayout::postMessage(MessageBox::success($message)); }else{ PageLayout::postMessage(MessageBox::error(_( 'Beim speichern der Einstellungen ist ein Fehler aufgetreten'. ' oder es wurden keine Änderungen vorgenommen.'))); } }else{ PageLayout::postMessage(MessageBox::error(_( 'Upload-Quota ist größer als das gesamte Nutzer-Quota. Bitte korrigieren Sie Ihre Eingabe.'))); } }else{ PageLayout::postMessage(MessageBox::error(_( 'Es wurden fehlerhafte Werte für die Quota eingegeben.'))); } $this->redirect('document/administration/filter'); }
/** * Saves a cycle */ public function saveCycle_action() { CSRFProtection::verifyRequest(); $start = strtotime(Request::get('start_time')); $end = strtotime(Request::get('end_time')); if (date('H', $start) > date('H', $end)) { $this->storeRequest(); PageLayout::postMessage(MessageBox::error(_('Die Zeitangaben sind nicht korrekt. Bitte überprüfen Sie diese!'))); $this->redirect('course/timesrooms/createCycle'); return; } $cycle = new SeminarCycleDate(); $cycle->seminar_id = $this->course->id; $cycle->weekday = Request::int('day'); $cycle->description = Request::get('description'); $cycle->sws = round(Request::float('teacher_sws'), 1); $cycle->cycle = Request::int('cycle'); $cycle->week_offset = Request::int('startWeek'); $cycle->end_offset = Request::int('endWeek') ?: null; $cycle->start_time = date('H:i:00', $start); $cycle->end_time = date('H:i:00', $end); if ($cycle->store()) { $cycle_info = $cycle->toString(); NotificationCenter::postNotification('CourseDidChangeSchedule', $this); $this->course->createMessage(sprintf(_('Die regelmäßige Veranstaltungszeit %s wurde hinzugefügt!'), $cycle_info)); $this->displayMessages(); if (Request::get('fromDialog') == 'true') { $this->redirect('course/timesrooms/index'); } else { $this->relocate('course/timesrooms/index'); } } else { $this->storeRequest(); $this->course->createError(_('Die regelmäßige Veranstaltungszeit konnte nicht hinzugefügt werden! Bitte überprüfen Sie Ihre Eingabe.')); $this->displayMessages(); $this->redirect('course/timesrooms/createCycle'); } }
/** * @return bool */ function auth_validatelogin() { global $_language_path; //prevent replay attack if (!Seminar_Session::check_ticket(Request::option('login_ticket'))) { return false; } // check for direct link if (!$_SESSION['_language'] || $_SESSION['_language'] == "") { $_SESSION['_language'] = get_accepted_languages(); } $_language_path = init_i18n($_SESSION['_language']); include 'config.inc.php'; $this->auth["uname"] = Request::get('loginname'); // This provides access for "loginform.ihtml" $this->auth["jscript"] = Request::get('resolution') != ""; $this->auth['devicePixelRatio'] = Request::float('device_pixel_ratio'); $check_auth = StudipAuthAbstract::CheckAuthentication(Request::get('loginname'), Request::get('password')); if ($check_auth['uid']) { $uid = $check_auth['uid']; if ($check_auth['need_email_activation'] == $uid) { $this->need_email_activation = $uid; $_SESSION['semi_logged_in'] = $uid; return false; } $user = $check_auth['user']; $this->auth["perm"] = $user->perms; $this->auth["uname"] = $user->username; $this->auth["auth_plugin"] = $user->auth_plugin; $this->auth_set_user_settings($user); Metrics::increment('core.login.succeeded'); return $uid; } else { Metrics::increment('core.login.failed'); $this->error_msg = $check_auth['error']; return false; } }