- 2006-23-01 * @version Dennis Stücken 2008 * @copyright Copyright 2004, 2005 - synetics GmbH * @license http://dev.perl.org/perl6/rfc/346.html Artistic License 2.0 */ class isys_cmdb_dao_category_g_ui extends isys_cmdb_dao_category_global { public function get_category_id() { return C__CATG__UNIVERSAL_INTERFACE; // dynamic Constant for catg dependency - id from isysgui_catg } /** * Import-Handler for category memory * * @author Dennis Stücken */ public function import($p_data) { if (is_array($p_data)) { foreach ($p_data as $l_key => $l_ui) { $l_obj_id = -1; foreach ($l_ui as $l_data) { $l_status = -1; $l_cat = -1; $l_id = -1; $l_title = $l_data["name"]; $l_con_type = -1; $l_plug_type = isys_import::check_dialog( "isys_ui_plugtype", "LC__UNIVERSAL__OTHER"); switch ($l_key) { case C__IMPORT__UI__MOUSE: $l_con_type = isys_import::check_dialog( "isys_ui_con_type", "LC__UI_CON_TYPE__MOUSE"); break; case C__IMPORT__UI__KEYBOARD: $l_con_type = isys_import::check_dialog( "isys_ui_con_type", "LC__UI_CON_TYPE__KEYBOARD"); break; case C__IMPORT__UI__MONITOR: $l_con_type = isys_import::check_dialog( "isys_ui_con_type", "Monitor"); break; case C__IMPORT__UI__PRINTER: $l_con_type = isys_import::check_dialog( "isys_ui_con_type", "LC__UI_CON_TYPE__PRINTER"); break; } /* Create it */ $this->create_element($l_cat, $l_id); $_POST['C__CATG__UI_TITLE'] = $l_title; $_POST['C__CATG__UI_CONNECTION_TYPE'] = $l_con_type; $_POST['C__CATG__UI_PLUG_TYPE'] = $l_plug_type; $_POST['C__CATG__UI__ASSIGNED_UI__HIDDEN'] = $l_obj_id; /* Save it */ $this->save_element($l_cat, $l_status, $l_id); } } } } /** * @param $p_cat_level level to save, standard 0 * (usage by reason of universality) * @param &$p_intOldRecStatus __status of record before update * @author Oliver Steigleder - 20051018 * @desc save global category odep element */ public function save_element($p_cat_level, &$p_intOldRecStatus, $p_id = NULL) { $intErrorCode = -1; // ErrorCode $l_catdata = $this->get_general_data(); $p_intOldRecStatus = $l_catdata["isys_catg_ui_list__status"]; if ($p_id > 0) { $l_catdata['isys_catg_ui_list__id'] = $p_id; } $l_intNewRecStatus = C__RECORD_STATUS__NORMAL; $l_bRet = ISYS_TRUE; if ($l_catdata["isys_catg_ui_list__id__connected"] != ISYS_NULL) { if ($l_catdata["isys_catg_ui_list__id__connected"] != $_POST['C__CATG__UI__ASSIGNED_UI__HIDDEN']){ // clear up the backreference of the prior assigned ui $l_strSql = "UPDATE isys_catg_ui_list ". "SET ". "isys_catg_ui_list__id__connected = NULL". " WHERE ". "isys_catg_ui_list__id = '". $l_catdata['isys_catg_ui_list__id__connected']."'"; $this->m_strLogbookSQL = $l_strSql; $l_bRet = $this->update($l_strSql); } } if ($l_bRet){ // update this isys_catg_ui_list entry for the actual record $l_strSql = "UPDATE isys_catg_ui_list ". "SET ". "isys_catg_ui_list__title = ".$this->convert_sql_text($_POST['C__CATG__UI_TITLE']).", ". "isys_catg_ui_list__isys_ui_con_type__id = ".$this->convert_sql_id($_POST['C__CATG__UI_CONNECTION_TYPE']).", ". "isys_catg_ui_list__isys_ui_plugtype__id = ".$this->convert_sql_id($_POST['C__CATG__UI_PLUG_TYPE']).", ". "isys_catg_ui_list__id__connected = ".$this->convert_sql_id($_POST['C__CATG__UI__ASSIGNED_UI__HIDDEN']).", ". "isys_catg_ui_list__description = ".$this->convert_sql_text($_POST['C__CMDB__CAT__COMMENTARY']).", ". "isys_catg_ui_list__status = "."'".C__RECORD_STATUS__NORMAL."' ". "WHERE ". "isys_catg_ui_list__id = '".$l_catdata['isys_catg_ui_list__id']."'".";"; $this->m_strLogbookSQL.= "\n\n ".$l_strSql; $l_bRet = $this->update($l_strSql); if ($l_bRet) { // refer the linked ui if ($_POST['C__CATG__UI__ASSIGNED_UI__HIDDEN'] != -1){ $l_strSql = "UPDATE isys_catg_ui_list ". "SET ". "isys_catg_ui_list__id__connected = ".$this->convert_sql_id($l_catdata['isys_catg_ui_list__id'])." ". "WHERE ". "isys_catg_ui_list__id = '".$_POST['C__CATG__UI__ASSIGNED_UI__HIDDEN']."'".";"; $this->m_strLogbookSQL.= "
".$l_strSql; $l_bRet = $this->update($l_strSql); } $l_bRet = $this->apply_update(); } } else { throw new isys_exception_database("Error while updating UI-Category."); } return $l_bRet == ISYS_TRUE ? NULL : $intErrorCode ; } /** * @param $p_cat_level level to save, standard 0 * (usage by reason of universality) * @param &$p_new_id returns the __id of the new record * @author Oliver Steigleder - 20060123 * @desc save global category ui element */ public function create_element($p_cat_level, &$p_new_id) { $p_new_id = -1; // no success $intRetCode = 3; $l_catdata = $this->get_general_data(); $l_fk_id = $l_catdata["isys_catg_ui__id"]; $l_strSql = "INSERT INTO ". "isys_catg_ui_list ". "SET ". "isys_catg_ui_list__isys_catg_ui__id = '".$l_fk_id."', ". "isys_catg_ui_list__title = '[new record - ui xx] ($l_fk_id)', ". "isys_catg_ui_list__status = '".C__RECORD_STATUS__BIRTH."' ". ";"; $this->m_strLogbookSQL = $l_strSql; if ($this->update($l_strSql)) { if ($this->apply_update()) { $p_new_id = $this->m_db->get_last_insert_id(); $intRetCode = ISYS_NULL; } } return $intRetCode; } /** * @author Niclas Potthast - 2006-11-17 * @return bool */ public function is_validate_post_data() { global $g_comp_template_language_manager; $l_retValid = ISYS_TRUE; $l_arrTomAdditional = array(); if ($_POST["C__CATG__UI_TITLE"]==""){ $l_arrTomAdditional["C__CATG__UI_TITLE"]["p_strInfoIconError"] = $g_comp_template_language_manager->{"LC___UNIVERSAL__ERROR_INFO_ICON"}; $l_retValid = ISYS_FALSE; } if ($_POST["C__CATG__UI_CONNECTION_TYPE"]<=0){ $l_arrTomAdditional["C__CATG__UI_CONNECTION_TYPE"]["p_strInfoIconError"] = $g_comp_template_language_manager->{"LC___UNIVERSAL__ERROR_INFO_ICON"}; $l_retValid = ISYS_FALSE; } if ($_POST["C__CATG__UI_TITLE"]==""){ $l_arrTomAdditional["C__CATG__UI_TITLE"]["p_strInfoIconError"] = $g_comp_template_language_manager->{"LC___UNIVERSAL__ERROR_INFO_ICON"}; $l_retValid = ISYS_FALSE; } $this->set_additional_rules( $l_retValid == ISYS_FALSE ? $l_arrTomAdditional : ISYS_NULL); $this->set_validation($l_retValid); return $l_retValid; } public function &get_ui() { global $g_comp_template; return new isys_cmdb_ui_category_g_ui($g_comp_template); } /** * return array to fill select box of all available ui´s * * @param $p_const_objType (optional) return list of specified obj_type, if NULL all obj * @return array * */ public function get_smarty_arr_available_ui($p_act_ui_id = ISYS_NULL){ global $g_comp_template_language_manager; $l_daoRes = $this->get_available_ui_by_ui($p_act_ui_id); if ($l_daoRes != ISYS_NULL) { while($l_rec = $l_daoRes->get_row()) { // list key=>value id=>obj_title $l_arr[$l_rec['isys_catg_ui_list__id']] = $l_rec['isys_catg_global_list__title']." > ".$l_rec['isys_catg_ui_list__title'] ; // . " (objID ".$l_rec['isys_obj__id'].") "; } } return $l_arr; } public function __construct(isys_component_database &$p_db) { parent::__construct($p_db); } } ?>