/**
  * Returns true if there is an available slot for starting a scheduled meeting.
  * The number of available slots includes the buffer as set in the administration.
  * @return boolean
  */
 public function mayStartScheduledMeeting($sco_id)
 {
     $scheduledSlots = (int) $this->adcInfo->getSetting('ac_interface_objects');
     if ((int) $scheduledSlots <= 0) {
         return true;
     }
     $bufferSlots = (int) $this->adcInfo->getSetting('ac_interface_objects_buffer');
     $this->getCurrentMeetings();
     return $bufferSlots + $scheduledSlots > $this->currentState->scheduled_meetings || array_key_exists($sco_id, $this->currentMeetings);
 }
 /**
  * Logs in user on Adobe Connect server. This is done by redirection to the cave server.
  * @ilObjUser $ilUser
  * @param  $user
  * @return String       Session id
  */
 public function externalLogin()
 {
     /*
      * @var $ilUser ilObjUser
      */
     global $ilUser;
     //ilObjAdobveConnect::DoRead calls getBreezeSession. Only login if the user has a AAI-Account!
     if (!ilAdobeConnectServer::useSwitchaaiAuthMode($ilUser->getAuthMode(true))) {
         return false;
     }
     self::$breeze_session = null;
     //if there is already a session don't create a new session
     if ($_SESSION['breezesession']) {
         self::$breeze_session = $_SESSION['breezesession'];
         return $_SESSION['breezesession'];
     }
     //SWITCH aai user logins
     if (!$_GET['breezesession']) {
         //header() redirects do NOT necessarily stop the script, so we put an exit after it
         header('Location: ' . ilAdobeConnectServer::getSetting('cave') . '?back=https://' . $_SERVER['HTTP_HOST'] . urlencode($_SERVER['REQUEST_URI']) . '&request_session=true');
         exit;
     }
     self::$breeze_session = $_GET['breezesession'];
     //cache the Session in a cookie
     $_SESSION['breezesession'] = $_GET['breezesession'];
     self::$loginsession_cache[$_SESSION['breezesession']] = true;
     return $_SESSION['breezesession'];
 }
 /**
  * @return ilSwitchAaiXMLAPI|ilAdobeConnectXMLAPI|ilAdobeConnectDfnXMLAPI
  */
 public static function getApiByAuthMode()
 {
     if (self::$classname === NULL) {
         if (ilAdobeConnectServer::getSetting('auth_mode') == ilAdobeConnectServer::AUTH_MODE_SWITCHAAI) {
             self::$classname = 'ilSwitchAaiXMLAPI';
         } else {
             if (ilAdobeConnectServer::getSetting('auth_mode') == ilAdobeConnectServer::AUTH_MODE_DFN) {
                 self::$classname = 'ilAdobeConnectDfnXMLAPI';
             } else {
                 self::$classname = 'ilAdobeConnectXMLAPI';
             }
         }
     }
     include_once dirname(__FILE__) . '/class.' . self::$classname . '.php';
     $objXMLApi = new self::$classname();
     return $objXMLApi;
 }
 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;
 }
 public function getFolderIdByLogin($externalLogin)
 {
     $session = $this->xmlApi->getBreezeSession();
     if (ilAdobeConnectServer::getSetting('use_user_folders') == 1) {
         $folder_id = $this->xmlApi->lookupUserFolderId($externalLogin, $session);
         if (!$folder_id) {
             $folder_id = $this->xmlApi->createUserFolder($externalLogin, $session);
         }
     } else {
         $folder_id = $this->xmlApi->getShortcuts("my-meetings", $session);
     }
     return $folder_id;
 }
 public function infoScreen()
 {
     global $tpl;
     $this->pluginObj->includeClass('class.ilAdobeConnectUserUtil.php');
     $this->pluginObj->includeClass('class.ilAdobeConnectServer.php');
     $this->pluginObj->includeClass('class.ilAdobeConnectQuota.php');
     $this->pluginObj->includeClass("class.ilObjAdobeConnectAccess.php");
     $settings = ilAdobeConnectServer::_getInstance();
     $this->tabs->setTabActive('info_short');
     include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php";
     $info = new ilInfoScreenGUI($this);
     $info->removeFormAction();
     $info->addSection($this->pluginObj->txt('general'));
     if ($this->object->getPermanentRoom() == 1 && ilAdobeConnectServer::getSetting('enable_perm_room', '1')) {
         $duration_text = $this->pluginObj->txt('permanent_room');
     } else {
         $duration_text = ilDatePresentation::formatPeriod(new ilDateTime($this->object->getStartDate()->getUnixTime(), IL_CAL_UNIX), new ilDateTime($this->object->getEndDate()->getUnixTime(), IL_CAL_UNIX));
     }
     $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 link
     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");
         } else {
             $href = '<a href="' . $this->ctrl->getLinkTarget($this, 'performSso') . '" target="_blank" >' . $presentation_url . $this->object->getURL() . '</a>';
         }
     } else {
         $href = $this->txt("meeting_not_available");
     }
     $info->addProperty($this->pluginObj->txt('duration'), $duration_text);
     $info->addProperty($this->pluginObj->txt('meeting_url'), $href);
     $tpl->setContent($info->getHTML() . $this->getPerformTriggerHtml());
 }
 /** Generates the login name for a user depending on assignment_mode setting
  * 
  * @param integer $user_id user_id 
  */
 public static function generateXavcLoginName($user_id)
 {
     // set default when there is no setting set: assign_user_email
     $assignment_mode = ilAdobeConnectServer::getSetting('user_assignment_mode') ? ilAdobeConnectServer::getSetting('user_assignment_mode') : 'assign_user_email';
     switch ($assignment_mode) {
         case 'assign_user_email':
             $xavc_login = IL_INST_ID . '_' . $user_id . '_' . ilObjUser::_lookupEmail($user_id);
             break;
         case 'assign_ilias_login':
             $xavc_login = IL_INST_ID . '_' . $user_id . '_' . ilObjUser::_lookupLogin($user_id);
             break;
             //The SWITCH aai/DFN case, only return e-mail address
         //The SWITCH aai/DFN case, only return e-mail address
         case 'assign_dfn_email':
         case 'assign_breezeSession':
             $xavc_login = ilObjUser::_lookupEmail($user_id);
             break;
     }
     return $xavc_login;
 }
 public function getIliasSettingsValues()
 {
     $values = array();
     $values['obj_creation_settings'] = unserialize(ilAdobeConnectServer::getSetting('obj_creation_settings')) ? unserialize(ilAdobeConnectServer::getSetting('obj_creation_settings')) : '0';
     $values['obj_title_suffix'] = ilAdobeConnectServer::getSetting('obj_title_suffix') ? ilAdobeConnectServer::getSetting('obj_title_suffix') : 0;
     $values['allow_crs_grp_trigger'] = ilAdobeConnectServer::getSetting('allow_crs_grp_trigger') ? ilAdobeConnectServer::getSetting('allow_crs_grp_trigger') : 0;
     $values['show_free_slots'] = ilAdobeConnectServer::getSetting('show_free_slots') ? ilAdobeConnectServer::getSetting('show_free_slots') : 0;
     $values['enable_perm_room'] = ilAdobeConnectServer::getSetting('enable_perm_room', '1') ? ilAdobeConnectServer::getSetting('enable_perm_room', '1') : 0;
     $values['default_perm_room'] = ilAdobeConnectServer::getSetting('default_perm_room') ? ilAdobeConnectServer::getSetting('default_perm_room') : 0;
     $values['add_to_desktop'] = ilAdobeConnectServer::getSetting('add_to_desktop') ? ilAdobeConnectServer::getSetting('add_to_desktop') : 0;
     $values['content_file_types'] = strlen(ilAdobeConnectServer::getSetting('content_file_types')) > 1 ? ilAdobeConnectServer::getSetting('content_file_types') : 'ppt, pptx, flv, swf, pdf, gif, jpg, png, mp3, html';
     $values['use_user_folders'] = ilAdobeConnectServer::getSetting('use_user_folders') ? ilAdobeConnectServer::getSetting('use_user_folders') : 0;
     //		$values['crs_owner'] = ilAdobeConnectServer::getSetting('crs_owner')? ilAdobeConnectServer::getSetting('crs_owner') : 'host';
     $values['crs_admin'] = ilAdobeConnectServer::getSetting('crs_admin') ? ilAdobeConnectServer::getSetting('crs_admin') : 'mini-host';
     $values['crs_tutor'] = ilAdobeConnectServer::getSetting('crs_tutor') ? ilAdobeConnectServer::getSetting('crs_tutor') : 'mini-host';
     $values['crs_member'] = ilAdobeConnectServer::getSetting('crs_member') ? ilAdobeConnectServer::getSetting('crs_member') : 'view';
     //		$values['grp_owner'] = ilAdobeConnectServer::getSetting('grp_owner')? ilAdobeConnectServer::getSetting('grp_owner') : 'host';
     $values['grp_admin'] = ilAdobeConnectServer::getSetting('grp_admin') ? ilAdobeConnectServer::getSetting('grp_admin') : 'mini-host';
     $values['grp_member'] = ilAdobeConnectServer::getSetting('grp_member') ? ilAdobeConnectServer::getSetting('grp_member') : 'view';
     $this->form->setValuesByArray($values);
 }
 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;
 }