本文整理汇总了PHP中cmsUser::get方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsUser::get方法的具体用法?PHP cmsUser::get怎么用?PHP cmsUser::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsUser
的用法示例。
在下文中一共展示了cmsUser::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
$orfo = $this->request->get('orfo');
$url = $this->request->get('url');
$comment = $this->request->get('comment', false);
$author = !cmsUser::isLogged() ? cmsUser::getIp() : cmsUser::get('nickname');
$form = $this->getForm('orfo');
$is_submitted = $this->request->has('submit');
if ($is_submitted) {
$data = $form->parse($this->request, $is_submitted);
$data['date'] = date('Y-m-d H:i:s');
$errors = $form->validate($this, $data);
dump($errors);
if (!$errors) {
$this->model->addComplaints($data);
$messenger = cmsCore::getController('messages');
$messenger->addRecipient(1);
$notice = array('content' => sprintf(LANG_COMPLAINTS_ADD_NOTICE, $url, $orfo), 'options' => array('is_closeable' => true));
$messenger->ignoreNotifyOptions()->sendNoticePM($notice, 'complaints_add');
}
cmsTemplate::getInstance()->renderJSON(array('errors' => false, 'callback' => 'formSuccess'));
}
$data = array('orfo' => $orfo, 'url' => $url, 'author' => $author, 'comment' => $comment);
return cmsTemplate::getInstance()->render('orfo', array('form' => $form, 'data' => $data));
}
示例2: run
public function run()
{
if (cmsUser::isLogged() && !cmsUser::isAdmin()) {
$this->redirectToHome();
}
$users_model = cmsCore::getModel('users');
$form = $this->getForm('registration');
//
// Добавляем поле для кода приглашения,
// если регистрация доступна только по приглашениям
//
if ($this->options['is_reg_invites']) {
$fieldset_id = $form->addFieldsetToBeginning(LANG_REG_INVITED_ONLY);
$form->addField($fieldset_id, new fieldString('inv', array('title' => LANG_REG_INVITE_CODE, 'rules' => array(array('required'), array('min_length', 10), array('max_length', 10)))));
}
//
// Добавляем поле выбора группы,
// при наличии публичных групп
//
$public_groups = $users_model->getPublicGroups();
if ($public_groups) {
$pb_items = array();
foreach ($public_groups as $pb) {
$pb_items[$pb['id']] = $pb['title'];
}
$form->addFieldToBeginning('basic', new fieldList('group_id', array('title' => LANG_USER_GROUP, 'items' => $pb_items)));
}
//
// Добавляем в форму обязательные поля профилей
//
$content_model = cmsCore::getModel('content');
$content_model->setTablePrefix('');
$content_model->orderBy('ordering');
$fields = $content_model->getRequiredContentFields('users');
// Разбиваем поля по группам
$fieldsets = cmsForm::mapFieldsToFieldsets($fields);
// Добавляем поля в форму
foreach ($fieldsets as $fieldset) {
$fieldset_id = $form->addFieldset($fieldset['title']);
foreach ($fieldset['fields'] as $field) {
if ($field['is_system']) {
continue;
}
$form->addField($fieldset_id, $field['handler']);
}
}
$user = array();
if ($this->request->hasInQuery('inv')) {
$user['inv'] = $this->request->get('inv');
}
$is_submitted = $this->request->has('submit');
if ($is_submitted) {
if (!$this->options['is_reg_enabled']) {
cmsCore::error404();
}
$errors = false;
$is_captcha_valid = true;
//
// Проверяем капчу
//
if ($this->options['reg_captcha']) {
$is_captcha_valid = cmsEventsManager::hook('captcha_validate', $this->request);
if (!$is_captcha_valid) {
$errors = true;
cmsUser::addSessionMessage(LANG_CAPTCHA_ERROR, 'error');
}
}
//
// Парсим и валидируем форму
//
if (!$errors) {
$user = $form->parse($this->request, $is_submitted);
$user['groups'] = array();
if (!empty($this->options['def_groups'])) {
$user['groups'] = $this->options['def_groups'];
}
if (isset($user['group_id'])) {
if (!in_array($user['group_id'], $user['groups'])) {
$user['groups'][] = $user['group_id'];
}
}
//
// убираем поля которые не относятся к выбранной пользователем группе
//
foreach ($fieldsets as $fieldset) {
foreach ($fieldset['fields'] as $field) {
if (!$field['groups_edit']) {
continue;
}
if (in_array(0, $field['groups_edit'])) {
continue;
}
if (!in_array($user['group_id'], $field['groups_edit'])) {
$form->disableField($field['name']);
unset($user[$field['name']]);
}
}
}
$errors = $form->validate($this, $user);
}
//.........这里部分代码省略.........
示例3: foreach
data-delete-url="<?php
echo $this->href_to('delete');
?>
"<?php
}
?>
>
<?php
if (is_array($photos)) {
?>
<?php
foreach ($photos as $photo) {
?>
<?php
$is_photo_owner = $is_owner || $photo['user_id'] == cmsUser::get('id');
?>
<div class="photo photo-<?php
echo $photo['id'];
?>
">
<div class="image">
<a href="<?php
echo $this->href_to('view', $photo['id']);
?>
" title="<?php
html($photo['title']);
?>
">
<?php
echo html_image($photo['image'], 'normal', $photo['title']);