50 public function __construct($a_id = 0, $a_call_by_reference =
true)
53 parent::__construct($a_id, $a_call_by_reference);
57 public function read()
63 $sql =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' .
$ilDB->quote($this->
getId(),
'integer');
64 $set =
$ilDB->query($sql);
65 if (
$ilDB->numRows($set)) {
66 $rec =
$ilDB->fetchObject($set);
77 $ilDB->insert(self::TABLE_NAME, array(
79 'orgu_id' => array(
'integer', $this->
getId() ),
89 $sql =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' .
$ilDB->quote($this->
getId(),
'integer');
90 $set =
$ilDB->query($sql);
91 if (
$ilDB->numRows($set)) {
92 $ilDB->update(self::TABLE_NAME, array(
95 'orgu_id' => array(
'integer', $this->
getId() ),
98 $ilDB->insert(self::TABLE_NAME, array(
100 'orgu_id' => array(
'integer', $this->
getId() ),
136 $this->orgu_type_id = $a_id;
150 public function getAdvancedMDValues($a_record_id = 0)
156 if (is_array($this->amd_data)) {
158 return (isset($this->amd_data[$a_record_id])) ? $this->amd_data[$a_record_id] : array();
167 $this->amd_data[$record_id] = $amd_values->getADTGroup()->getElements();
170 return (isset($this->amd_data[$a_record_id])) ? $this->amd_data[$a_record_id] : array();
184 public static function getIconsCache()
186 if (is_array(self::$icons_cache)) {
187 return self::$icons_cache;
190 $ilDB = $DIC[
'ilDB'];
192 $sql =
'SELECT orgu_id, ot.id AS type_id FROM orgu_data 193 INNER JOIN orgu_types AS ot ON (ot.id = orgu_data.orgu_type_id) 194 WHERE ot.icon IS NOT NULL';
195 $set =
$ilDB->query($sql);
197 while (
$row =
$ilDB->fetchObject($set)) {
199 if (
$type && is_file(
$type->getIconPath(
true))) {
214 self::loadRootOrgRefIdAndId();
216 return self::$root_ref_id;
225 self::loadRootOrgRefIdAndId();
227 return self::$root_id;
233 if (self::$root_ref_id === null || self::$root_id === null) {
235 $ilDB = $DIC[
'ilDB'];
236 $q =
"SELECT o.obj_id, r.ref_id FROM object_data o 237 INNER JOIN object_reference r ON r.obj_id = o.obj_id 238 WHERE title = " .
$ilDB->quote(
'__OrgUnitAdministration',
'text') .
"";
239 $set =
$ilDB->query($q);
241 self::$root_id =
$res[
"obj_id"];
242 self::$root_ref_id =
$res[
"ref_id"];
255 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
258 foreach ($user_ids as $user_id) {
261 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'assignUsersToEmployeeRole', array(
263 'obj_id' => $this->
getId(),
265 'position_id' => $position_id,
266 'user_id' => $user_id,
280 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
283 foreach ($user_ids as $user_id) {
286 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'assignUsersToSuperiorRole', array(
288 'obj_id' => $this->
getId(),
290 'position_id' => $position_id,
291 'user_id' => $user_id,
302 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
305 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'deassignUserFromEmployeeRole', array(
307 'obj_id' => $this->
getId(),
309 'position_id' => $position_id,
310 'user_id' => $user_id,
320 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
323 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'deassignUserFromSuperiorRole', array(
325 'obj_id' => $this->
getId(),
327 'position_id' => $position_id,
328 'user_id' => $user_id,
346 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
349 if (!in_array($role_id, $arrLocalRoles)) {
353 $return =
$rbacadmin->assignUser($role_id, $user_id);
355 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'assignUserToLocalRole', array(
357 'obj_id' => $this->
getId(),
359 'role_id' => $role_id,
360 'user_id' => $user_id,
380 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
383 if (!in_array($role_id, $arrLocalRoles)) {
387 $return =
$rbacadmin->deassignUser($role_id, $user_id);
389 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'deassignUserFromLocalRole', array(
391 'obj_id' => $this->
getId(),
393 'role_id' => $role_id,
394 'user_id' => $user_id,
408 public static function _exists($a_id, $a_reference =
false,
$type =
"orgu")
410 return parent::_exists($a_id, $a_reference,
"orgu");
421 if (parent::getTitle() !=
"__OrgUnitAdministration") {
422 return parent::getTitle();
424 return $this->lng->txt(
"objs_orgu");
437 if (parent::getTitle() ==
"__OrgUnitAdministration") {
438 return $this->lng->txt(
"obj_orgu_description");
440 return parent::getLongDescription();
452 $ilDB = $DIC[
'ilDB'];
454 $q =
"SELECT * FROM object_translation WHERE obj_id = " .
$ilDB->quote($this->
getId(),
'integer') .
" ORDER BY lang_default DESC";
455 $r = $this->db->query($q);
458 $data = [
"Fobject" => [] ];
460 $data[
"Fobject"][$num] = array(
461 "title" =>
$row->title,
462 "desc" =>
$row->description,
463 "lang" =>
$row->lang_code,
464 'lang_default' =>
$row->lang_default,
469 $translations =
$data;
471 if (!count($translations[
"Fobject"])) {
473 $translations[
"Fobject"][] = array(
476 "lang" =>
$lng->getDefaultLanguage(),
480 return $translations;
490 public function delete()
493 $ilDB = $DIC[
'ilDB'];
494 $ilAppEventHandler = $DIC[
'ilAppEventHandler'];
497 if (!parent::delete()) {
504 $query =
"DELETE FROM object_translation WHERE obj_id = " .
$ilDB->quote($this->
getId(),
'integer');
507 $ilAppEventHandler->raise(
'Modules/OrgUnit',
'delete', array(
509 'obj_id' => $this->
getId(),
512 $sql =
'DELETE FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' .
$ilDB->quote($this->
getId(),
'integer');
513 $ilDB->manipulate($sql);
524 foreach ($assignments as $assignment) {
525 $assignment->delete();
538 $ilDB = $DIC[
'ilDB'];
540 $query =
"DELETE FROM object_translation WHERE obj_id= " .
$ilDB->quote($this->
getId(),
'integer');
553 $ilDB = $DIC[
'ilDB'];
555 $query =
"DELETE FROM object_translation WHERE obj_id= " .
$ilDB->quote($this->
getId(),
'integer') .
" AND lang_code = " 556 .
$ilDB->quote($a_lang,
'text');
574 $ilDB = $DIC[
'ilDB'];
576 if (empty($a_title)) {
577 $a_title =
"NO TITLE";
580 $query =
"INSERT INTO object_translation " .
"(obj_id,title,description,lang_code,lang_default) " .
"VALUES " .
"(" 581 .
$ilDB->quote($this->
getId(),
'integer') .
"," .
$ilDB->quote($a_title,
'text') .
"," .
$ilDB->quote($a_desc,
'text') .
"," 582 .
$ilDB->quote($a_lang,
'text') .
"," .
$ilDB->quote($a_lang_default,
'integer') .
")";
602 $ilDB = $DIC[
'ilDB'];
604 if (empty($a_title)) {
605 $a_title =
"NO TITLE";
608 $query =
"UPDATE object_translation SET ";
610 $query .=
" title = " .
$ilDB->quote($a_title,
'text');
613 $query .=
", description = " .
$ilDB->quote($a_desc,
'text') .
" ";
616 if ($a_lang_default) {
617 $query .=
", lang_default = " .
$ilDB->quote($a_lang_default,
'integer') .
" ";
620 $query .=
" WHERE obj_id = " .
$ilDB->quote($this->
getId(),
'integer') .
" AND lang_code = " .
$ilDB->quote($a_lang,
'text');
630 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)
static findOrCreateAssignment($user_id, $position_id, $orgu_id)
deassignUserFromSuperiorRole($user_id)
assignUsersToSuperiorRole($user_ids)
Adds the user ids to the position superior.
const CORE_POSITION_EMPLOYEE
static getCorePositionId($core_identifier)
static _exists($a_id, $a_reference=false, $type="orgu")
Class ilOrgUnitPathStorage.
assignUsersToEmployeeRole($user_ids)
Adds the user ids to the position employee.
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 where($where, $operator=null)
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
static loadRootOrgRefIdAndId()
foreach($_POST as $key=> $value) $res
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
getLongDescription()
get object long description (stored in object_description)
static getInstance($a_id)
Public.
assignUserToLocalRole($role_id, $user_id)
Assign a given user to a given local role.
deassignUserFromEmployeeRole($user_id)
update($pash, $contents, Config $config)
const CORE_POSITION_SUPERIOR
getRefId()
get reference id public
const USER_FOLDER_ID
Class ilObjUserFolder.