loginpage_hook(); error_log("require login done", 0); #$userrecord = get_record('user', 'username', $username); #$userid = $userrecord->id; $id = 2; if ($id) { if (! $cm = get_coursemodule_from_id('print', $id)) { error("Course Module ID was incorrect"); } if (! $assignment = get_record("print", "id", $cm->instance)) { error("assignment ID was incorrect"); } if (! $course = get_record("course", "id", $assignment->course)) { error("Course is misconfigured"); } } else { if (!$assignment = get_record("print", "id", $a)) { error("Course module is incorrect"); } if (! $course = get_record("course", "id", $assignment->course)) { error("Course is misconfigured"); } if (! $cm = get_coursemodule_from_instance("print", $assignment->id, $course->id)) { error("Course Module ID was incorrect"); } } $assignmentinstance = new print_base($cm->id, $assignment, $cm, $course); $filearea = $assignmentinstance->file_area_name($USER->id); $handle = fopen($CFG->dataroot."/".$filearea."/".$title.".pdf", "wb"); fwrite($handle, $file->scalar); fclose($handle); $fpath = $CFG->dataroot."/".$filearea."/".$title.".pdf"; $assignmentinstance->upload_xmlrpc($fpath, $userid, $title, $assignment);// Display or process the submissions return 1; } function send_func($method_name, $params, $app_data) { $file = $params[0]; $title = $params[1]; actual_func($file, $title); return 1; } function greeting_func($method_name, $params, $app_data) { $name = $params[0]; return "Hello, $name. How are you today?"; } /* * This creates a server and sets a handle for the * server in the variable $xmlrpc_server */ $xmlrpc_server = xmlrpc_server_create(); /* * xmlrpc_server_register_method() registers a PHP * function as an XML-RPC method. It takes three * parameters: * The first is the handle of a server created with * xmlrpc_server_create(), the second is the name to * register the server under (this is what needs to * be in the of a request for this * method), and the third is the name of the PHP * function to register. */ xmlrpc_server_register_method($xmlrpc_server, "send_func", "send_func"); xmlrpc_server_register_method($xmlrpc_server, "greeting_func", "greeting_func"); /* * When an XML-RPC request is sent to this script, it * can be found in the raw post data. */ $request_xml = $HTTP_RAW_POST_DATA; /* * The xmlrpc_server_call_method() sends a request to * the server and returns the response XML. In this case, * it sends the raw post data we got before. It requires * 3 arguments: * The first is the handle of a server created with * xmlrpc_server_create(), the second is a string containing * an XML-RPC request, and the third is for application data. * Whatever is passed into the third parameter of this function * is passed as the third paramater of the PHP function that the * request is asking for. */ $response = xmlrpc_server_call_method($xmlrpc_server, $request_xml, ''); // Now we print the response for the client to read. print $response; /* * This method frees the resources for the server specified * It takes one argument, a handle of a server created with * xmlrpc_server_create(). */ xmlrpc_server_destroy($xmlrpc_server); ?>