summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 07d32bb)
raw | patch | inline | side by side (parent: 07d32bb)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 2 Apr 2008 12:23:47 +0000 (12:23 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 2 Apr 2008 12:23:47 +0000 (12:23 +0000) |
-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
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10115 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/plugins/admin/sudo/class_sudoGeneric.inc | patch | blob | history | |
gosa-core/plugins/admin/sudo/generic.tpl | patch | blob | history |
diff --git a/gosa-core/plugins/admin/sudo/class_sudoGeneric.inc b/gosa-core/plugins/admin/sudo/class_sudoGeneric.inc
index 9fc17326466cf815a6a18439b1e3359c97397483..ee3dfcf15a4c4d36d1a0c48af60fb8737234fa70 100644 (file)
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);
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);
}
$divlist_sudoCommand->Setheight("90");
$neg_img= "<img src='images/negate.png' alt='!' class='center'>";
- $option = "<input type='image' src='images/negate.png' name='del_%ATTR%_%KEY%' class='center'>";
- $option.= "<input type='image' src='images/edittrash.png' name='neg_%ATTR%_%KEY%' class='center'>";
+ $option = "<input type='image' src='images/negate.png' name='neg_%ATTR%_%KEY%' class='center'>";
+ $option.= "<input type='image' src='images/edittrash.png' name='del_%ATTR%_%KEY%' class='center'>";
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(
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()
return ($message);
}
- function getCopyDialog()
- {
- echo "NIY";
- }
-
- function saveCopyDialog()
- {
- echo "NIY";
- }
-
/* Return plugin informations for acl handling */
static function plInfo()
{
index 6f13ff04a9f4133813ee4e7453145627be125799..e0849e8dba41a5043fe84a0e664e55206cc86702 100644 (file)
<tr>
<td style="width:50%"><b>User / Groups</b>
{$divlist_sudoUser}
+ <input type='text' value='' name='new_sudoUser'><input type='submit' name='add_sudoUser' value='{msgPool type=addButton}'>
+ <input type='submit' name='list_sudoUser' value='{t}Add from list{/t}'>
</td>
<td style="border-left: solid 1px #AAAAAA;"><b>Commands</b>
{$divlist_sudoCommand}
+ <input type='text' value='' name='new_sudoCommand'><input type='submit' name='add_sudoCommand' value='{msgPool type=addButton}'>
</td>
</tr>
<tr><td style="width:100%;"colspan="2"><p class="seperator"> </p></td></tr>
<tr>
<td colspan="2"><b>Flags</b>
{$divlist_sudoOption}
+ <input type='submit' name='list_sudoOption' value='{t}Add from list{/t}'>
</td>
</tr>
<tr><td style="width:100%;"colspan="2"><p class="seperator"> </p></td></tr>
<tr>
<td><b>Hosts</b>
{$divlist_sudoHost}
+ <input type='text' value='' name='new_sudoHost'><input type='submit' name='add_sudoHost' value='{msgPool type=addButton}'>
+ <input type='submit' name='list_sudoHost' value='{t}Add from list{/t}'>
</td>
<td style="border-left: solid 1px #AAAAAA;"><b>Run as</b>
{$divlist_sudoRunas}
+ <input type='text' value='' name='new_sudoRunas'><input type='submit' name='add_sudoRunas' value='{msgPool type=addButton}'>
</td>
</tr>
</table>