1283 Posts
Bucklash
7 years ago
Topic

Hi folks

At the risk of sounding lazy, 

Has anyone got an example of how to access and manipulate  #__assets.rules, ie in a beforestore event?

An example of the field I am talking about would be ' art_rules',

It's field 393, FYI....

Any examples would be great like change 

{"core.admin":{"7":1},"core.manage":{"7":1}} 
to...  	<br>
...this
{"core.admin":{"12":1},"core.manage":{"5":1},"core.funky":{"12":1}}

Thanks or any tips 

Get a VIP membership
4229 Posts
Kadministrator
7 years ago
6
Level 1

asset rules are json encoded so you would need to read it, unpack it, manipulate reulting object, it encode back to json and store.

1283 Posts
Bucklash
7 years ago
5
Level 2

Hi Klas

Thanks for that.

1283 Posts
Bucklash
7 years ago
4
Level 3

To make sure you grab a string from db and process it using JSON yo have to wrap the string in double quotes.

I grabbed a #__assets.rule value from db using sql query for live value on the art_alias field.

I then wrapped this value in double quotes to achieve success

$alias = '"'.$fields['art_alias']->value.'"';
$jsonalias = json_decode($alias);
var_dump($jsonalias);
1283 Posts
Bucklash
7 years ago
3
Level 4

Hello

Back to this again...

So using JCckContentJoomla_Article.... is 'rules' applicable there?:

$newData = new JCckContentJoomla_Article;

$addData = $newData->create(
  'some_content_type',
  $columns(
     'title' => 'My Title, .... 
     'rules' => '{"core.delete":[],"core.edit":[],"core.edit.state":[]}'
  ),
  $columnsMore(stuff...),
  $columnsMore2(stuff...)
);

If it is, I am not sure what I am doing incorrectly, I end up with '{}' no matter what and I have checked that  do have a JSON string to store.... hmmm

4229 Posts
Kadministrator
7 years ago
2
Level 5

try passing it as an object, not as json string

1283 Posts
Bucklash
7 years ago
1
Level 6

Hi Klas

Tried that and no joy... if it is not a possibility at least I know

Jon

1283 Posts
Bucklash
7 years ago
0
Level 7
Get a Book for SEBLOD