本文整理汇总了PHP中webservice类的典型用法代码示例。如果您正苦于以下问题:PHP webservice类的具体用法?PHP webservice怎么用?PHP webservice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了webservice类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_site_info
/**
* Return user information including profile picture + basic site information
* Note:
* - no capability checking because we return just known information by logged user
* @param array $serviceshortnames of service shortnames - the functions of these services will be returned
* @return array
*/
public function get_site_info($serviceshortnames = array())
{
global $USER, $SITE, $CFG;
$params = self::validate_parameters(self::get_site_info_parameters(), array('serviceshortnames' => $serviceshortnames));
$profileimageurl = moodle_url::make_pluginfile_url(get_context_instance(CONTEXT_USER, $USER->id)->id, 'user', 'icon', NULL, '/', 'f1');
require_once $CFG->dirroot . "/webservice/lib.php";
$webservice = new webservice();
//If no service listed always return the mobile one by default
if (empty($params['serviceshortnames']) and $CFG->enablewebservices) {
$mobileservice = $webservice->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE);
if ($mobileservice->enabled) {
$params['serviceshortnames'] = array(MOODLE_OFFICIAL_MOBILE_SERVICE);
//return mobile service by default
}
}
//retrieve the functions related to the services
$functions = $webservice->get_external_functions_by_enabled_services($params['serviceshortnames']);
//built up the returned values of the list of functions
$componentversions = array();
$avalaiblefunctions = array();
foreach ($functions as $function) {
$functioninfo = array();
$functioninfo['name'] = $function->name;
if ($function->component == 'moodle') {
$version = $CFG->version;
//moodle version
} else {
$versionpath = get_component_directory($function->component) . '/version.php';
if (is_readable($versionpath)) {
//we store the component version once retrieved (so we don't load twice the version.php)
if (!isset($componentversions[$function->component])) {
include $versionpath;
$componentversions[$function->component] = $plugin->version;
$version = $plugin->version;
} else {
$version = $componentversions[$function->component];
}
} else {
//function component should always have a version.php,
//otherwise the function should have been described with component => 'moodle'
throw new moodle_exception('missingversionfile', 'webservice', '', $function->component);
}
}
$functioninfo['version'] = $version;
$avalaiblefunctions[] = $functioninfo;
}
return array('sitename' => $SITE->fullname, 'siteurl' => $CFG->wwwroot, 'username' => $USER->username, 'firstname' => $USER->firstname, 'lastname' => $USER->lastname, 'fullname' => fullname($USER), 'userid' => $USER->id, 'userpictureurl' => $profileimageurl->out(false), 'functions' => $avalaiblefunctions);
}
开发者ID:rosenclever,项目名称:moodle,代码行数:55,代码来源:externallib.php
示例2: get_cuentas
public static function get_cuentas()
{
$db = new db_core();
$webservice = new webservice();
$cuentas = array();
$consulta[0] = $db->db_query("SELECT * FROM cuentas_bancarias AS c WHERE c.id_user='" . $webservice->get_user($_SESSION['token']) . "'");
while ($consulta[1] = mysql_fetch_array($consulta[0])) {
$cantidad = $db->reg_one("SELECT COUNT(*) FROM inversion_proyecto AS i WHERE i.id_cuenta_bancaria='" . $consulta[1][0] . "' AND i.confirmado='1'");
if ($consulta[1]['tipo_de_cuenta'] == 0) {
$consulta[1]['tipo_de_cuenta'] = "Cuenta Corriente";
} elseif ($consulta[1]['tipo_de_cuenta'] == 1) {
$consulta[1]['tipo_de_cuenta'] = "Cuenta Vista";
}
$consulta[1]['banco'] = utf8_encode($consulta[1]['banco']);
$consulta[1]['cantidad'] = $cantidad[0];
$cuentas[] = $consulta[1];
}
return $cuentas;
}
开发者ID:centaurustech,项目名称:eollice,代码行数:19,代码来源:proyectos.php
示例3: definition
function definition()
{
global $USER, $CFG;
$mform = $this->_form;
$mform->setDisableShortforms(true);
$mform->addElement('header', 'changepassword', get_string('changepassword'), '');
// visible elements
$mform->addElement('static', 'username', get_string('username'), $USER->username);
$policies = array();
if (!empty($CFG->passwordpolicy)) {
$policies[] = print_password_policy();
}
if (!empty($CFG->passwordreuselimit) and $CFG->passwordreuselimit > 0) {
$policies[] = get_string('informminpasswordreuselimit', 'auth', $CFG->passwordreuselimit);
}
if ($policies) {
$mform->addElement('static', 'passwordpolicyinfo', '', implode('<br />', $policies));
}
$mform->addElement('password', 'password', get_string('oldpassword'));
$mform->addRule('password', get_string('required'), 'required', null, 'client');
$mform->setType('password', PARAM_RAW);
$mform->addElement('password', 'newpassword1', get_string('newpassword'));
$mform->addRule('newpassword1', get_string('required'), 'required', null, 'client');
$mform->setType('newpassword1', PARAM_RAW);
$mform->addElement('password', 'newpassword2', get_string('newpassword') . ' (' . get_String('again') . ')');
$mform->addRule('newpassword2', get_string('required'), 'required', null, 'client');
$mform->setType('newpassword2', PARAM_RAW);
if (empty($CFG->passwordchangetokendeletion) and !empty(webservice::get_active_tokens($USER->id))) {
$mform->addElement('advcheckbox', 'signoutofotherservices', get_string('signoutofotherservices'));
$mform->addHelpButton('signoutofotherservices', 'signoutofotherservices');
$mform->setDefault('signoutofotherservices', 1);
}
// hidden optional params
$mform->addElement('hidden', 'id', 0);
$mform->setType('id', PARAM_INT);
// buttons
if (get_user_preferences('auth_forcepasswordchange')) {
$this->add_action_buttons(false);
} else {
$this->add_action_buttons(true);
}
}
开发者ID:dg711,项目名称:moodle,代码行数:42,代码来源:change_password_form.php
示例4: cleanWSCacheEntries
/**
* this method checks for each cache entry of
* a webservice if it has to be deleted
*
* @param webservice $ws
*/
private function cleanWSCacheEntries($ws)
{
$log = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
if ($ws->getSpanOfLife() != "0") {
$cacheResults = WSStorage::getDatabase()->getResultsFromCache($ws->getArticleID());
$this->addSubTask(sizeof($cacheResults) + 1);
//echo($ws->getArticleID());
$deletedCacheEntries = 0;
foreach ($cacheResults as $cacheResult) {
if ($ws->doesExpireAfterUpdate() == "false") {
if ($cacheResult["lastAccess"]) {
if (wfTimestamp(TS_UNIX, $cacheResult["lastAccess"]) < wfTimestamp(TS_UNIX, $cacheResult["lastUpdate"])) {
$compareTS = $cacheResult["lastUpdate"];
} else {
$compareTS = $cacheResult["lastAccess"];
}
} else {
$compareTS = $cacheResult["lastUpdate"];
}
} else {
$compareTS = $cacheResult["lastUpdate"];
}
//todo: change to days again
if (wfTime() - wfTimestamp(TS_UNIX, $compareTS) > $ws->getSpanOfLife() * 24 * 60 * 60) {
WSStorage::getDatabase()->removeWSEntryFromCache($ws->getArticleID(), $cacheResult["paramSetId"]);
$deletedCacheEntries += 1;
}
$this->worked(1);
}
// echo($ws->getName()."-".$deletedCacheEntries);
if ($deletedCacheEntries > 0) {
$log->addGardeningIssueAboutValue($this->id, SMW_GARDISSUE__REMOVED_WSCACHE_ENTRIES, Title::newFromText($ws->getName()), $deletedCacheEntries);
}
} else {
$this->addSubTask(1);
$this->worked(1);
}
}
开发者ID:seedbank,项目名称:old-repo,代码行数:44,代码来源:SMW_WSCacheBot.php
示例5: moodle_url
$PAGE->set_url('/user/wsdoc.php');
$PAGE->set_title(get_string('documentation', 'webservice'));
$PAGE->set_heading(get_string('documentation', 'webservice'));
$PAGE->set_pagelayout('standard');
//nav bar
$PAGE->navbar->ignore_active(true);
$PAGE->navbar->add(get_string('usercurrentsettings'));
$PAGE->navbar->add(get_string('securitykeys', 'webservice'), new moodle_url('/user/managetoken.php', array('id' => $tokenid, 'sesskey' => sesskey())));
$PAGE->navbar->add(get_string('documentation', 'webservice'));
//check web service are enabled
if (empty($CFG->enablewsdocumentation)) {
echo get_string('wsdocumentationdisable', 'webservice');
die;
}
//check that the current user is the token user
$webservice = new webservice();
$token = $webservice->get_token_by_id($tokenid);
if (empty($token) or empty($token->userid) or empty($USER->id) or $token->userid != $USER->id) {
throw new moodle_exception('docaccessrefused', 'webservice');
}
// get the list of all functions related to the token
$functions = $webservice->get_external_functions(array($token->externalserviceid));
// get all the function descriptions
$functiondescs = array();
foreach ($functions as $function) {
$functiondescs[$function->name] = external_function_info($function);
}
//get activated protocol
$activatedprotocol = array();
$activatedprotocol['rest'] = webservice_protocol_is_enabled('rest');
$activatedprotocol['xmlrpc'] = webservice_protocol_is_enabled('xmlrpc');
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:wsdoc.php
示例6: required_param
require_once $CFG->dirroot . '/webservice/lib.php';
require_once $CFG->dirroot . '/' . $CFG->admin . '/webservice/forms.php';
$serviceid = required_param('serviceid', PARAM_INT);
$userid = required_param('userid', PARAM_INT);
admin_externalpage_setup('externalserviceusersettings');
//define nav bar
$PAGE->set_url('/' . $CFG->admin . '/webservice/service_user_settings.php', array('id' => $serviceid, 'userid' => $userid));
$node = $PAGE->settingsnav->find('externalservices', navigation_node::TYPE_SETTING);
if ($node) {
$node->make_active();
}
$PAGE->navbar->add(get_string('serviceusers', 'webservice'), new moodle_url('/' . $CFG->admin . '/webservice/service_users.php', array('id' => $serviceid)));
$PAGE->navbar->add(get_string('serviceusersettings', 'webservice'));
$formaction = new moodle_url('', array('id' => $serviceid, 'userid' => $userid));
$returnurl = new moodle_url('/' . $CFG->admin . '/webservice/service_users.php', array('id' => $serviceid));
$webservicemanager = new webservice();
$serviceuser = $webservicemanager->get_ws_authorised_user($serviceid, $userid);
$usersettingsform = new external_service_authorised_user_settings_form($formaction, $serviceuser);
$settingsformdata = $usersettingsform->get_data();
if ($usersettingsform->is_cancelled()) {
redirect($returnurl);
} else {
if (!empty($settingsformdata) and confirm_sesskey()) {
/// save user settings (administrator clicked on update button)
$settingsformdata = (object) $settingsformdata;
$serviceuserinfo = new stdClass();
$serviceuserinfo->id = $serviceuser->serviceuserid;
$serviceuserinfo->iprestriction = $settingsformdata->iprestriction;
$serviceuserinfo->validuntil = $settingsformdata->validuntil;
$webservicemanager->update_ws_authorised_user($serviceuserinfo);
//TODO: assign capability
开发者ID:covex-nn,项目名称:moodle,代码行数:31,代码来源:service_user_settings.php
示例7: optional_param
require_once $CFG->libdir . '/externallib.php';
$action = optional_param('action', '', PARAM_ACTION);
$tokenid = optional_param('tokenid', '', PARAM_SAFEDIR);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
admin_externalpage_setup('addwebservicetoken');
//Deactivate the second 'Manage token' navigation node, and use the main 'Manage token' navigation node
$node = $PAGE->settingsnav->find('addwebservicetoken', navigation_node::TYPE_SETTING);
$newnode = $PAGE->settingsnav->find('webservicetokens', navigation_node::TYPE_SETTING);
if ($node && $newnode) {
$node->display = false;
$newnode->make_active();
}
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
$tokenlisturl = new moodle_url("/" . $CFG->admin . "/settings.php", array('section' => 'webservicetokens'));
require_once $CFG->dirroot . "/webservice/lib.php";
$webservicemanager = new webservice();
switch ($action) {
case 'create':
$mform = new web_service_token_form(null, array('action' => 'create'));
$data = $mform->get_data();
if ($mform->is_cancelled()) {
redirect($tokenlisturl);
} else {
if ($data and confirm_sesskey()) {
ignore_user_abort(true);
//check the the user is allowed for the service
$selectedservice = $webservicemanager->get_external_service_by_id($data->service);
if ($selectedservice->restrictedusers) {
$restricteduser = $webservicemanager->get_ws_authorised_user($data->service, $data->user);
if (empty($restricteduser)) {
$allowuserurl = new moodle_url('/' . $CFG->admin . '/webservice/service_users.php', array('id' => $selectedservice->id));
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:tokens.php
示例8: init_service_class
/**
* Load the virtual class needed for the web service.
*
* Initialises the virtual class that contains the web service functions that the user is allowed to use.
* The web service function will be available if the user:
* - is validly registered in the external_services_users table.
* - has the required capability.
* - meets the IP restriction requirement.
* This virtual class can be used by web service protocols such as SOAP, especially when generating WSDL.
* NOTE: The implementation of this method has been mostly copied from webservice_zend_server::init_server_class().
*/
protected function init_service_class()
{
global $USER, $DB;
// Initialise service methods and struct classes.
$this->servicemethods = array();
$this->servicestructs = array();
$params = array();
$wscond1 = '';
$wscond2 = '';
if ($this->restricted_serviceid) {
$params = array('sid1' => $this->restricted_serviceid, 'sid2' => $this->restricted_serviceid);
$wscond1 = 'AND s.id = :sid1';
$wscond2 = 'AND s.id = :sid2';
}
$sql = "SELECT s.*, NULL AS iprestriction\n FROM {external_services} s\n JOIN {external_services_functions} sf ON (sf.externalserviceid = s.id AND s.restrictedusers = 0)\n WHERE s.enabled = 1 {$wscond1}\n\n UNION\n\n SELECT s.*, su.iprestriction\n FROM {external_services} s\n JOIN {external_services_functions} sf ON (sf.externalserviceid = s.id AND s.restrictedusers = 1)\n JOIN {external_services_users} su ON (su.externalserviceid = s.id AND su.userid = :userid)\n WHERE s.enabled = 1 AND (su.validuntil IS NULL OR su.validuntil < :now) {$wscond2}";
$params = array_merge($params, array('userid' => $USER->id, 'now' => time()));
$serviceids = array();
$remoteaddr = getremoteaddr();
// Query list of external services for the user.
$rs = $DB->get_recordset_sql($sql, $params);
// Check which service ID to include.
foreach ($rs as $service) {
if (isset($serviceids[$service->id])) {
continue;
// Service already added.
}
if ($service->requiredcapability and !has_capability($service->requiredcapability, $this->restricted_context)) {
continue;
// Cap required, sorry.
}
if ($service->iprestriction and !address_in_subnet($remoteaddr, $service->iprestriction)) {
continue;
// Wrong request source ip, sorry.
}
$serviceids[$service->id] = $service->id;
}
$rs->close();
// Generate the virtual class name.
$classname = 'webservices_virtual_class_000000';
while (class_exists($classname)) {
$classname++;
}
$this->serviceclass = $classname;
// Get the list of all available external functions.
$wsmanager = new webservice();
$functions = $wsmanager->get_external_functions($serviceids);
// Generate code for the virtual methods for this web service.
$methods = '';
foreach ($functions as $function) {
$methods .= $this->get_virtual_method_code($function);
}
$code = <<<EOD
/**
* Virtual class web services for user id {$USER->id} in context {$this->restricted_context->id}.
*/
class {$classname} {
{$methods}
}
EOD;
// Load the virtual class definition into memory.
eval($code);
}
开发者ID:rushi963,项目名称:moodle,代码行数:73,代码来源:lib.php
示例9: definition
function definition()
{
global $CFG;
$mform = $this->_form;
$data = $this->_customdata;
$mform->addElement('header', 'addfunction', get_string('addfunctions', 'webservice'));
require_once $CFG->dirroot . "/webservice/lib.php";
$webservicemanager = new webservice();
$functions = $webservicemanager->get_not_associated_external_functions($data['id']);
//we add the descriptions to the functions
foreach ($functions as $functionid => $functionname) {
//retrieve full function information (including the description)
$function = external_function_info($functionname);
$functions[$functionid] = $function->name . ':' . $function->description;
}
$mform->addElement('searchableselector', 'fids', get_string('name'), $functions, array('multiple'));
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'action');
$mform->setType('action', PARAM_ACTION);
$this->add_action_buttons(true, get_string('addfunctions', 'webservice'));
$this->set_data($data);
}
开发者ID:nickread,项目名称:moodle,代码行数:23,代码来源:forms.php
示例10: init_service_class
/**
* Load virtual class needed for Zend api
* @return void
*/
protected function init_service_class()
{
global $USER, $DB;
// first ofall get a complete list of services user is allowed to access
if ($this->restricted_serviceid) {
$params = array('sid1' => $this->restricted_serviceid, 'sid2' => $this->restricted_serviceid);
$wscond1 = 'AND s.id = :sid1';
$wscond2 = 'AND s.id = :sid2';
} else {
$params = array();
$wscond1 = '';
$wscond2 = '';
}
// now make sure the function is listed in at least one service user is allowed to use
// allow access only if:
// 1/ entry in the external_services_users table if required
// 2/ validuntil not reached
// 3/ has capability if specified in service desc
// 4/ iprestriction
$sql = "SELECT s.*, NULL AS iprestriction\n FROM {external_services} s\n JOIN {external_services_functions} sf ON (sf.externalserviceid = s.id AND s.restrictedusers = 0)\n WHERE s.enabled = 1 {$wscond1}\n\n UNION\n\n SELECT s.*, su.iprestriction\n FROM {external_services} s\n JOIN {external_services_functions} sf ON (sf.externalserviceid = s.id AND s.restrictedusers = 1)\n JOIN {external_services_users} su ON (su.externalserviceid = s.id AND su.userid = :userid)\n WHERE s.enabled = 1 AND su.validuntil IS NULL OR su.validuntil < :now {$wscond2}";
$params = array_merge($params, array('userid' => $USER->id, 'now' => time()));
$serviceids = array();
$rs = $DB->get_recordset_sql($sql, $params);
// now make sure user may access at least one service
$remoteaddr = getremoteaddr();
$allowed = false;
foreach ($rs as $service) {
if (isset($serviceids[$service->id])) {
continue;
}
if ($service->requiredcapability and !has_capability($service->requiredcapability, $this->restricted_context)) {
continue;
// cap required, sorry
}
if ($service->iprestriction and !address_in_subnet($remoteaddr, $service->iprestriction)) {
continue;
// wrong request source ip, sorry
}
$serviceids[$service->id] = $service->id;
}
$rs->close();
// now get the list of all functions
$wsmanager = new webservice();
$functions = $wsmanager->get_external_functions($serviceids);
// now make the virtual WS class with all the fuctions for this particular user
$methods = '';
foreach ($functions as $function) {
$methods .= $this->get_virtual_method_code($function);
}
// let's use unique class name, there might be problem in unit tests
$classname = 'webservices_virtual_class_000000';
while (class_exists($classname)) {
$classname++;
}
$code = '
/**
* Virtual class web services for user id ' . $USER->id . ' in context ' . $this->restricted_context->id . '.
*/
class ' . $classname . ' {
' . $methods . '
}
';
// load the virtual class definition into memory
eval($code);
$this->service_class = $classname;
}
开发者ID:vuchannguyen,项目名称:web,代码行数:70,代码来源:lib.php
示例11: definition
/**
* Define the form.
*/
public function definition()
{
global $USER, $CFG, $COURSE;
$mform = $this->_form;
$editoroptions = null;
$filemanageroptions = null;
if (!is_array($this->_customdata)) {
throw new coding_exception('invalid custom data for user_edit_form');
}
$editoroptions = $this->_customdata['editoroptions'];
$filemanageroptions = $this->_customdata['filemanageroptions'];
$user = $this->_customdata['user'];
$userid = $user->id;
// Accessibility: "Required" is bad legend text.
$strgeneral = get_string('general');
$strrequired = get_string('required');
// Add some extra hidden fields.
$mform->addElement('hidden', 'id');
$mform->setType('id', core_user::get_property_type('id'));
$mform->addElement('hidden', 'course', $COURSE->id);
$mform->setType('course', PARAM_INT);
// Print the required moodle fields first.
$mform->addElement('header', 'moodle', $strgeneral);
$auths = core_component::get_plugin_list('auth');
$enabled = get_string('pluginenabled', 'core_plugin');
$disabled = get_string('plugindisabled', 'core_plugin');
$authoptions = array($enabled => array(), $disabled => array());
$cannotchangepass = array();
$cannotchangeusername = array();
foreach ($auths as $auth => $unused) {
$authinst = get_auth_plugin($auth);
if (!$authinst->is_internal()) {
$cannotchangeusername[] = $auth;
}
$passwordurl = $authinst->change_password_url();
if (!($authinst->can_change_password() && empty($passwordurl))) {
if ($userid < 1 and $authinst->is_internal()) {
// This is unlikely but we can not create account without password
// when plugin uses passwords, we need to set it initially at least.
} else {
$cannotchangepass[] = $auth;
}
}
if (is_enabled_auth($auth)) {
$authoptions[$enabled][$auth] = get_string('pluginname', "auth_{$auth}");
} else {
$authoptions[$disabled][$auth] = get_string('pluginname', "auth_{$auth}");
}
}
$mform->addElement('text', 'username', get_string('username'), 'size="20"');
$mform->addHelpButton('username', 'username', 'auth');
$mform->setType('username', PARAM_RAW);
if ($userid !== -1) {
$mform->disabledIf('username', 'auth', 'in', $cannotchangeusername);
}
$mform->addElement('selectgroups', 'auth', get_string('chooseauthmethod', 'auth'), $authoptions);
$mform->addHelpButton('auth', 'chooseauthmethod', 'auth');
$mform->addElement('advcheckbox', 'suspended', get_string('suspended', 'auth'));
$mform->addHelpButton('suspended', 'suspended', 'auth');
$mform->addElement('checkbox', 'createpassword', get_string('createpassword', 'auth'));
$mform->disabledIf('createpassword', 'auth', 'in', $cannotchangepass);
if (!empty($CFG->passwordpolicy)) {
$mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
}
$mform->addElement('passwordunmask', 'newpassword', get_string('newpassword'), 'size="20"');
$mform->addHelpButton('newpassword', 'newpassword');
$mform->setType('newpassword', core_user::get_property_type('password'));
$mform->disabledIf('newpassword', 'createpassword', 'checked');
$mform->disabledIf('newpassword', 'auth', 'in', $cannotchangepass);
// Check if the user has active external tokens.
if ($userid and empty($CFG->passwordchangetokendeletion)) {
if ($tokens = webservice::get_active_tokens($userid)) {
$services = '';
foreach ($tokens as $token) {
$services .= format_string($token->servicename) . ',';
}
$services = get_string('userservices', 'webservice', rtrim($services, ','));
$mform->addElement('advcheckbox', 'signoutofotherservices', get_string('signoutofotherservices'), $services);
$mform->addHelpButton('signoutofotherservices', 'signoutofotherservices');
$mform->disabledIf('signoutofotherservices', 'newpassword', 'eq', '');
$mform->setDefault('signoutofotherservices', 1);
}
}
$mform->addElement('advcheckbox', 'preference_auth_forcepasswordchange', get_string('forcepasswordchange'));
$mform->addHelpButton('preference_auth_forcepasswordchange', 'forcepasswordchange');
$mform->disabledIf('preference_auth_forcepasswordchange', 'createpassword', 'checked');
// Shared fields.
useredit_shared_definition($mform, $editoroptions, $filemanageroptions, $user);
// Next the customisable profile fields.
profile_definition($mform, $userid);
if ($userid == -1) {
$btnstring = get_string('createuser');
} else {
$btnstring = get_string('updatemyprofile');
}
$this->add_action_buttons(false, $btnstring);
$this->set_data($user);
//.........这里部分代码省略.........
开发者ID:dg711,项目名称:moodle,代码行数:101,代码来源:editadvanced_form.php
示例12: require_login
require_login();
require_sesskey();
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
$PAGE->set_context($usercontext);
$PAGE->set_url('/user/managetoken.php');
$PAGE->set_title(get_string('securitykeys', 'webservice'));
$PAGE->set_heading(get_string('securitykeys', 'webservice'));
$PAGE->set_pagelayout('standard');
$rsstokenboxhtml = $webservicetokenboxhtml = '';
/// Manage user web service tokens
if (!is_siteadmin($USER->id) && !empty($CFG->enablewebservices) && has_capability('moodle/webservice:createtoken', $usercontext)) {
require $CFG->dirroot . '/webservice/lib.php';
$action = optional_param('action', '', PARAM_ACTION);
$tokenid = optional_param('tokenid', '', PARAM_SAFEDIR);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$webservice = new webservice();
//load the webservice library
$wsrenderer = $PAGE->get_renderer('core', 'webservice');
if ($action == 'resetwstoken') {
$token = $webservice->get_created_by_user_ws_token($USER->id, $tokenid);
/// Display confirmation page to Reset the token
if (!$confirm) {
$resetconfirmation = $wsrenderer->user_reset_token_confirmation($token);
} else {
/// Delete the token that need to be regenerated
$webservice->delete_user_ws_token($tokenid);
}
}
//no point creating the table is we're just displaying a confirmation screen
if (empty($resetconfirmation)) {
$webservice->generate_user_ws_tokens($USER->id);
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:managetoken.php
示例13: unregister_site
/**
* Unregister site
* @return bool 1 if unregistration was successfull
*/
public static function unregister_site()
{
global $DB, $CFG;
// Ensure the current user is allowed to run this function
$context = context_system::instance();
self::validate_context($context);
require_capability('local/hub:updateinfo', $context);
//clean params
$params = self::validate_parameters(self::unregister_site_parameters(), array());
//retieve the site communication
$token = optional_param('wstoken', '', PARAM_ALPHANUM);
$hub = new local_hub();
$communication = $hub->get_communication(WSSERVER, REGISTEREDSITE, null, $token);
//retrieve the site
$siteurl = $communication->remoteurl;
$site = $hub->get_site_by_url($siteurl);
//unregister the site
if (!empty($site)) {
$hub->unregister_site($site);
}
//delete the web service token
require_once $CFG->dirroot . '/webservice/lib.php';
$webservice_manager = new webservice();
$tokentodelete = $webservice_manager->get_user_ws_token($communication->token);
$webservice_manager->delete_user_ws_token($tokentodelete->id);
//delete the site communication
$hub->delete_communication($communication);
return true;
}
开发者ID:scyrma,项目名称:moodle-local_hub,代码行数:33,代码来源:externallib.php
示例14: init
<?php
include_once '../../includes/class.init.php';
include_once '../../includes/class.webservice.php';
$init = new init(0, 0, 0);
//echo json_encode($_GET);
//exit();
$data = file_get_contents("php://input");
$objData = json_decode($data);
$data = json_decode(json_encode($_GET), FALSE);
$data = $objData;
//Extra security due to public webservice without login
if ($data->method != "GET") {
echo json_encode(array("status" => array("code" => "403", "text" => "Alleen GET-acties zijn toegestaan")));
} else {
$webservice = new webservice($init);
echo json_encode($webservice->execute($data));
}
开发者ID:haverver,项目名称:SVN,代码行数:18,代码来源:webservice.php
示例15: required_param
require_once $CFG->dirroot . '/webservice/lib.php';
require_once 'forms.php';
$serviceid = required_param('id', PARAM_INT);
$functionid = optional_param('fid', 0, PARAM_INT);
$action = optional_param('action', '', PARAM_ACTION);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
admin_externalpage_setup('externalservicefunctions');
//define nav bar
$PAGE->set_url('/' . $CFG->admin . '/webservice/service_functions.php', array('id' => $serviceid));
$node = $PAGE->settingsnav->find('externalservices', navigation_node::TYPE_SETTING);
if ($node) {
$node->make_active();
}
$PAGE->navbar->add(get_string('functions', 'webservice'), new moodle_url('/' . $CFG->admin . '/webservice/service_functions.php', array('id' => $serviceid)));
$service = $DB->get_record('external_services', array('id' => $serviceid), '*', MUST_EXIST);
$webservicemanager = new webservice();
$renderer = $PAGE->get_renderer('core', 'webservice');
$functionlisturl = new moodle_url('/' . $CFG->admin . '/webservice/service_functions.php', array('id' => $serviceid));
// Add or Delete operations
switch ($action) {
case 'add':
$PAGE->navbar->add(get_string('addfunctions', 'webservice'));
/// Add function operation
if (confirm_sesskey() and $service and empty($service->component)) {
$mform = new external_service_functions_form(null, array('action' => 'add', 'id' => $service->id));
//cancelled add operation, redirect to function list page
if ($mform->is_cancelled()) {
redirect($functionlisturl);
}
//add the function to the service then redirect to function list page
if ($data = $mform->get_data()) {
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:service_functions.php
示例16: create_role
$roleid = create_role('Web Service', 'testtete', 'MDK: All permissions given by default.', '');
}
$context = context_system::instance();
set_role_contextlevels($roleid, array($context->contextlevel));
role_assign($roleid, $user->id, $context->id);
if (method_exists($context, 'get_capabilities')) {
$capabilities = $context->get_capabilities();
} else {
$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();
开发者ID:junpataleta,项目名称:mdk,代码行数:31,代码来源:webservices.php
示例17: the_following_tokens_exist
/**
* Creates tokens.
*
* @Given /^the following tokens exist:$/
* @param TableNode $data
*/
public function the_following_tokens_exist(TableNode $data)
{
global $DB, $CFG;
foreach ($data->getHash() as $datahash) {
$service = $this->get_service_id($datahash['service']);
$userid = $this->get_user_id($datahash['user']);
$validuntil = !empty($datahash['validuntil']) ? $datahash['validuntil'] : '';
$iprestriction = !empty($datahash['iprestriction']) ? $datahash['iprestriction'] : '';
require_once "{$CFG->dirroot}/webservice/lib.php";
$webservicemanager = new webservice();
// Check the the user is allowed for the service.
$selectedservice = $webservicemanager->get_external_service_by_id($service);
if ($selectedservice->restrictedusers) {
$restricteduser = $webservicemanager->get_ws_authorised_user($service, $userid);
if (empty($restricteduser)) {
throw new moodle_exception('usernotallowed', 'webservice');
}
}
// Check if the user is deleted. unconfirmed, suspended or guest.
$user = $DB->get_record('user', array('id' => $userid));
if ($user->id == $CFG->siteguest or $user->deleted or !$user->confirmed or $user->suspended) {
throw new moodle_exception('forbiddenwsuser', 'webservice');
}
external_generate_token(EXTERNAL_TOKEN_PERMANENT, $service, $userid, context_system::instance(), $validuntil, $iprestriction);
}
}
开发者ID:itamart,项目名称:moodle-block_mhaairs,代码行数:32,代码来源:behat_block_mhaairs.php
示例18: array
if (!$force) {
$function = 'hubdirectory_unregister_hub';
$params = array();
$serverurl = HUB_HUBDIRECTORYURL . "/local/hubdirectory/webservice/webservices.php";
require_once $CFG->dirroot . "/webservice/xmlrpc/lib.php";
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hubtodirectorycommunication->token);
try {
$result = $xmlrpcclient->call($function, $params);
} catch (Exception $e) {
$error = get_string('errorunregistration', 'local_hub', $e->getMessage());
}
}
if (empty($error)) {
if (!empty($directorytohubcommunication)) {
//delete the web service token
$webservice_manager = new webservice();
$tokentodelete = $webservice_manager->get_user_ws_token($directorytohubcommunication->token);
$webservice_manager->delete_user_ws_token($tokentodelete->id);
//delete the communication
$hub->delete_communication($directorytohubcommunication);
}
if (!empty($hubtodirectorycommunication)) {
$hub->delete_communication($hubtodirectorycommunication);
}
}
redirect(new moodle_url('/local/hub/admin/register.php', array('sesskey' => sesskey(), 'error' => $error)));
}
/////// UPDATE ACTION ////////
// update the hub registration (in fact it is a new registration)
$update = optional_param('update', 0, PARAM_INT);
if ($update && confirm_sesskey()) {
开发者ID:scyrma,项目名称:moodle-local_hub,代码行数:31,代码来源:register.php
示例19: load_function_info
/**
* Fetches the function description from database,
* verifies user is allowed to use this function and
* loads all paremeters and return descriptions.
* @return void
*/
protected function load_function_info()
{
global $USER;
if (empty($this->functionname)) {
throw new WebserviceInvalidParameterException(get_string('missingfuncname', 'webserivce'));
}
// function must exist
$function = webservice_function_info($this->functionname);
if (!$function) {
throw new WebserviceAccessException(get_string('accessextfunctionnotconf', 'auth.webservice'));
}
// first ofall get a complete list o
|
请发表评论