From: hickert Date: Thu, 12 Jun 2008 13:47:40 +0000 (+0000) Subject: Allow to create country objects. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4332bee2b8ed3273ba195bb4761ae974d5b3b9df;p=gosa.git Allow to create country objects. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11305 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/departments/class_countryGeneric.inc b/gosa-core/plugins/admin/departments/class_countryGeneric.inc index 6477cd146..d44f72e68 100644 --- a/gosa-core/plugins/admin/departments/class_countryGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_countryGeneric.inc @@ -25,9 +25,18 @@ class country extends department /* attribute list for save action */ var $attributes = array( "c", "description"); var $objectclasses = array("top", "country"); - var $type ="c"; + var $type ="c"; + var $c =""; + var $orgi_c =""; + + var $namingAttr = "c"; + + function check() + { + $message = plugin::check(); + return($message); + } - var $c =""; } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/gosa-core/plugins/admin/departments/class_departmentGeneric.inc b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc index 62b3947af..3962c4794 100644 --- a/gosa-core/plugins/admin/departments/class_departmentGeneric.inc +++ b/gosa-core/plugins/admin/departments/class_departmentGeneric.inc @@ -37,6 +37,7 @@ class department extends plugin var $view_logged = FALSE; var $type ="ou"; + var $namingAttr = "ou"; /* Headpage attributes */ var $last_dep_sorting= "invalid"; @@ -60,7 +61,13 @@ class department extends plugin $this->ui= get_userinfo(); $this->dn= $dn; $this->orig_dn= $dn; - $this->orig_ou= $this->ou; + + /* Save current naming attribuet + */ + $nA = $this->namingAttr; + $orig_nA = "orig_".$nA; + $this->$orig_nA = $this->$nA; + $this->config= $config; /* Set base */ diff --git a/gosa-core/plugins/admin/departments/class_departmentManagement.inc b/gosa-core/plugins/admin/departments/class_departmentManagement.inc index baf9ae2e4..03cf292c6 100644 --- a/gosa-core/plugins/admin/departments/class_departmentManagement.inc +++ b/gosa-core/plugins/admin/departments/class_departmentManagement.inc @@ -305,7 +305,6 @@ class departmentManagement extends plugin So don't move it below the moved check !. */ $message= $this->deptabs->check(); - $obj = $this->deptabs->by_object['department']; /************* MOVED ? @@ -333,7 +332,7 @@ class departmentManagement extends plugin $this->ObjectInSaveMode = true; /* This object must be tagged, so set ObjectTaggingRequested to true */ - if($this->deptabs->by_object['department']->must_be_tagged()){ + if($this->deptabs->by_object[$this->deptabs->base_name]->must_be_tagged()){ $smarty = get_smarty(); $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment&no_output_compression"); $smarty->assign("message",_("As soon as the tag operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog.")); @@ -427,6 +426,8 @@ class departmentManagement extends plugin $result[$tmp[$base_back]]=$tmp2; } + + if($this->DivListDepartment->SubSearch){ $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))", "department", $base, array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH); @@ -435,7 +436,16 @@ class departmentManagement extends plugin "department", $base, array("ou", "description"), GL_SIZELIMIT ); } + + /**/ + $non_ou = get_list("(&(|(c=$Regex)(description=$Regex))(objectClass=country))", + "department", $base, array("c", "description"), GL_SIZELIMIT ); + $this->departments= array(); + foreach($non_ou as $obj){ + $this->departments[] = $obj['dn']; + } + /* Add current base to the list of available departments, but only if its naming attribute is 'ou' */ if(preg_match("/^ou=/",$base)){ diff --git a/gosa-core/plugins/admin/departments/class_divListDepartment.inc b/gosa-core/plugins/admin/departments/class_divListDepartment.inc index 55ef8d2fa..6fa3f8d07 100644 --- a/gosa-core/plugins/admin/departments/class_divListDepartment.inc +++ b/gosa-core/plugins/admin/departments/class_divListDepartment.inc @@ -195,48 +195,59 @@ class divListDepartment extends MultiSelectWindow $actions= ""; - $acl = $ui->get_permissions($this->config->departments[$key] ,"department/department"); - $acl_all = $ui->has_complete_category_acls($this->config->departments[$key] ,"department"); + if(!isset($this->config->departments[$key])){ - $actions.= ""; + $field01 = array("string" => " ", "attach" => "style='width:20px;'"); + $field0 = array("string" => "department", + "attach" => "style='text-align:center;width:20px;'"); + $field1 = array("string" => $val, "attach" => "style='' title='".$val."'"); + $field2 = array("string" => "", "attach" => "style='border-right: 0px;'"); - if(preg_match("/d/",$acl)){ - $actions.= ""; - } + }else{ + $acl = $ui->get_permissions($this->config->departments[$key] ,"department/department"); + $acl_all = $ui->has_complete_category_acls($this->config->departments[$key] ,"department"); - if(!isset($this->config->departments[trim($key)])){ - $this->config->departments[trim($key)]=""; - } + $actions.= ""; - /* check if this department contains sub-departments - Display different image in this case - */ - $non_empty=""; - $nkey= normalizePreg($key); - foreach($this->config->departments as $keyd=>$vald ){ - if(preg_match('/$nkey\/.*/',$keyd)){ - $non_empty="full"; + if(preg_match("/d/",$acl)){ + $actions.= ""; } - } - $title = preg_replace('/ /', ' ', @LDAP::fix($this->config->departments[$key])); + if(!isset($this->config->departments[trim($key)])){ + $this->config->departments[trim($key)]=""; + } - if($val == "."){ - $field01 = array("string" => " ", - "attach" => "style='width:20px;'"); - }else{ - $field01 = array("string" => "" , - "attach" => "style='width:20px;'"); - } + /* check if this department contains sub-departments + Display different image in this case + */ + $non_empty=""; + $nkey= normalizePreg($key); + foreach($this->config->departments as $keyd=>$vald ){ + if(preg_match('/$nkey\/.*/',$keyd)){ + $non_empty="full"; + } + } + + $title = preg_replace('/ /', ' ', @LDAP::fix($this->config->departments[$key])); - $field0 = array("string" => "department", "attach" => "style='text-align:center;width:20px;'"); - $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'"); - $field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:60px;border-right:0px;text-align: - right;'"); + if($val == "."){ + $field01 = array("string" => " ", + "attach" => "style='width:20px;'"); + }else{ + $field01 = array("string" => "" , + "attach" => "style='width:20px;'"); + } + + $field0 = array("string" => "department", "attach" => "style='text-align:center;width:20px;'"); + $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'"); + $field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:60px;border-right:0px;text-align: + right;'"); + } $this->AddElement( array($field01,$field0,$field1,$field2)); } diff --git a/gosa-core/plugins/admin/departments/tabs_department.inc b/gosa-core/plugins/admin/departments/tabs_department.inc index 65fc151ef..e8a784248 100644 --- a/gosa-core/plugins/admin/departments/tabs_department.inc +++ b/gosa-core/plugins/admin/departments/tabs_department.inc @@ -24,11 +24,23 @@ class deptabs extends tabs { var $base= ""; var $moved = FALSE; + var $base_name = "department"; function deptabs($config, $data, $dn,$category) { tabs::tabs($config, $data, $dn,$category); + /* Detect the base class (The classs which extends from department) + */ + $class = "department"; + foreach($this->by_object as $name => $object){ + if($object instanceOf department){ + $this->base_name = get_class($object); + break; + } + } + + /* Add references/acls/snapshots */ $this->addSpecialTabs(); $this->by_object['acl']->skipTagging= TRUE;; @@ -47,11 +59,19 @@ class deptabs extends tabs { return(FALSE); if($this->moved) return(FALSE); - $baseobject= &$this->by_object['department']; - $ou = preg_replace('/,/', '\,', $baseobject->ou); - $new_dn = @LDAP::convert('ou='.$ou.','.$baseobject->base); - $old_ou = preg_replace('/,/', '\,', $baseobject->orig_ou); - $old_dn = @LDAP::convert('ou='.$ou.','.$baseobject->orig_base); + $baseobject= &$this->by_object[$this->base_name]; + + $namingAttr = $baseobject->namingAttr; + $orig_namingAttr = $baseobject->orig_namingAttr; + + $value = preg_replace('/,/', '\,', $baseobject->$namingAttr); + $orig_value = preg_replace('/,/', '\,', $baseobject->$orig_namingAttr); + + $new_dn = @LDAP::convert($namingAttr.'='.$value.','.$baseobject->base); + $old_dn = @LDAP::convert($namingAttr.'='.$orig_value.','.$baseobject->orig_base); + + print_a(array($new_dn,$old_dn)); + if ($this->dn != $new_dn && $this->dn != "new"){ return(TRUE); } @@ -73,7 +93,7 @@ class deptabs extends tabs function move_me() { if(!$this->am_i_moved()) return; - $baseobject= &$this->by_object['department']; + $baseobject= &$this->by_object[$this->base_name]; $ou = preg_replace('/,/', '\,', $baseobject->ou); $new_dn = @LDAP::convert('ou='.$ou.','.$baseobject->base); $old_ou = preg_replace('/,/', '\,', $baseobject->orig_ou); @@ -87,9 +107,12 @@ class deptabs extends tabs function save($ignore_account= FALSE) { - $baseobject= &$this->by_object['department']; - $ou = preg_replace('/,/', '\,', $baseobject->ou); - $new_dn = @LDAP::convert('ou='.$ou.','.$baseobject->base); + $baseobject= &$this->by_object[$this->base_name]; + + $namingAttr = $baseobject->namingAttr; + + $nAV = preg_replace('/,/', '\,', $baseobject->$namingAttr); + $new_dn = @LDAP::convert($namingAttr.'='.$nAV.','.$baseobject->base); /* Move group? */ if ($this->dn != $new_dn && $this->dn != "new"){