summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9ef4351)
raw | patch | inline | side by side (parent: 9ef4351)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 19 Jul 2006 11:15:10 +0000 (11:15 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 19 Jul 2006 11:15:10 +0000 (11:15 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4235 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/Changelog b/Changelog
index ad157e45842fe0a9991c2290b559094228066fb2..0cddad6ee4938aa22aa728b54a01e8a708977288 100644 (file)
--- a/Changelog
+++ b/Changelog
===============
* gosa 2.5.3
+ - Fixed gotoPrinter membership problem.
- Fixed environment shares, only available shares will be displayed (gosaUnitTag was ignored)
- Fixed saving of inherited workstation settings
- Removed error when no FAI repositories were present
diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc
index 8d4d00a8769602bfa516200ec27ac9042ff34019..d19ecd245b046267780bd0531a81585268e0a9de 100644 (file)
var $AdminMembers =array();
var $AdminMemberKeys =array();
- var $gotoUserPrinter ;
var $PPDdialogToSave = NULL;
var $BelongsTo = "unknown"; // Specifies if this is a standalone printer, or belongs to a terminal / WS
var $macAddress = "";
/* attribute list for save action */
- var $attributes = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD","gotoUserPrinter", "macAddress");
+ var $attributes = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD","gotoUserPrinter", "macAddress",
+ "gotoUserAdminPrinter","gotoGroupAdminPrinter","gotoUserPrinter","gotoGroupPrinter");
var $objectclasses = array("top", "gotoPrinter");
+ var $gotoUserAdminPrinter;
+ var $gotoGroupAdminPrinter ;
+ var $gotoGroupPrinter;
+ var $gotoUserPrinter ;
+
function printgeneric ($config, $dn= NULL,$parent = NULL)
{
$this->config = $config;
/* Member management, delete user / group / admin ..*/
if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
- if(isset($this->member['AddUser'][$_POST['UserMember']])){
- unset($this->member['AddUser'][$_POST['UserMember']]);
+ foreach($_POST['UserMember'] as $mem){
+ $this->DelMember('AddUser',$mem);
}
}
if((isset($_POST['DelUser']))&&(isset($_POST['UserMember']))){
- if(isset($this->member['AddGroup'][$_POST['UserMember']])){
- unset($this->member['AddGroup'][$_POST['UserMember']]);
+ foreach($_POST['UserMember'] as $mem){
+ $this->DelMember('AddGroup',$mem);
}
}
if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
- if(isset($this->member['AddAdminUser'][$_POST['AdminMember']])){
- unset($this->member['AddAdminUser'][$_POST['AdminMember']]);
+ foreach($_POST['AdminMember'] as $mem){
+ $this->DelMember('AddAdminUser',$mem);
}
}
if((isset($_POST['DelAdmin']))&&(isset($_POST['AdminMember']))){
- if(isset($this->member['AddAdminGroup'][$_POST['AdminMember']])){
- unset($this->member['AddAdminGroup'][$_POST['AdminMember']]);
+ foreach($_POST['AdminMember'] as $mem){
+ $this->DelMember('AddAdminGroup',$mem);
}
}
print_red($msg);
}
}else{
- $new = $this->dialog->save();
- $data = $new;
+ $data= $new = $this->dialog->save();
unset($data['type']);
-
- if(preg_match("/User/",$new['type'])){
- $use = "uid";
- }else{
- $use = "cn";
- }
-
- foreach($data as $mem){
- $this->member[$new['type']][$mem[$use][0]]=$mem;
+ foreach($data as $mem){
+ $this->AddMember($new['type'], $mem['dn']);
}
unset($this->dialog);
$this->dialog=NULL;
/* Append printer user
*/
- if((isset($this->attrs['gotoUserPrinter'])) && (is_string($this->attrs['gotoUserPrinter']))){
- $this->attrs['gotoUserPrinter']=array();
- }
+ $this->attrs['gotoUserPrinter']=array();
foreach($this->member['AddUser'] as $mem){
$this->attrs['gotoUserPrinter'][]=$mem['uid'][0];
}
/* Append printer group
*/
+ $this->attrs['gotoGroupPrinter'][] = array();
foreach($this->member['AddGroup'] as $mem){
$this->attrs['gotoGroupPrinter'][]=$mem['cn'][0];
}
/* Append printer admin user
*/
+ $this->attrs['gotoUserAdminPrinter'] =array();
foreach($this->member['AddAdminUser'] as $mem){
$this->attrs['gotoUserAdminPrinter'][]=$mem['uid'][0];
}
/* Append printer admin group
*/
+ $this->attrs['gotoGroupAdminPrinter'] = array();
foreach($this->member['AddAdminGroup'] as $mem){
$this->attrs['gotoGroupAdminPrinter'][]=$mem['cn'][0];
}
}
return($a_return);
}
-}
+ /* Delete member */
+ function DelMember($type,$id)
+ {
+ if(isset($this->member[$type][$id])){
+ unset($this->member[$type][$id]);
+ }
+ }
+
+ /* Add given obejct to members */
+ function AddMember($type,$dn)
+ {
+ $types = array("AddUser","AddGroup","AddAdminUser","AddAdminGroup");
+ if(!in_array_ics($type, $types)){
+ print_red(sprintf(_("Illegal printer type while adding '%s' to the list of '%s' printers,"),$dn,$type));
+ return;
+ }
+
+ /* Get name of index attributes */
+ if(preg_match("/user/i",$type)){
+ $var = "uid";
+ }else{
+ $var = "cn";
+ }
+
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($dn);
+ $ldap->cat($dn,array("cn","uid"));
+ if($ldap->count()){
+
+ $attrs = $ldap->fetch();
+ $name = $attrs[$var][0];
+ /* Check if this uid/cn is already assigned to any permission */
+ foreach($types as $ctype){
+ if(isset( $this->member[$ctype][$name])){
+ print_red(sprintf(_("Can't add '%s' to the list of members, it is already used."),$attrs[$var][0]));
+ return;
+ }
+ }
+
+ /* Everything is fine. So add the given object to members */
+ $this->member[$type][$attrs[$var][0]] = $attrs ;
+ }else{
+ print_red(sprintf(_("Can't add '%s' to list of members, it is not reachable."),$dn));
+ }
+ }
+}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
index 808d47f746ec152bcba1a89ff87a20c226810a48..876ae22baf1153f4c942217f9f641d47c43cc73a 100644 (file)
<tr>
<td>
{t}Users which are allowed to use this printer{/t}<br>
- <select size="1" name="UserMember" title="{t}Users{/t}" style="width:100%;height:120px;" multiple>
+ <select size="1" name="UserMember[]" title="{t}Users{/t}" style="width:100%;height:120px;" multiple>
{html_options options=$UserMembers values=$UserMemberKeys}
</select><br>
<input type="submit" value="{t}Add user{/t}" name="AddUser">
<tr>
<td>
{t}Users which are allowed to administrate this printer{/t}<br>
- <select size="1" name="AdminMember" title="{t}Admins{/t}" style="width:100%;height:120px;" multiple>
+ <select size="1" name="AdminMember[]" title="{t}Admins{/t}" style="width:100%;height:120px;" multiple>
{html_options options=$AdminMembers values=$AdminMemberKeys}
</select><br>
<input type="submit" value="{t}Add user{/t}" name="AddAdminUser">
diff --git a/plugins/personal/environment/class_environment.inc b/plugins/personal/environment/class_environment.inc
index b1c76c3a7d5d12c21f62c4fc71d66754155bb7d9..c411cd138996ee9100714996f0b5b09311d723f3 100644 (file)
/* Save usersettings to Printer */
-
if(chkacl($this->acl,"gotoPrinter")!=""){
$this->gotoPrinter = array();
}
+ /* 1. Search all printers that have our uid/cn as member
+ * 2. Delete this uid/cn from every single entry and save it again.
+ * 2.1 There are different types of members: Users / Groups, this will be defined in $suffix
+ * 2.2 And each type has two modes, Admin (e.g. 'gotoUserAdminPrinter') and Normal
+ */
+ $types = array( "gotoUserPrinter" => "AddUser",
+ "gotoGroupPrinter" => "AddGroup",
+ "gotoUserAdminPrinter" => "AddAdminUser",
+ "gotoGroupAdminPrinter" => "AddAdminGroup");
+
if($this->is_group){
$s_suffix = "Group";
+ $useVar = "cn";
}else{
+ $useVar = "uid";
$s_suffix = "User";
}
-
- /* 1. Search all printers that have our uid/cn as member
- * 2. Delete this uid/cn from every single entry and save it again.
- * 2.1 There are different types of members: Users / Groups, this will be defined in $suffix
- * 2.2 And each type has two modes, Admin (e.g. 'gotoUserAdminPrinter') and Normal
- */
- $ldap->search("(&(objectClass=gotoPrinter)(|(goto".$s_suffix."Printer=".$this->uid.")(goto".$s_suffix."AdminPrinter=".$this->uid.")))",array("*"));
+ /* Remove old entries */
+ $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."Printer=".$this->uid."))",array("*"));
while($attr = $ldap->fetch()){
+ $printerObj = NULL;
+ $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn']);
+ $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."Printer"],$this->uid);
+ $printerObj->by_object['printgeneric']->save();
+ }
- /* Walk trough all printers and check if our user id used, if so remove it.
- * Later we will insert our uid at the right place.
- */
-
- /* Remove normal entries (User)*/
- if(isset($attr['goto'.$s_suffix.'Printer'])) {
-
- /* Avoid saving count=>0 as member */
- unset($attr['goto'.$s_suffix.'Printer']['count']);
-
- foreach($attr['goto'.$s_suffix.'Printer'] as $key => $user){
- if($this->uid==$user){
- unset($attr['goto'.$s_suffix.'Printer'][$key]);
- }
- }
- $tmp = array();
- foreach($attr['goto'.$s_suffix.'Printer'] as $user){
- $tmp[] = $user;
- }
- $attr['goto'.$s_suffix.'Printer'] = array();
- $attr['goto'.$s_suffix.'Printer'] = $tmp;
- }
-
- /* Remove administrational entries (Admin)*/
- if(isset($attr['goto'.$s_suffix.'AdminPrinter'])){
-
- /* Avoid saving count=>0 as member */
- unset($attr['goto'.$s_suffix.'AdminPrinter']['count']);
-
- foreach($attr['goto'.$s_suffix.'AdminPrinter'] as $key => $user){
- if($this->uid==$user){
- unset($attr['goto'.$s_suffix.'AdminPrinter'][$key]);
- }
- }
- $tmp = array();
- foreach($attr['goto'.$s_suffix.'AdminPrinter'] as $user){
- $tmp[] = $user;
- }
- $attr['goto'.$s_suffix.'AdminPrinter'] = array();
- $attr['goto'.$s_suffix.'AdminPrinter'] = $tmp;
- }
-
- /* Extract useable tags, to be able to save all changes
- */
- $attrs_used = array();
- foreach($attr as $key=>$val){
-
- /* If index is numeric, skip it ...*/
- if((!is_numeric($key))&&($key!="count")){
-
- /* If entry contains 'count' remove it */
- if(is_array($val)&&isset($val['count'])){
- unset($val['count']);
- }
- $attrs_used[$key]=$val;
- }
- }
- /* the result of cleaning the entry is
- * to be able to directly save this again,
- * if all changes are made
- */
- $attr= $attrs_used;
-
-#fix : Id don't know why such an entry was set ...
- if(isset($attr['GOTOADMINPRINTER'])){
- unset($attr['GOTOADMINPRINTER']);
- }
-
- /* Save changes */
- $ldap->cd($attr['dn']);
- unset($attr['dn']);
-$ldap->modify ($attr);
-
- if($ldap->get_error()!="Success"){
- print_red(_("Error while writing printer")." : ".$ldap->get_error());
- }
+ $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."AdminPrinter=".$this->uid."))",array("*"));
+ while($attr = $ldap->fetch()){
+ $printerObj = NULL;
+ $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn']);
+ $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."AdminPrinter"],$this->uid);
+ $printerObj->by_object['printgeneric']->save();
}
- /* All printers are cleaned, (our cn/uid removed)
- * now we must add our uid / cn
- * to the new configured printers.
- */
- foreach($this->gotoPrinter as $printer) {
- $ldap->cat($printer['dn']);
- $attrs= $ldap->fetch();
- $attrs_used = array();
- foreach($attrs as $key=>$val){
- if((!is_numeric($key))&&($key!="count")){
- if(is_array($val)&&isset($val['count'])){
- unset($val['count']);
- }
- $attrs_used[$key]=$val;
- }
- }
- /* $attrs contains all values
- * we need, to save the entry lateron
- */
- $attrs= $attrs_used;
+ foreach($this->gotoPrinter as $printer){
+ $printerObj = NULL;
+ $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$printer['dn']);
- /* Depending on the type (User/Admin)
- * switch these attributes, that makes it easier
- */
- if($printer['mode'] == "user"){
- $attribute = "goto".$s_suffix."Printer";
- $attribute2 = "goto".$s_suffix."AdminPrinter";
+ if($printer['mode'] == "admin") {
+ $attribute = "goto".$s_suffix."AdminPrinter";
}else{
- $attribute = "goto".$s_suffix."AdminPrinter";
- $attribute2 = "goto".$s_suffix."Printer";
+ $attribute = "goto".$s_suffix."Printer";
}
- /* 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
- */
- if(!isset($printer[$attribute2])){
- $printer[$attribute2]=array();
- }else{
- if(in_array($this->uid,$printer[$attribute2])){
- $tmp = array_flip($printer[$attribute2]);
- unset($tmp[$this->uid]);
- $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])){
- $attrs[$attribute]=array($this->uid);
- }else{
- unset($attrs[$attribute]['count']);
- if(!in_array($this->uid,$attrs[$attribute])){
- $attrs[$attribute][]=$this->uid;
- }
- }
+ $printerObj->by_object['printgeneric']->AddMember($types[$attribute],$this->dn);
+ $printerObj->by_object['printgeneric']->save();
+ }
+
- $ldap->cd($attrs['dn']);
- unset($attrs['dn']);
-$ldap->modify ($attrs);
- if($ldap->get_error()!="Success"){
- print_red(_("Error while writing printer settings")." : ".$ldap->get_error());
- }
- }
-
/* Prepare HotPlug devices */
$this->attrs['gotoHotplugDevice'] = array();
foreach($this->gotoHotplugDevices as $name => $device){