Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
4a08f7d7
Commit
4a08f7d7
authored
Jul 26, 2013
by
kondou
Browse files
Add basic avatars and gravatar
parent
b8965c61
Changes
13
Hide whitespace changes
Inline
Side-by-side
config/config.sample.php
View file @
4a08f7d7
...
...
@@ -65,6 +65,12 @@ $CONFIG = array(
/* URL to the parent directory of the 3rdparty directory, as seen by the browser */
"3rdpartyurl"
=>
""
,
/* What avatars to use.
* May be "none" for none, "local" for uploaded avatars, or "gravatar" for gravatars.
* Default is "local".
*/
"avatars"
=>
"local"
,
/* Default app to load on login */
"defaultapp"
=>
"files"
,
...
...
core/img/defaultavatar.png
0 → 100644
View file @
4a08f7d7
12.2 KB
core/templates/layout.user.php
View file @
4a08f7d7
...
...
@@ -47,6 +47,7 @@
<div
id=
"logo-claim"
style=
"display:none;"
>
<?php
p
(
$theme
->
getLogoClaim
());
?>
</div>
<ul
id=
"settings"
class=
"svg"
>
<span
id=
"expand"
tabindex=
"0"
role=
"link"
>
<?php
if
(
isset
(
$_
[
'avatar'
]))
{
print_unescaped
(
$_
[
'avatar'
]);
}
?>
<span
id=
"expandDisplayName"
>
<?php
p
(
trim
(
$_
[
'user_displayname'
])
!=
''
?
$_
[
'user_displayname'
]
:
$_
[
'user_uid'
])
?>
</span>
<img
class=
"svg"
src=
"
<?php
print_unescaped
(
image_path
(
''
,
'actions/caret.svg'
));
?>
"
/>
</span>
...
...
lib/avatar.php
0 → 100644
View file @
4a08f7d7
<?php
/**
* Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
class
OC_Avatar
{
/**
* @brief gets the users avatar
* @param $user string username
* @param $size integer size in px of the avatar, defaults to 64
* @return mixed link to the avatar, false if avatars are disabled
*/
public
static
function
get
(
$user
,
$size
=
64
)
{
$mode
=
OC_Config
::
getValue
(
"avatar"
,
"local"
);
if
(
$mode
===
"none"
)
{
// avatars are disabled
return
false
;
}
elseif
(
$mode
===
"gravatar"
)
{
$email
=
OC_Preferences
::
getValue
(
$user
,
'settings'
,
'email'
);
if
(
$email
!==
null
)
{
$emailhash
=
md5
(
strtolower
(
trim
(
$email
)));
$url
=
"http://www.gravatar.com/avatar/"
.
$emailhash
.
"?s="
.
$size
;
return
$url
;
}
else
{
return
\
OC_Avatar
::
getDefaultAvatar
(
$size
);
}
}
elseif
(
$mode
===
"local"
)
{
if
(
false
)
{
//
}
else
{
return
\
OC_Avatar
::
getDefaultAvatar
(
$size
);
}
}
}
/**
* @brief sets the users local avatar
* @param $user string user to set the avatar for
* @param $path string path where the avatar is
* @return true on success
*/
public
static
function
setLocalAvatar
(
$user
,
$path
)
{
if
(
OC_Config
::
getValue
(
"avatar"
,
"local"
)
===
"local"
)
{
//
}
}
/**
* @brief gets the default avatar
* @return link to the default avatar
*/
public
static
function
getDefaultAvatar
(
$size
)
{
return
OC_Helper
::
imagePath
(
"core"
,
"defaultavatar.png"
);
}
}
lib/public/avatar.php
0 → 100644
View file @
4a08f7d7
<?php
/**
* Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace
OCP
;
class
Avatar
{
public
static
function
get
(
$user
,
$size
=
64
)
{
\
OC_Avatar
::
get
(
$user
,
$size
);
}
}
lib/templatelayout.php
View file @
4a08f7d7
...
...
@@ -18,6 +18,11 @@ class OC_TemplateLayout extends OC_Template {
$this
->
assign
(
'bodyid'
,
'body-user'
);
}
// display avatars if they are enabled
if
(
OC_Config
::
getValue
(
'avatar'
)
===
'gravatar'
||
OC_Config
::
getValue
(
'avatar'
)
===
'local'
)
{
$this
->
assign
(
'avatar'
,
'<img src="'
.
OC_Avatar
::
get
(
OC_User
::
getUser
(),
32
)
.
'">'
);
}
// Update notification
if
(
OC_Config
::
getValue
(
'updatechecker'
,
true
)
===
true
)
{
$data
=
OC_Updater
::
check
();
...
...
settings/admin.php
View file @
4a08f7d7
...
...
@@ -30,6 +30,7 @@ $tmpl->assign('isWebDavWorking', OC_Util::isWebDAVWorking());
$tmpl
->
assign
(
'has_fileinfo'
,
OC_Util
::
fileInfoLoaded
());
$tmpl
->
assign
(
'backgroundjobs_mode'
,
OC_Appconfig
::
getValue
(
'core'
,
'backgroundjobs_mode'
,
'ajax'
));
$tmpl
->
assign
(
'shareAPIEnabled'
,
OC_Appconfig
::
getValue
(
'core'
,
'shareapi_enabled'
,
'yes'
));
$tmpl
->
assign
(
'avatar'
,
OC_Config
::
getValue
(
"avatar"
,
"local"
));
// Check if connected using HTTPS
if
(
OC_Request
::
serverProtocol
()
===
'https'
)
{
...
...
settings/ajax/setavatarmode.php
0 → 100644
View file @
4a08f7d7
<?php
/**
* Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
OC_Util
::
checkAdminUser
();
OCP\JSON
::
callCheck
();
OC_Config
::
setValue
(
'avatar'
,
$_POST
[
'mode'
]);
settings/js/admin.js
View file @
4a08f7d7
...
...
@@ -14,6 +14,12 @@ $(document).ready(function(){
}
});
$
(
'
#avatar input
'
).
change
(
function
(){
if
(
$
(
this
).
attr
(
'
checked
'
))
{
$
.
post
(
OC
.
filePath
(
'
settings
'
,
'
ajax
'
,
'
setavatarmode.php
'
),
{
mode
:
$
(
this
).
val
()});
}
});
$
(
'
#shareAPIEnabled
'
).
change
(
function
()
{
$
(
'
.shareAPI td:not(#enable)
'
).
toggle
();
});
...
...
settings/personal.php
View file @
4a08f7d7
...
...
@@ -84,6 +84,7 @@ $tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User:
$tmpl
->
assign
(
'displayNameChangeSupported'
,
OC_User
::
canUserChangeDisplayName
(
OC_User
::
getUser
()));
$tmpl
->
assign
(
'displayName'
,
OC_User
::
getDisplayName
());
$tmpl
->
assign
(
'enableDecryptAll'
,
$enableDecryptAll
);
$tmpl
->
assign
(
'avatar'
,
OC_Config
::
getValue
(
'avatar'
,
'local'
));
$forms
=
OC_App
::
getForms
(
'personal'
);
$tmpl
->
assign
(
'forms'
,
array
());
...
...
settings/routes.php
View file @
4a08f7d7
...
...
@@ -70,3 +70,5 @@ $this->create('settings_ajax_setsecurity', '/settings/ajax/setsecurity.php')
->
actionInclude
(
'settings/ajax/setsecurity.php'
);
$this
->
create
(
'isadmin'
,
'/settings/js/isadmin.js'
)
->
actionInclude
(
'settings/js/isadmin.php'
);
$this
->
create
(
'settings_ajax_setavatarmode'
,
'/settings/ajax/setavatarmode.php'
)
->
actionInclude
(
'settings/ajax/setavatarmode.php'
);
settings/templates/admin.php
View file @
4a08f7d7
...
...
@@ -116,6 +116,43 @@ if (!$_['internetconnectionworking']) {
</p>
</fieldset>
<fieldset
class=
"personalblock"
id=
"avatar"
>
<legend><strong>
<?php
p
(
$l
->
t
(
'Avatars'
));
?>
</strong></legend>
<table
class=
"nostyle"
>
<tr>
<td>
<input
type=
"radio"
name=
"avatarmode"
value=
"gravatar"
id=
"avatar_gravatar"
<?php
if
(
$_
[
'avatar'
]
===
"gravatar"
)
{
print_unescaped
(
'checked="checked"'
);
}
?>
>
<label
for=
"avatar_gravatar"
>
Gravatar
</label><br>
<em>
<?php
print_unescaped
(
$l
->
t
(
'Use <a href="http://gravatar.com/">gravatar</a> for avatars'
));
?>
</em><br>
<em>
<?php
p
(
$l
->
t
(
'This sends data to gravatar'
));
?>
</em>
</td>
</tr>
<tr>
<td>
<input
type=
"radio"
name=
"avatarmode"
value=
"local"
id=
"avatar_local"
<?php
if
(
$_
[
'avatar'
]
===
"local"
)
{
print_unescaped
(
'checked="checked"'
);
}
?>
>
<label
for=
"avatar_local"
>
<?php
p
(
$l
->
t
(
'Local avatars'
));
?>
</label><br>
<em>
<?php
p
(
$l
->
t
(
'Use local avatars, which each user has to upload themselves'
));
?>
</em>
</td>
</tr>
<tr>
<td>
<input
type=
"radio"
name=
"avatarmode"
value=
"none"
id=
"avatar_none"
<?php
if
(
$_
[
'avatar'
]
===
"none"
)
{
print_unescaped
(
'checked="checked"'
);
}
?>
>
<label
for=
"avatar_none"
>
<?php
p
(
$l
->
t
(
'No avatars'
));
?>
</label><br>
<em>
<?php
print_unescaped
(
$l
->
t
(
'Do not provide avatars'
));
?>
</em>
</td>
</tr>
</table>
</fieldset>
<fieldset
class=
"personalblock"
id=
"shareAPI"
>
<legend><strong>
<?php
p
(
$l
->
t
(
'Sharing'
));
?>
</strong></legend>
<table
class=
"shareAPI nostyle"
>
...
...
settings/templates/personal.php
View file @
4a08f7d7
...
...
@@ -74,12 +74,25 @@ if($_['passwordChangeSupported']) {
<input
type=
"text"
name=
"email"
id=
"email"
value=
"
<?php
p
(
$_
[
'email'
]);
?>
"
placeholder=
"
<?php
p
(
$l
->
t
(
'Your email address'
));
?>
"
/><span
class=
"msg"
></span><br
/>
<em>
<?php
p
(
$l
->
t
(
'Fill in an email address to enable password recovery'
));
?>
</em>
<?php
if
(
$_
[
'avatar'
]
===
"gravatar"
)
{
print_unescaped
(
$l
->
t
(
'<br><em>Your Email will be used for your gravatar<em>'
));
}
?>
</fieldset>
</form>
<?php
}
?>
<?php
if
(
$_
[
'avatar'
]
===
"local"
)
:
?>
<form
id=
"avatar"
>
<fieldset
class=
"personalblock"
>
<legend><strong>
<?php
p
(
$l
->
t
(
'Avatar'
));
?>
</strong></legend>
<img
src=
"
<?php
print_unescaped
(
\
OC_Avatar
::
get
(
\
OC_User
::
getUser
()));
?>
"
><br>
<button>
<?php
p
(
$l
->
t
(
'Upload a new avatar'
));
?>
</button>
</fieldset>
</form>
<?php
endif
;
?>
<form>
<fieldset
class=
"personalblock"
>
<legend><strong>
<?php
p
(
$l
->
t
(
'Language'
));
?>
</strong></legend>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment