diff --git a/gosa-plugins/goto/admin/groups/apps/class_groupApplication.inc b/gosa-plugins/goto/admin/groups/apps/class_groupApplication.inc
index 33231aacdd12d92e1137df72ea2db8c7fd3e5acf..00f87bb5287539e360fb5c4c2979eb89c31834fb 100644 (file)
<?php
class appgroup extends plugin
{
- /* CLI vars */
- var $cli_summary= "Manage application groups";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
-
var $config;
var $curbase;
var $app_parameter = array();
var $edit_entry = array();
var $enableReleaseManagement = FALSE;
-
+
+ var $copied_release = "";
+
public function __construct(&$config, $dn= NULL, $parent= NULL)
{
$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;
}
- /*! \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"));
$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"));
}
}
+ /* 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));
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){
}
}
- $cnt = 0;
$ret[$name] = array("name" => $name,
"found" => $found,
"FAIstate" => $FAIstate,
}
- /*! \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;
$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];
$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";
$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];
}
}
+ /* Create object and append it to the current structure pointer
+ */
+ $data['LDAP_ATTRS'] = $attrs;
$data['DN'] = $attrs['dn'];
$data['NAME'] = $name;
$data['TYPE'] = $type;
/* 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'];
/* Append departments for current base */
foreach($departments as $key => $app){
$div->AddEntry(array(
- array("string"=>"<img class='center' src='images/folder.png' alt='"._("department")."'> ".sprintf($linkopen,
+ array("string"=>"<img class='center' src='images/lists/folder.png' alt='"._("department")."'> ".sprintf($linkopen,
base64_encode($key),$app),
"attach"=>"style='border:0px;'")
));
));
}
-
+ /* 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);
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);
$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();
/*! \brief prepare the entry with the given ID, to be edited.
+ Read application Parameter from ldap.
*/
function _edit_entry_edit($id)
{
}
+ /*! \brief Removes the menu structure from ldap
+ */
function remove_from_parent()
{
$ldap = $this->config->get_ldap_link();
}
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();
}
function check()
{
+ $message = plugin::check();
+ return($message);
}
+ /*! \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();
$o_to = $all[$to];
}
-
/* Target is ENTRY && same BASE, just switch */
if($o_to['PARENT'] == $o_from['PARENT'] ){
$parent = $all[$o_to['PARENT']];
}
-
+
+ /*! \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));
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);
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);
}
}
}
+
+ /* 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'];
}
- /* !\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
*/
$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)
{
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;
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);
}
}
- /*! \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;
}
$entry['INFO'] = "<font color='red'>"._("Not available in release.")."</font>";
}
}
-
$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{
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']);
}
}
}
+ /*! \brief Save this plugin data to ldap.
+ Save the current menu structure to ldap.
+ */
function save()
{
$ldap = $this->config->get_ldap_link();
$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'].",";
}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;
}
break;
case "FOLDER" :
{
- $attrs['objectClass'] = "gotoSubmenuEntry";
+ $attrs['objectClass'] = array("gotoSubmenuEntry");
$attrs['cn'] = $entry['NAME'];
$attrs['gosaApplicationPriority'] = $prio;
if($entry['STATUS'] != "ADDED"){
}
break;
case "RELEASE" :
- {
+ {
$attrs['ou'] = $entry['NAME'];
$attrs['objectClass'] = array();
$attrs['objectClass'][] = "top";
}
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;
}
}
+ /* First remove entries
+ */
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
foreach($Actions['Remove'] as $dn){
$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(
}
+ /* \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'])){
}
+ /*! \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();