function moodle_annotation_service($userid) { global $CFG; // Note: Cross-site request forgery protection requires cookies, so it will not be // activated if $CFG->usesid=true $csrfprotect = !empty($CFG->usesid) && $CFG->usesid; AnnotationService::AnnotationService(annotation_globals::get_host(), annotation_globals::get_service_path(), annotation_globals::get_install_date(), $userid, array('baseUrl' => $CFG->wwwroot, 'csrfCookie' => $csrfprotect ? null : 'MoodleSessionTest' . $CFG->sessioncookie, 'csrfCookieValue' => $csrfprotect ? null : $_SESSION['SESSION']->session_test)); $this->tablePrefix = $CFG->prefix; }
function OjsAnnotationService() { $servicePath = Request::getRequestUrl(); $host = Request::getServerHost(); // Get install date. Seems to produce 1969-12-31 $versionDao =& DAORegistry::getDAO('VersionDAO'); $versions =& $versionDao->getVersionHistory(); $firstVersion = array_pop($versions); $installDate = $firstVersion->getDateInstalled(); $installDate = strtotime($installDate); $username = Request::getUser(); if ($username) { $username = $username->getUsername(); } $sessionManager =& SessionManager::getManager(); $session = $sessionManager->getUserSession(); AnnotationService::AnnotationService($host, $servicePath, $installDate, $username, array('csrfCookie' => Config::getVar('general', 'session_cookie_name'), 'csrfCookieValue' => $session->getId())); }
function moodle_annotation_service($userid, $extService = null) { global $CFG; $this->extService = $extService; // Note: Cross-site request forgery protection requires cookies, so it will not be // activated if $CFG->usesid=true $csrfprotect = !empty($CFG->usesid) && $CFG->usesid; $cookiename = 'MoodleSession' . $CFG->sessioncookie; // was MoodleSessionTest. $cookievalue = $_COOKIE[$cookiename]; //$_SESSION['SESSION']->session_test; $moodlemia = moodle_marginalia::get_instance(); AnnotationService::AnnotationService($moodlemia->get_host(), $moodlemia->get_service_path(), $moodlemia->get_install_date(), $userid, array('baseUrl' => $CFG->wwwroot, 'csrfCookie' => $csrfprotect ? null : $cookiename, 'csrfCookieValue' => $csrfprotect ? null : $cookievalue, 'noPutDelete' => true)); }
function listBodyParams() { $method = $_SERVER['REQUEST_METHOD']; if ('POST' == $method) { $params = array(); foreach (array_keys($_POST) as $param) { $params[$param] = AnnotationService::unfix_quotes($_POST[$param]); } return $params; } elseif ('PUT' == $method) { // Now for some joy. PHP isn't clever enough to populate $_POST if the // Content-Type is application/x-www-form-urlencoded - it only does // that if the request method is POST. It is, however, clever enough // to insert its bloody !@#$! slashes. Bleargh. (Actually, to be fair // the descriptions of PUT I have seen insist that it should accept a // full resource representation, not changed fields as I'm doing here. // In Atom, at least, that's to maintain database consistency. I don't // think it's an issue here, so I haven't gotten around to doing it.) // Plus, how do I ensure the charset is respected correctly? Hmph. // Should fail if not Content-Type: application/x-www-form-urlencoded; charset: UTF-8 $fp = fopen('php://input', 'rb'); $urlencoded = ''; while ($data = fread($fp, 1024)) { $urlencoded .= $data; } parse_str($urlencoded, $params); foreach (array_keys($params) as $param) { $params[$param] = AnnotationService::unfix_quotes($params[$param]); } return $params; } else { return null; } }
function DemoAnnotationService() { global $CFG; $curuser = array_key_exists('curuser', $_GET) ? $_GET['curuser'] : '******'; AnnotationService::AnnotationService($CFG->host, $CFG->annotate_servicePath, $CFG->installDate, $curuser); }
function MoodleAnnotationService($username) { global $CFG; AnnotationService::AnnotationService(AnnotationGlobals::getHost(), AnnotationGlobals::getServicePath(), AnnotationGlobals::getInstallDate(), $username, $CFG->wwwroot); $this->tablePrefix = $CFG->prefix; }