ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCustomBlock Class Reference

This is the super class of all custom blocks. More...

+ Inheritance diagram for ilCustomBlock:
+ Collaboration diagram for ilCustomBlock:

Public Member Functions

 __construct ($a_id=0)
 Constructor. More...
 
 setId ($a_id)
 Set Id. More...
 
 getId ()
 Get Id. More...
 
 setContextObjId ($a_context_obj_id)
 Set ContextObjId. More...
 
 getContextObjId ()
 Get ContextObjId. More...
 
 setContextObjType ($a_context_obj_type)
 Set ContextObjType. More...
 
 getContextObjType ()
 Get ContextObjType. More...
 
 setContextSubObjId ($a_context_sub_obj_id)
 Set ContextSubObjId. More...
 
 getContextSubObjId ()
 Get ContextSubObjId. More...
 
 setContextSubObjType ($a_context_sub_obj_type)
 Set ContextSubObjType. More...
 
 getContextSubObjType ()
 Get ContextSubObjType. More...
 
 setType ($a_type)
 Set Type. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 create ()
 Create new item. More...
 
 read ()
 Read item from database. More...
 
 update ()
 Update item in database. More...
 
 delete ()
 Delete item from database. More...
 
 querygetBlocksForContext ()
 Query getBlocksForContext. More...
 
 queryBlocksForContext ($a_include_sub_obj=true)
 Query BlocksForContext. More...
 
 queryTitleForId ()
 Query TitleForId. More...
 
 queryCntBlockForContext ()
 Query CntBlockForContext. More...
 

Static Public Member Functions

static multiBlockQuery ($a_context_obj_type, array $a_context_obj_ids)
 

Protected Attributes

 $db
 
 $id
 
 $context_obj_id
 
 $context_obj_type
 
 $context_sub_obj_id
 
 $context_sub_obj_type
 
 $type
 
 $title
 

Detailed Description

This is the super class of all custom blocks.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilCustomBlock::__construct (   $a_id = 0)

Constructor.

Parameters
int$a_id

Definition at line 32 of file class.ilCustomBlock.php.

References $DIC, read(), and setId().

33  {
34  global $DIC;
35 
36  $this->db = $DIC->database();
37  if ($a_id > 0) {
38  $this->setId($a_id);
39  $this->read();
40  }
41  }
read()
Read item from database.
global $DIC
Definition: saml.php:7
setId($a_id)
Set Id.
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilCustomBlock::create ( )

Create new item.

Definition at line 187 of file class.ilCustomBlock.php.

References $db, $ilDB, $query, getContextObjId(), getContextObjType(), getContextSubObjId(), getContextSubObjType(), getId(), getTitle(), getType(), and setId().

188  {
189  $ilDB = $this->db;
190 
191  $this->setId($ilDB->nextId("il_custom_block"));
192  $query = "INSERT INTO il_custom_block (" .
193  " id" .
194  ", context_obj_id" .
195  ", context_obj_type" .
196  ", context_sub_obj_id" .
197  ", context_sub_obj_type" .
198  ", type" .
199  ", title" .
200  " ) VALUES (" .
201  $ilDB->quote($this->getId(), "integer")
202  . "," . $ilDB->quote($this->getContextObjId(), "integer")
203  . "," . $ilDB->quote($this->getContextObjType(), "text")
204  . "," . $ilDB->quote($this->getContextSubObjId(), "integer")
205  . "," . $ilDB->quote($this->getContextSubObjType(), "text")
206  . "," . $ilDB->quote($this->getType(), "text")
207  . "," . $ilDB->quote($this->getTitle(), "text") . ")";
208  $ilDB->manipulate($query);
209  }
setId($a_id)
Set Id.
getContextObjType()
Get ContextObjType.
getContextSubObjType()
Get ContextSubObjType.
$query
getContextSubObjId()
Get ContextSubObjId.
global $ilDB
getTitle()
Get Title.
getContextObjId()
Get ContextObjId.
+ Here is the call graph for this function:

◆ delete()

ilCustomBlock::delete ( )

Delete item from database.

Definition at line 256 of file class.ilCustomBlock.php.

References $db, $ilDB, $query, and getId().

257  {
258  $ilDB = $this->db;
259 
260  $query = "DELETE FROM il_custom_block" .
261  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
262 
263  $ilDB->manipulate($query);
264  }
$query
global $ilDB
+ Here is the call graph for this function:

◆ getContextObjId()

ilCustomBlock::getContextObjId ( )

Get ContextObjId.

Returns
int

Definition at line 78 of file class.ilCustomBlock.php.

References $context_obj_id.

Referenced by create(), queryBlocksForContext(), queryCntBlockForContext(), querygetBlocksForContext(), and update().

79  {
80  return (int) $this->context_obj_id;
81  }
+ Here is the caller graph for this function:

◆ getContextObjType()

ilCustomBlock::getContextObjType ( )

Get ContextObjType.

Returns
int

Definition at line 98 of file class.ilCustomBlock.php.

References $context_obj_type.

Referenced by create(), queryBlocksForContext(), queryCntBlockForContext(), querygetBlocksForContext(), and update().

99  {
101  }
+ Here is the caller graph for this function:

◆ getContextSubObjId()

ilCustomBlock::getContextSubObjId ( )

Get ContextSubObjId.

Returns
int

Definition at line 118 of file class.ilCustomBlock.php.

References $context_sub_obj_id.

Referenced by create(), queryBlocksForContext(), queryCntBlockForContext(), querygetBlocksForContext(), and update().

119  {
120  return (int) $this->context_sub_obj_id;
121  }
+ Here is the caller graph for this function:

◆ getContextSubObjType()

ilCustomBlock::getContextSubObjType ( )

Get ContextSubObjType.

Returns
int

Definition at line 138 of file class.ilCustomBlock.php.

References $context_sub_obj_type.

Referenced by create(), queryBlocksForContext(), queryCntBlockForContext(), querygetBlocksForContext(), and update().

139  {
141  }
+ Here is the caller graph for this function:

◆ getId()

ilCustomBlock::getId ( )

Get Id.

Returns
int

Definition at line 58 of file class.ilCustomBlock.php.

References $id.

Referenced by ilExternalFeedBlock\create(), create(), ilExternalFeedBlock\delete(), delete(), ilExternalFeedBlock\read(), read(), ilExternalFeedBlock\update(), and update().

59  {
60  return $this->id;
61  }
+ Here is the caller graph for this function:

◆ getTitle()

ilCustomBlock::getTitle ( )

Get Title.

Returns
string Title of block

Definition at line 178 of file class.ilCustomBlock.php.

References $title.

Referenced by create(), and update().

179  {
180  return $this->title;
181  }
+ Here is the caller graph for this function:

◆ getType()

ilCustomBlock::getType ( )

Get Type.

Returns
string Type of block.

Definition at line 158 of file class.ilCustomBlock.php.

References $type.

Referenced by create(), queryCntBlockForContext(), and update().

159  {
160  return $this->type;
161  }
+ Here is the caller graph for this function:

◆ multiBlockQuery()

static ilCustomBlock::multiBlockQuery (   $a_context_obj_type,
array  $a_context_obj_ids 
)
static

Definition at line 370 of file class.ilCustomBlock.php.

References $DIC, $ilDB, $query, $result, and array.

371  {
372  global $DIC;
373 
374  $ilDB = $DIC->database();
375 
376  $query = "SELECT id, context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, type, title " .
377  "FROM il_custom_block " .
378  "WHERE " .
379  $ilDB->in("context_obj_id", $a_context_obj_ids, "", "integer") .
380  " AND context_obj_type = " . $ilDB->quote($a_context_obj_type, "text") .
381  " ORDER BY title";
382  $set = $ilDB->query($query);
383  $result = array();
384  while ($rec = $ilDB->fetchAssoc($set)) {
385  $result[] = $rec;
386  }
387 
388  return $result;
389  }
$result
global $DIC
Definition: saml.php:7
$query
Create styles array
The data for the language used.
global $ilDB

◆ queryBlocksForContext()

ilCustomBlock::queryBlocksForContext (   $a_include_sub_obj = true)

Query BlocksForContext.

Definition at line 296 of file class.ilCustomBlock.php.

References $db, $ilDB, $query, $result, array, getContextObjId(), getContextObjType(), getContextSubObjId(), and getContextSubObjType().

297  {
298  $ilDB = $this->db;
299 
300  $query = "SELECT id, context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, type, title " .
301  "FROM il_custom_block " .
302  "WHERE " .
303  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
304  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text");
305  if ($a_include_sub_obj_id) {
306  $query .= " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
307  " AND " . $ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true);
308  //" AND context_sub_obj_type = ".$ilDB->quote($this->getContextSubObjType(), "text")."";
309  }
310  //echo "$query";
311  $set = $ilDB->query($query);
312  $result = array();
313  while ($rec = $ilDB->fetchAssoc($set)) {
314  $result[] = $rec;
315  }
316 
317  return $result;
318  }
$result
getContextObjType()
Get ContextObjType.
getContextSubObjType()
Get ContextSubObjType.
$query
Create styles array
The data for the language used.
getContextSubObjId()
Get ContextSubObjId.
global $ilDB
getContextObjId()
Get ContextObjId.
+ Here is the call graph for this function:

◆ queryCntBlockForContext()

ilCustomBlock::queryCntBlockForContext ( )

Query CntBlockForContext.

Definition at line 348 of file class.ilCustomBlock.php.

References $db, $ilDB, $query, $result, array, getContextObjId(), getContextObjType(), getContextSubObjId(), getContextSubObjType(), and getType().

349  {
350  $ilDB = $this->db;
351 
352  $query = "SELECT count(*) as cnt " .
353  "FROM il_custom_block " .
354  "WHERE " .
355  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
356  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
357  " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
358  " AND " . $ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true) .
359  " AND type = " . $ilDB->quote($this->getType(), "text") . "";
360 
361  $set = $ilDB->query($query);
362  $result = array();
363  while ($rec = $ilDB->fetchAssoc($set)) {
364  $result[] = $rec;
365  }
366 
367  return $result;
368  }
$result
getContextObjType()
Get ContextObjType.
getContextSubObjType()
Get ContextSubObjType.
$query
Create styles array
The data for the language used.
getContextSubObjId()
Get ContextSubObjId.
global $ilDB
getContextObjId()
Get ContextObjId.
+ Here is the call graph for this function:

◆ querygetBlocksForContext()

ilCustomBlock::querygetBlocksForContext ( )

Query getBlocksForContext.

Definition at line 270 of file class.ilCustomBlock.php.

References $db, $ilDB, $query, $result, array, getContextObjId(), getContextObjType(), getContextSubObjId(), and getContextSubObjType().

271  {
272  $ilDB = $this->db;
273 
274  $query = "SELECT id, context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, type, title " .
275  "FROM il_custom_block " .
276  "WHERE " .
277  "context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
278  " AND context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
279  " AND context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
280  " AND " . $ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true);
281  //" AND context_sub_obj_type = ".$ilDB->quote($this->getContextSubObjType(), "text")."";
282 
283  $set = $ilDB->query($query);
284  $result = array();
285  while ($rec = $ilDB->fetchAssoc($set)) {
286  $result[] = $rec;
287  }
288 
289  return $result;
290  }
$result
getContextObjType()
Get ContextObjType.
getContextSubObjType()
Get ContextSubObjType.
$query
Create styles array
The data for the language used.
getContextSubObjId()
Get ContextSubObjId.
global $ilDB
getContextObjId()
Get ContextObjId.
+ Here is the call graph for this function:

◆ queryTitleForId()

ilCustomBlock::queryTitleForId ( )

Query TitleForId.

Definition at line 324 of file class.ilCustomBlock.php.

References $db, and $ilDB.

325  {
326  $ilDB = $this->db;
327  die("ilCustomBlock::queryTitleForId is deprecated");
328  /*
329  $query = "SELECT id ".
330  "FROM il_custom_block ".
331  "WHERE "."";
332 
333  $set = $ilDB->query($query);
334  $result = array();
335  while($rec = $set->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
336  {
337  $result[] = $rec;
338  }
339 
340  return $result;
341  */
342  }
global $ilDB

◆ read()

ilCustomBlock::read ( )

Read item from database.

Definition at line 215 of file class.ilCustomBlock.php.

References $db, $ilDB, $query, getId(), setContextObjId(), setContextObjType(), setContextSubObjId(), setContextSubObjType(), setTitle(), and setType().

Referenced by __construct().

216  {
217  $ilDB = $this->db;
218 
219  $query = "SELECT * FROM il_custom_block WHERE id = " .
220  $ilDB->quote($this->getId(), "integer");
221  $set = $ilDB->query($query);
222  $rec = $ilDB->fetchAssoc($set);
223 
224  $this->setContextObjId($rec["context_obj_id"]);
225  $this->setContextObjType($rec["context_obj_type"]);
226  $this->setContextSubObjId($rec["context_sub_obj_id"]);
227  $this->setContextSubObjType($rec["context_sub_obj_type"]);
228  $this->setType($rec["type"]);
229  $this->setTitle($rec["title"]);
230  }
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
setTitle($a_title)
Set Title.
setType($a_type)
Set Type.
$query
global $ilDB
setContextObjType($a_context_obj_type)
Set ContextObjType.
setContextObjId($a_context_obj_id)
Set ContextObjId.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setContextObjId()

ilCustomBlock::setContextObjId (   $a_context_obj_id)

Set ContextObjId.

Parameters
int$a_context_obj_id

Definition at line 68 of file class.ilCustomBlock.php.

Referenced by read().

69  {
70  $this->context_obj_id = $a_context_obj_id;
71  }
+ Here is the caller graph for this function:

◆ setContextObjType()

ilCustomBlock::setContextObjType (   $a_context_obj_type)

Set ContextObjType.

Parameters
int$a_context_obj_type

Definition at line 88 of file class.ilCustomBlock.php.

Referenced by read().

89  {
90  $this->context_obj_type = $a_context_obj_type;
91  }
+ Here is the caller graph for this function:

◆ setContextSubObjId()

ilCustomBlock::setContextSubObjId (   $a_context_sub_obj_id)

Set ContextSubObjId.

Parameters
int$a_context_sub_obj_id

Definition at line 108 of file class.ilCustomBlock.php.

Referenced by read().

109  {
110  $this->context_sub_obj_id = $a_context_sub_obj_id;
111  }
+ Here is the caller graph for this function:

◆ setContextSubObjType()

ilCustomBlock::setContextSubObjType (   $a_context_sub_obj_type)

Set ContextSubObjType.

Parameters
int$a_context_sub_obj_type

Definition at line 128 of file class.ilCustomBlock.php.

Referenced by read().

129  {
130  $this->context_sub_obj_type = $a_context_sub_obj_type;
131  }
+ Here is the caller graph for this function:

◆ setId()

ilCustomBlock::setId (   $a_id)

Set Id.

Parameters
int$a_id

Definition at line 48 of file class.ilCustomBlock.php.

Referenced by __construct(), ilExternalFeedBlock\__construct(), and create().

49  {
50  $this->id = $a_id;
51  }
+ Here is the caller graph for this function:

◆ setTitle()

ilCustomBlock::setTitle (   $a_title)

Set Title.

Parameters
string$a_titleTitle of block

Definition at line 168 of file class.ilCustomBlock.php.

Referenced by read().

169  {
170  $this->title = $a_title;
171  }
+ Here is the caller graph for this function:

◆ setType()

ilCustomBlock::setType (   $a_type)

Set Type.

Parameters
string$a_typeType of block.

Definition at line 148 of file class.ilCustomBlock.php.

References $a_type.

Referenced by read().

149  {
150  $this->type = $a_type;
151  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ update()

ilCustomBlock::update ( )

Update item in database.

Definition at line 236 of file class.ilCustomBlock.php.

References $db, $ilDB, $query, getContextObjId(), getContextObjType(), getContextSubObjId(), getContextSubObjType(), getId(), getTitle(), and getType().

237  {
238  $ilDB = $this->db;
239 
240  $query = "UPDATE il_custom_block SET " .
241  " context_obj_id = " . $ilDB->quote($this->getContextObjId(), "integer") .
242  ", context_obj_type = " . $ilDB->quote($this->getContextObjType(), "text") .
243  ", context_sub_obj_id = " . $ilDB->quote($this->getContextSubObjId(), "integer") .
244  ", context_sub_obj_type = " . $ilDB->quote($this->getContextSubObjType(), "text") .
245  ", type = " . $ilDB->quote($this->getType(), "text") .
246  ", title = " . $ilDB->quote($this->getTitle(), "text") .
247  " WHERE id = " . $ilDB->quote($this->getId(), "integer");
248 
249  $ilDB->manipulate($query);
250  }
getContextObjType()
Get ContextObjType.
getContextSubObjType()
Get ContextSubObjType.
$query
getContextSubObjId()
Get ContextSubObjId.
global $ilDB
getTitle()
Get Title.
getContextObjId()
Get ContextObjId.
+ Here is the call graph for this function:

Field Documentation

◆ $context_obj_id

ilCustomBlock::$context_obj_id
protected

Definition at line 20 of file class.ilCustomBlock.php.

Referenced by getContextObjId().

◆ $context_obj_type

ilCustomBlock::$context_obj_type
protected

Definition at line 21 of file class.ilCustomBlock.php.

Referenced by getContextObjType().

◆ $context_sub_obj_id

ilCustomBlock::$context_sub_obj_id
protected

Definition at line 22 of file class.ilCustomBlock.php.

Referenced by getContextSubObjId().

◆ $context_sub_obj_type

ilCustomBlock::$context_sub_obj_type
protected

Definition at line 23 of file class.ilCustomBlock.php.

Referenced by getContextSubObjType().

◆ $db

◆ $id

ilCustomBlock::$id
protected

Definition at line 19 of file class.ilCustomBlock.php.

Referenced by getId().

◆ $title

ilCustomBlock::$title
protected

Definition at line 25 of file class.ilCustomBlock.php.

Referenced by getTitle().

◆ $type

ilCustomBlock::$type
protected

Definition at line 24 of file class.ilCustomBlock.php.

Referenced by getType().


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