From: hickert Date: Tue, 11 Dec 2007 09:03:19 +0000 (+0000) Subject: Added Checkboxes to user multiple edit X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3101d7de9ce3dff057a919049801a3eec9ae08d0;p=gosa.git Added Checkboxes to user multiple edit git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8075 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 51547403d..ff6786f10 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -128,6 +128,7 @@ class plugin /* This aviable indicates, that we are currently in multiple edit handle */ var $multiple_support_active = FALSE; var $selected_edit_values = array(); + var $multi_boxes = array(); /*! \brief plugin constructor @@ -1701,11 +1702,6 @@ class plugin */ function init_multiple_support() { - foreach($this->attributes as $attr){ - if(isset($this->$attr) && is_string($this->$attr)){ - $this->$attr = "{default}"; - } - } } @@ -1716,7 +1712,7 @@ class plugin { $ret = array(); foreach($this->attributes as $attr){ - if($this->$attr != "{default}"){ + if(in_array($attr,$this->multi_boxes)){ $ret[$attr] = $this->$attr; } } diff --git a/include/smarty/plugins/block.render.php b/include/smarty/plugins/block.render.php index 40a456aef..e58e9ad1a 100755 --- a/include/smarty/plugins/block.render.php +++ b/include/smarty/plugins/block.render.php @@ -26,7 +26,7 @@ function smarty_block_render($params, $text, &$smarty) * The parameter 'checked' specifies whether the box is checked or not. * The checkbox disables or enables the current object. */ - if(isset($params['checkbox'])){ + if(isset($params['checkbox']) && $params['checkbox']){ /* Detect name and id of the current object */ $use_text = preg_replace("/\n/"," ",$text); diff --git a/plugins/personal/generic/class_user.inc b/plugins/personal/generic/class_user.inc index ba6943ce8..b08f0c1a1 100644 --- a/plugins/personal/generic/class_user.inc +++ b/plugins/personal/generic/class_user.inc @@ -109,11 +109,12 @@ class user extends plugin var $multiple_support = TRUE; var $multiple_user_handles = array(); + var $multi_boxes = array(); + /* constructor, if 'dn' is set, the node loads the given 'dn' from LDAP */ function user (&$config, $dn= NULL) { - $this->config= $config; /* Configuration is fine, allways */ if ($this->config->current['GOVERNMENTMODE']){ @@ -282,12 +283,7 @@ class user extends plugin /* Assign sex */ $sex= array(0 => " ", "F" => _("female"), "M" => _("male")); $smarty->assign("gender_list", $sex); - - if($this->multiple_support_active){ - $language= array_merge(array(0 => " ","{default}"=>"{default}") ,get_languages(TRUE)); - }else{ - $language= array_merge(array(0 => " ") ,get_languages(TRUE)); - } + $language= array_merge(array(0 => " ") ,get_languages(TRUE)); $smarty->assign("preferredLanguage_list", $language); /* Get random number for pictures */ @@ -559,13 +555,10 @@ class user extends plugin $temp= passwordMethod::get_available_methods(); $is_configurable= FALSE; $hashes = $temp['name']; - if($this->multiple_support_active){ - $hashes["{default}"] = "{default}"; - } if(isset($temp[$this->pw_storage])){ $test= new $temp[$this->pw_storage]($this->config); $is_configurable= $test->is_configurable(); - }elseif($this->pw_storage != "{default}"){ + }else{ new msg_dialog(_("Password method"),_("The selected password method is no longer available."),WARNING_DIALOG); } @@ -573,6 +566,18 @@ class user extends plugin $ui =get_userinfo(); foreach($this->attributes as $val){ $smarty->assign("$val", $this->$val); + if(in_array($val,$this->multi_boxes)){ + $smarty->assign("use_".$val,TRUE); + }else{ + $smarty->assign("use_".$val,FALSE); + } + } + foreach(array("base","pw_storage","edit_picture") as $val){ + if(in_array($val,$this->multi_boxes)){ + $smarty->assign("use_".$val,TRUE); + }else{ + $smarty->assign("use_".$val,FALSE); + } } /* Set acls */ @@ -592,9 +597,6 @@ class user extends plugin /* Create base acls */ $tmp = @$this->allowedBasesToMoveTo(); - if($this->multiple_support_active){ - $tmp['{default}'] = "{"._("default")."}"; - } $smarty->assign("bases", $tmp); /* Save government mode attributes */ @@ -990,7 +992,6 @@ class user extends plugin return (1); } - /* Remove ACL dependencies too */ if($this->dn != $this->orig_dn && $this->orig_dn != "new"){ $tmp = new acl($this->config,$this->parent,$this->dn); @@ -1173,8 +1174,8 @@ class user extends plugin /* Indicate whether a password change is needed or not */ function password_change_needed() { - if($this->pw_storage == "{default}"){ - return(FALSE); + if(in_array("pw_storage",$this->multi_boxes)){ + return(TRUE); } return($this->pw_storage != $this->last_pw_storage); } @@ -1468,17 +1469,16 @@ class user extends plugin function init_multiple_support() { plugin::init_multiple_support(); - $this->pw_storage = "{default}"; } function get_multi_edit_values() { $ret = plugin::get_multi_edit_values(); - if($this->pw_storage != "{default}"){ + if(in_array("pw_storage",$this->multi_boxes)){ $ret['pw_storage'] = $this->pw_storage; } - if($this->jpegPhoto != "{default}"){ + if(in_array("edit_picture",$this->multi_boxes)){ $ret['jpegPhoto'] = $this->jpegPhoto; $ret['photoData'] = $this->photoData; $ret['old_jpegPhoto'] = $this->old_jpegPhoto; @@ -1491,7 +1491,7 @@ class user extends plugin unset($ret['cn']); } $ret['is_modified'] = $this->is_modified; - if($this->base != "{default}"){ + if(in_array("base",$this->multi_boxes)){ $ret['orig_base']="Changed_by_Multi_Plug"; $ret['base']=$this->base; } @@ -1518,6 +1518,20 @@ class user extends plugin if(isset($_POST['base'])){ $this->base = get_post('base'); } + + if(isset($_POST['user_mulitple_edit'])){ + $this->multi_boxes = array(); + foreach($this->attributes as $val){ + if(isset($_POST["use_".$val])){ + $this->multi_boxes[] = $val; + } + } + foreach(array("base","pw_storage","edit_picture") as $val){ + if(isset($_POST["use_".$val])){ + $this->multi_boxes[] = $val; + } + } + } } @@ -1530,37 +1544,31 @@ class user extends plugin if($this->dn == "new") { $this->set_acl_base($this->base); } - if ($this->sn == ""){ - $message[]= _("The required field 'Name' is not set."); - } - if ($this->givenName == ""){ - $message[]= _("The required field 'Given name' is not set."); - } - if (!is_url($this->labeledURI) && $this->labeledURI != "{default}"){ + if (!is_url($this->labeledURI) && in_array("labeledURI",$this->multi_boxes)){ $message[]= _("The field 'Homepage' contains an invalid URL definition."); } - if (preg_match ("/[\\\\]/", $this->sn) && $this->sn != "{default}"){ + if (preg_match ("/[\\\\]/", $this->sn) && in_array("sn",$this->multi_boxes)){ $message[]= _("The field 'Name' contains invalid characters."); } - if (preg_match ("/[\\\\]/", $this->givenName) && $this->givenName != "{default}"){ + if (preg_match ("/[\\\\]/", $this->givenName) && in_array("givenName",$this->multi_boxes)){ $message[]= _("The field 'Given name' contains invalid characters."); } - if (!is_phone_nr($this->telephoneNumber) && $this->telephoneNumber != "{default}"){ + if (!is_phone_nr($this->telephoneNumber) && in_array("telephoneNumber",$this->multi_boxes)){ $message[]= _("The field 'Phone' contains an invalid phone number."); } - if (!is_phone_nr($this->facsimileTelephoneNumber) && $this->facsimileTelephoneNumber != "{default}"){ + if (!is_phone_nr($this->facsimileTelephoneNumber) && in_array("facsimileTelephoneNumber",$this->multi_boxes)){ $message[]= _("The field 'Fax' contains an invalid phone number."); } - if (!is_phone_nr($this->mobile) && $this->mobile != "{default}"){ + if (!is_phone_nr($this->mobile) && in_array("mobile",$this->multi_boxes)){ $message[]= _("The field 'Mobile' contains an invalid phone number."); } - if (!is_phone_nr($this->pager) && $this->pager != "{default}"){ + if (!is_phone_nr($this->pager) && in_array("pager",$this->multi_boxes)){ $message[]= _("The field 'Pager' contains an invalid phone number."); } - if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName) && $this->givenName != "{default}"){ + if (preg_match ('/[,+"?\'()=<>;]/', $this->givenName) && in_array("givenName",$this->multi_boxes)){ $message[]= _("The field 'Given name' contains invalid characters."); } - if (preg_match ('/[,+"?\'()=<>;]/', $this->sn) && $this->sn != "{default}"){ + if (preg_match ('/[,+"?\'()=<>;]/', $this->sn) && in_array("sn",$this->multi_boxes)){ $message[]= _("The field 'Name' contains invalid characters."); } return($message); diff --git a/plugins/personal/generic/generic.tpl b/plugins/personal/generic/generic.tpl index 998165b37..1127e9441 100644 --- a/plugins/personal/generic/generic.tpl +++ b/plugins/personal/generic/generic.tpl @@ -25,9 +25,9 @@ - {render acl=$userPictureACL} +{render acl=$userPictureACL checkbox=$multiple_support checked=$use_edit_picture} - {/render} +{/render} @@ -82,9 +82,9 @@ {if !$multiple_support} - {render acl=$uidACL} +{render acl=$uidACL} - {/render} +{/render} {else} {/if} @@ -99,17 +99,17 @@
- {render acl=$personalTitleACL} +{render acl=$personalTitleACL checkbox=$multiple_support checked=$use_personalTitle} - {/render} +{/render} - {render acl=$academicTitleACL} +{render acl=$academicTitleACL checkbox=$multiple_support checked=$use_academicTitle} - {/render} +{/render} {if !$multiple_support} @@ -120,7 +120,7 @@
- {render acl=$dateOfBirthACL} +{render acl=$dateOfBirthACL} {if $use_dob eq 1} {/if} - {/render} +{/render} -{/if} -{if !$multiple_support} - {render acl=$genderACL} +{render acl=$genderACL} - {/render} +{/render} {/if} @@ -159,11 +157,11 @@ - {render acl=$preferredLanguageACL} +{render acl=$preferredLanguageACL checkbox=$multiple_support checked=$use_preferredLanguage} - {/render} +{/render} @@ -173,14 +171,14 @@
- {render acl=$baseACL} +{render acl=$baseACL checkbox=$multiple_support checked=$use_base} - {/render} - {render acl=$baseACL disable_picture='images/folder_gray.png'} +{/render} +{render acl=$baseACL disable_picture='images/folder_gray.png'} - {/render} +{/render} @@ -195,25 +193,25 @@ - {render acl=$homePostalAddressACL} +{render acl=$homePostalAddressACL checkbox=$multiple_support checked=$use_homePostalAddress} - {/render} +{/render} - {render acl=$homePhoneACL} +{render acl=$homePhoneACL checkbox=$multiple_support checked=$use_homePhone} - {/render} +{/render} - {render acl=$labeledURIACL} +{render acl=$labeledURIACL checkbox=$multiple_support checked=$use_labeledURI} - {/render} +{/render} @@ -224,14 +222,14 @@ - {render acl=$passwordStorageACL} +{render acl=$passwordStorageACL checkbox=$multiple_support checked=$use_pw_storage} {if $pw_configurable eq "true"}   {/if} - {/render} +{/render} @@ -239,9 +237,9 @@ - {render acl=$CertificatesACL mode=read_active} +{render acl=$CertificatesACL mode=read_active} - {/render} +{/render} {/if} @@ -272,41 +270,41 @@ - {render acl=$oACL} +{render acl=$oACL checkbox=$multiple_support checked=$use_o} - {/render} +{/render} - {render acl=$ouACL} +{render acl=$ouACL checkbox=$multiple_support checked=$use_ou} - {/render} +{/render} - {render acl=$departmentNumberACL} +{render acl=$departmentNumberACL checkbox=$multiple_support checked=$use_departmentNumber} - {/render} +{/render} - {render acl=$employeeNumberACL} +{render acl=$employeeNumberACL checkbox=$multiple_support checked=$use_employeeNumber} - {/render} +{/render} - {render acl=$employeeTypeACL} +{render acl=$employeeTypeACL checkbox=$multiple_support checked=$use_employeeType} - {/render} +{/render} @@ -322,43 +320,43 @@ - {render acl=$roomNumberACL} +{render acl=$roomNumberACL checkbox=$multiple_support checked=$use_roomNumber} - {/render} +{/render} {if $has_phoneaccount ne "true"} - {render acl=$telephoneNumberACL} +{render acl=$telephoneNumberACL checkbox=$multiple_support checked=$use_telephoneNumber} - {/render} +{/render} {/if} - {render acl=$mobileACL} +{render acl=$mobileACL checkbox=$multiple_support checked=$use_mobile} - {/render} +{/render} - {render acl=$pagerACL} +{render acl=$pagerACL checkbox=$multiple_support checked=$use_pager} - {/render} +{/render} - {render acl=$facsimileTelephoneNumberACL} +{render acl=$facsimileTelephoneNumberACL checkbox=$multiple_support checked=$use_facsimileTelephoneNumber} - {/render} +{/render} @@ -374,25 +372,25 @@ - {render acl=$lACL} +{render acl=$lACL checkbox=$multiple_support checked=$use_l} - {/render} +{/render} - {render acl=$stACL} +{render acl=$stACL checkbox=$multiple_support checked=$use_st} - {/render} +{/render} - {render acl=$postalAddressACL} +{render acl=$postalAddressACL checkbox=$multiple_support checked=$use_postalAddress} - {/render} +{/render} @@ -406,44 +404,44 @@ - {render acl=$vocationACL} +{render acl=$vocationACL checkbox=$multiple_support checked=$use_vocation} - {/render} +{/render} - {render acl=$gouvernmentOrganizationalUnitDescriptionACL} +{render acl=$gouvernmentOrganizationalUnitDescriptionACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalUnitDescription} - {/render} +{/render} - {render acl=$gouvernmentOrganizationalUnitSubjectAreaACL} +{render acl=$gouvernmentOrganizationalUnitSubjectAreaACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalUnitSubjectArea} - {/render} +{/render} - {render acl=$functionalTitleACL} +{render acl=$functionalTitleACL checkbox=$multiple_support checked=$use_functionalTitle} - {/render} +{/render} - {render acl=$roleACL} +{render acl=$roleACL checkbox=$multiple_support checked=$use_role} - {/render} +{/render} @@ -455,44 +453,44 @@ - {render acl=$gouvernmentOrganizationalPersonLocalityACL} +{render acl=$gouvernmentOrganizationalPersonLocalityACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalPersonLocality} - {/render} +{/render} - {render acl=$gouvernmentOrganizationalUnitACL} +{render acl=$gouvernmentOrganizationalUnitACL checkbox=$multiple_support checked=$use_gouvernmentOrganizationalUnit} - {/render} +{/render} - {render acl=$streetACL} +{render acl=$streetACL checkbox=$multiple_support checked=$use_street} - {/render} +{/render} - {render acl=$postalCodeACL} +{render acl=$postalCodeACL checkbox=$multiple_support checked=$use_postalCode} - {/render} +{/render} - {render acl=$houseIdentifierACL} +{render acl=$houseIdentifierACL checkbox=$multiple_support checked=$use_houseIdentifier} - {/render} +{/render} @@ -504,49 +502,49 @@ - {render acl=$roomNumberACL} +{render acl=$roomNumberACL checkbox=$multiple_support checked=$use_roomNumber} - {/render} +{/render} - {render acl=$telephoneNumberACL} +{render acl=$telephoneNumberACL checkbox=$multiple_support checked=$use_telephoneNumber} {if $has_phoneaccount ne "true"} {else} {t}Please use the phone tab{/t} {/if} - {/render} +{/render} - {render acl=$facsimileTelephoneNumberACL} +{render acl=$facsimileTelephoneNumberACL checkbox=$multiple_support checked=$use_facsimileTelephoneNumber} - {/render} +{/render} - {render acl=$ivbbLastDeliveryCollectiveACL} +{render acl=$ivbbLastDeliveryCollectiveACL checkbox=$multiple_support checked=$use_ivbbLastDeliveryCollective} - {/render} +{/render} - {render acl=$publicVisibleACL} +{render acl=$publicVisibleACL checkbox=$multiple_support checked=$use_publicVisible} - {/render} +{/render} @@ -555,6 +553,9 @@ +{if $multiple_support} + +{/if}