Code

Updated application handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 15 Apr 2008 10:36:06 +0000 (10:36 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 15 Apr 2008 10:36:06 +0000 (10:36 +0000)
-Removed Base selector

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10458 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/applications/class_applicationManagement.inc
gosa-plugins/goto/admin/applications/class_divListApplication.inc
gosa-plugins/goto/admin/applications/release_select.tpl
gosa-plugins/goto/admin/applications/tabs_application.inc

index d144f45c3d9a9e179bd59a8f970e91a92e6b287c..83c870da17c6137e74b62cee7b90e61a0ccd0623 100644 (file)
@@ -33,6 +33,9 @@ class applicationManagement extends plugin
   var $enableReleaseManagement  = false;
   var $start_pasting_copied_objects = FALSE;
 
+  var $app_base     ="";
+  var $app_release  ="";
+
   function IsReleaseManagementActivated()
   {
     /* Check if we should enable the release selection */
@@ -40,9 +43,9 @@ class applicationManagement extends plugin
     if(!empty($tmp)){
       return(true);
     }
-    return(false);
   }
 
+
   function applicationManagement (&$config, &$ui)
   {
     /* Save configuration for internal use */
@@ -64,20 +67,40 @@ class applicationManagement extends plugin
       /* Hide SubSearch checkbox */
       $this->DivListApplication->DisableCheckBox("SubSearch");
     }
+
+    /* Set default release */
+    if(!$this->IsReleaseManagementActivated()){
+      $this->app_base = get_ou("applicationou").$this->config->current['BASE'];
+      if(!session::is_set("app_filter")){
+        session::set("app_filter",array("app_base" => $this->app_base));
+      }
+      $app_filter     = session::get("app_filter");
+      $this->app_base = $app_filter['app_base'];
+    }else{
+      $this->app_base = get_ou("applicationou").$this->config->current['BASE'];
+      if(!session::is_set("app_filter")){
+        session::set("app_filter",array("app_base" => $this->app_base,"app_release" => $this->app_base));
+      }
+      $app_filter         = session::get("app_filter");
+      $this->app_base     = $app_filter['app_base'];
+      $this->app_release  = $app_filter['app_release'];
+    }
+    $this->app_base   = "ou=apps,ou=Direktorium,o=Landeshauptstadt München,c=de";
+    $this->app_release= $this->app_base;
   }
 
-  function getReleases($base)
-  {
-    $ldap                   = $this->config->get_ldap_link();
-    $dn                     = get_ou('applicationou').$base;
-    $ret                    = array();
-    $ret [get_ou('applicationou').$base] = "/";
 
-    $ldap->cd($dn);
-    $ldap->search("objectClass=organizationalUnit",array("ou"));
+  function getReleases()
+  {
+    $ldap = $this->config->get_ldap_link();
+    $ret  = array();
+    $base = $this->app_base; 
 
+    $ret[$this->app_base] = "/";
+    $ldap->cd($base);
+    $ldap->search("(&(objectClass=organizationalUnit)(objectClass=FAIbranch))",array("ou"));
     while($attrs = $ldap->fetch()){
-      $str = str_replace($dn,"",$attrs['dn']);
+      $str = str_replace($base,"",$attrs['dn']);
       $tmp = array_reverse( split("ou=",$str));
       $str = "";
       foreach($tmp as $val){
@@ -195,7 +218,8 @@ class applicationManagement extends plugin
 
       /* Create new usertab object */
       $this->apptabs= new apptabs($this->config,$this->config->data['TABS']['APPSTABS'], $this->dn,"application");
-      $this->apptabs->set_acl_base($this->DivListApplication->selectedBase);
+      $this->apptabs->parent = &$this;
+      $this->apptabs->set_acl_base($this->app_base);
     }
 
 
@@ -230,7 +254,6 @@ class applicationManagement extends plugin
       if (count($message) == 0){
 
         /* Save data data to ldap */
-        $this->apptabs->set_release($this->DivListApplication->selectedRelease);
         $this->apptabs->save();
 
         if (!isset($_POST['edit_apply'])){
@@ -273,6 +296,7 @@ class applicationManagement extends plugin
 
       /* Register apptabs to trigger edit dialog */
       $this->apptabs= new apptabs($this->config,$this->config->data['TABS']['APPSTABS'], $this->dn,"application");
+      $this->apptabs->parent = &$this;
       $this->apptabs->set_acl_base($this->dn);
       session::set('objectinfo',$this->dn);
     }
@@ -326,6 +350,7 @@ class applicationManagement extends plugin
 
           /* Delete request is permitted, perform LDAP action */
           $this->apptabs= new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $dn,"application");
+          $this->apptabs->parent = &$this;
           $this->apptabs->set_acl_base($dn);
           $this->apptabs->delete ();
           unset ($this->apptabs);
@@ -409,6 +434,7 @@ class applicationManagement extends plugin
 
         /* Delete request is permitted, perform LDAP action */
         $this->apptabs= new apptabs($this->config, $this->config->data['TABS']['APPSTABS'], $this->dn,"application");
+        $this->apptabs->parent = &$this;
         $this->apptabs->set_acl_base($this->dn);
         $this->apptabs->delete ();
         unset ($this->apptabs);
@@ -462,15 +488,21 @@ class applicationManagement extends plugin
      ****************/
 
     /* Check if there is a snapshot dialog open */
-    $base = $this->DivListApplication->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases($base))){
+    if($this->IsReleaseManagementActivated()){
+      $base = $this->app_release;  
+    }else{
+      $base = $this->app_base;  
+    }
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
       return($str);
     }
 
     /* Display dialog with system list */
     $this->DivListApplication->parent = $this;
     $this->DivListApplication->execute();
-    $this->DivListApplication->AddDepartments($this->DivListApplication->selectedBase,3,1);
+    if(!$this->IsReleaseManagementActivated()){
+      $this->DivListApplication->AddDepartments($this->DivListApplication->selectedBase,3,1);
+    } 
     $this->reload();
     $this->DivListApplication->setEntries($this->applications);
     return($this->DivListApplication->Draw());
@@ -478,11 +510,12 @@ class applicationManagement extends plugin
 
 
   /* Return departments, that will be included within snapshot detection */
-  function get_used_snapshot_bases(){
-    if($this->DivListApplication->selectedRelease == "main"){
-      return(array($this->DivListApplication->selectedBase));
+  function get_used_snapshot_bases()
+  {
+    if($this->IsReleaseManagementActivated()){
+      return(array($this->app_release));  
     }else{
-      return(array($this->DivListApplication->selectedRelease));
+      return(array($this->app_base));  
     }
   }
 
@@ -492,23 +525,16 @@ class applicationManagement extends plugin
     $this->applications= array();
 
     /* Set base for all searches */
-    $base       = $this->DivListApplication->selectedBase;
-    $release    = $this->DivListApplication->selectedRelease;
     $Regex      = $this->DivListApplication->Regex;
     $SubSearch  = $this->DivListApplication->SubSearch; 
     $Flags      =  GL_NONE | GL_SIZELIMIT;
     $Filter     = "(&(cn=".$Regex.")(objectClass=gosaApplication))";
     $tmp        = array();
-    $Releases   = $this->getReleases($base);
 
-    if(!$this->enableReleaseManagement){
-      $use_base = get_ou('applicationou').$base;
+    if(!$this->IsReleaseManagementActivated()){
+      $use_base = $this->app_base;
     }else{
-      if(isset($Releases[$release])){
-        $use_base  = $release;
-      }else{
-        $use_base  = get_ou('applicationou').$base;
-      }
+      $use_base = $this->app_release;
     }
 
     if($SubSearch){
@@ -584,7 +610,8 @@ class applicationManagement extends plugin
 
 
       /* Get dialog */
-      $this->CopyPasteHandler->SetVar("base",$this->DivListApplication->selectedBase);
+      $this->CopyPasteHandler->SetVar("base",$this->app_base);
+      $this->CopyPasteHandler->SetVar("parent",&$this);
       $data = $this->CopyPasteHandler->execute();
 
       /* Return dialog data */
@@ -634,6 +661,16 @@ class applicationManagement extends plugin
     if(is_object($this->CopyPasteHandler)){
       $this->CopyPasteHandler->save_object();
     }
+    
+    if($this->IsReleaseManagementActivated() && isset($_POST['app_release'])){
+      $sel_rel = get_post('app_release');
+      $releases = array_flip($this->getReleases());
+      if(isset($releases[$sel_rel])){
+        $this->app_release = $releases[$sel_rel];
+      }
+    }elseif(!$this->IsReleaseManagementActivated()){
+      $this->app_base = get_ou("applicationou").$this->DivListApplication->selectedBase;
+    }
   }
 
   function check() {}
index 1fc03c02a9104ebe069b08aee9b00fd2a373fbc7..0ffdec859d6c3913b18d4a5261fe98bfb128e60c 100644 (file)
@@ -3,9 +3,6 @@
 class divListApplication extends MultiSelectWindow
 {
   /* Current base */
-  var $selectedBase       = "";
-  var $selectedRelease    = "main";
-  var $AvailableReleases  = array();
   var $departments        = array();
   var $parent               ;
   var $ui                   ;
@@ -15,15 +12,12 @@ class divListApplication extends MultiSelectWindow
 
   /* Subsearch checkbox */
   var $SubSearch;
-
-  var $SaveAdditionalVars = array("selectedRelease");
+  var $selectedBase ="";
 
   function divListApplication (&$config,&$parent)
   {
     MultiSelectWindow::MultiSelectWindow($config,"Application", "application");
-   
-    $this->selectedRelease = get_ou('applicationou').session::get('CurrentMainBase');
+  
     $this->parent       = &$parent;
     $this->ui           = get_userinfo();
 
@@ -64,18 +58,23 @@ class divListApplication extends MultiSelectWindow
     $this->AddRegex   ("Regex",     _("Display users matching"),"*" , true);
   }
 
-  function AddUserBoxToFilter($position){
+
+  function AddUserBoxToFilter($position)
+  {
     $str = "";
     if(($position  == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){
       $smarty = get_smarty();
-      $smarty->assign("selectedRelease",$this->selectedRelease);
+      $releases = $this->parent->getReleases();
+      $smarty->assign("app_release" , $releases[$this->parent->app_release]);
+      $smarty->assign("app_base"    , $releases[$this->parent->app_base]);
       $smarty->assign("branchimage","images/branch.png");
-      $smarty->assign("releases",$this->AvailableReleases);
+      $smarty->assign("app_releases", $releases);
       $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE));
     }
     return($str);
   }
 
+
   function GenHeader()
   {
     /* Prepare departments,
@@ -83,65 +82,69 @@ class divListApplication extends MultiSelectWindow
     */
     $options= "";
 
-    /* Get all departments within this subtree */
-    $base = $this->config->current['BASE'];
+    /* Add default header */
+    $listhead = MultiSelectWindow::get_default_header();
+
+    if(!$this->parent->IsReleaseManagementActivated()){
+      
+      /* Get all departments within this subtree */
+      $base = $this->config->current['BASE'];
 
-    /* Add base */
-    $tmp = array();
-    $tmp[] = array("dn"=>$this->config->current['BASE']);
-    $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
-                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
+      /* Add base */
+      $tmp = array();
+      $tmp[] = array("dn"=>$this->config->current['BASE']);
+      $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
+                      array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
 
-    $deps = array();
-    foreach($tmp as $tm){
-      $deps[$tm['dn']] = $tm['dn'];
-    }
+      $deps = array();
+      foreach($tmp as $tm){
+        $deps[$tm['dn']] = $tm['dn'];
+      }
 
-    /* Load possible departments */
-    $ui= get_userinfo();
-    $tdeps= $ui->get_module_departments("application");
-    $ids = $this->config->idepartments;
-    $first = "";
-    $found = FALSE;
-    foreach($ids as $dep => $name){
-      if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
-
-        /* Keep first base dn in mind, we could need this
-         *  info if no valid base was found
-         */
-        if(empty($first)) {
-          $first = $dep['dn'];
-        }
+      /* Load possible departments */
+      $ui= get_userinfo();
+      $tdeps= $ui->get_module_departments("application");
+      $ids = $this->config->idepartments;
+      $first = "";
+      $found = FALSE;
+      foreach($ids as $dep => $name){
+        if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
+
+          /* Keep first base dn in mind, we could need this
+           *  info if no valid base was found
+           */
+          if(empty($first)) {
+            $first = $dep['dn'];
+          }
 
-        $value = $ids[$dep];
-        if ($this->selectedBase == $dep){
-          $found = TRUE;
-          $options.= "<option selected='selected' value='".$dep."'>$value</option>";
-        } else {
-          $options.= "<option value='".$dep."'>$value</option>";
+          $value = $ids[$dep];
+          if ($this->selectedBase == $dep){
+            $found = TRUE;
+            $options.= "<option selected='selected' value='".$dep."'>$value</option>";
+          } else {
+            $options.= "<option value='".$dep."'>$value</option>";
+          }
         }
       }
-    }
 
-    /* The currently used base is not visible with your acl setup.
-     * Set base to first useable base.
-     */
-    if(!$found){
-      $this->selectedBase = $first;
+      /* The currently used base is not visible with your acl setup.
+       * Set base to first useable base.
+       */
+      if(!$found){
+        $this->selectedBase = $first;
+      }
+
+
+      /* And the rest, a base selection box */
+      $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
+        " <input class='center' type='image' src='images/list_submit.png' align='middle' 
+          title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
     }
 
     /* Get acls */
     $ui       = get_userinfo();
-    $acl      = $ui->get_permissions("cn=dummy,".$this->selectedBase,"application/application");
-    $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"application");
-
-    /* Add default header */
-    $listhead = MultiSelectWindow::get_default_header();
-
-    /* And the rest, a base selection box */
-    $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
-      " <input class='center' type='image' src='images/list_submit.png' align='middle' 
-        title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
+    $acl      = $ui->get_permissions("cn=dummy,".$this->parent->app_base,"application/application");
+    $acl_all  = $ui->has_complete_category_acls($this->parent->app_base,"application");
 
     /* Create Layers menu */
     $s  = ".|"._("Actions")."|\n";
@@ -184,18 +187,18 @@ class divListApplication extends MultiSelectWindow
 
     $this->SetDropDownHeaderMenu($s);
     $this->SetListHeader($listhead);
-
     $this->SetListHeader($listhead);
   }
 
+
   /* so some basic settings */
   function execute()
   {
     $this->ClearElementsList();
     $this->GenHeader();
-    $this->AvailableReleases = $this->parent->getReleases($this->selectedBase);
   }
 
+
   function setEntries($list)
   {
     /********************
@@ -312,9 +315,6 @@ class divListApplication extends MultiSelectWindow
   {
     /* Save automatic created POSTs like regex, checkboxes */
     MultiSelectWindow::save_object(); 
-    $appfilter = session::get('appfilter');
-    $appfilter['release']  = $this->selectedRelease;
-    session::set('appfilter',$appfilter);
   }
 
 }
index d864cebcf5243f4176582740bbc3ebcd0a2f3914..4a8cee26830f2293e1ba6066ba2ae9974a10e61e 100644 (file)
@@ -6,8 +6,8 @@
   <tr>
    <td>
     {t}Current release{/t}&nbsp;
-    <select name="selectedRelease" onChange="document.mainform.submit();">
-     {html_options options=$releases selected=$selectedRelease}
+    <select name="app_release" onChange="document.mainform.submit();">
+        {html_options output=$app_releases values=$app_releases selected=$app_release}
     </select>
    </td>
   </tr>
index 5b6e82989e9129b09615e9bd925f06f9a4bd92b8..9636c44db90d962227ea0a6d56f69d6410b6872d 100644 (file)
@@ -2,7 +2,7 @@
 
 class apptabs extends tabs
 {
-  var $Release= "";
+  var $parent = FALSE;
 
   function apptabs($config, $data, $dn,$category)
   {
@@ -12,28 +12,14 @@ class apptabs extends tabs
     $this->addSpecialTabs();
   }
 
-  function set_release($newRelease)
-  {
-    $this->Release= preg_replace('/,'.get_ou('applicationou').'.*$/', '', $newRelease);
-    if ($this->Release != ""){
-      $this->Release= ",".$this->Release;
-    }
-  }
-
   function save($ignore_account= FALSE)
   {
     $baseobject= $this->by_object['application'];
 
     /* Check for new 'dn', in order to propagate the
        'dn' to all plugins */
-    $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
-    $appfilter = session::get('appfilter');
-    if((!empty($tmp)) && (isset($appfilter['release']))){
-      if(!$baseobject->isReleaseApplikation){
-        $new_dn= "cn=".$baseobject->cn.",".get_ou('applicationou').$baseobject->base;
-      }else{
-        $new_dn ="cn=".$baseobject->cn.",".$appfilter['release'];
-      }
+    if($this->parent->IsReleaseManagementActivated()){
+      $new_dn= "cn=".$baseobject->cn.",".$this->parent->app_release;
     }else{
       $new_dn= "cn=".$baseobject->cn.",".get_ou('applicationou').$baseobject->base;
     }