Finally getting to the point where I really need such a feature.
I was searching the documentation and the board a bit.
I noticed this reply: You could give a look at those functions, they can force a field to be read-only:
public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '') which is called before displaying the edit screen or GetInitialStateAttributeFlags() which is called before creation screen.
It seems to suggest GetAttributeFlags() is only called on modification. Is it possible with the same method (or others) to also hide this field during viewing details of for example a Person? (and also in search results)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Then you should simply configure the "list" zlist to remove the unwanted fields. Each classes has a "list" zlist to define which fields are displayed in a standard list (same goes with "details" zlist for object properties)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'll do that. But the initial idea was that there is some information which is more sensitive, in just one or two fields of an entire class (and it's not practical to create a new class for those to define separate userrights).
Furthermore, you can see the attribute when using CSV/Excel export (or even just previewing it).
So I was kind of hoping GetAttributeFlags() or something similar would work for the result lists as well, as it may be easy for those who have access to see that information in the lists. "lists" zlist only seems to define the default view, but when modifying, non-privileged people can still add and see the attribute.
( There might be more and more requests like this with GDPR in mind )
Last edit: Jeffrey Bostoen 2018-09-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Unfortunately it is not possible natively or with a nice angle.
That being said, there is an ugly hack to do so (would also work when viewing an object). You can overload the GetAsHTML($sAttCode, $bLocalize) method of your class with something like:
I'm trying to come up with the best possible solution; since it's only really one text string (like in your example). Linked sets or something like that don't make sense, and I noticed the count_min and count_max are not implemented either.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks. I got it working for the details page and the lists of a Class; also just made it track no changes; and it seems to hide it when previewing and actually exporting to CSV.
When exporting to Excel, I still see the value in the on-screen preview in iTop.
For some reason (maybe because of my GetAsXML()), the export just fails.
Not sure what to return there, I thought just "" or return Str::pure2xml((string)"";
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the frontend, it just says the export failed (I also tried it with only one column, same result, only happens when exporting to Excel/PDF. CSV is fine.) The preview works fine.
I removed all extensions related to "person", still an error.
Could it be a Windows / XAMPP issue instead, are any special permissions needed to create Excel files on Windows / XAMPP ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Jeffrey,
Sorry it's been a long time since you asked, but you may take a look at the new AttributeSet / AttributeTagSet classes that were introduced in 2.6.0
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for bumping the thread. How exactly should these attribute types help, Pierre? :)
I still need to investigate this; the only other option I've considered so far is storing that one field which is more sensitive (GDPR) in a separate class instead.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Say there's some sensitive information in a CI... Let's say, a regular user is allowed to view a person; but not the phone number for emergencies.
Can this be accomplished using roles?
That's not available out of the box, but overwritting GetAttributeFlags() allow you to hardcode some hiding logic based on profiles for example
Thanks, I'll look into that.
Finally getting to the point where I really need such a feature.
I was searching the documentation and the board a bit.
I noticed this reply: You could give a look at those functions, they can force a field to be read-only:
public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '') which is called before displaying the edit screen or GetInitialStateAttributeFlags() which is called before creation screen.
I also read https://www.itophub.io/wiki/page?id=2_5_0%3Acustomization%3Acascade-update .
It seems to suggest GetAttributeFlags() is only called on modification. Is it possible with the same method (or others) to also hide this field during viewing details of for example a Person? (and also in search results)
Hi Jeffrey,
Yes, the GetAttributeFlags() method is called when viewing an object as well. So it should suit your needs :)
Guillaume
Thank you Guillaume for your reply. I'll see if I can share an example back here as token of my appreciation! :)
That would be great :)
It seems to work on the detail page, even when just viewing; but the field still appears in result lists?
Do you mean result lists when browsing through the console or the lists shown in linkedset tabs of objects?
I meant the result lists when browsing through the console.
So when I search for Persons, or just use the iTop-wide search (top search bar).
Then you should simply configure the "list" zlist to remove the unwanted fields. Each classes has a "list" zlist to define which fields are displayed in a standard list (same goes with "details" zlist for object properties)
I'll do that. But the initial idea was that there is some information which is more sensitive, in just one or two fields of an entire class (and it's not practical to create a new class for those to define separate userrights).
Furthermore, you can see the attribute when using CSV/Excel export (or even just previewing it).
So I was kind of hoping GetAttributeFlags() or something similar would work for the result lists as well, as it may be easy for those who have access to see that information in the lists. "lists" zlist only seems to define the default view, but when modifying, non-privileged people can still add and see the attribute.
( There might be more and more requests like this with GDPR in mind )
Last edit: Jeffrey Bostoen 2018-09-13
Unfortunately it is not possible natively or with a nice angle.
That being said, there is an ugly hack to do so (would also work when viewing an object). You can overload the GetAsHTML($sAttCode, $bLocalize) method of your class with something like:
This will work in the console -not the portal- but I would not recommend it.
Would that work to hide it in exports as well?
I'm trying to come up with the best possible solution; since it's only really one text string (like in your example). Linked sets or something like that don't make sense, and I noticed the count_min and count_max are not implemented either.
It depends on the type of exports. You would have to overload GetAsXML and GetAsCSV as well.
Thanks. I got it working for the details page and the lists of a Class; also just made it track no changes; and it seems to hide it when previewing and actually exporting to CSV.
When exporting to Excel, I still see the value in the on-screen preview in iTop.
For some reason (maybe because of my GetAsXML()), the export just fails.
Not sure what to return there, I thought just "" or return Str::pure2xml((string)"";
Do you have an error message on your browser / error log ?
No error message in the backend.
In the frontend, it just says the export failed (I also tried it with only one column, same result, only happens when exporting to Excel/PDF. CSV is fine.) The preview works fine.
I removed all extensions related to "person", still an error.
Could it be a Windows / XAMPP issue instead, are any special permissions needed to create Excel files on Windows / XAMPP ?
Guillaume, could you give me an example please of what the GetAsXML() method should return?
Which ones do I need to override for Excel, PDF?
Hi Jeffrey,
Sorry it's been a long time since you asked, but you may take a look at the new AttributeSet / AttributeTagSet classes that were introduced in 2.6.0
Thanks for bumping the thread. How exactly should these attribute types help, Pierre? :)
I still need to investigate this; the only other option I've considered so far is storing that one field which is more sensitive (GDPR) in a separate class instead.
Because we had to implement exactly all of those methods :)
Last edit: Pierre Goiffon 2019-02-04
It's still not very clear to me how exactly the AttributeTagSet would help though?
I was reacting to your question about GetAsXML method... but right, this may not be of a great help
Sorry to bump this, but I assume the issue starts here:
https://github.com/Combodo/iTop/blob/96334d859aaa695aa128fe562256dad1cd6603cf/application/excelexporter.class.inc.php#L196
So, I'd either need to be able to overwrite that class; or the
GetEditValue()
methods of AttributeDefinition?Or would it be better to create a custom AttributeDefinition for this attribute instead?