$idOS)); $name = $os['name']; $description = $os['description']; $icon = $os['icon_name']; } else { $name = get_parameter('name', ''); $description = get_parameter('description', ''); $icon = get_parameter('icon',0); } // Header print_page_header(__('Edit OS'), "", false, "", true); switch ($action) { default: case 'new': $actionHidden = 'save'; $textButton = __('Create'); $classButton = 'class="sub next"'; break; case 'edit': $actionHidden = 'update'; $textButton = __('Update'); $classButton = 'class="sub upd"'; break; case 'save': $values = array(); $values['name'] = $name; $values['description'] = $description; if (($icon !== 0) && ($icon != '')) { $values['icon_name'] = $icon; } $resultOrId = process_sql_insert('tconfig_os', $values); if ($resultOrId === false) { print_error_message(__('Fail to create OS')); $actionHidden = 'save'; $textButton = __('Create'); $classButton = 'class="sub next"'; } else { $idOs = $resultOrId; print_success_message(__('Success to create OS')); $actionHidden = 'update'; $textButton = __('Update'); $classButton = 'class="sub upd"'; } break; case 'update': $name = get_parameter('name', ''); $description = get_parameter('description', ''); $icon = get_parameter('icon',0); $values = array(); $values['name'] = $name; $values['description'] = $description; if (($icon !== 0) && ($icon != '')) { $values['icon_name'] = $icon; } $result = process_sql_update('tconfig_os', $values, array('id_os' => $idOS)); print_result_message($result, __('Success to update OS'), __('Error to update OS')); $actionHidden = 'update'; $textButton = __('Update'); $classButton = 'class="sub upd"'; break; case 'delete': $sql = 'SELECT COUNT(id_os) AS count FROM tagente WHERE id_os = ' . $idOS; $count = get_db_all_rows_sql($sql); $count = $count[0]['count']; if ($count > 0) { print_error_message(__('There are agents with this OS.')); } else { $result = (bool)process_sql_delete('tconfig_os', array('id_os' => $idOS)); print_result_message($result, __('Success to delete'), __('Error to delete')); } $idOS = 0; $name = get_parameter('name', ''); $description = get_parameter('description', ''); $icon = get_parameter('icon',0); $actionHidden = 'save'; $textButton = __('Create'); $classButton = 'class="sub next"'; break; } $table = null; $table->width = '80%'; $table->head[0] = ''; $table->head[1] = __('Name'); $table->head[2] = __('Description'); $table->head[3] = ''; $table->align[0] = 'center'; $table->align[3] = 'center'; $table->size[0] = '20px'; $table->size[3] = '20px'; $osList = get_db_all_rows_in_table('tconfig_os'); $table->data = array(); foreach ($osList as $os) { $data = array(); $data[] = print_os_icon($os['id_os'], false, true); $data[] = '' . safe_output($os['name']) . ''; $data[] = printTruncateText(safe_output($os['description']), 25, true, true); if ($os['id_os'] > 13) { $data[] = ''; } else { //The original icons of pandora don't delete. $data[] = ''; } $table->data[] = $data; } $htmlListOS = print_table($table, true); toggle($htmlListOS,__('List of OS'), __('Toggle')); echo '
'; function get_list_os_icons_dir() { global $config; $return = array(); $items = scandir($config['homedir'] . '/images/os_icons'); foreach ($items as $item) { if (strstr($item, '_small.png') || strstr($item, '_small.gif') || strstr($item, '_small.jpg')) { continue; } if (strstr($item, '.png') || strstr($item, '.gif') || strstr($item, '.jpg')) { $return[$item] = $item; } } return $return; } ?>