ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilRatingCategory Class Reference

Class ilRatingCategory. More...

+ Collaboration diagram for ilRatingCategory:

Public Member Functions

 __construct ($a_id=null)
 Constructor. More...
 
 setId ($a_value)
 Set id. More...
 
 getId ()
 Get id. More...
 
 setParentId ($a_value)
 Set parent id. More...
 
 getParentId ()
 Get parent object id. More...
 
 setTitle ($a_value)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 setDescription ($a_value)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 setPosition ($a_value)
 Set position. More...
 
 getPosition ()
 Get position. More...
 
 update ()
 Update db entry. More...
 
 save ()
 Create db entry. More...
 

Static Public Member Functions

static delete ($a_id)
 Delete db entry. More...
 
static getAllForObject ($a_parent_obj_id)
 Get all categories for object. More...
 
static deleteForObject ($a_parent_obj_id)
 Delete all categories for object. More...
 

Protected Member Functions

 read ($a_id)
 Load db entry. More...
 
 getDBProperties ()
 Parse properties into db definition. More...
 

Protected Attributes

 $db
 
 $id
 
 $parent_id
 
 $title
 
 $description
 
 $pos
 

Detailed Description

Class ilRatingCategory.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 15 of file class.ilRatingCategory.php.

Constructor & Destructor Documentation

◆ __construct()

ilRatingCategory::__construct (   $a_id = null)

Constructor.

Parameters
int$a_id

Definition at line 33 of file class.ilRatingCategory.php.

References $DIC, and read().

34  {
35  global $DIC;
36 
37  $this->db = $DIC->database();
38  $this->read($a_id);
39  }
global $DIC
Definition: saml.php:7
read($a_id)
Load db entry.
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

static ilRatingCategory::delete (   $a_id)
static

Delete db entry.

Parameters
int$a_id

Definition at line 229 of file class.ilRatingCategory.php.

References $DIC, and $ilDB.

Referenced by ilRatingCategoryGUI\delete().

230  {
231  global $DIC;
232 
233  $ilDB = $DIC->database();
234 
235  if ((int) $a_id) {
236  $sql = "DELETE FROM il_rating" .
237  " WHERE category_id = " . $ilDB->quote($a_id, "integer");
238  $ilDB->manipulate($sql);
239 
240  $sql = "DELETE FROM il_rating_cat" .
241  " WHERE id = " . $ilDB->quote($a_id, "integer");
242  $ilDB->manipulate($sql);
243  }
244  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ deleteForObject()

static ilRatingCategory::deleteForObject (   $a_parent_obj_id)
static

Delete all categories for object.

Parameters
int$a_parent_obj_id

Definition at line 276 of file class.ilRatingCategory.php.

277  {
278  if ((int) $a_parent_obj_id) {
279  foreach (self::getAllForObject($a_parent_obj_id) as $item) {
280  self::delete($item["id"]);
281  }
282  }
283  }

◆ getAllForObject()

static ilRatingCategory::getAllForObject (   $a_parent_obj_id)
static

Get all categories for object.

Parameters
int$a_parent_obj_id
Returns
array

Definition at line 252 of file class.ilRatingCategory.php.

References $DIC, $ilDB, and $row.

Referenced by ilObjWiki\cloneObject(), ilRatingCategoryGUI\delete(), ilRatingCategoryGUI\export(), ilRatingGUI\getBlockHTML(), ilRatingGUI\getHTML(), and ilRatingCategoryTableGUI\getItems().

253  {
254  global $DIC;
255 
256  $ilDB = $DIC->database();
257 
258  $cats = array();
259 
260  $sql = "SELECT * FROM il_rating_cat" .
261  " WHERE parent_id = " . $ilDB->quote($a_parent_obj_id, "integer") .
262  " ORDER BY pos";
263  $set = $ilDB->query($sql);
264  while ($row = $ilDB->fetchAssoc($set)) {
265  $cats[] = $row;
266  }
267 
268  return $cats;
269  }
global $DIC
Definition: saml.php:7
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getDBProperties()

ilRatingCategory::getDBProperties ( )
protected

Parse properties into db definition.

Returns
array

Definition at line 171 of file class.ilRatingCategory.php.

References getDescription(), getPosition(), and getTitle().

Referenced by save(), and update().

172  {
173  // parent id must not change
174  $fields = array("title" => array("text", $this->getTitle()),
175  "description" => array("text", $this->getDescription()),
176  "pos" => array("integer", $this->getPosition()));
177 
178  return $fields;
179  }
getPosition()
Get position.
getDescription()
Get description.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescription()

ilRatingCategory::getDescription ( )

Get description.

Returns
string

Definition at line 116 of file class.ilRatingCategory.php.

References $description.

Referenced by getDBProperties().

117  {
118  return $this->description;
119  }
+ Here is the caller graph for this function:

◆ getId()

ilRatingCategory::getId ( )

Get id.

Returns
int

Definition at line 56 of file class.ilRatingCategory.php.

References $id.

Referenced by update().

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

◆ getParentId()

ilRatingCategory::getParentId ( )

Get parent object id.

Returns
int

Definition at line 76 of file class.ilRatingCategory.php.

References $parent_id.

Referenced by save().

77  {
78  return $this->parent_id;
79  }
+ Here is the caller graph for this function:

◆ getPosition()

ilRatingCategory::getPosition ( )

Get position.

Returns
int

Definition at line 136 of file class.ilRatingCategory.php.

References $pos.

Referenced by getDBProperties().

137  {
138  return $this->pos;
139  }
+ Here is the caller graph for this function:

◆ getTitle()

ilRatingCategory::getTitle ( )

Get title.

Returns
string

Definition at line 96 of file class.ilRatingCategory.php.

References $title.

Referenced by getDBProperties().

97  {
98  return $this->title;
99  }
+ Here is the caller graph for this function:

◆ read()

ilRatingCategory::read (   $a_id)
protected

Load db entry.

Parameters
int$a_id

Definition at line 146 of file class.ilRatingCategory.php.

References $db, $ilDB, $row, setDescription(), setId(), setParentId(), setPosition(), and setTitle().

Referenced by __construct().

147  {
148  $ilDB = $this->db;
149 
150  $a_id = (int) $a_id;
151  if ($a_id) {
152  $sql = "SELECT * FROM il_rating_cat" .
153  " WHERE id = " . $ilDB->quote($a_id, "integer");
154  $set = $ilDB->query($sql);
155  $row = $ilDB->fetchAssoc($set);
156  if ($row["id"]) {
157  $this->setId($row["id"]);
158  $this->setParentId($row["parent_id"]);
159  $this->setTitle($row["title"]);
160  $this->setDescription($row["description"]);
161  $this->setPosition($row["pos"]);
162  }
163  }
164  }
setPosition($a_value)
Set position.
setId($a_value)
Set id.
setParentId($a_value)
Set parent id.
$row
setTitle($a_value)
Set title.
setDescription($a_value)
Set description.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilRatingCategory::save ( )

Create db entry.

Definition at line 202 of file class.ilRatingCategory.php.

References $db, $id, $ilDB, $pos, getDBProperties(), getParentId(), setId(), and setPosition().

203  {
204  $ilDB = $this->db;
205 
206  $id = $ilDB->nextId("il_rating_cat");
207  $this->setId($id);
208 
209  // append
210  $sql = "SELECT max(pos) pos FROM il_rating_cat" .
211  " WHERE parent_id = " . $ilDB->quote($this->getParentId(), "integer");
212  $set = $ilDB->query($sql);
213  $pos = $ilDB->fetchAssoc($set);
214  $pos = $pos["pos"];
215  $this->setPosition($pos + 10);
216 
217  $fields = $this->getDBProperties();
218  $fields["id"] = array("integer", $id);
219  $fields["parent_id"] = array("integer", $this->getParentId());
220 
221  $ilDB->insert("il_rating_cat", $fields);
222  }
setPosition($a_value)
Set position.
getParentId()
Get parent object id.
setId($a_value)
Set id.
getDBProperties()
Parse properties into db definition.
global $ilDB
+ Here is the call graph for this function:

◆ setDescription()

ilRatingCategory::setDescription (   $a_value)

Set description.

Parameters
string$a_value

Definition at line 106 of file class.ilRatingCategory.php.

Referenced by read().

107  {
108  $this->description = (string) $a_value;
109  }
+ Here is the caller graph for this function:

◆ setId()

ilRatingCategory::setId (   $a_value)

Set id.

Parameters
int$a_value

Definition at line 46 of file class.ilRatingCategory.php.

Referenced by read(), and save().

47  {
48  $this->id = (int) $a_value;
49  }
+ Here is the caller graph for this function:

◆ setParentId()

ilRatingCategory::setParentId (   $a_value)

Set parent id.

Parameters
int$a_value

Definition at line 66 of file class.ilRatingCategory.php.

Referenced by read().

67  {
68  $this->parent_id = (int) $a_value;
69  }
+ Here is the caller graph for this function:

◆ setPosition()

ilRatingCategory::setPosition (   $a_value)

Set position.

Parameters
int$a_value

Definition at line 126 of file class.ilRatingCategory.php.

Referenced by read(), and save().

127  {
128  $this->pos = (int) $a_value;
129  }
+ Here is the caller graph for this function:

◆ setTitle()

ilRatingCategory::setTitle (   $a_value)

Set title.

Parameters
string$a_value

Definition at line 86 of file class.ilRatingCategory.php.

Referenced by read().

87  {
88  $this->title = (string) $a_value;
89  }
+ Here is the caller graph for this function:

◆ update()

ilRatingCategory::update ( )

Update db entry.

Definition at line 184 of file class.ilRatingCategory.php.

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

185  {
186  $ilDB = $this->db;
187 
188  if ($this->getId()) {
189  $fields = $this->getDBProperties();
190 
191  $ilDB->update(
192  "il_rating_cat",
193  $fields,
194  array("id" => array("integer", $this->getId()))
195  );
196  }
197  }
getDBProperties()
Parse properties into db definition.
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilRatingCategory::$db
protected

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

Referenced by read(), save(), and update().

◆ $description

ilRatingCategory::$description
protected

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

Referenced by getDescription().

◆ $id

ilRatingCategory::$id
protected

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

Referenced by getId(), and save().

◆ $parent_id

ilRatingCategory::$parent_id
protected

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

Referenced by getParentId().

◆ $pos

ilRatingCategory::$pos
protected

Definition at line 26 of file class.ilRatingCategory.php.

Referenced by getPosition(), and save().

◆ $title

ilRatingCategory::$title
protected

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

Referenced by getTitle().


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