ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilSCGroup.php
Go to the documentation of this file.
1 <?php
2 
3 include_once './Services/Calendar/classes/class.ilDateTime.php';
4 
5 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
6 
12 class ilSCGroup
13 {
14  private $id = 0;
15  private $component_id = '';
16  private $component_type = '';
17  private $last_update = null;
18  private $status = 0;
19 
20 
25  public function __construct($a_id = 0)
26  {
27  $this->id = $a_id;
28  $this->read();
29  }
30 
37  public static function lookupComponent($a_id)
38  {
39  global $DIC;
40 
41  $ilDB = $DIC['ilDB'];
42 
43  $query = 'SELECT component FROM sysc_groups ' .
44  'WHERE id = ' . $ilDB->quote($a_id, 'integer');
45  $res = $ilDB->query($query);
46  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
47  return (string) $row->component;
48  }
49  return '';
50  }
51 
52  public function getId()
53  {
54  return $this->id;
55  }
56 
57 
58  public function setComponentId($a_comp)
59  {
60  $this->component_id = $a_comp;
61  }
62 
67  public function getComponentId()
68  {
69  return $this->component_id;
70  }
71 
72 
73  public function setLastUpdate(ilDateTime $a_update)
74  {
75  $this->last_update = $a_update;
76  }
77 
82  public function getLastUpdate()
83  {
84  if (!$this->last_update) {
85  return $this->last_update = new ilDateTime();
86  }
87  return $this->last_update;
88  }
89 
90  public function setStatus($a_status)
91  {
92  $this->status = $a_status;
93  }
94 
99  public function getStatus()
100  {
101  return $this->status;
102  }
103 
107  public function read()
108  {
109  global $DIC;
110 
111  $ilDB = $DIC['ilDB'];
112 
113  if (!$this->getId()) {
114  return false;
115  }
116 
117  $query = 'SELECT * FROM sysc_groups ' .
118  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
119  $res = $ilDB->query($query);
120  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
121  $this->setComponentId($row->component);
122  $this->setLastUpdate(new ilDateTime($row->last_update, IL_CAL_DATETIME, ilTimeZone::UTC));
123  $this->setStatus($row->status);
124  }
125  return true;
126  }
127 
131  public function create()
132  {
133  global $DIC;
134 
135  $ilDB = $DIC['ilDB'];
136 
137  $this->id = $ilDB->nextId('sysc_groups');
138 
139  $query = 'INSERT INTO sysc_groups (id,component,status) ' .
140  'VALUES ( ' .
141  $ilDB->quote($this->getId(), 'integer') . ', ' .
142  $ilDB->quote($this->getComponentId(), 'text') . ', ' .
143  $ilDB->quote($this->getStatus(), 'integer') . ' ' .
144  ')';
145  $ilDB->manipulate($query);
146  return $this->getId();
147  }
148 }
const IL_CAL_DATETIME
getComponentId()
Get component.
global $DIC
Definition: saml.php:7
getLastUpdate()
Get last update date.
getStatus()
Get status.
create()
Create new group.
static lookupComponent($a_id)
lookup component by id type $ilDB
foreach($_POST as $key=> $value) $res
setLastUpdate(ilDateTime $a_update)
Date and time handling
$query
$row
global $ilDB
read()
Read group.
setStatus($a_status)
__construct($a_id=0)
Constructor.
setComponentId($a_comp)
Defines a system check group including different tasks of a component.