Registrations to Open-AudIT forums are now closed. To ask any new questions please visit Opmantek Community Questions.

Open-AudIT

What's on your network?
It is currently Sat Apr 20, 2024 11:47 pm

All times are UTC + 10 hours




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
PostPosted: Wed Jan 09, 2013 11:41 pm 
Offline
Newbie

Joined: Wed Jan 09, 2013 6:43 am
Posts: 13
Hi Mark,

Right now we are working with an Excel sheet as our server inventory in my company. We have some fields there you do not offer in OAv2 (e.g. which patch cycle, server owner, application owner or just a larger field for general notes). I saw that there's a "Custom Details" section in your system summary. Unfortunately it's just empty and I couldn't find a way to fill it with data. I had a look at your source code and the database and saw that you are already prepared for custom fields (tables sys_man_additional_fields and sys_man_additional_fields_data) as well as the associated model (m_additional_fields.php) and controller classes (main.php). But it looks like as if there are no fields within the database nothing will show up in the web GUI.
I have already searched for a hidden controller (that is not yet linked to a menu item) to add some custom fields but couldn't find anything. Trying to hack the database directly was my next approach but as I am not sure what values all the fields really expect I also gave up this try. Searching the forum wasn't very efficient as this isn't a topic people talking about a lot. The only thread I found was [url]http://www.open-audit.org/phpBB3/viewtopic.php?f=20&t=5749[/url], but it was just more or less the same question I have without a helpful answer.

Long story short: How can I add additional custom fields?

All the best,
Denis

_________________
You are running version beta9.2 of OAv2.
Your database platform is mysql (version 5.1.66).
Your web server is Apache/2.2.15 (CentOS) .

Mixed environment (Physical&Virtual):
~200x Windows, ~50x Linux, ~30x VMware hosts


Last edited by intimber on Sun Jan 27, 2013 1:06 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 22, 2013 5:19 am 
Offline
Newbie

Joined: Wed Jan 09, 2013 6:43 am
Posts: 13
Any help on this? Or is it too difficult to explain? Or is it even possible?

Thanks,
Denis

_________________
You are running version beta9.2 of OAv2.
Your database platform is mysql (version 5.1.66).
Your web server is Apache/2.2.15 (CentOS) .

Mixed environment (Physical&Virtual):
~200x Windows, ~50x Linux, ~30x VMware hosts


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 23, 2013 2:54 am 
Offline
Moderator

Joined: Fri Jul 20, 2007 8:27 am
Posts: 1259
It looks like it's on the list of things to do but Mark hasn't got there yet.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 23, 2013 3:07 am 
Offline
Newbie

Joined: Wed Jan 09, 2013 6:43 am
Posts: 13
Ok, thanks.

Does someone else know something about this? I don't need a detailed step-by-step tutorial for this. A small hint in the right direction would also be helpful for now. Maybe I will then find out the details by myself. I would also be able to provide a step-by-step guide for the community if someone gives me a raw introduction.

Thanks,
Denis

_________________
You are running version beta9.2 of OAv2.
Your database platform is mysql (version 5.1.66).
Your web server is Apache/2.2.15 (CentOS) .

Mixed environment (Physical&Virtual):
~200x Windows, ~50x Linux, ~30x VMware hosts


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 23, 2013 6:13 am 
Offline
Moderator

Joined: Fri Jul 20, 2007 8:27 am
Posts: 1259
Looking over the code it looks like most of the display code is ready but there's no interface for custom field type creation or adding custom field data to systems. This means you can edit the database directly if you really can't wait.

Define a custom text field:
Add a row to sys_man_additional_fields.
group_id = don't think this is used but you need something so put 1
field_name = "Your Field Name"
field_type = "varchar"
field_placement = "view_summary_custom" - Look through v_display_system.php for the display_custom_field calls and use the first parameter for the call to determine where you'd like to display your custom field. "view_summary_custom" puts it in the Summary - Custom - Custom Details section.

Add custom field data to a system:
Add a row to sys_man_additional_fields_data.
system_id = pick a system from the system table and use its id system_id here
field_id = field_id of the custom text field we just defined above
field_varchar = Data you want to display

See if that does what you want.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 23, 2013 8:47 am 
Offline
Site Admin
User avatar

Joined: Mon Jun 07, 2004 11:48 am
Posts: 1964
Location: Brisbane, Australia
[quote]Looking over the code it looks like most of the display code is ready but there's no interface for custom field type creation or adding custom field data to systems.

Yep - I'll see what I can do in short order...

_________________
Support and Development hours available from [url=https://opmantek.com]Opmantek[/url].
Please consider a purchase to help make Open-AudIT better for everyone.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 23, 2013 10:23 am 
Offline
Moderator

Joined: Fri Jul 20, 2007 8:27 am
Posts: 1259
I hacked some custom fields into the database and noticed that I could not edit the data when it was displayed. The patch below is the minimum amount of changes to get data edit working.

[attachment=0] edit_custom_fields.txt [3.96 KiB]
Downloaded 340 times


[code]
--- code_igniter/application/controllers/ajax.php Thu Jan 15 01:13:00 1970
+++ code_igniter/application/controllers/ajax.php Thu Jan 15 01:13:00 1970
@@ -113,15 +113,15 @@
if ((mb_substr_count($this->data['field_name'], 'custom_') > 0) && ($access_level >= 7)) {
$data = explode("_", $this->data['field_name']);
$sql = "SELECT * FROM sys_man_additional_fields_data WHERE field_details_id = ? AND system_id = ?";
- $data_array = array($data[3], $this->data['system_id']);
+ $data_array = array($data[2], $this->data['system_id']);
$query = $this->db->query($sql, $data_array);
if ($query->num_rows() > 0) {
- $sql = "update sys_man_additional_fields_data SET field_" . $data[1] . " = '" . urldecode($this->data['field_data']) . "' WHERE field_details_id = '" . $data[3] . "'";
+ $sql = "update sys_man_additional_fields_data SET field_" . $data[1] . " = '" . urldecode($this->data['field_data']) . "' WHERE field_details_id = " . $data[2];
$query = $this->db->query($sql);
$this->m_audit_log->insert_audit_event("sys_man_additional_fields_data", urldecode($this->data['field_data']), $this->data['system_id']);
echo urldecode($this->data['field_data']);
} else {
- $sql = "insert into sys_man_additional_fields_data (field_details_id, system_id, field_id, field_" . $data[1] . ") VALUES (NULL, '" . $this->data['system_id'] . "', '" . $data[3] . "', '" . urldecode($this->data['field_data']) . "')";
+ $sql = "insert into sys_man_additional_fields_data (field_details_id, system_id, field_id, field_" . $data[1] . ") VALUES (NULL, '" . $this->data['system_id'] . "', " . $data[2] . ", '" . urldecode($this->data['field_data']) . "')";
$query = $this->db->query($sql, $data);
$this->m_audit_log->insert_audit_event("sys_man_additional_fields_data", urldecode($this->data['field_data']), $this->data['system_id']);
echo urldecode($this->data['field_data']);
--- code_igniter/application/models/m_additional_fields.php Thu Jan 15 01:13:00 1970
+++ code_igniter/application/models/m_additional_fields.php Thu Jan 15 01:13:00 1970
@@ -50,6 +50,7 @@
sys_man_additional_fields.field_name,
sys_man_additional_fields.field_type,
sys_man_additional_fields.field_placement,
+ sys_man_additional_fields_data.field_details_id,
sys_man_additional_fields_data.field_datetime,
sys_man_additional_fields_data.field_varchar,
sys_man_additional_fields_data.field_int,
--- code_igniter/application/views/theme-tango/v_display_system.php Thu Jan 15 01:13:00 1970
+++ code_igniter/application/views/theme-tango/v_display_system.php Thu Jan 15 01:13:00 1970
@@ -2578,8 +2578,7 @@
{
if ($field->field_placement == $field_placement)
{
- $data_id = "field_" . $field->field_type;
- $data_id = $field->$data_id;
+ $data_id = $field->field_lower_name;
$data_value = "field_" . $field->field_type;
$data_value = $field->$data_value;
$width = "120";
@@ -2589,8 +2588,8 @@
}
# TODO - fix this string output hack with real html entities
echo "<div style=\"float: left; width: 90%; \">\n";
- echo "<label for=\"custom_" . $field->field_type . "_" . str_replace(" ", "_", str_replace("#", "", ($data_id))) . "_" . $field->field_id . "_placement\" >" . __($field->field_name) . ": </label>";
- echo "<span id=\"custom_" . $field->field_type . "_" . str_replace(" ", "_", str_replace("#", "", ($data_id))) . "_" . $field->field_id . "_placement\"" . $edit . ">" . print_something($data_value) . "</span>\n";
+ echo "<label for=\"custom_" . $field->field_type . "_" . $field->field_details_id . "_" . str_replace(" ", "_", str_replace("#", "", ($data_id))) . "_placement\" >" . __($field->field_name) . ": </label>";
+ echo "<span id=\"custom_" . $field->field_type . "_" . $field->field_details_id . "_" . str_replace(" ", "_", str_replace("#", "", ($data_id))) . "_placement\" " . $edit . ">" . print_something($data_value) . "</span>\n";
echo "</div>\n";
}
}[/code]

Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 23, 2013 2:27 pm 
Offline
Site Admin
User avatar

Joined: Mon Jun 07, 2004 11:48 am
Posts: 1964
Location: Brisbane, Australia
I'm nearly finished on this.
Just need to complete the "Edit Custom Field" page and I'll upload as 8.2.

_________________
Support and Development hours available from [url=https://opmantek.com]Opmantek[/url].
Please consider a purchase to help make Open-AudIT better for everyone.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 24, 2013 3:54 am 
Offline
Newbie

Joined: Wed Jan 09, 2013 6:43 am
Posts: 13
Thanks, you are so great!
I think this will really help me and also others to meet individual needs.

_________________
You are running version beta9.2 of OAv2.
Your database platform is mysql (version 5.1.66).
Your web server is Apache/2.2.15 (CentOS) .

Mixed environment (Physical&Virtual):
~200x Windows, ~50x Linux, ~30x VMware hosts


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 26, 2013 3:48 pm 
Offline
Site Admin
User avatar

Joined: Mon Jun 07, 2004 11:48 am
Posts: 1964
Location: Brisbane, Australia
You can now insert and alter these values in the web interface.
You cannot use them when uploading multiple systems using an Excel spreadsheet.
This is on the list.

_________________
Support and Development hours available from [url=https://opmantek.com]Opmantek[/url].
Please consider a purchase to help make Open-AudIT better for everyone.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC + 10 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group