本文整理汇总了PHP中AuthUser::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthUser::getId方法的具体用法?PHP AuthUser::getId怎么用?PHP AuthUser::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthUser
的用法示例。
在下文中一共展示了AuthUser::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeUpdate
public function beforeUpdate()
{
if (!Observer::notify('layout_before_edit', $this)) {
return false;
}
$this->updated_by_id = AuthUser::getId();
$this->updated_on = date('Y-m-d H:i:s');
return true;
}
示例2: _checkPermission
private static function _checkPermission()
{
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
redirect(get_url('login'));
} else {
if (!AuthUser::getId() == 1) {
Flash::set('error', __('You do not have permission to access the requested page!'));
redirect(get_url());
}
}
}
示例3: beforeUpdate
public function beforeUpdate()
{
/* TODO: Figure out logic behind xxx_on_time variables
$this->created_on = $this->created_on . ' ' . $this->created_on_time;
unset($this->created_on_time);
*/
if (!empty($this->published_on)) {
/*
$this->published_on = $this->published_on . ' ' . $this->published_on_time;
unset($this->published_on_time);
*/
} else {
if ($this->status_id == Page::STATUS_PUBLISHED) {
$this->published_on = date('Y-m-d H:i:s');
}
}
$this->updated_by_id = AuthUser::getId();
$this->updated_on = date('Y-m-d H:i:s');
return true;
}
示例4: edit
public function edit($id)
{
if ($_POST["action"] == "edit") {
$data = $_POST['event'];
Flash::set('postdata', $data);
$event = Record::findByIdFrom('Event', $id);
if (!$event) {
Flash::set('error', __('Event not found!'));
redirect(get_url('event'));
}
$save = true;
// verification
if (empty($data['title'])) {
Flash::set('error', __('You have to specify a event title!'));
redirect(get_url('event/view/' . $id));
}
if (empty($data['url'])) {
Flash::set('error', __('You have to specify the "Read More" URL!'));
redirect(get_url('event/view/' . $id));
}
$event->setFromData($data);
$event->updated_by_id = AuthUser::getId();
$event->updated_on = date('Y-m-d H:i:s');
if (!$event->save()) {
Flash::set('error', __('Event is not updated!'));
redirect(get_url('event/view/' . $id));
} else {
$this->upload($id);
Flash::set('success', __('Event has been updated!'));
if (isset($_POST['commit'])) {
redirect(get_url('event'));
} else {
redirect(get_url('event/view/' . $id));
}
}
}
}
示例5: _insert_log
function _insert_log($message)
{
$log_data = array("message" => $message, "user_id" => AuthUser::getId());
$record = Record::insert('ecommerce_log', $log_data);
}
示例6: __
echo __('Memory usage:');
?>
<?php
echo memory_usage();
?>
</p>
<?php
}
?>
<p id="site-links">
<?php
echo __('You are currently logged in as');
?>
<a href="<?php
echo get_url('user/edit/' . AuthUser::getId());
?>
"><?php
echo AuthUser::getRecord()->name;
?>
</a>
<span class="separator"> | </span>
<a id="site-view-link" href="<?php
echo URL_PUBLIC;
?>
" target="_blank"><?php
echo __('View Site');
?>
</a>
<span class="separator"> | </span>
<a href="<?php
示例7: edit
public function edit($id)
{
if ($_POST["action"] == "edit") {
$data = $_POST['news'];
Flash::set('postdata', $data);
$news = Record::findByIdFrom('News', $id);
if (!$news) {
Flash::set('error', __('Promo could not be found!'));
redirect(get_url('news'));
}
$save = true;
// verification
if (empty($data['title'])) {
Flash::set('error', __('You have to specify a news title!'));
redirect(get_url('news/view/' . $id));
}
// if (empty($data['url'])){
// Flash::set('error', __('You have to specify the URL!'));
// redirect(get_url('news/view/'.$id));
// }
$news->setFromData($data);
$news->updated_by_id = AuthUser::getId();
$news->updated_on = date('Y-m-d H:i:s');
if (!$news->save()) {
Flash::set('error', __('Promo is not updated!'));
redirect(get_url('news/view/' . $id));
} else {
$this->upload($id);
Flash::set('success', __('Promo has been updated!'));
if (isset($_POST['commit'])) {
redirect(get_url('news'));
} else {
redirect(get_url('news/view/' . $id));
}
}
}
}
示例8: add_sidebarlink
public function add_sidebarlink()
{
$this->_checkPermission();
$data = $_POST['sidebarlink'];
Flash::set('postdata', $data);
$image = $_POST['upload'];
$path = str_replace('..', '', $image['path']);
$overwrite = false;
// verification
if (empty($data['type'])) {
Flash::set('error', __('You have to specify the sidebar link type!'));
redirect(get_url('sidebarlink/create'));
}
//For sidebarlink image
if (empty($_FILES['upload_file']['name'])) {
Flash::set('error', __('You have to select a image to be uploaded!'));
redirect(get_url('sidebarlink/create'));
}
$sidebarlink = new SidebarLink($data);
$sidebarlink->created_by_id = AuthUser::getId();
$sidebarlink->created_on = date('Y-m-d H:i:s');
if (!$sidebarlink->save()) {
Flash::set('error', __('Sidebar link is not added!'));
redirect(get_url('sidebarlink', 'create'));
} else {
if (isset($_FILES)) {
$id = $sidebarlink->lastInsertId();
$file = $this->upload_file($_FILES['upload_file']['name'], FILES_DIR . '/sidebarlink/images/', $_FILES['upload_file']['tmp_name'], $overwrite, $id);
if ($file === false) {
Flash::set('error', __('File has not been uploaded!'));
}
}
Flash::set('success', __('Sidebar link has been added!'));
}
redirect(get_url('sidebarlink'));
}
示例9: _edit
private function _edit($id)
{
$data = $_POST['user'];
// CSRF checks
if (isset($_POST['csrf_token'])) {
$csrf_token = $_POST['csrf_token'];
if (!SecureToken::validateToken($csrf_token, BASE_URL . 'user/edit')) {
Flash::set('error', __('Invalid CSRF token found!'));
redirect(get_url('user/add'));
}
} else {
Flash::set('error', __('No CSRF token found!'));
redirect(get_url('user/edit'));
}
// check if user want to change the password
if (strlen($data['password']) > 0) {
// check if pass and confirm are egal and >= 5 chars
if (strlen($data['password']) >= 5 && $data['password'] == $data['confirm']) {
unset($data['confirm']);
} else {
Flash::set('error', __('Password and Confirm are not the same or too small!'));
redirect(get_url('user/edit/' . $id));
}
} else {
unset($data['password'], $data['confirm']);
}
$user = Record::findByIdFrom('User', $id);
if (isset($data['password'])) {
$data['password'] = AuthUser::generateHashedPassword($data['password'], $user->salt);
}
$user->setFromData($data);
if ($user->save()) {
if (AuthUser::hasPermission('administrator')) {
// now we need to add permissions
$data = isset($_POST['user_permission']) ? $_POST['user_permission'] : array();
UserPermission::setPermissionsFor($user->id, $data);
}
Flash::set('success', __('User has been saved!'));
} else {
Flash::set('error', __('User has not been saved!'));
}
if (AuthUser::getId() == $id) {
redirect(get_url('user/edit/' . $id));
} else {
redirect(get_url('user'));
}
}
示例10: addAction
public function addAction()
{
global $tpl;
//如果是分表则通过$_POST['content'], $_POST['content_part']区分
//$data = isset($_POST['article']) ? $_POST['article'] : array();
$data = array();
if (isset($_POST['add']) || isset($_POST['save'])) {
$data = $_POST['content'];
//判断ID是否存在
if (!$data['id']) {
//add
$data['slug'] = !empty($data['slug']) ? dealWords($data['slug']) : null;
$data['created_uid'] = AuthUser::getId();
$data['created_date'] = time();
$article = new Article($data);
if ($article->save()) {
$data_part = array();
$data_part = $_POST['content_part'];
$data_part['id'] = $article->id;
$content_part = new ContentPart($data_part);
$content_part->insert();
$article->content = $content_part->content;
//save tags
$article->saveTags(trim($_POST['tags']));
//update category
$category = new Category('id', $article->cid);
$category->count++;
$category->save();
$article->category = $category->name;
$article->category_slug = $category->slug;
//删除上一篇缓存
$prev = $article->previous();
$this->delPostHtml($prev->id);
}
} else {
//update
$data['updated_uid'] = AuthUser::getId();
$data['updated_date'] = time();
$old_article = new Article('id', $data['id']);
$article = new Article($data);
if ($article->save()) {
$data_part = array();
$data_part = $_POST['content_part'];
$data_part['id'] = $article->id;
$content_part = new ContentPart($data_part);
$content_part->save();
$article->content = $content_part->content;
$article->saveTags($_POST['tags']);
//更新文章分类统计
if ($old_article->cid != $article->cid) {
$c1 = new Category('id', $article->cid);
$c1->count++;
$c1->save();
$c2 = new Category('id', $old_article->cid);
$c2->count--;
$c2->save();
}
}
}
//$_POST = array();
$tpl->assign('article', $article);
//生成静态页面
$status = isset($data['status']) ? $data['status'] : 'draft';
if ($status == 'publish') {
$this->createPostHtml($article);
} else {
if ($status == 'draft') {
$this->delPostHtml($article->id);
}
}
del_cache();
if (isset($_POST['add'])) {
header('location:index.php?job=admin_article');
}
}
$categories = Category::findAll();
$tpl->assign('cats', $categories);
$tpl->display('admin/article_add.html');
}
示例11: edit
public function edit($id)
{
if ($_POST["action"] == "edit") {
$data = $_POST['dine'];
Flash::set('postdata', $data);
$dine = Record::findByIdFrom('Dine', $id);
if (!$dine) {
Flash::set('error', __('Dine could not be found!'));
redirect(get_url('dine'));
}
$save = true;
// verification
if (empty($data['title'])) {
Flash::set('error', __('You have to specify a dine title!'));
redirect(get_url('dine/view/' . $id));
}
$dine->setFromData($data);
$dine->updated_by_id = AuthUser::getId();
$dine->updated_on = date('Y-m-d H:i:s');
if (!$dine->save()) {
Flash::set('error', __('Dine is not updated!'));
redirect(get_url('dine/view/' . $id));
} else {
$this->upload($id);
Flash::set('success', __('Dine has been updated!'));
if (isset($_POST['commit'])) {
redirect(get_url('dine'));
} else {
redirect(get_url('dine/view/' . $id));
}
}
}
}
示例12: beforeUpdate
public function beforeUpdate()
{
if (!Observer::notify('page_edit_before_save', $this)) {
return false;
}
if (!strpos($this->created_on, " ") && $this->created_on_time) {
$this->created_on = $this->created_on . ' ' . $this->created_on_time;
unset($this->created_on_time);
}
if (!empty($this->published_on)) {
if (!strpos($this->published_on, " ") && $this->published_on_time) {
$this->published_on = $this->published_on . ' ' . $this->published_on_time;
unset($this->published_on_time);
}
} else {
if ($this->status_id == Page::STATUS_PUBLISHED) {
$this->published_on = date('Y-m-d H:i:s');
}
}
$this->updated_by_id = AuthUser::getId();
$this->updated_on = date('Y-m-d H:i:s');
return true;
}
示例13: _edit_category
public function _edit_category($id)
{
$data = $_POST['cat'];
Flash::set('postdata', $data);
$category_rec = Record::query('select * from ' . TABLE_PREFIX . 'newscategory where id=' . $id);
$cat = $category_rec->fetchObject();
if (!$cat) {
Flash::set('error', __('News category could not be found!'));
redirect(get_url('news'));
}
$save = true;
// verification
if (empty($data['title'])) {
Flash::set('error', __('You have to specify a category name!'));
redirect(get_url('news/edit_category/' . $id));
}
$title = $data['title'];
$status = $data['status'];
$cat = Record::query('Update ' . TABLE_PREFIX . 'newscategory set title=' . $title . ', status="' . $status . '", updated_by_id=' . AuthUser::getId() . ',updated_on="' . date('Y-m-d H:i:s') . '" where id="' . $id . '"');
$cat->execute();
Flash::set('success', __('Category has been updated!'));
if (isset($_POST['commit'])) {
redirect(get_url('news'));
} else {
redirect(get_url('news/edit_category/' . $id));
}
}
示例14: registered_users_page_found
function registered_users_page_found($page)
{
$PDO = Record::getConnection();
// If login is required for the page
if ($page->getLoginNeeded() == Page::LOGIN_REQUIRED) {
AuthUser::load();
// Not Logged In
if (!AuthUser::isLoggedIn()) {
// Get the current page id
$requested_page_id = $page->id();
// Let's get the page that is set as the login page to prevent any loopbacks
$getloginpage = 'SELECT * FROM ' . TABLE_PREFIX . "page WHERE behavior_id='login_page'";
$getloginpage = $PDO->prepare($getloginpage);
$getloginpage->execute();
while ($loginpage = $getloginpage->fetchObject()) {
$slug = $loginpage->slug;
print_r($loginpage);
}
if ($requested_page_id != $loginpage_id) {
header('Location: ' . BASE_URL . $slug);
}
} else {
// We need to check if the user has permission to access the page
// Get requested page id
$requested_page_id = $page->id();
// Get permissions that are required for this page
$permissions_check = "SELECT * FROM " . TABLE_PREFIX . "permission_page WHERE page_id='{$requested_page_id}'";
$permissions_check = $PDO->prepare($permissions_check);
$permissions_check->execute();
$permission_array = array();
while ($permission = $permissions_check->fetchObject()) {
$page_permission = $permission->permission_id;
array_push($permission_array, $page_permission);
}
$permissions_count = count($permission_array);
AuthUser::load();
$userid = AuthUser::getRecord()->id;
// Get permissions that this user has
/*
$user_permissions_check = "SELECT * FROM ".TABLE_PREFIX."user_permission WHERE user_id='$userid'";
$user_permissions_check = $__CMS_CONN__->prepare($user_permissions_check);
$user_permissions_check->execute();
$user_permissions_array = array();
while ($user_permissions = $user_permissions_check->fetchObject()) {
$user_permission = $user_permissions->permission_id;
array_push($user_permissions_array, $user_permission);
}*/
$roles = AuthUser::getRecord()->roles();
foreach ($roles as $role) {
$user_permissions_array[] = $role->id;
}
$permission_result = array_intersect($permission_array, $user_permissions_array);
$permission_result_count = count($permission_result);
if ($permission_result_count < 1 && AuthUser::getId() != 1) {
// Let's get the authorisation required page
$auth_required_page = Plugin::getSetting("auth_required_page", "registered_users");
header('Location: ' . URL_PUBLIC . '' . $auth_required_page . '');
}
}
}
}
示例15: _edit
/**
* @todo merge _add() and _edit() into one _store()
*
* @param <type> $id
*/
private function _edit($id)
{
use_helper('Validate');
$data = $_POST['user'];
Flash::set('post_data', (object) $data);
// Add pre-save checks here
$errors = false;
// CSRF checks
if (isset($_POST['csrf_token'])) {
$csrf_token = $_POST['csrf_token'];
if (!SecureToken::validateToken($csrf_token, BASE_URL . 'user/edit')) {
Flash::set('error', __('Invalid CSRF token found!'));
redirect(get_url('user/edit/' . $id));
}
} else {
Flash::set('error', __('No CSRF token found!'));
redirect(get_url('user/edit/' . $id));
}
// check if user want to change the password
if (strlen($data['password']) > 0) {
// check if pass and confirm are egal and >= 5 chars
if (strlen($data['password']) >= 5 && $data['password'] == $data['confirm']) {
unset($data['confirm']);
} else {
Flash::set('error', __('Password and Confirm are not the same or too small!'));
redirect(get_url('user/edit/' . $id));
}
} else {
unset($data['password'], $data['confirm']);
}
// Check alphanumerical fields
$fields = array('username');
foreach ($fields as $field) {
if (!empty($data[$field]) && !Validate::alphanum_space($data[$field])) {
$errors[] = __('Illegal value for :fieldname field!', array(':fieldname' => $field));
}
}
if (!empty($data['name']) && !Validate::alphanum_space($data['name'], true)) {
$errors[] = __('Illegal value for :fieldname field!', array(':fieldname' => 'name'));
}
if (!empty($data['email']) && !Validate::email($data['email'])) {
$errors[] = __('Illegal value for :fieldname field!', array(':fieldname' => 'email'));
}
if (!empty($data['language']) && !Validate::alpha($data['language'])) {
$errors[] = __('Illegal value for :fieldname field!', array(':fieldname' => 'language'));
}
if ($errors !== false) {
// Set the errors to be displayed.
Flash::set('error', implode('<br/>', $errors));
redirect(get_url('user/edit/' . $id));
}
$user = Record::findByIdFrom('User', $id);
if (isset($data['password'])) {
if (empty($user->salt)) {
$user->salt = AuthUser::generateSalt();
}
$data['password'] = AuthUser::generateHashedPassword($data['password'], $user->salt);
}
$user->setFromData($data);
if ($user->save()) {
if (AuthUser::hasPermission('user_edit')) {
// now we need to add permissions
$data = isset($_POST['user_permission']) ? $_POST['user_permission'] : array();
UserRole::setPermissionsFor($user->id, $data);
}
Flash::set('success', __('User has been saved!'));
Observer::notify('user_after_edit', $user->name);
} else {
Flash::set('error', __('User has not been saved!'));
}
if (AuthUser::getId() == $id) {
redirect(get_url('user/edit/' . $id));
} else {
redirect(get_url('user'));
}
}