3require_once 
"./Services/Container/classes/class.ilContainer.php";
 
    4require_once(
"./Modules/OrgUnit/classes/class.ilOrgUnitImporter.php");
 
    5require_once(
'./Modules/OrgUnit/classes/Types/class.ilOrgUnitType.php');
 
    6require_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
 
    7require_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
 
   49        public function __construct($a_id = 0, $a_call_by_reference = 
true) {
 
   55        public function read() {
 
   59                $sql = 
'SELECT * FROM ' . self::TABLE_NAME . 
' WHERE orgu_id = ' 
   61                $set = 
$ilDB->query($sql);
 
   62                if (
$ilDB->numRows($set)) {
 
   63                        $rec = 
$ilDB->fetchObject($set);
 
   72                $ilDB->insert(self::TABLE_NAME, array(
 
   74                        'orgu_id'      => array( 
'integer', $this->
getId() ),
 
   82                $sql = 
'SELECT * FROM ' . self::TABLE_NAME . 
' WHERE orgu_id = ' 
   84                $set = 
$ilDB->query($sql);
 
   85                if (
$ilDB->numRows($set)) {
 
   86                        $ilDB->update(self::TABLE_NAME, array(
 
   89                                'orgu_id' => array( 
'integer', $this->
getId() ),
 
   92                        $ilDB->insert(self::TABLE_NAME, array(
 
   94                                'orgu_id'      => array( 
'integer', $this->
getId() ),
 
  100                                                                                                  ->getAssignedAdvancedMDRecordIds());
 
  128                $this->orgu_type_id = $a_id;
 
  142        public function getAdvancedMDValues($a_record_id = 0) {
 
  147                if (is_array($this->amd_data)) {
 
  149                                return (isset($this->amd_data[$a_record_id])) ? $this->amd_data[$a_record_id] : array();
 
  158                        $this->amd_data[$record_id] = $amd_values->getADTGroup()->getElements();
 
  161                        return (isset($this->amd_data[$a_record_id])) ? $this->amd_data[$a_record_id] : array();
 
  175        public static function getIconsCache() {
 
  176                if (is_array(self::$icons_cache)) {
 
  181                $sql = 
'SELECT orgu_id, ot.id AS type_id FROM orgu_data 
  182                INNER JOIN orgu_types AS ot ON (ot.id = orgu_data.orgu_type_id) 
  183                WHERE ot.icon IS NOT NULL';
 
  184                $set = 
$ilDB->query($sql);
 
  186                while (
$row = 
$ilDB->fetchObject($set)) {
 
  188                        if (
$type && is_file(
$type->getIconPath(
true))) {
 
  213                if (self::$root_ref_id === 
null || self::$root_id === 
null) {
 
  215                        $q = 
"SELECT o.obj_id, r.ref_id FROM object_data o 
  216                        INNER JOIN object_reference r ON r.obj_id = o.obj_id 
  217                        WHERE title = " . 
$ilDB->quote(
'__OrgUnitAdministration', 
'text') . 
"";
 
  218                        $set = 
$ilDB->query($q);
 
  220                        self::$root_id = 
$res[
"obj_id"];
 
  221                        self::$root_ref_id = 
$res[
"ref_id"];
 
  228                if (!$this->employee_role || !$this->superior_role) {
 
  232                if (!$this->employee_role || !$this->superior_role) {
 
  235                        if (!$this->employee_role || !$this->superior_role) {
 
  236                                throw new Exception(
"The standard roles the orgu object with id: " . $this->
getId()
 
  237                                                    . 
" aren't initialized or have been deleted, newly creating them didn't work!");
 
  239                                $ilLog->write(
"[" . __FILE__ . 
":" . __LINE__
 
  240                                              . 
"] The standard roles for the orgu obj with id: " . $this->
getId()
 
  241                                              . 
" were newly created as they couldnt be found.");
 
  249                if (!$this->employee_role || !$this->superior_role) {
 
  250                        $q = 
"SELECT obj_id, title FROM object_data WHERE title LIKE 'il_orgu_employee_" 
  251                             . 
$ilDB->quote($this->
getRefId(), 
"integer") . 
"' OR title LIKE 'il_orgu_superior_" 
  252                             . $ilDB->quote($this->
getRefId(), 
"integer") . 
"'";
 
  253                        $set = 
$ilDB->query($q);
 
  255                                if (
$res[
"title"] == 
"il_orgu_employee_" . $this->
getRefId()) {
 
  256                                        $this->employee_role = 
$res[
"obj_id"];
 
  257                                } elseif (
$res[
"title"] == 
"il_orgu_superior_" . $this->
getRefId()) {
 
  258                                        $this->superior_role = 
$res[
"obj_id"];
 
  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!");
 
  271                global $rbacadmin, $ilAppEventHandler;
 
  272                foreach ($user_ids as $user_id) {
 
  275                        $ilAppEventHandler->raise(
'Modules/OrgUnit', 
'assignUsersToEmployeeRole', array(
 
  277                                'obj_id'  => $this->
getId(),
 
  280                                'user_id' => $user_id,
 
  287                global $rbacadmin, $ilAppEventHandler;
 
  288                foreach ($user_ids as $user_id) {
 
  291                        $ilAppEventHandler->raise(
'Modules/OrgUnit', 
'assignUsersToSuperiorRole', array(
 
  293                                'obj_id'  => $this->
getId(),
 
  296                                'user_id' => $user_id,
 
  303                global $rbacadmin, $ilAppEventHandler;
 
  306                $ilAppEventHandler->raise(
'Modules/OrgUnit', 
'deassignUserFromEmployeeRole', array(
 
  308                        'obj_id'  => $this->
getId(),
 
  311                        'user_id' => $user_id,
 
  317                global $rbacadmin, $ilAppEventHandler;
 
  320                $ilAppEventHandler->raise(
'Modules/OrgUnit', 
'deassignUserFromSuperiorRole', array(
 
  322                        'obj_id'  => $this->
getId(),
 
  325                        'user_id' => $user_id,
 
  338                global $rbacreview, $rbacadmin, $ilAppEventHandler;
 
  340                $arrLocalRoles = $rbacreview->getLocalRoles($this->
getRefId());
 
  341                if (!in_array($role_id, $arrLocalRoles)) {
 
  345                $return = $rbacadmin->assignUser($role_id, $user_id);
 
  347                $ilAppEventHandler->raise(
'Modules/OrgUnit', 
'assignUserToLocalRole', array(
 
  349                                'obj_id'  => $this->
getId(),
 
  351                                'role_id' => $role_id,
 
  352                                'user_id' => $user_id,
 
  367                global $rbacreview, $rbacadmin, $ilAppEventHandler;
 
  369                $arrLocalRoles = $rbacreview->getLocalRoles($this->
getRefId());
 
  370                if (!in_array($role_id, $arrLocalRoles)) {
 
  374                $return = $rbacadmin->deassignUser($role_id, $user_id);
 
  376                $ilAppEventHandler->raise(
'Modules/OrgUnit', 
'deassignUserFromLocalRole', array(
 
  378                                'obj_id'  => $this->
getId(),
 
  380                                'role_id' => $role_id,
 
  381                                'user_id' => $user_id,
 
  396        public static function _exists($a_id, $a_reference = 
false) {
 
  397                return parent::_exists($a_id, $a_reference, 
"orgu");
 
  430                global $ilAppEventHandler;
 
  432                include_once 
'./Services/AccessControl/classes/class.ilObjRole.php';
 
  434                                                         . $this->
getRefId(), 
"Emplyee of org unit obj_no." 
  438                                                         . $this->
getRefId(), 
"Superior of org unit obj_no." 
  441                $ilAppEventHandler->raise(
'Modules/OrgUnit', 
'initDefaultRoles', array(
 
  443                        'obj_id'           => $this->
getId(),
 
  445                        'role_superior_id' => $role_sup->getId(),
 
  446                        'role_employee_id' => $role_emp->getId(),
 
  457                if (parent::getTitle() != 
"__OrgUnitAdministration") {
 
  458                        return parent::getTitle();
 
  460                        return $this->lng->txt(
"objs_orgu");
 
  472                if (parent::getTitle() == 
"__OrgUnitAdministration") {
 
  473                        return $this->lng->txt(
"obj_orgu_description");
 
  475                        return parent::getLongDescription();
 
  486                $q = 
"SELECT * FROM object_translation WHERE obj_id = " 
  487                     . 
$ilDB->quote($this->
getId(), 
'integer') . 
" ORDER BY lang_default DESC";
 
  488                $r = $this->
ilias->db->query($q);
 
  493                        $data[
"Fobject"][$num] = array(
 
  494                                "title"        => 
$row->title,
 
  495                                "desc"         => 
$row->description,
 
  496                                "lang"         => 
$row->lang_code,
 
  497                                'lang_default' => 
$row->lang_default,
 
  502                $translations = 
$data;
 
  504                if (!count($translations[
"Fobject"])) {
 
  506                        $translations[
"Fobject"][] = array(
 
  509                                "lang"  => $lng->getDefaultLanguage(),
 
  513                return $translations;
 
  524        public function delete() {
 
  525                global 
$ilDB, $ilAppEventHandler;
 
  528                if (!parent::delete()) {
 
  533                include_once(
'./Services/User/classes/class.ilObjUserFolder.php');
 
  536                $query = 
"DELETE FROM object_translation WHERE obj_id = " 
  538                $ilDB->manipulate(
$query);
 
  540                $ilAppEventHandler->raise(
'Modules/OrgUnit', 
'delete', array(
 
  542                        'obj_id' => $this->
getId(),
 
  545                $sql = 
'DELETE FROM ' . self::TABLE_NAME . 
' WHERE orgu_id = ' 
  547                $ilDB->manipulate($sql);
 
  549                if (!$this->employee_role || !$this->superior_role) {
 
  552                $emp = 
new ilObjRole($this->employee_role);
 
  555                $sup = 
new ilObjRole($this->superior_role);
 
  567                $query = 
"DELETE FROM object_translation WHERE obj_id= " 
  577                $query = 
"DELETE FROM object_translation WHERE obj_id= " 
  578                         . 
$ilDB->quote($this->
getId(), 
'integer') . 
" AND lang_code = " 
  579                         . $ilDB->quote($a_lang, 
'text');
 
  588                if (empty($a_title)) {
 
  589                        $a_title = 
"NO TITLE";
 
  592                $query = 
"INSERT INTO object_translation " 
  593                         . 
"(obj_id,title,description,lang_code,lang_default) " . 
"VALUES " . 
"(" 
  594                         . 
$ilDB->quote($this->
getId(), 
'integer') . 
"," . $ilDB->quote($a_title, 
'text')
 
  595                         . 
"," . 
$ilDB->quote($a_desc, 
'text') . 
"," . 
$ilDB->quote($a_lang, 
'text') . 
"," 
  596                         . 
$ilDB->quote($a_lang_default, 
'integer') . 
")";
 
  607                if (empty($a_title)) {
 
  608                        $a_title = 
"NO TITLE";
 
  611                $query = 
"UPDATE object_translation SET ";
 
  613                $query .= 
" title = " . 
$ilDB->quote($a_title, 
'text');
 
  616                        $query .= 
", description = " . 
$ilDB->quote($a_desc, 
'text') . 
" ";
 
  619                if ($a_lang_default) {
 
  620                        $query .= 
", lang_default = " . 
$ilDB->quote($a_lang_default, 
'integer') . 
" ";
 
  623                $query .= 
" WHERE obj_id = " . 
$ilDB->quote($this->
getId(), 
'integer') . 
" AND lang_code = " 
  624                          . $ilDB->quote($a_lang, 
'text');
 
const DB_FETCHMODE_OBJECT
const USER_FOLDER_ID
Class ilObjUserFolder.
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
static getInstancesForObjectId($a_obj_id, $a_obj_type=null, $a_sub_type="-", $a_sub_id=0)
Get instances for given object id.
ilContainer($a_id=0, $a_call_by_reference=true)
Constructor @access public.
assignUsersToSuperiorRole($user_ids)
static _exists($a_id, $a_reference=false)
static loadRootOrgRefIdAndId()
deassignUserFromSuperiorRole($user_id)
addTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
initDefaultRoles()
init default roles settings Purpose of this function is to create a local role folder and local roles...
deassignUserFromEmployeeRole($user_id)
deassignUserFromLocalRole($role_id, $user_id)
Deassign a given user to a given local role.
__construct($a_id=0, $a_call_by_reference=true)
setSuperiorRole($superior_role)
deleteTranslation($a_lang)
assignUserToLocalRole($role_id, $user_id)
Assign a given user to a given local role.
getLongDescription()
get object long description (stored in object_description)
assignUsersToEmployeeRole($user_ids)
updateTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
setEmployeeRole($employee_role)
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)
static _updateUserFolderAssignment($a_old_id, $a_new_id)
Update user folder assignment Typically called after deleting a category with local user accounts.
getRefId()
get reference id @access public
getId()
get object id @access public
static getInstance($a_id)
Public.
redirection script todo: (a better solution should control the processing via a xml file)