Code

Followup commit for #3020
[gosa.git] / trunk / gosa-plugins / goto / admin / systems / goto / tabs_workstation.inc
1 <?php
3 class worktabs extends tabs
4 {
6   public $was_activated = FALSE;
8   function worktabs($config, $data, $dn,$category)
9   {
10     /* Save dn */
11     $this->dn= $dn;
12     $this->config= $config;
14     $baseobject= NULL;
16     $this->acl_category = $category;
17     foreach ($data as $tab){
19       if(!class_available($tab['CLASS'])) continue;
20       $this->by_name[$tab['CLASS']]= $tab['NAME'];
22       if ($baseobject === NULL){
23         $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
24         $this->by_object[$tab['CLASS']]= $baseobject;
25       } else {
26         $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
27       }
29       $this->by_object[$tab['CLASS']]->parent= &$this;
30       $this->by_object[$tab['CLASS']]->set_acl_category($category);
31       $this->read_only |= $this->by_object[$tab['CLASS']]->read_only;
33       /* Initialize current */
34       if ($this->current == ""){
35         $this->current= $tab['CLASS'];
36       }
37     }
39     /* Add references/acls/snapshots */
40     $this->addSpecialTabs();
41   }
44   /*! \brief Reinitializes the tab classes with fresh ldap values.
45     This maybe usefull if for example the apply button was pressed.
46    */
47   function re_init()
48   {
49     $baseobject= NULL;
50     foreach($this->by_object as $name => $object){
51       $class = get_class($object);
52       if(in_array($class,array("reference","acl"))) continue;
53       if ($baseobject === NULL){
54         $baseobject= new $class($this->config, $this->dn,NULL,$this);
55         $baseobject->enable_CSN_check();
56         $this->by_object[$name]= $baseobject;
57       } else {
58         $this->by_object[$name]= new $class($this->config, $this->dn, $baseobject,$this);
59       }
60       $this->by_object[$name]->parent= &$this;
61       $this->by_object[$name]->set_acl_category($this->acl_category);
62     }
63   }
66   function save_object($save_current= FALSE)
67   {
68     tabs::save_object($save_current);
70     /* Assign current cn */
71     $baseobject= $this->by_object['workgeneric'];
72     $baseobject->netConfigDNS->cn= $baseobject->cn;
73     foreach ($this->by_object as $key => $obj){
74       $this->by_object[$key]->cn= $baseobject->cn;
75     }
76   }
79   function save($ignore_account= FALSE)
80   {
81     /* Check for new 'dn', in order to propagate the
82        'dn' to all plugins */
83     $baseobject= $this->by_object['workgeneric'];
84     $this->dn= "cn=".$baseobject->cn.",".get_ou('workstationRDN').$baseobject->base;
86     if($this->dn != $baseobject->orig_dn && $baseobject->orig_dn != "new"){
88       /* Udpate acls */
89       $baseobject->update_acls($baseobject->orig_dn,$this->dn);
90       $baseobject->move($baseobject->orig_dn,$this->dn);
91     }
93     $baseobject->dn= $this->dn;
95     foreach ($this->by_object as $key => $obj){
96       $this->by_object[$key]->dn= $this->dn;
97       $this->by_object[$key]->cn= $baseobject->cn;
98     }
100     tabs::save(TRUE);
102     if(isset($this->by_object['printgeneric'])){
103       if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){
104         $this->by_object['printgeneric']->remove_from_parent();
105       }
106     }
107   }
111 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
112 ?>