本文整理汇总了PHP中priv_check函数的典型用法代码示例。如果您正苦于以下问题:PHP priv_check函数的具体用法?PHP priv_check怎么用?PHP priv_check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了priv_check函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transform
public function transform(BeatmapDiscussionPost $post)
{
if (!priv_check('BeatmapDiscussionPostShow', $post)->can()) {
return [];
}
return ['id' => $post->id, 'beatmap_discussion_id' => $post->beatmap_discussion_id, 'user_id' => $post->user_id, 'last_editor_id' => presence($post->last_editor_id, $post->user_id), 'deleted_by_id' => $post->deleted_by_id, 'system' => $post->system, 'message' => $post->message, 'created_at' => json_time($post->created_at), 'updated_at' => json_time($post->updated_at), 'deleted_at' => json_time($post->deleted_at)];
}
示例2: updatePage
public function updatePage()
{
$user = Auth::user();
priv_check('UserPageEdit', $user)->ensureCan();
$user = $user->updatePage(Request::input('body'));
return ['html' => $user->userPage->bodyHTML];
}
示例3: update
public function update($id)
{
$post = BeatmapDiscussionPost::findOrFail($id);
priv_check('BeatmapDiscussionPostEdit', $post)->ensureCan();
$post->update($this->postParams($post->beatmapDiscussion, false));
return ['beatmapset_discussion' => $post->beatmapsetDiscussion->defaultJson()];
}
示例4: destroy
public function destroy($id)
{
$user = Auth::user();
$entry = UserContestEntry::where(['user_id' => $user->user_id])->findOrFail($id);
$contest = Contest::findOrFail($entry->contest_id);
priv_check('ContestEntryDestroy', $entry)->ensureCan();
$entry->deleteWithFile();
return $contest->userEntries($user);
}
示例5: show
public function show($id)
{
$forum = Forum::with('subForums')->findOrFail($id);
$sort = explode('_', Request::input('sort'));
$withReplies = Request::input('with_replies', '');
priv_check('ForumView', $forum)->ensureCan();
$cover = json_item($forum->cover()->firstOrNew([]), new ForumCoverTransformer());
$pinnedTopics = $forum->topics()->pinned()->orderBy('topic_type', 'desc')->recent()->get();
$topics = $forum->topics()->normal()->recent(compact('sort', 'withReplies'))->paginate(15);
$topicReadStatus = TopicTrack::readStatus(Auth::user(), $pinnedTopics, $topics);
return view('forum.forums.show', compact('forum', 'topics', 'pinnedTopics', 'topicReadStatus', 'cover'));
}
示例6: vote
public function vote($id)
{
$discussion = BeatmapDiscussion::findOrFail($id);
priv_check('BeatmapDiscussionVote', $discussion)->ensureCan();
$params = get_params(Request::all(), 'beatmap_discussion_vote', ['score:int']);
$params['user_id'] = Auth::user()->user_id;
if ($discussion->vote($params)) {
return $discussion->beatmapsetDiscussion->defaultJson(Auth::user());
} else {
return error_popup(trans('beatmaps.discussion-votes.update.error'));
}
}
示例7: show
public function show($id)
{
$user = User::lookup($id, null, true);
if ($user === null || !priv_check('UserShow', $user)->can()) {
abort(404);
}
if ((string) $user->user_id !== $id) {
return ujs_redirect(route('users.show', $user));
}
$achievements = json_collection(Achievement::achievable()->orderBy('grouping')->orderBy('ordering')->orderBy('progression')->get(), new AchievementTransformer());
$userArray = json_item($user, new UserTransformer(), ['userAchievements', 'allRankHistories', 'allScores', 'allScoresBest', 'allScoresFirst', 'allStatistics', 'beatmapPlaycounts', 'page', 'recentActivities', 'recentlyReceivedKudosu', 'rankedAndApprovedBeatmapsets.beatmaps', 'favouriteBeatmapsets.beatmaps']);
return view('users.show', compact('user', 'userArray', 'achievements'));
}
示例8: update
public function update($id)
{
$cover = TopicCover::findOrFail($id);
priv_check('ForumTopicCoverEdit', $cover)->ensureCan();
if (Request::hasFile('cover_file') === true) {
try {
$cover = $cover->updateFile(Request::file('cover_file')->getRealPath(), Auth::user());
} catch (ImageProcessorException $e) {
return error_popup($e->getMessage());
}
}
return json_item($cover, new TopicCoverTransformer());
}
示例9: postMessage
public function postMessage()
{
switch (Request::input('target_type')) {
case 'channel':
$target = Channel::findOrFail(Request::input('channel_id'));
break;
case 'user':
$target = User::findOrFail(Request::input('user_id'));
break;
default:
abort(422);
}
priv_check('ChatMessageSend', $target)->ensureCan();
$target->sendMessage(Auth::user(), Request::input('message'));
return json_encode('ok');
}
示例10: includeUsers
public function includeUsers(BeatmapsetDiscussion $discussion)
{
$userIds = [$discussion->beatmapset->user_id];
foreach ($discussion->beatmapDiscussions as $beatmapDiscussion) {
if (!priv_check('BeatmapDiscussionShow', $beatmapDiscussion)->can()) {
continue;
}
$userIds[] = $beatmapDiscussion->user_id;
foreach ($beatmapDiscussion->beatmapDiscussionPosts as $post) {
if (!priv_check('BeatmapDiscussionPostShow', $post)->can()) {
continue;
}
$userIds[] = $post->user_id;
$userIds[] = $post->last_editor_id;
$userIds[] = $post->deleted_by;
}
}
$userIds = array_unique($userIds);
$users = User::whereIn('user_id', $userIds)->get();
return $this->collection($users, new UserCompactTransformer());
}
示例11: includeCurrentUserAttributes
public function includeCurrentUserAttributes(BeatmapDiscussion $discussion)
{
if (!priv_check('BeatmapDiscussionShow', $discussion)->can()) {
return;
}
$currentUser = Auth::user();
if ($currentUser === null) {
return;
}
$score = 0;
// This assumes beatmapDiscussionVotes are already preloaded and
// thus will save one query.
foreach ($discussion->beatmapDiscussionVotes as $vote) {
if ($vote->user_id === $currentUser->user_id) {
$score = $vote->score;
break;
}
}
return $this->item($discussion, function ($discussion) use($score) {
return ['vote_score' => $score];
});
}
示例12: eCRC
if ($HTTP_GET_VARS["error"] == 1) {
$ausgaben["form_error"] = "#(error1)";
}
} else {
$ausgaben["form_error"] = "";
}
// navigation erstellen
$ausgaben["renumber"] = "<a href=\"" . $cfg["menued"]["basis"] . "/sort,all,nop,0.html\">#(renumber)</a>";
$check_parameter = $environment["parameter"][1];
if (!$environment["parameter"][1]) {
$check_parameter = 0;
}
if (priv_check(make_ebene($check_parameter), $cfg["menued"]["modify"]["add"][2], $specialvars["dyndb"])) {
$ausgaben["new"] .= "<a href=\"" . $cfg["menued"]["basis"] . "/add," . $environment["parameter"][1] . "," . $array["refid"] . ".html\">g(new)</a>";
$ausgaben["root"] = "";
if ($specialvars["security"]["new"] == -1 && priv_check("/", $cfg["menued"]["modify"]["rights"][2], $specialvars["dyndb"]) && ($environment["parameter"][1] == "" || $environment["parameter"][1] == "0")) {
$ausgaben["root"] = "<ul class=\"menued\"><li><a style=\"float:right\" href=\"" . $pathvars["virtual"] . "/" . $cfg["menued"]["subdir"] . "/righted/edit,0.html\"><img style=\"float:right\" src=\"/images/default/rights.png\" alt=\"righted\" title=\"RIGHTED\" width=\"24\" height=\"18\"></img></a><span>/</span></li></ul>";
}
} else {
$ausgaben["new"] = "";
$ausgaben["root"] = "";
}
// was anzeigen
$mapping["main"] = eCRC($environment["ebene"]) . ".list";
$mapping["navi"] = "leer";
// unzugaengliche #(marken) sichtbar machen
if (isset($HTTP_GET_VARS["edit"])) {
$ausgaben["inaccessible"] = "inaccessible values:<br />";
$ausgaben["inaccessible"] .= "# (error1) #(error1)<br />";
$ausgaben["inaccessible"] .= "# (disabled) #(disabled)<br />";
$ausgaben["inaccessible"] .= "# (enabled) #(enabled)<br />";
示例13: promote
public function promote()
{
priv_check('LivestreamPromote')->ensureCan();
LivestreamCollection::promote(Request::input('id'));
return js_view('layout.ujs-reload');
}
示例14: watch
public function watch($id)
{
$topic = Topic::findOrFail($id);
$state = get_bool(Request::input('watch'));
$privName = 'ForumTopicWatch' . ($state ? 'Add' : 'Remove');
$type = 'watch';
priv_check($privName, $topic)->ensureCan();
TopicWatch::toggle($topic, Auth::user(), $state);
switch (Request::input('page')) {
case 'manage':
$topics = Topic::watchedByUser(Auth::user())->get();
$topicReadStatus = TopicTrack::readStatus(Auth::user(), $topics);
// there's currently only destroy action from watch index
return js_view('forum.topic_watches.destroy', compact('topic', 'topics', 'topicReadStatus'));
default:
return js_view('forum.topics.replace_button', compact('topic', 'type', 'state'));
}
}
示例15: foreach
59 Temple Place, Suite 330
Boston, MA 02111-1307
USA
You may contact the author/development team at:
Chaos Networks
c/o Werner Ammon
Lerchenstr. 11c
86343 Königsbrunn
URL: http://www.chaos.de
*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if ($cfg["leveled"]["right"] == "" || priv_check('', $cfg["leveled"]["right"])) {
// funktions bereich fuer erweiterungen
// ***
// ausgaben variablen bauen
$sql = "SELECT * FROM " . $cfg["leveled"]["db"]["level"]["entries"] . " WHERE lid='" . $environment["parameter"][1] . "'";
$result = $db->query($sql);
$field = $db->fetch_array($result, $nop);
foreach ($field as $name => $value) {
$ausgaben[$name] = $value;
}
//z.B. evtl. auf verknuepften datensatz pruefen
$sql = "SELECT " . $cfg["leveled"]["db"]["user"]["order"] . "\n FROM " . $cfg["leveled"]["db"]["right"]["entries"] . "\n INNER JOIN " . $cfg["leveled"]["db"]["user"]["entries"] . "\n ON ( auth_right.uid=auth_user.uid )\n WHERE " . $cfg["leveled"]["db"]["right"]["level"] . "='" . $environment["parameter"][1] . "'";
$result = $db->query($sql);
while ($members = $db->fetch_array($result, 1)) {
$ausgaben["members"] == "" ? $trenner = "" : ($trenner = ", ");
$ausgaben["members"] .= $trenner . $members["username"];