ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilDBUpdateNewObjectType Class Reference

Helper class to create new object types (object_data, RBAC) More...

+ Collaboration diagram for ilDBUpdateNewObjectType:

Static Public Member Functions

static addNewType ($a_type_id, $a_type_title)
 Add new type to object data.
static addRBACOperations ($a_type_id, array $a_operations)
 Add RBAC operations for type.
static addRBACOperation ($a_type_id, $a_ops_id)
 Add RBAC operation.
static deleteRBACOperation ($a_type, $a_ops_id)
 Delete rbac operation.
static deleteRBACTemplateOperation ($a_type, $a_ops_id)
 Delete operation for type in templates.
static getCustomRBACOperationId ($a_operation)
 Get id of RBAC operation.
static addCustomRBACOperation ($a_id, $a_title, $a_class, $a_pos)
 Add custom RBAC operation.
static getObjectTypeId ($a_type)
 Get id for object data type entry.
static addRBACCreate ($a_id, $a_title, array $a_parent_types)
 Add create RBAC operations for parent object types.
static updateOperationOrder ($a_operation, $a_pos)
 Change order of operations.
static varchar2text ($a_table_name, $a_column_name)
 Migrate varchar column to text/clob.

Data Fields

const RBAC_OP_EDIT_PERMISSIONS = 1
const RBAC_OP_VISIBLE = 2
const RBAC_OP_READ = 3
const RBAC_OP_WRITE = 4
const RBAC_OP_DELETE = 6
const RBAC_OP_COPY = 99

Static Protected Member Functions

static isValidRBACOperation ($a_ops_id)
 Check if given RBAC operation id is valid.

Detailed Description

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.

Member Function Documentation

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.

References getCustomRBACOperationId().

Referenced by addRBACCreate().

{
global $ilDB;
// check if it already exists
if($ops_id)
{
return $ops_id;
}
if(!in_array($a_class, array('create', 'object', 'general')))
{
return;
}
if($a_class == 'create')
{
$a_pos = 9999;
}
$ops_id = $ilDB->nextId('rbac_operations');
$fields = array(
'ops_id' => array('integer', $ops_id),
'operation' => array('text', $a_id),
'description' => array('text', $a_title),
'class' => array('text', $a_class),
'op_order' => array('integer', $a_pos),
);
$ilDB->insert('rbac_operations', $fields);
return $ops_id;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 getObjectTypeId(), and ilUtil\now().

{
global $ilDB;
// check if it already exists
$type_id = self::getObjectTypeId($a_type_id);
if($type_id)
{
return $type_id;
}
$type_id = $ilDB->nextId('object_data');
$fields = array(
'obj_id' => array('integer', $type_id),
'type' => array('text', 'typ'),
'title' => array('text', $a_type_id),
'description' => array('text', $a_type_title),
'owner' => array('integer', -1),
'create_date' => array('timestamp', ilUtil::now()),
'last_update' => array('timestamp', ilUtil::now())
);
$ilDB->insert('object_data', $fields);
return $type_id;
}

+ Here is the call graph for this function:

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.

References addCustomRBACOperation(), addRBACOperation(), and getObjectTypeId().

{
$ops_id = self::addCustomRBACOperation($a_id, $a_title, 'create', 9999);
foreach($a_parent_types as $type)
{
$type_id = self::getObjectTypeId($type);
if($type_id)
{
self::addRBACOperation($type_id, $ops_id);
}
}
}

+ Here is the call graph for this function:

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.

Referenced by addRBACCreate(), and addRBACOperations().

{
global $ilDB;
// check if it already exists
$set = $ilDB->query('SELECT * FROM rbac_ta'.
' WHERE typ_id = '.$ilDB->quote($a_type_id, 'integer').
' AND ops_id = '.$ilDB->quote($a_ops_id, 'integer'));
if($ilDB->numRows($set))
{
return;
}
$fields = array(
'typ_id' => array('integer', $a_type_id),
'ops_id' => array('integer', $a_ops_id)
);
return $ilDB->insert('rbac_ta', $fields);
}

+ Here is the caller graph for this function:

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.

References addRBACOperation(), and getCustomRBACOperationId().

{
foreach($a_operations as $ops_id)
{
if(self::isValidRBACOperation($ops_id))
{
if($ops_id == self::RBAC_OP_COPY)
{
$ops_id = self::getCustomRBACOperationId('copy');
}
self::addRBACOperation($a_type_id, $ops_id);
}
}
}

+ Here is the call graph for this function:

static ilDBUpdateNewObjectType::deleteRBACOperation (   $a_type,
  $a_ops_id 
)
static

Delete rbac operation.

Parameters
int$a_type
int$a_ops_id

Definition at line 110 of file class.ilDBUpdateNewObjectType.php.

References $GLOBALS, $query, deleteRBACTemplateOperation(), and getObjectTypeId().

{
global $ilDB;
if(!$a_type || !$a_ops_id)
{
return;
}
$type_id = self::getObjectTypeId($a_type);
if(!$type_id)
{
return;
}
$query = 'DELETE FROM rbac_ta WHERE '.
'typ_id = '.$ilDB->quote($type_id,'integer').' AND '.
'ops_id = '.$ilDB->quote($a_ops_id,'integer');
$GLOBALS['ilLog']->write(__METHOD__.': '.$query);
$ilDB->manipulate($query);
self::deleteRBACTemplateOperation($a_type, $a_ops_id);
}

+ Here is the call graph for this function:

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.

Referenced by deleteRBACOperation().

{
global $ilDB;
if(!$a_type || !$a_ops_id)
{
return;
}
$query = 'DELETE FROM rbac_templates WHERE '.
'type = '.$ilDB->quote($a_type,'text').' AND '.
'ops_id = '.$ilDB->quote($a_ops_id,'integer');
$GLOBALS['ilLog']->write(__METHOD__.': '.$query);
$ilDB->manipulate($query);
}

+ Here is the caller graph for this function:

static ilDBUpdateNewObjectType::getCustomRBACOperationId (   $a_operation)
static

Get id of RBAC operation.

Parameters
string$a_operation
Returns
int

Definition at line 185 of file class.ilDBUpdateNewObjectType.php.

References $res, and $row.

Referenced by addCustomRBACOperation(), and addRBACOperations().

{
global $ilDB;
$sql = 'SELECT ops_id'.
' FROM rbac_operations'.
' WHERE operation = '.$ilDB->quote($a_operation, 'text');
$res = $ilDB->query($sql);
$row = $ilDB->fetchAssoc($res);
return $row['ops_id'];
}

+ Here is the caller graph for this function:

static ilDBUpdateNewObjectType::getObjectTypeId (   $a_type)
static

Get id for object data type entry.

Parameters
string$a_type
Returns
int

Definition at line 246 of file class.ilDBUpdateNewObjectType.php.

References $res, and $row.

Referenced by addNewType(), addRBACCreate(), and deleteRBACOperation().

{
global $ilDB;
$sql = 'SELECT obj_id FROM object_data'.
' WHERE type = '.$ilDB->quote('typ', 'text').
' AND title = '.$ilDB->quote($a_type, 'text');
$res = $ilDB->query($sql);
$row = $ilDB->fetchAssoc($res);
return $row['obj_id'];
}

+ Here is the caller graph for this function:

static ilDBUpdateNewObjectType::isValidRBACOperation (   $a_ops_id)
staticprotected

Check if given RBAC operation id is valid.

Parameters
int$a_ops_id
Returns
bool

Definition at line 162 of file class.ilDBUpdateNewObjectType.php.

References $valid.

{
$valid = array(
self::RBAC_OP_EDIT_PERMISSIONS,
self::RBAC_OP_VISIBLE,
self::RBAC_OP_READ,
self::RBAC_OP_WRITE,
self::RBAC_OP_DELETE,
self::RBAC_OP_COPY
);
if(in_array($a_ops_id, $valid))
{
return true;
}
return false;
}
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.

{
global $ilDB;
$ilDB->update('rbac_operations',
array('op_order' => array('integer', $a_pos)),
array('operation' => array('text', $a_operation))
);
}
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 302 of file class.ilDBUpdateNewObjectType.php.

References ilDB\LOCK_WRITE.

{
global $ilDB;
$tmp_column_name = $a_column_name."_tmp_clob";
if(!$ilDB->tableColumnExists($a_table_name, $a_column_name) ||
$ilDB->tableColumnExists($a_table_name, $tmp_column_name))
{
return false;
}
// oracle does not support ALTER TABLE varchar2 to CLOB
$ilDB->lockTables(array(
array('name'=> $a_table_name, 'type'=>ilDB::LOCK_WRITE)
));
$def = array(
'type' => 'clob',
'notnull' => false
);
$ilDB->addTableColumn($a_table_name, $tmp_column_name, $def);
$ilDB->manipulate('UPDATE '.$a_table_name.' SET '.$tmp_column_name.' = '.$a_column_name);
$ilDB->dropTableColumn($a_table_name, $a_column_name);
$ilDB->renameTableColumn($a_table_name, $tmp_column_name, $a_column_name);
$ilDB->unlockTables();
return true;
}

Field Documentation

const ilDBUpdateNewObjectType::RBAC_OP_COPY = 99

Definition at line 20 of file class.ilDBUpdateNewObjectType.php.

const ilDBUpdateNewObjectType::RBAC_OP_DELETE = 6

Definition at line 19 of file class.ilDBUpdateNewObjectType.php.

const ilDBUpdateNewObjectType::RBAC_OP_EDIT_PERMISSIONS = 1

Definition at line 15 of file class.ilDBUpdateNewObjectType.php.

const ilDBUpdateNewObjectType::RBAC_OP_READ = 3

Definition at line 17 of file class.ilDBUpdateNewObjectType.php.

const ilDBUpdateNewObjectType::RBAC_OP_VISIBLE = 2

Definition at line 16 of file class.ilDBUpdateNewObjectType.php.

const ilDBUpdateNewObjectType::RBAC_OP_WRITE = 4

Definition at line 18 of file class.ilDBUpdateNewObjectType.php.


The documentation for this class was generated from the following file: