3 require_once 
"./Services/Container/classes/class.ilContainer.php";
 
    4 require_once(
"./Modules/OrgUnit/classes/class.ilOrgUnitImporter.php");
 
   22         public function __construct($a_id = 0,$a_call_by_reference = 
true){
 
   38                 if(self::$root_ref_id === Null || self::$root_id === null){
 
   40                         $q = 
"SELECT o.obj_id, r.ref_id FROM object_data o 
   41                         INNER JOIN object_reference r ON r.obj_id = o.obj_id 
   42                         WHERE title = ".$ilDB->quote(
'__OrgUnitAdministration', 
'text').
"";
 
   43                         $set = $ilDB->query($q);
 
   44                         $res = $ilDB->fetchAssoc($set);
 
   45                         self::$root_id = 
$res[
"obj_id"];
 
   46                         self::$root_ref_id= 
$res[
"ref_id"];
 
   52                         if(!$this->employee_role || !$this->superior_role){
 
   56                         if(!$this->employee_role || !$this->superior_role){
 
   59                                 if(!$this->employee_role || !$this->superior_role)
 
   60                                         throw new Exception(
"The standard roles the orgu object with id: ".$this->
getId().
" aren't initialized or have been deleted, newly creating them didn't work!");
 
   62                                         $ilLog->write(
"[".__FILE__.
":".__LINE__.
"] The standard roles for the orgu obj with id: ".$this->getId().
" were newly created as they couldnt be found.");
 
   68                 if(!$this->employee_role || !$this->superior_role){
 
   69                 $q = 
"SELECT obj_id, title FROM object_data WHERE title LIKE 'il_orgu_employee_".$ilDB->quote($this->
getRefId(),
"integer").
"' OR title LIKE 'il_orgu_superior_".$ilDB->quote($this->
getRefId(),
"integer").
"'";
 
   70                 $set = $ilDB->query($q);
 
   71                 while(
$res = $ilDB->fetchAssoc($set)){
 
   72                         if(
$res[
"title"] == 
"il_orgu_employee_".$this->
getRefId())
 
   73                                 $this->employee_role = 
$res[
"obj_id"];
 
   74                         elseif(
$res[
"title"] == 
"il_orgu_superior_".$this->
getRefId())
 
   75                                 $this->superior_role = 
$res[
"obj_id"];
 
   78                         if(!$this->employee_role || !$this->superior_role)
 
   79                                 throw new Exception(
"The standard roles the orgu object with id: ".$this->
getId().
" aren't initialized or have been deleted!");
 
   84                 global $rbacadmin, $ilAppEventHandler;
 
   85                 foreach($user_ids as $user_id)
 
   89             $ilAppEventHandler->raise(
'Modules/OrgUnit',
 
   90                 'assignUsersToEmployeeRole',
 
   91                 array(
'object' => $this,
 
   92                     'obj_id' => $this->
getId(),
 
   95                     'user_id' => $user_id));
 
  100                 global $rbacadmin, $ilAppEventHandler;
 
  101                 foreach($user_ids as $user_id)
 
  105             $ilAppEventHandler->raise(
'Modules/OrgUnit',
 
  106                 'assignUsersToSuperiorRole',
 
  107                 array(
'object' => $this,
 
  108                     'obj_id' => $this->
getId(),
 
  111                     'user_id' => $user_id));
 
  117                 global $rbacadmin, $ilAppEventHandler;
 
  120         $ilAppEventHandler->raise(
'Modules/OrgUnit',
 
  121             'deassignUserFromEmployeeRole',
 
  122             array(
'object' => $this,
 
  123                 'obj_id' => $this->
getId(),
 
  126                 'user_id' => $user_id));
 
  130                 global $rbacadmin, $ilAppEventHandler;
 
  134         $ilAppEventHandler->raise(
'Modules/OrgUnit',
 
  135             'deassignUserFromSuperiorRole',
 
  136             array(
'object' => $this,
 
  137                 'obj_id' => $this->
getId(),
 
  140                 'user_id' => $user_id));
 
  151         public static function _exists($a_id, $a_reference = 
false){
 
  182                 global $rbacadmin,$rbacreview, $ilAppEventHandler;
 
  187                 $role_obj = $rolf_obj->createRole(
"il_orgu_employee_".$this->
getRefId(),
"Emplyee of org unit obj_no.".$this->
getId());
 
  202                 $role_obj = $rolf_obj->createRole(
"il_orgu_superior_".$this->
getRefId(),
"Superior of org unit obj_no.".$this->
getId());
 
  205                 $query = 
"SELECT obj_id FROM object_data ".
 
  206                         " WHERE type='rolt' AND title='il_orgu_superior'";
 
  209                 $rbacadmin->copyRoleTemplatePermissions(
$res->obj_id,ROLE_FOLDER_ID,$rolf_obj->getRefId(),$role_obj->getId());
 
  212                 $ops = $rbacreview->getOperationsOfRole($role_obj->getId(),
"orgu",$rolf_obj->getRefId());
 
  213                 $rbacadmin->grantPermission($role_obj->getId(),$ops,$this->
getRefId());
 
  216         $ilAppEventHandler->raise(
'Modules/OrgUnit',
 
  218             array(
'object' => $this,
 
  219                   'obj_id' => $this->
getId(),
 
  221                   'role_superior_id' => $role_obj->getId(),
 
  222                   'role_employee_id' => $role_obj->getId()));
 
  227                 if(parent::getTitle() != 
"__OrgUnitAdministration")
 
  230                         return $this->lng->txt(
"objs_orgu");
 
  239         $translations = array();
 
  241                 $q = 
"SELECT * FROM object_translation WHERE obj_id = ".
 
  242             $ilDB->quote($this->
getId(),
'integer').
" ORDER BY lang_default DESC";
 
  243                 $r = $this->ilias->db->query($q);
 
  249             $data[
"Fobject"][$num]= array(
"title"       => 
$row->title,
 
  250                 "desc"  => 
$row->description,
 
  251                 "lang"  => 
$row->lang_code
 
  256                 $translations = $data;
 
  258                 if(!count($translations[
"Fobject"])){
 
  260                         $translations[
"Fobject"][] = array(
"title"      => $this->
getTitle(),
 
  262                                 "lang"  => $lng->getDefaultLanguage());
 
  264                 return $translations;
 
  276         global $ilDB,$ilAppEventHandler;
 
  279         if (!parent::delete())
 
  285         include_once(
'./Services/User/classes/class.ilObjUserFolder.php');
 
  288         $query = 
"DELETE FROM object_translation WHERE obj_id = ".$ilDB->quote($this->
getId(),
'integer');
 
  291         $ilAppEventHandler->raise(
'Modules/OrgUnit',
 
  293             array(
'object' => $this,
 
  294                 'obj_id' => $this->
getId()));
 
  305         $query = 
"DELETE FROM object_translation WHERE obj_id= ".
 
  306             $ilDB->quote($this->
getId(),
'integer');
 
  315         $query = 
"DELETE FROM object_translation WHERE obj_id= ".
 
  316             $ilDB->quote($this->
getId(),
'integer').
" AND lang_code = ".
 
  317             $ilDB->quote($a_lang, 
'text');
 
  328             $a_title = 
"NO TITLE";
 
  331         $query = 
"INSERT INTO object_translation ".
 
  332             "(obj_id,title,description,lang_code,lang_default) ".
 
  334             "(".$ilDB->quote($this->
getId(),
'integer').
",".
 
  335             $ilDB->quote($a_title,
'text').
",".$ilDB->quote($a_desc,
'text').
",".
 
  336             $ilDB->quote($a_lang,
'text').
",".$ilDB->quote($a_lang_default,
'integer').
")";
 
  349             $a_title = 
"NO TITLE";
 
  352         $query = 
"UPDATE object_translation SET ";
 
  355             $query .= 
" title = ". $ilDB->quote($a_title,
'text');
 
  359                     $query .= 
", description = ".$ilDB->quote($a_desc,
'text').
" ";
 
  362             if($a_lang_default) {
 
  363                     $query .= 
", lang_default = ".$ilDB->quote($a_lang_default,
'integer').
" ";
 
  366             $query .=  
" WHERE obj_id = ".$ilDB->quote($this->
getId(),
'integer').
" AND lang_code = ".$ilDB->quote($a_lang,
'text');