5include_once(
"./Services/Component/classes/class.ilPlugin.php");
 
   28        return "AdvancedMetaData";
 
   33        return "AdvancedMDClaiming";
 
   43        require_once 
"Services/AdvancedMetaData/classes/class.ilAdvancedMDPermissionHelper.php";
 
   80        $set = 
$ilDB->query(
"SELECT record_id FROM adv_md_record" .
 
   81            " WHERE record_id = " . 
$ilDB->quote($a_record_id, 
"integer"));
 
   82        return (
bool) 
$ilDB->numRows($set);
 
   94    public static function createDBRecord($a_title, $a_description, $a_active, array $a_obj_types)
 
  100        $record_id = 
$ilDB->nextId(
"adv_md_record");
 
  103            "record_id" => array(
"integer", $record_id),
 
  104            "import_id" => array(
"text", 
'il_' . IL_INST_ID . 
'_adv_md_record_' . $record_id),
 
  105            "title" => array(
"text", trim($a_title)),
 
  106            "description" => array(
"text", trim($a_description)),
 
  107            "active" => array(
"integer", (
int) $a_active)
 
  109        $ilDB->insert(
"adv_md_record", $fields);
 
  123    protected static function isValidObjType($a_obj_type, $a_is_substitution = 
false)
 
  126        $valid = array(
"crs", 
"cat", 
"book", 
"wiki", 
"glo", 
"orgu", 
"prg", 
'grp', 
'iass');
 
  128        if (!$a_is_substitution) {
 
  133        return in_array($a_obj_type, 
$valid);
 
  148        foreach ($a_obj_types as 
$type) {
 
  149            if (!is_array(
$type)) {
 
  153                $subtype = strtolower(trim(
$type[1]));
 
  157            if (self::isValidObjType(
$type)) {
 
  159                    "record_id" => array(
"integer", $a_record_id),
 
  160                    "obj_type" => array(
"text", 
$type),
 
  161                    "sub_type" => array(
"text", $subtype)
 
  163                $ilDB->insert(
"adv_md_record_objs", $fields);
 
  178    public static function updateDBRecord($a_record_id, $a_title, $a_description, $a_active, array $a_obj_types)
 
  184        if (self::hasDBRecord($a_record_id)) {
 
  186                "title" => array(
"text", trim($a_title)),
 
  187                "description" => array(
"text", trim($a_description)),
 
  188                "active" => array(
"integer", (
int) $a_active)
 
  193                array(
"record_id" => array(
"integer", $a_record_id))
 
  196            $ilDB->manipulate(
"DELETE FROM adv_md_record_objs" .
 
  197                " WHERE record_id = " . 
$ilDB->quote($a_record_id, 
"integer"));
 
  219        if (self::hasDBRecord($a_record_id)) {
 
  220            $ilDB->manipulate(
"DELETE FROM adv_md_record" .
 
  221                " WHERE record_id = " . 
$ilDB->quote($a_record_id, 
"integer"));
 
  240        $set = 
$ilDB->query(
"SELECT field_id FROM adv_mdf_definition" .
 
  241            " WHERE field_id = " . 
$ilDB->quote($a_field_id, 
"integer"));
 
  242        return (
bool) 
$ilDB->numRows($set);
 
  259        $sql = 
"SELECT max(position) pos" .
 
  260            " FROM adv_mdf_definition" .
 
  261            " WHERE record_id = " . 
$ilDB->quote($a_record_id, 
"integer");
 
  262        $set = 
$ilDB->query($sql);
 
  263        if (
$ilDB->numRows($set)) {
 
  264            $pos = 
$ilDB->fetchAssoc($set);
 
  265            return (
int) $pos[
"pos"];
 
  282    public static function createDBField($a_record_id, 
$a_type, $a_title, $a_description = 
null, $a_searchable = 
false, array $a_definition = 
null)
 
  288        if (!self::hasDBRecord($a_record_id)) {
 
  292        $field_id = 
$ilDB->nextId(
"adv_mdf_definition");
 
  296        if ($a_type < 1 || $a_type > 8) {
 
  303            "record_id" => array(
"integer", $a_record_id),
 
  304            "field_id" => array(
"integer", $field_id),
 
  305            "import_id" => array(
"text", 
"il_" . IL_INST_ID . 
"_adv_md_field_" . $field_id),
 
  306            "field_type" => array(
"integer", 
$a_type),
 
  307            "position" => array(
"integer", $pos),
 
  308            "title" => array(
"text", trim($a_title)),
 
  309            "description" => array(
"text", trim($a_description)),
 
  310            "searchable" => array(
"integer", (
int) $a_searchable)
 
  313            $fields[
"field_values"] = array(
"text", serialize($a_definition));
 
  315        $ilDB->insert(
"adv_mdf_definition", $fields);
 
  330    public static function updateDBField($a_field_id, $a_title, $a_description = 
null, $a_searchable = 
false, array $a_definition = 
null)
 
  336        if (self::hasDBField($a_field_id)) {
 
  338                "field_id" => array(
"integer", $a_field_id),
 
  339                "title" => array(
"text", trim($a_title)),
 
  340                "description" => array(
"text", trim($a_description)),
 
  341                "searchable" => array(
"integer", (
int) $a_searchable)
 
  344                $fields[
"field_values"] = array(
"text", serialize($a_definition));
 
  347                "adv_mdf_definition",
 
  349                array(
"field_id" => array(
"integer", $a_field_id))
 
  369        if (self::hasDBField($a_field_id)) {
 
  370            $ilDB->manipulate(
"DELETE FROM adv_mdf_definition" .
 
  371                " WHERE field_id = " . 
$ilDB->quote($a_field_id, 
"integer"));
 
  391        $set = 
$ilDB->query(
"SELECT * FROM adv_md_substitutions" .
 
  392            " WHERE obj_type = " . 
$ilDB->quote($a_obj_type, 
"text"));
 
  393        if (
$ilDB->numRows($set)) {
 
  395            $res[
"hide_description"] = array(
"integer", (
bool) 
$res[
"hide_description"]);
 
  396            $res[
"hide_field_names"] = array(
"integer", (
bool) 
$res[
"hide_field_names"]);
 
  398            if ($a_include_field_data) {
 
  399                $res[
"substitution"] = array(
"text", (array) unserialize(
$res[
"substitution"]));
 
  401                unset(
$res[
"substitution"]);
 
  403            unset(
$res[
"obj_type"]);
 
  423        if (self::isValidObjType($a_obj_type, 
true)) {
 
  429                $fields = array(
"obj_type" => array(
"text", $a_obj_type));
 
  432            $fields[
"hide_description"] = array(
"integer", !(
bool) $a_show_description);
 
  433            $fields[
"hide_field_names"] = array(
"integer", !(
bool) $a_show_field_names);
 
  436                $ilDB->insert(
"adv_md_substitutions", $fields);
 
  439                    "adv_md_substitutions",
 
  441                    array(
"obj_type" => array(
"text", $a_obj_type))
 
  459        if (self::isValidObjType($a_obj_type, 
true)) {
 
  461            $fields = $fields[
"substitution"][1];
 
  462            foreach ($fields as $field) {
 
  463                if ($field[
"field_id"] == $a_field_id) {
 
  486        if (self::isValidObjType($a_obj_type, 
true)) {
 
  492                $fields = $fields[
"substitution"][1];
 
  496            foreach ($fields as $idx => $field) {
 
  497                if ($field[
"field_id"] == $a_field_id) {
 
  498                    $fields[$idx][
"bold"] = (bool) $a_bold;
 
  499                    $fields[$idx][
"newline"] = (bool) $a_newline;
 
  506                    "field_id" => $a_field_id
 
  507                    ,
"bold" => (
bool) $a_bold
 
  508                    ,
"newline" => (
bool) $a_newline
 
  512            $fields = array(
"substitution" => array(
"text", serialize($fields)));
 
  514                "adv_md_substitutions",
 
  516                array(
"obj_type" => array(
"text", $a_obj_type))
 
  535        if (self::isValidObjType($a_obj_type, 
true)) {
 
  540                $fields = $fields[
"substitution"][1];
 
  544            foreach ($fields as $idx => $field) {
 
  545                if ($field[
"field_id"] == $a_field_id) {
 
  546                    unset($fields[$idx]);
 
  552                $fields = array(
"substitution" => array(
"text", serialize($fields)));
 
  554                    "adv_md_substitutions",
 
  556                    array(
"obj_type" => array(
"text", $a_obj_type))
 
An exception for terminatinating execution or to throw for unit testing.
Abstract parent class for all advanced md claiming plugin classes.
static getDBSubstitution($a_obj_type, $a_include_field_data=false)
Get substitution DB data for object type.
static deleteDBField($a_field_id)
Delete field db entry.
getComponentType()
Get Component Type.
static getDBFieldLastPosition($a_record_id)
Get last position of record.
static removeDBFieldSubstitution($a_obj_type, $a_field_id)
Remove field substitution entry in DB.
static hasDBFieldSubstitution($a_obj_type, $a_field_id)
Is substitution active for field in object type.
slotInit()
Object initialization done by slot.
static updateDBField($a_field_id, $a_title, $a_description=null, $a_searchable=false, array $a_definition=null)
Update field db entry.
static deleteDBRecord($a_record_id)
Delete record db entry.
static updateDBRecord($a_record_id, $a_title, $a_description, $a_active, array $a_obj_types)
Update record db entry.
static createDBRecord($a_title, $a_description, $a_active, array $a_obj_types)
Create record db entry.
static hasDBField($a_field_id)
Check if field has db entry.
static isValidObjType($a_obj_type, $a_is_substitution=false)
Validate object type.
static hasDBRecord($a_record_id)
Check if record 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 saveRecordObjTypes($a_record_id, array $a_obj_types)
Save object type assignments for record.
getComponentName()
Get Component Name.
checkPermission($a_user_id, $a_context_type, $a_context_id, $a_action_id, $a_action_sub_id)
Check permission.
static setDBFieldSubstitution($a_obj_type, $a_field_id, $a_bold=false, $a_newline=false)
Update field substitution entry in DB.
static setDBSubstitution($a_obj_type, $a_show_description, $a_show_field_names)
Set substitution DB entry (for object type)
foreach($_POST as $key=> $value) $res