From ab44ea6afcdf33e5678c5f84d689ec7c12dbe541 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 12 Apr 2005 19:38:32 +0000 Subject: [PATCH] better error handling if no Unix groups exist --- lam/lib/modules/posixAccount.inc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 0d569d80..be26125e 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -358,9 +358,11 @@ class posixAccount extends baseModule { // call parent init parent::init($base); $groups = $_SESSION['cache']->findgroups(); // list of all groupnames - // TODO better error handling - if (count($groups)==0) trigger_error(_('No groups found in ldap.'), E_USER_WARNING); $this->createhomedir=false; + if (count($groups)==0) { + StatusMessage("ERROR", _('No Unix groups found in LDAP! Please create one first.'), ''); + return; + } } // Variables @@ -587,6 +589,10 @@ class posixAccount extends baseModule { /* Write variables into object and do some regexp checks */ function process_attributes(&$post) { + $groups = $_SESSION['cache']->findgroups(); // list of all groupnames + if (count($groups)==0) { + return array("ERROR", _('No Unix groups found in LDAP! Please create one first.'), ''); + } $this->attributes['homeDirectory'][0] = $post['homeDirectory']; $this->attributes['loginShell'][0] = $post['loginShell']; if (isset($post['gecos'])) $this->attributes['gecos'][0] = $post['gecos']; @@ -798,6 +804,10 @@ class posixAccount extends baseModule { */ function display_html_attributes(&$post) { $groups = $_SESSION['cache']->findgroups(); // list of all groupnames + if (count($groups)==0) { + StatusMessage("ERROR", _('No Unix groups found in LDAP! Please create one first.'), ''); + return; + } $shelllist = getshells(); // list of all valid shells $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _("Username").'*' ),