diff --git a/plugins/admin/groups/class_groupApplication.inc b/plugins/admin/groups/class_groupApplication.inc
index edc3239b34d1a8465448bdaa888a90dc36caa1f2..12b80fab21da955b609519b1be3058b5c17b5132 100644 (file)
var $curbase = "";
var $curCatDir ;
var $curCatDepth =0; //
+ var $Categories;
/* attribute list for save action */
var $attributes = array("gosaMemberApplication","gosaApplicationParameter");
var $AllAppsForRelease = array();
var $AllAppsForReleaseParameter = array();
-
+ var $view_logged = FALSE;
var $CopyPasteVars = array("Categories");
var $gosaApplicationParameter ;
var $ui = NULL;
var $no_release_acls = false;
- function appgroup ($config, $dn= NULL, $parent= NULL)
+ function appgroup (&$config, $dn= NULL, $parent= NULL)
{
/* Check if we have relase mangement enabled and prepare group application for release management */
- $tmp = search_config($config->data,"faiManagement","CLASS");
+ $tmp = $config->search("faiManagement", "CLASS",array('menu','tabs'));
if(!empty($tmp)){
$this->enableReleaseManagement = true;
$this->objectclasses [] = "FAIreleaseTag";
/* Release management is activated && this is a valid group app account,
but no release class was found, so activate is_account flag */
- if($dn != "new" && ( in_array("gosaApplicationGroup",$this->attrs['objectClass'])) &&
- (!in_array("FAIreleaseTag",$this->attrs['objectClass']))){
- $this->is_account =true;
+ if(isset($this->attrs['objectClass'])){
+ if($dn != "new" && ( in_array("gosaApplicationGroup",$this->attrs['objectClass'])) &&
+ (!in_array("FAIreleaseTag",$this->attrs['objectClass']))){
+ $this->is_account =true;
+ }
}
}
$this->InitialFAIrelease = $this->FAIrelease;
$this->Releases = $this->getReleases();
}
+
}
/* Call parent execute */
plugin::execute();
+ /* Log view */
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","groups/".get_class($this),$this->dn);
+ }
+
/* Check if department was selected */
if((isset($_GET['act']))&&($_GET['act']=="depopen")){
$dep = base64_decode($_GET['depid']);
}
/* Check if category was selected */
- if((isset($_GET['act']))&&($_GET['act']=="open") && isset($this->Categories[base64_decode($_GET['id'])])){
+ if((isset($_GET['act']))&&($_GET['act']=="open") && (empty($_GET['id']) || isset($this->Categories[base64_decode($_GET['id'])]))){
$this->curCatDir = base64_decode($_GET['id']);
}
}
/* Do we represent a valid group? */
- if (!$this->is_account && $this->parent == NULL){
+ if (!$this->is_account && $this->parent === NULL){
$display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
_("This 'dn' is no appgroup.")."</b>";
return ($display);
/* Show tab dialog headers */
$display= "";
- if ($this->parent != NULL){
+ if ($this->parent !== NULL){
if ($this->is_account){
$display= $this->show_disable_header(_("Remove applications"),
_("This group has application features enabled. You can disable them by clicking below."));
}
}
- /* Remove category entry */
- 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) && !$only_once){
+ $only_once =TRUE;
+ $cat = preg_replace("/DelCat_/","",$name);
+ $cat = trim(base64_decode( preg_replace("/_.*$/","",$cat)));
+
+ $free_apps = array();
+
+ if(isset($this->gosaMemberApplication[$cat]) && is_array($this->gosaMemberApplication[$cat])){
+ foreach($this->gosaMemberApplication[$cat] as $app){
+ $free_apps[] = $app['App'];
+ }
+ unset($this->gosaMemberApplication[$cat]);
+ unset($this->Categories[$cat]);
+ }
+ foreach($this->Categories as $key => $name){
+ if(preg_match("/^".normalizePreg($cat)."\/.*/",$key)){
+ foreach($this->gosaMemberApplication[$key] as $app){
+ $free_apps[] = $app['App'];
}
+ unset($this->gosaMemberApplication[$key]);
unset($this->Categories[$key]);
}
}
+ foreach($free_apps as $app){
+ if(isset($this->used_apps[$app])){
+ unset($this->used_apps[$app]);
+ }
+ }
}
/* Edit application parameter */
$ldap= $this->config->get_ldap_link();
/* Check if we have release management enabled */
- $tmp = search_config($this->config->data,"faiManagement","CLASS");
+ $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
if(!empty($tmp)){
/* Get application parameter from ldap */
}
}
+ /* Add multiple */
+ if(isset($_POST['AddApps'])){
+ foreach($_POST as $name => $value){
+ if(preg_match("/AddApp_/",$name)){
+ $app = preg_replace("/AddApp_/","",$name);
+ $this->addApp($app);
+ }
+ }
+ }
+
/* Add application with post */
if((isset($_GET['act']))&&($_GET['act']=="add")){
$this->used_apps[$_GET['id']]= $_GET['id'];
/* Create application list */
- $div = new DivSelectBox("appgroup");
+ $div = new divSelectBox("appgroup");
$div->SetHeight(300);
$departments = array();
$res = get_list("(objectClass=gosaDepartment)", "application", $this->curbase,array("description","cn","ou"),GL_SIZELIMIT);
foreach($res as $value){
- $fdn= @LDAP::fix(str_replace($this->curbase,"",$value['dn']));
+ $fdn = $value['dn'];
+ $fdn = preg_replace("/".normalizePreg($this->curbase)."/","",$fdn);
+ $fdn= @LDAP::fix($fdn);
if($value["description"][0]!=".."){
$departments[$value['dn']]= convert_department_dn($fdn)." - [".$value["description"][0]."]";
}else{
- $departments[$value['dn']]=convert_department_dn($fdn);
+ $departments[$value['dn']]=convert_department_dn($fdn)." ["._("Back")."]";
}
}
}
/* Create list of used/assigned applications */
- $div2 = new DivSelectBox("appgroup");
+ $div2 = new divSelectBox("appgroup");
$div2->SetHeight(300);
/* Check acls to create "edit/remove" category links */
$tmp = split("/",$this->curCatDir);
$bbk = "";
for($i = 0 ; $i < ($cnt -1 ) ; $i++){
- $bbk .= $tmp[$i];
+ $bbk .= $tmp[$i]."/";
}
- $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,base64_encode($bbk),"..")),array("string"=>" ","attach"=>"style='border-right:0px;'")));
+ $bbk = preg_replace("/\/$/","",$bbk);
+ $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,base64_encode($bbk),".. ["._("Back")."]")),array("string"=>" ","attach"=>"style='border-right:0px;'")));
}
/* Add sub categories */
/* release managent is active
*/
if(!$this->enableReleaseManagement){
- $image = "<img class='center' src='images/select_invalid_application.png'
+ $image = "<img class='center' alt='R' src='images/select_invalid_application.png'
title='"._("This application is no longer available.")."'> ";
}else{
- $image = "<img class='center' src='images/select_invalid_application.png'
- title='".sprintf(_("This application is not available in any release named %s."),$this->FAIrelease)."'> ";
+ $image = "<img class='center' alt='F' src='images/select_invalid_application.png'
+ title=\"".sprintf(_("This application is not available in any release named %s."),$this->FAIrelease)."\"> ";
}
}elseif(isset($Differences[$entry['App']]) && ($Differences[$entry['App']] == true)) {
}
/* Show main page */
- if ($this->dialog){
+ if (is_object($this->dialog)){
$smarty->assign("table", $this->table);
- $display.= $smarty->fetch (get_template_path('application_options.tpl', TRUE));
+ $display.= $smarty->fetch (get_template_path('application_options.tpl', TRUE,dirname(__FILE__)));
} else {
- $display.= $smarty->fetch (get_template_path('application.tpl', TRUE));
+ $display.= $smarty->fetch (get_template_path('application.tpl', TRUE,dirname(__FILE__)));
}
return ($display);
function remove_from_parent()
{
+ if(!$this->initially_was_account){
+ return;
+ }
+
plugin::remove_from_parent();
$ldap= $this->config->get_ldap_link();
$this->cleanup();
$ldap->modify ($this->attrs);
-
+ new log("remove","group/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
show_ldap_error($ldap->get_error(), sprintf(_("Removing of groups/applications with dn '%s' failed."),$this->dn));
/* Optionally execute a command after we're done */
{
/* Skip saving application settings, if we do not have release acls */
if($this->no_release_acls){
- gosa_log("Skip saving group application extension. Caused by insufficient acls");
+ new log("security","groups/".get_class($this),$this->dn,array(),"Skip saving group application extension. Caused by insufficient acls");
+
return;
}
$this->Categories[""]="";
$this->attrs["gosaMemberApplication"]= array();
$this->attrs["gosaApplicationParameter"]= array();
+ $cat_id= 0 ;
foreach($this->Categories as $name => $cats){
$i =0;
if(isset($this->gosaMemberApplication[$name])){
foreach($this->gosaMemberApplication[$name] as $entry){
if(!preg_match("/__SEPARATOR__/",$entry['App'])){
$this->attrs["gosaMemberApplication"][]= $entry['App']."|".$name."|".$i;
+ $i ++;
}
- $i ++;
}
}
if(($i==0)&&(!empty($name))){
- $this->attrs["gosaMemberApplication"][]= "|".$name."|".$i;
+ $this->attrs["gosaMemberApplication"][]= "|".$name."|".$cat_id;
}
+ $cat_id++;
}
+
+
/* Are there application parameters to be saved */
$this->attrs['gosaApplicationParameter']= array();
foreach($this->appoption as $name => $value){
$this->cleanup();
$ldap->modify ($this->attrs);
+ if($this->initially_was_account){
+ new log("modify","group/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }else{
+ new log("create","group/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ }
+
show_ldap_error($ldap->get_error(), sprintf(_("Saving of groups/applications with dn '%s' failed."),$this->dn));
/* Optionally execute a command after we're done */
$this->apps= array();
/* Special handling for release managed apps */
- $tmp = search_config($this->config->data,"faiManagement","CLASS");
- if(!empty($tmp)){
+ $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
+ if(!empty($tmp) && count($this->Releases)){
$this->enableReleaseManagement = true;
/* Check if release is available */
}
/* Get all apps ... */
- $res = get_list("objectClass=gosaApplication","application",$this->config->current['BASE'],array("gosaApplicationParameter","cn"));
- $tmp = search_config($this->config->data,"faiManagement","CLASS");
+ $res = get_list("objectClass=gosaApplication","application",$this->config->current['BASE'],array("gosaApplicationParameter","cn"),GL_SUBSEARCH);
+ $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
$this->AllAppsForRelease = array();
if(!empty($tmp)){
$tmp = array_flip($this->Releases);
}
+ function PrepareForCopyPaste($source)
+ {
+ $s = new appgroup($this->config,$source['dn']);
+ $this->FAIrelease = $this->InitialFAIrelease = $s->FAIrelease;
+ $this->gosaMemberApplication = $s->gosaMemberApplication;
+ $this->appoption = $s->appoption;
+ $this->Categories = $s->Categories;
+ }
+
+
/* Return plugin informations for acl handling */
- function plInfo()
+ static function plInfo()
{
return (array(
"plShortName" => _("Applications"),