ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

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: shib_login.php:26

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

+ 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.

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 }

References $DIC, and $ilDB.

Referenced by ilRatingCategoryGUI\delete(), and deleteForObject().

+ 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 }
static delete(int $a_id)

References delete().

+ Here is the call graph for this function:

◆ getAllForObject()

static ilRatingCategory::getAllForObject ( int  $a_parent_obj_id)
static

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

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 }

References $DIC, and $ilDB.

Referenced by ilObjWiki\cloneObject(), ilRatingCategoryGUI\delete(), ilRatingCategoryGUI\export(), ilRatingGUI\getBlockHTML(), and ILIAS\Rating\RatingCategoryOrderingTable\initRecords().

+ Here is the caller graph for this function:

◆ getDBProperties()

ilRatingCategory::getDBProperties ( )
protected

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

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 }

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

Referenced by save(), and update().

+ 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.

84 : string
85 {
86 return $this->description;
87 }

References $description.

Referenced by getDBProperties().

+ Here is the caller graph for this function:

◆ getId()

ilRatingCategory::getId ( )

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

54 : int
55 {
56 return $this->id;
57 }

References $id.

Referenced by update().

+ Here is the caller graph for this function:

◆ getParentId()

ilRatingCategory::getParentId ( )

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

64 : int
65 {
66 return $this->parent_id;
67 }

References $parent_id.

Referenced by save().

+ Here is the caller graph for this function:

◆ getPosition()

ilRatingCategory::getPosition ( )

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

94 : int
95 {
96 return $this->pos;
97 }

References $pos.

Referenced by getDBProperties().

+ Here is the caller graph for this function:

◆ getTitle()

ilRatingCategory::getTitle ( )

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

74 : string
75 {
76 return $this->title;
77 }

References $title.

Referenced by getDBProperties().

+ Here is the caller graph for this function:

◆ read()

ilRatingCategory::read ( int  $a_id)
protected

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

100 : void
101 {
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 }
setTitle(string $a_value)
setDescription(string $a_value)

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

Referenced by __construct().

+ 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.

145 : void
146 {
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 }

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

+ Here is the call graph for this function:

◆ setDescription()

ilRatingCategory::setDescription ( string  $a_value)

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

79 : void
80 {
81 $this->description = $a_value;
82 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setId()

ilRatingCategory::setId ( int  $a_value)

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

49 : void
50 {
51 $this->id = $a_value;
52 }

Referenced by read(), and save().

+ Here is the caller graph for this function:

◆ setParentId()

ilRatingCategory::setParentId ( int  $a_value)

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

59 : void
60 {
61 $this->parent_id = $a_value;
62 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setPosition()

ilRatingCategory::setPosition ( int  $a_value)

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

89 : void
90 {
91 $this->pos = $a_value;
92 }

Referenced by read(), and save().

+ Here is the caller graph for this function:

◆ setTitle()

ilRatingCategory::setTitle ( string  $a_value)

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

69 : void
70 {
71 $this->title = $a_value;
72 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilRatingCategory::update ( )

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

130 : void
131 {
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 }

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

+ 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(), and save().

◆ $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(), and save().

◆ $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: