private function getAccounts(\Nethgui\View\ViewInterface $view) { static $ds; if (isset($ds)) { return $ds; } $data = json_decode($this->getPlatform()->exec("/usr/bin/sudo /usr/libexec/nethserver/read-mail-accounts")->getOutput(), TRUE); $users = \Nethgui\Widget\XhtmlWidget::hashToDatasource($data['users'], TRUE); $groups = \Nethgui\Widget\XhtmlWidget::hashToDatasource($data['groups'], TRUE); $ds = array(); if ($users) { $ds[] = array($users, $view->translate('Users_label')); } if ($groups) { $ds[] = array($groups, $view->translate('Groups_label')); } return $ds; }
/** * Find interfaces names with a role and associated to a non-existent MAC address */ private function getCards($T) { $formatInterface = function ($e) { return strtr($e['bootproto'] === 'dhcp' ? 'role DHCP(hwaddr)' : 'role ipaddr', $e); }; $basicDatasource = array('' => $T('[leave untouched]')); $interfaceDatasource = array_merge($basicDatasource, array_map($formatInterface, $this->getUnassignedInterfaces())); $ndb = $this->getPlatform()->getDatabase('networks')->getAll('ethernet'); if (count($interfaceDatasource) === 1) { return array(); } $fields = explode(' ', 'name hwaddr type model driver speed link'); $parsef = function ($line) use($fields, $interfaceDatasource, $basicDatasource, $ndb, $T) { $values = str_getcsv($line); $h = array_combine($fields, $values); $h['linkText'] = $h['link'] ? $T('Link is up') : $T('Link is down'); $h['link'] = $h['link'] ? 'linkup' : 'linkdown'; $h['currentRole'] = isset($ndb[$h['name']], $ndb[$h['name']]['role']) ? $ndb[$h['name']]['role'] : 'black'; $isPresent = isset($ndb[$h['name']]) && isset($ndb[$h['name']]['role']) && $ndb[$h['name']]['role'] != '' && strtolower($ndb[$h['name']]['hwaddr']) === strtolower($h['hwaddr']); $h['interfaceDatasource'] = \Nethgui\Widget\XhtmlWidget::hashToDatasource($isPresent ? $basicDatasource : $interfaceDatasource); $h['configuration'] = $isPresent ? 'configured' : 'unconfigured'; return $h; }; $cards = array_map($parsef, $this->getNicInfo()); if ($this->getRequest()->isMutation()) { return $this->requestAssignment($cards); } else { return $cards; } }
public function getAccountDatasource() { $userProvider = new \NethServer\Tool\UserProvider($this->getPlatform()); $groupProvider = new \NethServer\Tool\GroupProvider($this->getPlatform()); $mbxProvider = new \NethServer\Module\MailAccount\SharedMailbox\SharedMailboxAdapter($this->getPlatform()); $users = $userProvider->getUsers(); $hash = array(); if ($this->parameters['Account'] instanceof \Traversable) { foreach ($this->parameters['Account'] as $a) { $hash[$a] = $a; } } foreach ($users as $key => $prop) { $hash[$key] = $key; } foreach ($groupProvider->getGroups() as $key => $prop) { $hash[$key] = $key; } foreach ($mbxProvider->getSharedMailboxList() as $mbx) { $hash['vmail+' . $mbx['name']] = $mbx['name']; } return \Nethgui\Widget\XhtmlWidget::hashToDatasource($hash, TRUE); }
<?php /* @var $view \Nethgui\Renderer\Xhtml */ echo $view->header()->setAttribute('template', $T('SetPppoeParameters_header')); echo $view->selector('PppoeInterface', $view::SELECTOR_DROPDOWN)->setAttribute('choices', 'PppoeInterfaceDatasource'); echo $view->textInput('PppoeProvider'); echo $view->textInput('PppoeUser'); echo $view->textInput('PppoePassword'); echo $view->selector('PppoeAuthType', $view::SELECTOR_DROPDOWN)->setAttribute('choices', \Nethgui\Widget\XhtmlWidget::hashToDatasource(array('auto' => $T('AuthType_auto'), 'pap' => $T('AuthType_pap'), 'chap' => $T('AuthType_chap')))); echo $view->buttonList($view::BUTTON_HELP)->insert($view->button('Submit', $view::BUTTON_SUBMIT))->insert($view->button('Back', $view::BUTTON_CANCEL));
/** * Convert the given hash to the array format accepted from UI widgets as * "datasource". * * Deprecated here. Moved to \Nethgui\Widget\XhtmlWidget::hashToDatasource. * * @api * @param array $h * @param boolean $sort -- default FALSE * @return array * @deprecated since 1.6 * @see \Nethgui\Widget\XhtmlWidget::hashToDatasource */ public static function hashToDatasource($H, $sort = FALSE) { $log = new \Nethgui\Log\Syslog(E_WARNING); $log->deprecated(); return \Nethgui\Widget\XhtmlWidget::hashToDatasource($H, $sort); }