예제 #1
0
 /**
  * @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;
 }
예제 #2
0
 /**
  * @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)))))));
 }