ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 25 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 76 of file class.ilDidacticTemplateObjSettings.php.

References $DIC, and $ilDB.

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

76  : void
77  {
78  global $DIC;
79 
80  $ilDB = $DIC->database();
81 
82  self::deleteByRefId($a_ref_id);
83 
84  $query = 'INSERT INTO didactic_tpl_objs (ref_id,obj_id,tpl_id) ' .
85  'VALUES ( ' .
86  $ilDB->quote($a_ref_id, 'integer') . ', ' .
87  $ilDB->quote($a_obj_id, 'integer') . ', ' .
88  $ilDB->quote($a_tpl_id, 'integer') . ' ' .
89  ')';
90  $ilDB->manipulate($query);
91  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ deleteByObjId()

static ilDidacticTemplateObjSettings::deleteByObjId ( int  $a_obj_id)
static

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

References $DIC, and $ilDB.

Referenced by ilObject\delete().

43  : void
44  {
45  global $DIC;
46 
47  $ilDB = $DIC->database();
48 
49  $query = 'DELETE FROM didactic_tpl_objs ' .
50  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
51  $ilDB->manipulate($query);
52  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ deleteByRefId()

static ilDidacticTemplateObjSettings::deleteByRefId ( int  $a_ref_id)
static

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

References $DIC, and $ilDB.

Referenced by ilObject\delete().

65  : void
66  {
67  global $DIC;
68 
69  $ilDB = $DIC->database();
70 
71  $query = 'DELETE FROM didactic_tpl_objs ' .
72  'WHERE ref_id = ' . $ilDB->quote($a_ref_id, 'integer');
73  $ilDB->manipulate($query);
74  }
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ deleteByTemplateId()

static ilDidacticTemplateObjSettings::deleteByTemplateId ( int  $a_tpl_id)
static

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

References $DIC, and $ilDB.

Referenced by ilDidacticTemplateSetting\delete().

54  : void
55  {
56  global $DIC;
57 
58  $ilDB = $DIC->database();
59 
60  $query = 'DELETE FROM didactic_tpl_objs ' .
61  'WHERE tpl_id = ' . $ilDB->quote($a_tpl_id, 'integer');
62  $ilDB->manipulate($query);
63  }
global $DIC
Definition: shib_login.php:22
+ 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 97 of file class.ilDidacticTemplateObjSettings.php.

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

Referenced by ilDidacticTemplateSettingsGUI\editImport().

97  : array
98  {
99  global $DIC;
100 
101  $ilDB = $DIC->database();
102 
103  $query = 'SELECT * FROM didactic_tpl_objs ' .
104  'WHERE tpl_id = ' . $ilDB->quote($a_tpl_id, 'integer');
105  $res = $ilDB->query($query);
106  $assignments = [];
107 
108  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
109  $assignments[] = ["ref_id" => (int) $row->ref_id, "obj_id" => (int) $row->obj_id];
110  }
111 
112  return $assignments;
113  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ 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 119 of file class.ilDidacticTemplateObjSettings.php.

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

Referenced by ilDidacticTemplateIconFactory\initTemplates().

119  : array
120  {
121  global $DIC;
122 
123  $db = $DIC->database();
124  $query = 'select * from didactic_tpl_objs ' .
125  'where ' . $db->in('tpl_id', $template_ids, false, ilDBConstants::T_INTEGER);
126  $res = $db->query($query);
127  $assignments = [];
128  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
129  $assignments[(int) $row->tpl_id][] = (int) $row->ref_id;
130  }
131 
132  return $assignments;
133  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ 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 141 of file class.ilDidacticTemplateObjSettings.php.

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

Referenced by ilDidacticTemplateSettingsGUI\editImport().

141  : bool
142  {
143  global $DIC;
144 
145  $ilDB = $DIC->database();
146 
147  $query = 'SELECT auto_generated FROM didactic_tpl_settings ' .
148  'WHERE id = ' . $ilDB->quote($a_src, 'integer');
149  $res = $ilDB->query($query);
150 
151  $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
152 
153  if ((int) $row->auto_generated === 0) {
154  return false;
155  }
156 
157  $query = 'UPDATE didactic_tpl_settings ' .
158  'SET ' .
159  'auto_generated = ' . $ilDB->quote(1, 'integer') .
160  ' WHERE id = ' . $ilDB->quote($a_dest, 'integer');
161  $ilDB->manipulate($query);
162 
163  $query = 'UPDATE didactic_tpl_settings ' .
164  'SET ' .
165  'auto_generated = ' . $ilDB->quote(0, 'integer') .
166  ' WHERE id = ' . $ilDB->quote($a_src, 'integer');
167  $ilDB->manipulate($query);
168 
169  return true;
170  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

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