public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     parent::prepareView($view);
     $view['username'] = $this->userName;
     $view['FullName'] = $this->getPlatform()->getDatabase('NethServer::Database::Passwd')->getProp($this->userName, 'gecos');
     $provider = new \NethServer\Tool\UserProvider($this->getPlatform());
     $view['readOnly'] = $provider->isReadOnly();
     $view['ChangePassword'] = $view->getModuleUrl('../ChangePassword');
 }
Example #2
0
 protected function initializeAttributes(\Nethgui\Module\ModuleAttributesInterface $base)
 {
     $provider = new \NethServer\Tool\UserProvider($this->getPlatform());
     # hide this module if no provider is installed
     if ($provider->isReadOnly()) {
         return $base;
     } else {
         return \Nethgui\Module\SimpleModuleAttributesProvider::extendModuleAttributes($base, 'Security', 30);
     }
 }
 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);
 }
Example #4
0
 public function validate(\Nethgui\Controller\ValidationReportInterface $report)
 {
     if (!$this->getRequest()->isMutation()) {
         return;
     }
     if ($this->getIdentifier() === 'delete') {
         $v = $this->createValidator()->platform('user-delete');
         if (!$v->evaluate($this->getAdapter()->getKeyValue())) {
             $report->addValidationError($this, 'username', $v);
         }
     }
     if ($this->getIdentifier() === 'update' || $this->getIdentifier() === 'create') {
         $groups = array_keys($this->getGroupProvider()->getGroups());
         $this->getValidator('groups')->memberOf($groups);
     }
     if ($this->getIdentifier() === 'create') {
         $users = array();
         if ($this->parameters['setPassword'] === 'enabled') {
             $passwordValidator = $this->getPlatform()->createValidator()->platform('password-strength', 'Users');
             $this->stash = new \NethServer\Tool\PasswordStash();
             $this->stash->store($this->parameters['newPassword']);
             if ($this->parameters['newPassword'] !== $this->parameters['confirmNewPassword']) {
                 $report->addValidationErrorMessage($this, 'confirmNewPassword', 'ConfirmNoMatch_label');
             } elseif (!$passwordValidator->evaluate($this->stash->getFilePath())) {
                 $report->addValidationError($this, 'newPassword', $passwordValidator);
             }
         }
         $userProvider = new \NethServer\Tool\UserProvider($this->getPlatform());
         foreach (array_keys($userProvider->getUsers()) as $u) {
             $tmp = explode('@', $u);
             $users[] = $tmp[0];
         }
         if (in_array($this->parameters['username'], $users)) {
             # user already exists
             $report->addValidationErrorMessage($this, 'username', 'user_exists');
         }
     }
     parent::validate($report);
 }