Hyperlinks configurator
- name:
- Hyperlinks configurator
- description:
- Create custom hyperlinks on objects' details, by configuration
- version:
- 1.1.2
- release:
- 2021-10-14
- code:
- combodo-custom-hyperlinks
- state:
- stable
- diffusion:
- Client Store, iTop Hub
- php-version-max:
- PHP 8.1
Create hyperlink buttons to jump from one object in iTop into another application, via configurable URLs, without writing a single line of code.
Features
-
Hyperlink, label, tooltip and icon are configurable
-
The
scope
option makes it possible to display the hyperlink only on objects matching a specific rule -
The target of the link is configurable as well (by default
_blank
to open the link in another tab/window) -
The
contexts
option specifies if the link is available in the backoffice (console) and/or in the portal(s) (and in which portal if there are several of them). -
The action/button can be limited to users having at least one of the
allowed_profiles
.
Revision History
Version | Release Date | Comments |
---|---|---|
1.1.2 | 2021-10-14 | - Added the ability to have a button calling a
method (i.e. method://SomeMethod() ) inside the
portal.- Actions calling a method can now also be displayed as “shortcut actions” (i.e. outside of the “Other actions” menu) - Retrocompatibility with iTop 2.6.x |
1.1.0 | 2021-05-10 | Add iTop 3.0 compatibility |
1.0.4 | 2020-11-08 | New capability to call a method on the selected
object via an Ajax call, with the URL scheme
method://SomeMethod() Label and tooltip are now treated as template strings (i.e. $this->att_code$ is supported)Menus items declared on a class are now inherited on derived classes Extended support for Font Awesome 5 “brand” icons (see the note about icons below). |
1.0.2 | 2019-03-19 | Add it on Portal objects with scope Add “allowed_profiles” parameter |
1.0.1 | 2019-03-15 | Addition of the “tooltip” and “contexts” parameters |
1.0.0 | 2019-02-07 | First version |
Limitations
-
Button labels cannot be localized (they are not dictionary entries)
Requirements
iTop 2.3.0 or newer
method://
) are only supported on iTop
2.6 or newer.Installation
Use the Standard installation process for this extension.
Configuration
For each “link” to be displayed, the following configuration parameters are available:
Parameter | Mandatory? | Meaning | Example |
---|---|---|---|
label |
mandatory if no icon | The label of the button/link | Wikipedia |
url |
mandatory | The hyperlink to jump to |
https://www.wikipedia.org/wiki/$this->first_name$_$this->name$ .
Note: since 1.0.3 you can use the special syntax
method://SomePublicMethod() to generate a menu item
that will call the specified method of the object. |
target |
optional | where to display the url result
_blank for a new window default,
_top for the current window |
_blank |
scope |
optional | An OQL query to filter on which object to display this link | SELECT Contact WHERE org_id = 2 |
icon |
optional | A Font Awesome icon code. See the note about icons below. | wikipedia |
tooltip |
optional | The label of a tooltip to display on the item. default: no tooltip | Lookup $this->name$ in Wikipedia |
contexts |
optional | If specified, a comma separated list of portals in
which to enabled this link. Use backoffice for the
iTop console. If not specified, it's available in all contexts |
backoffice,itop-portal |
allowed_profiles |
optional | If specified, a comma separated list of iTop Profiles for which to enable this link. If not specified, all profiles are allowed. | Support Agent,Configuration
Manager |
- Configuration file
-
'combodo-custom-hyperlinks' => array ( 'hyperlinks' => array ( 'Person' => array ( 'linkedin_me' => array ( 'label' => 'Linkedin Me!', 'url' => 'https://www.linkedin.com/search/results/all/?keywords=$this->friendlyname$', 'scope' => 'SELECT Contact WHERE org_id_friendlyname=\'demo\'', 'icon' => 'fab fa-linkedin', ), 'google_me' => array ( 'label' => 'Google Me!', 'url' => 'https://www.google.com/search?q=$this->friendlyname$', 'scope' => 'SELECT Contact', 'icon' => 'fab fa-google-plus-g', 'tooltip' => 'Search on Google for the person full name', ), ), 'Location' => array ( 'maps_me' => array ( 'label' => 'GoogleMaps Me!', 'url' => 'https://www.google.com/maps/search/$this->address$+$this->postal_code$+$this->city$+$this->country$', 'scope' => 'SELECT Location WHERE org_id_friendlyname=\'demo\'', 'icon' => 'fas fa-globe-africa', ), ), ), ),
method://SomeMethod()
for the url
, the
menu item will be a piece of Javascript that triggers an Ajax call
during which the specified method is executed on the object. When
this is done, the details of the object is displayed again
(refreshed). If the object is to be modified by this method, then
it's up to the method to call $this->DBWrite()
to
have the modified object persisted to the database. In order to
display a message to the end-user, the method can call
$this->SetSessionMessageFromInstance(...)
icon
string contains spaces, it will be used as-is
as the class to be applied to the <i>
tag. This
enables the support of FontAwesome 5 brand icons. For example when Font Awesome
4.7 is used (iTop up to version 2.7), the code for the LinkedIn
icon is linkedin
, when FontAwesome 5 is used (iTop
version 3.0), the code is fab fa-linkedin
.Usage
Questions & Answers
Q: Can I use this extension to propose a user action
which would create or update objects on multiple classes at
once?
A: Yes, this extension can be one part of the solution. In addition
you will need to write you own extension to provide that complex
action as a PHP method on the class on which the user will trigger
the action.
An exemple a customer to whom you deliver services, is
terminating its contract, as a result, you would like to close all
the tickets open by its users, set all its contact status to
inactive, disable all its user account, set all its CDMB owned CIs
to obsolete and so on… For this you will need to write a PHP method
for eg on the Organization
class. That method will
called by an action on the details of the Organization. So the User
will trigger that Terminate customer
action on the
organization he wants to terminate.
- class:Organization
-
public function TerminateCustomer() { $iOrgID = $this->GetKey(); // Desactivate Contacts $oSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT Contact WHERE org_id =$iOrgID")); while ($oContact = $oSet->Fetch()) { $oContact->Set('status','inactive'); $oContact->DBUpdate(); } // Disable Users $oSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT User WHERE org_id =$iOrgID")); while ($oUser = $oSet->Fetch()) { $oUser->Set('status','disabled'); $oUser->DBUpdate(); } // Auto-resolve UserRequests $oSet = new CMDBObjectSet(DBObjectSearch::FromOQL( "SELECT UserRequest WHERE org_id =$iOrgID AND status IN ('new','assigned','pending','approved')" )); while ($oUserRequest = $oSet->Fetch()) { $oUserRequest->ApplyStimulus('ev_autoresolve'); // No need to call DBUpdate(), it's done within ApplyStimulus } // Other automations... }
Then add an entry in the Configuration File, to display that action to the users with enough rights to do it
- config-itop.php
-
'combodo-custom-hyperlinks' => array ( 'hyperlinks' => array ( 'Organization' => array ( 'terminate_customer' => array ( 'label' => 'Terminate Customer', 'url' => 'method://TerminateCustomer()', 'scope' => 'SELECT Organization', 'allowed_profiles' => 'Administrator', 'icon' => 'fas fa-skull-crossbones', 'contexts' => 'backoffice', ), ), ), ),