ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

34 {
35 global $DIC;
36
37 $this->db = $DIC->database();
38 $this->read($a_id);
39 }
read($a_id)
Load db entry.
global $DIC
Definition: saml.php:7

References $DIC, and read().

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

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 $ilDB

References $DIC, and $ilDB.

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

+ 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 }
static delete($a_id)
Delete db entry.

References delete().

+ Here is the call graph for this function:

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

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 }

References $DIC, $ilDB, and $row.

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

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

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 }
getDescription()
Get description.

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 ( )

Get description.

Returns
string

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

117 {
118 return $this->description;
119 }

References $description.

Referenced by getDBProperties().

+ Here is the caller graph for this function:

◆ getId()

ilRatingCategory::getId ( )

Get id.

Returns
int

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

57 {
58 return $this->id;
59 }

References $id.

Referenced by update().

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

+ Here is the caller graph for this function:

◆ getPosition()

ilRatingCategory::getPosition ( )

Get position.

Returns
int

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

137 {
138 return $this->pos;
139 }

References $pos.

Referenced by getDBProperties().

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

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

147 {
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.
setTitle($a_value)
Set title.
setParentId($a_value)
Set parent id.
setDescription($a_value)
Set description.
setId($a_value)
Set id.

References $db, $ilDB, $row, 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 ( )

Create db entry.

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

203 {
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 }
getParentId()
Get parent object id.
getDBProperties()
Parse properties into db definition.

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

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

107 {
108 $this->description = (string) $a_value;
109 }

Referenced by read().

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

47 {
48 $this->id = (int) $a_value;
49 }

Referenced by read(), and save().

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

67 {
68 $this->parent_id = (int) $a_value;
69 }

Referenced by read().

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

127 {
128 $this->pos = (int) $a_value;
129 }

Referenced by read(), and save().

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

87 {
88 $this->title = (string) $a_value;
89 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilRatingCategory::update ( )

Update db entry.

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

185 {
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 }

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

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