From: hickert Date: Wed, 1 Jul 2009 09:59:34 +0000 (+0000) Subject: Updated role handling X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d6c0324fac5f06b3bc6a18af6cc45da0fadff35a;p=gosa.git Updated role handling git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13866 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index ce88fdc4b..5ff19c639 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -1164,6 +1164,7 @@ function get_ou($name) global $config; $map = array( + "roleRDN" => "ou=roles,", "ogroupRDN" => "ou=groups,", "applicationRDN" => "ou=apps,", "systemRDN" => "ou=systems,", diff --git a/gosa-plugins/roleManagement/admin/roleManagement/class_divListRole.inc b/gosa-plugins/roleManagement/admin/roleManagement/class_divListRole.inc index bc76d0e88..22c7f1d0a 100644 --- a/gosa-plugins/roleManagement/admin/roleManagement/class_divListRole.inc +++ b/gosa-plugins/roleManagement/admin/roleManagement/class_divListRole.inc @@ -118,8 +118,8 @@ class divListRole extends MultiSelectWindow if(preg_match("/c/",$acls)) { $s .= "..|". " "._("Create")."|\n"; - $s.= "...|". - " "._("Roles")."|role_new|\n"; + $s.= "...|". + " "._("Role")."|role_new|\n"; } /* Multiple options */ @@ -194,7 +194,7 @@ class divListRole extends MultiSelectWindow $field0 = array("string" => "" , "attach" => "style='width:20px;'"); - $field1 = array("string" => " ""._("Role")."", "attach" => "style='text-align:center;width: 20px;'"); $field2 = array("string" => sprintf($editlink,$key,$display), diff --git a/gosa-plugins/roleManagement/admin/roleManagement/class_roleGeneric.inc b/gosa-plugins/roleManagement/admin/roleManagement/class_roleGeneric.inc index 098215732..48c6c7570 100644 --- a/gosa-plugins/roleManagement/admin/roleManagement/class_roleGeneric.inc +++ b/gosa-plugins/roleManagement/admin/roleManagement/class_roleGeneric.inc @@ -23,20 +23,123 @@ class roleGeneric extends plugin { - var $cn =""; + var $cn = ""; + var $description =""; + var $telephoneNumber = ""; + var $facsimileTelephoneNumber = ""; + var $x121Address = ""; + var $roleOccupant = array(); + + var $base = ""; + var $orig_dn = ""; + + var $objectclasses = array("top","organizationalRole"); + var $attributes = array("cn","x121Address","description", + "telephoneNumber","facsimileTelephoneNumber","roleOccupant"); function __construct($config,$dn){ plugin::plugin($config,$dn); + $this->is_account = TRUE; + $this->orig_dn = $dn; + + /* Set base */ + if ($this->dn == "new"){ + $this->base = session::get('CurrentMainBase'); + } else { + $this->base= preg_replace("/^[^,]+,".preg_quote(get_ou("roleRDN"), '/')."/","",$this->dn); + } } function execute(){ $smarty = get_smarty(); - + /* Create base acls */ + $tmp = $this->allowedBasesToMoveTo(); + $smarty->assign("bases", $tmp); + $smarty->assign("base_select",$this->base); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $attr => $desc){ + $smarty->assign($attr."ACL",$this->getacl($attr)); + } return($smarty->fetch(get_template_path('roleGeneric.tpl',TRUE,dirname(__FILE__)))); } + + function save(){ + plugin::save(); + + /* Save data. Using 'modify' implies that the entry is already present, use 'add' for + new entries. So do a check first... */ + $ldap = $this->config->get_ldap_link(); + $ldap->cat ($this->dn, array('dn')); + if ($ldap->fetch()){ + $mode= "modify"; + } else { + $mode= "add"; + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn)); + } + @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save via $mode"); + + /* Finally write data with selected 'mode' */ + $this->cleanup(); + $ldap->cd ($this->dn); + $ldap->$mode ($this->attrs); + if (!$ldap->success()){ + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), + $this->dn, LDAP_DEL, get_class())); + 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); + $tmp->update_acl_membership($this->orig_dn,$this->dn); + } + + if($mode == "modify"){ + new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + } + + + /* This avoids that users move themselves out of their rights. + */ + function allowedBasesToMoveTo() + { + /* Get bases */ + $bases = $this->get_allowed_bases(); + return($bases); + } + + + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Role generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 1, + "plSection" => array("administration"), + "plCategory" => array("roles" => array("description" => _("Roles"), + "objectClass" => "organizationalRole")), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "description" => _("Description"), + "base" => _("Base"), + "telephoneNumber" => _("Telefon number"), + "facsimileTelephoneNumber" => _("Fax number"), + "roleOccupant" => _("Occupants"), + "x121Address" => _("X.121 Address")) + )); + } } diff --git a/gosa-plugins/roleManagement/admin/roleManagement/class_roleManagement.inc b/gosa-plugins/roleManagement/admin/roleManagement/class_roleManagement.inc index 6752cde43..598dcf80f 100644 --- a/gosa-plugins/roleManagement/admin/roleManagement/class_roleManagement.inc +++ b/gosa-plugins/roleManagement/admin/roleManagement/class_roleManagement.inc @@ -115,6 +115,7 @@ class roleManagement extends plugin if($s_action == "new"){ $this->dialog = new roletabs($this->config, $this->config->data['TABS']['ROLETABS'], "new"); + $this->dialog->set_acl_base($this->DivListRoles->selectedBase); } /*************** @@ -126,7 +127,7 @@ class roleManagement extends plugin trigger_error("Unknown entry!"); }else{ $entry = $this->roles[$s_entry]; - print_a($entry); + $this->dialog = new roletabs($this->config, $this->config->data['TABS']['ROLETABS'], $entry['dn']); } } @@ -134,7 +135,22 @@ class roleManagement extends plugin * Dialog handling ***************/ - if (isset($_POST['edit_cancel'])){ + if (isset($_POST['edit_finish']) && $this->dialog instanceOf tabs){ + $this->dialog->save_object(); + $msgs = $this->dialog->check(); + if(count($msgs)){ + msg_dialog::displayChecks($msgs); + }else{ + $this->dialog->save(); + if(isset($this->grouptab->dn)){ + $this->remove_lock(); + } + $this->dialog= NULL; + set_object_info(); + } + } + + if (isset($_POST['edit_cancel']) && $this->dialog instanceOf tabs){ if(isset($this->grouptab->dn)){ $this->remove_lock(); } @@ -198,9 +214,17 @@ class roleManagement extends plugin // Search and fetch all matching role objects. $this->roles = array(); $ldap = $this->config->get_ldap_link(); - $ldap->search("(objectClass=gosaGroupOfNames)",array("cn","description")); + $filter= "(&(objectClass=organizationalRole)(cn=$Regex))"; + $attrs = array("cn","description","objectClass"); + + if($this->DivListRoles->SubSearch){ + $res= get_sub_list($filter, "roles",get_ou('roleRDN'), $base, $attrs, GL_SIZELIMIT | GL_SUBSEARCH); + }else{ + $res= get_sub_list($filter, "roles",get_ou('roleRDN'), get_ou('roleRDN').$base, $attrs, GL_SIZELIMIT ); + } + $tmp = array(); - while($attrs = $ldap->fetch()){ + foreach($res as $attrs){ $tmp[$attrs['cn'][0].$attrs['dn']] = $attrs; } diff --git a/gosa-plugins/roleManagement/admin/roleManagement/main.inc b/gosa-plugins/roleManagement/admin/roleManagement/main.inc index 28c548c68..72c5ae1fc 100644 --- a/gosa-plugins/roleManagement/admin/roleManagement/main.inc +++ b/gosa-plugins/roleManagement/admin/roleManagement/main.inc @@ -54,7 +54,7 @@ if ( $cleanup ){ "\"\" ". LDAP::fix(get_object_info())); } else { - $display= print_header(get_template_path('plugins/roleManagement/images/plugin.png'), _("roleManagement")); + $display= print_header(get_template_path('plugins/roleManagement/images/plugin.png'), _("Role management")); } $display.= $output; diff --git a/gosa-plugins/roleManagement/admin/roleManagement/roleGeneric.tpl b/gosa-plugins/roleManagement/admin/roleManagement/roleGeneric.tpl index 45f95e2f0..ca1fc0c22 100644 --- a/gosa-plugins/roleManagement/admin/roleManagement/roleGeneric.tpl +++ b/gosa-plugins/roleManagement/admin/roleManagement/roleGeneric.tpl @@ -1,48 +1,43 @@ + - - - - - + - - - - - - - - - + + + + + - + @@ -54,14 +49,6 @@ {/render} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
{t}x121Address{/t}: - {render acl=$x121AddressACL} - - {/render} -
{t}registeredAddress{/t}:{t}cn{/t}: - {render acl=$registeredAddressACL} - + {render acl=$cnACL} + {/render}
{t}destinationIndicator{/t}: - {render acl=$destinationIndicatorACL} - - {/render} -
{t}preferredDeliveryMethod{/t}: - {render acl=$preferredDeliveryMethodACL} - - {/render} -
{t}telexNumber{/t}:{t}description{/t}: - {render acl=$telexNumberACL} - + {render acl=$descriptionACL} + {/render}
+
+ +
+
+{render acl=$baseACL} + +{/render} +{render acl=$baseACL disable_picture='images/lists/folder_grey.png'} + +{/render} +
{t}teletexTerminalIdentifier{/t}:{t}x121Address{/t}: - {render acl=$teletexTerminalIdentifierACL} - + {render acl=$x121AddressACL} + {/render}
{t}internationaliSDNNumber{/t}: - {render acl=$internationaliSDNNumberACL} - - {/render} -
{t}facsimileTelephoneNumber{/t}: @@ -70,100 +57,4 @@ {/render}
{t}seeAlso{/t}: - {render acl=$seeAlsoACL} - - {/render} -
{t}roleOccupant{/t}: - {render acl=$roleOccupantACL} - - {/render} -
{t}preferredDeliveryMethod{/t}: - {render acl=$preferredDeliveryMethodACL} - - {/render} -
{t}street{/t}: - {render acl=$streetACL} - - {/render} -
{t}postOfficeBox{/t}: - {render acl=$postOfficeBoxACL} - - {/render} -
{t}postalCode{/t}: - {render acl=$postalCodeACL} - - {/render} -
{t}postalAddress{/t}: - {render acl=$postalAddressACL} - - {/render} -
{t}physicalDeliveryOfficeName{/t}: - {render acl=$physicalDeliveryOfficeNameACL} - - {/render} -
{t}ou{/t}: - {render acl=$ouACL} - - {/render} -
{t}st{/t}: - {render acl=$stACL} - - {/render} -
{t}l{/t}: - {render acl=$lACL} - - {/render} -
{t}description{/t}: - {render acl=$descriptionACL} - - {/render} -
diff --git a/gosa-plugins/roleManagement/admin/roleManagement/tabs_roles.inc b/gosa-plugins/roleManagement/admin/roleManagement/tabs_roles.inc index fc660f0a2..e0c64754a 100644 --- a/gosa-plugins/roleManagement/admin/roleManagement/tabs_roles.inc +++ b/gosa-plugins/roleManagement/admin/roleManagement/tabs_roles.inc @@ -26,6 +26,7 @@ class roletabs extends tabs function __construct($config, $data, $dn) { tabs::tabs($config, $data, $dn,"roles"); + $this->base = $baseobject= $this->by_object['roleGeneric']->base; $this->addSpecialTabs(); }