protected function getAdditionalItems($data)
 {
     $xavc_participants = $this->parent_obj->object->getParticipants();
     $selected_user_ids = array();
     foreach ($data['items'] as $db_item) {
         $selected_user_ids[] = (int) $db_item['user_id'];
     }
     if ($xavc_participants != NULL) {
         foreach ($xavc_participants as $participant) {
             $user_id = ilXAVCMembers::_lookupUserId($participant['login']);
             //if the user_id is in the xavc members table in ilias (->$selected_user_ids), all information is already in $data['items'], so we just continue.
             //if the user_id belongs to the technical user, we just continue, because we don't want him to be shown
             if (in_array((int) $user_id, $selected_user_ids) || $participant['login'] == ilAdobeConnectServer::getSetting('login')) {
                 continue;
             }
             //when user_id is bigger than 0, he exists. So we get it's information by using ilObjUser
             if ($user_id > 0) {
                 $tmp_user = ilObjectFactory::getInstanceByObjId($user_id, false);
                 if (!$tmp_user) {
                     // Maybe delete entries xavc_members xavc_users tables
                     continue;
                 }
                 $firstname = $tmp_user->getFirstname();
                 $lastname = $tmp_user->getLastname();
                 if ($tmp_user->hasPublicProfile() && $tmp_user->getPref('public_email') == 'y') {
                     $user_mail = $tmp_user->getEmail();
                 } else {
                     $user_mail = '';
                 }
             } else {
                 $firstname = $participant['name'];
                 $user_mail = '';
             }
             $ac_user['user_id'] = $user_id;
             $ac_user['firstname'] = $firstname;
             $ac_user['lastname'] = $lastname;
             $ac_user['login'] = $participant['login'];
             $ac_user['email'] = $user_mail;
             $ac_user['xavc_status'] = $participant['status'];
             $data['items'][] = $ac_user;
         }
     }
     return $data;
 }
 /**
  * Do Cloning
  */
 public function doClone($a_target_id, $a_copy_id, $new_obj)
 {
     /**
      * @var $ilDB   ilDB
      * @var $ilUser ilObjUser
      */
     global $ilDB, $ilUser;
     // to avoid date-conflicts:
     // start_date = now - 2h
     // duration = 1h
     $now = new ilDateTime(time(), IL_CAL_UNIX);
     $this->start_date = new ilDateTime($now->getUnixTime() - 7200, IL_CAL_UNIX);
     //$this->start_date = new ilDateTime(0, IL_CAL_UNIX);
     $this->duration = array('hours' => 1, 'minutes' => 0);
     $new_obj->setStartDate($this->getStartDate());
     $new_obj->setInstructions($this->getInstructions());
     $new_obj->setContactInfo($this->getContactInfo());
     $new_obj->setPermanentRoom($this->getPermanentRoom());
     $new_obj->setReadContents($this->getReadContents());
     $new_obj->setReadRecords($this->getReadRecords());
     $new_obj->setDuration($this->getDuration());
     $new_obj->setURL($this->getURL());
     $new_obj->setScoId($this->getScoId());
     $new_obj->setFolderId($this->getFolderId());
     $new_obj->update();
     // add xavc-member,  assign roles
     $new_obj_id = $new_obj->getId();
     $res = $ilDB->queryF('SELECT sco_id FROM rep_robj_xavc_data WHERE id = %s', array('integer'), array($new_obj_id));
     $row = $ilDB->fetchAssoc($res);
     $new_sco_id = $row['sco_id'];
     $this->pluginObj->includeClass('class.ilXAVCMembers.php');
     $this->pluginObj->includeClass('class.ilAdobeConnectRoles.php');
     $xavcMemberObj = new ilXAVCMembers($new_obj->getRefId(), $ilUser->getId());
     $xavcMemberObj->setPresenterStatus();
     $xavcMemberObj->setScoId($new_sco_id);
     $xavcMemberObj->insertXAVCMember();
     $xavc_role = new ilAdobeConnectRoles($new_obj->getRefId());
     $xavc_role->addAdministratorRole($ilUser->getId());
     if (ilAdobeConnectServer::getSetting('add_to_desktop') == 1) {
         ilObjUser::_addDesktopItem($ilUser->getId(), $new_obj->getRefId(), 'xavc');
     }
 }
 /**
  *  Check whether a user is host in this virtual classroom.
  * @param String $login
  * @return boolean
  */
 public function isParticipant($login)
 {
     global $ilUser;
     $this->pluginObj->includeClass('class.ilAdobeConnectServer.php');
     $settings = ilAdobeConnectServer::_getInstance();
     if ($settings->getAuthMode() == ilAdobeConnectServer::AUTH_MODE_SWITCHAAI) {
         $this->pluginObj->includeClass('class.ilXAVCMembers.php');
         return ilXAVCMembers::_isMember($ilUser->getId(), $this->getRefId());
     } else {
         $session = $this->xmlApi->getBreezeSession();
         if ($session != NULL && $this->xmlApi->login($this->adminLogin, $this->adminPass, $session)) {
             return $this->xmlApi->isParticipant($login, $this->sco_id, $session);
         }
     }
 }
 public function showContent()
 {
     /*
      * var $ilUser ilUser
      */
     global $ilUser, $tpl, $ilAccess;
     $this->pluginObj->includeClass('class.ilAdobeConnectUserUtil.php');
     $this->pluginObj->includeClass('class.ilAdobeConnectServer.php');
     $has_write_permission = $ilAccess->checkAccess("write", "", $this->object->getRefId());
     $settings = ilAdobeConnectServer::_getInstance();
     if ($settings->getAuthMode() == ilAdobeConnectServer::AUTH_MODE_SWITCHAAI and ilAdobeConnectServer::useSwitchaaiAuthMode($ilUser->getAuthMode(true))) {
         //Login User - this creates a user if he not exists.
         $ilAdobeConnectUser = new ilAdobeConnectUserUtil($this->user->getId());
         $ilAdobeConnectUser->loginUser();
         //Add the user as Participant @adobe switch
         $status = ilXAVCMembers::_lookupStatus($ilUser->getId(), $this->object->getRefId());
         $this->object->addSwitchParticipant($ilUser->getEmail(), $status);
     }
     $this->tabs->setTabActive('contents');
     include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php";
     $info = new ilInfoScreenGUI($this);
     $info->removeFormAction();
     $this->pluginObj->includeClass('class.ilAdobeConnectQuota.php');
     $this->pluginObj->includeClass("class.ilObjAdobeConnectAccess.php");
     $is_member = ilObjAdobeConnectAccess::_hasMemberRole($ilUser->getId(), $this->object->getRefId());
     $is_admin = ilObjAdobeConnectAccess::_hasAdminRole($ilUser->getId(), $this->object->getRefId());
     //SWITCHAAI: If the user has no SWITCHaai-Account, we show the room link without connecting to the adobe-connect server. This is used for guest logins.
     $show_only_roomlink = false;
     if ($settings->getAuthMode() == ilAdobeConnectServer::AUTH_MODE_SWITCHAAI and !ilAdobeConnectServer::useSwitchaaiAuthMode($ilUser->getAuthMode(true))) {
         $show_only_roomlink = true;
         $presentation_url = $settings->getPresentationUrl();
         $button_txt = $this->pluginObj->txt('enter_vc');
         $button_target = $presentation_url . $this->object->getURL();
         $button_tpl = new ilTemplate($this->pluginObj->getDirectory() . "/templates/default/tpl.bigbutton.html", true, true);
         $button_tpl->setVariable('BUTTON_TARGET', $button_target);
         $button_tpl->setVariable('BUTTON_TEXT', $button_txt);
         $big_button = $button_tpl->get();
         $info->addSection('');
         $info->addProperty('', $big_button . "<br />");
     }
     if (($this->access->checkAccess("write", "", $this->object->getRefId()) || $is_member || $is_admin) && !$show_only_roomlink) {
         $presentation_url = $settings->getPresentationUrl();
         $form = new ilPropertyFormGUI();
         $form->setTitle($this->pluginObj->txt('access_meeting_title'));
         $this->object->doRead();
         if ($this->object->getStartDate() != NULL) {
             $ilAdobeConnectUser = new ilAdobeConnectUserUtil($this->user->getId());
             $ilAdobeConnectUser->ensureAccountExistance();
             $xavc_login = $ilAdobeConnectUser->getXAVCLogin();
             $quota = new ilAdobeConnectQuota();
             // show button
             if (($this->object->getPermanentRoom() == 1 || $this->doProvideAccessLink()) && $this->object->isParticipant($xavc_login)) {
                 if (!$quota->mayStartScheduledMeeting($this->object->getScoId())) {
                     $href = $this->txt("meeting_not_available_no_slots");
                     $button_disabled = true;
                 } else {
                     $href = '<a href="' . $this->ctrl->getLinkTarget($this, 'performSso') . '" target="_blank" >' . $presentation_url . $this->object->getURL() . '</a>';
                     $button_disabled = false;
                 }
             } else {
                 $href = $this->txt("meeting_not_available");
                 $button_disabled = true;
             }
             if ($button_disabled == true) {
                 $button_txt = $href;
             } else {
                 $button_txt = $this->pluginObj->txt('enter_vc');
             }
             $button_target = ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'performSso', '', false, false);
             $button_tpl = new ilTemplate($this->pluginObj->getDirectory() . "/templates/default/tpl.bigbutton.html", true, true);
             $button_tpl->setVariable('BUTTON_TARGET', $button_target);
             $button_tpl->setVariable('BUTTON_TEXT', $button_txt);
             $big_button = $button_tpl->get();
             $info->addSection('');
             if ($button_disabled == true) {
                 $info->addProperty('', $href);
             } else {
                 $info->addProperty('', $big_button . "<br />");
             }
             // show instructions
             if (strlen($this->object->getInstructions()) > 1) {
                 $info->addSection($this->lng->txt('exc_instruction'));
                 $info->addProperty('', nl2br($this->object->getInstructions()));
             }
             // show contact info
             if (strlen($this->object->getContactInfo()) > 1) {
                 $info->addSection($this->pluginObj->txt('contact_information'));
                 $info->addProperty('', nl2br($this->object->getContactInfo()));
             }
             //show contents
             if (ilXAVCPermissions::hasAccess($ilUser->getId(), $this->object->getRefId(), AdobeConnectPermissions::PERM_READ_CONTENTS) && $this->object->getReadContents('content')) {
                 $info->addSection($this->pluginObj->txt('file_uploads'));
                 $info->setFormAction($this->ctrl->getFormAction($this, 'showContent'));
                 $has_access = false;
                 if (ilXAVCPermissions::hasAccess($ilUser->getId(), $this->ref_id, AdobeConnectPermissions::PERM_UPLOAD_CONTENT) || $has_write_permission) {
                     $has_access = true;
                     $tpl_sub_button = new ilTemplate("Services/InfoScreen/templates/default/tpl.submitbuttons.html", true, true);
                     $tpl_sub_button->setVariable('BTN_NAME', $this->txt("add_new_content"));
                     $tpl_sub_button->setVariable('BTN_COMMAND', 'showAddContent');
                     $info->addProperty('', $tpl_sub_button->get());
                 }
                 $info->addProperty('', $this->viewContents($has_access));
             }
             // show records
             if (ilXAVCPermissions::hasAccess($ilUser->getId(), $this->object->getRefId(), AdobeConnectPermissions::PERM_READ_RECORDS) && $this->object->getReadRecords()) {
                 $has_access = false;
                 if (ilXAVCPermissions::hasAccess($ilUser->getId(), $this->ref_id, AdobeConnectPermissions::PERM_EDIT_RECORDS) || $has_write_permission) {
                     $has_access = true;
                 }
                 $info->addSection($this->pluginObj->txt('records'));
                 $info->addProperty('', $this->viewRecords($has_access, 'record'));
             }
         } else {
             ilUtil::sendFailure($this->txt('error_connect_ac_server'));
         }
     }
     $info->hideFurtherSections();
     $tpl->setContent($info->getHTML() . $this->getPerformTriggerHtml());
     $tpl->setPermanentLink('xavc', $this->object->getRefId());
     $tpl->addILIASFooter();
 }
 public function performCrsGrpTrigger()
 {
     ignore_user_abort(true);
     @set_time_limit(0);
     $response = new stdClass();
     $response->succcess = false;
     $this->pluginObj->includeClass('class.ilAdobeConnectServer.php');
     if ((int) ilAdobeConnectServer::getSetting('allow_crs_grp_trigger') == 0) {
         echo json_encode($response);
         exit;
     }
     global $tree;
     $this->pluginObj->includeClass('class.ilXAVCMembers.php');
     $parent_crs_ref = $tree->checkForParentType($this->object->getRefId(), 'crs');
     $parent_grp_ref = $tree->checkForParentType($this->object->getRefId(), 'grp');
     $ok = false;
     if ($parent_crs_ref && empty($parent_grp_ref)) {
         $ok = true;
         $obj_id = ilObject::_lookupObjectId($parent_crs_ref);
         include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
         $oParticipants = ilCourseParticipants::_getInstanceByObjId($obj_id);
     } else {
         if ($parent_grp_ref) {
             $ok = true;
             $obj_id = ilObject::_lookupObjectId($parent_grp_ref);
             include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
             $oParticipants = ilGroupParticipants::_getInstanceByObjId($obj_id);
         }
     }
     if ($ok) {
         $sco_id = ilObjAdobeConnect::_lookupScoId(ilObject::_lookupObjectId($this->object->getRefId()));
         $current_member_ids = ilXAVCMembers::getMemberIds($this->object->getRefId());
         $crs_grp_member_ids = $oParticipants->getParticipants();
         if (count($current_member_ids) == 0 && count($crs_grp_member_ids) > 0) {
             $this->object->addCrsGrpMembers($this->object->getRefId(), $sco_id);
         } else {
             $new_member_ids = array_diff($crs_grp_member_ids, $current_member_ids);
             $delete_member_ids = array_diff($current_member_ids, $crs_grp_member_ids);
             $ongoing_member_ids = array_intersect($current_member_ids, $crs_grp_member_ids);
             if (is_array($new_member_ids) && count($new_member_ids) > 0) {
                 $this->object->addCrsGrpMembers($this->object->getRefId(), $sco_id, $new_member_ids);
             }
             if (is_array($delete_member_ids) && count($delete_member_ids) > 0) {
                 $this->object->deleteCrsGrpMembers($sco_id, $delete_member_ids);
             }
             //This is necessary to assure consistency between Ilias Roles on Group/Course and on the Adobe Connect Room.
             //Excemption granted for none Switch Server Types, as there is no way to test this for us.
             $this->pluginObj->includeClass('class.ilAdobeConnectRoles.php');
             $xavc_role = new ilAdobeConnectRoles($this->object->getRefId());
             $settings = ilAdobeConnectServer::_getInstance();
             if ($settings->getAuthMode() == ilAdobeConnectServer::AUTH_MODE_SWITCHAAI) {
                 foreach ($ongoing_member_ids as $member_id) {
                     $is_admin = $xavc_role->isAdministrator($member_id);
                     if ($oParticipants->isAdmin($member_id) && !$is_admin) {
                         $xavc_role->detachMemberRole($member_id);
                         $xavc_role->addAdministratorRole($member_id);
                     } else {
                         if ($oParticipants->isMember($member_id) && $is_admin) {
                             $xavc_role->detachAdministratorRole($member_id);
                             $xavc_role->addMemberRole($member_id);
                         }
                     }
                 }
             }
         }
     }
     $response->succcess = true;
     echo json_encode($response);
     exit;
 }