X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Fgoto%2Fadmin%2Fgroups%2Fapps%2Fclass_groupApplication.inc;h=00f87bb5287539e360fb5c4c2979eb89c31834fb;hb=1ea7fc6b8292ab24adc41e2a602c3a5c152afa14;hp=33231aacdd12d92e1137df72ea2db8c7fd3e5acf;hpb=1609447070529db729abb365e4b6fdcbfca74a5e;p=gosa.git diff --git a/gosa-plugins/goto/admin/groups/apps/class_groupApplication.inc b/gosa-plugins/goto/admin/groups/apps/class_groupApplication.inc index 33231aacd..00f87bb52 100644 --- a/gosa-plugins/goto/admin/groups/apps/class_groupApplication.inc +++ b/gosa-plugins/goto/admin/groups/apps/class_groupApplication.inc @@ -1,12 +1,6 @@ "Eins ist toll", "zwei" => "Zwei ist noch besser"); - - var $config; var $curbase; @@ -22,7 +16,9 @@ class appgroup extends plugin var $app_parameter = array(); var $edit_entry = array(); var $enableReleaseManagement = FALSE; - + + var $copied_release = ""; + public function __construct(&$config, $dn= NULL, $parent= NULL) { @@ -39,9 +35,12 @@ class appgroup extends plugin $this->Releases = $this->getReleases(); $this->FAIrelease = "/"; - $this->curbase = $this->config->current['BASE']; + $this->curbase = $this->config->current['BASE']; $this->reload(); - + + /* If we have at least one assigned application- + Enable this account. + */ $this->is_account = FALSE; if(count($this->_get_all_entries()) > 1){ $this->is_account= TRUE; @@ -50,15 +49,21 @@ class appgroup extends plugin } - /*! \brief Reload the list of applications for the currently selected release + /*! \brief Reload the list of applications for the currently selected release. + If necessary, maybe the list is already cached. */ function reload() { $ret = array(); $release_info = $this->Releases[$this->FAIrelease]; + /* Check if the available application were already been fetched. + If not, build up a list of available applications. + */ if(!isset($this->_cache['ReleaseApps'][$release_info['suffix']])){ + /* First of all, get all application departments to search in. + */ $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); $ldap->search("ou=apps",array("dn")); @@ -67,6 +72,8 @@ class appgroup extends plugin $app_deps[] = $attrs['dn']; } + /* Search all release departments for the above fetched application departments + */ foreach($app_deps as $dep){ $ldap->cd($dep); $ldap->search("objectClass=FAIbranch",array("dn")); @@ -75,34 +82,77 @@ class appgroup extends plugin } } + /* Filter out those releases that match the currently selected release, + and fetch all applications from those departments. + */ foreach($app_deps as $dep){ if(preg_match("/^".normalizePreg($release_info['suffix'])."/",$dep)){ $ret = array_merge($ret,get_list("(objectClass=gosaApplication)","application",$dep,array("*"),GL_NONE)); } } - $this->_cache['ReleaseApps'][$release_info['suffix']] = $ret; + + /* Create a new array containing all fetch apps for the currently selected release, + sort it and store results in cache. + */ + $tmp = array(); + foreach($ret as $key => $app){ + $tmp[$key] = $app['cn'][0]; + } + natcasesort($tmp); + $res = array(); + foreach($tmp as $key => $app){ + $res[] = $ret[$key]; + } + + $this->_cache['ReleaseApps'][$release_info['suffix']] = $res; } $this->apps = $this->_cache['ReleaseApps'][$release_info['suffix']]; } - /*! \brief generate a list of available releases @return return an array with all available releases. + + e.g. + + / "name" / + "found" 1 + "parts" Array (empty) + "suffix" ou=apps, + + halut "name" halut + "found" 1 + "FAIstate" + "dn" ou=halut,ou=apps,ou=Direktorium,o=Landeshauptstadt München,c=de + "parts" 0 halut + "suffix" ou=halut,ou=apps, + + This will be used as base for the application menu structure. + If there is a menu assigned for a release, this menu will be + appended with the index 'ENTRIES'; */ function getReleases() { $ret =array("/" => array("name" => "/", "found" => TRUE , "parts" => array(),"suffix" => get_ou('applicationou'))); if($this->enableReleaseManagement){ - /* Only display those releases that we are able to read */ - $dn = $this->config->current['BASE']; + /* Only display those releases that we are able to read + */ + $dn = get_ou("applicationou").$this->config->current['BASE']; $filter = "(&(objectClass=organizationalUnit)(objectClass=FAIbranch))"; - $res = get_list($filter,"application", $dn, array("ou","FAIstate"), GL_SUBSEARCH); + $res = get_sub_list($filter,array("application","fai"), + array(get_ou("applicationou"),get_ou("faiou")),$dn, array("ou","FAIstate"), GL_SUBSEARCH); + /* Go through all departments and check which department is a valid + department release. + */ foreach($res as $attrs){ if(preg_match("/".get_ou('applicationou')."/",$attrs['dn'])){ + + /* Parse all returned departments dns into a useable type. + (ou=1.0.0,ou=halut,ou=apps ==> halue/1.0.0) + */ $bb = preg_replace("/".get_ou('applicationou').".*/","",$attrs['dn']); $parts = array_reverse(split("ou=",$bb)); @@ -120,11 +170,14 @@ class appgroup extends plugin if(empty($name)) { $name ="/"; } + $FAIstate = ""; if(isset($attrs['FAIstate'])){ $FAIstate = $attrs['FAIstate'][0]; } + /* Check if this department has a menu structure assigned + */ $all = $this->_get_all_entries(); $found = FALSE; foreach($all as $entry){ @@ -134,7 +187,6 @@ class appgroup extends plugin } } - $cnt = 0; $ret[$name] = array("name" => $name, "found" => $found, "FAIstate" => $FAIstate, @@ -148,15 +200,31 @@ class appgroup extends plugin } - /*! \brief Load the menu structure from ldap and create a multi dimensional array + /*! \brief Load the menu structure from ldap and create a multi dimensional array. + + This will create a multidimensional array. + e.g.: + + $this->a_Structure = + + [0]['TYPE'] = "BASE" + [0]['ENTRIES'] [0]['TYPE'] = "RELEASE" + [0]['NAME'] = "halut" + [0]['ENTRIES']= array() + ... + [0]['ENTRIES'] [1]['TYPE'] = "RELEASE" + [1]['NAME'] = "halut/1.0.0" + [1]['ENTRIES'] [0]['TYPE'] = "TYPE" + [0]['NAME'] = "Programme" + [0]['ENTRIES'][0]['TYPE'] = "ENTRY" + [0]['NAME'] = "konqueror" + [1]['TYPE'] = "ENTRY" + [1]['NAME'] = "firefox" */ function _load_menu_structure() { - $this->a_Structure = array(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->dn); - $ldap->search("(|(objectClass=gotoSubmenuEntry)(objectClass=FAIbranch)(objectClass=gotoMenuEntry))",array("*")); - + /* Create the base object + */ $base = array(); $base['UNIQID'] = uniqid(); $base['PARENT'] = 0; @@ -165,26 +233,57 @@ class appgroup extends plugin $base['ENTRIES']= array(); $base['STATUS'] = "LOADED"; + $this->a_Structure = array(); $this->a_Structure[0] = $base; + /* Search for all Releases/Menu Folders and Menu Entries, + to append them to our structure array. + */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->search("(|(objectClass=gotoSubmenuEntry)(objectClass=FAIbranch)(objectClass=gotoMenuEntry))",array("*")); while($attrs = $ldap->fetch()){ - $cur = &$this->a_Structure[0]['ENTRIES']; + + /* Find the correct position where to add this entry. + e.g. If we have cn=firefox,cn=Programme,ou=halut... + + 1. get a pointer to the halut array ($this->a_Structure['0'][ENTRIES''][]['halut']) + 2. then get a pointer to the halut['ENTRIES'][]['Programme'] array. + 3. append 'firefox' to the 'ENTRIES' of our "Programme" pointer. + */ + $cur = &$this->a_Structure[0]['ENTRIES']; $parent_id = $base['UNIQID']; $sub_dn = preg_replace("/,".normalizePreg($this->dn)."$/","",$attrs['dn']); $sub_dn_array = split("\,",$sub_dn); - + /* Walk through our menu structure array while we have found + the correct position where to add this object. + */ + $found = true; for($i = (count($sub_dn_array)-1) ; $i >= 0 ; $i--){ $name = preg_replace("/^[^=]*+=/","",$sub_dn_array[$i]); + + /* We haven't found the end node where this object has to be added + */ if($i > 0){ + $found =FALSE; foreach($cur as $key => $entry){ if($entry['NAME'] == $name){ $cur = &$cur[$key]['ENTRIES']; $parent_id = $entry['UNIQID']; + $found =true; + break; } } }else{ + + if(!$found){ + break; + } + /* Get application priority. + And ensure that each priority exists once. + */ $priority = 1; if(isset($attrs['gosaApplicationPriority'])){ $priority= $attrs['gosaApplicationPriority'][0]; @@ -193,7 +292,15 @@ class appgroup extends plugin $priority ++; } + /* Create the data object that should be added + * Folder + * Entry + * Release + */ $data = array(); + + /* Add a menu folder + */ if(in_array("gotoSubmenuEntry",$attrs['objectClass'])){ $type = "FOLDER"; @@ -202,18 +309,29 @@ class appgroup extends plugin $data['ICON'] = $ldap->get_attribute($attrs['dn'],"gosaApplicationIcon"); } + /* Add a menu entry + */ }elseif(in_array("gotoMenuEntry",$attrs['objectClass'])){ + $type = "ENTRY"; $data['INFO'] = ""; $data['PARAMETER'] = array(); if(isset($attrs['gosaApplicationParameter'])){ for($p = 0 ; $p < $attrs['gosaApplicationParameter']['count'] ; $p ++){ - $tmp = split(":",$attrs['gosaApplicationParameter'][$p]); - $data['PARAMETER'][$tmp[0]] = $tmp[1]; + if(preg_match("/:/",$attrs['gosaApplicationParameter'][$p])){ + $tmp = split(":",$attrs['gosaApplicationParameter'][$p]); + $data['PARAMETER'][$tmp[0]] = $tmp[1]; + }elseif($attrs['gosaApplicationParameter'][$p] == "*separator*"){ + $type = "SEPERATOR"; + $data['PARAMETER'] = array(); + break; + } } } - }elseif(in_array("FAIbranch",$attrs['objectClass'])){ + /* Add a release + */ + }elseif(in_array("FAIbranch",$attrs['objectClass'])){ $type = "RELEASE"; if(isset($attrs['FAIstate'][0])){ $data['FAIstate'] = $attrs['FAIstate'][0]; @@ -222,6 +340,9 @@ class appgroup extends plugin } } + /* Create object and append it to the current structure pointer + */ + $data['LDAP_ATTRS'] = $attrs; $data['DN'] = $attrs['dn']; $data['NAME'] = $name; $data['TYPE'] = $type; @@ -243,20 +364,19 @@ class appgroup extends plugin /* Call parent execute */ plugin::execute(); + if(isset($_GET['r'])) $this->__construct($this->config,$this->dn); + if (isset($_POST['modify_state'])){ $this->is_account = !$this->is_account; } /* Do we represent a valid account? */ if (!$this->is_account){ - $display= $this->show_enable_header(_("Add application extension"), - _("Application extension disabled. You can enable it by clicking below.")); + $display= $this->show_disable_header(msgPool::addFeaturesButton(_("Menu")), msgPool::featuresDisabled(_("Menu"))); return ($display); } - $display = $this->show_enable_header(_("Remove application extension"), - _("Application extension enabled. You can disable it by clicking below.")); - + $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Menu")), msgPool::featuresEnabled(_("Menu"))); if(isset($_GET['send'])){ $id = $_GET['send']; @@ -327,7 +447,7 @@ class appgroup extends plugin /* Append departments for current base */ foreach($departments as $key => $app){ $div->AddEntry(array( - array("string"=>""._("department")." ".sprintf($linkopen, + array("string"=>""._("department")." ".sprintf($linkopen, base64_encode($key),$app), "attach"=>"style='border:0px;'") )); @@ -355,10 +475,18 @@ class appgroup extends plugin )); } - + /* Assign copy / paste values + */ + if(!empty($this->copied_release)){ + $smarty->assign("copied", TRUE); + $smarty->assign("copy_source", $this->copied_release); + }else{ + $smarty->assign("copied", FALSE); + } $smarty->assign("enableReleaseManagement",$this->enableReleaseManagement); $smarty->assign("FAIrelease",$this->FAIrelease); $smarty->assign("app_list",$div->DrawList()); + $smarty->assign("i",0); $smarty->assign("releases",$this->Releases); $smarty->assign("folders" , $this->_get_folder_names()); $entries = $this->_get_entries_for_release($this->FAIrelease); @@ -374,10 +502,21 @@ class appgroup extends plugin function _get_folder_names() { $data = $this->_get_entries_for_release($this->FAIrelease); + $all = $this->_get_all_entries(); $ret = array("BASE" => "."); foreach($data as $entry){ + if($entry['TYPE'] == "FOLDER"){ - $ret[$entry['UNIQID']] = $entry['NAME']; + $str = $entry['NAME']; + $parent = $entry['PARENT']; + $i = 10; + while(isset($all[$parent]) && $i){ + $i --; + $parent_o = $all[$parent]; + $str = $parent_o['NAME']."/".$str; + $parent = $all[$parent_o['UNIQID']]['PARENT']; + } + $ret[$entry['UNIQID']] = $str; } } return($ret); @@ -408,14 +547,15 @@ class appgroup extends plugin $all = $this->_get_all_entries(); $key = $this->_get_release_key($release); if(isset($all[$key]) && count($all[$key]['ENTRIES'])){ - $res = $this->_get_all_entries(TRUE,TRUE,&$all[$key]['ENTRIES']); + $res = $this->_get_all_entries(TRUE,TRUE,$all[$key]['ENTRIES']); return($res); } return(array()); } - /*! \brief Save the currently edited entry */ + /*! \brief Save the currently edited entry + */ function _save_entry_edit() { $all = $this->_get_all_entries(); @@ -436,6 +576,7 @@ class appgroup extends plugin /*! \brief prepare the entry with the given ID, to be edited. + Read application Parameter from ldap. */ function _edit_entry_edit($id) { @@ -480,6 +621,8 @@ class appgroup extends plugin } + /*! \brief Removes the menu structure from ldap + */ function remove_from_parent() { $ldap = $this->config->get_ldap_link(); @@ -491,9 +634,9 @@ class appgroup extends plugin } foreach($a_remove as $remove){ $ldap->rmdir_recursive($remove); - show_ldap_error($ldap->get_error(), - sprintf(_("Removing of group/application account with dn '%s' failed, could not remove '%s'."), - $this->dn,$remove)); + if (!$ldap->success()){ + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class())); + } } $this->_load_menu_structure(); } @@ -501,6 +644,8 @@ class appgroup extends plugin function check() { + $message = plugin::check(); + return($message); } @@ -543,6 +688,10 @@ class appgroup extends plugin + /*! \brief Moves a given object ($id) in a specified direction ($dir). + @param String The object ID of the object we want to move + @dir String Move "up" or "down" + */ function _move_entry($id,$dir) { $all = $this->_get_all_entries(); @@ -565,7 +714,6 @@ class appgroup extends plugin $o_to = $all[$to]; } - /* Target is ENTRY && same BASE, just switch */ if($o_to['PARENT'] == $o_from['PARENT'] ){ $parent = $all[$o_to['PARENT']]; @@ -587,7 +735,10 @@ class appgroup extends plugin } - + + /*! \brief Returns the railing object ID of the given object. + @return String The id of the trailing object. + */ function _get_last($id) { $all_l = array_reverse($this->_get_entries_for_release($this->FAIrelease)); @@ -612,7 +763,10 @@ class appgroup extends plugin return($all_l[$i]['UNIQID']); } - + + /*! \brief Returns the following object ID of the given object. + @return String The id of the following object. + */ function _get_next($id,$parent = 0) { $all_l = $this->_get_entries_for_release($this->FAIrelease); @@ -648,6 +802,26 @@ class appgroup extends plugin function save_object() { foreach($_POST as $name => $value){ + + if(preg_match("/^menu_copy_/",$name)){ + $this->copied_release = $this->FAIrelease; + break; + } + if(preg_match("/^menu_paste_/",$name)){ + $source_rel = $this->_get_release_key($this->copied_release); + $current_rel = $this->_get_release_key($this->FAIrelease); + + $all = $this->_get_all_entries(); + $menu = $all[$source_rel]['ENTRIES']; + + foreach($menu as $entry){ + if(in_array($entry['TYPE'],array("FOLDER","ENTRY","SEPERATOR"))){ + $this->_add_entry($current_rel,$entry,-1); + } + } + break; + } + if(preg_match("/del_/",$name)){ $id = preg_replace("/^del_/","",$name); $id = preg_replace("/_(x|y)$/","",$id); @@ -693,6 +867,13 @@ class appgroup extends plugin } } } + + /* Add seperator */ + if(isset($_POST['add_seperator']) && isset($_POST['menu_folder'])){ + $folder = $_POST['menu_folder']; + $this->_add_seperator($folder); + } + if(isset($_POST['add_menu_to_folder']) && isset($_POST['menu_folder'])){ $folder = $_POST['menu_folder']; $name = $_POST['menu_folder_name']; @@ -778,7 +959,7 @@ class appgroup extends plugin } - /* !\brief Remove the given id from the menu structure. + /* !\brief Remove the given id from the menu structure. @param String ID to of the entry we want to remove. @return Boolean TRUE on success */ @@ -787,15 +968,17 @@ class appgroup extends plugin $all = $this->_get_all_entries(); if(isset($all[$id])){ $all[$id]['STATUS'] = "REMOVED"; + $all[$id]['ENTRIES'] = array(); return(TRUE); } return(FALSE); } - /* !\brief Remove the given id from the menu structure. - @param String ID to of the entry we want to remove. - @return Boolean TRUE on success + /* !\brief Adds an object to a given folder. + @param String The folder where we should add the entry + @param Array The entry we want to add. + @param Array The position in the destination entry array. */ function _add_entry($folder_id,$entry,$pos = 0) { @@ -806,16 +989,30 @@ class appgroup extends plugin return; } + /* Check if the folder exists + */ if(isset($all[$folder_id])){ + /* Check if the entry we want to add, + contains su objects. + */ + if(!isset($entry['ENTRIES'])){ + $entries = array(); + }else{ + $entries = $entry['ENTRIES']; + } $folder = &$all[$folder_id]; - $entries = $entry['ENTRIES']; + /* Prepare the entry to be added. + */ $entry['UNIQID'] = uniqid(); $entry['PARENT'] = $folder_id; $entry['ENTRIES']= array(); $entry['STATUS'] = "ADDED"; - + + /* Append the ebtry to the given folder + and to the given position \$pos + */ $cnt = 0; $new = array(); $added =FALSE; @@ -833,8 +1030,10 @@ class appgroup extends plugin if(!$added){ $new[] = $entry; } - - $all[$folder_id]['ENTRIES'] = $new; + $all[$folder_id]['ENTRIES'] = &$new; + + /* Add sub entries too. + */ foreach($entries as $sub){ $this->_add_entry($entry['UNIQID'],$sub,-1); } @@ -873,18 +1072,45 @@ class appgroup extends plugin } - /*! \brief Return all entries linear. + /*! \brief Add the application identified by $app_id to folder $folder_id + @param String folder_id The UNIQID of the folder where we want to add the new folder. + @param Integer app_id The ID of the application which should be added. + */ + function _add_seperator($folder_id) + { + $all = $this->_get_all_entries(); + if($folder_id == "BASE"){ + $folder_id = $this->_get_release_key($this->FAIrelease); + } + + if(isset($all[$folder_id])){ + $new = array(); + $new['TYPE'] = "SEPERATOR"; + $new['NAME'] = "SEPERATOR"; + $new['UNIQID']= uniqid(); + $new['PARENT']= $folder_id; + $new['PARAMETER']= array(); + $new['STATUS']= "ADDED"; + $all[$folder_id]['ENTRIES'][] = $new; + } + } + + + /*! \brief Return all entries linear. ($this->a_Structure is a multidimensional array) @param Boolean $add_tags If TRUE, OPEN/CLOSE Tags will be appended. + Used in the smarty template to display logical sperations. @param &Array Start here, Pointer to an array. */ - function _get_all_entries($add_tags = FALSE, $skip_release = FALSE, $cur = NULL) + function _get_all_entries($add_tags = FALSE, $skip_release = FALSE, &$cur = NULL) { $ret = array(); if($cur == NULL){ $cur = &$this->a_Structure; } - foreach($cur as $key => $entry){ + /* Walk through all entries and append them to our return array + */ + foreach($cur as $key => $entry){ if($skip_release && $entry['TYPE'] == "RELEASE"){ continue; } @@ -903,13 +1129,19 @@ class appgroup extends plugin $entry['INFO'] = ""._("Not available in release.").""; } } - $tmp = $entry; + + /* Recursive resolution of the subentries + There are two methods. + - Just add sub entries + - Add sub entries and additionaly add OPEN / CLOSE tags to be able + to display logical seperators in the smarty template. + */ if(!$add_tags){ $ret[$tmp['UNIQID']] = &$cur[$key]; if(isset($entry['ENTRIES']) && count($entry['ENTRIES'])){ - $ret = array_merge($ret,$this->_get_all_entries($add_tags,$skip_release,&$cur[$key]['ENTRIES'])); + $ret = array_merge($ret,$this->_get_all_entries($add_tags,$skip_release,$cur[$key]['ENTRIES'])); } }else{ @@ -929,7 +1161,7 @@ class appgroup extends plugin if($add){ $ret[] = array("TYPE" => "OPEN", "PARENT" => $entry['PARENT']); - $ret = array_merge($ret,$this->_get_all_entries($add_tags,$skip_release,&$cur[$key]['ENTRIES'])); + $ret = array_merge($ret,$this->_get_all_entries($add_tags,$skip_release,$cur[$key]['ENTRIES'])); $ret[] = array("TYPE" => "CLOSE" , "PARENT" => $entry['PARENT']); } } @@ -940,6 +1172,9 @@ class appgroup extends plugin } + /*! \brief Save this plugin data to ldap. + Save the current menu structure to ldap. + */ function save() { $ldap = $this->config->get_ldap_link(); @@ -947,13 +1182,23 @@ class appgroup extends plugin $prio = 0; $Actions = array("Remove" => array(),"Edit" => array() , "Add" => array()); + + /* Walk through the menu structure and build up the ldap data object, + the entry dn and the entry priority. + */ + $sep_id = 0; foreach($all as $entry){ $prio ++; $cur = $entry; $dn = ""; + /* Build entry dn + */ do{ - if($cur['TYPE'] == "ENTRY"){ + if($cur['TYPE'] == "SEPERATOR"){ + $sep_id ++; + $dn.= "cn=seperator_".$sep_id.","; + }elseif($cur['TYPE'] == "ENTRY"){ $dn.= "cn=".$cur['NAME'].","; }elseif($cur['TYPE'] == "FOLDER"){ $dn.= "cn=".$cur['NAME'].","; @@ -969,17 +1214,26 @@ class appgroup extends plugin }while(is_array($cur)); $cur_dn = $dn.$this->dn; - $attrs = array(); + + /* Build entry data object. + */ switch($entry['TYPE']){ + case "SEPERATOR" : + { + $attrs['objectClass'] = array("gotoMenuEntry"); + $attrs['cn'] = "seperator_".$sep_id; + $attrs['gosaApplicationPriority'] = $prio; + $attrs['gosaApplicationParameter'] = "*separator*"; + } + break; case "ENTRY" : { - $attrs['objectClass'] = "gotoMenuEntry"; + $attrs['objectClass'] = array("gotoMenuEntry"); $attrs['cn'] = $entry['NAME']; $attrs['gosaApplicationPriority'] = $prio; $attrs['gosaApplicationParameter'] = array(); - foreach($entry['PARAMETER'] as $name => $value){ $attrs['gosaApplicationParameter'][] = $name.":".$value; } @@ -990,7 +1244,7 @@ class appgroup extends plugin break; case "FOLDER" : { - $attrs['objectClass'] = "gotoSubmenuEntry"; + $attrs['objectClass'] = array("gotoSubmenuEntry"); $attrs['cn'] = $entry['NAME']; $attrs['gosaApplicationPriority'] = $prio; if($entry['STATUS'] != "ADDED"){ @@ -1003,7 +1257,7 @@ class appgroup extends plugin } break; case "RELEASE" : - { + { $attrs['ou'] = $entry['NAME']; $attrs['objectClass'] = array(); $attrs['objectClass'][] = "top"; @@ -1015,12 +1269,29 @@ class appgroup extends plugin } break; } + + /* Append missing ObjectClasses, ... Tagging + */ + if(isset($entry['LDAP_ATTRS'])){ + for($i = 0 ; $i < $entry['LDAP_ATTRS']['objectClass']['count']; $i ++){ + $oc = $entry['LDAP_ATTRS']['objectClass'][$i]; + if(!in_array($oc,$attrs['objectClass'])){ + $attrs['objectClass'][] = $oc; + } + } + } + /* Create an array containing all operations sorted by type. (add,remove...) + */ if($entry['STATUS'] == "LOADED"){ continue; } if($entry['STATUS'] == "REMOVED"){ - $Actions['Remove'][$cur_dn] = $cur_dn; + if(isset($entry['DN'])){ + $Actions['Remove'][$entry['DN']] = $entry['DN']; + }else{ + $Actions['Remove'][$cur_dn] = $cur_dn; + } } if($entry['STATUS'] == "EDITED"){ $Actions['Edit'][$cur_dn] = $attrs; @@ -1030,6 +1301,8 @@ class appgroup extends plugin } } + /* First remove entries + */ $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); foreach($Actions['Remove'] as $dn){ @@ -1037,30 +1310,45 @@ class appgroup extends plugin $ldap->cat($dn); if($ldap->count()){ $ldap->rmdir_recursive($dn); - show_ldap_error($ldap->get_error(), _("Could not save group application settings.")); + if (!$ldap->success()){ + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_DEL, get_class())); + } } } + + /* Add new entries + */ foreach($Actions['Add'] as $dn => $data){ $ldap->cd($dn); $ldap->cat($dn); if(!$ldap->count()){ $ldap->add($data); - show_ldap_error($ldap->get_error(), _("Could not save group application settings.")); + if (!$ldap->success()){ + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_DEL, get_class())); + } } } + + /* Modify entries + */ foreach($Actions['Edit'] as $dn => $data){ $ldap->cd($dn); $ldap->cat($dn); if($ldap->count()){ $ldap->modify($data); - show_ldap_error($ldap->get_error(), _("Could not save group application settings.")); + if (!$ldap->success()){ + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_DEL, get_class())); + } } } + $this->_load_menu_structure(); } - /* Return plugin informations for acl handling */ + /*! \brief Return plugin informations for acl handling + @return Array containing all plugin ACL informations + */ static function plInfo() { return (array( @@ -1079,11 +1367,29 @@ class appgroup extends plugin } + /* \brief Prepare this plugin to be copied. + Adapt all required attributes from the source object. + In this case, update the menu structure too, mark all elements + as newly added, so they will be saved in save(); + */ function PrepareForCopyPaste($source) { + plugin::PrepareForCopyPaste($source); + + $tmp = new appgroup($this->config,$source['dn']); + $this->is_account = TRUE; + $this->a_Structure = $tmp->a_Structure; + $all = $this->_get_all_entries(); + foreach($all as &$entry){ + if(isset($entry['STATUS'])){ + $entry['STATUS'] = "ADDED"; + } + } } + /*! \brief Save HTML posts in multiple edit mode + */ function multiple_save_object() { if(isset($_POST['group_apps_multi'])){ @@ -1100,6 +1406,11 @@ class appgroup extends plugin } + /*! \brief Return values used in multiple edit mode. + Some values can be modified for multiple + groups at the same time. + @return Array All values that support multiple edit. + */ function get_multi_edit_values() { $ret = plugin::get_multi_edit_values();