diff --git a/plugins/admin/departments/class_departmentManagement.inc b/plugins/admin/departments/class_departmentManagement.inc
index dbfcab0b4ad7a6797c2b7799ede3d4ab4b4a02e4..815f40da2b874a87de132c048275da4bac52637c 100644 (file)
var $attributes= array();
var $objectclasses= array();
- /* Tagging || Moving in progress */
- var $AfterSaveProcedure = false;
+ /* Vars to handle operations after saving the department
+ Recursive move && tagging */
+ var $ObjectInSaveMode = false; // Is true, if current object wasn't saved right now
+ var $ObjectTaggingRequested = false; // Object must be tagged, an iframe will be shown.
+ var $RecursiveRemoveRequested = false; // Is true, if this object must be moved, an iframe will be displayed in this case
function departmentManagement ($config, $ui)
{
* The entry which will be edited is defined in $s_entry
*/
if (( $s_action=="edit") && (!isset($this->deptabs->config))){
- $s_entry = convert_department_dn(base64_decode($s_entry));
$this->dn= $this->config->departments[trim($s_entry)];
if (($user= get_lock($this->dn)) != ""){
* The entry which will be deleted is defined in $s_entry
*/
if ($s_action =="del"){
- $s_entry = convert_department_dn(base64_decode($s_entry));
$this->dn= $this->config->departments[trim($s_entry)];
/* Check locking */
}
}
+
+ /***************
+ Edit department finished
+ ***************/
+
+ if ((isset($_POST['edit_finish'])) && (isset($this->deptabs->config))){
+
+ /* Check tabs, will feed message array */
+ $message= $this->deptabs->check();
+
+ /* Save, or display error message? */
+ if (count($message) == 0){
+
+ $this->deptabs->save(true);
+ $this->deptabs->by_object['department']->save();
+
+ /* This object must be tagged, so set ObjectTaggingRequested to true */
+ if($this->deptabs->by_object['department']->must_be_tagged()){
+ $this->ObjectTaggingRequested = true;
+ }
+
+ /* Get recursive move is required, set RecursiveRemoveRequested to true */
+ if($this->deptabs->by_object['department']->am_i_moved()){
+ $this->RecursiveRemoveRequested = true;
+ }
+
+ /* This var indicated that there is an object which isn't saved right now. */
+ $this->ObjectInSaveMode = true;
+
+ } else {
+ /* Ok. There seem to be errors regarding to the tab data,
+ show message and continue as usual. */
+ show_errors($message);
+ }
+ }
+
+
/***************
Handle Tagging (Return output for an iframe)
***************/
- /* This department must be tagged (Is called from iframe, generates output) */
+ /* This department must be tagged (Is called from iframe, generates output)*/
if(isset($_GET['TagDepartment'])){
$this->deptabs->by_object['department']->tag_objects();
- $this->deptabs->by_object['department']->must_be_tagged = false;
exit();
}
/* initiate recursive remove (Is called from iframe, generates output)*/
if(isset($_GET['PerformRecMove'])){
- $this->deptabs->by_object['department']->recursive_move();
- $this->deptabs->by_object['department']->MustBeMoved = false;
+ $this->deptabs->by_object['department']->recursive_move("","",true);
exit();
}
-
/***************
- Edit department finished
+ Return iframes, which call tagging / recusrsive move
***************/
- if (($this->AfterSaveProcedure || isset($_POST['edit_finish'])) && (isset($this->deptabs->config))){
+ /* While one of these vars below isset, we must return an iframe,
+ to perform requested operation */
+ if($this->ObjectTaggingRequested){
+ $this->ObjectTaggingRequested = false;
+ return($this->deptabs->by_object['department']->ShowTagFrame());
+ }
+ if($this->RecursiveRemoveRequested){
+ $this->RecursiveRemoveRequested = false;
+ return($this->deptabs->by_object['department']->ShowMoveFrame());
+ }
- /* Check tabs, will feed message array */
- $message= $this->deptabs->check();
- /* Save, or display error message? */
- if (count($message) == 0){
+ /***************
+ In case of tagging/moving the object wasn't deleted, do it know
+ ***************/
- /* Save current changes */
- if(!$this->AfterSaveProcedure){
- $this->deptabs->save(true);
- }
-
- /* Check if we have to tag this department */
- if($this->deptabs->by_object['department']->must_be_tagged){
- $this->AfterSaveProcedure = true;
- $this->deptabs->by_object['department']->must_be_tagged = false;
- return($this->deptabs->by_object['department']->ShowTagFrame());
- }
-
- /* Saving and tagging, is done now, lets move the dep if required */
- if($this->deptabs->by_object['department']->MustBeMoved){
- $this->AfterSaveProcedure = true;
- $this->deptabs->by_object['department']->MustBeMoved = false;
- return($this->deptabs->by_object['department']->ShowMoveFrame());
- }
-
- if ($this->dn != "new"){
- del_lock ($this->dn);
- }
- gosa_log ("Department object'".$this->dn."' has been saved");
- unset ($this->deptabs);
- $this->deptabs= NULL;
- $this->AfterSaveProcedure = false;
- unset ($_SESSION['objectinfo']);
- } else {
- /* Ok. There seem to be errors regarding to the tab data,
- show message and continue as usual. */
- show_errors($message);
+ /* If there is an unsaved object and all operations are done
+ remove locks & save object tab & unset current object */
+ if($this->ObjectInSaveMode && (!$this->RecursiveRemoveRequested) && (!$this->ObjectTaggingRequested)){
+ $this->deptabs->save();
+ $this->ObjectInSaveMode = false;
+ if ($this->dn != "new"){
+ del_lock ($this->dn);
}
+ gosa_log ("Department object'".$this->dn."' has been saved");
+ unset ($this->deptabs);
+ $this->deptabs= NULL;
+ unset ($_SESSION['objectinfo']);
}
$display= $this->deptabs->execute();
if (!$this->deptabs->by_object[$this->deptabs->current]->dialog){
$display.= "<p style=\"text-align:right\">\n";
- $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
+ $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
$display.= " \n";
$display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
$display.= "</p>";
}
return ($display);
}else{
-
- /* Check if there is a snapshot dialog open */
- if($str = $this->showSnapshotDialog($this->DivListDepartment->selectedBase,$this->DivListDepartment->selectedBase)){
- return($str);
- }
-
/* Display dialog with group list */
$this->DivListDepartment->parent = $this;
$this->DivListDepartment->execute();
}
$this->departments= array();
- $tmp = array();
- foreach ($res as $key => $value){
- #$tmp[get_sub_department(convert_department_dn($value['dn']))] = $key;
- $tmp[$key] = get_sub_department(convert_department_dn($value['dn']));
+
+ /* Add current base to the list of available departments, but only if its naming attribute is 'ou' */
+ if(preg_match("/^ou=/",$base)){
+ $this->departments [ convert_department_dn($base) ] = ".";
}
- natcasesort($tmp);
- foreach($tmp as $key => $q){
- $value = $res [$key];
+
+ foreach ($res as $key => $value){
+
/* Don't display base as entry on subsearch */
if(($value['dn'] == $base) && ($this->DivListDepartment->SubSearch)){
continue;
}
- $this->departments[base64_encode($value['dn'])]= $value;
+ $cdn= convert_department_dn($value['dn']);
+
+ /* Append to dep list */
+ if(isset($value["description"][0])){
+ $this->departments[$cdn]= get_sub_department($cdn)." - [".$value["description"][0]."]";
+ }else{
+ $this->departments[$cdn]= get_sub_department($cdn);//$value["description"][0];
+ }
}
+ natcasesort ($this->departments);
+ reset ($this->departments);
}
function remove_from_parent()
$this->config->make_idepartments();
$this->DivListDepartment->save_object();
}
+
+ function plInfo()
+ {
+ return (array("plDescription" => _("Departments"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array("objectClass" => "gosaDepartment", "description" => _("Departments")),
+ "description" => _("Description"),
+ "c" => _("Country"),
+ "l" => _("Location"),
+ "telephoneNumber" => _("Telephone"),
+ "ou" => _("Department name") ));
+ }
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: