summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9c5ac44)
raw | patch | inline | side by side (parent: 9c5ac44)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 4 Jan 2006 09:50:59 +0000 (09:50 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 4 Jan 2006 09:50:59 +0000 (09:50 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2400 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/systems/class_glpiAccount.inc | patch | blob | history |
diff --git a/plugins/admin/systems/class_glpiAccount.inc b/plugins/admin/systems/class_glpiAccount.inc
index 563ad430d98382d3f840483cd4d95ad1a784f702..6d7813e8c6205277e6265ee023f6fa6327f387a7 100644 (file)
$smarty= get_smarty();
$display= "";
- /* Assign smarty defaults */
+ /* Assign smarty defaults
+ To avoid undefined indexes, if there is an error with the glpi db
+ */
foreach(array("SystemTypes","SystemTypeKeys","Manufacturers",
"OSs","TechnicalResponsibles","InstalledDevices","Attachments",
"OSKeys","OSs","ManufacturerKeys","InstalledDeviceKeys") as $attr){
$smarty->assign($attr,array());
$smarty->assign($attr."ACL"," disabled ");
}
-
foreach(array("type","FK_glpi_enterprise","os","tech_num","comments","contact_num") as $attr){
$smarty->assign($attr,"");
$smarty->assign($attr."ACL"," disabled ");
}
+ /* Check if there is a glpi database server defined
+ */
if(!isset($this->config->data['SERVERS']['GLPI'])){
print_red(_("There is no server with valid glpi database service."));
return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
$this->data = $this->config->data['SERVERS']['GLPI'];
+ /* Check if we can call mysql_connect
+ If we can't, there is no the mysql-php extension
+ */
if(!is_callable("mysql_connect")){
print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
$this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+ /* If handle == false, abort
+ Seems that the server, username and or password is wrong
+ */
if(!$this->handle->is_connected){
print_red(_("Can't connect to glpi database, check configuration twice."));
return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
}
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
- $users = ($this->handle->getUsers());
-
+ /* All check are ok
+ Lets handle Posts, templates etc below ...
+ */
+
+ $users = $this->handle->getUsers();
$ldap= $this->config->get_ldap_link();
-
+
+ /* Add Device was requested, open new dialog
+ */
if(isset($_POST['AddDevice'])){
$this->dialog =true;
$this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn,$this->usedDevices);
}
- /* We have selected some devices and pressed use button */
+ /* We have selected some devices and pressed use button
+ */
if(isset($_POST['SelectDeviceSave'])){
$this->cur_dialog->save_object();
$this->usedDevices= ($this->cur_dialog->getSelected());
$this->edit_type=false;
}
- /* Aborted Device selction */
+ /* Aborted Device selction
+ */
if(isset($_POST['SelectDeviceCancel'])){
$this->dialog = false;
$this->cur_dialog = false;
$this->edit_type=true;
}
+ /* This closes the system type editing dialog
+ */
if(isset($_POST['close_edit_type'])){
$this->edit_type=false;
$this->dialog = false;
}
+ /* This appends a new system to our sytem types
+ */
if((isset($_POST['add_type']))&&(!empty($_POST['type_string']))){
$this->handle->addSystemType($_POST['type_string']);
}
+ /* Remove selected type from our system types list
+ */
if((isset($_POST['del_type']))&&(!empty($_POST['select_type']))){
$this->handle->removeSystemType($_POST['select_type']);
}
+ /* Rename selected system type to given string
+ */
if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))&&(!empty($_POST['type_string']))){
$this->handle->updateSystemType($_POST['type_string'],$_POST['select_type']);
}
+ /* Someone wants to edit the system types ...
+ So, lets open a new dialog which provides some buttons to edit the types
+ */
if($this->edit_type){
$smarty->assign("SystemTypes", $this->handle->getSystemTypes());
$smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
-
$display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE));
return($display);
}
- /* ENDE, Systemtype management.
- */
-
/* System os management
*/
if(isset($_POST['edit_os'])){
$this->edit_os=true;
}
+ /* Close Operating system dialog
+ */
if(isset($_POST['close_edit_os'])){
$this->edit_os=false;
$this->dialog = false;
}
+ /* Add new os to the db
+ */
if((isset($_POST['add_os']))&&(!empty($_POST['is_string']))){
$this->handle->addOS($_POST['is_string']);
}
+ /* Delete selected os from list and db
+ */
if((isset($_POST['del_os']))&&(!empty($_POST['select_os']))){
$this->handle->removeOS_byID($_POST['select_os']);
}
+ /* Rename selected os to given string
+ */
if((isset($_POST['rename_os']))&&(!empty($_POST['select_os']))&&(!empty($_POST['is_string']))){
$this->handle->updateOS($_POST['is_string'],$_POST['select_os']);
}
+ /* Open dialog to edit os types
+ */
if($this->edit_os){
$smarty->assign("OSKeys", array_flip($this->handle->getOSTypes()));
$smarty->assign("OSs", $this->handle->getOSTypes());
-
$display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE));
return($display);
}
- /* ENDE, os management.
+ /* Show dialog to select a new contact person
+ * Select a contact person
*/
-
if(isset($_POST['SelectContactPerson'])){
$this->addUser = "contact";
$this->cur_dialog= new glpiSelectUser($this->config,$this->dn);
}
+ /* Open dialog which allows to edit the manufacturers
+ */
if(isset($_POST['edit_manufacturer'])){
$this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
$this->dialog = true;
}
+ /* Close manufacturer editing dialog
+ */
if(isset($_POST['close_edit_manufacturer'])){
$this->dialog = false;
$this->cur_dialog = false;
}
+ /* Abort user selection
+ */
if(isset($_POST['SelectUserCancel'])){
$this->dialog = false;
$this->addUser ="";
$this->cur_dialog = false;
}
-
+ /* Selecte technical responsible person
+ */
if(isset($_POST['SelectTechPerson'])){
$this->addUser ="tech";
$this->cur_dialog= new glpiSelectUser($this->config,$this->dn);
$this->dialog= false;
}
+ /* if( cur_dialog != false || cur_dialog != NULL)
+ * There is a dialog which wants to be displayed
+ */
if($this->cur_dialog){
$this->cur_dialog->save_object();
$this->dialog=true;
$smarty->assign($attr."ACL",chkacl($this->acl,$attr));
}
+ /* Assign some vars to smarty
+ */
foreach(array("type","FK_glpi_enterprise","os","tech_num","contact_num") as $attr){
$smarty->assign($attr,"");
$smarty->assign($attr."ACL",chkacl($this->acl,$attr));
}
- /* Perform some checks
- * arround the database
- */
- if(!isset($this->config->data['SERVERS']['GLPI'])){
- print_red(_("There is no valid configuration for glpi database available."));
- return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
- }
- $this->data = $this->config->data['SERVERS']['GLPI'];
-
- if(!is_callable("mysql_connect")){
- print_red(_("The php mysql extension is missing. Can't perform any queries."));
- return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
- }
-
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-
- if(!$this->handle->is_connected){
- print_red(_("Can't connect to specified database."));
- return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
- }
-
- /* If we reach this this
- * the database connection seams to ok
- */
-
/* Do we need to flip is_account state? */
if (isset($_POST['modify_state'])){
$this->is_account= !$this->is_account;
return ($display);
}
-
+ /* Assign ACLs to smarty*/
foreach($this->attributes as $attr){
$smarty->assign($attr."ACL",chkacl($this->acl,$attr));
}
-
+ /* Assign system types
+ */
$smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
$smarty->assign("SystemTypes", $this->handle->getSystemTypes());
$smarty->assign("type", $this->type);
+ /* Assign os types
+ */
$smarty->assign("OSKeys", array_flip($this->handle->getOSTypes()));
$smarty->assign("OSs", $this->handle->getOSTypes());
$smarty->assign("os", $this->os);
+ /* Dispaly installed devices */
$smarty->assign("InstalledDevices" ,$this->getDevices());
$smarty->assign("InstalledDeviceKeys" ,array_flip($this->getDevices()));
-
+ /* Append manufacturers
+ */
$smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises()));
$smarty->assign("Manufacturers", $this->handle->getEnterprises());
$smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
+ /* Handle contact person
+ Assign name ... to smarty, if set
+ */
if(isset($users[$this->contact_num])){
$tr = $ldap->fetch($ldap->cat($users[$this->contact_num]));
$str = "";
- if(isset($tr['givenName'][0])){
- $str .= $tr['givenName'][0]." ";
- }
-
- if(isset($tr['sn'][0])){
- $str .= $tr['sn'][0]." ";
- }
-
- if(isset($tr['uid'][0])){
- $str .= "[".$tr['uid'][0]."]";
- }
-
-
+ if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
+ if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
$smarty->assign("contact_num", $str);
}else{
$smarty->assign("contact_num", _("N/A"));
}
+ /* Handle tech person
+ Assign name ... to smarty, if set
+ */
if(isset($users[$this->tech_num])){
$tr = $ldap->fetch($ldap->cat($users[$this->tech_num]));
$str = "";
- if(isset($tr['givenName'][0])){
- $str .= $tr['givenName'][0]." ";
- }
-
- if(isset($tr['sn'][0])){
- $str .= $tr['sn'][0]." ";
- }
-
- if(isset($tr['uid'][0])){
- $str .= "[".$tr['uid'][0]."]";
- }
-
-
+ if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
+ if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
$smarty->assign("tech_num", $str);
}else{
$smarty->assign("tech_num", _("N/A"));