Create role using php

Author Message

Tamaki Hodge

Sunday 01 October 2006 8:52:00 pm

Hi,

Does anyone know how to create a role programmatically using php?

Thanks.

Ɓukasz Serwatka

Sunday 01 October 2006 11:27:03 pm

Hi Tamaki,

Take a look on kernel/classes/ezrole.php class definition.

$role = eZRole::create( 'Role name' );
$role->store();

Related classes are also:
kernel/classes/ezpolicy.php
kernel/classes/ezpolicylimitation.php

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Tamaki Hodge

Monday 02 October 2006 3:23:03 pm

Thanks Lukasz,

I managed to get something going.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 22:17:21
Script start
Timing: Jan 18 2025 22:17:21
Module start 'layout'
Timing: Jan 18 2025 22:17:21
Module start 'content'
Timing: Jan 18 2025 22:17:21
Module end 'content'
Timing: Jan 18 2025 22:17:21
Script end

Main resources:

Total runtime0.0140 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 589.0234152.6250
Module start 'layout' 0.00580.0027 741.648439.4453
Module start 'content' 0.00840.0037 781.093889.4297
Module end 'content' 0.01220.0018 870.523430.3047
Script end 0.0139  900.8281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002316.1861140.0002
Check MTime0.00107.4867140.0001
Mysql Total
Database connection0.00074.822010.0007
Mysqli_queries0.002618.592930.0009
Looping result0.00000.136610.0000
Template Total0.001410.410.0014
Template load0.00075.360110.0007
Template processing0.00074.979210.0007
Override
Cache load0.00053.474310.0005
General
dbfile0.00021.373380.0000
String conversion0.00000.063240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs