/** * Given an ID of an instance of this module, * this function will permanently delete the instance * and any data that depends on it. * * @param int $id Id of the module instance * @return boolean Success/Failure */ function adobeconnect_delete_instance($id) { global $DB; $param = array('id' => $id); if (!($adobeconnect = $DB->get_record('adobeconnect', $param))) { return false; } $result = true; // Remove meeting from Adobe connect server $param = array('instanceid' => $adobeconnect->id); $adbmeetings = $DB->get_records('adobeconnect_meeting_groups', $param); if (!empty($adbmeetings)) { $aconnect = aconnect_login(); foreach ($adbmeetings as $meeting) { // Update calendar event $param = array('courseid' => $adobeconnect->course, 'instance' => $adobeconnect->id, 'groupid' => $meeting->groupid, 'modulename' => 'adobeconnect'); $eventid = $DB->get_field('event', 'id', $param); if (!empty($eventid)) { $event = calendar_event::load($eventid); $event->delete(); } aconnect_remove_meeting($aconnect, $meeting->meetingscoid); } aconnect_logout($aconnect); } $param = array('id' => $adobeconnect->id); $result &= $DB->delete_records('adobeconnect', $param); $param = array('instanceid' => $adobeconnect->id); $result &= $DB->delete_records('adobeconnect_meeting_groups', $param); return $result; }
function adobe_connection_test($host = '', $port = 80, $username = '', $password = '', $httpheader = '', $emaillogin) { if (empty($host) or empty($port) or 0 == $port or empty($username) or empty($password) or empty($httpheader)) { echo "</p>One of the required parameters is blank or incorrect: <br />" . "Host: {$host}<br /> Port: {$port}<br /> Username: {$username}<br /> Password: {$password}" . "<br /> HTTP Header: {$httpheader}</p>"; die; } $messages = array(); $aconnectDOM = new connect_class_dom($host, $port, $username, $password); $params = array('action' => 'common-info'); // Send common-info call to obtain the session key echo '<p>Sending common-info call:</p>'; $aconnectDOM->create_request($params); if (!empty($aconnectDOM->_xmlresponse)) { // Get the session key from the XML response $aconnectDOM->read_cookie_xml($aconnectDOM->_xmlresponse); $cookie = $aconnectDOM->get_cookie(); if (empty($cookie)) { echo '<p>unable to obtain session key from common-info call</p>'; echo '<p>xmlrequest:</p>'; $doc = new DOMDocument(); if ($doc->loadXML($aconnectDOM->_xmlrequest)) { echo '<p>' . htmlspecialchars($doc->saveXML()) . '</p>'; } else { echo '<p>unable to display the XML request</p>'; } echo '<p>xmlresponse:</p>'; $doc = new DOMDocument(); if ($doc->loadXML($aconnectDOM->_xmlresponse)) { echo '<p>' . htmlspecialchars($doc->saveHTML()) . '</p>'; } else { echo '<p>unable to display the XML response</p>'; } } else { // print success echo '<p style="color:#006633">successfully obtained the session key: ' . $aconnectDOM->get_cookie() . '</p>'; // test logging in as the administrator $params = array('action' => 'login', 'login' => $aconnectDOM->get_username(), 'password' => $aconnectDOM->get_password()); $aconnectDOM->create_request($params); if ($aconnectDOM->call_success()) { echo '<p style="color:#006633">successfully logged in as admin user</p>'; //$username //Test retrevial of folders echo '<p>Testing retrevial of shared content, recording and meeting folders:</p>'; $folderscoid = aconnect_get_folder($aconnectDOM, 'content'); if ($folderscoid) { echo '<p style="color:#006633">successfully obtained shared content folder scoid: ' . $folderscoid . '</p>'; } else { echo '<p>error obtaining shared content folder</p>'; echo '<p style="color:#680000">XML request:<br />' . htmlspecialchars($aconnectDOM->_xmlrequest) . '</p>'; echo '<p style="color:#680000">XML response:<br />' . htmlspecialchars($aconnectDOM->_xmlresponse) . '</p>'; } $folderscoid = aconnect_get_folder($aconnectDOM, 'forced-archives'); if ($folderscoid) { echo '<p style="color:#006633">successfully obtained forced-archives (meeting recordings) folder scoid: ' . $folderscoid . '</p>'; } else { echo '<p>error obtaining forced-archives (meeting recordings) folder</p>'; echo '<p style="color:#680000">XML request:<br />' . htmlspecialchars($aconnectDOM->_xmlrequest) . '</p>'; echo '<p style="color:#680000">XML response:<br />' . htmlspecialchars($aconnectDOM->_xmlresponse) . '</p>'; } $folderscoid = aconnect_get_folder($aconnectDOM, 'meetings'); if ($folderscoid) { echo '<p style="color:#006633">successfully obtained meetings folder scoid: ' . $folderscoid . '</p>'; } else { echo '<p>error obtaining meetings folder</p>'; echo '<p style="color:#680000">XML request:<br />' . htmlspecialchars($aconnectDOM->_xmlrequest) . '</p>'; echo '<p style="color:#680000">XML response:<br />' . htmlspecialchars($aconnectDOM->_xmlresponse) . '</p>'; } //Test creating a meeting $folderscoid = aconnect_get_folder($aconnectDOM, 'meetings'); $meeting = new stdClass(); $meeting->name = 'testmeetingtest'; $time = time(); $meeting->starttime = $time; $time = $time + 60 * 60; $meeting->endtime = $time; if ($meetingscoid = aconnect_create_meeting($aconnectDOM, $meeting, $folderscoid)) { echo '<p style="color:#006633">successfully created meeting <b>testmeetingtest</b> scoid: ' . $meetingscoid . '</p>'; } else { echo '<p>error creating meeting <b>testmeetingtest</b> folder</p>'; echo '<p style="color:#680000">XML request:<br />' . htmlspecialchars($aconnectDOM->_xmlrequest) . '</p>'; echo '<p style="color:#680000">XML response:<br />' . htmlspecialchars($aconnectDOM->_xmlresponse) . '</p>'; } //Test creating a user $user = new stdClass(); $user->username = '******'; $user->firstname = 'testusertest'; $user->lastname = 'testusertest'; $user->email = '*****@*****.**'; if (!empty($emaillogin)) { $user->username = $user->email; } $skipdeletetest = false; if (!($usrprincipal = aconnect_user_exists($aconnectDOM, $user))) { $usrprincipal = aconnect_create_user($aconnectDOM, $user); if ($usrprincipal) { echo '<p style="color:#006633">successfully created user <b>testusertest</b> principal-id: ' . $usrprincipal . '</p>'; } else { echo '<p>error creating user <b>testusertest</b></p>'; echo '<p style="color:#680000">XML request:<br />' . htmlspecialchars($aconnectDOM->_xmlrequest) . '</p>'; echo '<p style="color:#680000">XML response:<br />' . htmlspecialchars($aconnectDOM->_xmlresponse) . '</p>'; } } else { echo '<p>user <b>testusertest</b> already exists skipping delete user test</p>'; $skipdeletetest = true; } //Test assigning a user a role to the meeting if (aconnect_check_user_perm($aconnectDOM, $usrprincipal, $meetingscoid, ADOBE_PRESENTER, true)) { echo '<p style="color:#006633">successfully assigned user <b>testusertest</b>' . ' presenter role in meeting <b>testmeetingtest</b>: ' . $usrprincipal . '</p>'; } else { echo '<p>error assigning user <b>testusertest</b> presenter role in meeting <b>testmeetingtest</b></p>'; echo '<p style="color:#680000">XML request:<br />' . htmlspecialchars($aconnectDOM->_xmlrequest) . '</p>'; echo '<p style="color:#680000">XML response:<br />' . htmlspecialchars($aconnectDOM->_xmlresponse) . '</p>'; } //Test removing role from meeting if (aconnect_check_user_perm($aconnectDOM, $usrprincipal, $meetingscoid, ADOBE_REMOVE_ROLE, true)) { echo '<p style="color:#006633">successfully removed presenter role for user <b>testusertest</b>' . ' in meeting <b>testmeetingtest</b>: ' . $usrprincipal . '</p>'; } else { echo '<p>error remove presenter role for user <b>testusertest</b> in meeting <b>testmeetingtest</b></p>'; echo '<p style="color:#680000">XML request:<br />' . htmlspecialchars($aconnectDOM->_xmlrequest) . '</p>'; echo '<p style="color:#680000">XML response:<br />' . htmlspecialchars($aconnectDOM->_xmlresponse) . '</p>'; } //Test removing user from server if (!$skipdeletetest) { if (aconnect_delete_user($aconnectDOM, $usrprincipal)) { echo '<p style="color:#006633">successfully removed user <b>testusertest</b> principal-id: ' . $usrprincipal . '</p>'; } else { echo '<p>error removing user <b>testusertest</b></p>'; echo '<p style="color:#680000">XML request:<br />' . htmlspecialchars($aconnectDOM->_xmlrequest) . '</p>'; echo '<p style="color:#680000">XML response:<br />' . htmlspecialchars($aconnectDOM->_xmlresponse) . '</p>'; } } //Test removing meeting from server if ($meetingscoid) { if (aconnect_remove_meeting($aconnectDOM, $meetingscoid)) { echo '<p style="color:#006633">successfully removed meeting <b>testmeetingtest</b> scoid: ' . $meetingscoid . '</p>'; } else { echo '<p>error removing meeting <b>testmeetingtest</b> folder</p>'; echo '<p style="color:#680000">XML request:<br />' . htmlspecialchars($aconnectDOM->_xmlrequest) . '</p>'; echo '<p style="color:#680000">XML response:<br />' . htmlspecialchars($aconnectDOM->_xmlresponse) . '</p>'; } } } else { echo '<p style="color:#680000">logging in as ' . $username . ' was not successful, check to see if the username and password are correct </p>'; } } } else { echo '<p style="color:#680000">common-info API call returned an empty document. Please check your settings and try again </p>'; } aconnect_logout($aconnectDOM); }
/** * Given an ID of an instance of this module, * this function will permanently delete the instance * and any data that depends on it. * * @param int $id Id of the module instance * @return boolean Success/Failure */ function adobeconnect_delete_instance($id) { if (!($adobeconnect = get_record('adobeconnect', 'id', $id))) { return false; } $result = true; // Remove meeting from Adobe connect server $adbmeetings = get_records('adobeconnect_meeting_groups', 'instanceid', $adobeconnect->id); if (!empty($adbmeetings)) { $aconnect = aconnect_login(); foreach ($adbmeetings as $meeting) { // Update calendar event $eventid = get_field('event', 'id', 'courseid', $adobeconnect->course, 'instance', $adobeconnect->id, 'groupid', $meeting->groupid); if (!empty($eventid)) { delete_event($eventid); } aconnect_remove_meeting($aconnect, $meeting->meetingscoid); } aconnect_logout($aconnect); } $result &= delete_records('adobeconnect', 'id', $adobeconnect->id); $result &= delete_records('adobeconnect_meeting_groups', 'instanceid', $adobeconnect->id); return $result; }