ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB;
22
23 $query = 'SELECT tpl_id FROM didactic_tpl_objs ' .
24 'WHERE ref_id = ' . $ilDB->quote($a_ref_id, 'integer');
25 $res = $ilDB->query($query);
26 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
27 return $row->tpl_id;
28 }
29 return 0;
30 }
31
32
39 public static function deleteByObjId($a_obj_id)
40 {
41 global $ilDB;
42
43 $query = 'DELETE FROM didactic_tpl_objs ' .
44 'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
45 $ilDB->manipulate($query);
46 return true;
47 }
48
55 public static function deleteByTemplateId($a_tpl_id)
56 {
57 global $ilDB;
58
59 $query = 'DELETE FROM didactic_tpl_objs ' .
60 'WHERE tpl_id = ' . $ilDB->quote($a_tpl_id, 'integer');
61 $ilDB->manipulate($query);
62 return true;
63 }
64
70 public static function deleteByRefId($a_ref_id)
71 {
72 global $ilDB;
73
74 $query = 'DELETE FROM didactic_tpl_objs ' .
75 'WHERE ref_id = ' . $ilDB->quote($a_ref_id, 'integer');
76 $ilDB->manipulate($query);
77 }
78
86 public static function assignTemplate($a_ref_id, $a_obj_id, $a_tpl_id)
87 {
88 global $ilDB;
89
90 self::deleteByRefId($a_ref_id);
91
92 $query = 'INSERT INTO didactic_tpl_objs (ref_id,obj_id,tpl_id) ' .
93 'VALUES ( ' .
94 $ilDB->quote($a_ref_id, 'integer') . ', ' .
95 $ilDB->quote($a_obj_id, 'integer') . ', ' .
96 $ilDB->quote($a_tpl_id, 'integer') . ' ' .
97 ')';
98 $ilDB->manipulate($query);
99 return true;
100 }
107 public static function getAssignmentsByTemplateID($a_tpl_id)
108 {
109 global $ilDB;
110
111 $query = 'SELECT * FROM didactic_tpl_objs ' .
112 'WHERE tpl_id = ' . $ilDB->quote($a_tpl_id, 'integer');
113 $res = $ilDB->query($query);
114 $assignments = array();
115
116 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
117 $assignments[] = array("ref_id" => $row->ref_id, "obj_id" => $row->obj_id);
118 }
119 return $assignments;
120 }
121
122
130 public static function transferAutoGenerateStatus($a_src, $a_dest)
131 {
132 global $ilDB;
133
134 $query = 'SELECT auto_generated FROM didactic_tpl_settings ' .
135 'WHERE id = ' . $ilDB->quote($a_src, 'integer');
136 $res = $ilDB->query($query);
137
139
140 if ($row->auto_generated == 0) {
141 return false;
142 }
143
144 $query = 'UPDATE didactic_tpl_settings ' .
145 'SET ' .
146 'auto_generated = ' . $ilDB->quote(1, 'integer') .
147 ' WHERE id = ' . $ilDB->quote($a_dest, 'integer');
148 $ilDB->manipulate($query);
149
150 $query = 'UPDATE didactic_tpl_settings ' .
151 'SET ' .
152 'auto_generated = ' . $ilDB->quote(0, 'integer') .
153 ' WHERE id = ' . $ilDB->quote($a_src, 'integer');
154 $ilDB->manipulate($query);
155
156 return true;
157 }
158}
An exception for terminatinating execution or to throw for unit testing.
Stores the applied template id for objects.
static assignTemplate($a_ref_id, $a_obj_id, $a_tpl_id)
Assign template to object @global ilDB $ilDB.
static deleteByObjId($a_obj_id)
Delete by obj id @global ilDB $ilDB.
static deleteByRefId($a_ref_id)
Delete by ref_id @global ilDB $ilDB.
static deleteByTemplateId($a_tpl_id)
Delete by template id @global ilDB $ilDB.
static lookupTemplateId($a_ref_id)
Lookup template id @global ilDB $ilDB.
static getAssignmentsByTemplateID($a_tpl_id)
Lookup template id @global ilDB $ilDB.
static transferAutoGenerateStatus($a_src, $a_dest)
transfer auto generated flag if source is auto generated
$query
foreach($_POST as $key=> $value) $res
global $ilDB