diff --git a/gosa-core/plugins/personal/posix/class_posixAccount.inc b/gosa-core/plugins/personal/posix/class_posixAccount.inc
index af89c484aa01195d54eeb56ee4149e7b0268daa3..924153c380ddbd3f0ef8aaaf8eb959be936a84e5 100644 (file)
var $multiple_support = TRUE;
var $groupMembership_some = array();
+ // group SortableListing
+ var $groupList = null;
+ var $groupListData = null;
+
/* constructor, if 'dn' is set, the node loads the given
'dn' from LDAP */
function posixAccount (&$config, $dn= NULL, $parent =NULL)
/* Load bases attributes */
plugin::plugin($config, $dn, $parent);
+ $groupImage = image('plugins/groups/images/select_group.png');
+
$this->trustModeDialog = new trustModeDialog($this->config, $this->dn, $parent);
$this->trustModeDialog->setAcl('users/posixAccount');
/* Correct is_account. shadowAccount is not required. */
if (isset($this->attrs['objectClass']) &&
- in_array ('posixAccount', $this->attrs['objectClass'])){
+ in_array_strict('posixAccount', $this->attrs['objectClass'])){
$this->is_account= TRUE;
}
}
/* Get group membership */
+ $this->groupListData = array();
$ldap->cd($this->config->current['BASE']);
$ldap->search("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("cn", "description"));
while ($attrs= $ldap->fetch()){
if (!isset($attrs["description"][0])){
$entry= $attrs["cn"][0];
+ $this->groupListData[$ldap->getDN()] = array($groupImage, $attrs["cn"][0], "");
} else {
$entry= $attrs["cn"][0]." [".$attrs["description"][0]."]";
+ $this->groupListData[$ldap->getDN()] = array($groupImage, $attrs["cn"][0], $attrs["description"][0]);
}
$this->groupMembership[$ldap->getDN()]= $entry;
}
}
/* Insert possibly missing loginShell */
- if ($this->loginShell != "" && !in_array($this->loginShell, $this->loginShellList)){
+ if ($this->loginShell != "" && !in_array_strict($this->loginShell, $this->loginShellList)){
$this->loginShellList[]= $this->loginShell;
}
asort ($this->secondaryGroups);
$this->ui = get_userinfo();
+
+ // Create group-list
+ $this->groupList = new sortableListing(array(), array());
+ $this->groupList->setHeader(array(_("~"), _("Group"), _("Description")));
+ $this->groupList->setEditable(false);
+ $this->groupList->setDeleteable(true);
+ $this->groupList->setInstantDelete(false);
+ $this->groupList->setEditable(false);
+ $this->groupList->setReorderable(false);
+ $this->groupList->setDefaultSortColumn(1);
+ $this->groupList->setWidth("100%");
+ $this->groupList->setHeight("150px");
+ $this->groupList->setAcl("rwcdm");
}
$this->groupSelect= NULL;
}
+ // Remove groups that were removed by list
+ $this->groupList->save_object();
+ $actionL = $this->groupList->getAction();
+ if($actionL['action'] == "delete") {
+ $key = $this->groupList->getData($actionL['targets'][0]);
+ $this->delGroup(array($key));
+ }
+
// Remove groups from currently selected groups.
if (isset($_POST['delete_groupmembership']) &&
isset($_POST['group_list']) && count($_POST['group_list'])){
$this->delGroup (get_post('group_list'));
}
- /* Templates now! */
- $smarty= get_smarty();
+ // Build group-list data
+ $dDisp = array();
+ $dData = array();
+
+ foreach($this->groupListData as $key => $value) {
+ $dData[$key] = $key;
+ $dDisp[$key] = array('data' => $value);
+ }
+
+ $this->groupList->setListData($dData, $dDisp);
+ $this->groupList->update();
+ /* Templates now! */
+ $smarty = get_smarty();
+ $smarty->assign("groupList", $this->groupList->render());
// Handle trust mode dialog
$trustModeDialog = $this->trustModeDialog->execute();
$smarty->assign("force_idsACL", $this->getacl("uidNumber").$this->getacl("gidNumber"));
foreach(array("primaryGroup","activate_shadowWarning","activate_shadowInactive","activate_shadowMin","activate_shadowMax","activate_shadowExpire","mustchangepassword") as $val){
- if(in_array($val,$this->multi_boxes)){
+ if(in_array_strict($val,$this->multi_boxes)){
$smarty->assign("use_".$val,TRUE);
}else{
$smarty->assign("use_".$val,FALSE);
/* Load attributes and acl's */
foreach($this->attributes as $val){
- if(in_array($val,$this->multi_boxes)){
+ if(in_array_strict($val,$this->multi_boxes)){
$smarty->assign("use_".$val,TRUE);
}else{
$smarty->assign("use_".$val,FALSE);
if ($this->mustchangepassword){
$this->shadowLastChange= (int)(date("U") / 86400) - $this->shadowMax - 1;
} else {
- $this->shadowLastChange= (int)(date("U") / 86400);
+# $this->shadowLastChange= (int)(date("U") / 86400);
}
if (!$this->activate_shadowWarning){
$this->shadowWarning= "0";
function multiple_check()
{
$message = plugin::multiple_check();
- if ($this->homeDirectory == "" && in_array("homeDirectory",$this->multi_boxes)){
+ if ($this->homeDirectory == "" && in_array_strict("homeDirectory",$this->multi_boxes)){
$message[]= msgPool::required(_("Home directory"));
}
- if (!tests::is_path($this->homeDirectory) && in_array("homeDirectory",$this->multi_boxes)){
+ if (!tests::is_path($this->homeDirectory) && in_array_strict("homeDirectory",$this->multi_boxes)){
$message[]= msgPool::invalid(_("Home directory"), "", "", "/home/yourname" );
}
/* Check shadow settings, well I like spaghetties... */
- if ($this->activate_shadowMin && in_array("activate_shadowMin",$this->multi_boxes)){
+ if ($this->activate_shadowMin && in_array_strict("activate_shadowMin",$this->multi_boxes)){
if (!tests::is_id($this->shadowMin)){
$message[]= msgPool::invalid(_("shadowMin"), $this->shadowMin, "/[0-9]/");
}
}
- if ($this->activate_shadowMax && in_array("activate_shadowMax",$this->multi_boxes)){
+ if ($this->activate_shadowMax && in_array_strict("activate_shadowMax",$this->multi_boxes)){
if (!tests::is_id($this->shadowMax)){
$message[]= msgPool::invalid(_("shadowMax"), $this->shadowMax, "/[0-9]/");
}
}
- if ($this->activate_shadowWarning && in_array("activate_shadowWarning",$this->multi_boxes)){
+ if ($this->activate_shadowWarning && in_array_strict("activate_shadowWarning",$this->multi_boxes)){
if (!tests::is_id($this->shadowWarning)){
$message[]= msgPool::invalid(_("shadowWarning"), $this->shadowWarning, "/[0-9]/");
}
- if (!$this->activate_shadowMax && in_array("activate_shadowMax",$this->multi_boxes)){
+ if (!$this->activate_shadowMax && in_array_strict("activate_shadowMax",$this->multi_boxes)){
$message[]= msgPool::depends("shadowWarning", "shadowMax");
}
- if ($this->shadowWarning > $this->shadowMax && in_array("activate_shadowWarning",$this->multi_boxes)){
+ if ($this->shadowWarning > $this->shadowMax && in_array_strict("activate_shadowWarning",$this->multi_boxes)){
$message[]= msgPool::toobig("shadowWarning", "shadowMax");
}
- if ($this->activate_shadowMin && $this->shadowWarning < $this->shadowMin && in_array("activate_shadowMin",$this->multi_boxes)){
+ if ($this->activate_shadowMin && $this->shadowWarning < $this->shadowMin && in_array_strict("activate_shadowMin",$this->multi_boxes)){
$message[]= msgPool::tosmall("shadowWarning", "shadowMin");
}
}
- if ($this->activate_shadowInactive && in_array("activate_shadowInactive",$this->multi_boxes)){
+ if ($this->activate_shadowInactive && in_array_strict("activate_shadowInactive",$this->multi_boxes)){
if (!tests::is_id($this->shadowInactive)){
$message[]= msgPool::invalid(_("shadowInactive"), $this->shadowInactive, "/[0-9]/");
}
- if (!$this->activate_shadowMax && in_array("activate_shadowMax",$this->multi_boxes)){
+ if (!$this->activate_shadowMax && in_array_strict("activate_shadowMax",$this->multi_boxes)){
$message[]= msgPool::depends("shadowInactive", "shadowMax");
}
}
- if ($this->activate_shadowMin && $this->activate_shadowMax && in_array("activate_shadowMin",$this->multi_boxes)){
+ if ($this->activate_shadowMin && $this->activate_shadowMax && in_array_strict("activate_shadowMin",$this->multi_boxes)){
if ($this->shadowMin > $this->shadowMax){
$message[]= msgPool::toobig("shadowMin", "shadowMax");
}
{
/* include global link_info */
$ldap= $this->config->get_ldap_link();
+ $groupImage = image("plugins/groups/images/select_group.png");
/* Walk through groups and add the descriptive entry if not exists */
foreach ($groups as $value){
if (!array_key_exists($value, $this->groupMembership)){
$ldap->cat($value, array('cn', 'description', 'dn'));
$attrs= $ldap->fetch();
+ $dsc = " ";
error_reporting (0);
if (!isset($attrs['description'][0])){
$entry= $attrs["cn"][0];
if(obj_is_writable($attrs['dn'],"groups/group","memberUid")){
$this->groupMembership[$attrs['dn']]= $entry;
+
+ /* Add new group to groupList */
+ $this->groupListData[$attrs['dn']] = array();
+ $this->groupListData[$attrs['dn']][] = $groupImage;
+ $this->groupListData[$attrs['dn']][] = $attrs['cn'][0];
+ if(isset($attrs["description"])) {
+ $this->groupListData[$attrs['dn']][] = $attrs['description'][0];
+ } else {
+ $this->groupListData[$attrs['dn']][] = "";
+ }
+ if($this->multiple_support_active) {
+ $this->groupListData[$attrs['dn']][] = _("all");
+ }
+
if($this->multiple_support_active && isset($this->groupMembership_some[$attrs['dn']])){
unset($this->groupMembership_some[$attrs['dn']]);
}
foreach($groups as $dn_to_del){
if(isset($this->groupMembership[$dn_to_del]) && obj_is_writable($dn_to_del,"groups/group","memberUid")){
unset($this->groupMembership[$dn_to_del]);
+ unset($this->groupListData[$dn_to_del]);
}
if($this->multiple_support_active){
if(isset($this->groupMembership_some[$dn_to_del]) && obj_is_writable($dn_to_del,"groups/group","memberUid")){
unset($this->groupMembership_some[$dn_to_del]);
+ unset($this->groupListData[$dn_to_del]);
}
}
}
}
}
- /* FIXME: NEED review of this section */
- /* Need to check shadowExpire separately */
-
- /*
- * If shadowExpire is not enabled in the template, it's a UNIX timestamp - so don't convert it to seconds.
- * The check is a hack - if difference between timestamp generated above and here is max 1 day.
- */
- if(abs($this->shadowExpire - time())>86400) {
- $this->shadowExpire= $this->convertToSeconds($this->shadowExpire);
- }
-
/* Only enable checkbox, if shadowExpire is in the future */
if($this->shadowExpire > time()) {
$this->activate_shadowExpire= "1";
}
+
+ /* Convert shadowExpire for usage */
+ if ($this->shadowExpire == 0){
+ $this->shadowExpire= "";
+ } else {
+ $this->shadowExpire= date('d.m.Y', $this->shadowExpire * 60 * 60 * 24);
+ }
}
function convertToSeconds($val)
}
}
-
+ /* Convert shadowExpire for usage */
+ if ($this->shadowExpire == 0){
+ $this->shadowExpire= "";
+ } else {
+ $this->shadowExpire= date('d.m.Y', $this->shadowExpire * 60 * 60 * 24);
+ }
$tmp = new trustModeDialog($this->config, $source['dn']);
$this->trustModeDialog = new trustModeDialog($this->config, $this->dn);
$ret['groupMembership'] = $this->groupMembership;
$ret['groupMembership_some']= $this->groupMembership_some;
- if(in_array("primaryGroup",$this->multi_boxes)){
+ if(in_array_strict("primaryGroup",$this->multi_boxes)){
$ret['primaryGroup'] = $this->primaryGroup;
}
foreach(array("shadowWarning","shadowInactive","shadowMin","shadowMax", "shadowExpire") as $entry){
$active = "activate_".$entry;
- if(in_array($active,$this->multi_boxes)){
+ if(in_array_strict($active,$this->multi_boxes)){
$ret[$entry] = $this->$entry;
$ret[$active] = $this->$active;
}
}
- if(in_array("mustchangepassword",$this->multi_boxes)){
+ if(in_array_strict("mustchangepassword",$this->multi_boxes)){
$ret['mustchangepassword'] = $this->mustchangepassword;
}
return($ret);
foreach(array("shadowMin","shadowMax","shadowExpire","shadowInactive","shadowWarning") as $var) {
if($this->acl_is_writeable($var)){
$activate_var = "activate_".$var;
- if(in_array($activate_var, $this->multi_boxes)){
+ if(in_array_strict($activate_var, $this->multi_boxes)){
if(isset($_POST['activate_'.$var])){
$this->$activate_var = true;
$this->$var = get_post($var);
}
/* Restore shadow value, if the shadow attribute isn't used */
- if(!in_array("activate_shadowExpire",$this->multi_boxes)){
+ if(!in_array_strict("activate_shadowExpire",$this->multi_boxes)){
$this->shadowExpire = $expire_tmp;
}
plugin::init_multiple_support($attrs,$all);
$this->trustModeDialog->init_multiple_support($attrs,$all);
+ // set header for multiple support
+ $this->groupList->setHeader(array(_("~"), _("Group"), _("Description"), _("Members")));
+
/* Some dummy values */
$groups_some = array();
$groups_all = array();
$uids = array();
$first = TRUE;
+ $groupImage = image('plugins/groups/images/select_group.png');
+
/* Get all groups used by currently edited users */
$uid_filter="";
for($i =0; $i < $this->multi_attrs_all['uid']['count'] ; $i ++){
$uid_filter = "(&(objectClass=posixGroup)(|".$uid_filter."))";
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
- $ldap->search($uid_filter,array("dn","cn","memberUid"));
+ $ldap->search($uid_filter,array("dn","cn","memberUid","description"));
while($group = $ldap->fetch()){
$groups_some[$group['dn']] = $group['cn'][0];
+
+ $desc = " ";
+ if(isset($group['description'])) $desc = $group['description'][0];
+
+ $this->groupListData[$group['dn']] = array($groupImage,
+ $group['cn'][0],
+ $desc,
+ _("some"));
+
for($i = 0 ; $i < $group['memberUid']['count'] ; $i++){
$groups_uid[$group['dn']][] = $group['memberUid'][$i];
}
$groups_all = $groups_some;
foreach($groups_all as $id => $group){
foreach($uids as $uid){
- if(!in_array($uid,$groups_uid[$id])){
+ if(!in_array_strict($uid,$groups_uid[$id])){
unset($groups_all[$id]);
break;
}
$this->groupMembership = $groups_all;
/* Create an array of all grouops used by all users */
- foreach( $groups_all as $dn => $cn){
- if(isset($groups_some[$dn])){
+ foreach($groups_all as $dn => $cn) {
+ if(isset($groups_some[$dn])) {
unset($groups_some[$dn]);
+ $this->groupListData[$dn][3] = _("all");
}
}
+
$this->groupMembership_some = $groups_some;
$this->primaryGroup = $this->gidNumber;