本文整理汇总了PHP中webservice::add_external_service方法的典型用法代码示例。如果您正苦于以下问题:PHP webservice::add_external_service方法的具体用法?PHP webservice::add_external_service怎么用?PHP webservice::add_external_service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webservice
的用法示例。
在下文中一共展示了webservice::add_external_service方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: webservice
$capabilities = fetch_context_capabilities($context);
}
foreach ($capabilities as $capability) {
assign_capability($capability->name, CAP_ALLOW, $roleid, $context->id, true);
}
$context->mark_dirty();
// Create a new service with all functions for the user.
$webservicemanager = new webservice();
if (!($service = $DB->get_record('external_services', array('shortname' => 'mdk_all')))) {
$service = new stdClass();
$service->name = 'MDK: All functions';
$service->shortname = 'mdk_all';
$service->enabled = 1;
$service->restrictedusers = 1;
$service->downloadfiles = 1;
$service->id = $webservicemanager->add_external_service($service);
}
$functions = $webservicemanager->get_not_associated_external_functions($service->id);
foreach ($functions as $function) {
$webservicemanager->add_external_function_to_service($function->name, $service->id);
}
if (!$webservicemanager->get_ws_authorised_user($service->id, $user->id)) {
$adduser = new stdClass();
$adduser->externalserviceid = $service->id;
$adduser->userid = $user->id;
$webservicemanager->add_ws_authorised_user($adduser);
}
// Generate a token for the user.
if (!($token = $DB->get_field('external_tokens', 'token', array('userid' => $user->id, 'externalserviceid' => $service->id)))) {
$token = external_generate_token(EXTERNAL_TOKEN_PERMANENT, $service->id, $user->id, $context, 0, '');
}
示例2: redirect
add_to_log(SITEID, 'webservice', 'delete', $returnurl, get_string('deleteservice', 'webservice', $service));
redirect($returnurl);
}
/// EDIT/CREATE/CANCEL operations => at the end redirect to add function page / main service page
$mform = new external_service_form(null, $service);
if ($mform->is_cancelled()) {
redirect($returnurl);
} else {
if ($servicedata = $mform->get_data()) {
$servicedata = (object) $servicedata;
if (!empty($servicedata->requiredcapability) && $servicedata->requiredcapability == "norequiredcapability") {
$servicedata->requiredcapability = "";
}
//create operation
if (empty($servicedata->id)) {
$servicedata->id = $webservicemanager->add_external_service($servicedata);
add_to_log(SITEID, 'webservice', 'add', $returnurl, get_string('addservice', 'webservice', $servicedata));
//redirect to the 'add functions to service' page
$addfunctionpage = new moodle_url($CFG->wwwroot . '/' . $CFG->admin . '/webservice/service_functions.php', array('id' => $servicedata->id));
$returnurl = $addfunctionpage->out(false);
} else {
//update operation
$webservicemanager->update_external_service($servicedata);
add_to_log(SITEID, 'webservice', 'edit', $returnurl, get_string('editservice', 'webservice', $servicedata));
}
redirect($returnurl);
}
}
//OUTPUT edit/create form
echo $OUTPUT->header();
$mform->display();