本文整理汇总了PHP中user::isGuest方法的典型用法代码示例。如果您正苦于以下问题:PHP user::isGuest方法的具体用法?PHP user::isGuest怎么用?PHP user::isGuest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user
的用法示例。
在下文中一共展示了user::isGuest方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAction
public function addAction()
{
if (user::isGuest() && reg::getKey('/comments/only_reg')) {
system::stop();
}
if (user::isGuest() && !system::validCapcha('random_image')) {
system::json(array('error' => 1, 'data' => lang::get('FEEDBACK_ERROR1')));
}
// Добавляем новый комментарий
$comment = new comment();
$comment->setParentId(system::POST('parent_id'));
$comment->setObjId(system::POST('obj_id'));
$comment->setUserName(system::POST('username'));
$comment->setEmail(system::POST('email'));
$comment->setText(system::POST('text'));
$comment->setSendEmail(system::POST('send_email'));
$obj_id = $comment->save();
if ($obj_id) {
page::assign('current_url', system::POST('back_url'));
$html = page::macros('comments')->view($comment->id());
system::json(array('error' => 0, 'data' => $html));
} else {
system::json(array('error' => 2, 'data' => $comment->getErrorListText(' ')));
}
if (!empty($_POST['back_url']) && !system::isAjax()) {
system::redirect($_POST['back_url'] . '#comment' . $obj_id, true);
} else {
system::stop();
}
}
示例2: form
/**
* @return HTML
* @param string $templ_name - Шаблон оформления
* @desc МАКРОС: Выводит форму обратной связи (добавления отзыва, вопрос-ответа и пр.)
*/
public function form($templ_name = 'default')
{
$templ_file = '/feedback/' . $templ_name . '.tpl';
$TEMPLATE = page::getTemplate($templ_file);
if (!is_array($TEMPLATE)) {
return page::errorNotFound('feedback.form', $templ_file);
}
if (!user::isGuest()) {
page::assign('feedback.name', user::get('surname') . ' ' . user::get('name'));
page::assign('feedback.email', user::get('email'));
}
page::assignSavingPost('feedback');
// Парсим текст сообщения об ошибке
page::parseError('feedback');
return page::parse($TEMPLATE['frame'], 1);
}
示例3: order_procAction
public function order_procAction()
{
if (!user::isGuest() && isset($_SESSION['order_step'])) {
switch ($_SESSION['order_step']) {
case 1:
// Доставка
$_SESSION['order']['name'] = system::POST('delivery_name', isString);
$_SESSION['order']['surname'] = system::POST('delivery_surname', isString);
$_SESSION['order']['phone'] = system::POST('delivery_phone', isString);
$_SESSION['order']['address'] = system::POST('delivery_address', isString);
$_SESSION['order']['notice'] = system::POST('delivery_notice', isText);
$_SESSION['order']['delivery'] = system::POST('delivery', isInt);
if (empty($_SESSION['order']['delivery']) || empty($_SESSION['order']['name']) || empty($_SESSION['order']['surname']) || empty($_SESSION['order']['phone']) || empty($_SESSION['order']['address'])) {
// Ошибка: не все поля заполнены
} else {
// Все отлично, переходим к следующему шагу
$_SESSION['order_step'] = 2;
}
break;
case 2:
// Подтвеждение заказа, сохраняем данные в БД
$order = new eShopOrder();
// Информация о доставке
$order->setDelivery($_SESSION['order']['delivery']);
$order->delivery_name = $_SESSION['order']['name'];
$order->delivery_surname = $_SESSION['order']['surname'];
$order->delivery_phone = $_SESSION['order']['phone'];
$order->delivery_address = $_SESSION['order']['address'];
$order->delivery_notice = $_SESSION['order']['notice'];
$order_id = $order->save();
if ($order_id) {
// Заказ сохранен
unset($_SESSION['order_step']);
unset($_SESSION['order']);
system::redirect('/eshop/ok/' . $order_id);
} else {
// Произошла ошибка
}
system::redirect('/eshop/order');
break;
}
}
system::redirect('/eshop/order');
}
示例4: showAuthForm
private function showAuthForm($error = 0)
{
if (file_exists(MODUL_DIR . '/mpanel/template/auth.tpl')) {
include MODUL_DIR . '/mpanel/template/auth.tpl';
page::assign('title', lang::get('CMF'));
if (user::isGuest()) {
// Пользователь не авторизован
page::assign('url', system::getCurrentUrl());
page::assign('login', lang::get('AUTHFORM_LOGIN'));
page::assign('passw', lang::get('AUTHFORM_PASSW'));
page::assign('enter', lang::get('AUTHFORM_ENTER'));
page::assign('error', $error);
echo page::parse($TEMPLATE['frame']);
} else {
// Пользователь авторизован, но не является админом
page::assign('exit_url', '/users/logout');
page::assign('user', user::get('name'));
page::assign('hello', lang::get('AUTHFORM_HELLO'));
page::assign('big_text', lang::get('AUTHFORM_BIG_TEXT'));
page::assign('exit_text', lang::get('AUTHFORM_EXIT_TEXT'));
echo page::parse($TEMPLATE['frame_no_admin']);
}
system::stop();
}
}
示例5: createObject
private function createObject()
{
if (empty($this->newprop['c_obj_id'])) {
$this->newError(100, 'Необходимо указать ID объекта к которому будет привязан комментарий!');
return false;
}
if (empty($this->newprop['c_username'])) {
$this->newError(100, 'Необходимо указать имя пользователя оставившего комментарий!');
return false;
}
if (empty($this->newprop['c_email'])) {
$this->newError(100, 'Необходимо указать E-mail пользователя оставившего комментарий!');
return false;
}
if (empty($this->newprop['c_text'])) {
$this->newError(100, 'Необходимо указать текст комментария!');
return false;
}
$sql = '';
if (!empty($this->newprop)) {
reset($this->newprop);
while (list($fname, $value) = each($this->newprop)) {
$sql .= ', ' . $fname . ' = "' . $value . '"';
}
}
if (!user::isGuest()) {
$sql .= ', c_user_id = "' . user::get('id') . '"';
}
$id = db::q('INSERT INTO <<comments>> SET c_publ_date = "' . date('Y-m-d H:i:s') . '" ' . $sql . ';');
if ($id) {
$this->id = $id;
$this->curprop = $this->newprop;
// Отправка уведомлений о новом комментарии
$this->sendEmails();
$this->clearCache();
return $this->id;
}
return false;
}
示例6: socialAuthConfirm
/**
* @return string
* @param string $templ_name - Шаблон оформления
* @desc МАКРОС: Выводит форму второго шага авторизации через соц сети, если требуется указать e-mail или согласиться с правилами.
*/
function socialAuthConfirm($templ_name = 'social_auth_confirm')
{
$templ_file = '/users/' . $templ_name . '.tpl';
$TEMPLATE = page::getTemplate($templ_file);
if (!is_array($TEMPLATE)) {
return page::errorNotFound('users.socialAuthConfirm', $templ_file);
}
if (user::isGuest() && !empty($_SESSION['SOCIAL_AUTH_USER_INFO'])) {
page::assign('obj.email', '');
foreach ($_SESSION['SOCIAL_AUTH_USER_INFO'] as $key => $val) {
page::assign('obj.' . $key, $val);
}
page::assign('email_block', reg::getKey('/users/ask_email') && empty($_SESSION['SOCIAL_AUTH_USER_INFO']['email']) ? page::parse($TEMPLATE['email']) : '');
page::assign('confirm_block', reg::getKey('/users/confirm') ? page::parse($TEMPLATE['confirm']) : '');
// Вывод сообщения об ошибках
page::parseError('social_auth_confirm');
return page::parse($TEMPLATE['frame']);
}
}
示例7: order
public function order($templ_name = 'order_steps')
{
$templ_file = '/eshop/' . $templ_name . '.tpl';
$TEMPLATE = page::getTemplate($templ_file);
if (!is_array($TEMPLATE)) {
return page::errorNotFound('eshop.basket', $templ_file);
}
if (user::isGuest()) {
page::assign('order.cost', basket::getTotalCost());
return page::parse($TEMPLATE['no_auth']);
}
if (!isset($_SESSION['order_step'])) {
$_SESSION['order_step'] = 1;
}
if (system::url(2) == 'back') {
$_SESSION['order_step']--;
}
switch ($_SESSION['order_step']) {
case 1:
// Доставка
$sel = new ormSelect('eshop_delivery_method');
$sel->fields('name, price, notice');
$list = '';
while ($obj = $sel->getObject()) {
page::assign('obj.id', $obj->id);
page::assign('obj.name', $obj->name);
page::assign('obj.price', $obj->price);
page::assign('obj.notice', $obj->notice);
$act = isset($_SESSION['order']['delivery']) && $obj->id == $_SESSION['order']['delivery'] ? '_active' : '';
$list .= page::parse($TEMPLATE['delivery_list' . $act]);
}
page::assign('delivery_list', $list);
page::assign('order.name', isset($_SESSION['order']['name']) ? $_SESSION['order']['name'] : user::get('name'));
page::assign('order.surname', isset($_SESSION['order']['surname']) ? $_SESSION['order']['surname'] : user::get('surname'));
page::assign('order.phone', isset($_SESSION['order']['phone']) ? $_SESSION['order']['phone'] : user::get('phone'));
page::assign('order.address', isset($_SESSION['order']['address']) ? $_SESSION['order']['address'] : user::get('address'));
page::assign('order.notice', isset($_SESSION['order']['notice']) ? $_SESSION['order']['notice'] : '');
page::assign('order.cost', basket::getTotalCost());
return page::parse($TEMPLATE['delivery']);
break;
case 2:
// Подтверждение
// Расчитываем общую стоимость с учетом доставки
if ($delivery = ormObjects::get($_SESSION['order']['delivery'])) {
page::assign('order.delivery', $delivery->name);
page::assign('order.delivery_price', $delivery->price);
$cost = $delivery->price + basket::getTotalCost();
page::assign('order.cost', $cost);
}
page::assign('order.name', isset($_SESSION['order']['name']) ? $_SESSION['order']['name'] : user::get('name'));
page::assign('order.surname', isset($_SESSION['order']['surname']) ? $_SESSION['order']['surname'] : user::get('surname'));
page::assign('order.phone', isset($_SESSION['order']['phone']) ? $_SESSION['order']['phone'] : user::get('phone'));
page::assign('order.address', isset($_SESSION['order']['address']) ? $_SESSION['order']['address'] : user::get('address'));
return page::parse($TEMPLATE['aception']);
break;
default:
unset($_SESSION['order_step']);
system::redirect('/eshop/basket');
}
}
示例8: socialAuthConfirm
static function socialAuthConfirm()
{
if (user::isGuest() && isset($_SESSION['SOCIAL_AUTH_USER_INFO'])) {
$confirm = system::POST('confirm', isBool);
$email = system::POST('email', isEmail);
$validate = true;
if (empty($_SESSION['SOCIAL_AUTH_USER_INFO']['email'])) {
if (reg::getKey('/users/ask_email') && empty($email)) {
$validate = false;
} else {
if (!empty($email)) {
$_SESSION['SOCIAL_AUTH_USER_INFO']['email'] = $email;
}
}
}
if (reg::getKey('/users/confirm') && !$confirm) {
$validate = false;
}
if ($validate) {
$user = self::createUserForSocial($_SESSION['SOCIAL_AUTH_USER_INFO']);
if ($user && !$user->issetErrors()) {
user::authHim($user);
self::closeWindowAndOpen('/');
} else {
echo $user->getErrorListText();
}
system::stop();
}
}
}
示例9: addEmail
static function addEmail($email, $subscriptions, $copyUserData = false)
{
$email = system::checkVar($email, isEmail);
if (!empty($email) && !empty($subscriptions)) {
$obj = new ormObject();
$obj->setClass('subscribe_user');
$obj->name = $email;
if (!user::isGuest() && $copyUserData) {
$obj->second_name = user::get('surname');
$obj->first_name = user::get('name');
$obj->user_id = user::get('id');
}
// Указываем на какие подписки подписать
while (list($key, $val) = each($subscriptions)) {
$obj->setNewParent($val);
}
// Сохраняем изменения
$sid = $obj->save();
if ($obj->issetErrors(29)) {
// Если указанный e-mail уже существует, пытаемся найти его и подписать на рассылки.
$sel = new ormSelect('subscribe_user');
$sel->where('name', '=', $email);
$sel->limit(1);
if ($obj = $sel->getObject()) {
if (!user::isGuest() && $copyUserData) {
$obj->second_name = user::get('surname');
$obj->first_name = user::get('name');
$obj->user_id = user::get('id');
}
reset($subscriptions);
while (list($key, $val) = each($subscriptions)) {
$obj->setNewParent($val);
}
$sid = $obj->save();
}
}
return $sid;
}
}
示例10: change_password_procAction
public function change_password_procAction()
{
if (user::isGuest()) {
system::redirect('/users/add');
}
$cur_password = system::POST('current_password', isPassword);
$new_passw = system::POST('password', isPassword);
$new_passw2 = system::POST('password2', isPassword);
if ($cur_password == user::get('password')) {
if ($new_passw && $new_passw == $new_passw2) {
if ($user = user::getObject()) {
$user->password = system::POST('password');
if ($user->save()) {
if (system::isAjax()) {
system::json(array('ok' => 1));
} else {
system::redirect('/users/change_password/ok');
}
}
}
}
} else {
$answer = array('msg' => lang::get('USERS_CHANGE_PSW_MSG'), 'field' => 'current_password');
if (!system::isAjax()) {
system::saveErrorToSession('change_password', $answer);
system::redirect('/users/change_password');
} else {
system::json($answer);
}
}
system::redirect('/users/change_password');
}