From a8a209196615cf253e13561a8d88256201c11df6 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 26 Aug 2005 08:20:55 +0000 Subject: [PATCH] Some Fixes for environment, added icon for userlist git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1222 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/groups/acl_definition.inc | 14 ++ plugins/admin/users/class_userManagement.inc | 10 +- .../environment/class_environment.inc | 159 ++++++++++++++++-- .../class_kioskManagementDialog.inc | 16 +- .../class_logonManagementDialog.inc | 28 ++- plugins/personal/environment/environment.tpl | 12 +- .../personal/environment/logonManagement.tpl | 2 +- plugins/personal/environment/main.inc | 6 +- 8 files changed, 212 insertions(+), 35 deletions(-) diff --git a/plugins/admin/groups/acl_definition.inc b/plugins/admin/groups/acl_definition.inc index 580029e60..e4e27bea8 100644 --- a/plugins/admin/groups/acl_definition.inc +++ b/plugins/admin/groups/acl_definition.inc @@ -194,5 +194,19 @@ $ACLD['goFonConference']= array( "goFonConferenceOption_c", "goFonConferenceOwner"); +$ACLD['gotoEnvironment']=array( + "gotoPrinter", + "gotoEnvironment", + "gotoShare", + "gotoProfileServer", + "gotoProfileFlags", + "gotoXResolution", + "gotoLogonScript", + "gotoKioskProfile", + "gotoProfileQuota", + "gotoHotplugDevice" + ); + + $ACLD['global-addressbook']= array("create", "delete"); ?> diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index cc23c1d61..0f812e6a4 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -705,6 +705,8 @@ class userManagement extends plugin name='user_edit_%KEY%-user' title='"._("Edit generic properties")."'>"; $posiximg = ""; + $eviroimg = ""; $mailimg = ""; $fonimg = " sprintf($tpl,$val['dn']),"attach"=>"style='width:20px;align:middle;'"); $field2 = array("string" => sprintf($editlink,$key,$display).$ip_port,"attach"=>"title='".$val['dn']."'"); - $field3 = array("string" => $usrimg." ".$posix." ".$maila." ".$fonac." ".$faxac." ".$samba." ".$s_img_create_from_template, "attach" => "style='width:138px;'"); + $field3 = array("string" => $usrimg." ".$posix." ".$enviro." ".$maila." ".$fonac." ".$faxac." ".$samba." ".$s_img_create_from_template, "attach" => "style='width:138px;'"); $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action),"attach" => "style='border:none; text-align:right;width:48px'"); $add = array($field1,$field2,$field3,$field4); diff --git a/plugins/personal/environment/class_environment.inc b/plugins/personal/environment/class_environment.inc index d0b694cff..44f2ae039 100644 --- a/plugins/personal/environment/class_environment.inc +++ b/plugins/personal/environment/class_environment.inc @@ -12,7 +12,9 @@ class environment extends plugin var $plHeadline = "Environment"; var $plDescription = "This does something"; var $dialog = false; // Indicates that we are currently editing in an seperate dialog - + + var $in_dialog = false; + var $uid = ""; /* Attribute definition */ @@ -93,6 +95,29 @@ class environment extends plugin } } + /* prepare LogonScripts */ + if((isset($this->attrs['gotoLogonScript']))&&(is_array($this->attrs['gotoLogonScript']))){ + unset($this->attrs['gotoLogonScript']['count']); + foreach($this->attrs['gotoLogonScript'] as $device){ + $tmp = $tmp2 = array(); + $tmp = split("\|",$device); + $tmp2['LogonName'] = $tmp[0]; + $tmp2['LogonPriority'] = $tmp[2]; + if(preg_match("/O/i",$tmp[1])){ + $tmp2['LogonOverload'] = "O"; + }else{ + $tmp2['LogonOverload'] = ""; + } + if(preg_match("/L/i",$tmp[1])){ + $tmp2['LogonLast'] = "L"; + }else{ + $tmp2['LogonLast'] = ""; + } + $tmp2['LogonData'] = base64_decode($tmp[3]); + $this->gotoLogonScripts[$tmp[0]]=$tmp2; + } + } + /* Prepare Shares */ if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){ unset($this->attrs['gotoShare']['count']); @@ -130,7 +155,7 @@ class environment extends plugin // 1. Account disabled . Editing from usermenu if((!isset($this->parent))&&(!$this->is_account)){ - /* We are currently editing this tab from usermenu, but htis account is not enabled */ + /* We are currently editing this tab from usermenu, but this account is not enabled */ $smarty->assign("is_account",$this->is_account); /* Load template */ $display .= $smarty->fetch(get_template_path('environment.tpl', TRUE)); @@ -157,10 +182,17 @@ class environment extends plugin $display= $this->show_header(_("Remove environment extension"), _("This server has environment extension enabled. You can disable it by clicking below.")); } else { - // 4. Account disabled . Editing from adminmenu - $display= $this->show_header(_("Add environment extension"), - _("This server has environment extension disabled. You can enable it by clicking below.")); - return $display; + if((in_array("posixAccount",$this->attrs['objectClass']))||($this->parent->by_object['posixAccount']->is_account==true)){ + // 4. There is a PosixAccount + $display= $this->show_header(_("Add environment extension"), + _("This server has environment extension disabled. You can enable it by clicking below.")); + return $display; + }else{ + // 4. There is a PosixAccount + $display= $this->show_header(_("Add environment extension"), + _("This server has environment extension disabled. You have to setup a posix account before you can enable this feature."),TRUE,TRUE); + return $display; + } } } } @@ -276,8 +308,7 @@ class environment extends plugin * We only can delete if there is an entry selected. */ if((isset($_POST['gotoLogonScriptDel']))&&(isset($_POST['gotoLogonScript']))){ - $is_entry = $this->gotoLogonScripts[$_POST['gotoLogonScript']]; - print "Deleting ".$is_entry; + unset($this->gotoLogonScripts[$_POST['gotoLogonScript']]); } /* In this case we want to edit an existing entry, we open a new Dialog to allow editing. @@ -495,7 +526,7 @@ class environment extends plugin if(isset($_POST['iamposted'])){ plugin::save_object(); foreach($this->attributes as $s_attr){ - if(in_array($s_attr,array("gotoShares","gotoHotplugDevices","gotoPrinters","gotoLogonScripts"))) continue; + if(in_array($s_attr,array("gotoShares","gotoHotplugDevices","gotoPrinters","gotoLogonScripts","uid"))) continue; if(isset($_POST[$s_attr])){ $this->$s_attr = $_POST[$s_attr]; }else{ @@ -521,7 +552,10 @@ class environment extends plugin $ldap= $this->config->get_ldap_link(); $realyUsedAttrs= array(); + + + /* Save already used objectClasses */ $ocs = $this->attrs['objectClass']; unset($ocs['count']); @@ -535,6 +569,58 @@ class environment extends plugin /* Save usersettings to Printer */ + + if(chkacl($this->acl,"gotoPrinter")!=""){ + $this->gotoPrinters = array(); + } + + if(count($this->gotoPrinters)==0){ + $ldap->search("(&(objectClass=gotoPrinter)(|(gotoUserPrinter=".$this->uid.")(gotoAdminPrinter=".$this->uid.")))",array("*")); + while($attr = $ldap->fetch()){ + + foreach($attr['gotoUserPrinter'] as $key => $user){ + if($this->uid==$user){ + unset($attr['gotoUserPrinter'][$key]); + } + } + + foreach($attr['gotoAdminPrinter'] as $key => $user){ + if($this->uid==$user){ + unset($attr['gotoAdminPrinter'][$key]); + } + } + + $attrs_used = array(); + foreach($attr as $key=>$val){ + if((!is_numeric($key))&&($key!="count")){ + if(is_array($val)&&isset($val['count'])){ + unset($val['count']); + } + $attrs_used[$key]=$val; + } + } + $attr= $attrs_used; + $tmp =array(); + foreach($attr['gotoAdminPrinter'] as $print){ + $tmp[]=$print; + } + $attr['gotoAdminPrinter'] = $tmp; + + $tmp =array(); + foreach($attr['gotoUserPrinter'] as $print){ + $tmp[]=$print; + } + $attr['gotoUserPrinter'] = $tmp; + + $ldap->cd($attr['dn']); + unset($attr['dn']); + $ldap->modify($attr); + if($ldap->get_error()!="Success"){ + print_red("Printer saving ".$ldap->get_error()); + } + } + } + foreach($this->gotoPrinters as $printer) { $ldap->cd($printer['dn']); $ldap->cat($printer['dn']); @@ -559,7 +645,7 @@ class environment extends plugin $attribute = "gotoAdminPrinter"; $attribute2 = "gotoUserPrinter"; } - + /* If this user is already assigned to $attribute2 * delete user from $attribute2, to be albe to attach him to $attribute * A user can't be admin and normal user for one printer @@ -570,14 +656,14 @@ class environment extends plugin if(in_array($this->uid,$printer[$attribute2])){ $tmp = array_flip($attrs[$attribute2]); unset($tmp[$this->uid]); - $attrs[$attribute2]=$tmp; + $attrs[$attribute2]=array_flip($tmp); } /* If Last entry removed, clear attribute*/ if(empty($attrs[$attribute2])){ $attrs[$attribute2]=array(); } } - + /* Attach user to the $attribute, if he is'nt already attached */ if(!isset($attrs[$attribute])){ @@ -588,20 +674,52 @@ class environment extends plugin $attrs[$attribute][]=$this->uid; } } + + $tmp =array(); + if(isset($attrs['gotoAdminPrinter'])){ + foreach($attrs['gotoAdminPrinter'] as $print){ + $tmp[]=$print; + } + } + $attrs['gotoAdminPrinter'] = $tmp; + + $tmp =array(); + if(isset($attrs['gotoUserPrinter'])){ + foreach($attrs['gotoUserPrinter'] as $print){ + $tmp[]=$print; + } + } + $attrs['gotoUserPrinter'] = $tmp; + $ldap->cd($attrs['dn']); unset($attrs['dn']); $ldap->modify($attrs); if($ldap->get_error()!="Success"){ - print_red($ldap->get_error()); + print_red("Printer saving ".$ldap->get_error()); } } - + + plugin::save(); + + if(isset($this->attrs['gotoPrinter'])){ + unset($this->attrs['gotoPrinter']); + } + /* Prepare HotPlug devices */ $this->attrs['gotoHotplugDevice'] = array(); foreach($this->gotoHotplugDevices as $name => $device){ $this->attrs['gotoHotplugDevice'][] = $device['name']."|".$device['description']."|".$device['id']; } + /* Prepare LogonScripts */ + $this->attrs['gotoLogonScript'] = array(); + foreach($this->gotoLogonScripts as $name => $script){ + $this->attrs['gotoLogonScript'][] = $script['LogonName']."|". + $script['LogonOverload'].$script['LogonLast']."|". + $script['LogonPriority']."|". + base64_encode($script['LogonData']); + } + /* Prepare Shares */ $this->attrs['gotoShare']=array(); foreach($this->gotoShares as $name => $share){ @@ -635,6 +753,15 @@ class environment extends plugin $this->attrs['gotoProfileServer']= array(); } + foreach($this->attributes as $s_attr){ + if(chkacl($this->acl,$s_attr)!="") { + if(isset($this->attrs[$s_attr])){ + unset($this->attrs[$s_attr]); + } + } + } + + $ldap->cat ($this->dn); if ($ldap->fetch()){ $mode= "modify"; @@ -652,9 +779,6 @@ class environment extends plugin $this->handle_post_events($mode); } - - - /* This function returns all available Shares defined in this ldap * There are two ways to call this function, if listboxEntry is true * only name and path are attached to the array, in it is false, the whole @@ -732,7 +856,6 @@ function printOutHotPlugDevices() */ function printOutLogonScripts() { - print_a($this->gotoLogonScripts); $a_return = array(); if(is_array($this->gotoLogonScripts)){ foreach($this->gotoLogonScripts as $script){ diff --git a/plugins/personal/environment/class_kioskManagementDialog.inc b/plugins/personal/environment/class_kioskManagementDialog.inc index ef0067831..4b2611781 100644 --- a/plugins/personal/environment/class_kioskManagementDialog.inc +++ b/plugins/personal/environment/class_kioskManagementDialog.inc @@ -36,10 +36,15 @@ class kioskManagementDialog extends plugin $file = $_FILES['newProfile']; if(!file_exists($this->baseDir.$file['name'])){ $name = preg_replace("/\..*$/","",$file['name']).$this->filePrefix; - $str = file_get_contents($file['tmp_name']); - $fp = fopen($this->baseDir.$name,"w+"); - fwrite($fp,$str,strlen($str)); - fclose($fp); + $str = file_get_contents($file['tmp_name']); + $fp = @fopen($this->baseDir.$name,"w+"); + if($fp){ + fwrite($fp,$str,strlen($str)); + fclose($fp); + }else{ + print_red(_("Can't save kioskProfile. Permission denied.")." ".$this->baseDir); + } + unlink($file['tmp_name']);; } } @@ -72,6 +77,9 @@ class kioskManagementDialog extends plugin function getKioskProfiles() { $dir = opendir($this->baseDir); + if(!file_exists($this->baseDir)){ + mkdir($this->baseDir); + } $a_return = array(); while($file = readdir($dir)){ if(preg_match("/".$this->filePrefix."$/i",$file)){ diff --git a/plugins/personal/environment/class_logonManagementDialog.inc b/plugins/personal/environment/class_logonManagementDialog.inc index 55b16c7df..0587f834b 100644 --- a/plugins/personal/environment/class_logonManagementDialog.inc +++ b/plugins/personal/environment/class_logonManagementDialog.inc @@ -17,11 +17,23 @@ class logonManagementDialog extends plugin var $LogonLast =""; // Is this script marked as the last, all following scripts will be skipped var $LogonOverload =""; // If Overload is activated this script is overlaodable by a group script with same prio var $LogonData =""; // The script itself + var $nameIsEditable = true; - function logonManagementDialog ($config, $dn= NULL,$use_existing=false ) + var $real_LogonName = ""; + + function logonManagementDialog ($config, $dn= NULL,$data=false) { - $this->use_existing = $use_existing; plugin::plugin ($config, $dn); + + if($data){ + $this->LogonName = $data['LogonName']; + $this->LogonPriority = $data['LogonPriority']; + $this->LogonOverload = $data['LogonOverload']; + $this->LogonLast = $data['LogonLast']; + $this->LogonData = $data['LogonData']; + $this->nameIsEditable = false; + $this->real_LogonName = $data['LogonName']; + } } function execute() @@ -40,6 +52,13 @@ class logonManagementDialog extends plugin $prios=array(1,2,3,4,5,6,7,8,9,10); $smarty->assign("LogonPrioritys",$prios); $smarty->assign("LogonPriorityKeys",$prios); + + if(!$this->nameIsEditable){ + $smarty->assign("LogonNameACL"," disabled "); + }else{ + $smarty->assign("LogonNameACL",""); + } + $display.= $smarty->fetch(get_template_path('logonManagement.tpl', TRUE,dirname(__FILE__))); return($display); } @@ -63,6 +82,11 @@ class logonManagementDialog extends plugin foreach($this->attributes as $attr){ $a_return[$attr]=$this->$attr; } + + if(!$this->nameIsEditable){ + $a_return['LogonName']=$this->real_LogonName; + } + return($a_return); } diff --git a/plugins/personal/environment/environment.tpl b/plugins/personal/environment/environment.tpl index ee4acbce0..e182f88d1 100644 --- a/plugins/personal/environment/environment.tpl +++ b/plugins/personal/environment/environment.tpl @@ -10,7 +10,7 @@ @@ -91,7 +91,7 @@  
- + {t}Use profile managment{/t} @@ -49,7 +49,7 @@ {t}Quota{/t} - +
- +
@@ -106,9 +106,9 @@
- - - + + + diff --git a/plugins/personal/environment/logonManagement.tpl b/plugins/personal/environment/logonManagement.tpl index d5abcbd68..acae9af5d 100644 --- a/plugins/personal/environment/logonManagement.tpl +++ b/plugins/personal/environment/logonManagement.tpl @@ -10,7 +10,7 @@ {t}Name{/t} - + diff --git a/plugins/personal/environment/main.inc b/plugins/personal/environment/main.inc index 91883ab78..22f06d12b 100644 --- a/plugins/personal/environment/main.inc +++ b/plugins/personal/environment/main.inc @@ -57,10 +57,10 @@ if (!$remove_lock){ /* Adjust acl's to mode */ if (isset($_SESSION['edit'])){ $acl= get_permissions ($ui->dn, $ui->subtreeACL); - $environment->acl= get_module_permission($acl, "environment", $ui->dn); + $environment->acl= get_module_permission($acl, "gotoEnvironment", $ui->dn); } else { $acl= get_permissions ($ui->dn, $ui->subtreeACL); - $editacl= get_module_permission($acl, "environment",$ui->dn); + $editacl= get_module_permission($acl, "gotoEnvironment",$ui->dn); $environment->acl= "#none#"; } @@ -100,7 +100,7 @@ if (!$remove_lock){ $display.= "

"; /* Are we in edit mode? */ - if (isset($_SESSION['edit'])){ + if ((isset($_SESSION['edit']))&&($environment->dialog==NULL)){ $display.= "\n"; $display.= " "; $display.= "\n"; -- 2.30.2