diff --git a/plugins/admin/groups/class_groupApplication.inc b/plugins/admin/groups/class_groupApplication.inc
index 4f036b494812a4776cf45d3dbe4fa4005f7b5ff1..8166af28ccfba2cefc2b37966d609bde1f31baa3 100644 (file)
var $gosaApplicationParameter ;
- function appgroup ($config, $dn= NULL)
+ function appgroup ($config, $dn= NULL, $parent= NULL)
{
/* prepare group app for release management */
$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.
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")){
}
/* 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? */
$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);
}
/* 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."));
}
}
$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= "<table summary=\"\">";
- 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= "<table summary=\"\">";
+ for ($i= 0; $i < count($this->option_name); $i++){
+ if (isset($this->option_value[$i])){
+ $value= $this->option_value[$i];
+ } else {
+ $value= "";
+ }
+ $table.="<tr><td>".$this->option_name[$i]."</td><td>".
+ "<input name=\"value$i\" size=60 maxlength=250 ".
+ "value=\"".$value."\"><br></td></tr>";
}
- $table.="<tr><td>".$this->option_name[$i]."</td><td>".
- "<input name=\"value$i\" size=60 maxlength=250 ".
- "value=\"".$value."\"><br></td></tr>";
+ $table.= "</table>";
+ $this->table= $table;
+ } else {
+ print_red (_("The selected application has no options."));
}
- $table.= "</table>";
- $this->table= $table;
- } else {
- print_red (_("The selected application has no options."));
}
}
}
}
-
+
$this->reload();
/* Add group with post */
/* 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{
}
}
+ if($this->acl_is_writeable("gosaMemberApplication")){
+ $linkadd = "<a href='?plug=".$_GET['plug']."&act=add&id=%s'>%s</a>";
+ }else{
+ $linkadd = "%s";
+ }
+
$linkopen = "<a href='?plug=".$_GET['plug']."&act=depopen&depid=%s'>%s</a>";
- $linkadd = "<a href='?plug=".$_GET['plug']."&act=add&id=%s'>%s</a>";
$base_back = preg_replace("/^[^,]+,/","",$this->curbase);
if((strlen($base_back)>= strlen($this->config->current['BASE']))&&($this->curbase!=$this->config->current['BASE'])){
$div2 = new DivSelectBox("appgroup");
$div2->SetHeight(300);
- $linkopen = "<img class='center' src='images/folder.png' alt=\"\"> <a href='?plug=".$_GET['plug']."&act=open&id=%s'>%s</a>";
- $catremove = " <input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelCat_%s' value='%s'>";
- $app = "<img class='center' src='images/select_application.png' alt=\"\"> %s";
-
- $catupdown = "<a href='?plug=".$_GET['plug']."&act=cat_up&id=%s'>
- <img align='top' alt=\"\" src='images/sort_up.png' border=0 title='"._("Move up")."'></a> <a href='?plug=".$_GET['plug']."&act=cat_down&id=%s'>
- <img alt=\"\" src='images/sort_down.png' title='"._("Move down")."' border=0></a>";
+ if(!$this->acl_is_writeable("gosaMemberApplication")){
+ $linkopen = "<img class='center' src='images/folder.png' alt=\"\"> <a href='?plug=".$_GET['plug']."&act=open&id=%s'>%s</a>";
+ $catremove = " <img src='images/empty.png' alt=' '>";
+ $catupdown = "";
+ }else{
+ $linkopen = "<img class='center' src='images/folder.png' alt=\"\"> <a href='?plug=".$_GET['plug']."&act=open&id=%s'>%s</a>";
+ $catremove = " <input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelCat_%s' value='%s'>";
+ $catupdown = "<a href='?plug=".$_GET['plug']."&act=cat_up&id=%s'>".
+ "<img align='top' alt=\"\" src='images/sort_up.png' border=0 title='"._("Move up")."'>".
+ "</a> ".
+ "<a href='?plug=".$_GET['plug']."&act=cat_down&id=%s'>".
+ "<img alt=\"\" src='images/sort_down.png' title='"._("Move down")."' border=0>".
+ "</a>";
+ }
if(empty($this->curCatDir)){
$cnt =0;
$separator ="<hr size=1>";
- $sep = "<input type='image' src='images/back.png' title='"._("Insert seperator")."' value='%s' name='AddSep_%s'>";
-
- $upudown ="<a href='?plug=".$_GET['plug']."&act=one_up&id=%s'> <img alt='{t}sort{/t}' align='top' src='images/sort_up.png' title='"._("Move up")."' border=0></a>".
- " <a href='?plug=".$_GET['plug']."&act=one_down&id=%s'> <img alt='{t}sort{/t}' src='images/sort_down.png' title='"._("Move down")."' border=0></a>".
- " <input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelApp_%s' value='%s' alt='{t}delete{/t}' >";
- $edit= " <input type='image' src='images/edit.png' title='"._("Edit entry")."' name='EdiApp_%s' value='%s' alt='{t}edit{/t}' >";
+ if($this->acl_is_writeable("gosaMemberApplication")){
+ $sep = "<input type='image' src='images/back.png' title='"._("Insert seperator")."' value='%s' name='AddSep_%s'>";
+ $upudown = "<a href='?plug=".$_GET['plug']."&act=one_up&id=%s'>".
+ " <img alt='{t}sort{/t}' align='top' src='images/sort_up.png' title='"._("Move up")."' border=0>".
+ "</a> ".
+ "<a href='?plug=".$_GET['plug']."&act=one_down&id=%s'>".
+ " <img alt='{t}sort{/t}' src='images/sort_down.png' title='"._("Move down")."' border=0>".
+ "</a> ".
+ "<input type='image' src='images/edittrash.png' title='"._("Delete entry")."' name='DelApp_%s' value='%s' alt='{t}delete{/t}' >";
+ }else{
+ $sep = "";
+ $upudown = "";
+ }
+
+ if($this->acl_is_writeable("gosaApplicationParameter")){
+ $edit= " <input type='image' src='images/edit.png' title='"._("Edit entry")."' name='EdiApp_%s' value='%s' alt='{t}edit{/t}' >";
+ }else{
+ $edit= "";
+ }
$Differences = $this->diffAppsInReleases();
$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){
} 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));
/* 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");
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);
$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:
?>