本文整理汇总了PHP中app\Permission::sufficient方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::sufficient方法的具体用法?PHP Permission::sufficient怎么用?PHP Permission::sufficient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Permission
的用法示例。
在下文中一共展示了Permission::sufficient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
Response::success("You've already signed out");
}
CSRFProtection::protect();
if (isset($_REQUEST['unlink'])) {
try {
DeviantArt::request('https://www.deviantart.com/oauth2/revoke', null, array('token' => $currentUser->Session['access']));
} catch (CURLRequestException $e) {
Response::fail("Coulnd not revoke the site's access: {$e->getMessage()} (HTTP {$e->getCode()})");
}
}
if (isset($_REQUEST['unlink']) || isset($_REQUEST['everywhere'])) {
$col = 'user';
$val = $currentUser->id;
$username = Users::validateName('username', null, true);
if (isset($username)) {
if (!Permission::sufficient('staff') || isset($_REQUEST['unlink'])) {
Response::fail();
}
/** @var $TargetUser User */
$TargetUser = $Database->where('name', $username)->getOne('users', 'id,name');
if (empty($TargetUser)) {
Response::fail("Target user doesn't exist");
}
if ($TargetUser->id !== $currentUser->id) {
$val = $TargetUser->id;
} else {
unset($TargetUser);
}
}
} else {
$col = 'id';
示例2: catch
<?php
use App\CoreUtils;
use App\CSRFProtection;
use App\GlobalSettings;
use App\Permission;
use App\RegExp;
use App\Response;
/** @var $data string */
if (!Permission::sufficient('staff') || !POST_REQUEST) {
CoreUtils::notFound();
}
CSRFProtection::protect();
if (!preg_match(new RegExp('^([gs]et)/([a-z_]+)$'), CoreUtils::trim($data), $_match)) {
Response::fail('Setting key invalid');
}
$getting = $_match[1] === 'get';
$key = $_match[2];
$currvalue = GlobalSettings::get($key);
if ($getting) {
Response::done(array('value' => $currvalue));
}
if (!isset($_POST['value'])) {
Response::fail('Missing setting value');
}
try {
$newvalue = GlobalSettings::process($key);
} catch (Exception $e) {
Response::fail('Preference value error: ' . $e->getMessage());
}
if ($newvalue === $currvalue) {
示例3: empty
echo !empty($_GET['q']) ? " value='" . CoreUtils::aposEncode($_GET['q']) . "'" : '';
?>
title='Search'>
<button type='submit' class='blue'>Search</button>
<button type='button' class='green typcn typcn-flash sanic-button' title="I'm feeling lucky"></button>
<button type='reset' class='red typcn typcn-times' title='Clear'<?php
echo empty($_GET['q']) ? ' disabled' : '';
?>
></button>
</form>
<? }
else echo CoreUtils::notice('warn','<span class="typcn typcn-warning"></span> <strong>ElasticSearch server is down!</strong> Please <a class="send-feedback">let us know</a>, and in the meantime, use the <a class="btn darkblue typcn typcn-th-menu" href="/cg'.($EQG?'/eqg':'').'/full">Full List</a> to find appearances faster. Sorry for the inconvenience.',true); ?>
<?php
echo $Pagination->HTML . Appearances::getHTML($Ponies) . $Pagination->HTML;
?>
</div>
<? $export = array(
'Color' => $Color,
'color' => $color,
'EQG' => $EQG,
'AppearancePage' => false,
);
if (Permission::sufficient('staff'))
$export = array_merge($export, array(
'TAG_TYPES_ASSOC' => Tags::$TAG_TYPES_ASSOC,
'MAX_SIZE' => CoreUtils::getMaxUploadSize(),
'HEX_COLOR_PATTERN' => $HEX_COLOR_REGEX,
));
echo CoreUtils::exportVars($export); ?>
示例4: getCachedSubmission
/**
* Caches information about a deviation in the 'deviation_cache' table
* Returns null on failure
*
* @param string $ID
* @param null|string $type
* @param bool $mass
*
* @return array|null
*/
static function getCachedSubmission($ID, $type = 'fav.me', $mass = false)
{
global $Database, $FULLSIZE_MATCH_REGEX;
if ($type === 'sta.sh') {
$ID = CoreUtils::nomralizeStashID($ID);
}
$Deviation = $Database->where('id', $ID)->where('provider', $type)->getOne('deviation_cache');
$cacheExhausted = self::$_MASS_CACHE_USED > self::$_MASS_CACHE_LIMIT;
$cacheExpired = empty($Deviation['updated_on']) ? true : strtotime($Deviation['updated_on']) + Time::$IN_SECONDS['hour'] * 12 < time();
$lastRequestSuccessful = !self::$_CACHE_BAILOUT;
$localDataMissing = empty($Deviation);
$massCachingWithinLimit = $mass && !$cacheExhausted;
$notMassCachingAndCacheExpired = !$mass && $cacheExpired;
if ($lastRequestSuccessful && ($localDataMissing || ($massCachingWithinLimit && $cacheExpired || $notMassCachingAndCacheExpired))) {
try {
$json = self::oEmbed($ID, $type);
if (empty($json)) {
throw new \Exception();
}
} catch (\Exception $e) {
if (!empty($Deviation)) {
$Database->where('id', $Deviation['id'])->update('deviation_cache', array('updated_on' => date('c', time() + Time::$IN_SECONDS['minute'])));
}
$ErrorMSG = "Saving local data for {$ID}@{$type} failed: " . $e->getMessage();
if (!Permission::sufficient('developer')) {
trigger_error($ErrorMSG);
}
if (POST_REQUEST) {
Response::fail($ErrorMSG);
} else {
echo "<div class='notice fail'><label>da_cache_deviation({$ID}, {$type})</label><p>{$ErrorMSG}</p></div>";
}
self::$_CACHE_BAILOUT = true;
return $Deviation;
}
$insert = array('title' => preg_replace(new RegExp('\\\\\''), "'", $json['title']), 'preview' => URL::makeHttps($json['thumbnail_url']), 'fullsize' => URL::makeHttps(isset($json['fullsize_url']) ? $json['fullsize_url'] : $json['url']), 'provider' => $type, 'author' => $json['author_name'], 'updated_on' => date('c'));
if (!preg_match($FULLSIZE_MATCH_REGEX, $insert['fullsize'])) {
$fullsize_attempt = CoreUtils::getFullsizeURL($ID, $type);
if (is_string($fullsize_attempt)) {
$insert['fullsize'] = $fullsize_attempt;
}
}
if (empty($Deviation)) {
$Deviation = $Database->where('id', $ID)->where('provider', $type)->getOne('deviation_cache');
}
if (empty($Deviation)) {
$insert['id'] = $ID;
$Database->insert('deviation_cache', $insert);
} else {
$Database->where('id', $Deviation['id'])->update('deviation_cache', $insert);
$insert['id'] = $ID;
}
self::$_MASS_CACHE_USED++;
$Deviation = $insert;
} else {
if (!empty($Deviation['updated_on'])) {
$Deviation['updated_on'] = date('c', strtotime($Deviation['updated_on']));
if (self::$_CACHE_BAILOUT) {
$Database->where('id', $Deviation['id'])->update('deviation_cache', array('updated_on' => $Deviation['updated_on']));
}
}
}
return $Deviation;
}
示例5: Input
}
$url = (new Input('url', 'url', array(Input::IN_RANGE => [3, 255], Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => 'Link URL is missing', Input::ERROR_RANGE => 'Link URL must be between @min and @max characters long'))))->out();
if ($creating || $Link['url'] !== $url) {
$data['url'] = $url;
}
$title = (new Input('title', 'string', array(Input::IS_OPTIONAL => true, Input::IN_RANGE => [3, 255], Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_RANGE => 'Link title must be between @min and @max characters long'))))->out();
if (!isset($title)) {
$data['title'] = '';
} else {
if ($creating || $Link['title'] !== $title) {
CoreUtils::checkStringValidity($title, 'Link title', INVERSE_PRINTABLE_ASCII_PATTERN);
$data['title'] = $title;
}
}
$minrole = (new Input('minrole', function ($value) {
if (empty(Permission::ROLES_ASSOC[$value]) || !Permission::sufficient('user', $value)) {
Response::fail();
}
}, array(Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => 'Minumum role is missing', Input::ERROR_INVALID => 'Minumum role (@value) is invalid'))))->out();
if ($creating || $Link['minrole'] !== $minrole) {
$data['minrole'] = $minrole;
}
if (empty($data)) {
Response::fail('Nothing was changed');
}
$query = $creating ? $Database->insert('usefullinks', $data) : $Database->where('id', $Link['id'])->update('usefullinks', $data);
if (!$query) {
Response::dbError();
}
Response::done();
break;
示例6: getNavigationHTML
/**
* Returns the HTML code of the navigation in the header
*
* @param bool $disabled
*
* @return string
*/
static function getNavigationHTML($disabled = false)
{
if (!empty($GLOBALS['NavHTML'])) {
return $GLOBALS['NavHTML'];
}
global $do;
// Navigation items
if (!$disabled) {
$NavItems = array('latest' => array('/', 'Latest episode'), 'eps' => array('/episodes', 'Episodes'));
if ($do === 'episodes') {
global $Episodes, $Pagination;
if (isset($Episodes)) {
$NavItems['eps'][1] .= " - Page {$Pagination->page}";
}
}
global $CurrentEpisode;
if (($do === 'episode' || $do === 's' || $do === 'movie') && !empty($CurrentEpisode)) {
if ($CurrentEpisode->isMovie) {
$NavItems['eps'][1] = 'Movies';
}
if ($CurrentEpisode->isLatest()) {
$NavItems['latest'][0] = $_SERVER['REQUEST_URI'];
} else {
$NavItems['eps']['subitem'] = CoreUtils::cutoff($GLOBALS['heading'], Episodes::TITLE_CUTOFF);
}
}
global $Color, $EQG;
$NavItems['colorguide'] = array("/cg" . (!empty($EQG) ? '/eqg' : ''), (!empty($EQG) ? 'EQG ' : '') . "{$Color} Guide");
if ($do === 'colorguide') {
global $Tags, $Changes, $Ponies, $Pagination, $Appearance, $Map;
if (!empty($Appearance)) {
$NavItems['colorguide']['subitem'] = (isset($Map) ? "Sprite {$Color}s - " : '') . CoreUtils::escapeHTML($Appearance['label']);
} else {
if (isset($Ponies)) {
$NavItems['colorguide'][1] .= " - Page {$Pagination->page}";
} else {
if ($GLOBALS['data'] === 'full') {
$NavItems['colorguide']['subitem'] = 'Full List';
} else {
if (isset($Tags)) {
$pagePrefix = 'Tags';
} else {
if (isset($Changes)) {
$pagePrefix = "Major {$Color} Changes";
}
}
$NavItems['colorguide']['subitem'] = (isset($pagePrefix) ? "{$pagePrefix} - " : '') . "Page {$Pagination->page}";
}
}
}
}
if ($GLOBALS['signedIn']) {
$NavItems['u'] = array("/@{$GLOBALS['currentUser']->name}", 'Account');
}
if ($do === 'user' || Permission::sufficient('staff')) {
global $User, $sameUser;
$NavItems['users'] = array('/users', 'Users', Permission::sufficient('staff'));
if (!empty($User) && empty($sameUser)) {
$NavItems['users']['subitem'] = $User->name;
}
}
if (Permission::sufficient('staff')) {
$NavItems['admin'] = array('/admin', 'Admin');
global $task;
if ($task === 'logs') {
global $Pagination;
$NavItems['admin']['subitem'] = "Logs - Page {$Pagination->page}";
}
}
$NavItems[] = array('/about', 'About');
} else {
$NavItems = array(array(true, 'HTTP 503', false, 'subitem' => 'Service Temporarily Unavailable'));
}
$GLOBALS['NavHTML'] = '';
foreach ($NavItems as $item) {
$sublink = '';
if (isset($item['subitem'])) {
list($class, $sublink) = self::_processHeaderLink(array(true, $item['subitem']));
$sublink = " › {$sublink}";
$link = self::_processHeaderLink($item, HTML_ONLY);
} else {
if (isset($item[2]) && !$item[2]) {
continue;
} else {
list($class, $link) = self::_processHeaderLink($item);
}
}
$GLOBALS['NavHTML'] .= "<li{$class}>{$link}{$sublink}</li>";
}
$GLOBALS['NavHTML'] .= '<li><a href="http://mlp-vectorclub.deviantart.com/" target="_blank">MLP-VectorClub</a></li>';
return $GLOBALS['NavHTML'];
}
示例7: catch
<?php
use App\CoreUtils;
use App\CSRFProtection;
use App\Permission;
use App\RegExp;
use App\Response;
use App\UserPrefs;
/** @var $data string */
if (!Permission::sufficient('user') || !POST_REQUEST) {
CoreUtils::notFound();
}
CSRFProtection::protect();
if (!preg_match(new RegExp('^([gs]et)/([a-z_]+)$'), CoreUtils::trim($data), $_match)) {
Response::fail('Preference key invalid');
}
$getting = $_match[1] === 'get';
$key = $_match[2];
// TODO Support changing some preferences of other users by staff
$currvalue = UserPrefs::get($key);
if ($getting) {
Response::done(array('value' => $currvalue));
}
try {
$newvalue = UserPrefs::process($key);
} catch (Exception $e) {
Response::fail('Preference value error: ' . $e->getMessage());
}
if ($newvalue === $currvalue) {
Response::done(array('value' => $newvalue));
}
示例8: array
$SubMSG = "Check the name for typos and try again";
}
if (!isset($MSG)) {
$MSG = 'Local user data missing';
if (!$signedIn) {
$exists = 'exists on DeviantArt';
if (isset($un)) {
$exists = "<a href='http://{$un}.deviantart.com/'>{$exists}</a>";
}
$SubMSG = "If this user {$exists}, sign in to import their details.";
}
}
$canEdit = $sameUser = false;
} else {
$sameUser = $signedIn && $User->id === $currentUser->id;
$canEdit = !$sameUser && Permission::sufficient('staff') && Permission::sufficient($User->role);
$pagePath = "/@{$User->name}";
CoreUtils::fixPath($pagePath);
}
if (isset($MSG)) {
HTTP::statusCode(404);
} else {
if ($sameUser) {
$CurrentSession = $currentUser->Session;
$Database->where('id != ?', array($CurrentSession['id']));
}
$Sessions = $Database->where('user', $User->id)->orderBy('lastvisit', 'DESC')->get('sessions', null, 'id,created,lastvisit,platform,browser_name,browser_ver,user_agent,scope');
}
$settings = array('title' => !isset($MSG) ? ($sameUser ? 'Your' : CoreUtils::posess($User->name)) . ' ' . ($sameUser || $canEdit ? 'account' : 'profile') : 'Account', 'no-robots', 'do-css', 'js' => array('user'));
if ($canEdit) {
$settings['js'][] = 'user-manage';
示例9:
?>
items/page</p>
<p class='align-center links'>
<a class='btn darkblue typcn typcn-arrow-back' href="/cg">Back to <?php
echo $Color;
?>
Guide</a>
<a class='btn darkblue typcn typcn-warning' href="/cg/changes">Major Changes</a>
</p>
<?php
echo $Pagination->HTML;
?>
<table id="tags">
<thead><?php
$cspan = Permission::sufficient('staff') ? '" colspan="2' : '';
$refresher = Permission::sufficient('staff') ? " <button class='typcn typcn-arrow-sync refresh-all' title='Refresh usage data on this page'></button>" : '';
echo $thead = <<<HTML
\t\t\t<tr>
\t\t\t\t<th class="tid">ID</th>
\t\t\t\t<th class="name{$cspan}">Name</th>
\t\t\t\t<th class="title">Description</th>
\t\t\t\t<th class="type">Type</th>
\t\t\t\t<th class="uses">Uses{$refresher}</th>
\t\t\t</tr>
HTML;
?>
</thead>
<?php
echo Tags::getTagListHTML($Tags);
?>
<tfoot><?php
示例10: _getPostActions
/**
* Generate HTML for post action buttons
*
* @param Post $Post
* @param bool $isRequest
* @param false|string $view_only Only show the "View" button
* Contains HREF attribute of button if string
*
* @return string
*/
private static function _getPostActions(Post $Post, bool $isRequest, $view_only) : string
{
global $signedIn, $currentUser;
$By = $Post->Reserver;
$requestedByUser = $isRequest && $signedIn && $Post->requested_by === $currentUser->id;
$isNotReserved = empty($By);
$sameUser = $signedIn && $Post->reserved_by === $currentUser->id;
$CanEdit = empty($Post->lock) && Permission::sufficient('staff') || Permission::sufficient('developer') || $requestedByUser && $isNotReserved;
$Buttons = array();
$HTML = self::getPostReserveButton($Post, $By, $view_only);
if (!empty($Post->reserved_by)) {
$finished = !empty($Post->deviation_id);
$staffOrSameUser = $sameUser && Permission::sufficient('member') || Permission::sufficient('staff');
if (!$finished) {
if (!$sameUser && Permission::sufficient('member') && $Post->isTransferable() && !$Post->isOverdue()) {
$Buttons[] = array('user-add darkblue pls-transfer', 'Take on');
}
if ($staffOrSameUser) {
$Buttons[] = array('user-delete red cancel', 'Cancel Reservation');
$Buttons[] = array('attachment green finish', ($sameUser ? "I'm" : 'Mark as') . ' finished');
}
}
if ($finished && empty($Post->lock)) {
if (Permission::sufficient('staff')) {
$Buttons[] = array((empty($Post->preview) ? 'trash delete-only red' : 'media-eject orange') . ' unfinish', empty($Post->preview) ? 'Delete' : 'Unfinish');
}
if ($staffOrSameUser) {
$Buttons[] = array('tick green check', 'Check');
}
}
}
if (empty($Post->lock) && empty($Buttons) && (Permission::sufficient('staff') || $requestedByUser && $isNotReserved)) {
$Buttons[] = array('trash red delete', 'Delete');
}
if ($CanEdit) {
array_splice($Buttons, 0, 0, array(array('pencil darkblue edit', 'Edit')));
}
if ($Post->lock && Permission::sufficient('staff')) {
$Buttons[] = array('lock-open orange unlock', 'Unlock');
}
$HTML .= "<div class='actions'>";
if (!$view_only) {
$Buttons[] = array('export blue share', 'Share');
}
if (!empty($Buttons)) {
if ($view_only) {
$HTML .= "<div><a href='{$view_only}' class='btn blue typcn typcn-arrow-forward'>View</a></div>";
} else {
$regularButton = count($Buttons) < 3;
foreach ($Buttons as $b) {
$WriteOut = "'" . ($regularButton ? ">{$b[1]}" : " title='" . CoreUtils::aposEncode($b[1]) . "'>");
$HTML .= "<button class='typcn typcn-{$b[0]}{$WriteOut}</button>";
}
}
}
$HTML .= '</div>';
return $HTML;
}
示例11: if
?>
</tbody>
</table>
<? }
echo $Pagination;
$Movies = $Database->where('season', 0)->orderBy('episode','DESC')->get('episodes'); ?>
<h1>Movies</h1>
<? if (empty($Episodes)){ ?>
<p>There are no movies stored in the database</p>
<? }
if (Permission::sufficient('staff')) { ?>
<div class="actions">
<button id="add-movie" class="green typcn typcn-plus">Add Movie</button>
</div>
<? }
if (!empty($Episodes) || (empty($Episodes) && Permission::sufficient('staff'))){ ?>
<table id="movies">
<thead>
<tr>
<th><span class="mobile-hide">Overall </span>#</th>
<th>Title & Air Date</th>
</tr>
</thead>
<tbody><?php
echo Episodes::getTableTbody($Movies, true);
?>
</tbody>
</table>
<? } ?>
</div>
示例12: getUpdatesHTML
/**
* Returns the markup for the time of last update displayed under an appaerance
*
* @param int $PonyID
* @param bool $wrap
*
* @return string
*/
static function getUpdatesHTML($PonyID, $wrap = WRAP)
{
global $Database;
$update = Updates::get($PonyID, MOST_RECENT);
if (!empty($update)) {
$update = "Last updated " . Time::tag($update['timestamp']);
} else {
if (!Permission::sufficient('staff')) {
return '';
}
$update = '';
}
return $wrap ? "<div class='update'>{$update}</div>" : $update;
}
示例13: die
if (isset($_GET['error_description'])) {
$errdesc = $_GET['error_description'];
}
global $signedIn;
if ($signedIn) {
HTTP::redirect($_GET['state']);
}
Episodes::loadPage();
}
$currentUser = DeviantArt::getToken($_GET['code']);
$signedIn = !empty($currentUser);
if (isset($_GET['error'])) {
$err = $_GET['error'];
if (isset($_GET['error_description'])) {
$errdesc = $_GET['error_description'];
}
if ($err === 'user_banned') {
$errdesc .= "\n\nIf you'd like to appeal your ban, please <a href='http://mlp-vectorclub.deviantart.com/notes/'>send the group a note</a>.";
}
Episodes::loadPage();
}
if (preg_match(new RegExp('^[a-z\\d]+$', 'i'), $_GET['state'], $_match)) {
$confirm = str_replace('{{CODE}}', $_match[0], file_get_contents(INCPATH . 'views/loginConfrim.html'));
$confirm = str_replace('{{USERID}}', Permission::sufficient('developer') || UserPrefs::get('p_disable_ga') ? '' : $currentUser->id, $confirm);
die($confirm);
} else {
if (preg_match($REWRITE_REGEX, $_GET['state'])) {
HTTP::redirect($_GET['state']);
}
}
HTTP::redirect('/');
示例14: intval
<?php
use App\CoreUtils;
use App\Permission;
use App\RegExp;
/** @var $data string */
$AgentString = null;
if (is_numeric($data) && Permission::sufficient('developer')) {
$SessionID = intval($data, 10);
$Session = $Database->where('id', $SessionID)->getOne('sessions');
if (!empty($Session)) {
$AgentString = $Session['user_agent'];
}
}
$browser = CoreUtils::detectBrowser($AgentString);
if (empty($browser['platform'])) {
error_log('Could not find platform based on the following UA string: ' . preg_replace(new RegExp(INVERSE_PRINTABLE_ASCII_PATTERN), '', $AgentString));
}
CoreUtils::fixPath('/browser' . (!empty($Session) ? "/{$Session['id']}" : ''));
CoreUtils::loadPage(array('title' => 'Browser recognition test page', 'do-css', 'no-robots'));
示例15: array
}
$insert = array('preview' => $Image->preview, 'fullsize' => $Image->fullsize);
$season = Episodes::validateSeason(Episodes::ALLOW_MOVIES);
$episode = Episodes::validateEpisode();
$epdata = Episodes::getActual($season, $episode, Episodes::ALLOW_MOVIES);
if (empty($epdata)) {
Response::fail("The specified episode (S{$season}E{$episode}) does not exist");
}
$insert['season'] = $epdata->season;
$insert['episode'] = $epdata->episode;
$ByID = $currentUser->id;
if (Permission::sufficient('developer')) {
$username = Posts::validatePostAs();
if (isset($username)) {
$PostAs = Users::get($username, 'name', 'id,role');
if (empty($PostAs)) {
Response::fail('The user you wanted to post as does not exist');
}
if ($type === 'reservation' && !Permission::sufficient('member', $PostAs->role) && !isset($_POST['allow_nonmember'])) {
Response::fail('The user you wanted to post as is not a club member, do you want to post as them anyway?', array('canforce' => true));
}
$ByID = $PostAs->id;
}
}
$insert[$type === 'reservation' ? 'reserved_by' : 'requested_by'] = $ByID;
Posts::checkPostDetails($type, $insert);
$PostID = $Database->insert("{$type}s", $insert, 'id');
if (!$PostID) {
Response::dbError();
}
Response::done(array('id' => $PostID));