User Profile picture

Allows to add picture to user for use in themes
To avoid errors :
- Add “pictures” folder to content
- Add "picture" to admin entry in database
This commit is contained in:
Xavier Olland 2015-10-06 16:52:16 +03:00
parent a1bfc15298
commit edc4f72f6b
18 changed files with 52 additions and 11 deletions

View File

@ -406,3 +406,6 @@ div.pluginBox span.version {
li.active { li.active {
border-bottom: 2px solid #ccc; border-bottom: 2px solid #ccc;
} }
/* ----------- PROFILE-PICTURE ----------- */
#profilePicture { width:50px; height:50px; border-radius:50%; float:left;}

View File

@ -17,7 +17,7 @@
<!-- ===================================== --> <!-- ===================================== -->
<div id="profile"> <div id="profile">
<form method="post" action="" class="forms"> <form method="post" action="" class="forms" enctype="multipart/form-data">
<input type="hidden" id="jstoken" name="token" value="<?php $Security->printToken() ?>"> <input type="hidden" id="jstoken" name="token" value="<?php $Security->printToken() ?>">
<input type="hidden" name="username" value="<?php echo $_user['username'] ?>"> <input type="hidden" name="username" value="<?php echo $_user['username'] ?>">
@ -30,6 +30,15 @@
<?php $Language->p('Last name') ?> <?php $Language->p('Last name') ?>
<input type="text" name="lastName" class="width-50" value="<?php echo $_user['lastName'] ?>"> <input type="text" name="lastName" class="width-50" value="<?php echo $_user['lastName'] ?>">
</label> </label>
<!-- Picture -->
<label>
<?php $Language->p('Profile picture') ?><br/>
<?php if($_user['picture']) { ?>
<img id="profilePicture" src="<?php echo HTML_PATH_PICTURES.trim($_user['username']).'.'.$_user['picture'].'?'.$_user['updated'] ?>">
<?php } ?>
<input type="file" name="profilePicture" id="fileToUpload">
</label><br/>
<?php if($Login->username()==='admin') { ?> <?php if($Login->username()==='admin') { ?>

View File

@ -156,6 +156,7 @@ define('HTML_PATH_ADMIN_THEME_JS', HTML_PATH_ADMIN_THEME.'js/');
define('HTML_PATH_ADMIN_ROOT', HTML_PATH_ROOT.'admin/'); define('HTML_PATH_ADMIN_ROOT', HTML_PATH_ROOT.'admin/');
define('HTML_PATH_UPLOADS', HTML_PATH_ROOT.'content/uploads/'); define('HTML_PATH_UPLOADS', HTML_PATH_ROOT.'content/uploads/');
define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'plugins/'); define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'plugins/');
define('HTML_PATH_PICTURES', HTML_PATH_ROOT.'content/pictures/');
define('JQUERY', HTML_PATH_ADMIN_THEME_JS.'jquery.min.js'); define('JQUERY', HTML_PATH_ADMIN_THEME_JS.'jquery.min.js');

View File

@ -7,6 +7,7 @@ class dbUsers extends dbJSON
'lastName'=> array('inFile'=>false, 'value'=>''), 'lastName'=> array('inFile'=>false, 'value'=>''),
'username'=> array('inFile'=>false, 'value'=>''), 'username'=> array('inFile'=>false, 'value'=>''),
'role'=> array('inFile'=>false, 'value'=>'editor'), 'role'=> array('inFile'=>false, 'value'=>'editor'),
'picture'=> array('inFile'=>false, 'value'=>''),
'password'=> array('inFile'=>false, 'value'=>''), 'password'=> array('inFile'=>false, 'value'=>''),
'salt'=> array('inFile'=>false, 'value'=>'!Pink Floyd!Welcome to the machine!'), 'salt'=> array('inFile'=>false, 'value'=>'!Pink Floyd!Welcome to the machine!'),
'email'=> array('inFile'=>false, 'value'=>''), 'email'=> array('inFile'=>false, 'value'=>''),
@ -80,6 +81,19 @@ class dbUsers extends dbJSON
} }
} }
//Profile picture upload
$imageFormat = pathinfo($_FILES['profilePicture']['name'],PATHINFO_EXTENSION);
$target_file = 'content/pictures/'.$args['username'].'.'.$imageFormat;
if (move_uploaded_file($_FILES['profilePicture']['tmp_name'], $target_file)) {
$user['picture'] = $imageFormat;
} else {
'Error occured when trying to upload your file.';
}
// Saving modification time
$user['updated'] = Date::unixTime();
// Save the database // Save the database
$this->db[$args['username']] = $user; $this->db[$args['username']] = $user;
if( $this->save() === false ) { if( $this->save() === false ) {

View File

@ -15,6 +15,7 @@
"editor": "Editor", "editor": "Editor",
"dashboard": "Nástěnka", "dashboard": "Nástěnka",
"role": "Úroveň", "role": "Úroveň",
"profile-picture": "Profile picture",
"post": "Zveřejnit", "post": "Zveřejnit",
"posts": "Počet příspěvků", "posts": "Počet příspěvků",
"users": "Počet uživatelů", "users": "Počet uživatelů",

View File

@ -15,6 +15,7 @@
"editor": "Editor", "editor": "Editor",
"dashboard": "Dashboard", "dashboard": "Dashboard",
"role": "Rolle", "role": "Rolle",
"profile-picture": "Profil-bild",
"post": "Beitrag", "post": "Beitrag",
"posts": "Beiträge", "posts": "Beiträge",
"users": "Benutzer", "users": "Benutzer",

View File

@ -15,6 +15,7 @@
"editor": "Editor", "editor": "Editor",
"dashboard": "Dashboard", "dashboard": "Dashboard",
"role": "Role", "role": "Role",
"profile-picture": "Profile picture",
"post": "Post", "post": "Post",
"posts": "Posts", "posts": "Posts",
"users": "Users", "users": "Users",

View File

@ -15,6 +15,7 @@
"editor": "Editor", "editor": "Editor",
"dashboard": "Panel", "dashboard": "Panel",
"role": "Rol", "role": "Rol",
"profile-picture": "Profile picture",
"post": "Post", "post": "Post",
"posts": "Posts", "posts": "Posts",
"users": "Usuarios", "users": "Usuarios",

View File

@ -15,6 +15,7 @@
"editor": "Editor", "editor": "Editor",
"dashboard": "Panel", "dashboard": "Panel",
"role": "Rol", "role": "Rol",
"profile-picture": "Profile picture",
"post": "Post", "post": "Post",
"posts": "Posts", "posts": "Posts",
"users": "Usuarios", "users": "Usuarios",

View File

@ -15,6 +15,7 @@
"editor": "Editor", "editor": "Editor",
"dashboard": "Tablero", "dashboard": "Tablero",
"role": "Papel", "role": "Papel",
"profile-picture": "Profile picture",
"post": "Mensaje", "post": "Mensaje",
"posts": "Entrada", "posts": "Entrada",
"users": "Usuarios", "users": "Usuarios",

View File

@ -15,6 +15,7 @@
"editor": "Rédacteur", "editor": "Rédacteur",
"dashboard": "Tableau de bord", "dashboard": "Tableau de bord",
"role": "Rôle", "role": "Rôle",
"profile-picture": "Photo de profil",
"post": "Article", "post": "Article",
"posts": "Articles", "posts": "Articles",
"users": "Utilisateurs", "users": "Utilisateurs",

View File

@ -15,6 +15,7 @@
"editor": "Editor", "editor": "Editor",
"dashboard": "Dasbor", "dashboard": "Dasbor",
"role": "Peran", "role": "Peran",
"profile-picture": "Profile picture",
"post": "Posting", "post": "Posting",
"posts": "Posting", "posts": "Posting",
"users": "Pengguna", "users": "Pengguna",

View File

@ -15,6 +15,7 @@
"editor": "編集者", "editor": "編集者",
"dashboard": "ダッシュボード", "dashboard": "ダッシュボード",
"role": "役割", "role": "役割",
"profile-picture": "Profile picture",
"posts": "記事", "posts": "記事",
"users": "ユーザー", "users": "ユーザー",
"administrator": "管理者", "administrator": "管理者",

View File

@ -15,6 +15,7 @@
"editor": "Edytor", "editor": "Edytor",
"dashboard": "Pulpit nawigacyjny", "dashboard": "Pulpit nawigacyjny",
"role": "Rola", "role": "Rola",
"profile-picture": "Profile picture",
"post": "Post", "post": "Post",
"posts": "Posty", "posts": "Posty",
"users": "Użytkownicy", "users": "Użytkownicy",

View File

@ -15,6 +15,7 @@
"editor": "Editor", "editor": "Editor",
"dashboard": "Painel", "dashboard": "Painel",
"role": "Cargo", "role": "Cargo",
"profile-picture": "Profile picture",
"post": "Postagem", "post": "Postagem",
"posts": "Postagens", "posts": "Postagens",
"users": "Usuários", "users": "Usuários",

View File

@ -15,6 +15,7 @@
"editor": "Редактор", "editor": "Редактор",
"dashboard": "Панель управления", "dashboard": "Панель управления",
"role": "Роль", "role": "Роль",
"profile-picture": "Profile picture",
"post": "Запись", "post": "Запись",
"posts": "Записи", "posts": "Записи",
"users": "Пользователи", "users": "Пользователи",

View File

@ -15,6 +15,7 @@
"editor": "Редактор", "editor": "Редактор",
"dashboard": "Панель управління", "dashboard": "Панель управління",
"role": "Роль", "role": "Роль",
"profile-picture": "Profile picture",
"post": "Запис", "post": "Запис",
"posts": "Записи", "posts": "Записи",
"users": "Користувачі", "users": "Користувачі",

View File

@ -15,6 +15,7 @@
"editor": "作者", "editor": "作者",
"dashboard": "主頁面", "dashboard": "主頁面",
"role": "角色", "role": "角色",
"profile-picture": "Profile picture",
"post": "文章", "post": "文章",
"posts": "文章", "posts": "文章",
"users": "使用者", "users": "使用者",