3 require_once
"./Services/Container/classes/class.ilContainer.php";
4 require_once(
"./Modules/OrgUnit/classes/class.ilOrgUnitImporter.php");
5 require_once(
'./Modules/OrgUnit/classes/Types/class.ilOrgUnitType.php');
6 require_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
7 require_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
8 require_once(
'./Modules/OrgUnit/classes/PathStorage/class.ilOrgUnitPathStorage.php');
64 public function __construct($a_id = 0, $a_call_by_reference =
true) {
66 parent::__construct($a_id, $a_call_by_reference);
70 public function read() {
75 $sql =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' 77 $set =
$ilDB->query($sql);
78 if (
$ilDB->numRows($set)) {
79 $rec =
$ilDB->fetchObject($set);
91 'orgu_id' =>
array(
'integer', $this->
getId() ),
100 $sql =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' 102 $set =
$ilDB->query($sql);
103 if (
$ilDB->numRows($set)) {
107 'orgu_id' =>
array(
'integer', $this->
getId() ),
112 'orgu_id' =>
array(
'integer', $this->
getId() ),
118 ->getAssignedAdvancedMDRecordIds());
146 $this->orgu_type_id = $a_id;
160 public function getAdvancedMDValues($a_record_id = 0) {
165 if (is_array($this->amd_data)) {
167 return (isset($this->amd_data[$a_record_id])) ? $this->amd_data[$a_record_id] :
array();
176 $this->amd_data[$record_id] = $amd_values->getADTGroup()->getElements();
179 return (isset($this->amd_data[$a_record_id])) ? $this->amd_data[$a_record_id] :
array();
193 public static function getIconsCache() {
194 if (is_array(self::$icons_cache)) {
195 return self::$icons_cache;
198 $ilDB = $DIC[
'ilDB'];
200 $sql =
'SELECT orgu_id, ot.id AS type_id FROM orgu_data 201 INNER JOIN orgu_types AS ot ON (ot.id = orgu_data.orgu_type_id) 202 WHERE ot.icon IS NOT NULL';
203 $set =
$ilDB->query($sql);
205 while (
$row =
$ilDB->fetchObject($set)) {
207 if (
$type && is_file(
$type->getIconPath(
true))) {
221 self::loadRootOrgRefIdAndId();
223 return self::$root_ref_id;
231 self::loadRootOrgRefIdAndId();
233 return self::$root_id;
238 if (self::$root_ref_id === null || self::$root_id === null) {
240 $ilDB = $DIC[
'ilDB'];
241 $q =
"SELECT o.obj_id, r.ref_id FROM object_data o 242 INNER JOIN object_reference r ON r.obj_id = o.obj_id 243 WHERE title = " .
$ilDB->quote(
'__OrgUnitAdministration',
'text') .
"";
244 $set =
$ilDB->query($q);
246 self::$root_id =
$res[
"obj_id"];
247 self::$root_ref_id =
$res[
"ref_id"];
255 if (!$this->employee_role || !$this->superior_role) {
259 if (!$this->employee_role || !$this->superior_role) {
262 if (!$this->employee_role || !$this->superior_role) {
263 throw new Exception(
"The standard roles the orgu object with id: " . $this->
getId()
264 .
" aren't initialized or have been deleted, newly creating them didn't work!");
266 $ilLog->write(
"[" . __FILE__ .
":" . __LINE__
267 .
"] The standard roles for the orgu obj with id: " . $this->
getId()
268 .
" were newly created as they couldnt be found.");
276 $ilDB = $DIC[
'ilDB'];
277 if (!$this->employee_role || !$this->superior_role) {
278 $q =
"SELECT obj_id, title FROM object_data WHERE title = 'il_orgu_employee_" 279 .
$ilDB->quote($this->
getRefId(),
"integer") .
"' OR title = 'il_orgu_superior_" 281 $set =
$ilDB->query($q);
283 if (
$res[
"title"] ==
"il_orgu_employee_" . $this->
getRefId()) {
284 $this->employee_role =
$res[
"obj_id"];
285 } elseif (
$res[
"title"] ==
"il_orgu_superior_" . $this->
getRefId()) {
286 $this->superior_role =
$res[
"obj_id"];
290 if (!$this->employee_role || !$this->superior_role) {
291 throw new Exception(
"The standard roles the orgu object with id: " . $this->
getId()
292 .
" aren't initialized or have been deleted!");
300 $rbacadmin = $DIC[
'rbacadmin'];
301 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
302 foreach ($user_ids as $user_id) {
305 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'assignUsersToEmployeeRole',
array(
307 'obj_id' => $this->
getId(),
310 'user_id' => $user_id,
318 $rbacadmin = $DIC[
'rbacadmin'];
319 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
320 foreach ($user_ids as $user_id) {
323 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'assignUsersToSuperiorRole',
array(
325 'obj_id' => $this->
getId(),
328 'user_id' => $user_id,
336 $rbacadmin = $DIC[
'rbacadmin'];
337 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
340 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'deassignUserFromEmployeeRole',
array(
342 'obj_id' => $this->
getId(),
345 'user_id' => $user_id,
352 $rbacadmin = $DIC[
'rbacadmin'];
353 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
356 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'deassignUserFromSuperiorRole',
array(
358 'obj_id' => $this->
getId(),
361 'user_id' => $user_id,
375 $rbacreview = $DIC[
'rbacreview'];
376 $rbacadmin = $DIC[
'rbacadmin'];
377 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
379 $arrLocalRoles = $rbacreview->getLocalRoles($this->
getRefId());
380 if (!in_array($role_id, $arrLocalRoles)) {
384 $return = $rbacadmin->assignUser($role_id, $user_id);
386 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'assignUserToLocalRole',
array(
388 'obj_id' => $this->
getId(),
390 'role_id' => $role_id,
391 'user_id' => $user_id,
407 $rbacreview = $DIC[
'rbacreview'];
408 $rbacadmin = $DIC[
'rbacadmin'];
409 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
411 $arrLocalRoles = $rbacreview->getLocalRoles($this->
getRefId());
412 if (!in_array($role_id, $arrLocalRoles)) {
416 $return = $rbacadmin->deassignUser($role_id, $user_id);
418 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'deassignUserFromLocalRole',
array(
420 'obj_id' => $this->
getId(),
422 'role_id' => $role_id,
423 'user_id' => $user_id,
444 public static function _exists($a_id, $a_reference =
false,
$type =
"orgu") {
445 return parent::_exists($a_id, $a_reference,
"orgu");
479 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
481 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
483 . $this->
getRefId(),
"Emplyee of org unit obj_no." 487 . $this->
getRefId(),
"Superior of org unit obj_no." 490 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'initDefaultRoles',
array(
492 'obj_id' => $this->
getId(),
494 'role_superior_id' => $role_sup->getId(),
495 'role_employee_id' => $role_emp->getId(),
506 if (parent::getTitle() !=
"__OrgUnitAdministration") {
507 return parent::getTitle();
509 return $this->lng->txt(
"objs_orgu");
521 if (parent::getTitle() ==
"__OrgUnitAdministration") {
522 return $this->lng->txt(
"obj_orgu_description");
524 return parent::getLongDescription();
535 $ilDB = $DIC[
'ilDB'];
537 $translations =
array();
539 $q =
"SELECT * FROM object_translation WHERE obj_id = " 540 .
$ilDB->quote($this->
getId(),
'integer') .
" ORDER BY lang_default DESC";
541 $r = $this->
ilias->db->query($q);
547 "title" =>
$row->title,
548 "desc" =>
$row->description,
549 "lang" =>
$row->lang_code,
550 'lang_default' =>
$row->lang_default,
555 $translations =
$data;
557 if (!count($translations[
"Fobject"])) {
559 $translations[
"Fobject"][] =
array(
562 "lang" =>
$lng->getDefaultLanguage(),
566 return $translations;
577 public function delete() {
579 $ilDB = $DIC[
'ilDB'];
580 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
583 if (!parent::delete()) {
588 include_once(
'./Services/User/classes/class.ilObjUserFolder.php');
591 $query =
"DELETE FROM object_translation WHERE obj_id = " 595 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'delete',
array(
597 'obj_id' => $this->
getId(),
600 $sql =
'DELETE FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' 602 $ilDB->manipulate($sql);
609 if (!$this->employee_role || !$this->superior_role) {
612 $emp =
new ilObjRole($this->employee_role);
615 $sup =
new ilObjRole($this->superior_role);
628 $ilDB = $DIC[
'ilDB'];
630 $query =
"DELETE FROM object_translation WHERE obj_id= " 643 $ilDB = $DIC[
'ilDB'];
645 $query =
"DELETE FROM object_translation WHERE obj_id= " 646 .
$ilDB->quote($this->
getId(),
'integer') .
" AND lang_code = " 647 .
$ilDB->quote($a_lang,
'text');
663 $ilDB = $DIC[
'ilDB'];
665 if (empty($a_title)) {
666 $a_title =
"NO TITLE";
669 $query =
"INSERT INTO object_translation " 670 .
"(obj_id,title,description,lang_code,lang_default) " .
"VALUES " .
"(" 671 .
$ilDB->quote($this->
getId(),
'integer') .
"," .
$ilDB->quote($a_title,
'text')
672 .
"," .
$ilDB->quote($a_desc,
'text') .
"," .
$ilDB->quote($a_lang,
'text') .
"," 673 .
$ilDB->quote($a_lang_default,
'integer') .
")";
691 $ilDB = $DIC[
'ilDB'];
694 if (empty($a_title)) {
695 $a_title =
"NO TITLE";
698 $query =
"UPDATE object_translation SET ";
700 $query .=
" title = " .
$ilDB->quote($a_title,
'text');
703 $query .=
", description = " .
$ilDB->quote($a_desc,
'text') .
" ";
706 if ($a_lang_default) {
707 $query .=
", lang_default = " .
$ilDB->quote($a_lang_default,
'integer') .
" ";
710 $query .=
" WHERE obj_id = " .
$ilDB->quote($this->
getId(),
'integer') .
" AND lang_code = " 711 .
$ilDB->quote($a_lang,
'text');
720 ilOrgUnitPathStorage::writePathByRefId($this->
getRefId());
static _updateUserFolderAssignment($a_old_id, $a_new_id)
Update user folder assignment Typically called after deleting a category with local user accounts...
static getInstancesForObjectId($a_obj_id, $a_obj_type=null, $a_sub_type="-", $a_sub_id=0)
Get instances for given object id.
removeTranslations()
remove all Translations of current OrgUnit
__construct($a_id=0, $a_call_by_reference=true)
deassignUserFromSuperiorRole($user_id)
assignUsersToSuperiorRole($user_ids)
static _exists($a_id, $a_reference=false, $type="orgu")
Class ilOrgUnitPathStorage.
assignUsersToEmployeeRole($user_ids)
updateTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
update a translation to current OrgUnit
deassignUserFromLocalRole($role_id, $user_id)
Deassign a given user to a given local role.
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
static loadRootOrgRefIdAndId()
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)
setEmployeeRole($employee_role)
addTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
add a new translation to current OrgUnit
getId()
get object id public
deleteTranslation($a_lang)
remove translations of current OrgUnit
setSuperiorRole($superior_role)
getLongDescription()
get object long description (stored in object_description)
static getInstance($a_id)
Public.
redirection script todo: (a better solution should control the processing via a xml file) ...
assignUserToLocalRole($role_id, $user_id)
Assign a given user to a given local role.
deassignUserFromEmployeeRole($user_id)
Create styles array
The data for the language used.
getRefId()
get reference id public
const USER_FOLDER_ID
Class ilObjUserFolder.