ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDidacticTemplateObjSettings.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
12 
19  public static function lookupTemplateId($a_ref_id)
20  {
21  global $DIC;
22 
23  $ilDB = $DIC['ilDB'];
24 
25  $query = 'SELECT tpl_id FROM didactic_tpl_objs ' .
26  'WHERE ref_id = ' . $ilDB->quote($a_ref_id, 'integer');
27  $res = $ilDB->query($query);
28  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
29  return $row->tpl_id;
30  }
31  return 0;
32  }
33 
34 
41  public static function deleteByObjId($a_obj_id)
42  {
43  global $DIC;
44 
45  $ilDB = $DIC['ilDB'];
46 
47  $query = 'DELETE FROM didactic_tpl_objs ' .
48  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
49  $ilDB->manipulate($query);
50  return true;
51  }
52 
59  public static function deleteByTemplateId($a_tpl_id)
60  {
61  global $DIC;
62 
63  $ilDB = $DIC['ilDB'];
64 
65  $query = 'DELETE FROM didactic_tpl_objs ' .
66  'WHERE tpl_id = ' . $ilDB->quote($a_tpl_id, 'integer');
67  $ilDB->manipulate($query);
68  return true;
69  }
70 
76  public static function deleteByRefId($a_ref_id)
77  {
78  global $DIC;
79 
80  $ilDB = $DIC['ilDB'];
81 
82  $query = 'DELETE FROM didactic_tpl_objs ' .
83  'WHERE ref_id = ' . $ilDB->quote($a_ref_id, 'integer');
84  $ilDB->manipulate($query);
85  }
86 
94  public static function assignTemplate($a_ref_id, $a_obj_id, $a_tpl_id)
95  {
96  global $DIC;
97 
98  $ilDB = $DIC['ilDB'];
99 
100  self::deleteByRefId($a_ref_id);
101 
102  $query = 'INSERT INTO didactic_tpl_objs (ref_id,obj_id,tpl_id) ' .
103  'VALUES ( ' .
104  $ilDB->quote($a_ref_id, 'integer') . ', ' .
105  $ilDB->quote($a_obj_id, 'integer') . ', ' .
106  $ilDB->quote($a_tpl_id, 'integer') . ' ' .
107  ')';
108  $ilDB->manipulate($query);
109  return true;
110  }
117  public static function getAssignmentsByTemplateID($a_tpl_id)
118  {
119  global $DIC;
120 
121  $ilDB = $DIC['ilDB'];
122 
123  $query = 'SELECT * FROM didactic_tpl_objs ' .
124  'WHERE tpl_id = ' . $ilDB->quote($a_tpl_id, 'integer');
125  $res = $ilDB->query($query);
126  $assignments = array();
127 
128  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
129  $assignments[] = array("ref_id" => $row->ref_id, "obj_id" => $row->obj_id);
130  }
131  return $assignments;
132  }
133 
134 
142  public static function transferAutoGenerateStatus($a_src, $a_dest)
143  {
144  global $DIC;
145 
146  $ilDB = $DIC['ilDB'];
147 
148  $query = 'SELECT auto_generated FROM didactic_tpl_settings ' .
149  'WHERE id = ' . $ilDB->quote($a_src, 'integer');
150  $res = $ilDB->query($query);
151 
153 
154  if ($row->auto_generated == 0) {
155  return false;
156  }
157 
158  $query = 'UPDATE didactic_tpl_settings ' .
159  'SET ' .
160  'auto_generated = ' . $ilDB->quote(1, 'integer') .
161  ' WHERE id = ' . $ilDB->quote($a_dest, 'integer');
162  $ilDB->manipulate($query);
163 
164  $query = 'UPDATE didactic_tpl_settings ' .
165  'SET ' .
166  'auto_generated = ' . $ilDB->quote(0, 'integer') .
167  ' WHERE id = ' . $ilDB->quote($a_src, 'integer');
168  $ilDB->manipulate($query);
169 
170  return true;
171  }
172 }
static lookupTemplateId($a_ref_id)
Lookup template id ilDB $ilDB.
global $DIC
Definition: saml.php:7
static deleteByRefId($a_ref_id)
Delete by ref_id ilDB $ilDB.
static transferAutoGenerateStatus($a_src, $a_dest)
transfer auto generated flag if source is auto generated
static getAssignmentsByTemplateID($a_tpl_id)
Lookup template id ilDB $ilDB.
Stores the applied template id for objects.
static assignTemplate($a_ref_id, $a_obj_id, $a_tpl_id)
Assign template to object ilDB $ilDB.
foreach($_POST as $key=> $value) $res
static deleteByTemplateId($a_tpl_id)
Delete by template id ilDB $ilDB.
$query
$row
global $ilDB
static deleteByObjId($a_obj_id)
Delete by obj id ilDB $ilDB.