From: hickert Date: Wed, 2 Apr 2008 12:23:47 +0000 (+0000) Subject: Updated sudo stuff. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=138da586e49e72ecd93148b7a1e12e2b1c542e68;p=gosa.git Updated sudo stuff. -You are now able to add new roles and edit existing. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10115 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/admin/sudo/class_sudoGeneric.inc b/gosa-core/plugins/admin/sudo/class_sudoGeneric.inc index 9fc173264..ee3dfcf15 100644 --- a/gosa-core/plugins/admin/sudo/class_sudoGeneric.inc +++ b/gosa-core/plugins/admin/sudo/class_sudoGeneric.inc @@ -35,6 +35,8 @@ class sudo extends plugin var $objectclasses = array("top","sudoRole"); var $attributes = array("cn","description","sudoUser","sudoCommand","sudoOption","sudoHost","sudoRunas"); + var $is_account = TRUE; + function sudo(&$config, $dn= NULL) { plugin::plugin ($config, $dn); @@ -57,19 +59,70 @@ class sudo extends plugin plugin::execute(); + /********************* + NEGATE values + *********************/ + foreach($_POST as $name => $value){ + if(preg_match("/^neg_/",$name)){ + $attr = preg_replace("/^neg_([^_]*)_.*$/","\\1",$name); + $value= preg_replace("/^neg_[^_]*_([0-9]*)_.*$/","\\1",$name); + $attrs = $this->$attr; + if(isset( $attrs[$value])){ + $v = $attrs[$value]; + if(preg_match("/^!/",$v)){ + $attrs[$value] = preg_replace("/^!/","",$v); + }else{ + $attrs[$value] = "!".$v; + } + $this->$attr = $attrs; + } + break; // Do it once, image inputs will be posted twice + } + } - - - - + /********************* + Delete values + *********************/ + foreach($_POST as $name => $value){ + if(preg_match("/^del_/",$name)){ + $attr = preg_replace("/^del_([^_]*)_.*$/","\\1",$name); + $value= preg_replace("/^del_[^_]*_([0-9]*)_.*$/","\\1",$name); + $attrs = $this->$attr; + if(isset( $attrs[$value])){ + unset($attrs[$value]); + $this->$attr = $attrs; + } + break; // Do it once, image inputs will be posted twice + } + } + /********************* + ADD values + *********************/ + foreach(array("sudoUser","sudoHost","sudoRunas") as $attr){ + if(isset($_POST["add_".$attr]) && isset($_POST['new_'.$attr]) && !empty($_POST['new_'.$attr])){ + if(preg_match("/^[a-z\.0-9]*$/i",$_POST['new_'.$attr])){ + $attrs = $this->$attr; + $attrs[] = trim($_POST['new_'.$attr]); + $this->$attr = $attrs; + }else{ + msg_dialog::display(_("Invalid"),msgPool::invalid($attr,$_POST['new_'.$attr],"/[a-z0-9]/")); + } + } + } + foreach(array("sudoCommand") as $attr){ + if(isset($_POST["add_".$attr]) && isset($_POST['new_'.$attr])){ + $attrs = $this->$attr; + $attrs[] = trim($_POST['new_'.$attr]); + $this->$attr = $attrs; + } + } $smarty = get_smarty(); - foreach($this->attributes as $attr){ $smarty->assign($attr,$this->$attr); } @@ -86,12 +139,11 @@ class sudo extends plugin $divlist_sudoCommand->Setheight("90"); $neg_img= "!"; - $option = ""; - $option.= ""; + $option = ""; + $option.= ""; foreach(array("sudoUser","sudoCommand","sudoOption","sudoHost","sudoRunas") as $attr){ foreach($this->$attr as $key => $entry){ $entry = preg_replace("/^!/",$neg_img,$entry); - $list_name = "divlist_".$attr; $$list_name->AddEntry( array( @@ -128,6 +180,17 @@ class sudo extends plugin function save() { plugin::save(); + $this->cleanup(); + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->config->current['BASE']); + $ldap->create_missing_trees(get_ou("sudoou")); + $ldap->cd($this->dn); + if($this->is_new){ + $ldap->add($this->attrs);; + }else{ + $ldap->modify($this->attrs);; + } } function check() @@ -136,16 +199,6 @@ class sudo extends plugin return ($message); } - function getCopyDialog() - { - echo "NIY"; - } - - function saveCopyDialog() - { - echo "NIY"; - } - /* Return plugin informations for acl handling */ static function plInfo() { diff --git a/gosa-core/plugins/admin/sudo/generic.tpl b/gosa-core/plugins/admin/sudo/generic.tpl index 6f13ff04a..e0849e8db 100644 --- a/gosa-core/plugins/admin/sudo/generic.tpl +++ b/gosa-core/plugins/admin/sudo/generic.tpl @@ -25,24 +25,31 @@ User / Groups {$divlist_sudoUser} + + Commands {$divlist_sudoCommand} +

 

Flags {$divlist_sudoOption} +

 

Hosts {$divlist_sudoHost} + + Run as {$divlist_sudoRunas} +