Code

75f6bd4e9b2511d9946d6fe6c24ead250cf8ea97
[gosa.git] / 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,$hide_refs = FALSE, $hide_acls = FALSE)
9   {
10     
11     /* Save dn */
12     $this->dn= $dn;
13     $this->config= $config;
15     $this->hide_refs = $hide_refs;
16     $this->hide_acls = $hide_acls;
18     $baseobject= NULL;
20     $this->acl_category = $category;
22     foreach ($data as $tab){
24       if(!class_available($tab['CLASS'])) continue;
25       $this->by_name[$tab['CLASS']]= $tab['NAME'];
27       if ($baseobject === NULL){
28         $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
29         $this->by_object[$tab['CLASS']]= $baseobject;
30       } else {
31         $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
32       }
34       $this->by_object[$tab['CLASS']]->parent= &$this;
35       $this->by_object[$tab['CLASS']]->set_acl_category($category);
36       $this->read_only |= $this->by_object[$tab['CLASS']]->read_only;
38       /* Initialize current */
39       if ($this->current == ""){
40         $this->current= $tab['CLASS'];
41       }
42     }
44     /* Add references/acls/snapshots */
45     $this->addSpecialTabs();
46   }
49   /*! \brief Reinitializes the tab classes with fresh ldap values.
50     This maybe usefull if for example the apply button was pressed.
51    */
52   function re_init()
53   {
54     $baseobject= NULL;
55     foreach($this->by_object as $name => $object){
56       $class = get_class($object);
57       if(in_array($class,array("reference","acl"))) continue;
58       if ($baseobject === NULL){
59         $baseobject= new $class($this->config, $this->dn,NULL,$this);
60         $baseobject->enable_CSN_check();
61         $this->by_object[$name]= $baseobject;
62       } else {
63         $this->by_object[$name]= new $class($this->config, $this->dn, $baseobject,$this);
64       }
65       $this->by_object[$name]->parent= &$this;
66       $this->by_object[$name]->set_acl_category($this->acl_category);
67     }
68   }
71   function save_object($save_current= FALSE)
72   {
73     tabs::save_object($save_current);
75     /* Assign current cn */
76     $baseobject= $this->by_object['workgeneric'];
77     $baseobject->netConfigDNS->cn= $baseobject->cn;
78     foreach ($this->by_object as $key => $obj){
79       $this->by_object[$key]->cn= $baseobject->cn;
80     }
81   }
84   function save($ignore_account= FALSE)
85   {
86     /* Check for new 'dn', in order to propagate the
87        'dn' to all plugins */
88     $baseobject= $this->by_object['workgeneric'];
89     $cn      = preg_replace('/,/', '\,', $baseobject->cn);
90     $cn      = preg_replace('/"/', '\"', $cn);
91     $this->dn= "cn=".$cn.",".get_ou("workgeneric", "workstationRDN").$baseobject->base;
93     if($this->dn != $baseobject->orig_dn && $baseobject->orig_dn != "new"){
95       /* Udpate acls */
96       $baseobject->update_acls($baseobject->orig_dn,$this->dn);
97       $baseobject->move($baseobject->orig_dn,$this->dn);
98     }
100     $baseobject->dn= $this->dn;
102     foreach ($this->by_object as $key => $obj){
103       $this->by_object[$key]->dn= $this->dn;
104       $this->by_object[$key]->cn= $baseobject->cn;
105     }
107     tabs::save(TRUE);
109     if(isset($this->by_object['printgeneric'])){
110       if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){
111         $this->by_object['printgeneric']->remove_from_parent();
112       }
113     }
114   }
118 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
119 ?>