Is it possible to bind a policy to a class attribute in the eZ Publish 4.7 admin interface - ezpublish

I wanted to know if it's possible to allow a user to fill (and edit) a class attribute (field within a class) only if he has a specific role.
A simple example :
I give the role "Classic" to user "A" which allow him to create a class Article and fill the attributes "Title" and "Author".
Now if I give the role "Premium" to user "B", I want him to be able to create the same class Article and fill the attributes "Title", "Author" AND "Description".
My problem is that I can't find anything related to class attribute when I create a policy...
Any idea on how to proceed ?

You can create an override template for edit view of article (via override.ini.append.php file). In this template you will display only allowed attributes, filtering by user role.
So, you can configure roles and attributes mapping in a ini file.

Related

Is there any out of box SNOW(Service Now) api to create catalog item and its variables?

For e.g. , I want to create a catalog items under a category named "Backpack".Let's say I want to create a "Catalog Item" named "American Tourister" under the "Category" named "Backpack".I want to add the attributes like "colour","type" of these catalog items in the form of "Variables".
I have these values stored in my database.And data gets add up in the incremental form in database.
Is there any "Out of the Box API" in ServiceNow to create "Catalog Item" and its "Variables" using that out of box api,so that I can create catalog item and variables using data in my database.
For the latest 2 version (Jakarta and Istanbul) yes there is a set of classes for creating and manipulating catalog items, catalog categories, variable sets and variables, (CatItem, CatCategory, CatalogItemVariable, CatalogItemVariableSet, CatalogItemVariableSetM2M) please visit the official documentation for the server side APIs
I don't know about the other version but in case they are not there you can still make use of the GlideRecord API to manually do all this stuff, for example:
var catItemGr = new GlideRecord('sc_cat_item');
catItemGr.initialize();
catItemGr.setValue('name', 'American Tourister');
catItemGr.setValue('short_description', 'American Tourister Stuff');
catItemGr.setValue('category', 'sys_id for the category Backpack');
catItemGr.insert();
The above snippet can be used to create a new catalog item programmatically, you can set up the variables, variable sets and the relations using the same way
Via the REST API Explorer you can use the Namespace sn_sc to access the Service Catalog API.
Use this path to get to it:
https://.service-now.com/$restapi.do?ns=sn_sc&service=Service Catalog API&version=v1
You'll find the available operations on this page.

Odoo 8 declare view file programmatically

I want to declare my view file that its struct is loaded from database. I know in order I have to declare it on openerp.py file. But I have many user, and I want each of theme when access to my module (form view - for instance) will have difference view (fields), I am mentions to fields on database, not by "how to hide some fields for some user?". Is there any solution for this? Thanks
You can use Field Access Right.
As of OpenERP 7.0, you can create field level access rights. You can achieve this by adding the groups attribute in your field definition in the module:
_columns = { 'my_field': fields.char('My field', groups="base.group_erp_manager,base.group_system") }`
It's still valid in Odoo 8. Check Odoo documentation about security
https://www.odoo.com/documentation/8.0/reference/security.html
There is one solution I'm thinking of but haven't try it yet:
Override _views_get_fnc in 'ir.actions.act_window' model. This function return {action_id: (view_id, view_mode)}. Here you can query for view_id based on the user.

how to create an ajax-driven auto-complete field in a sonata admin form in symfony?

I have a form generated with the sonata admin bundle. I want to enable a live search tip for my user on an input field. The proposition should come from a category table in the DB.
For example, if I have a field called company, when a user writes "a", I should suggest all companies whose name contains "a".
Use JQuery Autocomplete. On server side create controller action that will return suggestions through AJAX.
See example - http://jqueryui.com/autocomplete/#remote-jsonp

Dynamically add input boxes to an edit form in joomla 2.5

I followed this tutorial on how to build a component for joomla 2.5, but now I am stuck.
What I want to do:
Besided thoses field defined in admin\models\forms\.xml I want to dynamically add form fields. The field list should be read from database.
I have a:
main table #__tours(id, title),
field list table #__tourfields(id,lable,description,position)
field value table #__tourfieldvalues(tourid,fieldid,fieldvalue)
#__tourfields contains a list of additional fields, that the user may want to specify for each entry in #__tours. #__tourfieldvalues would contain the values for the additional fields.
So now I need to figure out how to add input boxes to the edit form for each row in #__tourfields, read the values in #__tourfieldvalues for the currently to display entry of #__tours.
How can I do this?
This is very complex question. Subject to small book :)
In general you have to create class for every field type and initiate this class for every field in #__tourfields. This class have to extend JFormField and have getInput() method overridden.
Then in cycle you fetch your fields.
Something like this. But I believe you have to have more specific question. This one sounds like "How to create CMS like Joomla from scratch?"

.NET MVC 3 Validation

I use Entity framework for creating model.
I have table hierarchy where User is my base table and I have tables Lecturer and Student which have some specific data in them. Entity framework made model that it isn't suitable so I made my middle layer called modelview where I have student table which wraps all data from both user and student tables. I have made CRUD functionality for students but I only want that admin can create student with some initial password, than admin should not have option to change student password at Edit action.
The problem is that password is required field at student Create action so I set [Required] attribute to it, but at Edit I must not have password field and my ModelState.IsValid is then always false since password field in this case isn't present and therefore is null.
I thought on adding hidden password field, but that would be very bad since someone could look at page source and see password value.
Can I somehow once this field required and another time not required?
If you have any other idea that might help please share with me.
When a user is being edited, you can put in a placeholder hidden field, with the value * (or something like that). This will satisfy the Required attribute - you just have to make sure you don't update the password when the user is edited :)
Maybe you could randomly generate a password and not have it be required at all.
Or you could remove the requred attribute and manually check if it's present at the serverside.
if (string.IsNullOrEmpty(user.Password))
ModelState.AddModelError("Password","A password is required");
To validate clientside, if you're using jquery validation: JQuery Docs
If you have separate views for Student addition and editing, an alternative solution would be:
Create a StudentViewModel class which contains all the properties required for both Student addition and editing, and
Create a StudentAdditionViewModel class (optionally derived from StudentViewModel) which includes a Password property.
You can then use StudentAdditionViewModel as the Add view's model, and StudentViewModel as the edit view's model :)

Resources