Code

Replaced in_array calls for gosa-plugins
[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     foreach ($data as $tab){
22       if(!class_available($tab['CLASS'])) continue;
23       $this->by_name[$tab['CLASS']]= $tab['NAME'];
25       if ($baseobject === NULL){
26         $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
27         $this->by_object[$tab['CLASS']]= $baseobject;
28       } else {
29         $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
30       }
32       $this->by_object[$tab['CLASS']]->parent= &$this;
33       $this->by_object[$tab['CLASS']]->set_acl_category($category);
34       $this->read_only |= $this->by_object[$tab['CLASS']]->read_only;
36       /* Initialize current */
37       if ($this->current == ""){
38         $this->current= $tab['CLASS'];
39       }
40     }
42     /* Add references/acls/snapshots */
43     $this->addSpecialTabs();
44   }
47   /*! \brief Reinitializes the tab classes with fresh ldap values.
48     This maybe usefull if for example the apply button was pressed.
49    */
50   function re_init()
51   {
52     $baseobject= NULL;
53     foreach($this->by_object as $name => $object){
54       $class = get_class($object);
55       if(in_array_strict($class,array("reference","acl"))) continue;
56       if ($baseobject === NULL){
57         $baseobject= new $class($this->config, $this->dn,NULL,$this);
58         $baseobject->enable_CSN_check();
59         $this->by_object[$name]= $baseobject;
60       } else {
61         $this->by_object[$name]= new $class($this->config, $this->dn, $baseobject,$this);
62       }
63       $this->by_object[$name]->parent= &$this;
64       $this->by_object[$name]->set_acl_category($this->acl_category);
65     }
66   }
69   function save_object($save_current= FALSE)
70   {
71     tabs::save_object($save_current);
73     /* Assign current cn */
74     $baseobject= $this->by_object['workgeneric'];
75     $baseobject->netConfigDNS->cn= $baseobject->cn;
76     foreach ($this->by_object as $key => $obj){
77       $this->by_object[$key]->cn= $baseobject->cn;
78     }
79   }
82   function save($ignore_account= FALSE)
83   {
84     /* Check for new 'dn', in order to propagate the
85        'dn' to all plugins */
86     $baseobject= $this->by_object['workgeneric'];
87     $this->dn= "cn=".$baseobject->cn.",".get_ou('workstationRDN').$baseobject->base;
89     if($this->dn != $baseobject->orig_dn && $baseobject->orig_dn != "new"){
91       /* Udpate acls */
92       $baseobject->update_acls($baseobject->orig_dn,$this->dn);
93       $baseobject->move($baseobject->orig_dn,$this->dn);
94     }
96     $baseobject->dn= $this->dn;
98     foreach ($this->by_object as $key => $obj){
99       $this->by_object[$key]->dn= $this->dn;
100       $this->by_object[$key]->cn= $baseobject->cn;
101     }
103     tabs::save(TRUE);
105     if(isset($this->by_object['printgeneric'])){
106       if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){
107         $this->by_object['printgeneric']->remove_from_parent();
108       }
109     }
110   }
114 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
115 ?>