X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Fadmin%2Fgroups%2Fclass_groupApplication.inc;h=8166af28ccfba2cefc2b37966d609bde1f31baa3;hb=9a0dd04fc44c7afa080b0a0dea3db4ce836d8f36;hp=4f036b494812a4776cf45d3dbe4fa4005f7b5ff1;hpb=cd37996be53acba7f368111a169307a05a9d718f;p=gosa.git diff --git a/plugins/admin/groups/class_groupApplication.inc b/plugins/admin/groups/class_groupApplication.inc index 4f036b494..8166af28c 100644 --- a/plugins/admin/groups/class_groupApplication.inc +++ b/plugins/admin/groups/class_groupApplication.inc @@ -39,7 +39,7 @@ class appgroup extends plugin var $gosaApplicationParameter ; - function appgroup ($config, $dn= NULL) + function appgroup ($config, $dn= NULL, $parent= NULL) { /* prepare group app for release management */ @@ -50,7 +50,7 @@ class appgroup extends plugin $this->attributes[] = "FAIrelease"; } - plugin::plugin ($config, $dn); + plugin::plugin ($config, $dn, $parent); /* In some case of old applikations with old release tag saving, we must reassign is_account state. @@ -372,10 +372,8 @@ class appgroup extends plugin plugin::execute(); if((isset($_GET['act']))&&($_GET['act']=="depopen")){ - $dep = base64_decode($_GET['depid']); - if(isset($this->config->idepartments[$dep])){ - $this->curbase =$dep; - } + $dep = base64_decode($_GET['depid']); + $this->curbase =$dep; } if((isset($_GET['act']))&&($_GET['act']=="open")){ @@ -383,8 +381,12 @@ class appgroup extends plugin } /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; + if(isset($_POST['modify_state'])){ + if($this->is_account && $this->acl_is_removeable()){ + $this->is_account= FALSE; + }elseif(!$this->is_account && $this->acl_is_createable()){ + $this->is_account= TRUE; + } } /* Do we represent a valid group? */ @@ -398,10 +400,10 @@ class appgroup extends plugin $display= ""; if ($this->parent != NULL){ if ($this->is_account){ - $display= $this->show_header(_("Remove applications"), + $display= $this->show_disable_header(_("Remove applications"), _("This group has application features enabled. You can disable them by clicking below.")); } else { - $display.= $this->show_header(_("Create applications"), + $display.= $this->show_enable_header(_("Create applications"), _("This group has application features disabled. You can enable them by clicking below.")); return ($display); } @@ -409,20 +411,22 @@ class appgroup extends plugin /* Add Categorie */ - - if((isset($_POST['AddCat']))&&(isset($_POST['CatName']))&&(!empty($_POST['CatName']))){ - if(preg_match("/[\\\\\/]/i",$_POST['CatName'])){ - print_red(_("Invalid character in category name.")); - }elseif(!in_array($_POST['CatName'],$this->Categories)){ - if(empty($this->curCatDir)){ - $this->Categories[$_POST['CatName']]=$_POST['CatName']; + /* Only allow adding a category, if it is allowed */ + if($this->acl_is_writeable("gosaMemberApplication")){ + + if(preg_match("/[\\\\\/]/i",$_POST['CatName'])){ + print_red(_("Invalid character in category name.")); + }elseif(!in_array($_POST['CatName'],$this->Categories)){ + if(empty($this->curCatDir)){ + $this->Categories[$_POST['CatName']]=$_POST['CatName']; + }else{ + $this->Categories[$this->curCatDir."/".$_POST['CatName']]=$_POST['CatName']; + } }else{ - $this->Categories[$this->curCatDir."/".$_POST['CatName']]=$_POST['CatName']; + print_red(_("The specified category already exists.")); } - }else{ - print_red(_("The specified category already exists.")); } } @@ -431,134 +435,137 @@ class appgroup extends plugin $this->diffAppsInReleases(); $only_once = false; - foreach($_POST as $name => $value){ - - if((preg_match("/AddSep_/",$name))&&(!$only_once)){ - $only_once = true; - $n = preg_replace("/AddSep_/","",$name); - $val= preg_replace("/_.*$/","",$n); - $this->AddSeperator($val); - } - if((preg_match("/DelApp_/",$name))&&(!$only_once)){ - $only_once = true; - + /* Check POST variables for commands to add/remove some applications */ + if($this->acl_is_writeable("gosaMemberApplication")){ + foreach($_POST as $name => $value){ - if(preg_match("/DelApp___SEPARATOR__/",$name)) { - $n= preg_replace("/DelApp___SEPARATOR__/","",$name); - $val= "__SEPARATOR__".preg_replace("/_.*$/","",$n); - }else{ - $n = preg_replace("/DelApp_/","",$name); + if((preg_match("/AddSep_/",$name))&&(!$only_once)){ + $only_once = true; + $n = preg_replace("/AddSep_/","",$name); $val= preg_replace("/_.*$/","",$n); + $this->AddSeperator($val); } - foreach($this->gosaMemberApplication as $key => $cat){ - foreach($cat as $key2 => $app){ - - if($app['App'] == $val){ - unset($this->gosaMemberApplication[$key][$key2]); - if(isset($this->used_apps[$val])){ - foreach($this->getParameters($val) as $para){ - if(isset($this->appoption[$para])){ - unset($this->appoption[$para]); + if((preg_match("/DelApp_/",$name))&&(!$only_once)){ + $only_once = true; + + if(preg_match("/DelApp___SEPARATOR__/",$name)) { + $n= preg_replace("/DelApp___SEPARATOR__/","",$name); + $val= "__SEPARATOR__".preg_replace("/_.*$/","",$n); + }else{ + $n = preg_replace("/DelApp_/","",$name); + $val= preg_replace("/_.*$/","",$n); + } + + foreach($this->gosaMemberApplication as $key => $cat){ + foreach($cat as $key2 => $app){ + + if($app['App'] == $val){ + unset($this->gosaMemberApplication[$key][$key2]); + if(isset($this->used_apps[$val])){ + foreach($this->getParameters($val) as $para){ + if(isset($this->appoption[$para])){ + unset($this->appoption[$para]); + } } + unset($this->used_apps[$val]); } - unset($this->used_apps[$val]); } } } } - } - - if(preg_match("/DelCat_/",$name)){ - $n = preg_replace("/DelCat_/","",$name); - $app = base64_decode( preg_replace("/_.*$/","",$n)); - foreach($this->Categories as $key => $cat){ - if($cat == $app){ - foreach($this->Categories as $p => $n){ - if(preg_match("/^".$key."\/.*/",$p)){ - unset($this->Categories[$p]); + + if(preg_match("/DelCat_/",$name)){ + $n = preg_replace("/DelCat_/","",$name); + $app = base64_decode( preg_replace("/_.*$/","",$n)); + foreach($this->Categories as $key => $cat){ + if($cat == $app){ + foreach($this->Categories as $p => $n){ + if(preg_match("/^".$key."\/.*/",$p)){ + unset($this->Categories[$p]); + } } + unset($this->Categories[$key]); } - unset($this->Categories[$key]); } } - } - - if((preg_match("/EdiApp_/",$name))&&(!$only_once)){ - - $only_once = true; - $appname = $value; - $appname = preg_replace("/EdiApp_/","",$name); - $appname = preg_replace("/_.*$/","",$appname); - - /* We've got the appname, get parameters from ldap - */ - $ldap= $this->config->get_ldap_link(); - - $tmp = search_config($this->config->data,"faiManagement","CLASS"); - if(!empty($tmp)){ - $tmp = array_flip($this->Releases); - $base = $tmp[$this->FAIrelease]; - - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter")); - $found = ""; - while($attrs = $ldap->fetch()) { - if(preg_match("/cn=".$appname.",".$base."/",$attrs['dn'])){ - $found = $attrs['dn']; + + if((preg_match("/EdiApp_/",$name))&&(!$only_once)){ + + $only_once = true; + $appname = $value; + $appname = preg_replace("/EdiApp_/","",$name); + $appname = preg_replace("/_.*$/","",$appname); + + /* We've got the appname, get parameters from ldap + */ + $ldap= $this->config->get_ldap_link(); + + $tmp = search_config($this->config->data,"faiManagement","CLASS"); + if(!empty($tmp)){ + $tmp = array_flip($this->Releases); + $base = $tmp[$this->FAIrelease]; + + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter")); + $found = ""; + while($attrs = $ldap->fetch()) { + if(preg_match("/cn=".$appname.",".$base."/",$attrs['dn'])){ + $found = $attrs['dn']; + } } + $ldap->cat($found, array("gosaApplicationParameter")); + }else{ + $ldap->cd($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter")); } - $ldap->cat($found, array("gosaApplicationParameter")); - }else{ - $ldap->cd($this->config->current['BASE']); - $ldap->search("(&(objectClass=gosaApplication)(cn=$appname))",array("gosaApplicationParameter")); - } - if ($ldap->count() != 1){ - print_red (_("The selected application name is not uniq. Please check your LDAP.")); - } else { - $attrs= $ldap->fetch(); - if(isset($attrs['gosaApplicationParameter'])){ - $this->dialog= TRUE; - - /* Fill name and value arrays */ - for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){ - $option= preg_replace('/^[^:]+:/', '', - $attrs['gosaApplicationParameter'][$i]); - $name= preg_replace('/:.*$/', '', - $attrs['gosaApplicationParameter'][$i]); - $this->option_name[$i]= $name; - - /* Fill with values from application, default should be - loaded by the external scripts */ - if (isset($this->appoption[$name])){ - $this->option_value[$i]= $this->appoption[$name]; + if ($ldap->count() != 1){ + print_red (_("The selected application name is not uniq. Please check your LDAP.")); + } else { + $attrs= $ldap->fetch(); + if(isset($attrs['gosaApplicationParameter'])){ + $this->dialog= TRUE; + + /* Fill name and value arrays */ + for ($i= 0; $i<$attrs['gosaApplicationParameter']['count']; $i++){ + $option= preg_replace('/^[^:]+:/', '', + $attrs['gosaApplicationParameter'][$i]); + $name= preg_replace('/:.*$/', '', + $attrs['gosaApplicationParameter'][$i]); + $this->option_name[$i]= $name; + + /* Fill with values from application, default should be + loaded by the external scripts */ + if (isset($this->appoption[$name])){ + $this->option_value[$i]= $this->appoption[$name]; + } } - } - /* Create edit field */ - $table= ""; - for ($i= 0; $i < count($this->option_name); $i++){ - if (isset($this->option_value[$i])){ - $value= $this->option_value[$i]; - } else { - $value= ""; + /* Create edit field */ + $table= "
"; + for ($i= 0; $i < count($this->option_name); $i++){ + if (isset($this->option_value[$i])){ + $value= $this->option_value[$i]; + } else { + $value= ""; + } + $table.=""; } - $table.=""; + $table.= "
".$this->option_name[$i]."". + "
".$this->option_name[$i]."". - "
"; + $this->table= $table; + } else { + print_red (_("The selected application has no options.")); } - $table.= ""; - $this->table= $table; - } else { - print_red (_("The selected application has no options.")); } } } } - + $this->reload(); /* Add group with post */ @@ -613,9 +620,9 @@ class appgroup extends plugin /* get departments */ $ui = get_userinfo(); $departments = array(); - $res = get_list("(objectClass=gosaDepartment)",$ui->subtreeACL,$this->curbase,array("description","cn","ou"),GL_SIZELIMIT); + $res = get_list("(objectClass=gosaDepartment)", "department", $this->curbase,array("description","cn","ou"),GL_SIZELIMIT); foreach($res as $value){ - $fdn= @LDAP::fix($value['dn']); + $fdn= @LDAP::fix(str_replace($this->curbase,"",$value['dn'])); if($value["description"][0]!=".."){ $departments[$value['dn']]= convert_department_dn($fdn)." - [".$value["description"][0]."]"; }else{ @@ -623,8 +630,13 @@ class appgroup extends plugin } } + if($this->acl_is_writeable("gosaMemberApplication")){ + $linkadd = "%s"; + }else{ + $linkadd = "%s"; + } + $linkopen = "%s"; - $linkadd = "%s"; $base_back = preg_replace("/^[^,]+,/","",$this->curbase); if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($this->curbase!=$this->config->current['BASE'])){ @@ -673,13 +685,20 @@ class appgroup extends plugin $div2 = new DivSelectBox("appgroup"); $div2->SetHeight(300); - $linkopen = "\"\" %s"; - $catremove = " "; - $app = "\"\" %s"; - - $catupdown = " - \"\"  - \"\""; + if(!$this->acl_is_writeable("gosaMemberApplication")){ + $linkopen = "\"\" %s"; + $catremove = "  "; + $catupdown = ""; + }else{ + $linkopen = "\"\" %s"; + $catremove = " "; + $catupdown = "". + "\"\"". + " ". + "". + "\"\"". + ""; + } if(empty($this->curCatDir)){ $cnt =0; @@ -706,12 +725,25 @@ class appgroup extends plugin $separator ="
"; - $sep = ""; - - $upudown =" {t}sort{/t}". - "  {t}sort{/t}". - " "; - $edit= " "; + if($this->acl_is_writeable("gosaMemberApplication")){ + $sep = ""; + $upudown = "". + " {t}sort{/t}". + " ". + "". + " {t}sort{/t}". + " ". + ""; + }else{ + $sep = ""; + $upudown = ""; + } + + if($this->acl_is_writeable("gosaApplicationParameter")){ + $edit= " "; + }else{ + $edit= ""; + } $Differences = $this->diffAppsInReleases(); @@ -771,7 +803,13 @@ class appgroup extends plugin $smarty->assign("ReleaseSelectAble", true); } } - $smarty->assign("ReleaseSelectAble", true); + $smarty->assign("ReleaseSelectAble", true); + + /* Set acls to template */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $acl => $translation){ + $smarty->assign($acl."ACL",$this->getacl($acl)); + } /* Show main page */ if ($this->dialog){ @@ -780,18 +818,19 @@ class appgroup extends plugin } else { $display.= $smarty->fetch (get_template_path('application.tpl', TRUE)); } + return ($display); } function getReleases() { - $dn = $this->config->current['BASE']; - $ldap = $this->config->get_ldap_link(); - $ldap->cd($dn); - $ldap->search("(&(objectClass=organizationalUnit)(objectClass=FAIbranch))",array("ou")); + $dn = $this->config->current['BASE']; + $filter = "(&(objectClass=organizationalUnit)(objectClass=FAIbranch))"; + $res = get_list($filter,"groups", $dn, array("ou"), GL_SUBSEARCH); + $ret =array(); - while($attrs = $ldap->fetch()){ + foreach($res as $attrs){ if(preg_match("/ou=apps,/",$attrs['dn'])){ $bb = preg_replace("/ou=apps,.*/","",$attrs['dn']); $parts = array_reverse(split("ou=",$bb)); @@ -879,7 +918,7 @@ class appgroup extends plugin /* Optionally execute a command after we're done */ if ($this->initially_was_account == $this->is_account){ if ($this->is_modified){ - $this->handle_post_events("mofify"); + $this->handle_post_events("modify"); } } else { $this->handle_post_events("add"); @@ -911,12 +950,15 @@ class appgroup extends plugin if(isset($tmp[$this->FAIrelease])){ $base = $tmp[$this->FAIrelease]; }else{ + $old_r = $this->FAIrelease; $k = key($tmp); $r = $tmp[$k]; $this->FAIrelease = $k; $base = $r; - - print_red(sprintf(_("Can't resolve the release name '%s', setting release name to '%s'. Possibly the objects base has changed."),$this->FAIrelease,$k)); + + if(!(!$this->initially_was_account && $old_r =="/")){ + print_red(sprintf(_("Can't resolve the release name '%s', setting release name to '%s'. Possibly the objects base has changed."),$this->FAIrelease,$k)); + } } $base = preg_replace("/ou=apps,.*$/","ou=apps,".$this->curbase,$base); @@ -1049,9 +1091,27 @@ class appgroup extends plugin $ret[$path]=$cat; } } - return($ret); + return($ret); } -} + + /* Return plugin informations for acl handling */ + function plInfo() + { + return (array( + "plShortName" => _("Applications"), + "plDescription" => _("Group applications"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("admin"), + "plCategory" => array("groups"), + "plProvidedAcls"=> array( + "gosaMemberApplication" => _("Application"), + "FAIrelease" => _("Release"), + "gosaApplicationParameter" => _("Application parameter")) + )); + } +} // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>