parent
b8965c6107
commit
4a08f7d710
|
After Width: | Height: | Size: 12 KiB |
@ -0,0 +1,59 @@ |
||||
<?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"); |
||||
} |
||||
} |
||||
@ -0,0 +1,15 @@ |
||||
<?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); |
||||
} |
||||
} |
||||
@ -0,0 +1,12 @@ |
||||
<?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']); |
||||
Loading…
Reference in new issue