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 {
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">
<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" name="username" value="<?php echo $_user['username'] ?>">
@ -30,6 +30,15 @@
<?php $Language->p('Last name') ?>
<input type="text" name="lastName" class="width-50" value="<?php echo $_user['lastName'] ?>">
</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') { ?>

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_UPLOADS', HTML_PATH_ROOT.'content/uploads/');
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');

View File

@ -7,6 +7,7 @@ class dbUsers extends dbJSON
'lastName'=> array('inFile'=>false, 'value'=>''),
'username'=> array('inFile'=>false, 'value'=>''),
'role'=> array('inFile'=>false, 'value'=>'editor'),
'picture'=> array('inFile'=>false, 'value'=>''),
'password'=> array('inFile'=>false, 'value'=>''),
'salt'=> array('inFile'=>false, 'value'=>'!Pink Floyd!Welcome to the machine!'),
'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
$this->db[$args['username']] = $user;
if( $this->save() === false ) {

View File

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

View File

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

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": "Panel",
"role": "Rol",
"profile-picture": "Profile picture",
"post": "Post",
"posts": "Posts",
"users": "Usuarios",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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