ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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

 $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 28 of file class.ilRatingCategory.php.

29 {
30 $this->read($a_id);
31 }
read($a_id)
Load db entry.

References 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 221 of file class.ilRatingCategory.php.

222 {
223 global $ilDB;
224
225 if((int)$a_id)
226 {
227 $sql = "DELETE FROM il_rating".
228 " WHERE category_id = ".$ilDB->quote($a_id, "integer");
229 $ilDB->manipulate($sql);
230
231 $sql = "DELETE FROM il_rating_cat".
232 " WHERE id = ".$ilDB->quote($a_id, "integer");
233 $ilDB->manipulate($sql);
234 }
235 }
global $ilDB

References $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 266 of file class.ilRatingCategory.php.

267 {
268 if((int)$a_parent_obj_id)
269 {
270 foreach(self::getAllForObject($a_parent_obj_id) as $item)
271 {
272 self::delete($item["id"]);
273 }
274 }
275 }
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 243 of file class.ilRatingCategory.php.

244 {
245 global $ilDB;
246
247 $cats = array();
248
249 $sql = "SELECT * FROM il_rating_cat".
250 " WHERE parent_id = ".$ilDB->quote($a_parent_obj_id, "integer").
251 " ORDER BY pos";
252 $set = $ilDB->query($sql);
253 while($row = $ilDB->fetchAssoc($set))
254 {
255 $cats[] = $row;
256 }
257
258 return $cats;
259 }

References $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 165 of file class.ilRatingCategory.php.

166 {
167 // parent id must not change
168 $fields = array("title" => array("text", $this->getTitle()),
169 "description" => array("text", $this->getDescription()),
170 "pos" => array("integer", $this->getPosition()));
171
172 return $fields;
173 }
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 108 of file class.ilRatingCategory.php.

109 {
110 return $this->description;
111 }

References $description.

Referenced by getDBProperties().

+ Here is the caller graph for this function:

◆ getId()

ilRatingCategory::getId ( )

Get id.

Returns
int

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

49 {
50 return $this->id;
51 }

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 68 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 128 of file class.ilRatingCategory.php.

129 {
130 return $this->pos;
131 }

References $pos.

Referenced by getDBProperties().

+ Here is the caller graph for this function:

◆ getTitle()

ilRatingCategory::getTitle ( )

Get title.

Returns
string

Definition at line 88 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 138 of file class.ilRatingCategory.php.

139 {
140 global $ilDB;
141
142 $a_id = (int)$a_id;
143 if($a_id)
144 {
145 $sql = "SELECT * FROM il_rating_cat".
146 " WHERE id = ".$ilDB->quote($a_id, "integer");
147 $set = $ilDB->query($sql);
148 $row = $ilDB->fetchAssoc($set);
149 if($row["id"])
150 {
151 $this->setId($row["id"]);
152 $this->setParentId($row["parent_id"]);
153 $this->setTitle($row["title"]);
154 $this->setDescription($row["description"]);
155 $this->setPosition($row["pos"]);
156 }
157 }
158 }
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 $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 194 of file class.ilRatingCategory.php.

195 {
196 global $ilDB;
197
198 $id = $ilDB->nextId("il_rating_cat");
199 $this->setId($id);
200
201 // append
202 $sql = "SELECT max(pos) pos FROM il_rating_cat".
203 " WHERE parent_id = ".$ilDB->quote($this->getParentId(), "integer");
204 $set = $ilDB->query($sql);
205 $pos = $ilDB->fetchAssoc($set);
206 $pos = $pos["pos"];
207 $this->setPosition($pos+10);
208
209 $fields = $this->getDBProperties();
210 $fields["id"] = array("integer", $id);
211 $fields["parent_id"] = array("integer", $this->getParentId());
212
213 $ilDB->insert("il_rating_cat", $fields);
214 }
getParentId()
Get parent object id.
getDBProperties()
Parse properties into db definition.

References $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 98 of file class.ilRatingCategory.php.

99 {
100 $this->description = (string)$a_value;
101 }

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 38 of file class.ilRatingCategory.php.

39 {
40 $this->id = (int)$a_value;
41 }

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 58 of file class.ilRatingCategory.php.

59 {
60 $this->parent_id = (int)$a_value;
61 }

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 118 of file class.ilRatingCategory.php.

119 {
120 $this->pos = (int)$a_value;
121 }

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 78 of file class.ilRatingCategory.php.

79 {
80 $this->title = (string)$a_value;
81 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilRatingCategory::update ( )

Update db entry.

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

179 {
180 global $ilDB;
181
182 if($this->getId())
183 {
184 $fields = $this->getDBProperties();
185
186 $ilDB->update("il_rating_cat", $fields,
187 array("id" => array("integer", $this->getId())));
188 }
189 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $description

ilRatingCategory::$description
protected

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

Referenced by getDescription().

◆ $id

ilRatingCategory::$id
protected

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

Referenced by getId(), and save().

◆ $parent_id

ilRatingCategory::$parent_id
protected

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

Referenced by getParentId().

◆ $pos

ilRatingCategory::$pos
protected

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

Referenced by getPosition(), and save().

◆ $title

ilRatingCategory::$title
protected

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

Referenced by getTitle().


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