index 617c7eacaff81cd72b8c8fdb35d55a22670b7b03..6437f1dd9452694874bc0cd197cce1aed39b6d9e 100644 (file)
"functionalTitle", "certificateSerialNumber", "publicVisible", "street", "role",
"postalCode");
+ var $multiple_support = TRUE;
+ var $multiple_support_active = FALSE;
+ var $selected_edit_values = array();
+ var $multiple_user_handles = 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']){
/* Load base attributes */
plugin::plugin ($config, $dn);
- $this->orig_dn = $this->dn;
+ $this->orig_dn = $this->dn;
+ $this->new_dn = $this->dn;
+
+ $this->new_dn = $dn;
if ($this->config->current['GOVERNMENTMODE']){
/* Fix public visible attribute if unset */
}
/* Load data from LDAP? */
- if ($dn != NULL){
+ if ($dn !== NULL){
/* Do base conversation */
if ($this->dn == "new"){
if (isset ($this->attrs['gender'])){
$this->gender= strtoupper($this->attrs['gender'][0]);
}
-
+
$this->orig_base = $this->base;
}
+
+
/* execute generates the html output for this node */
function execute()
{
/* Call parent execute */
plugin::execute();
+ if($this->multiple_support_active){
+ return($this->execute_multiple());
+ }
/* Log view */
if($this->is_account && !$this->view_logged){
$this->view_logged = TRUE;
$temp= passwordMethod::get_available_methods();
$hashes = $temp['name'];
+ $test= new $temp[$this->pw_storage]($this->config);
+ $is_configurable= $test->is_configurable();
/* Load attributes and acl's */
$ui =get_userinfo();
$smarty->assign("pwmode", $hashes);
$smarty->assign("pwmode_select", $this->pw_storage);
+ $smarty->assign("pw_configurable", $is_configurable);
$smarty->assign("passwordStorageACL", $this->getacl("userPassword",(!is_object($this->parent) && !isset($_SESSION['edit']))));
$smarty->assign("base_select", $this->base);
$smarty->assign("CertificatesACL", $this->getacl("Certificate",(!is_object($this->parent) && !isset($_SESSION['edit']))));
$og->save ();
}
- /* Kerberos server defined? */
- if (isset($this->config->data['SERVERS']['KERBEROS'])){
- $cfg= $this->config->data['SERVERS']['KERBEROS'];
+ /* If needed, let the password method do some cleanup */
+ $tmp = new passwordMethod($_SESSION['config']);
+ $available = $tmp->get_available_methods();
+ if (in_array_ics($this->pw_storage, $available['name'])){
+ $test= new $available[$this->pw_storage]($this->config);
+ $test->attrs= $this->attrs;
+ $test->dn= $this->dn;
+ $test->remove_from_parent();
}
- if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
-
- /* Connect to the admin interface */
- $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
- $cfg['ADMIN'], $cfg['PASSWORD']);
-
- /* Errors? */
- if ($handle === FALSE){
- print_red (_("Kerberos database communication failed"));
- return (2);
- }
-
- /* Build user principal, get list of existsing principals */
- $principal= $this->uid."@".$cfg['REALM'];
- $principals = kadm5_get_principals($handle);
-
- /* User exists in database? */
- if (in_array($principal, $principals)){
-
- /* Ok. User exists. Remove him/her */
- $ret= kadm5_delete_principal ( $handle, $principal);
- if ($ret === FALSE){
- print_red (_("Can't remove user from kerberos database."));
- }
- }
- /* Free kerberos admin handle */
- kadm5_destroy($handle);
- }
-
- /* Remove ACL dependencies too,
- */
+ /* Remove ACL dependencies too */
$tmp = new acl($this->config,$this->parent,$this->dn);
$tmp->remove_acl();
/* Save data to object */
function save_object()
{
- if (isset($_POST['generic'])){
+ if (isset($_POST['multiple_user_posted'])){
+ $this->save_object_multiple();
+ }
+ if(isset($_POST['generic']) || isset($_POST['multiple_user_posted'])){
/* Make a backup of the current selected base */
$base_tmp = $this->base;
}
}
+
/* Save data to LDAP, depending on is_account we save or delete */
function save()
{
if($this->gender=="0") $this->gender ="";
if($this->preferredLanguage=="0") $this->preferredLanguage ="";
-
/* First use parents methods to do some basic fillup in $this->attrs */
plugin::save ();
}
- /* Remove ACL dependencies too,
- */
+ /* Remove ACL dependencies too */
if($this->dn != $this->orig_dn && $this->orig_dn != "new"){
$tmp = new acl($this->config,$this->parent,$this->dn);
$tmp->update_acl_membership($this->orig_dn,$this->dn);
ldap_close($ds);
}
- /* Kerberos server defined? */
- if (isset($this->config->data['SERVERS']['KERBEROS'])){
- $cfg= $this->config->data['SERVERS']['KERBEROS'];
- }
- if (isset($cfg['SERVER']) && function_exists('kadm5_init_with_password')){
-
- /* Connect to the admin interface */
- $handle = kadm5_init_with_password($cfg['SERVER'], $cfg['REALM'],
- $cfg['ADMIN'], $cfg['PASSWORD']);
-
- /* Errors? */
- if ($handle === FALSE){
- print_red (_("Kerberos database communication failed"));
- return (2);
+ /* If needed, let the password method do some cleanup */
+ if ($this->pw_storage != $this->last_pw_storage){
+ $tmp = new passwordMethod($_SESSION['config']);
+ $available = $tmp->get_available_methods();
+ if (in_array_ics($this->pw_storage, $available['name'])){
+ $test= new $available[$this->pw_storage]($this->config);
+ $test->attrs= $this->attrs;
+ $test->dn= $this->dn;
+ $test->remove_from_parent();
}
-
- /* Build user principal, get list of existsing principals */
- $principal= $this->uid."@".$cfg['REALM'];
- $principals = kadm5_get_principals($handle);
-
- /* User exists in database? */
- if (in_array($principal, $principals)){
-
- /* Ok. User exists. Remove him/her when pw_storage has
- changed to be NOT kerberos. */
- if ($this->pw_storage != $this->config->current['KRBSASL']){
- $ret= kadm5_delete_principal ( $handle, $principal);
-
- if ($ret === FALSE){
- print_red (_("Can't remove user from kerberos database."));
- }
- }
-
- } else {
-
- /* User doesn't exists, create it when pw_storage is kerberos. */
- if ($this->pw_storage == "kerberos" || $this->pw_storage == "sasl" ){
- $ret= kadm5_create_principal ( $handle, $principal);
-
- if ($ret === FALSE){
- print_red (_("Can't add user to kerberos database."));
- }
- }
-
- }
-
- /* Free kerberos admin handle */
- kadm5_destroy($handle);
}
/* Optionally execute a command after we're done */
$this->set_acl_base($this->base);
}
- /* must: sn, givenName, uid */
- if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
- $message[]= _("The required field 'Name' is not set.");
- }
- /* UID already used? */
- $ldap= $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(uid=$this->uid)", array("uid"));
- $ldap->fetch();
- if ($ldap->count() != 0 && $this->dn == 'new'){
- $message[]= _("There's already a person with this 'Login' in the database.");
- }
+ if(!$this->multiple_support_active){
- /* In template mode, the uid and givenName are autogenerated... */
- if (!$this->is_template){
- if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
- $message[]= _("The required field 'Given name' is not set.");
+ /* must: sn, givenName, uid */
+ if ($this->sn == "" && ($this->acl_is_writeable("sn",(!is_object($this->parent) && !isset($_SESSION['edit'])) || ($this->is_new)))){
+ $message[]= _("The required field 'Name' is not set.");
}
- if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
- $message[]= _("The required field 'Login' is not set.");
+
+ /* UID already used? */
+ $ldap= $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(uid=$this->uid)", array("uid"));
+ $ldap->fetch();
+ if ($ldap->count() != 0 && $this->dn == 'new'){
+ $message[]= _("There's already a person with this 'Login' in the database.");
}
- if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
- $ldap->cat($this->new_dn);
- if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){
- $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
+
+ /* In template mode, the uid and givenName are autogenerated... */
+ if (!$this->is_template){
+ if ($this->givenName == "" && $this->acl_is_writeable("givenName",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
+ $message[]= _("The required field 'Given name' is not set.");
+ }
+ if ($this->uid == "" && $this->acl_is_writeable("uid",(!is_object($this->parent) && !isset($_SESSION['edit'])))){
+ $message[]= _("The required field 'Login' is not set.");
+ }
+ if (!(isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid")){
+ $ldap->cat($this->new_dn);
+ if ($ldap->count() != 0 && $this->dn != $this->new_dn && $this->dn == 'new'){
+ $message[]= _("There's already a person with this 'Name'/'Given name' combination in the database.");
+ }
}
}
- }
- /* Check for valid input */
- if ($this->is_modified && !is_uid($this->uid)){
- $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
- }
- if (!is_url($this->labeledURI)){
- $message[]= _("The field 'Homepage' contains an invalid URL definition.");
- }
- if (preg_match ("/[\\\\]/", $this->sn)){
- $message[]= _("The field 'Name' contains invalid characters.");
- }
- if (preg_match ("/[\\\\]/", $this->givenName)){
- $message[]= _("The field 'Given name' contains invalid characters.");
+ /* Check for valid input */
+ if ($this->is_modified && !is_uid($this->uid)){
+ $message[]= _("The field 'Login' contains invalid characters. Lowercase, numbers and dashes are allowed.");
+ }
+ if (!is_url($this->labeledURI)){
+ $message[]= _("The field 'Homepage' contains an invalid URL definition.");
+ }
+ if (preg_match ("/[\\\\]/", $this->sn)){
+ $message[]= _("The field 'Name' contains invalid characters.");
+ }
+ if (preg_match ("/[\\\\]/", $this->givenName)){
+ $message[]= _("The field 'Given name' contains invalid characters.");
+ }
}
/* Check phone numbers */
/* Indicate whether a password change is needed or not */
function password_change_needed()
{
- return ($this->pw_storage != $this->last_pw_storage);
+ return($this->pw_storage != $this->last_pw_storage);
}
}
/* Get back uid/sn/givenName */
- if ($this->parent != NULL){
+ if ($this->parent !== NULL){
$this->uid= $this->parent->uid;
$this->sn= $this->parent->sn;
$this->givenName= $this->parent->givenName;
}
- function plInfo()
+ static function plInfo()
{
$govattrs= array(
$ret["plProvidedAcls"][$attr] = $desc;
}
}
-
return($ret);
}
+
+
+
+
+
+
+
+
+ function get_values_to_update()
+ {
+ $ret = plugin::get_multi_edit_values();
+ return($ret);
+ }
+
+
+ function save_object_multiple()
+ {
+ foreach(array("pw_storage","base","edit_cert") as $attr){
+ if(isset($_POST["use_".$attr])){
+ $this->selected_edit_values[$attr] = TRUE;
+ }else{
+ $this->selected_edit_values[$attr] = FALSE;
+ }
+ }
+ }
+
+
+ function execute_multiple()
+ {
+ $smarty =get_smarty();
+ $language= array_merge(array(0 => " ") ,get_languages(TRUE));
+ $smarty->assign("preferredLanguage_list", $language);
+ @$smarty->assign("bases", $this->allowedBasesToMoveTo());
+ $smarty->assign("base_select", $this->base);
+
+ /* Save government mode attributes */
+ if (isset($this->config->current['GOVERNMENTMODE']) &&
+ preg_match('/true/i', $this->config->current['GOVERNMENTMODE'])){
+ $smarty->assign("governmentmode", "true");
+ $ivbbmodes= array("nein", "ivbv", "testa", "ivbv,testa", "internet",
+ "internet,ivbv", "internet,testa", "internet,ivbv,testa");
+ $smarty->assign("ivbbmodes", $ivbbmodes);
+ foreach ($this->govattrs as $val){
+ $smarty->assign("$val", $this->$val);
+ $smarty->assign("$val"."ACL", $this->getacl($val,(!is_object($this->parent) && !isset($_SESSION['edit']))));
+ }
+ } else {
+ $smarty->assign("governmentmode", "false");
+ }
+
+ $temp= passwordMethod::get_available_methods();
+ $hashes = $temp['name'];
+ $test= new $temp[$this->pw_storage]($this->config);
+ $is_configurable= $test->is_configurable();
+ $smarty->assign("pwmode", $hashes);
+ $smarty->assign("pwmode_select", $this->pw_storage);
+ $smarty->assign("pw_configurable", $is_configurable);
+
+ foreach($this->attributes as $attr){
+ if(isset($this->selected_edit_values[$attr]) && $this->selected_edit_values[$attr] == TRUE){
+ $smarty->assign("use_".$attr,TRUE);
+ }else{
+ $smarty->assign("use_".$attr,FALSE);
+ }
+ $smarty->assign($attr,$this->$attr);
+ }
+ foreach(array("pw_storage","base","edit_cert") as $attr){
+ if(isset($this->selected_edit_values[$attr]) && $this->selected_edit_values[$attr] == TRUE){
+ $smarty->assign("use_".$attr,TRUE);
+ }else{
+ $smarty->assign("use_".$attr,FALSE);
+ }
+ }
+ return($smarty->fetch (get_template_path('multiple_generic.tpl', TRUE, dirname(__FILE__))));
+ }
+
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: