Code

5632cb462ae2c242a49b10f3e2c7193ed26d4cde
[gosa.git] / plugins / admin / systems / class_glpiAccount.inc
1 <?php
3 class glpiAccount extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary= "Manage server basic objects";
7   var $cli_description= "Some longer text\nfor help";
8   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $ignore_account= TRUE;
12   var $attributes= array();
13   var $objectclasses= array("whatever");
15   var $initialy_was_account = false;
17   var $data;
18   var $handle = NULL;
20   /* Contructor 
21      Sets default values and checks if we already hae an existing glpi account
22   */
23   function glpiAccount ($config, $dn= NULL)
24   {
25     plugin::plugin ($config, $dn);
27     if(!isset($this->config->data['SERVERS']['GLPI'])){
28       return;
29     }
30     
31     $this->data = $this->config->data['SERVERS']['GLPI'];
32     
33     if(!is_callable("mysql_connect")){
34       return;
35     }
36     
37     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
38     
39     if(!$this->handle->is_connected){
40       return;
41     } 
43     if($this->handle->is_account($this->dn)){
44       $this->is_account = true;
45     }else{
46       $this->is_account = false;
47     }
49     $this->initialy_was_account = $this->is_account;
50   }
52   function execute()
53   {
54         /* Call parent execute */
55           plugin::execute();
57     /* Fill templating stuff */
58     $smarty= get_smarty();
59     $display= "";
61     /* Assign smarty defaults */ 
62     foreach(array("SystemTypes","Manufacturers","OSs","TechnicalResponsibles","InstalledDevices","Attachments") as $attr){
63       $smarty->assign($attr,array());
64       $smarty->assign($attr."ACL"," disabled ");
65     }
67     foreach(array("SystemType","Manufacturer","OS","TechnicalResponsible") as $attr){
68       $smarty->assign($attr,"");
69       $smarty->assign($attr."ACL"," disabled ");
70     }
72     /* Perform some checks
73      *  arround the database
74      */ 
75     if(!isset($this->config->data['SERVERS']['GLPI'])){
76       print_red(_("There is no valid configuration for glpi database available."));
77       return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
78     }
79     $this->data = $this->config->data['SERVERS']['GLPI'];
81     if(!is_callable("mysql_connect")){
82       print_red(_("The php mysql extension is missing. Can't perform any queries."));
83       return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
84     }
86     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
88     if(!$this->handle->is_connected){
89       print_red(_("Can't copnnect to specified database."));
90       return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
91     }
93     /* If we reach this this 
94      * the database connection seams to ok
95      */
97     /* Do we need to flip is_account state? */
98     if (isset($_POST['modify_state'])){
99       $this->is_account= !$this->is_account;
100     }
102     /* Show tab dialog headers */
103     if ($this->is_account){
104       $display= $this->show_header(_("Remove DNS service"),
105           _("This server has DNS features enabled. You can disable them by clicking below."));
106     } else {
107       $display= $this->show_header(_("Add DNS service"),
108           _("This server has DNS features disabled. You can enable them by clicking below."));
109       return ($display);
110     }
113     foreach(array("SystemType","Manufacturer","OS","TechnicalResponsible","InstalledDevices","Attachments") as $attr){
114       $smarty->assign($attr,"");
115       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
116     }
117     
119     $smarty->assign("SystemTypes",$this->handle->getSystemTypes());
120     $smarty->assign("SystemType","os");
122     $smarty->assign("OSs",$this->handle->getOSTypes());
123     $smarty->assign("OS","is");
125     $smarty->assign("Manufacturers",$this->handle->getEnterprisesTypes());
126     $smarty->assign("Manufacturer","still");
128     $smarty->assign("TechnicalResponsibles",array("os","is","still","missing"));
129     $smarty->assign("TechnicalResponsible","missing");
132     $display.= $smarty->fetch(get_template_path('glpi.tpl', TRUE));
133     return($display);
134   }
136   function remove_from_parent()
137   {
138   }
141   /* Save data to object */
142   function save_object()
143   {
144     plugin::save_object();
145   }
148   /* Check supplied data */
149   function check()
150   {
151     $message= array();
153     return ($message);
154   }
157   /* Save to LDAP */
158   function save()
159   {
160   }
164 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
165 ?>