/** * @return Stage */ public static function frontendAccount() { $Stage = new Stage('Benutzerkonnten'); $tblAccount = Account::useService()->getAccountBySession(); if ($tblAccount) { $isSystem = Account::useService()->hasAuthorization($tblAccount, Access::useService()->getRoleByName('Administrator')); } else { $isSystem = false; } $tblConsumer = Consumer::useService()->getConsumerBySession(); // Token $tblTokenAll = Token::useService()->getTokenAll(); array_walk($tblTokenAll, function (TblToken &$tblToken) { if (Account::useService()->getAccountAllByToken($tblToken)) { $tblToken = false; } else { $tblToken = new RadioBox('Account[Token]', implode(' ', str_split($tblToken->getSerial(), 4)), $tblToken->getId()); } }); $tblTokenAll = array_filter($tblTokenAll); array_unshift($tblTokenAll, new RadioBox('Account[Token]', new \SPHERE\Common\Frontend\Text\Repository\Danger('KEIN Hardware-Token'), null)); // Identification $tblIdentificationAll = Account::useService()->getIdentificationAll(); /** @noinspection PhpUnusedParameterInspection */ array_walk($tblIdentificationAll, function (TblIdentification &$tblIdentification, $Index, $isSystem) { if ($tblIdentification->getName() == 'System' && !$isSystem) { $tblIdentification = false; } else { $tblIdentification = new RadioBox('Account[Identification]', $tblIdentification->getDescription(), $tblIdentification->getId()); } }, $isSystem); $tblIdentificationAll = array_filter($tblIdentificationAll); // Role $tblRoleAll = Access::useService()->getRoleAll(); /** @noinspection PhpUnusedParameterInspection */ array_walk($tblRoleAll, function (TblRole &$tblRole, $Index, $isSystem) { if ($tblRole->getName() == 'Administrator' && !$isSystem) { $tblRole = false; } else { $tblRole = new CheckBox('Account[Role][' . $tblRole->getId() . ']', $tblRole->getName(), $tblRole->getId()); } }, $isSystem); $tblRoleAll = array_filter($tblRoleAll); // Account $tblAccountAll = Account::useService()->getAccountAll(); array_walk($tblAccountAll, function (TblAccount &$tblAccount) { /** @noinspection PhpUndefinedFieldInspection */ $tblAccount->Option = new Danger('Löschen', '/Platform/Gatekeeper/Authorization/Account/Destroy', new Remove(), array('Id' => $tblAccount->getId()), 'Löschen'); }); $Stage->setContent(($tblAccountAll ? new TableData($tblAccountAll, new Title('Bestehende Benutzerkonnten'), array('Username' => 'Benutzername')) : new Warning('Keine Benutzerkonnten vorhanden')) . new Form(array(new FormGroup(array(new FormRow(array(new FormColumn((new TextField('Account[Name]', 'Benutzername', 'Benutzername', new Person()))->setPrefixValue($tblConsumer->getAcronym()), 4), new FormColumn(new PasswordField('Account[Password]', 'Passwort', 'Passwort', new Lock()), 4), new FormColumn(new PasswordField('Account[PasswordSafety]', 'Passwort wiederholen', 'Passwort wiederholen', new Repeat()), 4)))), new \SPHERE\Common\Frontend\Form\Repository\Title('Benutzerkonnto anlegen')), new FormGroup(array(new FormRow(array(new FormColumn(array(new Panel('Authentifizierungstyp', $tblIdentificationAll)), 4), new FormColumn(array(new Panel('Berechtigungsstufe', $tblRoleAll)), 4), new FormColumn(array(new Panel('Hardware-Token', $tblTokenAll)), 4)))), new \SPHERE\Common\Frontend\Form\Repository\Title('Berechtigungen zuweisen'))), new Primary('Hinzufügen'))); return $Stage; }
/** * @return Form */ private function formPerson() { $tblGroupList = Group::useService()->getGroupAll(); if ($tblGroupList) { // Sort by Name usort($tblGroupList, function (TblGroup $ObjectA, TblGroup $ObjectB) { return strnatcmp($ObjectA->getName(), $ObjectB->getName()); }); // Create CheckBoxes /** @noinspection PhpUnusedParameterInspection */ array_walk($tblGroupList, function (TblGroup &$tblGroup) { switch (strtoupper($tblGroup->getMetaTable())) { case 'COMMON': $Global = $this->getGlobal(); $Global->POST['Person']['Group'][$tblGroup->getId()] = $tblGroup->getId(); $Global->savePost(); $tblGroup = new RadioBox('Person[Group][' . $tblGroup->getId() . ']', $tblGroup->getName() . ' ' . new Muted(new Small($tblGroup->getDescription())), $tblGroup->getId()); break; default: $tblGroup = new CheckBox('Person[Group][' . $tblGroup->getId() . ']', $tblGroup->getName() . ' ' . new Muted(new Small($tblGroup->getDescription())), $tblGroup->getId()); } }); } else { $tblGroupList = array(new Warning('Keine Gruppen vorhanden')); } $tblSalutationAll = Person::useService()->getSalutationAll(); return new Form(new FormGroup(array(new FormRow(array(new FormColumn(new Panel('Anrede', array(new SelectBox('Person[Salutation]', 'Anrede', array('Salutation' => $tblSalutationAll), new Conversation()), new AutoCompleter('Person[Title]', 'Titel', 'Titel', array('Dipl.- Ing.'), new Conversation())), Panel::PANEL_TYPE_INFO), 4), new FormColumn(new Panel('Name', array(new TextField('Person[FirstName]', 'Rufname', 'Vorname'), new TextField('Person[SecondName]', 'weitere Vornamen', 'Zweiter Vorname'), new TextField('Person[LastName]', 'Nachname geb. Geburtsname', 'Nachname / Geburtsname')), Panel::PANEL_TYPE_INFO), 4), new FormColumn(new Panel('Gruppen', $tblGroupList, Panel::PANEL_TYPE_INFO), 4)))))); }
/** * @return Form */ private function formAccount() { $tblConsumer = Consumer::useService()->getConsumerBySession(); // Identification $tblIdentificationAll = Account::useService()->getIdentificationAll(); array_walk($tblIdentificationAll, function (TblIdentification &$tblIdentification) { if ($tblIdentification->getName() == 'System') { $tblIdentification = false; } else { switch (strtoupper($tblIdentification->getName())) { case 'STUDENT': $Global = $this->getGlobal(); if (!isset($Global->POST['Account']['Identification'])) { $Global->POST['Account']['Identification'] = $tblIdentification->getId(); $Global->savePost(); } $Label = $tblIdentification->getDescription(); break; default: $Label = $tblIdentification->getDescription() . ' (' . new Key() . ')'; } $tblIdentification = new RadioBox('Account[Identification]', $Label, $tblIdentification->getId()); } }); $tblIdentificationAll = array_filter($tblIdentificationAll); // Role $tblRoleAll = Access::useService()->getRoleAll(); array_walk($tblRoleAll, function (TblRole &$tblRole) { if ($tblRole->getName() == 'Administrator') { $tblRole = false; } else { $tblRole = new CheckBox('Account[Role][' . $tblRole->getId() . ']', $tblRole->getName(), $tblRole->getId()); } }); $tblRoleAll = array_filter($tblRoleAll); // Token $Global = $this->getGlobal(); if (!isset($Global->POST['Account']['Token'])) { $Global->POST['Account']['Token'] = 0; $Global->savePost(); } $tblTokenAll = Token::useService()->getTokenAllByConsumer(Consumer::useService()->getConsumerBySession()); array_walk($tblTokenAll, function (TblToken &$tblToken) { if (Account::useService()->getAccountAllByToken($tblToken)) { $tblToken = false; } else { $tblToken = new RadioBox('Account[Token]', implode(' ', str_split($tblToken->getSerial(), 4)), $tblToken->getId()); } }); $tblTokenAll = array_filter($tblTokenAll); array_unshift($tblTokenAll, new RadioBox('Account[Token]', new Danger('KEIN Hardware-Schlüssel'), 0)); // Person $tblPersonAll = Account::useService()->getPersonAllHavingNoAccount(); if ($tblPersonAll) { array_walk($tblPersonAll, function (TblPerson &$tblPerson) { $tblPerson = new RadioBox('Account[User]', $tblPerson->getFullName(), $tblPerson->getId()); }); $tblPersonAll = array_filter($tblPersonAll); } return new Form(array(new FormGroup(array(new FormRow(array(new FormColumn(new Panel(new PersonKey() . ' Benutzerkonto hinzufügen', array((new TextField('Account[Name]', 'Benutzername (min. 5 Zeichen)', 'Benutzername', new Person()))->setPrefixValue($tblConsumer->getAcronym()), new PasswordField('Account[Password]', 'Passwort (min. 8 Zeichen)', 'Passwort', new Lock()), new PasswordField('Account[PasswordSafety]', 'Passwort wiederholen', 'Passwort wiederholen', new Repeat())), Panel::PANEL_TYPE_INFO), 4), new FormColumn(array(new Panel(new Nameplate() . ' Berechtigungsstufe zuweisen', $tblRoleAll, Panel::PANEL_TYPE_INFO), new Panel(new Person() . ' Person zuweisen', $tblPersonAll, Panel::PANEL_TYPE_INFO, null, true)), 4), new FormColumn(array(new Panel(new Lock() . ' Authentifizierungstyp wählen', $tblIdentificationAll, Panel::PANEL_TYPE_INFO), new Panel(new Key() . ' Hardware-Schlüssel zuweisen', $tblTokenAll, Panel::PANEL_TYPE_INFO)), 4))))))); }
/** * @return Form */ private function formCompany() { $tblGroupList = Group::useService()->getGroupAll(); if ($tblGroupList) { // Sort by Name usort($tblGroupList, function (TblGroup $ObjectA, TblGroup $ObjectB) { return strnatcmp($ObjectA->getName(), $ObjectB->getName()); }); // Create CheckBoxes /** @noinspection PhpUnusedParameterInspection */ array_walk($tblGroupList, function (TblGroup &$tblGroup) { switch (strtoupper($tblGroup->getMetaTable())) { case 'COMMON': $Global = $this->getGlobal(); $Global->POST['Company']['Group'][$tblGroup->getId()] = $tblGroup->getId(); $Global->savePost(); $tblGroup = new RadioBox('Company[Group][' . $tblGroup->getId() . ']', $tblGroup->getName() . ' ' . new Muted(new Small($tblGroup->getDescription())), $tblGroup->getId()); break; default: $tblGroup = new CheckBox('Company[Group][' . $tblGroup->getId() . ']', $tblGroup->getName() . ' ' . new Muted(new Small($tblGroup->getDescription())), $tblGroup->getId()); } }); } else { $tblGroupList = array(new Warning('Keine Gruppen vorhanden')); } return new Form(new FormGroup(array(new FormRow(array(new FormColumn(new Panel('Firmenname', array(new TextField('Company[Name]', 'Name', 'Name'), new TextField('Company[Description]', 'Beschreibung', 'Beschreibung')), Panel::PANEL_TYPE_INFO), 8), new FormColumn(new Panel('Gruppen', $tblGroupList, Panel::PANEL_TYPE_INFO), 4)))))); }