Professional Documents
Culture Documents
Customizing Itop 1-0
Customizing Itop 1-0
Customizing Itop 1-0
0
(Draft)
1 Table of content ...............................................................................................................................................2
2 What can be customized in iTop .......................................................................................................................3
3 Data Model ........................................................................................................................................................3
Overview ................................................................................................................................................................3
Change the model, step by step ...........................................................................................................................3
Class defintion ......................................................................................................................................................3
Available attributes ...............................................................................................................................................4
4 Change the appearance ....................................................................................................................................5
New menus ...........................................................................................................................................................5
Templates ..............................................................................................................................................................6
Overview ................................................................................................................................................................6
Step by step ......................................................................................................................................................6
itopblock ...........................................................................................................................................................6
2
2 What can be customized in iTop
The iTop application was designed to be fully customizable. The data model of the application is fully
configurable. The user interface is "generic" and adapts automatically to the underlying data model.
There are two kind of things you can customize in iTop : the data model, and the appearance of data.
Adapt the data model if you want to add attributes to the existing objects or create your own objects
from scratch.
Change the appearance if the default appearance does not feet your need (e.g. need to strongly
differentiate between two kinds of objects, or need to display a powerful dashboard)
3 Data Model
Overview
The iTop Data Model is based on PHP classes. Each class of object manipulated by iTop corresponds to
a valid PHP class.
In order to be stored/maintained in the MySQL database by the iTop "ORM" (Object Relational Mapper)
layer, the definition of such classes uses a specific API, provided by the static "MetaModel" class.
Since release 1.0, classes delivered with iTop are defined in the files
/modules/mymodule/model.mymodule.php (e.g. /modules/itop-config-mgmt-1.0.0/model.itop-config-
mgmt.php).
The data model definition files are listed in the module definition files:
/modules/mymodule/module.mymodule.php.
When you're done you can use the iTop application with your new/modified data model, create new
instances of your objects, edit them, etc...
Class defintion
A class definition occurs, for each class, inside the method Init. This definition defines 5 types of
information:
1. Basic information about the class: name, label, table to use in the database, template for
3
the display...
2. The list of Attributes (i.e. members of the class)
3. The list of Search Criteria for the class. (i.e. which attribute will be search-able – note that
in iTop 1.0 this list is obsolete, all attributes are search-able by default).
4. The life cycle for this class, if the class is state based (e.g. Incident Tickets).
5. Lists (called Zlists) defining the appearance of the object inside list of results or details...
MetaModel::Init_AddAttribute(new AttributeString("name",
array("allowed_values"=>null, "sql"=>"name", "default_value"=>"", "is_null_allowed"=>false,
"depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeString("code",
array("allowed_values"=>null, "sql"=>"code", "default_value"=>"", "is_null_allowed"=>true,
"depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeEnum("status",
array("allowed_values"=>new ValueSetEnum('active,inactive'), "sql"=>"status",
"default_value"=>"active", "is_null_allowed"=>true, "depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id",
array("targetclass"=>"Organization", "jointype"=>null, "allowed_values"=>null,
"sql"=>"parent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL,
"depends_on"=>array())));
MetaModel::Init_AddAttribute(new AttributeExternalField("parent_name",
array("allowed_values"=>null, "extkey_attcode"=>"parent_id", "target_attcode"=>"name",
"is_null_allowed"=>true, "depends_on"=>array())));
Available attributes
Here is the list of attributes that you can use. Please see existing examples to know more about the
options available on each type of attribute.
4
Type Description
AttributeString String of 255 characters
AttributeText Long string (depends on the length of TEXT columns on you MySQL
server)
AttributeEmailAddress String with format checking
AttributeIPAddress String with format checking
AttributeEnum Enumeration of values
AttributeInteger Integer value
AttributeBoolean Boolean value
AttributeDate Date
AttributeDateTime Date and time
AttributeBlob Document contents
AttributePropertySet A custom table of properties: no search possible, no rule on
formatting, no specific tracking of changes
AttributeTable A table of data: no rule at all, just a table
AttributeExternalKey Link to an object of a given class
AttributeExternalField View an attribute of an object (given by the corresponding External
Key)
AttributeLinkedSet List of objects of a class having an external key on the current class
(1-N link)
AttributeLinkedSetIndirect List of objects of a class being linked through an intermediate class
(N-N link)
Once data model had been modified, just re-install this new version of iTop.
5
));
Note: there is an issue related to the value of fRank. The symptom is: a popup window displays
“assertion failed”. The workaround is to define another value for fRank (check especially with the first
entry (MenuGroup).
This customization does not require re-installation of iTop. You just have to reload your web browser.
Templates
Overview
Templates allow you to design a custom dashboard (or to customize an existing one).
A template is an html file which accepts tags recognized by iTop: <itopblock>. The tags defines
contents computed by itop: a list of objects, a pie chart or a bar chart.
Step by step
Create a template file (see existing HMTL files in /modules/ directories)
Declare the template in a data model file (see explanations above)
$oCINode = new TemplateMenuNode('My dashboard', '../modules/mymodule/mytemplate.html',
$oMyGroup->GetIndex(), 5 /* fRank */);
itopblock
An itopblock is the combination of an OQL query, a grouping criteria and a type of graphic. There are 3
types of itopblock:
• Bar chart
• Pie chart
• Display list
6
<td class="dashboard">
<itopblock BlockClass="DisplayBlock" type="open_flash_chart"
parameters="chart_type:pie;group_by:someattribute;chart_title:DictionaryID"
asynchronous="false" encoding="text/oql">SELECT MyClass</itopblock>
</td>
</tr>
<tr>
<td class="dashboard">
<h2><itopstring>DictionaryID</itopstring></h2>
<itopblock BlockClass="DisplayBlock" type="list" parameters="dashboard:true"
asynchronous="false" encoding="text/oql">SELECT MyClass WHERE age = 30</itopblock>
</td>
<td class="dashboard">
</td>
</tr>
</table>
DicionaryID could be either a label, or a placeholder for the label found in a dictionary. The use of a
disctionary is a must if localization is needed.