本文整理汇总了PHP中Env::getCurrentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Env::getCurrentUser方法的具体用法?PHP Env::getCurrentUser怎么用?PHP Env::getCurrentUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Env
的用法示例。
在下文中一共展示了Env::getCurrentUser方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionEdit
public function actionEdit($id)
{
if (isset($_POST['SlideForm'])) {
$error = "";
if (empty($_POST['SlideForm']['name'])) {
$error = "name";
}
if (empty($_POST['SlideForm']['content'])) {
$error = "content";
}
if (Env::getCurrentUser() == null) {
$error = "auth";
}
if (Env::getCurrentUser()->isBanned()) {
$error = "banned";
}
if (!empty($error)) {
Env::setCookie("slider_content", $_POST['SlideForm']['content']);
Env::setCookie("slider_name", $_POST['SlideForm']['name']);
$this->redirect('/slider/edit/#error-' . $error);
} else {
Env::deleteCookie("slider_content");
Env::deleteCookie("slider_name");
$slide = Slide::model()->findByPk($id);
$slide->name = Env::clear($_POST['SlideForm']['name']);
$slide->content = $_POST['SlideForm']['content'];
$slide->update();
$this->redirect('/slider');
}
} else {
$this->render('edit', array("slide" => Slide::model()->findByPk($id)));
}
}
示例2: actionCreate
public function actionCreate()
{
$this->checkAddAccess(Env::getCurrentUser());
if (isset($_POST['PostForm'])) {
$error = "";
if (empty($_POST['PostForm']['title'])) {
$error = "title";
}
if (empty($_POST['PostForm']['content'])) {
$error = "content";
}
if (empty($_POST['PostForm']['type'])) {
$error = "type";
}
if (empty($_POST['PostForm']['logo'])) {
$error = "logo";
}
if ($this->checkTags($_POST['PostForm']['tags'])) {
$error = "tags";
}
if (Env::getCurrentUser() == null) {
$error = "auth";
}
if (Env::getCurrentUser()->isBanned()) {
$error = "banned";
}
if (!empty($error)) {
Env::setCookie("post_logo", $_POST['PostForm']['logo']);
Env::setCookie("post_content", $_POST['PostForm']['content']);
Env::setCookie("post_type", $_POST['PostForm']['type']);
Env::setCookie("post_tags", $_POST['PostForm']['tags']);
Env::setCookie("post_title", $_POST['PostForm']['title']);
$this->redirect('/video/create/#error-' . $error);
} else {
Env::deleteCookie("post_logo");
Env::deleteCookie("post_content");
Env::deleteCookie("post_type");
Env::deleteCookie("post_tags");
Env::deleteCookie("post_title");
$post = new Post();
$post->title = Env::clear($_POST['PostForm']['title']);
$post->content = $_POST['PostForm']['content'];
$post->type = Env::clear($_POST['PostForm']['type']);
$post->logo = Env::clear($_POST['PostForm']['logo']);
$post->uid = Env::getCurrentUser()->id;
$post->time = time();
$post->save();
$post->addTags(Env::clear($_POST['PostForm']['tags']));
$this->redirect(Yii::app()->homeUrl);
}
} else {
$this->render('create');
}
}
示例3: actionUpload
public function actionUpload()
{
$user = Env::getCurrentUser();
$this->checkUploadAccess($user);
if (isset($_POST['Image'])) {
$model = new Image();
$model->attributes = $_POST['Image'];
$model->image = CUploadedFile::getInstance($model, 'image');
$imageId = $user->getNextImageId();
@mkdir('./images/uploads/u' . $user->id);
$model->image->saveAs('./images/uploads/u' . $user->id . "/f" . $imageId);
die("/image/view?url=u" . $user->id . "/f" . $imageId);
}
}
示例4: actionAdd
public function actionAdd($id)
{
$this->checkAdminAccess(Env::getCurrentUser(), $id);
if (isset($_POST['param'])) {
$user = User::model()->find("vkid=:vkid or vkuri=:vkuri or nickname=:nickname", array("vkid" => (int) $_POST['param'], "vkuri" => $_POST['param'], "nickname" => $_POST['param']));
if ($user === null) {
$this->redirect('/list/' . $id . "#error-notfound");
} else {
$user->group = $id;
$user->update();
$this->redirect('/list/' . $id);
}
} else {
$this->redirect('/list/' . $id);
}
}
示例5:
popup.document.write(msg);
});
if(location.href.indexOf("#error")>-1) {
var splits = location.href.split("-");
var res = "";
if(splits[splits.length-1]==="name") res += "Нет названия слайдера";
if(splits[splits.length-1]==="content") res += "Нет основного содержания слайдера";
if(splits[splits.length-1]==="banned") res += "Вы в бане";
\$("#error-container").html("<div class='error'>"+res+"</div>");
}
\$('#editor1').markItUp(mySettings);
SCRIPTS;
?>
<div class="post">
<?php
if (Env::getCurrentUser() == null || Env::getCurrentUser()->group < 3) {
?>
<div class="addpost-needauth">
Недостаточно прав для редактирование слайда.
</div>
<?php
} else {
?>
<div id="error-container"></div>
<form method="POST" class="addpost addslide" action="/slider/edit/<?php
echo $slide->id;
?>
">
<div class="meta">
<input type="text" class="title" name="SlideForm[name]" placeholder="Название слайда" value="<?php
echo $slide->name;
示例6: array
<?php
/* @var $this SiteController */
/* @var $error array */
$this->pageTitle = Yii::app()->name . ' - Error';
$this->breadcrumbs = array('Error');
?>
<div class="post">
<div class="addpost-needauth">
<?php
echo CHtml::encode($message);
?>
<?php
if (Env::getCurrentUser() == null) {
?>
Возможно, стоит <a href="<?php
echo Env::getVKAuthLink();
?>
">авторизоваться</a>.<?php
}
?>
</div>
</div>
示例7:
?>
">
<div class="info">
<div class="author">
<a href="http://vk.com/<?php
echo Env::getCurrentUser()->vkuri;
?>
" target="_blank">
<b><?php
echo Env::getCurrentUser()->nickname;
?>
</b><u>vk.com/<?php
echo Env::getCurrentUser()->vkuri;
?>
</u><img src="<?php
echo Env::getCurrentUser()->avatar;
?>
">
</a>
</div>
</div>
</div>
<input name="PostForm[content]" class="link" placeholder="Ссылка на видео/twitch канал" value="<?php
echo Yii::app()->request->cookies['post_content'];
?>
">
<div id="preview"></div>
<input type="hidden" name="PostForm[type]" value="<?php
echo Yii::app()->request->cookies['post_type'] != null ? Yii::app()->request->cookies['post_type'] : "1";
?>
">
示例8: url
?>
<div class="post">
<?php
if (Env::getCurrentUser() == null) {
?>
<div class="addpost-needauth">
Перед редактированием поста необходимо <a href="<?php
echo Env::getVKAuthLink();
?>
">авторизоваться</a>.
</div>
<?php
} else {
?>
<?php
if (Env::getCurrentUser()->isBanned() || !$post->isAbleToEdit(Env::getCurrentUser())) {
?>
<div class="addpost-needauth">
Вы не можете редактировать новости.
</div>
<?php
} else {
?>
<div class="post-image">
<div class="biglogo-uploader" style="background-image: url('<?php
echo $post->logo;
?>
');background-size: cover;">
<form class="biglogo">
<input id="ytImage_image" type="hidden" value="" name="Image[image]">
<input name="Image[image]" class='fileInput' id="Image_image" type="file">
示例9: beforeAction
public function beforeAction($action)
{
$this->checkAccess(Env::getCurrentUser());
return parent::beforeAction($action);
}
示例10:
</p>
<a href="http://vk.com/<?php
echo Env::getCurrentUser()->vkuri;
?>
" target="_blank">Страница ВКонтакте</a>
<?php
if (Env::getCurrentUser()->group > 2) {
?>
<a href="/list/3">Админы</a>
<a href="/list/2">Редакторы</a>
<a href="/slider/">Слайдер</a>
<?php
}
?>
<?php
if (Env::getCurrentUser()->group > 1) {
?>
<a href="/list/0">Баны</a>
<?php
}
?>
<a href="/login/logout">Выход</a>
<?php
}
?>
</div>
<div class="hinttext">
<?php
echo Yii::app()->params['hintText'];
?>
</div>
示例11: actionClear
public function actionClear($id)
{
$comment = Comment::model()->findByPk($id);
if (!$comment->isAbleToEdit(Env::getCurrentUser())) {
throw new AccessException();
}
$comment->delete();
$this->redirect('/post/' . $comment->pid);
}