本文整理汇总了PHP中webservice::get_user_ws_token方法的典型用法代码示例。如果您正苦于以下问题:PHP webservice::get_user_ws_token方法的具体用法?PHP webservice::get_user_ws_token怎么用?PHP webservice::get_user_ws_token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webservice
的用法示例。
在下文中一共展示了webservice::get_user_ws_token方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: webservice
function delete_site($id, $unregistercourses = false)
{
global $CFG;
require_once $CFG->dirroot . '/local/hub/locallib.php';
$sitetodelete = $this->get_site($id);
//unregister the courses first
if (!empty($unregistercourses)) {
$this->delete_courses($sitetodelete->id);
}
$sitetohubcommunication = $this->get_communication(WSSERVER, REGISTEREDSITE, $sitetodelete->url);
if (!empty($sitetohubcommunication)) {
//delete the token for this site
require_once $CFG->dirroot . '/webservice/lib.php';
$webservice_manager = new webservice();
$tokentodelete = $webservice_manager->get_user_ws_token($sitetohubcommunication->token);
$webservice_manager->delete_user_ws_token($tokentodelete->id);
//delete the communications to this hub
$this->delete_communication($sitetohubcommunication);
}
// Send email to the site administrator.
$contactuser = local_hub_create_contact_user($sitetodelete->contactemail ? $sitetodelete->contactemail : $CFG->noreplyaddress, $sitetodelete->contactname ? $sitetodelete->contactname : get_string('noreplyname'));
$emailinfo = new stdClass();
$hubinfo = $this->get_info();
$emailinfo->hubname = $hubinfo['name'];
$emailinfo->huburl = $hubinfo['url'];
$emailinfo->sitename = $sitetodelete->name;
$emailinfo->siteurl = $sitetodelete->url;
$emailinfo->unregisterpagelink = $sitetodelete->url . '/admin/registration/index.php?huburl=' . $hubinfo['url'] . '&force=1&unregistration=1';
email_to_user($contactuser, get_admin(), get_string('emailtitlesitedeleted', 'local_hub', $emailinfo), get_string('emailmessagesitedeleted', 'local_hub', $emailinfo));
$this->unregister_site($sitetodelete);
}
示例2: array
$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()) {
//update the registration
示例3: 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;
}