Helper class to create new object types (object_data, RBAC)
More...
|
static | addNewType ($a_type_id, $a_type_title) |
| Add new type to object data. More...
|
|
static | addRBACOperations ($a_type_id, array $a_operations) |
| Add RBAC operations for type. More...
|
|
static | addRBACOperation ($a_type_id, $a_ops_id) |
| Add RBAC operation. More...
|
|
static | deleteRBACOperation ($a_type, $a_ops_id) |
| Delete rbac operation. More...
|
|
static | deleteRBACTemplateOperation ($a_type, $a_ops_id) |
| Delete operation for type in templates. More...
|
|
static | getCustomRBACOperationId ($a_operation) |
| Get id of RBAC operation. More...
|
|
static | addCustomRBACOperation ($a_id, $a_title, $a_class, $a_pos) |
| Add custom RBAC operation. More...
|
|
static | getObjectTypeId ($a_type) |
| Get id for object data type entry. More...
|
|
static | addRBACCreate ($a_id, $a_title, array $a_parent_types) |
| Add create RBAC operations for parent object types. More...
|
|
static | updateOperationOrder ($a_operation, $a_pos) |
| Change order of operations. More...
|
|
static | addAdminNode ($a_obj_type, $a_title) |
| Create new admin object node. More...
|
|
static | varchar2text ($a_table_name, $a_column_name) |
| Migrate varchar column to text/clob. More...
|
|
Helper class to create new object types (object_data, RBAC)
- Author
- Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
- Id
- class.ilObjFolderGUI.php 25134 2010-08-13 14:22:11Z smeyer
Definition at line 13 of file class.ilDBUpdateNewObjectType.php.
◆ addAdminNode()
static ilDBUpdateNewObjectType::addAdminNode |
( |
|
$a_obj_type, |
|
|
|
$a_title |
|
) |
| |
|
static |
Create new admin object node.
- Parameters
-
string | $a_id | |
string | $a_title | |
Definition at line 301 of file class.ilDBUpdateNewObjectType.php.
References $ref_id.
305 if(self::getObjectTypeId($a_obj_type))
310 $obj_type_id = self::addNewType($a_obj_type, $a_title);
312 $obj_id = $ilDB->nextId(
'object_data');
313 $ilDB->manipulate(
"INSERT INTO object_data ".
314 "(obj_id, type, title, description, owner, create_date, last_update) VALUES (".
315 $ilDB->quote($obj_id,
"integer").
",".
316 $ilDB->quote($a_obj_type,
"text").
",".
317 $ilDB->quote($a_title,
"text").
",".
318 $ilDB->quote($a_title,
"text").
",".
319 $ilDB->quote(-1,
"integer").
",".
324 $ref_id = $ilDB->nextId(
'object_reference');
325 $ilDB->manipulate(
"INSERT INTO object_reference ".
326 "(obj_id, ref_id) VALUES (".
327 $ilDB->quote($obj_id,
"integer").
",".
328 $ilDB->quote(
$ref_id,
"integer").
332 $tree =
new ilTree(ROOT_FOLDER_ID);
333 $tree->insertNode(
$ref_id, SYSTEM_FOLDER_ID);
336 self::RBAC_OP_EDIT_PERMISSIONS,
337 self::RBAC_OP_VISIBLE,
341 self::addRBACOperations($obj_type_id, $rbac_ops);
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
◆ addCustomRBACOperation()
static ilDBUpdateNewObjectType::addCustomRBACOperation |
( |
|
$a_id, |
|
|
|
$a_title, |
|
|
|
$a_class, |
|
|
|
$a_pos |
|
) |
| |
|
static |
Add custom RBAC operation.
- Parameters
-
string | $a_id | |
string | $a_title | |
string | $a_class | |
string | $a_pos | |
- Returns
- int ops_id
Definition at line 206 of file class.ilDBUpdateNewObjectType.php.
211 $ops_id = self::getCustomRBACOperationId($a_id);
217 if(!in_array($a_class, array(
'create',
'object',
'general')))
221 if($a_class ==
'create')
226 $ops_id = $ilDB->nextId(
'rbac_operations');
229 'ops_id' => array(
'integer', $ops_id),
230 'operation' => array(
'text', $a_id),
231 'description' => array(
'text', $a_title),
232 'class' => array(
'text', $a_class),
233 'op_order' => array(
'integer', $a_pos),
235 $ilDB->insert(
'rbac_operations', $fields);
◆ addNewType()
static ilDBUpdateNewObjectType::addNewType |
( |
|
$a_type_id, |
|
|
|
$a_type_title |
|
) |
| |
|
static |
Add new type to object data.
- Parameters
-
string | $a_type_id | |
string | $a_type_title | |
- Returns
- int insert id
Definition at line 29 of file class.ilDBUpdateNewObjectType.php.
References ilUtil\now().
34 $type_id = self::getObjectTypeId($a_type_id);
40 $type_id = $ilDB->nextId(
'object_data');
43 'obj_id' => array(
'integer', $type_id),
44 'type' => array(
'text',
'typ'),
45 'title' => array(
'text', $a_type_id),
46 'description' => array(
'text', $a_type_title),
47 'owner' => array(
'integer', -1),
51 $ilDB->insert(
'object_data', $fields);
static now()
Return current timestamp in Y-m-d H:i:s format.
◆ addRBACCreate()
static ilDBUpdateNewObjectType::addRBACCreate |
( |
|
$a_id, |
|
|
|
$a_title, |
|
|
array |
$a_parent_types |
|
) |
| |
|
static |
Add create RBAC operations for parent object types.
- Parameters
-
string | $a_id | |
string | $a_title | |
array | $a_parent_types | |
Definition at line 265 of file class.ilDBUpdateNewObjectType.php.
267 $ops_id = self::addCustomRBACOperation($a_id, $a_title,
'create', 9999);
269 foreach($a_parent_types as $type)
271 $type_id = self::getObjectTypeId($type);
274 self::addRBACOperation($type_id, $ops_id);
◆ addRBACOperation()
static ilDBUpdateNewObjectType::addRBACOperation |
( |
|
$a_type_id, |
|
|
|
$a_ops_id |
|
) |
| |
|
static |
Add RBAC operation.
- Parameters
-
int | $a_type_id | |
int | $a_ops_id | |
Definition at line 84 of file class.ilDBUpdateNewObjectType.php.
89 $set = $ilDB->query(
'SELECT * FROM rbac_ta'.
90 ' WHERE typ_id = '.$ilDB->quote($a_type_id,
'integer').
91 ' AND ops_id = '.$ilDB->quote($a_ops_id,
'integer'));
92 if($ilDB->numRows($set))
98 'typ_id' => array(
'integer', $a_type_id),
99 'ops_id' => array(
'integer', $a_ops_id)
101 return $ilDB->insert(
'rbac_ta', $fields);
◆ addRBACOperations()
static ilDBUpdateNewObjectType::addRBACOperations |
( |
|
$a_type_id, |
|
|
array |
$a_operations |
|
) |
| |
|
static |
Add RBAC operations for type.
- Parameters
-
int | $a_type_id | |
array | $a_operations | |
Definition at line 62 of file class.ilDBUpdateNewObjectType.php.
64 foreach($a_operations as $ops_id)
66 if(self::isValidRBACOperation($ops_id))
68 if($ops_id == self::RBAC_OP_COPY)
70 $ops_id = self::getCustomRBACOperationId(
'copy');
73 self::addRBACOperation($a_type_id, $ops_id);
◆ deleteRBACOperation()
static ilDBUpdateNewObjectType::deleteRBACOperation |
( |
|
$a_type, |
|
|
|
$a_ops_id |
|
) |
| |
|
static |
Delete rbac operation.
- Parameters
-
Definition at line 110 of file class.ilDBUpdateNewObjectType.php.
References $GLOBALS, and $query.
114 if(!$a_type || !$a_ops_id)
119 $type_id = self::getObjectTypeId($a_type);
125 $query =
'DELETE FROM rbac_ta WHERE '.
126 'typ_id = '.$ilDB->quote($type_id,
'integer').
' AND '.
127 'ops_id = '.$ilDB->quote($a_ops_id,
'integer');
129 $ilDB->manipulate(
$query);
131 self::deleteRBACTemplateOperation($a_type, $a_ops_id);
◆ deleteRBACTemplateOperation()
static ilDBUpdateNewObjectType::deleteRBACTemplateOperation |
( |
|
$a_type, |
|
|
|
$a_ops_id |
|
) |
| |
|
static |
Delete operation for type in templates.
- Parameters
-
string | $a_type | |
int | $a_ops_id | |
Definition at line 140 of file class.ilDBUpdateNewObjectType.php.
References $GLOBALS, and $query.
144 if(!$a_type || !$a_ops_id)
149 $query =
'DELETE FROM rbac_templates WHERE '.
150 'type = '.$ilDB->quote($a_type,
'text').
' AND '.
151 'ops_id = '.$ilDB->quote($a_ops_id,
'integer');
153 $ilDB->manipulate(
$query);
◆ getCustomRBACOperationId()
static ilDBUpdateNewObjectType::getCustomRBACOperationId |
( |
|
$a_operation | ) |
|
|
static |
Get id of RBAC operation.
- Parameters
-
- Returns
- int
Definition at line 185 of file class.ilDBUpdateNewObjectType.php.
References $res, and $row.
189 $sql =
'SELECT ops_id'.
190 ' FROM rbac_operations'.
191 ' WHERE operation = '.$ilDB->quote($a_operation,
'text');
192 $res = $ilDB->query($sql);
194 return $row[
'ops_id'];
◆ getObjectTypeId()
static ilDBUpdateNewObjectType::getObjectTypeId |
( |
|
$a_type | ) |
|
|
static |
Get id for object data type entry.
- Parameters
-
- Returns
- int
Definition at line 246 of file class.ilDBUpdateNewObjectType.php.
References $res, and $row.
250 $sql =
'SELECT obj_id FROM object_data'.
251 ' WHERE type = '.$ilDB->quote(
'typ',
'text').
252 ' AND title = '.$ilDB->quote($a_type,
'text');
253 $res = $ilDB->query($sql);
255 return $row[
'obj_id'];
◆ isValidRBACOperation()
static ilDBUpdateNewObjectType::isValidRBACOperation |
( |
|
$a_ops_id | ) |
|
|
staticprotected |
Check if given RBAC operation id is valid.
- Parameters
-
- Returns
- bool
Definition at line 162 of file class.ilDBUpdateNewObjectType.php.
References $valid.
165 self::RBAC_OP_EDIT_PERMISSIONS,
166 self::RBAC_OP_VISIBLE,
169 self::RBAC_OP_DELETE,
172 if(in_array($a_ops_id,
$valid))
◆ updateOperationOrder()
static ilDBUpdateNewObjectType::updateOperationOrder |
( |
|
$a_operation, |
|
|
|
$a_pos |
|
) |
| |
|
static |
Change order of operations.
- Parameters
-
string | $a_operation | |
int | $a_pos | |
Definition at line 285 of file class.ilDBUpdateNewObjectType.php.
289 $ilDB->update(
'rbac_operations',
290 array(
'op_order' => array(
'integer', $a_pos)),
291 array(
'operation' => array(
'text', $a_operation))
◆ varchar2text()
static ilDBUpdateNewObjectType::varchar2text |
( |
|
$a_table_name, |
|
|
|
$a_column_name |
|
) |
| |
|
static |
Migrate varchar column to text/clob.
- Parameters
-
string | $a_table_name | |
string | $a_column_name | |
- Returns
- bool
Definition at line 351 of file class.ilDBUpdateNewObjectType.php.
References ilDB\LOCK_WRITE.
355 $tmp_column_name = $a_column_name.
"_tmp_clob";
357 if(!$ilDB->tableColumnExists($a_table_name, $a_column_name) ||
358 $ilDB->tableColumnExists($a_table_name, $tmp_column_name))
365 $ilDB->lockTables(array(
373 $ilDB->addTableColumn($a_table_name, $tmp_column_name, $def);
375 $ilDB->manipulate(
'UPDATE '.$a_table_name.
' SET '.$tmp_column_name.
' = '.$a_column_name);
377 $ilDB->dropTableColumn($a_table_name, $a_column_name);
379 $ilDB->renameTableColumn($a_table_name, $tmp_column_name, $a_column_name);
381 $ilDB->unlockTables();
◆ RBAC_OP_COPY
const ilDBUpdateNewObjectType::RBAC_OP_COPY = 99 |
◆ RBAC_OP_DELETE
const ilDBUpdateNewObjectType::RBAC_OP_DELETE = 6 |
◆ RBAC_OP_EDIT_PERMISSIONS
const ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS = 1 |
◆ RBAC_OP_READ
const ilDBUpdateNewObjectType::RBAC_OP_READ = 3 |
◆ RBAC_OP_VISIBLE
const ilDBUpdateNewObjectType::RBAC_OP_VISIBLE = 2 |
◆ RBAC_OP_WRITE
const ilDBUpdateNewObjectType::RBAC_OP_WRITE = 4 |
The documentation for this class was generated from the following file: