3 declare(strict_types=1);
17 $ilDB = $DIC->database();
19 $query =
'SELECT tpl_id FROM didactic_tpl_objs ' .
20 'WHERE ref_id = ' .
$ilDB->quote($a_ref_id,
'integer');
23 return (
int) $row->tpl_id;
33 $ilDB = $DIC->database();
35 $query =
'DELETE FROM didactic_tpl_objs ' .
36 'WHERE obj_id = ' .
$ilDB->quote($a_obj_id,
'integer');
44 $ilDB = $DIC->database();
46 $query =
'DELETE FROM didactic_tpl_objs ' .
47 'WHERE tpl_id = ' .
$ilDB->quote($a_tpl_id,
'integer');
55 $ilDB = $DIC->database();
57 $query =
'DELETE FROM didactic_tpl_objs ' .
58 'WHERE ref_id = ' .
$ilDB->quote($a_ref_id,
'integer');
62 public static function assignTemplate(
int $a_ref_id,
int $a_obj_id,
int $a_tpl_id): void
66 $ilDB = $DIC->database();
68 self::deleteByRefId($a_ref_id);
70 $query =
'INSERT INTO didactic_tpl_objs (ref_id,obj_id,tpl_id) ' .
72 $ilDB->quote($a_ref_id,
'integer') .
', ' .
73 $ilDB->quote($a_obj_id,
'integer') .
', ' .
74 $ilDB->quote($a_tpl_id,
'integer') .
' ' .
87 $ilDB = $DIC->database();
89 $query =
'SELECT * FROM didactic_tpl_objs ' .
90 'WHERE tpl_id = ' .
$ilDB->quote($a_tpl_id,
'integer');
95 $assignments[] = [
"ref_id" => (
int) $row->ref_id,
"obj_id" => (
int) $row->obj_id];
109 $db = $DIC->database();
110 $query =
'select * from didactic_tpl_objs ' .
115 $assignments[(
int) $row->tpl_id][] = (
int) $row->ref_id;
131 $ilDB = $DIC->database();
133 $query =
'SELECT auto_generated FROM didactic_tpl_settings ' .
134 'WHERE id = ' .
$ilDB->quote($a_src,
'integer');
139 if ((
int) $row->auto_generated === 0) {
143 $query =
'UPDATE didactic_tpl_settings ' .
145 'auto_generated = ' .
$ilDB->quote(1,
'integer') .
146 ' WHERE id = ' .
$ilDB->quote($a_dest,
'integer');
149 $query =
'UPDATE didactic_tpl_settings ' .
151 'auto_generated = ' .
$ilDB->quote(0,
'integer') .
152 ' WHERE id = ' .
$ilDB->quote($a_src,
'integer');
static assignTemplate(int $a_ref_id, int $a_obj_id, int $a_tpl_id)
static getAssignmentsByTemplateID(int $a_tpl_id)
static deleteByObjId(int $a_obj_id)
static transferAutoGenerateStatus(int $a_src, int $a_dest)
Transfer auto generated flag if source is auto generated.
Stores the applied template id for objects.
static lookupTemplateId(int $a_ref_id)
static deleteByTemplateId(int $a_tpl_id)
static getAssignmentsForTemplates(array $template_ids)
static deleteByRefId(int $a_ref_id)