Пример #1
0
 /**
  * @return Layout
  */
 public function frontendLayoutToken()
 {
     $tblTokenAll = Token::useService()->getTokenAllByConsumer(Consumer::useService()->getConsumerBySession());
     if ($tblTokenAll !== false) {
         array_walk($tblTokenAll, function (TblToken &$tblToken) {
             $Serial = $tblToken->getSerial();
             $Serial = substr($Serial, 0, 4) . ' ' . substr($Serial, 4, 4);
             $Content = array();
             $tblAccountAll = $tblToken->getAccountAllByToken();
             if (!empty($tblAccountAll)) {
                 array_walk($tblAccountAll, function (TblAccount &$tblAccount) {
                     $tblAccount = new PullClear(new PullLeft(new PersonKey() . ' ' . $tblAccount->getUsername()) . new PullRight(new Standard('', '/Setting/Authorization/Account', new PersonKey(), array('Id' => $tblAccount->getId()), 'zu ' . $tblAccount->getUsername() . ' wechseln')));
                 });
                 $Content = array_merge($Content, $tblAccountAll);
                 $Content = array_filter($Content);
                 array_unshift($Content, new Info(new Exclamation() . ' ' . new Small('Benutzerkonten verknüpft')));
             } else {
                 $Content = array(new Muted(new Small('Keine Benutzerkonten verknüpft')), new Muted(new Small('Der Schlüssel kann gefahrlos entfernt werden')));
             }
             $tblToken = new LayoutColumn(new Panel(new YubiKey() . ' ' . $Serial, $Content, Panel::PANEL_TYPE_INFO, empty($tblAccountAll) ? new Standard('', '/Setting/Authorization/Token/Destroy', new Remove(), array('Id' => $tblToken->getId()), 'Schlüssel ' . $Serial . ' löschen') : new Muted(new Small('Der Schlüssel kann nicht entfernt werden'))), 3);
         });
     } else {
         $tblTokenAll = array(new LayoutColumn(new Warning('Keine Hardware-Schlüssel hinterlegt')));
     }
     $LayoutRowList = array();
     $LayoutRowCount = 0;
     $LayoutRow = null;
     /**
      * @var LayoutColumn $tblToken
      */
     foreach ($tblTokenAll as $tblToken) {
         if ($LayoutRowCount % 4 == 0) {
             $LayoutRow = new LayoutRow(array());
             $LayoutRowList[] = $LayoutRow;
         }
         $LayoutRow->addColumn($tblToken);
         $LayoutRowCount++;
     }
     return new Layout(new LayoutGroup($LayoutRowList));
 }