本文整理汇总了PHP中BasicAuth::enable方法的典型用法代码示例。如果您正苦于以下问题:PHP BasicAuth::enable方法的具体用法?PHP BasicAuth::enable怎么用?PHP BasicAuth::enable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BasicAuth
的用法示例。
在下文中一共展示了BasicAuth::enable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index($request)
{
// For 2.3 and 2.4 compatibility
$bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
BasicAuth::enable();
BasicAuth::requireLogin("CMS RSS feed access. Use your CMS login", "CMS_ACCESS_CMSMain");
$member = $this->getBasicAuthMember();
// Due to a bug in 2.3.0 we can't get the information that we need from $request
$params = Director::urlParams();
// Default value
if (!isset($params['Data']) || !$params['Data']) {
$params['Data'] = 'all';
}
switch ($params['Data']) {
case 'all':
$changes = $this->changes();
break;
case 'page':
if ((int) $params['PageID']) {
$changes = $this->changes("{$bt}SiteTree{$bt}.{$bt}ID{$bt} = " . (int) $params['PageID']);
} else {
return new HTTPResponse("<h1>Bad Page ID</h1><p>Bad page ID when getting RSS feed of changes to a page.</p>", 400);
}
break;
default:
user_error("CMSChangeTracker Data param value '{$params['Data']}' not implemented; this is probably due to a bad URL rule.", E_USER_ERROR);
}
$processedChanges = new DataObjectSet();
foreach ($changes as $change) {
if ($change->canEdit($member)) {
$author = DataObject::get_by_id("Member", $change->AuthorID);
$verbed = $change->Version == 1 ? "created" : "edited";
if ($author) {
$changeTitle = "'{$change->Title}' {$verbed} by {$author->FirstName} {$author->Surname}";
$changeAuthor = "{$author->FirstName} {$author->Surname}";
$firstParagraph = "{$author->FirstName} {$author->Surname} (<a href=\"mailto:{$author->Email}\">{$author->Email}</a>) has {$verbed} the '{$change->Title}' page.";
} else {
$changeTitle = "'{$change->Title}' {$verbed}";
$changeAuthor = "";
$firstParagraph = "The '{$change->Title}' page has been {$verbed}.";
}
$actionLinks = "";
$cmsLink = Director::absoluteURL("admin/show/{$change->ID}");
$actionLinks .= "<li><a href=\"{$cmsLink}\">Edit in CMS</a></li>\n";
$page = DataObject::get_by_id('SiteTree', $change->ID);
if ($page) {
$link = $page->AbsoluteLink();
$actionLinks .= "<li><a href=\"{$link}\">See the page on site</a></li>\n";
}
if ($change->Version > 1) {
$prevVersion = $change->Version - 1;
$diffLink = Director::absoluteURL("admin/compareversions/{$change->ID}/?From={$prevVersion}&To={$change->Version}");
$actionLinks .= "<li><a href=\"{$diffLink}\">See the changes in CMS</a></li>\n";
}
$changeDescription = <<<HTML
<p>{$firstParagraph}</p>
<h3>Actions and links</h3>
<ul>
\t{$actionLinks}
</ul>
HTML;
$processedChange = new CMSChangeTracker_Change(array("ChangeTitle" => $changeTitle, "Author" => $changeAuthor, "Content" => $changeDescription, "Link" => $change->Link() . "version/{$change->Version}"));
$processedChanges->push($processedChange);
}
}
$feed = new RSSFeed($processedChanges, Director::absoluteURL("admin/"), "SilverStripe Content Changes", "", "ChangeTitle");
return $feed->outputToBrowser();
}