ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilDidacticTemplateObjSettings Class Reference

Stores the applied template id for objects. More...

+ Collaboration diagram for ilDidacticTemplateObjSettings:

Static Public Member Functions

static lookupTemplateId (int $a_ref_id)
 
static deleteByObjId (int $a_obj_id)
 
static deleteByTemplateId (int $a_tpl_id)
 
static deleteByRefId (int $a_ref_id)
 
static assignTemplate (int $a_ref_id, int $a_obj_id, int $a_tpl_id)
 
static getAssignmentsByTemplateID (int $a_tpl_id)
 
static getAssignmentsForTemplates (array $template_ids)
 
static transferAutoGenerateStatus (int $a_src, int $a_dest)
 Transfer auto generated flag if source is auto generated. More...
 

Detailed Description

Stores the applied template id for objects.

Author
Stefan Meyer <meyer.de>

Definition at line 11 of file class.ilDidacticTemplateObjSettings.php.

Member Function Documentation

◆ assignTemplate()

static ilDidacticTemplateObjSettings::assignTemplate ( int  $a_ref_id,
int  $a_obj_id,
int  $a_tpl_id 
)
static

Definition at line 62 of file class.ilDidacticTemplateObjSettings.php.

References $DIC, and $ilDB.

Referenced by ilObject\applyDidacticTemplate(), and ilDidacticTemplateSettingsGUI\editImport().

62  : void
63  {
64  global $DIC;
65 
66  $ilDB = $DIC->database();
67 
68  self::deleteByRefId($a_ref_id);
69 
70  $query = 'INSERT INTO didactic_tpl_objs (ref_id,obj_id,tpl_id) ' .
71  'VALUES ( ' .
72  $ilDB->quote($a_ref_id, 'integer') . ', ' .
73  $ilDB->quote($a_obj_id, 'integer') . ', ' .
74  $ilDB->quote($a_tpl_id, 'integer') . ' ' .
75  ')';
76  $ilDB->manipulate($query);
77  }
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ deleteByObjId()

static ilDidacticTemplateObjSettings::deleteByObjId ( int  $a_obj_id)
static

Definition at line 29 of file class.ilDidacticTemplateObjSettings.php.

References $DIC, and $ilDB.

Referenced by ilObject\delete().

29  : void
30  {
31  global $DIC;
32 
33  $ilDB = $DIC->database();
34 
35  $query = 'DELETE FROM didactic_tpl_objs ' .
36  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
37  $ilDB->manipulate($query);
38  }
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ deleteByRefId()

static ilDidacticTemplateObjSettings::deleteByRefId ( int  $a_ref_id)
static

Definition at line 51 of file class.ilDidacticTemplateObjSettings.php.

References $DIC, and $ilDB.

Referenced by ilObject\delete().

51  : void
52  {
53  global $DIC;
54 
55  $ilDB = $DIC->database();
56 
57  $query = 'DELETE FROM didactic_tpl_objs ' .
58  'WHERE ref_id = ' . $ilDB->quote($a_ref_id, 'integer');
59  $ilDB->manipulate($query);
60  }
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ deleteByTemplateId()

static ilDidacticTemplateObjSettings::deleteByTemplateId ( int  $a_tpl_id)
static

Definition at line 40 of file class.ilDidacticTemplateObjSettings.php.

References $DIC, and $ilDB.

Referenced by ilDidacticTemplateSetting\delete().

40  : void
41  {
42  global $DIC;
43 
44  $ilDB = $DIC->database();
45 
46  $query = 'DELETE FROM didactic_tpl_objs ' .
47  'WHERE tpl_id = ' . $ilDB->quote($a_tpl_id, 'integer');
48  $ilDB->manipulate($query);
49  }
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ getAssignmentsByTemplateID()

static ilDidacticTemplateObjSettings::getAssignmentsByTemplateID ( int  $a_tpl_id)
static
Parameters
int$a_tpl_id
Returns
array{ref_id: int, obj_id: int}[]

Definition at line 83 of file class.ilDidacticTemplateObjSettings.php.

References $DIC, $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by ilDidacticTemplateSettingsGUI\editImport().

83  : array
84  {
85  global $DIC;
86 
87  $ilDB = $DIC->database();
88 
89  $query = 'SELECT * FROM didactic_tpl_objs ' .
90  'WHERE tpl_id = ' . $ilDB->quote($a_tpl_id, 'integer');
91  $res = $ilDB->query($query);
92  $assignments = [];
93 
94  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
95  $assignments[] = ["ref_id" => (int) $row->ref_id, "obj_id" => (int) $row->obj_id];
96  }
97 
98  return $assignments;
99  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignmentsForTemplates()

static ilDidacticTemplateObjSettings::getAssignmentsForTemplates ( array  $template_ids)
static
Parameters
int[]$template_ids
Returns
array<int, int[]>

Definition at line 105 of file class.ilDidacticTemplateObjSettings.php.

References $DIC, $res, ilDBConstants\FETCHMODE_OBJECT, ILIAS\Repository\int(), and ilDBConstants\T_INTEGER.

Referenced by ilDidacticTemplateIconFactory\initTemplates().

105  : array
106  {
107  global $DIC;
108 
109  $db = $DIC->database();
110  $query = 'select * from didactic_tpl_objs ' .
111  'where ' . $db->in('tpl_id', $template_ids, false, ilDBConstants::T_INTEGER);
112  $res = $db->query($query);
113  $assignments = [];
114  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
115  $assignments[(int) $row->tpl_id][] = (int) $row->ref_id;
116  }
117 
118  return $assignments;
119  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupTemplateId()

static ilDidacticTemplateObjSettings::lookupTemplateId ( int  $a_ref_id)
static

◆ transferAutoGenerateStatus()

static ilDidacticTemplateObjSettings::transferAutoGenerateStatus ( int  $a_src,
int  $a_dest 
)
static

Transfer auto generated flag if source is auto generated.

Parameters
int$a_src
int$a_dest
Returns
bool

Definition at line 127 of file class.ilDidacticTemplateObjSettings.php.

References $DIC, $ilDB, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilDidacticTemplateSettingsGUI\editImport().

127  : bool
128  {
129  global $DIC;
130 
131  $ilDB = $DIC->database();
132 
133  $query = 'SELECT auto_generated FROM didactic_tpl_settings ' .
134  'WHERE id = ' . $ilDB->quote($a_src, 'integer');
135  $res = $ilDB->query($query);
136 
137  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
138 
139  if ((int) $row->auto_generated === 0) {
140  return false;
141  }
142 
143  $query = 'UPDATE didactic_tpl_settings ' .
144  'SET ' .
145  'auto_generated = ' . $ilDB->quote(1, 'integer') .
146  ' WHERE id = ' . $ilDB->quote($a_dest, 'integer');
147  $ilDB->manipulate($query);
148 
149  $query = 'UPDATE didactic_tpl_settings ' .
150  'SET ' .
151  'auto_generated = ' . $ilDB->quote(0, 'integer') .
152  ' WHERE id = ' . $ilDB->quote($a_src, 'integer');
153  $ilDB->manipulate($query);
154 
155  return true;
156  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

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