ILIAS  release_4-4 Revision
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.

References read().

29  {
30  $this->read($a_id);
31  }
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 221 of file class.ilRatingCategory.php.

Referenced by ilRatingCategoryGUI\delete().

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

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

References $row.

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

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

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

Referenced by save(), and update().

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

References $description.

Referenced by getDBProperties().

109  {
110  return $this->description;
111  }
+ Here is the caller graph for this function:

◆ getId()

ilRatingCategory::getId ( )

Get id.

Returns
int

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

References $id.

Referenced by update().

49  {
50  return $this->id;
51  }
+ 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().

69  {
70  return $this->parent_id;
71  }
+ Here is the caller graph for this function:

◆ getPosition()

ilRatingCategory::getPosition ( )

Get position.

Returns
int

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

References $pos.

Referenced by getDBProperties().

129  {
130  return $this->pos;
131  }
+ 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().

89  {
90  return $this->title;
91  }
+ 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.

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

Referenced by __construct().

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

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

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  }
setPosition($a_value)
Set position.
getParentId()
Get parent object id.
setId($a_value)
Set id.
getDBProperties()
Parse properties into db definition.
+ 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.

Referenced by read().

99  {
100  $this->description = (string)$a_value;
101  }
+ 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.

Referenced by read(), and save().

39  {
40  $this->id = (int)$a_value;
41  }
+ 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.

Referenced by read().

59  {
60  $this->parent_id = (int)$a_value;
61  }
+ 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.

Referenced by read(), and save().

119  {
120  $this->pos = (int)$a_value;
121  }
+ 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.

Referenced by read().

79  {
80  $this->title = (string)$a_value;
81  }
+ Here is the caller graph for this function:

◆ update()

ilRatingCategory::update ( )

Update db entry.

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

References getDBProperties(), and getId().

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  }
getDBProperties()
Parse properties into db definition.
+ 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: