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 | isRBACOperation ($a_type_id, $a_ops_id) |
| Check if rbac operation exists. 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 | cloneOperation ($a_obj_type, $a_source_op_id, $a_target_op_id) |
| Clone RBAC-settings between operations. 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 323 of file class.ilDBUpdateNewObjectType.php.
References $ilDB, and $ref_id.
327 if(self::getObjectTypeId($a_obj_type))
332 $obj_type_id = self::addNewType($a_obj_type, $a_title);
334 $obj_id = $ilDB->nextId(
'object_data');
335 $ilDB->manipulate(
"INSERT INTO object_data ".
336 "(obj_id, type, title, description, owner, create_date, last_update) VALUES (".
337 $ilDB->quote($obj_id,
"integer").
",".
338 $ilDB->quote($a_obj_type,
"text").
",".
339 $ilDB->quote($a_title,
"text").
",".
340 $ilDB->quote($a_title,
"text").
",".
341 $ilDB->quote(-1,
"integer").
",".
346 $ref_id = $ilDB->nextId(
'object_reference');
347 $ilDB->manipulate(
"INSERT INTO object_reference ".
348 "(obj_id, ref_id) VALUES (".
349 $ilDB->quote($obj_id,
"integer").
",".
350 $ilDB->quote(
$ref_id,
"integer").
354 $tree =
new ilTree(ROOT_FOLDER_ID);
355 $tree->insertNode(
$ref_id, SYSTEM_FOLDER_ID);
358 self::RBAC_OP_EDIT_PERMISSIONS,
359 self::RBAC_OP_VISIBLE,
363 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 228 of file class.ilDBUpdateNewObjectType.php.
References $ilDB.
233 $ops_id = self::getCustomRBACOperationId($a_id);
239 if(!in_array($a_class, array(
'create',
'object',
'general')))
243 if($a_class ==
'create')
248 $ops_id = $ilDB->nextId(
'rbac_operations');
251 'ops_id' => array(
'integer', $ops_id),
252 'operation' => array(
'text', $a_id),
253 'description' => array(
'text', $a_title),
254 'class' => array(
'text', $a_class),
255 'op_order' => array(
'integer', $a_pos),
257 $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 $ilDB, and 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 287 of file class.ilDBUpdateNewObjectType.php.
289 $ops_id = self::addCustomRBACOperation($a_id, $a_title,
'create', 9999);
291 foreach($a_parent_types as $type)
293 $type_id = self::getObjectTypeId($type);
296 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.
References $ilDB.
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);
◆ cloneOperation()
static ilDBUpdateNewObjectType::cloneOperation |
( |
|
$a_obj_type, |
|
|
|
$a_source_op_id, |
|
|
|
$a_target_op_id |
|
) |
| |
|
static |
Clone RBAC-settings between operations.
- Parameters
-
string | $a_obj_type | |
int | $a_source_op_id | |
int | $a_target_op_id | |
Definition at line 373 of file class.ilDBUpdateNewObjectType.php.
References $ilDB, and $row.
378 $sql =
"SELECT rpa.*".
380 " JOIN object_reference ref ON (ref.ref_id = rpa.ref_id)".
381 " JOIN object_data od ON (od.obj_id = ref.obj_id AND od.type = ".$ilDB->quote($a_obj_type).
")".
383 " WHERE (".$ilDB->like(
"ops_id",
"text",
"%i:".$a_source_op_id.
"%").
384 " OR ".$ilDB->like(
"ops_id",
"text",
"%:\"".$a_source_op_id.
"\";%").
")";
385 $set = $ilDB->query($sql);
386 while(
$row = $ilDB->fetchAssoc($set))
388 $ops = unserialize(
$row[
"ops_id"]);
390 if(in_array($a_source_op_id, $ops) && !in_array($a_target_op_id, $ops))
392 $ops[] = $a_target_op_id;
394 $ilDB->manipulate(
"UPDATE rbac_pa".
395 " SET ops_id = ".$ilDB->quote(serialize($ops),
"text").
396 " WHERE rol_id = ".$ilDB->quote(
$row[
"rol_id"],
"integer").
397 " AND ref_id = ".$ilDB->quote(
$row[
"ref_id"],
"integer"));
403 $sql =
"SELECT rol_id, parent, ops_id".
404 " FROM rbac_templates".
405 " WHERE type = ".$ilDB->quote($a_obj_type,
"text").
406 " AND (ops_id = ".$ilDB->quote($a_source_op_id,
"integer").
407 " OR ops_id = ".$ilDB->quote($a_target_op_id).
")";
408 $set = $ilDB->query($sql);
409 while(
$row = $ilDB->fetchAssoc($set))
411 $tmp[
$row[
"rol_id"]][
$row[
"parent"]][] = $row[
"ops_id"];
414 foreach($tmp as $role_id => $parents)
416 foreach($parents as $parent_id => $ops_ids)
419 if(
sizeof($ops_ids) < 2 && in_array($a_source_op_id, $ops_ids))
421 $ilDB->manipulate(
"INSERT INTO rbac_templates".
422 " (rol_id, type, ops_id, parent)".
424 "(".$ilDB->quote($role_id,
"integer").
425 ",".$ilDB->quote($a_obj_type,
"text").
426 ",".$ilDB->quote($a_target_op_id,
"integer").
427 ",".$ilDB->quote($parent_id,
"integer").
◆ deleteRBACOperation()
static ilDBUpdateNewObjectType::deleteRBACOperation |
( |
|
$a_type, |
|
|
|
$a_ops_id |
|
) |
| |
|
static |
Delete rbac operation.
- Parameters
-
Definition at line 132 of file class.ilDBUpdateNewObjectType.php.
References $GLOBALS, $ilDB, and $query.
136 if(!$a_type || !$a_ops_id)
141 $type_id = self::getObjectTypeId($a_type);
147 $query =
'DELETE FROM rbac_ta WHERE '.
148 'typ_id = '.$ilDB->quote($type_id,
'integer').
' AND '.
149 'ops_id = '.$ilDB->quote($a_ops_id,
'integer');
151 $ilDB->manipulate(
$query);
153 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 162 of file class.ilDBUpdateNewObjectType.php.
References $GLOBALS, $ilDB, and $query.
166 if(!$a_type || !$a_ops_id)
171 $query =
'DELETE FROM rbac_templates WHERE '.
172 'type = '.$ilDB->quote($a_type,
'text').
' AND '.
173 'ops_id = '.$ilDB->quote($a_ops_id,
'integer');
175 $ilDB->manipulate(
$query);
◆ getCustomRBACOperationId()
static ilDBUpdateNewObjectType::getCustomRBACOperationId |
( |
|
$a_operation | ) |
|
|
static |
Get id of RBAC operation.
- Parameters
-
- Returns
- int
Definition at line 207 of file class.ilDBUpdateNewObjectType.php.
References $ilDB, $res, and $row.
211 $sql =
'SELECT ops_id'.
212 ' FROM rbac_operations'.
213 ' WHERE operation = '.$ilDB->quote($a_operation,
'text');
214 $res = $ilDB->query($sql);
216 return $row[
'ops_id'];
◆ getObjectTypeId()
static ilDBUpdateNewObjectType::getObjectTypeId |
( |
|
$a_type | ) |
|
|
static |
Get id for object data type entry.
- Parameters
-
- Returns
- int
Definition at line 268 of file class.ilDBUpdateNewObjectType.php.
References $ilDB, $res, and $row.
272 $sql =
'SELECT obj_id FROM object_data'.
273 ' WHERE type = '.$ilDB->quote(
'typ',
'text').
274 ' AND title = '.$ilDB->quote($a_type,
'text');
275 $res = $ilDB->query($sql);
277 return $row[
'obj_id'];
◆ isRBACOperation()
static ilDBUpdateNewObjectType::isRBACOperation |
( |
|
$a_type_id, |
|
|
|
$a_ops_id |
|
) |
| |
|
static |
Check if rbac operation exists.
- Parameters
-
int | $a_type_id | type id |
int | $a_ops_id | operation id |
- Returns
- bool
Definition at line 111 of file class.ilDBUpdateNewObjectType.php.
References $ilDB.
116 $set = $ilDB->query(
'SELECT * FROM rbac_ta' .
117 ' WHERE typ_id = ' . $ilDB->quote($a_type_id,
'integer') .
118 ' AND ops_id = ' . $ilDB->quote($a_ops_id,
'integer'));
119 if ($ilDB->numRows($set))
◆ isValidRBACOperation()
static ilDBUpdateNewObjectType::isValidRBACOperation |
( |
|
$a_ops_id | ) |
|
|
staticprotected |
Check if given RBAC operation id is valid.
- Parameters
-
- Returns
- bool
Definition at line 184 of file class.ilDBUpdateNewObjectType.php.
References $valid.
187 self::RBAC_OP_EDIT_PERMISSIONS,
188 self::RBAC_OP_VISIBLE,
191 self::RBAC_OP_DELETE,
194 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 307 of file class.ilDBUpdateNewObjectType.php.
References $ilDB.
311 $ilDB->update(
'rbac_operations',
312 array(
'op_order' => array(
'integer', $a_pos)),
313 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 441 of file class.ilDBUpdateNewObjectType.php.
References $ilDB, and ilDB\LOCK_WRITE.
445 $tmp_column_name = $a_column_name.
"_tmp_clob";
447 if(!$ilDB->tableColumnExists($a_table_name, $a_column_name) ||
448 $ilDB->tableColumnExists($a_table_name, $tmp_column_name))
455 $ilDB->lockTables(array(
463 $ilDB->addTableColumn($a_table_name, $tmp_column_name, $def);
465 $ilDB->manipulate(
'UPDATE '.$a_table_name.
' SET '.$tmp_column_name.
' = '.$a_column_name);
467 $ilDB->dropTableColumn($a_table_name, $a_column_name);
469 $ilDB->renameTableColumn($a_table_name, $tmp_column_name, $a_column_name);
471 $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: