本文整理汇总了PHP中get_site函数的典型用法代码示例。如果您正苦于以下问题:PHP get_site函数的具体用法?PHP get_site怎么用?PHP get_site使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_site函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* Sets up and retrieves the API objects
*
**/
public function __construct($company, $user, $course, $invoice, $classroom, $license, $sender, $approveuser)
{
$this->company =& $company;
$this->user =& $user;
$this->invoice =& $invoice;
$this->classroom =& $classroom;
$this->license =& $license;
$this->sender =& $sender;
$this->approveuser =& $approveuser;
if (!isset($this->company)) {
if (isset($user->id) && !isset($user->profile)) {
profile_load_custom_fields($this->user);
}
if (isset($user->profile["company"])) {
$this->company = company::by_shortname($this->user->profile["company"])->get('*');
}
}
$this->course =& $course;
if (!empty($course->id)) {
$this->course->url = new moodle_url('/course/view.php', array('id' => $this->course->id));
}
if (!empty($user->id)) {
$this->url = new moodle_url('/user/profile.php', array('id' => $this->user->id));
}
$this->site = get_site();
}
示例2: html_header
function html_header($course, $wdir, $formfield = "")
{
global $CFG, $ME, $choose;
if (!($site = get_site())) {
error("Invalid site!");
}
$strfiles = get_string("coursefiles", 'wiki');
if ($wdir == "/") {
$fullnav = "{$strfiles}";
} else {
$dirs = explode("/", $wdir);
$numdirs = count($dirs);
$link = "";
$navigation = "";
for ($i = 1; $i < $numdirs - 1; $i++) {
$navigation .= " -> ";
$link .= "/" . urlencode($dirs[$i]);
$navigation .= "<a href=\"" . $ME . "?id={$course->id}&wdir={$link}&choose={$choose}\">" . $dirs[$i] . "</a>";
}
$fullnav = "<a href=\"" . $ME . "?id={$course->id}&wdir=/&choose={$choose}\">{$strfiles}</a> {$navigation} -> " . $dirs[$numdirs - 1];
}
if ($choose) {
print_header();
$chooseparts = explode('.', $choose);
?>
<script language="javascript" type="text/javascript">
<!--
function set_value(txt) {
opener.document.forms['<?php
echo $chooseparts[0] . "']." . $chooseparts[1];
?>
.value = txt;
window.close();
}
-->
</script>
<?php
$fullnav = str_replace('->', '»', "{$course->shortname} -> {$fullnav}");
echo '<div id="nav-bar">' . $fullnav . '</div>';
if ($course->id == $site->id) {
print_heading(get_string("publicsitefileswarning"), "center", 2);
}
} else {
if ($course->id == $site->id) {
print_header("{$course->shortname}: {$strfiles}", "{$course->fullname}", "<a href=\"../index.php?id={$course->id}\">" . get_string("modulenameplural", 'wiki') . "</a> -> {$fullnav}", $formfield);
print_heading(get_string("publicsitefileswarning"), "center", 2);
} else {
print_header("{$course->shortname}: {$strfiles}", "{$course->fullname}", "<a href=\"../../../course/view.php?id={$course->id}\">{$course->shortname}" . "</a> -> <a href=\"../index.php?id={$course->id}\">" . get_string("modulenameplural", 'wiki') . "</a> -> {$fullnav}", $formfield);
}
}
$prop = null;
$prop->border = "0";
$prop->spacing = "3";
$prop->padding = "3";
$prop->width = "640";
$prop->class = "boxaligncenter";
$prop->colspantd = "2";
wiki_table_start($prop);
}
示例3: xmldb_tool_bloglevelupgrade_install
function xmldb_tool_bloglevelupgrade_install()
{
global $CFG, $OUTPUT;
// this is a hack - admins were long ago instructed to upgrade blog levels,
// the problem is that blog is not supposed to be course level activity!!
if (!empty($CFG->bloglevel_upgrade_complete)) {
// somebody already upgrades, we do not need this any more
unset_config('bloglevel_upgrade_complete');
return;
}
if (!isset($CFG->bloglevel)) {
// fresh install?
return;
}
if ($CFG->bloglevel == BLOG_COURSE_LEVEL || $CFG->bloglevel == BLOG_GROUP_LEVEL) {
// inform admins that some settings require attention after upgrade
$site = get_site();
$a = new StdClass();
$a->sitename = $site->fullname;
$a->fixurl = "{$CFG->wwwroot}/{$CFG->admin}/tool/bloglevelupgrade/index.php";
$subject = get_string('bloglevelupgrade', 'tool_bloglevelupgrade');
$description = get_string('bloglevelupgradedescription', 'tool_bloglevelupgrade', $a);
// can not use messaging here because it is not configured yet!
upgrade_log(UPGRADE_LOG_NOTICE, null, $subject, $description);
set_config('tool_bloglevelupgrade_pending', 1);
echo $OUTPUT->notification($description);
}
}
示例4: test_get_site_in_switched_state_returns_switched_site
public function test_get_site_in_switched_state_returns_switched_site()
{
switch_to_blog(self::$site_ids['wordpress.org/foo/']);
$site = get_site();
restore_current_blog();
$this->assertEquals(self::$site_ids['wordpress.org/foo/'], $site->id);
}
示例5: test_filter
/**
* Tests that the filter applies the required changes.
*
* @return void
*/
public function test_filter()
{
$this->resetAfterTest(true);
$this->setAdminUser();
filter_manager::reset_caches();
filter_set_global_state('data', TEXTFILTER_ON);
$course1 = $this->getDataGenerator()->create_course();
$coursecontext1 = context_course::instance($course1->id);
$course2 = $this->getDataGenerator()->create_course();
$coursecontext2 = context_course::instance($course2->id);
$sitecontext = context_course::instance(SITEID);
$site = get_site();
$this->add_simple_database_instance($site, array('SiteEntry'));
$this->add_simple_database_instance($course1, array('CourseEntry'));
$html = '<p>I like CourseEntry and SiteEntry</p>';
// Testing at course level (both site and course).
$filtered = format_text($html, FORMAT_HTML, array('context' => $coursecontext1));
$this->assertRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
$this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
// Testing at site level (only site).
$filtered = format_text($html, FORMAT_HTML, array('context' => $sitecontext));
$this->assertNotRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
$this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
// Changing to another course to test the caches invalidation (only site).
$filtered = format_text($html, FORMAT_HTML, array('context' => $coursecontext2));
$this->assertNotRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
$this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
}
示例6: html_header
function html_header($course, $wdir, $formfield = "")
{
global $CFG, $ME, $choose;
if (!($site = get_site())) {
error("Invalid site!");
}
if ($course->id == $site->id) {
$strfiles = get_string("sitefiles");
} else {
$strfiles = get_string("files");
}
if ($wdir == "/") {
$fullnav = "{$strfiles}";
} else {
$dirs = explode("/", $wdir);
$numdirs = count($dirs);
$link = "";
$navigation = "";
for ($i = 1; $i < $numdirs - 1; $i++) {
$navigation .= " -> ";
$link .= "/" . urlencode($dirs[$i]);
$navigation .= "<a href=\"" . $ME . "?id={$course->id}&wdir={$link}&choose={$choose}\">" . $dirs[$i] . "</a>";
}
$fullnav = "<a href=\"" . $ME . "?id={$course->id}&wdir=/&choose={$choose}\">{$strfiles}</a> {$navigation} -> " . $dirs[$numdirs - 1];
}
if ($choose) {
print_header();
$chooseparts = explode('.', $choose);
?>
<script language="javascript" type="text/javascript">
<!--
function set_value(txt) {
opener.document.forms['<?php
echo $chooseparts[0] . "']." . $chooseparts[1];
?>
.value = txt;
window.close();
}
-->
</script>
<?php
$fullnav = str_replace('->', '»', "{$course->shortname} -> {$fullnav}");
echo '<div id="nav-bar">' . $fullnav . '</div>';
if ($course->id == $site->id) {
print_heading(get_string("publicsitefileswarning"), "center", 2);
}
} else {
if ($course->id == $site->id) {
print_header("{$course->shortname}: {$strfiles}", "{$course->fullname}", "<a href=\"../{$CFG->admin}/index.php\">" . get_string("administration") . "</a> -> {$fullnav}", $formfield);
print_heading(get_string("publicsitefileswarning"), "center", 2);
} else {
print_header("{$course->shortname}: {$strfiles}", "{$course->fullname}", "<a href=\"../course/view.php?id={$course->id}\">{$course->shortname}" . "</a> -> {$fullnav}", $formfield);
}
}
echo "<table border=\"0\" align=\"center\" cellspacing=\"3\" cellpadding=\"3\" width=\"640\">";
echo "<tr>";
echo "<td colspan=\"2\">";
}
示例7: config_read
function config_read($name)
{
$site = get_site();
if ($site->format == 'page') {
return 1;
} else {
return 0;
}
}
示例8: loginpage_hook
/**
* Authentication choice (CAS or other)
* Redirection to the CAS form or to login/index.php
* for other authentication
*/
function loginpage_hook()
{
global $frm;
global $CFG;
global $SESSION, $OUTPUT, $PAGE;
$site = get_site();
$CASform = get_string('CASform', 'auth_cas');
$username = optional_param('username', '', PARAM_RAW);
if (!empty($username)) {
if (isset($SESSION->wantsurl) && (strstr($SESSION->wantsurl, 'ticket') || strstr($SESSION->wantsurl, 'NOCAS'))) {
unset($SESSION->wantsurl);
}
return;
}
// Return if CAS enabled and settings not specified yet
if (empty($this->config->hostname)) {
return;
}
// Connection to CAS server
$this->connectCAS();
if (phpCAS::checkAuthentication()) {
$frm = new stdClass();
$frm->username = phpCAS::getUser();
$frm->password = 'passwdCas';
return;
}
if (isset($_GET['loginguest']) && $_GET['loginguest'] == true) {
$frm = new stdClass();
$frm->username = 'guest';
$frm->password = 'guest';
return;
}
if ($this->config->multiauth) {
$authCAS = optional_param('authCAS', '', PARAM_RAW);
if ($authCAS == 'NOCAS') {
return;
}
// Show authentication form for multi-authentication
// test pgtIou parameter for proxy mode (https connection
// in background from CAS server to the php server)
if ($authCAS != 'CAS' && !isset($_GET['pgtIou'])) {
$PAGE->set_url('/auth/cas/auth.php');
$PAGE->navbar->add($CASform);
$PAGE->set_title("{$site->fullname}: {$CASform}");
$PAGE->set_heading($site->fullname);
echo $OUTPUT->header();
include $CFG->dirroot . '/auth/cas/cas_form.html';
echo $OUTPUT->footer();
exit;
}
}
// Force CAS authentication (if needed).
if (!phpCAS::isAuthenticated()) {
phpCAS::setLang($this->config->language);
phpCAS::forceAuthentication();
}
}
示例9: set_parameters
/**
* Sets the parameters property of the extended class
*
* Sets the parameters property of the extended file resource class
*
* @param USER global object
* @param CFG global object
*/
function set_parameters()
{
global $USER, $CFG;
$site = get_site();
$this->parameters = array('label2' => array('langstr' => "", 'value' => '/optgroup'), 'label3' => array('langstr' => get_string('course'), 'value' => 'optgroup'), 'courseid' => array('langstr' => 'id', 'value' => $this->course->id), 'coursefullname' => array('langstr' => get_string('fullname'), 'value' => $this->course->fullname), 'courseshortname' => array('langstr' => get_string('shortname'), 'value' => $this->course->shortname), 'courseidnumber' => array('langstr' => get_string('idnumbercourse'), 'value' => $this->course->idnumber), 'coursesummary' => array('langstr' => get_string('summary'), 'value' => $this->course->summary), 'courseformat' => array('langstr' => get_string('format'), 'value' => $this->course->format), 'courseteacher' => array('langstr' => get_string('wordforteacher'), 'value' => $this->course->teacher), 'courseteachers' => array('langstr' => get_string('wordforteachers'), 'value' => $this->course->teachers), 'coursestudent' => array('langstr' => get_string('wordforstudent'), 'value' => $this->course->student), 'coursestudents' => array('langstr' => get_string('wordforstudents'), 'value' => $this->course->students), 'label4' => array('langstr' => "", 'value' => '/optgroup'), 'label5' => array('langstr' => get_string('miscellaneous'), 'value' => 'optgroup'), 'lang' => array('langstr' => get_string('preferredlanguage'), 'value' => current_language()), 'sitename' => array('langstr' => get_string('fullsitename'), 'value' => format_string($site->fullname)), 'serverurl' => array('langstr' => get_string('serverurl', 'resource', $CFG), 'value' => $CFG->wwwroot), 'currenttime' => array('langstr' => get_string('time'), 'value' => time()), 'encryptedcode' => array('langstr' => get_string('encryptedcode'), 'value' => $this->set_encrypted_parameter()), 'label6' => array('langstr' => "", 'value' => '/optgroup'));
if (!empty($USER->id)) {
$userparameters = array('label1' => array('langstr' => get_string('user'), 'value' => 'optgroup'), 'userid' => array('langstr' => 'id', 'value' => $USER->id), 'userusername' => array('langstr' => get_string('username'), 'value' => $USER->username), 'useridnumber' => array('langstr' => get_string('idnumber'), 'value' => $USER->idnumber), 'userfirstname' => array('langstr' => get_string('firstname'), 'value' => $USER->firstname), 'userlastname' => array('langstr' => get_string('lastname'), 'value' => $USER->lastname), 'userfullname' => array('langstr' => get_string('fullname'), 'value' => fullname($USER)), 'useremail' => array('langstr' => get_string('email'), 'value' => $USER->email), 'usericq' => array('langstr' => get_string('icqnumber'), 'value' => $USER->icq), 'userphone1' => array('langstr' => get_string('phone') . ' 1', 'value' => $USER->phone1), 'userphone2' => array('langstr' => get_string('phone') . ' 2', 'value' => $USER->phone2), 'userinstitution' => array('langstr' => get_string('institution'), 'value' => $USER->institution), 'userdepartment' => array('langstr' => get_string('department'), 'value' => $USER->department), 'useraddress' => array('langstr' => get_string('address'), 'value' => $USER->address), 'usercity' => array('langstr' => get_string('city'), 'value' => $USER->city), 'usertimezone' => array('langstr' => get_string('timezone'), 'value' => get_user_timezone_offset()), 'userurl' => array('langstr' => get_string('webpage'), 'value' => $USER->url));
$this->parameters = $userparameters + $this->parameters;
}
}
示例10: saml_error
function saml_error($err, $urltogo = false, $logfile = '')
{
global $CFG, $PAGE, $OUTPUT;
if (!isset($CFG->debugdisplay) || !$CFG->debugdisplay) {
$debug = false;
} else {
$debug = true;
}
if ($urltogo != false) {
$site = get_site();
if ($site === false || !isset($site->fullname)) {
$site_name = '';
} else {
$site_name = $site->fullname;
}
$PAGE->set_title($site_name . ':Error SAML Login');
echo $OUTPUT->header();
echo '<div style="margin:20px;font-weight: bold; color: red;">';
}
if (is_array($err)) {
foreach ($err as $key => $messages) {
if (!is_array($messages)) {
if ($urltogo != false && ($debug || $key == 'course_enrollment')) {
echo $messages;
}
$msg = 'Moodle SAML module: ' . $key . ': ' . $messages;
log_saml_error($msg, $logfile);
} else {
foreach ($messages as $message) {
if ($urltogo != false && ($debug || $key == 'course_enrollment')) {
echo $message . '<br>';
}
$msg = 'Moodle SAML module: ' . $key . ': ' . $message;
log_saml_error($msg, $logfile);
}
}
echo '<br>';
}
} else {
if ($urltogo != false) {
echo $err;
}
$msg = 'Moodle SAML module: login: ' . $err;
log_saml_error($msg, $logfile);
}
if ($urltogo != false) {
echo '</div>';
$OUTPUT->continue_button($urltogo);
if ($debug) {
print_string("auth_saml_disable_debugdisplay", "auth_saml");
}
$OUTPUT->footer();
exit;
}
}
示例11: send_message
/**
* Processes the message and sends a notification via airnotifier
*
* @param stdClass $eventdata the event data submitted by the message sender plus $eventdata->savedmessageid
* @return true if ok, false if error
*/
public function send_message($eventdata)
{
global $CFG;
require_once $CFG->libdir . '/filelib.php';
if (!empty($CFG->noemailever)) {
// Hidden setting for development sites, set in config.php if needed.
debugging('$CFG->noemailever active, no airnotifier message sent.', DEBUG_MINIMAL);
return true;
}
// Skip any messaging suspended and deleted users.
if ($eventdata->userto->auth === 'nologin' or $eventdata->userto->suspended or $eventdata->userto->deleted) {
return true;
}
// Site id, to map with Moodle Mobile stored sites.
$siteid = md5($CFG->wwwroot . $eventdata->userto->username);
// Airnotifier can handle custom requests using processors (that are Airnotifier plugins).
// In the extra parameter we indicate which processor to use and also additional data to be handled by the processor.
// Here we clone the eventdata object because will be deleting/adding attributes.
$extra = clone $eventdata;
// Delete attributes that may content private information.
if (!empty($eventdata->userfrom)) {
$extra->userfromid = $eventdata->userfrom->id;
$extra->userfromfullname = fullname($eventdata->userfrom);
unset($extra->userfrom);
}
$extra->usertoid = $eventdata->userto->id;
unset($extra->userto);
$extra->processor = 'moodle';
$extra->site = $siteid;
$extra->date = !empty($eventdata->timecreated) ? $eventdata->timecreated : time();
$extra->notification = !empty($eventdata->notification) ? 1 : 0;
// Site name.
$site = get_site();
$extra->sitefullname = format_string($site->fullname);
$extra->siteshortname = format_string($site->shortname);
// We are sending to message to all devices.
$airnotifiermanager = new message_airnotifier_manager();
$devicetokens = $airnotifiermanager->get_user_devices($CFG->airnotifiermobileappname, $eventdata->userto->id);
foreach ($devicetokens as $devicetoken) {
if (!$devicetoken->enable) {
continue;
}
// Sending the message to the device.
$serverurl = $CFG->airnotifierurl . ':' . $CFG->airnotifierport . '/api/v2/push/';
$header = array('Accept: application/json', 'X-AN-APP-NAME: ' . $CFG->airnotifierappname, 'X-AN-APP-KEY: ' . $CFG->airnotifieraccesskey);
$curl = new curl();
$curl->setHeader($header);
$params = array('device' => $devicetoken->platform, 'token' => $devicetoken->pushid, 'extra' => $extra);
// JSON POST raw body request.
$resp = $curl->post($serverurl, json_encode($params));
}
return true;
}
示例12: print_header
function print_header($title)
{
global $USER, $CFG;
$replacements = array('%fullname%' => get_string('mycollaboration', 'local'));
foreach ($replacements as $search => $replace) {
$title = str_replace($search, $replace, $title);
}
$site = get_site();
$nav = get_string('mycollaboration', 'local');
$header = $site->shortname . ': ' . $nav;
$navlinks = array(array('name' => $nav, 'link' => '', 'type' => 'misc'));
$navigation = build_navigation($navlinks);
print_header($title, $header, $navigation, '', '', true);
}
示例13: print_header
function print_header($title)
{
global $USER;
$replacements = array('%fullname%' => get_string('mymoodle', 'my'));
foreach ($replacements as $search => $replace) {
$title = str_replace($search, $replace, $title);
}
$site = get_site();
$button = update_mymoodle_icon($USER->id);
$nav = get_string('mymoodle', 'my');
$header = $site->shortname . ': ' . $nav;
$loggedinas = user_login_string($site);
print_header($title, $header, $nav, '', '', true, $button, $loggedinas);
}
示例14: begin
public function begin()
{
global $CFG, $USER;
$txnId = time() . $this->_transaction->get_id();
$site = get_site();
// create the "Generate Request" XML message
$xmlrequest = sprintf("<GenerateRequest>\n \t<PxPayUserId>%s</PxPayUserId>\n \t<PxPayKey>%s</PxPayKey>\n \t<AmountInput>%.2f</AmountInput>\n \t<CurrencyInput>%s</CurrencyInput>\n \t<MerchantReference>%s</MerchantReference>\n \t<EmailAddress>%s</EmailAddress>\n \t<TxnData1>%d</TxnData1>\n \t<TxnData2>%s</TxnData2>\n \t<TxnData3>%s</TxnData3>\n \t<TxnType>Purchase</TxnType>\n \t<TxnId>%d</TxnId>\n \t<BillingId></BillingId>\n \t<EnableAddBillCard>0</EnableAddBillCard>\n \t<UrlSuccess>%s</UrlSuccess>\n \t<UrlFail>%s</UrlFail>\n \t<Opt></Opt>\n </GenerateRequest>", clean_param(get_config('local_moodec', 'payment_dps_userid'), PARAM_CLEAN), clean_param(get_config('local_moodec', 'payment_dps_key'), PARAM_CLEAN), clean_param($this->_transaction->get_cost(), PARAM_CLEAN), clean_param(get_config('local_moodec', 'currency'), PARAM_CLEAN), clean_param('Transaction #' . $this->_transaction->get_id(), PARAM_CLEAN), clean_param($USER->email, PARAM_CLEAN), clean_param($txnId, PARAM_CLEAN), clean_param(substr($site->shortname, 0, 50), PARAM_CLEAN), clean_param(substr("{$USER->lastname}, {$USER->firstname}", 0, 50), PARAM_CLEAN), clean_param(time() . $this->_transaction->get_id(), PARAM_CLEAN), new moodle_url($CFG->wwwroot . '/local/moodec/payment/dps/success.php'), new moodle_url($CFG->wwwroot . '/local/moodec/payment/dps/fail.php'));
// Query DPS with the xml request
$result = $this->query($xmlrequest);
// Set the transaction gateway and status
$this->_transaction->set_gateway(MOODEC_GATEWAY_DPS);
$this->_transaction->set_txn_id($txnId);
$this->_transaction->pending();
// Return the DOM formatted result of the request
return $this->get_dom($result);
}
示例15: find_site
/**
* Find site by domain.
*
* @param string $domain The domain to look for.
*
* @return \WP_Site|null
*/
protected function find_site($domain)
{
if (empty($domain) || !is_string($domain)) {
return;
}
// Get site by domain.
if ($site = get_site_by_path($domain, '')) {
return $site instanceof WP_Site ? $site : new WP_Site($site);
}
// Redirect to main site if no site is found.
if ($site = get_site(1)) {
$scheme = is_ssl() ? 'https' : 'http';
$uri = sprintf('%s://%s', $scheme, $site->domain);
header('Location: ' . $uri);
die;
}
}