ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAdvancedMDClaimingPlugin Class Reference

Abstract parent class for all advanced md claiming plugin classes. More...

+ Inheritance diagram for ilAdvancedMDClaimingPlugin:
+ Collaboration diagram for ilAdvancedMDClaimingPlugin:

Public Member Functions

 getComponentType ()
 Get Component Type.
 getComponentName ()
 Get Component Name.
 getSlot ()
 Get Slot Name.
 getSlotId ()
 Get Slot ID.
 checkPermission ($a_user_id, $a_context_type, $a_context_id, $a_action_id, $a_action_sub_id)
 Check permission.
- Public Member Functions inherited from ilPlugin
 __construct ()
 Constructor.
 getPluginName ()
 Get Plugin Name.
 getId ()
 Get Id.
 getLastUpdateVersion ()
 Get Version of last update.
 getVersion ()
 Get Current Version (from plugin.php file).
 getIliasMinVersion ()
 Get Required ILIAS min.
 getIliasMaxVersion ()
 Get Required ILIAS max.
 getActive ()
 Get Active.
 setDBVersion ($a_dbversion)
 Set DB Version.
 getDBVersion ()
 Get DB Version.
 writeDBVersion ($a_dbversion)
 Write DB version to database.
 getDirectory ()
 Get Plugin Directory.
 includeClass ($a_class_file_name)
 Include (once) a class file.
 getPrefix ()
 Get plugin prefix, used for lang vars.
 getTablePrefix ()
 Get db table plugin prefix.
 updateLanguages ()
 Update all languages.
 updateDatabase ()
 Update database.
 loadLanguageModule ()
 Load language module for plugin.
 txt ($a_var)
 Get Language Variable (prefix will be prepended automatically)
 getTemplate ($a_template, $a_par1=true, $a_par2=true)
 Get template from plugin.
 getImagePath ($a_img)
 Get image path.
 getStyleSheetLocation ($a_css_file)
 Get css file location.
 addBlockFile ($a_tpl, $a_var, $a_block, $a_tplname)
 Add template content to placeholder variable.
 isActive ()
 Check whether plugin is active.
 needsUpdate ()
 Check whether update is needed.
 activate ()
 Activate.
 deactivate ()
 Deactivate.
 update ()
 Update plugin.
 lookupNameForId ($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
 Lookup name for id.
 lookupIdForName ($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
 Lookup id for name.

Static Public Member Functions

static hasDBRecord ($a_record_id)
 Check if record has db entry.
static createDBRecord ($a_title, $a_description, $a_active, array $a_obj_types)
 Create record db entry.
static updateDBRecord ($a_record_id, $a_title, $a_description, $a_active, array $a_obj_types)
 Update record db entry.
static deleteDBRecord ($a_record_id)
 Delete record db entry.
static hasDBField ($a_field_id)
 Check if field has db entry.
static createDBField ($a_record_id, $a_type, $a_title, $a_description=null, $a_searchable=false, array $a_definition=null)
 Create field db entry.
static updateDBField ($a_field_id, $a_title, $a_description=null, $a_searchable=false, array $a_definition=null)
 Update field db entry.
static deleteDBField ($a_field_id)
 Delete field db entry.
static setDBSubstitution ($a_obj_type, $a_show_description, $a_show_field_names)
 Set substitution DB entry (for object type)
static hasDBFieldSubstitution ($a_obj_type, $a_field_id)
 Is substitution active for field in object type.
static setDBFieldSubstitution ($a_obj_type, $a_field_id, $a_bold=false, $a_newline=false)
 Update field substitution entry in DB.
static removeDBFieldSubstitution ($a_obj_type, $a_field_id)
 Remove field substitution entry in DB.
- Static Public Member Functions inherited from ilPlugin
static _getDirectory ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Get plugin directory.
static getAvailableLangFiles ($a_lang_directory)
 Get array of all language files in the plugin.
static hasConfigureClass ($a_slot_dir, $a_name)
 Has the plugin a configure class?
static getConfigureClassName ($a_name)
 Get plugin configure class name.
static getDBUpdateScriptName ($a_ctype, $a_cname, $a_slot_name, $a_pname)
 Get DB update script filename (full path)
static lookupTxt ($a_mod_prefix, $a_pl_id, $a_lang_var)
 Lookup language text.
static _getImagePath ($a_ctype, $a_cname, $a_slot_id, $a_pname, $a_img)
 Get image path.
static createPluginRecord ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Create plugin record, if not existing.
static getPluginRecord ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Get record from il_plugin table.
static getPluginObject ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Get plugin object.
static lookupStoredData ($a_ctype, $a_cname, $a_slot_id, $a_pname)
 Lookup information data in il_plugin.
static getActivePluginsForSlot ($a_ctype, $a_cname, $a_slot_id)
 Get all active plugins for a slot.

Protected Member Functions

 slotInit ()
 Object initialization done by slot.
- Protected Member Functions inherited from ilPlugin
 setSlotObject ($a_slot)
 Set Plugin Slot.
 getSlotObject ()
 Get Plugin Slot.
 getClassesDirectory ()
 Get Plugin's classes Directory.
 getLanguageDirectory ()
 Get Plugin's language Directory.
 init ()
 Object initialization.
 beforeActivation ()
 Before activation processing.
 afterActivation ()
 After activation processing.
 afterDeactivation ()
 After deactivation processing.
 beforeUpdate ()
 Before update processing.
 afterUpdate ()
 After update processing.

Static Protected Member Functions

static isValidObjType ($a_obj_type, $a_is_substitution=false)
 Validate object type.
static saveRecordObjTypes ($a_record_id, array $a_obj_types)
 Save object type assignments for record.
static getDBFieldLastPosition ($a_record_id)
 Get last position of record.
static getDBSubstitution ($a_obj_type, $a_include_field_data=false)
 Get substitution DB data for object type.

Additional Inherited Members

- Protected Attributes inherited from ilPlugin
 $lang_initialised = false

Detailed Description

Abstract parent class for all advanced md claiming plugin classes.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Member Function Documentation

ilAdvancedMDClaimingPlugin::checkPermission (   $a_user_id,
  $a_context_type,
  $a_context_id,
  $a_action_id,
  $a_action_sub_id 
)
abstract

Check permission.

Parameters
int$a_user_id
int$a_context_type
int$a_context_id
int$a_action_id
int$a_action_sub_id
Returns
bool
static ilAdvancedMDClaimingPlugin::createDBField (   $a_record_id,
  $a_type,
  $a_title,
  $a_description = null,
  $a_searchable = false,
array  $a_definition = null 
)
static

Create field db entry.

Parameters
int$a_record_id
int$a_type
string$a_title
string$a_description
bool$a_searchable
array$a_definition
Returns
int field id

Definition at line 273 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB, and getDBFieldLastPosition().

{
global $ilDB;
if(!self::hasDBRecord($a_record_id))
{
return;
}
$field_id = $ilDB->nextId("adv_mdf_definition");
// validating type
$a_type = (int)$a_type;
if($a_type < 1 || $a_type > 7)
{
return;
}
$pos = self::getDBFieldLastPosition($a_record_id)+1;
$fields = array(
"record_id" => array("integer", $a_record_id),
"field_id" => array("integer", $field_id),
"import_id" => array("text", "il_".IL_INST_ID."_adv_md_field_".$field_id),
"field_type" => array("integer", $a_type),
"position" => array("integer", $pos),
"title" => array("text", trim($a_title)),
"description" => array("text", trim($a_description)),
"searchable" => array("integer", (int)$a_searchable)
);
if($a_definition)
{
$fields["field_values"] = array("text", serialize($a_definition));
}
$ilDB->insert("adv_mdf_definition", $fields);
return $field_id;
}

+ Here is the call graph for this function:

static ilAdvancedMDClaimingPlugin::createDBRecord (   $a_title,
  $a_description,
  $a_active,
array  $a_obj_types 
)
static

Create record db entry.

Parameters
string$a_title
string$a_description
bool$a_active
array$a_obj_types
Returns
int record id

Definition at line 92 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB, and saveRecordObjTypes().

{
global $ilDB;
$record_id = $ilDB->nextId("adv_md_record");
$fields = array(
"record_id" => array("integer", $record_id),
"import_id" => array("text", 'il_'.IL_INST_ID.'_adv_md_record_'.$record_id),
"title" => array("text", trim($a_title)),
"description" => array("text", trim($a_description)),
"active" => array("integer", (int)$a_active)
);
$ilDB->insert("adv_md_record", $fields);
self::saveRecordObjTypes($record_id, $a_obj_types);
return $record_id;
}

+ Here is the call graph for this function:

static ilAdvancedMDClaimingPlugin::deleteDBField (   $a_field_id)
static

Delete field db entry.

Parameters
int$a_field_id
Returns
bool

Definition at line 352 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB.

{
global $ilDB;
if(self::hasDBField($a_field_id))
{
$ilDB->manipulate("DELETE FROM adv_mdf_definition".
" WHERE field_id = ".$ilDB->quote($a_field_id, "integer"));
return true;
}
return false;
}
static ilAdvancedMDClaimingPlugin::deleteDBRecord (   $a_record_id)
static

Delete record db entry.

Parameters
int$a_record_id
Returns
bool

Definition at line 208 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB.

{
global $ilDB;
if(self::hasDBRecord($a_record_id))
{
$ilDB->manipulate("DELETE FROM adv_md_record".
" WHERE record_id = ".$ilDB->quote($a_record_id, "integer"));
return true;
}
return false;
}
ilAdvancedMDClaimingPlugin::getComponentName ( )
final

Get Component Name.

Must be overwritten in plugin class of plugin slot. (and should be made final)

Returns
string Component Name

Reimplemented from ilPlugin.

Definition at line 26 of file class.ilAdvancedMDClaimingPlugin.php.

{
return "AdvancedMetaData";
}
ilAdvancedMDClaimingPlugin::getComponentType ( )
final

Get Component Type.

Must be overwritten in plugin class of plugin slot. (and should be made final)

Returns
string Component Type

Reimplemented from ilPlugin.

Definition at line 21 of file class.ilAdvancedMDClaimingPlugin.php.

References IL_COMP_SERVICE.

{
}
static ilAdvancedMDClaimingPlugin::getDBFieldLastPosition (   $a_record_id)
staticprotected

Get last position of record.

See Also
ilAdvancedMDFieldDefinition::getLastPosition()
Parameters
int$a_record_id
Returns
int

Definition at line 245 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB.

Referenced by createDBField().

{
global $ilDB;
$sql = "SELECT max(position) pos".
" FROM adv_mdf_definition".
" WHERE record_id = ".$ilDB->quote($a_record_id, "integer");
$set = $ilDB->query($sql);
if($ilDB->numRows($set))
{
$pos = $ilDB->fetchAssoc($set);
return (int)$pos["pos"];
}
return 0;
}

+ Here is the caller graph for this function:

static ilAdvancedMDClaimingPlugin::getDBSubstitution (   $a_obj_type,
  $a_include_field_data = false 
)
staticprotected

Get substitution DB data for object type.

Parameters
string$a_obj_type
bool$a_include_field_data
Returns
array

Definition at line 373 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB, and $res.

Referenced by hasDBFieldSubstitution(), removeDBFieldSubstitution(), setDBFieldSubstitution(), and setDBSubstitution().

{
global $ilDB;
$set = $ilDB->query("SELECT * FROM adv_md_substitutions".
" WHERE obj_type = ".$ilDB->quote($a_obj_type, "text"));
if($ilDB->numRows($set))
{
$res = $ilDB->fetchAssoc($set);
$res["hide_description"] = array("integer", (bool)$res["hide_description"]);
$res["hide_field_names"] = array("integer", (bool)$res["hide_field_names"]);
if($a_include_field_data)
{
$res["substitution"] = array("text", (array)unserialize($res["substitution"]));
}
else
{
unset($res["substitution"]);
}
unset($res["obj_type"]);
return $res;
}
}

+ Here is the caller graph for this function:

ilAdvancedMDClaimingPlugin::getSlot ( )
final

Get Slot Name.

Must be overwritten in plugin class of plugin slot. (and should be made final)

Returns
string Slot Name

Reimplemented from ilPlugin.

Definition at line 31 of file class.ilAdvancedMDClaimingPlugin.php.

{
return "AdvancedMDClaiming";
}
ilAdvancedMDClaimingPlugin::getSlotId ( )
final

Get Slot ID.

Must be overwritten in plugin class of plugin slot. (and should be made final)

Returns
string Slot Id

Reimplemented from ilPlugin.

Definition at line 36 of file class.ilAdvancedMDClaimingPlugin.php.

{
return "amdc";
}
static ilAdvancedMDClaimingPlugin::hasDBField (   $a_field_id)
static

Check if field has db entry.

Parameters
int$a_field_id
Returns
bool

Definition at line 228 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB.

{
global $ilDB;
$set = $ilDB->query("SELECT field_id FROM adv_mdf_definition".
" WHERE field_id = ".$ilDB->quote($a_field_id, "integer"));
return (bool)$ilDB->numRows($set);
}
static ilAdvancedMDClaimingPlugin::hasDBFieldSubstitution (   $a_obj_type,
  $a_field_id 
)
static

Is substitution active for field in object type.

Parameters
string$a_obj_type
int$a_field_id
Returns
bool

Definition at line 447 of file class.ilAdvancedMDClaimingPlugin.php.

References getDBSubstitution().

{
if(self::isValidObjType($a_obj_type, true))
{
$fields = self::getDBSubstitution($a_obj_type, true);
$fields = $fields["substitution"][1];
foreach($fields as $field)
{
if($field["field_id"] == $a_field_id)
{
return true;
}
}
return false;
}
}

+ Here is the call graph for this function:

static ilAdvancedMDClaimingPlugin::hasDBRecord (   $a_record_id)
static

Check if record has db entry.

Parameters
int$a_record_id
Returns
bool

Definition at line 74 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB.

{
global $ilDB;
$set = $ilDB->query("SELECT record_id FROM adv_md_record".
" WHERE record_id = ".$ilDB->quote($a_record_id, "integer"));
return (bool)$ilDB->numRows($set);
}
static ilAdvancedMDClaimingPlugin::isValidObjType (   $a_obj_type,
  $a_is_substitution = false 
)
staticprotected

Validate object type.

Parameters
string$a_obj_type
bool$a_is_substitution
Returns
bool

Definition at line 119 of file class.ilAdvancedMDClaimingPlugin.php.

References $valid.

{
// ecs, glossary not supported yet
$valid = array("crs", "cat");
if(!$a_is_substitution)
{
$valid[] = "orgu";
}
return in_array($a_obj_type, $valid);
}
static ilAdvancedMDClaimingPlugin::removeDBFieldSubstitution (   $a_obj_type,
  $a_field_id 
)
static

Remove field substitution entry in DB.

Parameters
string$a_obj_type
int$a_field_id
Returns
bool

Definition at line 524 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB, and getDBSubstitution().

{
global $ilDB;
if(self::isValidObjType($a_obj_type, true))
{
$fields = self::getDBSubstitution($a_obj_type, true);
if(!$fields)
{
return true;
}
else
{
$fields = $fields["substitution"][1];
}
$found = false;
foreach($fields as $idx => $field)
{
if($field["field_id"] == $a_field_id)
{
unset($fields[$idx]);
$found = true;
break;
}
}
if($found)
{
$fields = array("substitution"=>array("text", serialize($fields)));
$ilDB->update("adv_md_substitutions", $fields,
array("obj_type" => array("text", $a_obj_type)));
}
return true;
}
return false;
}

+ Here is the call graph for this function:

static ilAdvancedMDClaimingPlugin::saveRecordObjTypes (   $a_record_id,
array  $a_obj_types 
)
staticprotected

Save object type assignments for record.

Parameters
int$a_record_id
array$a_obj_types

Definition at line 138 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB.

Referenced by createDBRecord(), and updateDBRecord().

{
global $ilDB;
foreach($a_obj_types as $type)
{
if(!is_array($type))
{
$type = strtolower(trim($type));
$subtype = "-";
}
else
{
$type = strtolower(trim($type[0]));
$subtype = strtolower(trim($type[1]));
}
if(self::isValidObjType($type))
{
$fields = array(
"record_id" => array("integer", $a_record_id),
"obj_type" => array("text", $type),
"sub_type" => array("text", $subtype)
);
$ilDB->insert("adv_md_record_objs", $fields);
}
}
}

+ Here is the caller graph for this function:

static ilAdvancedMDClaimingPlugin::setDBFieldSubstitution (   $a_obj_type,
  $a_field_id,
  $a_bold = false,
  $a_newline = false 
)
static

Update field substitution entry in DB.

Parameters
string$a_obj_type
int$a_field_id
bool$a_bold
bool$a_newline
Returns
bool

Definition at line 473 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB, getDBSubstitution(), and setDBSubstitution().

{
global $ilDB;
if(self::isValidObjType($a_obj_type, true))
{
$fields = self::getDBSubstitution($a_obj_type, true);
if(!$fields)
{
self::setDBSubstitution($a_obj_type, true, true);
$fields = array();
}
else
{
$fields = $fields["substitution"][1];
}
$found = false;
foreach($fields as $idx => $field)
{
if($field["field_id"] == $a_field_id)
{
$fields[$idx]["bold"] = (bool)$a_bold;
$fields[$idx]["newline"] = (bool)$a_newline;
$found = true;
break;
}
}
if(!$found)
{
$fields[] = array(
"field_id" => $a_field_id
,"bold" => (bool)$a_bold
,"newline" => (bool)$a_newline
);
}
$fields = array("substitution"=>array("text", serialize($fields)));
$ilDB->update("adv_md_substitutions", $fields,
array("obj_type" => array("text", $a_obj_type)));
}
return false;
}

+ Here is the call graph for this function:

static ilAdvancedMDClaimingPlugin::setDBSubstitution (   $a_obj_type,
  $a_show_description,
  $a_show_field_names 
)
static

Set substitution DB entry (for object type)

Parameters
string$a_obj_type
bool$a_show_description
bool$a_show_field_names
Returns
bool

Definition at line 407 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB, and getDBSubstitution().

Referenced by setDBFieldSubstitution().

{
global $ilDB;
if(self::isValidObjType($a_obj_type, true))
{
$fields = self::getDBSubstitution($a_obj_type);
$create = false;
if(!$fields)
{
$create = true;
$fields = array("obj_type" => array("text", $a_obj_type));
}
$fields["hide_description"] = array("integer", !(bool)$a_show_description);
$fields["hide_field_names"] = array("integer", !(bool)$a_show_field_names);
if($create)
{
$ilDB->insert("adv_md_substitutions", $fields);
}
else
{
$ilDB->update("adv_md_substitutions", $fields,
array("obj_type" => array("text", $a_obj_type)));
}
return true;
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAdvancedMDClaimingPlugin::slotInit ( )
finalprotected

Object initialization done by slot.

Must be overwritten in plugin class of plugin slot.

(and should be made protected final)

Reimplemented from ilPlugin.

Definition at line 41 of file class.ilAdvancedMDClaimingPlugin.php.

{
require_once "Services/AdvancedMetaData/classes/class.ilAdvancedMDPermissionHelper.php";
}
static ilAdvancedMDClaimingPlugin::updateDBField (   $a_field_id,
  $a_title,
  $a_description = null,
  $a_searchable = false,
array  $a_definition = null 
)
static

Update field db entry.

Parameters
int$a_field_id
string$a_title
string$a_description
bool$a_searchable
array$a_definition
Returns
bool

Definition at line 322 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB.

{
global $ilDB;
if(self::hasDBField($a_field_id))
{
$fields = array(
"field_id" => array("integer", $a_field_id),
"title" => array("text", trim($a_title)),
"description" => array("text", trim($a_description)),
"searchable" => array("integer", (int)$a_searchable)
);
if($a_definition)
{
$fields["field_values"] = array("text", serialize($a_definition));
}
$ilDB->update("adv_mdf_definition", $fields,
array("field_id" => array("integer", $a_field_id)));
return true;
}
return false;
}
static ilAdvancedMDClaimingPlugin::updateDBRecord (   $a_record_id,
  $a_title,
  $a_description,
  $a_active,
array  $a_obj_types 
)
static

Update record db entry.

Parameters
int$a_record_id
string$a_title
string$a_description
bool$a_active
array$a_obj_types
Returns
bool

Definition at line 177 of file class.ilAdvancedMDClaimingPlugin.php.

References $ilDB, and saveRecordObjTypes().

{
global $ilDB;
if(self::hasDBRecord($a_record_id))
{
$fields = array(
"title" => array("text", trim($a_title)),
"description" => array("text", trim($a_description)),
"active" => array("integer", (int)$a_active)
);
$ilDB->update("adv_md_record", $fields,
array("record_id" => array("integer", $a_record_id)));
$ilDB->manipulate("DELETE FROM adv_md_record_objs".
" WHERE record_id = ".$ilDB->quote($a_record_id, "integer"));
self::saveRecordObjTypes($a_record_id, $a_obj_types);
return true;
}
return false;
}

+ Here is the call graph for this function:


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