3 require_once(
'Services/OrgUnit/exceptions/class.ilOrgUnitException.php');
24 $this->
id = (int)$ou_id;
31 require_once(
'Services/OrgUnit/classes/class.ilOrgUnitAssignmentList.php');
35 public function assignUser($a_user_id, $a_reporting_access,
36 $a_cc_compl_invit, $a_cc_compl_not1, $a_cc_compl_not2)
38 if($this->assignment_list === null)
41 $this->assignment_list->addAssignment($a_user_id, $a_reporting_access,
42 $a_cc_compl_invit, $a_cc_compl_not1, $a_cc_compl_not2);
47 if($this->assignment_list === null)
50 $this->assignment_list->removeAssignment($a_user_id);
55 if($this->assignment_list === null)
58 return $this->assignment_list->doesAssignmentExist($a_user_id);
63 if($this->assignment_list === null)
66 $assignments = array();
67 foreach($this->assignment_list as $assignment)
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()
84 $query =
"SELECT * FROM org_unit_data WHERE ou_id = %s";
86 $res = $ilDB->queryF(
$query, array(
'integer'), array($this->
id));
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;
99 'organisation unit with id "'.$this->
id.
'" does not exist!'
110 'ou_title' => array(
'text', $this->title),
111 'ou_subtitle' => array(
'text', $this->subtitle),
112 'ou_import_id' => array(
'text', $this->import_id)
114 array(
'ou_id' => array(
'integer', $this->
id))
122 $this->
id = $ilDB->nextId(
'org_unit_data');
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)
132 array(
'ou_id' => array(
'integer', $this->
id))
136 public function delete()
145 $query =
"DELETE FROM org_unit_data WHERE ou_id = %s";
147 $ilDB->queryF(
$query, array(
'integer'), array($ou_id));
149 if( isset(self::$instance_cache[$ou_id]) )
151 unset(self::$instance_cache[$ou_id]);
157 if( !isset(self::$instance_cache[$ou_id]) )
159 self::$instance_cache[$ou_id] =
new self($ou_id);
162 return self::$instance_cache[$ou_id];
169 $unit ->setTitle($ou_title)
170 ->setSubTitle($ou_subtitle)
171 ->setImportId($ou_import_id)
174 self::$instance_cache[$unit->getId()] = $unit;
181 if( isset(self::$import_id_cache[$ou_import_id]) )
183 return self::$import_id_cache[$ou_import_id];
188 $query =
"SELECT ou_id FROM org_unit_data WHERE ou_import_id = %s";
190 $res = $ilDB->queryF(
$query, array(
'integer'), array($ou_import_id));
194 self::$import_id_cache[$ou_import_id] =
$row->ou_id;
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";
210 $res = $ilDB->queryF(
$query, array(
'integer'), array($a_user_id));
223 if($this->assignment_list === null) $this->
initAssigns();
225 return $this->assignment_list->hasUserReportingAccess($a_user_id);
230 $this->
id = (int)$ou_id;
239 $this->title = $ou_title;
248 $this->subtitle = $ou_subtitle;
257 $this->import_id = (int)$ou_import_id;
267 $this->parent = (int)$a_parent;
276 $this->childs[] = $a_child;
285 return (
bool)count($this->childs);
289 usort($this->childs, array($this,
'sortCallback'));
291 foreach($this->childs as $child)
293 if( $child->hasChilds() ) $child->sortChilds();
298 return strcmp($a_a->getTitle(), $a_b->getTitle());