...
 
Commits (3)
......@@ -19,16 +19,14 @@ class RestDebugController extends RestBaseController {
new vFormValidationField('forename', 'Vorname', 'required|min_length[2]'),
new vFormValidationField('surname', 'Nachname', 'required|min_length[2]'),
new vFormValidationField('uid', 'uid', 'required|min_length[4]'),
new vFormValidationField('eppn', 'eppn', 'required|valid_email'),
new vFormValidationField('groups', 'Gruppen', 'required|min_length[2]')
new vFormValidationField('eppn', 'eppn', 'required|valid_email')
));
$this->user->debugLogin(
$v['uid']->getValue(),
$v['forename']->getValue(),
$v['surname']->getValue(),
$v['forename']->getValue() . " " . $v['surname']->getValue(),
$v['eppn']->getValue(),
$v['groups']->getValue()
$v['eppn']->getValue()
);
vRest::success(true);
}
......
......@@ -29,27 +29,26 @@ class UserController extends BaseController {
$deprecated = $user['deprecated'];
$deprecatedMsg = $deprecated ? " (veraltet)" : "";
$showMail = ($isAdmin || $user['show_mail']);
// filter out the student number
if($showMail)
$mail = vHtml::encryptText(preg_replace("#\+[0-9]*@#", '@', $user['mail']));
$mail = isset($mail) ? ($mail . $deprecatedMsg) : "";
$innerData = array('Anzeigename:' => htmlspecialchars($user['displayname']));
if($this->user->isLoggedIn()) {
$innerData['Username:'] = htmlspecialchars($user['name'] . $deprecatedMsg);
$innerData['Vorname:'] = htmlspecialchars($user['forename']);
$innerData['Nachname:'] = htmlspecialchars($user['surname']);
}
// admin can see all emails, others only if the user said yes
if($isAdmin || $user['show_mail']) {
// filter out the student number and encrypt
$innerData['E-Mail:'] = vHtml::encryptText(preg_replace("#\+[0-9]*@#", '@', $user['mail']));
}
$innerData['Admin:'] = $user['admin'] ? "Ja" : "Nein";
$data = array(
'data' => array(
'Anzeigename:' => htmlspecialchars($user['displayname']),
'Username:' => htmlspecialchars($user['name'] . $deprecatedMsg),
'Vorname:' => htmlspecialchars($user['forename']),
'Nachname:' => htmlspecialchars($user['surname']),
'Gruppen:' => htmlspecialchars(implode(", ", Utils::parseGroups($user['groups']))),
'E-Mail' => $mail,
'Admin' => $user['admin'] ? "Ja" : "Nein"
),
'data' => $innerData,
'userId' => $id,
'deprecated' => $deprecated,
'isAdmin' => $isAdmin
);
if(!$this->user->isLoggedIn())
unset($data['data']['Username:']);
vTemplate::pushView('content', 'content/userinfo', $data);
$this->loadSidebar(null);
......
......@@ -56,15 +56,14 @@ class User {
$_SERVER['givenName'],
$_SERVER['sn'],
$_SERVER['displayName'],
$_SERVER['eppn'],
$_SERVER['isMemberOf']);
$_SERVER['eppn']);
$this->saveSession();
return true;
}
return false;
}
private function createOrUpdateUser($username, $forename, $surname, $displayname, $mail, $groups) {
private function createOrUpdateUser($username, $forename, $surname, $displayname, $mail) {
vDb::transactionBegin();
$user = vDb::get("user")->select("id, displayname, admin")->where("mail", $mail)->fetch();
if($user === false) {
......@@ -76,8 +75,7 @@ class User {
'forename' => $forename,
'surname' => $surname,
'displayname' => $displayname,
'mail' => $mail,
'groups' => $groups
'mail' => $mail
));
if($user === false)
trigger_error ("Error creating user");
......@@ -93,8 +91,7 @@ class User {
$result = $user->update(array(
'name' => $username,
'forename' => $forename,
'surname' => $surname,
'groups' => $groups
'surname' => $surname
));
if($result === false)
trigger_error ("Error updating user");
......@@ -104,8 +101,8 @@ class User {
}
// Todo: remove debug functions on release
public function debugLogin($username, $forename, $surname, $displayname, $mail, $groups) {
$this->createOrUpdateUser($username, $forename, $surname, $displayname, $mail, $groups);
public function debugLogin($username, $forename, $surname, $displayname, $mail) {
$this->createOrUpdateUser($username, $forename, $surname, $displayname, $mail);
$this->saveSession();
}
......
......@@ -8,11 +8,6 @@ use velox\vTemplate;
use blushee\SoftException;
class Utils {
private static $GROUP_MAP = array(
"student"=> "Student",
"infstd" => "Informatik Student",
"fsinf" => "Ratsmitglied (FSRI)"
);
public static function escapeForSegment($str) {
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
......@@ -121,14 +116,4 @@ class Utils {
return $rows->order('controversy DESC');
return $rows->order('hotness DESC');
}
public static function parseGroups($groups) {
$list = explode(";", $groups);
$out = array();
foreach ($list as $short) {
if(array_key_exists($short, self::$GROUP_MAP))
$out[]= self::$GROUP_MAP[$short];
}
return $out;
}
}
......@@ -83,7 +83,6 @@ CREATE TABLE IF NOT EXISTS `user` (
`surname` text COLLATE utf8_bin NOT NULL,
`displayname` text COLLATE utf8_bin NOT NULL,
`mail` text COLLATE utf8_bin NOT NULL,
`groups` text COLLATE utf8_bin NOT NULL,
`admin` tinyint(1) NOT NULL DEFAULT '0',
`show_mail` tinyint(1) NOT NULL DEFAULT '0',
`deprecated` tinyint(1) NOT NULL DEFAULT '0'
......
......@@ -41,10 +41,6 @@
<td>eppn</td>
<td><input name="eppn" value="mustermm+123456@hochschule-trier.de"></td>
</tr>
<tr>
<td>Gruppen</td>
<td><input name="groups" value="student;infstd;fsinf"></td>
</tr>
</table>
</div>
<div class="modal-footer">
......
<?php namespace velox; ?>
<footer>
&copy; <?=$year;?>, <a href="https://fsi.hochschule-trier.de">Fachschaft Informatik</a>
<a href="https://hochschule-trier.de">Hochschule Trier</a> -
<a href="https://hochschule-trier.de">Hochschule Trier</a> -
<a href="https://fsi.hochschule-trier.de/datenschutzerklaerung">Datenschutzerklärung</a> -
<a href="https://fsi.hochschule-trier.de/impressum/">Impressum</a> -
<a href="<?=vRequest::siteUrl('user/admins');?>">User mit Adminstatus</a>
</footer>