Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
a58d2706
Commit
a58d2706
authored
11 years ago
by
Christopher Schäpers
Browse files
Options
Downloads
Patches
Plain Diff
Load avatar from path, if one's provided
parent
2bfe6622
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/avatar.php
+6
-6
6 additions, 6 deletions
lib/avatar.php
settings/ajax/newavatar.php
+3
-7
3 additions, 7 deletions
settings/ajax/newavatar.php
with
9 additions
and
13 deletions
lib/avatar.php
+
6
−
6
View file @
a58d2706
...
...
@@ -42,21 +42,21 @@ class OC_Avatar {
/**
* @brief sets the users local avatar
* @param $user string user to set the avatar for
* @param $
img
mixed imagedata to set a new avatar, or false to delete the current avatar
* @param $
data
mixed imagedata
or path
to set a new avatar, or false to delete the current avatar
* @throws Exception if the provided file is not a jpg or png image
* @throws Exception if the provided image is not valid, or not a square
* @return true on success
*/
public
static
function
setLocalAvatar
(
$user
,
$
img
)
{
public
static
function
setLocalAvatar
(
$user
,
$
data
)
{
$view
=
new
\OC\Files\View
(
'/'
.
$user
);
if
(
$
img
===
false
)
{
if
(
$
data
===
false
)
{
$view
->
unlink
(
'avatar.jpg'
);
$view
->
unlink
(
'avatar.png'
);
return
true
;
}
else
{
$img
=
new
OC_Image
(
$
img
);
// FIXME this always says "image/png"
$img
=
new
OC_Image
(
$
data
);
// FIXME this always says "image/png"
, when loading from data
$type
=
substr
(
$img
->
mimeType
(),
-
3
);
if
(
$type
===
'peg'
)
{
$type
=
'jpg'
;
}
if
(
$type
!==
'jpg'
&&
$type
!==
'png'
)
{
...
...
@@ -69,7 +69,7 @@ class OC_Avatar {
$view
->
unlink
(
'avatar.jpg'
);
$view
->
unlink
(
'avatar.png'
);
$view
->
file_put_contents
(
'avatar.'
.
$type
,
$
img
);
$view
->
file_put_contents
(
'avatar.'
.
$type
,
$
data
);
return
true
;
}
}
...
...
This diff is collapsed.
Click to expand it.
settings/ajax/newavatar.php
+
3
−
7
View file @
a58d2706
...
...
@@ -5,16 +5,12 @@ OC_JSON::callCheck();
$user
=
OC_User
::
getUser
();
if
(
isset
(
$_POST
[
'path'
]))
{
$path
=
$_POST
[
'path'
];
if
(
$path
===
"false"
)
{
// delete avatar
if
(
$_POST
[
'path'
]
===
"false"
)
{
// delete avatar
\OC_Avatar
::
setLocalAvatar
(
$user
,
false
);
}
else
{
// select an image from own files
$view
=
new
\OC\Files\View
(
'/'
.
$user
.
'/files'
);
$img
=
$view
->
file_get_contents
(
$path
);
$type
=
substr
(
$path
,
-
3
);
try
{
\OC_Avatar
::
setLocalAvatar
(
$user
,
$img
);
$path
=
OC
::
$SERVERROOT
.
'/data/'
.
$user
.
'/files'
.
$_POST
[
'path'
];
\OC_Avatar
::
setLocalAvatar
(
$user
,
$path
);
OC_JSON
::
success
();
}
catch
(
Exception
$e
)
{
OC_JSON
::
error
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment