ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilRatingCategory Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilRatingCategory:

Public Member Functions

 __construct (int $a_id=null, \ilDBInterface $db=null)
 
 setId (int $a_value)
 
 getId ()
 
 setParentId (int $a_value)
 
 getParentId ()
 
 setTitle (string $a_value)
 
 getTitle ()
 
 setDescription (string $a_value)
 
 getDescription ()
 
 setPosition (int $a_value)
 
 getPosition ()
 
 update ()
 
 save ()
 

Static Public Member Functions

static delete (int $a_id)
 
static getAllForObject (int $a_parent_obj_id)
 
static deleteForObject (int $a_parent_obj_id)
 

Protected Member Functions

 read (int $a_id)
 
 getDBProperties ()
 

Protected Attributes

ilDBInterface $db
 
int $id = 0
 
int $parent_id = 0
 
string $title = ""
 
string $description = ""
 
int $pos = 0
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilRatingCategory

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

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

Constructor & Destructor Documentation

◆ __construct()

ilRatingCategory::__construct ( int  $a_id = null,
\ilDBInterface  $db = null 
)

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

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

37  {
38  global $DIC;
39 
40  $this->db = (is_null($db))
41  ? $DIC->database()
42  : $db;
43 
44  if ($a_id > 0) {
45  $this->read($a_id);
46  }
47  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

static ilRatingCategory::delete ( int  $a_id)
static

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

References $DIC, and $ilDB.

Referenced by ilRatingCategoryGUI\delete().

167  : void
168  {
169  global $DIC;
170 
171  $ilDB = $DIC->database();
172 
173  if ($a_id > 0) {
174  $sql = "DELETE FROM il_rating" .
175  " WHERE category_id = " . $ilDB->quote($a_id, "integer");
176  $ilDB->manipulate($sql);
177 
178  $sql = "DELETE FROM il_rating_cat" .
179  " WHERE id = " . $ilDB->quote($a_id, "integer");
180  $ilDB->manipulate($sql);
181  }
182  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ deleteForObject()

static ilRatingCategory::deleteForObject ( int  $a_parent_obj_id)
static

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

205  : void
206  {
207  if ($a_parent_obj_id) {
208  foreach (self::getAllForObject($a_parent_obj_id) as $item) {
209  self::delete($item["id"]);
210  }
211  }
212  }

◆ getAllForObject()

static ilRatingCategory::getAllForObject ( int  $a_parent_obj_id)
static

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

References $DIC, and $ilDB.

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

185  : array
186  {
187  global $DIC;
188 
189  $ilDB = $DIC->database();
190 
191  $cats = array();
192 
193  $sql = "SELECT * FROM il_rating_cat" .
194  " WHERE parent_id = " . $ilDB->quote($a_parent_obj_id, "integer") .
195  " ORDER BY pos";
196  $set = $ilDB->query($sql);
197  while ($row = $ilDB->fetchAssoc($set)) {
198  $cats[] = $row;
199  }
200 
201  return $cats;
202  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getDBProperties()

ilRatingCategory::getDBProperties ( )
protected

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

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

Referenced by save(), and update().

120  : array
121  {
122  // parent id must not change
123  $fields = array("title" => array("text", $this->getTitle()),
124  "description" => array("text", $this->getDescription()),
125  "pos" => array("integer", $this->getPosition()));
126 
127  return $fields;
128  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescription()

ilRatingCategory::getDescription ( )

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

References $description.

Referenced by getDBProperties().

84  : string
85  {
86  return $this->description;
87  }
+ Here is the caller graph for this function:

◆ getId()

ilRatingCategory::getId ( )

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

References $id.

Referenced by update().

54  : int
55  {
56  return $this->id;
57  }
+ Here is the caller graph for this function:

◆ getParentId()

ilRatingCategory::getParentId ( )

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

References $parent_id.

Referenced by save().

64  : int
65  {
66  return $this->parent_id;
67  }
+ Here is the caller graph for this function:

◆ getPosition()

ilRatingCategory::getPosition ( )

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

References $pos.

Referenced by getDBProperties().

94  : int
95  {
96  return $this->pos;
97  }
+ Here is the caller graph for this function:

◆ getTitle()

ilRatingCategory::getTitle ( )

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

References $title.

Referenced by getDBProperties().

74  : string
75  {
76  return $this->title;
77  }
+ Here is the caller graph for this function:

◆ read()

ilRatingCategory::read ( int  $a_id)
protected

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

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

Referenced by __construct().

100  : void
101  {
102  $ilDB = $this->db;
103 
104  if ($a_id > 0) {
105  $sql = "SELECT * FROM il_rating_cat" .
106  " WHERE id = " . $ilDB->quote($a_id, "integer");
107  $set = $ilDB->query($sql);
108  $row = $ilDB->fetchAssoc($set);
109  if ($row["id"]) {
110  $this->setId($row["id"]);
111  $this->setParentId($row["parent_id"]);
112  $this->setTitle($row["title"]);
113  $this->setDescription($row["description"]);
114  $this->setPosition($row["pos"]);
115  }
116  }
117  }
setDescription(string $a_value)
setTitle(string $a_value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilRatingCategory::save ( )

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

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

145  : void
146  {
147  $ilDB = $this->db;
148 
149  $id = $ilDB->nextId("il_rating_cat");
150  $this->setId($id);
151 
152  // append
153  $sql = "SELECT max(pos) pos FROM il_rating_cat" .
154  " WHERE parent_id = " . $ilDB->quote($this->getParentId(), "integer");
155  $set = $ilDB->query($sql);
156  $pos = $ilDB->fetchAssoc($set);
157  $pos = $pos["pos"];
158  $this->setPosition($pos + 10);
159 
160  $fields = $this->getDBProperties();
161  $fields["id"] = array("integer", $id);
162  $fields["parent_id"] = array("integer", $this->getParentId());
163 
164  $ilDB->insert("il_rating_cat", $fields);
165  }
+ Here is the call graph for this function:

◆ setDescription()

ilRatingCategory::setDescription ( string  $a_value)

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

Referenced by read().

79  : void
80  {
81  $this->description = $a_value;
82  }
+ Here is the caller graph for this function:

◆ setId()

ilRatingCategory::setId ( int  $a_value)

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

Referenced by read(), and save().

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

◆ setParentId()

ilRatingCategory::setParentId ( int  $a_value)

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

Referenced by read().

59  : void
60  {
61  $this->parent_id = $a_value;
62  }
+ Here is the caller graph for this function:

◆ setPosition()

ilRatingCategory::setPosition ( int  $a_value)

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

Referenced by read(), and save().

89  : void
90  {
91  $this->pos = $a_value;
92  }
+ Here is the caller graph for this function:

◆ setTitle()

ilRatingCategory::setTitle ( string  $a_value)

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

Referenced by read().

69  : void
70  {
71  $this->title = $a_value;
72  }
+ Here is the caller graph for this function:

◆ update()

ilRatingCategory::update ( )

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

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

130  : void
131  {
132  $ilDB = $this->db;
133 
134  if ($this->getId()) {
135  $fields = $this->getDBProperties();
136 
137  $ilDB->update(
138  "il_rating_cat",
139  $fields,
140  array("id" => array("integer", $this->getId()))
141  );
142  }
143  }
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilRatingCategory::$db
protected

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

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

◆ $description

string ilRatingCategory::$description = ""
protected

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

Referenced by getDescription().

◆ $id

int ilRatingCategory::$id = 0
protected

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

Referenced by getId().

◆ $parent_id

int ilRatingCategory::$parent_id = 0
protected

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

Referenced by getParentId().

◆ $pos

int ilRatingCategory::$pos = 0
protected

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

Referenced by getPosition().

◆ $title

string ilRatingCategory::$title = ""
protected

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

Referenced by getTitle().


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