Example #1
0
 public function validate(\Nethgui\Controller\ValidationReportInterface $report)
 {
     if (!$this->getRequest()->isMutation()) {
         return;
     }
     if ($this->getIdentifier() === 'delete') {
         $v = $this->createValidator()->platform('group-delete');
         if (!$v->evaluate($this->getAdapter()->getKeyValue())) {
             $report->addValidationError($this, 'groupname', $v);
         }
     }
     if ($this->getIdentifier() === 'update' || $this->getIdentifier() === 'create') {
         $users = array_keys($this->getUserProvider()->getUsers());
         $this->getValidator('members')->memberOf($users);
     }
     if ($this->getIdentifier() === 'create') {
         $groups = array();
         $groupProvider = new \NethServer\Tool\GroupProvider($this->getPlatform());
         foreach (array_keys($groupProvider->getGroups()) as $u) {
             $tmp = explode('@', $u);
             $groups[] = $tmp[0];
         }
         if (in_array($this->parameters['groupname'], $groups)) {
             # group already exists
             $report->addValidationErrorMessage($this, 'groupname', 'group_exists');
         }
     }
     parent::validate($report);
 }
 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);
 }
 private function getOwnersDatasource(\Nethgui\View\ViewInterface $view)
 {
     $gp = new \NethServer\Tool\GroupProvider($this->getPlatform());
     return array_map(function ($x) {
         return array($x, $x);
     }, array_keys($gp->getGroups()));
 }