ILIAS  release_4-4 Revision
ilOrgUnit Class Reference
+ Collaboration diagram for ilOrgUnit:

Public Member Functions

 initAssigns ()
 
 assignUser ($a_user_id, $a_reporting_access, $a_cc_compl_invit, $a_cc_compl_not1, $a_cc_compl_not2)
 
 deassignUser ($a_user_id)
 
 isUserAssigned ($a_user_id)
 
 getAssignedUsers ()
 
 read ()
 
 update ()
 
 create ()
 
 delete ()
 
 hasUserReportingAccess ($a_user_id)
 
 setId ($ou_id)
 
 getId ()
 
 setTitle ($ou_title)
 
 getTitle ()
 
 setSubTitle ($ou_subtitle)
 
 getSubTitle ()
 
 setImportId ($ou_import_id)
 
 getImportId ()
 
 setParent ($a_parent)
 
 getParent ()
 
 addChild ($a_child)
 
 getChilds ()
 
 hasChilds ()
 
 sortChilds ()
 
 sortCallback ($a_a, $a_b)
 

Static Public Member Functions

static deleteInstance ($ou_id)
 
static getInstance ($ou_id)
 
static createInstance ($ou_title, $ou_subtitle, $ou_import_id)
 
static lookupIdByImportId ($ou_import_id)
 
static getInstancesByAssignedUser ($a_user_id)
 

Private Member Functions

 __construct ($ou_id=0)
 

Private Attributes

 $id = 0
 
 $title = ''
 
 $subtitle = ''
 
 $import_id = 0
 
 $parent = 0
 
 $childs = array()
 
 $assignment_list = null
 

Static Private Attributes

static $instance_cache = array()
 
static $import_id_cache = array()
 

Detailed Description

Definition at line 5 of file class.ilOrgUnit.php.

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnit::__construct (   $ou_id = 0)
private

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

References read().

21  {
22  if( (int)$ou_id > 0 )
23  {
24  $this->id = (int)$ou_id;
25  $this->read();
26  }
27  }
+ Here is the call graph for this function:

Member Function Documentation

◆ addChild()

ilOrgUnit::addChild (   $a_child)

Definition at line 274 of file class.ilOrgUnit.php.

275  {
276  $this->childs[] = $a_child;
277  return $this;
278  }

◆ assignUser()

ilOrgUnit::assignUser (   $a_user_id,
  $a_reporting_access,
  $a_cc_compl_invit,
  $a_cc_compl_not1,
  $a_cc_compl_not2 
)

Definition at line 35 of file class.ilOrgUnit.php.

37  {
38  if($this->assignment_list === null)
39  throw new ilOrgUnitException('Error: Assignment object not initialised yet!');
40 
41  $this->assignment_list->addAssignment($a_user_id, $a_reporting_access,
42  $a_cc_compl_invit, $a_cc_compl_not1, $a_cc_compl_not2);
43  }

◆ create()

ilOrgUnit::create ( )

Definition at line 118 of file class.ilOrgUnit.php.

119  {
120  global $ilDB;
121 
122  $this->id = $ilDB->nextId('org_unit_data');
123 
124  $ilDB->insert(
125  'org_unit_data',
126  array(
127  'ou_id' => array('integer', $this->id),
128  'ou_title' => array('text', $this->title),
129  'ou_subtitle' => array('text', $this->subtitle),
130  'ou_import_id' => array('text', $this->import_id)
131  ),
132  array('ou_id' => array('integer', $this->id))
133  );
134  }

◆ createInstance()

static ilOrgUnit::createInstance (   $ou_title,
  $ou_subtitle,
  $ou_import_id 
)
static

Definition at line 165 of file class.ilOrgUnit.php.

166  {
167  $unit = new self();
168 
169  $unit ->setTitle($ou_title)
170  ->setSubTitle($ou_subtitle)
171  ->setImportId($ou_import_id)
172  ->create();
173 
174  self::$instance_cache[$unit->getId()] = $unit;
175 
176  return $unit;
177  }

◆ deassignUser()

ilOrgUnit::deassignUser (   $a_user_id)

Definition at line 45 of file class.ilOrgUnit.php.

46  {
47  if($this->assignment_list === null)
48  throw new ilOrgUnitException('Error: Assignment object not initialised yet!');
49 
50  $this->assignment_list->removeAssignment($a_user_id);
51  }

◆ delete()

ilOrgUnit::delete ( )

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

137  {
138  self::deleteInstance($this->id);
139  }

◆ deleteInstance()

static ilOrgUnit::deleteInstance (   $ou_id)
static

Definition at line 141 of file class.ilOrgUnit.php.

References $query.

142  {
143  global $ilDB;
144 
145  $query = "DELETE FROM org_unit_data WHERE ou_id = %s";
146 
147  $ilDB->queryF($query, array('integer'), array($ou_id));
148 
149  if( isset(self::$instance_cache[$ou_id]) )
150  {
151  unset(self::$instance_cache[$ou_id]);
152  }
153  }

◆ getAssignedUsers()

ilOrgUnit::getAssignedUsers ( )

Definition at line 61 of file class.ilOrgUnit.php.

62  {
63  if($this->assignment_list === null)
64  throw new ilOrgUnitException('Error: Assignment object not initialised yet!');
65 
66  $assignments = array();
67  foreach($this->assignment_list as $assignment)
68  {
69  $assignments[$assignment->getUserId()] = array(
70  'reporting_access' => $assignment->hasReportingAccess(),
71  'cc_coml_invit' => $assignment->hasCcComplianceInvitation(),
72  'cc_coml_not1' => $assignment->hasCcComplianceNotify1(),
73  'cc_coml_not2' => $assignment->hasCcComplianceNotify2()
74  );
75  }
76 
77  return $assignments;
78  }

◆ getChilds()

ilOrgUnit::getChilds ( )

Definition at line 279 of file class.ilOrgUnit.php.

References $childs.

Referenced by ilOrgUnitTreeExplorerGUI\renderUnit().

280  {
281  return $this->childs;
282  }
+ Here is the caller graph for this function:

◆ getId()

ilOrgUnit::getId ( )

Definition at line 233 of file class.ilOrgUnit.php.

References $id.

Referenced by ilOrgUnitTreeExplorerGUI\renderUnit().

234  {
235  return $this->id;
236  }
+ Here is the caller graph for this function:

◆ getImportId()

ilOrgUnit::getImportId ( )

Definition at line 260 of file class.ilOrgUnit.php.

References $import_id.

261  {
262  return $this->import_id;
263  }

◆ getInstance()

static ilOrgUnit::getInstance (   $ou_id)
static

Definition at line 155 of file class.ilOrgUnit.php.

Referenced by ilOrgUnitTree\getRecursiveOrgUnitTree().

156  {
157  if( !isset(self::$instance_cache[$ou_id]) )
158  {
159  self::$instance_cache[$ou_id] = new self($ou_id);
160  }
161 
162  return self::$instance_cache[$ou_id];
163  }
+ Here is the caller graph for this function:

◆ getInstancesByAssignedUser()

static ilOrgUnit::getInstancesByAssignedUser (   $a_user_id)
static

Definition at line 201 of file class.ilOrgUnit.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilOrgUnitAssignmentTableGUI\getItems().

202  {
203  global $ilDB;
204 
205  $query = "SELECT ou_id FROM org_unit_data ".
206  "LEFT JOIN org_unit_assignments ".
207  "ON ou_id = oa_ou_id ".
208  "WHERE oa_usr_id = %s";
209 
210  $res = $ilDB->queryF($query, array('integer'), array($a_user_id));
211 
212  $units = array();
213  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
214  {
215  $units[$row->ou_id] = self::getInstance($row->ou_id);
216  }
217 
218  return $units;
219  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ getParent()

ilOrgUnit::getParent ( )

Definition at line 270 of file class.ilOrgUnit.php.

References $parent.

271  {
272  return $this->parent;
273  }

◆ getSubTitle()

ilOrgUnit::getSubTitle ( )

Definition at line 251 of file class.ilOrgUnit.php.

References $subtitle.

Referenced by ilOrgUnitTreeExplorerGUI\renderUnit().

252  {
253  return $this->subtitle;
254  }
+ Here is the caller graph for this function:

◆ getTitle()

ilOrgUnit::getTitle ( )

Definition at line 242 of file class.ilOrgUnit.php.

References $title.

Referenced by ilOrgUnitTreeExplorerGUI\renderUnit().

243  {
244  return $this->title;
245  }
+ Here is the caller graph for this function:

◆ hasChilds()

ilOrgUnit::hasChilds ( )

Definition at line 283 of file class.ilOrgUnit.php.

Referenced by ilOrgUnitTreeExplorerGUI\renderUnit().

284  {
285  return (bool)count($this->childs);
286  }
+ Here is the caller graph for this function:

◆ hasUserReportingAccess()

ilOrgUnit::hasUserReportingAccess (   $a_user_id)

Definition at line 221 of file class.ilOrgUnit.php.

References initAssigns().

222  {
223  if($this->assignment_list === null) $this->initAssigns();
224 
225  return $this->assignment_list->hasUserReportingAccess($a_user_id);
226  }
+ Here is the call graph for this function:

◆ initAssigns()

ilOrgUnit::initAssigns ( )

Definition at line 29 of file class.ilOrgUnit.php.

Referenced by hasUserReportingAccess(), and ilOrgUnitTreeExplorerGUI\renderUnit().

30  {
31  require_once('Services/OrgUnit/classes/class.ilOrgUnitAssignmentList.php');
32  $this->assignment_list = new ilOrgUnitAssignmentList($this->id);
33  }
Organisation Unit Assignment List.
+ Here is the caller graph for this function:

◆ isUserAssigned()

ilOrgUnit::isUserAssigned (   $a_user_id)

Definition at line 53 of file class.ilOrgUnit.php.

54  {
55  if($this->assignment_list === null)
56  throw new ilOrgUnitException('Error: Assignment object not initialised yet!');
57 
58  return $this->assignment_list->doesAssignmentExist($a_user_id);
59  }

◆ lookupIdByImportId()

static ilOrgUnit::lookupIdByImportId (   $ou_import_id)
static

Definition at line 179 of file class.ilOrgUnit.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

180  {
181  if( isset(self::$import_id_cache[$ou_import_id]) )
182  {
183  return self::$import_id_cache[$ou_import_id];
184  }
185 
186  global $ilDB;
187 
188  $query = "SELECT ou_id FROM org_unit_data WHERE ou_import_id = %s";
189 
190  $res = $ilDB->queryF($query, array('integer'), array($ou_import_id));
191 
192  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
193  {
194  self::$import_id_cache[$ou_import_id] = $row->ou_id;
195  return $row->ou_id;
196  }
197 
198  return null;
199  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

◆ read()

ilOrgUnit::read ( )

Definition at line 80 of file class.ilOrgUnit.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by __construct().

81  {
82  global $ilDB;
83 
84  $query = "SELECT * FROM org_unit_data WHERE ou_id = %s";
85 
86  $res = $ilDB->queryF($query, array('integer'), array($this->id));
87 
88  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
89  {
90  $this->id = $row->ou_id;
91  $this->title = $row->ou_title;
92  $this->subtitle = $row->ou_subtitle;
93  $this->import_id = $row->ou_import_id;
94 
95  return true;
96  }
97 
99  'organisation unit with id "'.$this->id.'" does not exist!'
100  );
101  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ setId()

ilOrgUnit::setId (   $ou_id)

Definition at line 228 of file class.ilOrgUnit.php.

229  {
230  $this->id = (int)$ou_id;
231  return $this;
232  }

◆ setImportId()

ilOrgUnit::setImportId (   $ou_import_id)

Definition at line 255 of file class.ilOrgUnit.php.

256  {
257  $this->import_id = (int)$ou_import_id;
258  return $this;
259  }

◆ setParent()

ilOrgUnit::setParent (   $a_parent)

Definition at line 265 of file class.ilOrgUnit.php.

266  {
267  $this->parent = (int)$a_parent;
268  return $this;
269  }

◆ setSubTitle()

ilOrgUnit::setSubTitle (   $ou_subtitle)

Definition at line 246 of file class.ilOrgUnit.php.

247  {
248  $this->subtitle = $ou_subtitle;
249  return $this;
250  }

◆ setTitle()

ilOrgUnit::setTitle (   $ou_title)

Definition at line 237 of file class.ilOrgUnit.php.

238  {
239  $this->title = $ou_title;
240  return $this;
241  }

◆ sortCallback()

ilOrgUnit::sortCallback (   $a_a,
  $a_b 
)

Definition at line 296 of file class.ilOrgUnit.php.

297  {
298  return strcmp($a_a->getTitle(), $a_b->getTitle());
299  }

◆ sortChilds()

ilOrgUnit::sortChilds ( )

Definition at line 287 of file class.ilOrgUnit.php.

288  {
289  usort($this->childs, array($this,'sortCallback'));
290 
291  foreach($this->childs as $child)
292  {
293  if( $child->hasChilds() ) $child->sortChilds();
294  }
295  }

◆ update()

ilOrgUnit::update ( )

Definition at line 103 of file class.ilOrgUnit.php.

104  {
105  global $ilDB;
106 
107  $ilDB->update(
108  'org_unit_data',
109  array(
110  'ou_title' => array('text', $this->title),
111  'ou_subtitle' => array('text', $this->subtitle),
112  'ou_import_id' => array('text', $this->import_id)
113  ),
114  array('ou_id' => array('integer', $this->id))
115  );
116  }

Field Documentation

◆ $assignment_list

ilOrgUnit::$assignment_list = null
private

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

◆ $childs

ilOrgUnit::$childs = array()
private

Definition at line 16 of file class.ilOrgUnit.php.

Referenced by getChilds().

◆ $id

ilOrgUnit::$id = 0
private

Definition at line 10 of file class.ilOrgUnit.php.

Referenced by getId().

◆ $import_id

ilOrgUnit::$import_id = 0
private

Definition at line 13 of file class.ilOrgUnit.php.

Referenced by getImportId().

◆ $import_id_cache

ilOrgUnit::$import_id_cache = array()
staticprivate

Definition at line 8 of file class.ilOrgUnit.php.

◆ $instance_cache

ilOrgUnit::$instance_cache = array()
staticprivate

Definition at line 7 of file class.ilOrgUnit.php.

◆ $parent

ilOrgUnit::$parent = 0
private

Definition at line 15 of file class.ilOrgUnit.php.

Referenced by getParent().

◆ $subtitle

ilOrgUnit::$subtitle = ''
private

Definition at line 12 of file class.ilOrgUnit.php.

Referenced by getSubTitle().

◆ $title

ilOrgUnit::$title = ''
private

Definition at line 11 of file class.ilOrgUnit.php.

Referenced by getTitle().


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