Code

Removed usePrototype flag, its activated always now.
[gosa.git] / gosa-plugins / goto / admin / applications / class_applicationManagement.inc
index db6d93ccd336f8e4e4a81b6d3b18c49c985d226d..e1bafafa080de3cb5b29fb43aa922e0a7a635e23 100644 (file)
 class applicationManagement extends management
 {
   var $plHeadline     = "Applications";
-  var $plDescription  = "Application administration";
-  var $plIcon  = "plugins/applications/images/plugin.png";
+  var $plDescription  = "Define and parametrize desktop applications for using them in desktop profiles";
+  var $plIcon  = "plugins/goto/images/application.png";
 
   var $app_release = ""; // The currently selected release while in release management mode!
+  var $app_base = ""; // The currently selected release while in release management mode!
 
   // Tab definition 
   protected $tabClass = "apptabs";
@@ -35,24 +36,38 @@ class applicationManagement extends management
   protected $aclPlugin   = "application";
   protected $objectName   = "application";
 
+  var $releaseSelector = NULL;
+
   function __construct($config,$ui)
   {
     $this->config = $config;
     $this->ui = $ui;
-   
-    $this->storagePoints = array(get_ou("applicationRDN"));
-#   // Build filter
-#   if (session::global_is_set(get_class($this)."_filter")){
-#     $filter= session::global_get(get_class($this)."_filter");
-#   } else {
-     $filter = new filter(get_template_path("application-filter-release.xml", true));
-#     $filter->setObjectStorage($this->storagePoints);
-#   }
+    $this->app_base    = get_ou('applicationRDN').$this->config->current['BASE'];
+    $this->app_release = get_ou('applicationRDN').$this->config->current['BASE'];
+
+    if($this->IsReleaseManagementActivated()){
+      $filter_xml = "application-filter-release.xml";
+      $list_xml = "application-list-release.xml";
+      $this->storagePoints= array("");
+      $releases = faiManagement::getReleaseStates($this->config,$this->app_base);
+      $this->releaseSelector = new releaseSelector($releases, $this->app_release, $this->app_release);
+    }else{
+      $filter_xml = "application-filter.xml";
+      $list_xml = "application-list.xml";
+      $this->storagePoints= array(get_ou("applicationRDN"));
+    }
+
+    // Build filter
+    if (session::global_is_set(get_class($this)."_filter")){
+      $filter= session::global_get(get_class($this)."_filter");
+    } else {
+      $filter = new filter(get_template_path($filter_xml, true));
+      $filter->setObjectStorage($this->storagePoints);
+    }
     $this->setFilter($filter);
 
     // Build headpage
-    $headpage = new listing(get_template_path("application-list-release.xml", true));
+    $headpage = new listing(get_template_path($list_xml, true));
     $headpage->setFilter($filter);
 
     // Add copy&paste and snapshot handler.
@@ -70,41 +85,84 @@ class applicationManagement extends management
     $this->registerAction("edit_mailapplication","editEntry");
   }
 
-  function renderList()
+
+  /*! \brief   Someone wants to remove some object(s)
+   *            ask for a confirmation now.
+   */
+  function removeEntryRequested($action="",$target=array(),$all=array(), 
+      $altTabClass ="", $altTabType = "",             $altAclCategory="")
   {
-    $filter = $this->getFilter();
+    // Close dialogs and remove locks for currently handled dns
+    $this->cancelEdit();
+
+    // Do not allow to remove objects with state freeezed
+    $errors = $disallowed = array();
     $headpage = $this->getHeadpage();
-    $filter->setComboBoxOptions("RELEASE",$this->getReleaseList());
+    foreach($target as $dn){
 
-    if(isset($_POST['RELEASE'])){
-      $headpage->setBase($_POST['RELEASE']);
-    }else{
-      $headpage->setBase($base = get_ou('applicationRDN').$this->config->current['BASE']);
+      $obj = $headpage->getEntry($dn);
+      $acl  = $this->ui->get_permissions($obj['dn'],"application/application");
+      if(!preg_match("/d/",$acl)){
+        $disallowed[] = $obj['dn'];
+      }elseif(isset($obj['FAIstate']) && preg_match('/freeze/i', $obj['FAIstate'][0])){
+        $errors[] = $obj['dn'];
+      }else{
+        $this->dns[] = $obj['dn'];
+      }
     }
-    
-    $headpage->update();
-    $display = $headpage->render();
-    return($this->getHeader().$display);
-
+    if(count($errors)){
+      msg_dialog::display(_("Branch locked"),
+          sprintf(_("The following entries are locked, you can't remove them %s."),
+            msgPool::buildList($errors)),INFO_DIALOG);
+    }
+    if(count($disallowed)){
+      msg_dialog::display(_("Permission error"), msgPool::permDelete($disallowed), ERROR_DIALOG);
+    }
+    return(management::removeEntryRequested($action, $this->dns));
   }
 
-  function getReleaseList($base = "", $prefix ="")
+
+  /*! \brief  This method opens an existing object or a list of existing objects to be edited.
+   *
+   *
+   *  @param  String  'action'  The name of the action which was the used as trigger.
+   *  @param  Array   'target'  A list of object dns, which should be affected by this method.
+   *  @param  Array   'all'     A combination of both 'action' and 'target'.
+   */
+  function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
   {
-    $list = array();
-    if(empty($base)){
-      $base = get_ou('applicationRDN').$this->config->current['BASE'];
-      $list[$base] = "/";
+    management::editEntry($action,$target,$all,$altTabClass,$altTabType,$altAclCategory);
+    if($this->tabObject){
+      if(isset($this->tabObject->by_object['application']->attrs['FAIstate'][0])){
+        $state = $this->tabObject->by_object['application']->attrs['FAIstate'][0];
+        $this->tabObject->setReadOnly(preg_match("/freeze/i", $state));
+      }
     }
+  }
 
-    $ldap = $this->config->get_ldap_link();
-    $ldap->ls("(objectClass=FAIbranch)",$base,array("ou","FAIstate"));
-    while($release = $ldap->fetch()){
-      $list[$release['dn']] = $prefix.$release['ou'][0];
-      $list = array_merge($list,$this->getReleaseList($release['dn'],$prefix."  "));
+
+  /*! \brief   Overridden render method of class mangement.
+   *            this allows us to add a release selection box.
+   */
+  function renderList()
+  {
+    $smarty = get_smarty();
+    $filter = $this->getFilter();
+    $headpage = $this->getHeadpage();
+
+    // Display release selector
+    if($this->IsReleaseManagementActivated()){
+      $this->releaseSelector->update();
+      $this->app_release = $this->releaseSelector->getBase();
+      $headpage->setBase($this->app_release);
+      $smarty->assign("RELEASE", $this->releaseSelector->render());
     }
-    return($list);
+
+    $headpage->update();
+    $display = $headpage->render();
+    return($this->getHeader().$display);
   }
-  
+
 
   function IsReleaseManagementActivated()
   {