Remove gravatar and no-avatar functionality, prepare for default avatars even more and reword some stuff
This commit is contained in:
parent
960262bbb4
commit
81cadd5ea3
11
avatar.php
11
avatar.php
|
@ -7,11 +7,6 @@ if (!\OC_User::isLoggedIn()) {
|
||||||
\OC_Template::printErrorPage("Permission denied");
|
\OC_Template::printErrorPage("Permission denied");
|
||||||
}
|
}
|
||||||
|
|
||||||
$mode = \OC_Avatar::getMode();
|
|
||||||
if ($mode === "none") {
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === "GET") {
|
if ($_SERVER['REQUEST_METHOD'] === "GET") {
|
||||||
if (isset($_GET['user'])) {
|
if (isset($_GET['user'])) {
|
||||||
//SECURITY TODO does this fully eliminate directory traversals?
|
//SECURITY TODO does this fully eliminate directory traversals?
|
||||||
|
@ -33,8 +28,6 @@ if ($_SERVER['REQUEST_METHOD'] === "GET") {
|
||||||
|
|
||||||
if ($image instanceof \OC_Image) {
|
if ($image instanceof \OC_Image) {
|
||||||
$image->show();
|
$image->show();
|
||||||
} elseif (is_string($image)) { // Gravatar alike services
|
|
||||||
header("Location: ".$image);
|
|
||||||
} else {
|
} else {
|
||||||
$image = \OC_Avatar::getDefaultAvatar($user, $size);
|
$image = \OC_Avatar::getDefaultAvatar($user, $size);
|
||||||
$image->show();
|
$image->show();
|
||||||
|
@ -60,7 +53,7 @@ if ($_SERVER['REQUEST_METHOD'] === "GET") {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
\OC_Avatar::setLocalAvatar($user, $avatar);
|
\OC_Avatar::set($user, $avatar);
|
||||||
OC_JSON::success();
|
OC_JSON::success();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
OC_JSON::error(array("data" => array ("message" => $e->getMessage()) ));
|
OC_JSON::error(array("data" => array ("message" => $e->getMessage()) ));
|
||||||
|
@ -69,7 +62,7 @@ if ($_SERVER['REQUEST_METHOD'] === "GET") {
|
||||||
$user = OC_User::getUser();
|
$user = OC_User::getUser();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
\OC_Avatar::setLocalAvatar($user, false);
|
\OC_Avatar::set($user, false);
|
||||||
OC_JSON::success();
|
OC_JSON::success();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
OC_JSON::error(array("data" => array ("message" => $e->getMessage()) ));
|
OC_JSON::error(array("data" => array ("message" => $e->getMessage()) ));
|
||||||
|
|
|
@ -65,12 +65,6 @@ $CONFIG = array(
|
||||||
/* URL to the parent directory of the 3rdparty directory, as seen by the browser */
|
/* URL to the parent directory of the 3rdparty directory, as seen by the browser */
|
||||||
"3rdpartyurl" => "",
|
"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 */
|
/* Default app to load on login */
|
||||||
"defaultapp" => "files",
|
"defaultapp" => "files",
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
136
lib/avatar.php
136
lib/avatar.php
|
@ -8,105 +8,20 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class gets and sets users avatars.
|
* This class gets and sets users avatars.
|
||||||
* Available backends are local (saved in users root at avatar.[png|jpg]), gravatar TODO and custom backends.
|
*/
|
||||||
* However the get function is easy to extend with further backends.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class OC_Avatar {
|
class OC_Avatar {
|
||||||
/**
|
/**
|
||||||
* @brief gets the users avatar
|
* @brief get the users avatar
|
||||||
* @param $user string username, if not provided, the default avatar will be returned
|
* @param $user string which user to get the avatar for
|
||||||
* @param $size integer size in px of the avatar, defaults to 64
|
* @param $size integer size in px of the avatar, defaults to 64
|
||||||
* @return mixed \OC_Image containing the avatar, a link to the avatar, false if avatars are disabled
|
* @return \OC_Image containing the avatar
|
||||||
*/
|
*/
|
||||||
public static function get ($user = false, $size = 64) {
|
public static function get ($user, $size = 64) {
|
||||||
$mode = self::getMode();
|
|
||||||
if ($mode === "none") {
|
|
||||||
// avatars are disabled
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if ($user === false) {
|
if ($user === false) {
|
||||||
return self::getDefaultAvatar($size);
|
|
||||||
} elseif ($mode === "gravatar") {
|
|
||||||
return self::getGravatar($user, $size);
|
|
||||||
} elseif ($mode === "local") {
|
|
||||||
return self::getLocalAvatar($user, $size);
|
|
||||||
} elseif ($mode === "custom") {
|
|
||||||
return self::getCustomAvatar($user, $size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief returns the active avatar mode
|
|
||||||
* @return string active avatar mode
|
|
||||||
*/
|
|
||||||
public static function getMode () {
|
|
||||||
return \OC_Config::getValue("avatar", "local");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief sets the users local avatar
|
|
||||||
* @param $user string user to set the avatar for
|
|
||||||
* @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, $data) {
|
|
||||||
$view = new \OC\Files\View('/'.$user);
|
|
||||||
|
|
||||||
if ($data === false) {
|
|
||||||
$view->unlink('avatar.jpg');
|
|
||||||
$view->unlink('avatar.png');
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
$img = new OC_Image($data);
|
|
||||||
$type = substr($img->mimeType(), -3);
|
|
||||||
if ($type === 'peg') { $type = 'jpg'; }
|
|
||||||
if ($type !== 'jpg' && $type !== 'png') {
|
|
||||||
$l = \OC_L10N::get('lib');
|
|
||||||
throw new \Exception($l->t("Unknown filetype for avatar"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!( $img->valid() && ($img->height() === $img->width()) )) {
|
|
||||||
$l = \OC_L10N::get('lib');
|
|
||||||
throw new \Exception($l->t("Invalid image, or the provided image is not square"));
|
|
||||||
}
|
|
||||||
|
|
||||||
$view->unlink('avatar.jpg');
|
|
||||||
$view->unlink('avatar.png');
|
|
||||||
$view->file_put_contents('avatar.'.$type, $data);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief get the users gravatar
|
|
||||||
* @param $user string which user to get the gravatar for
|
|
||||||
* @param $size integer size in px of the avatar, defaults to 64
|
|
||||||
* @return string link to the gravatar, or \OC_Image with the default avatar
|
|
||||||
*/
|
|
||||||
public static function getGravatar ($user, $size = 64) {
|
|
||||||
$email = \OC_Preferences::getValue($user, 'settings', 'email');
|
|
||||||
if ($email !== null) {
|
|
||||||
$emailhash = md5(strtolower(trim($email)));
|
|
||||||
$url = "http://secure.gravatar.com/avatar/".$emailhash."?d=404&s=".$size;
|
|
||||||
$headers = get_headers($url, 1);
|
|
||||||
if (strpos($headers[0], "404 Not Found") === false) {
|
|
||||||
return $url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return self::getDefaultAvatar($user, $size);
|
return self::getDefaultAvatar($user, $size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief get the local avatar
|
|
||||||
* @param $user string which user to get the avatar for
|
|
||||||
* @param $size integer size in px of the avatar, defaults to 64
|
|
||||||
* @return string \OC_Image containing the avatar
|
|
||||||
*/
|
|
||||||
public static function getLocalAvatar ($user, $size = 64) {
|
|
||||||
$view = new \OC\Files\View('/'.$user);
|
$view = new \OC\Files\View('/'.$user);
|
||||||
|
|
||||||
if ($view->file_exists('avatar.jpg')) {
|
if ($view->file_exists('avatar.jpg')) {
|
||||||
|
@ -123,10 +38,39 @@ class OC_Avatar {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo todo
|
* @brief sets the users avatar
|
||||||
|
* @param $user string user to set the avatar for
|
||||||
|
* @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 getCustomAvatar($user, $size) {
|
public static function set ($user, $data) {
|
||||||
// TODO
|
$view = new \OC\Files\View('/'.$user);
|
||||||
|
|
||||||
|
if ($data === false) {
|
||||||
|
$view->unlink('avatar.jpg');
|
||||||
|
$view->unlink('avatar.png');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$img = new OC_Image($data);
|
||||||
|
$type = substr($img->mimeType(), -3);
|
||||||
|
if ($type === 'peg') { $type = 'jpg'; }
|
||||||
|
if ($type !== 'jpg' && $type !== 'png') {
|
||||||
|
$l = \OC_L10N::get('lib');
|
||||||
|
throw new \Exception($l->t("Unknown filetype"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!( $img->valid() && ($img->height() === $img->width()) )) {
|
||||||
|
$l = \OC_L10N::get('lib');
|
||||||
|
throw new \Exception($l->t("Invalid image, or the provided image is not square"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$view->unlink('avatar.jpg');
|
||||||
|
$view->unlink('avatar.png');
|
||||||
|
$view->file_put_contents('avatar.'.$type, $data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,8 +81,10 @@ class OC_Avatar {
|
||||||
* @todo use custom default images, when they arive
|
* @todo use custom default images, when they arive
|
||||||
*/
|
*/
|
||||||
public static function getDefaultAvatar ($user, $size = 64) {
|
public static function getDefaultAvatar ($user, $size = 64) {
|
||||||
$default = new OC_Image(OC::$SERVERROOT."/core/img/defaultavatar.png");
|
// TODO
|
||||||
|
/*$default = new OC_Image(OC::$SERVERROOT."/core/img/defaultavatar.png");
|
||||||
$default->resize($size);
|
$default->resize($size);
|
||||||
return $default;
|
return $default;*/
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ $tmpl->assign('isWebDavWorking', OC_Util::isWebDAVWorking());
|
||||||
$tmpl->assign('has_fileinfo', OC_Util::fileInfoLoaded());
|
$tmpl->assign('has_fileinfo', OC_Util::fileInfoLoaded());
|
||||||
$tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax'));
|
$tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax'));
|
||||||
$tmpl->assign('shareAPIEnabled', OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes'));
|
$tmpl->assign('shareAPIEnabled', OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes'));
|
||||||
$tmpl->assign('avatar', OC_Config::getValue("avatar", "local"));
|
|
||||||
|
|
||||||
// Check if connected using HTTPS
|
// Check if connected using HTTPS
|
||||||
if (OC_Request::serverProtocol() === 'https') {
|
if (OC_Request::serverProtocol() === 'https') {
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?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']);
|
|
|
@ -14,12 +14,6 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#avatar input').change(function(){
|
|
||||||
if ($(this).attr('checked')) {
|
|
||||||
$.post(OC.filePath('settings', 'ajax', 'setavatarmode.php'), {mode: $(this).val()});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#shareAPIEnabled').change(function() {
|
$('#shareAPIEnabled').change(function() {
|
||||||
$('.shareAPI td:not(#enable)').toggle();
|
$('.shareAPI td:not(#enable)').toggle();
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,9 +15,7 @@ OC_Util::addScript( 'settings', 'personal' );
|
||||||
OC_Util::addStyle( 'settings', 'settings' );
|
OC_Util::addStyle( 'settings', 'settings' );
|
||||||
OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' );
|
OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' );
|
||||||
OC_Util::addStyle( '3rdparty', 'chosen' );
|
OC_Util::addStyle( '3rdparty', 'chosen' );
|
||||||
if (OC_Config::getValue('avatar', 'local') === 'local') {
|
\OC_Util::addScript('files', 'jquery.fileupload');
|
||||||
\OC_Util::addScript('files', 'jquery.fileupload');
|
|
||||||
}
|
|
||||||
OC_App::setActiveNavigationEntry( 'personal' );
|
OC_App::setActiveNavigationEntry( 'personal' );
|
||||||
|
|
||||||
$storageInfo=OC_Helper::getStorageInfo();
|
$storageInfo=OC_Helper::getStorageInfo();
|
||||||
|
|
|
@ -70,5 +70,3 @@ $this->create('settings_ajax_setsecurity', '/settings/ajax/setsecurity.php')
|
||||||
->actionInclude('settings/ajax/setsecurity.php');
|
->actionInclude('settings/ajax/setsecurity.php');
|
||||||
$this->create('isadmin', '/settings/js/isadmin.js')
|
$this->create('isadmin', '/settings/js/isadmin.js')
|
||||||
->actionInclude('settings/js/isadmin.php');
|
->actionInclude('settings/js/isadmin.php');
|
||||||
$this->create('settings_ajax_setavatarmode', '/settings/ajax/setavatarmode.php')
|
|
||||||
->actionInclude('settings/ajax/setavatarmode.php');
|
|
||||||
|
|
|
@ -116,33 +116,6 @@ if (!$_['internetconnectionworking']) {
|
||||||
</p>
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="personalblock" id="avatar">
|
|
||||||
<legend><strong><?php p($l->t('Profile images')); ?></strong></legend>
|
|
||||||
<p>
|
|
||||||
<input type="radio" name="avatarmode" value="gravatar" id="avatar_gravatar"
|
|
||||||
<?php if ($_['avatar'] === "gravatar") { p('checked'); } ?>
|
|
||||||
<?php if (!$_['internetconnectionworking']) { p('disabled'); } ?>>
|
|
||||||
<label for="avatar_gravatar">Gravatar</label><br>
|
|
||||||
<em><?php print_unescaped($l->t('Use <a href="http://gravatar.com/">gravatar</a> for profile images')); ?></em><br>
|
|
||||||
<em><?php p($l->t('This sends data to gravatar and may slow down loading')); ?></em>
|
|
||||||
<?php if (!$_['internetconnectionworking']): ?>
|
|
||||||
<br><em><?php p($l->t('Gravatar needs an internet connection!')); ?></em>
|
|
||||||
<?php endif; ?>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<input type="radio" name="avatarmode" value="local" id="avatar_local"
|
|
||||||
<?php if ($_['avatar'] === "local") { p('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>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<input type="radio" name="avatarmode" value="none" id="avatar_none"
|
|
||||||
<?php if ($_['avatar'] === "none") { p('checked'); } ?>>
|
|
||||||
<label for="avatar_none"><?php p($l->t('No avatars')); ?></label><br>
|
|
||||||
<em><?php p($l->t('Do not provide avatars')); ?></em>
|
|
||||||
</p>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<fieldset class="personalblock" id="shareAPI">
|
<fieldset class="personalblock" id="shareAPI">
|
||||||
<legend><strong><?php p($l->t('Sharing'));?></strong></legend>
|
<legend><strong><?php p($l->t('Sharing'));?></strong></legend>
|
||||||
<table class="shareAPI nostyle">
|
<table class="shareAPI nostyle">
|
||||||
|
|
|
@ -83,26 +83,17 @@ if($_['passwordChangeSupported']) {
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if ($_['avatar'] !== "none"): ?>
|
|
||||||
<form id="avatar" method="post" action="<?php p(\OC_Helper::linkTo('', 'avatar.php')); ?>">
|
<form id="avatar" method="post" action="<?php p(\OC_Helper::linkTo('', 'avatar.php')); ?>">
|
||||||
<fieldset class="personalblock">
|
<fieldset class="personalblock">
|
||||||
<legend><strong><?php p($l->t('Profile Image')); ?></strong></legend>
|
<legend><strong><?php p($l->t('Profile Image')); ?></strong></legend>
|
||||||
<img src="<?php print_unescaped(link_to('', 'avatar.php').'?user='.OC_User::getUser().'&size=128'); ?>"><br>
|
<img src="<?php print_unescaped(link_to('', 'avatar.php').'?user='.OC_User::getUser().'&size=128'); ?>"><br>
|
||||||
<?php if ($_['avatar'] === "local"): ?>
|
<em><?php p($l->t('Has to be square and either PNG or JPG')); ?></em><br>
|
||||||
<em><?php p($l->t('Your profile image has to be a square and either a PNG or JPG image')); ?></em><br>
|
<div class="inlineblock button" id="uploadavatarbutton"><?php p($l->t('Upload new')); ?></div>
|
||||||
<div class="inlineblock button" id="uploadavatarbutton"><?php p($l->t('Upload a new image')); ?></div>
|
|
||||||
<input type="file" class="hidden" name="files[]" id="uploadavatar">
|
<input type="file" class="hidden" name="files[]" id="uploadavatar">
|
||||||
<div class="inlineblock button" id="selectavatar"><?php p($l->t('Select a new image from your files')); ?></div>
|
<div class="inlineblock button" id="selectavatar"><?php p($l->t('Select new from files')); ?></div>
|
||||||
<div class="inlineblock button" id="removeavatar"><?php p($l->t('Remove my image')); ?></div>
|
<div class="inlineblock button" id="removeavatar"><?php p($l->t('Remove image')); ?></div>
|
||||||
<?php elseif ($_['avatar'] === "gravatar"): ?>
|
|
||||||
<em><?php p($l->t('Your profile image is provided by gravatar, which is based on your Email.')); ?></em>
|
|
||||||
<div class?"inlineblock button" id="overridegravatar"><?php p($l->t('Use my local avatar instead')); ?></div>
|
|
||||||
<?php else: ?>
|
|
||||||
<em><?php p($l->t('Your profile image is provided by a custom service, ask your administrator, on how to change your image.')); ?></em>
|
|
||||||
<?php endif; ?>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<form>
|
<form>
|
||||||
<fieldset class="personalblock">
|
<fieldset class="personalblock">
|
||||||
|
|
|
@ -81,9 +81,7 @@ $_['subadmingroups'] = array_flip($items);
|
||||||
<table class="hascontrols" data-groups="<?php p(json_encode($allGroups));?>">
|
<table class="hascontrols" data-groups="<?php p(json_encode($allGroups));?>">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<?php if(\OC_Avatar::getMode() !== "none"): ?>
|
|
||||||
<th id='headerAvatar'></th>
|
<th id='headerAvatar'></th>
|
||||||
<?php endif; ?>
|
|
||||||
<th id='headerName'><?php p($l->t('Username'))?></th>
|
<th id='headerName'><?php p($l->t('Username'))?></th>
|
||||||
<th id="headerDisplayName"><?php p($l->t( 'Display Name' )); ?></th>
|
<th id="headerDisplayName"><?php p($l->t( 'Display Name' )); ?></th>
|
||||||
<th id="headerPassword"><?php p($l->t( 'Password' )); ?></th>
|
<th id="headerPassword"><?php p($l->t( 'Password' )); ?></th>
|
||||||
|
@ -99,9 +97,7 @@ $_['subadmingroups'] = array_flip($items);
|
||||||
<?php foreach($_["users"] as $user): ?>
|
<?php foreach($_["users"] as $user): ?>
|
||||||
<tr data-uid="<?php p($user["name"]) ?>"
|
<tr data-uid="<?php p($user["name"]) ?>"
|
||||||
data-displayName="<?php p($user["displayName"]) ?>">
|
data-displayName="<?php p($user["displayName"]) ?>">
|
||||||
<?php if(\OC_Avatar::getMode() !== "none"): ?>
|
|
||||||
<td class="avatar"><img src="<?php print_unescaped(link_to('', 'avatar.php')); ?>?user=<?php p($user['name']); ?>&size=32"></td>
|
<td class="avatar"><img src="<?php print_unescaped(link_to('', 'avatar.php')); ?>?user=<?php p($user['name']); ?>&size=32"></td>
|
||||||
<?php endif; ?>
|
|
||||||
<td class="name"><?php p($user["name"]); ?></td>
|
<td class="name"><?php p($user["name"]); ?></td>
|
||||||
<td class="displayName"><span><?php p($user["displayName"]); ?></span> <img class="svg action"
|
<td class="displayName"><span><?php p($user["displayName"]); ?></span> <img class="svg action"
|
||||||
src="<?php p(image_path('core', 'actions/rename.svg'))?>"
|
src="<?php p(image_path('core', 'actions/rename.svg'))?>"
|
||||||
|
|
|
@ -8,51 +8,23 @@
|
||||||
|
|
||||||
class Test_Avatar extends PHPUnit_Framework_TestCase {
|
class Test_Avatar extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
public function testModes() {
|
public function testAvatar() {
|
||||||
$this->assertEquals('local', \OC_Avatar::getMode());
|
|
||||||
|
|
||||||
\OC_Config::setValue('avatar', 'local');
|
|
||||||
$this->assertEquals('local', \OC_Avatar::getMode());
|
|
||||||
|
|
||||||
\OC_Config::setValue('avatar', 'gravatar');
|
|
||||||
$this->assertEquals('gravatar', \OC_Avatar::getMode());
|
|
||||||
|
|
||||||
\OC_Config::setValue('avatar', 'none');
|
|
||||||
$this->assertEquals('none', \OC_Avatar::getMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDisabledAvatar() {
|
|
||||||
\OC_Config::setValue('avatar', 'none');
|
|
||||||
$this->assertFalse(\OC_Avatar::get(\OC_User::getUser()));
|
|
||||||
$this->assertFalse(\OC_Avatar::get(\OC_User::getUser(), 32));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLocalAvatar() {
|
|
||||||
\OC_Config::setValue('avatar', 'local');
|
|
||||||
$expected = \OC_Avatar::getDefaultAvatar()->data();
|
$expected = \OC_Avatar::getDefaultAvatar()->data();
|
||||||
$this->assertEquals($expected, \OC_Avatar::get(\OC_User::getUser())->data());
|
$this->assertEquals($expected, \OC_Avatar::get(\OC_User::getUser())->data());
|
||||||
|
|
||||||
$expected = new OC_Image(\OC::$SERVERROOT.'/tests/data/testavatar.png');
|
$expected = new OC_Image(\OC::$SERVERROOT.'/tests/data/testavatar.png');
|
||||||
\OC_Avatar::setLocalAvatar(\OC_User::getUser(), $expected->data());
|
\OC_Avatar::set(\OC_User::getUser(), $expected->data());
|
||||||
$expected->resize(64);
|
$expected->resize(64);
|
||||||
$this->assertEquals($expected->data(), \OC_Avatar::get(\OC_User::getUser())->data());
|
$this->assertEquals($expected->data(), \OC_Avatar::get(\OC_User::getUser())->data());
|
||||||
|
|
||||||
\OC_Avatar::setLocalAvatar(\OC_User::getUser(), false);
|
\OC_Avatar::set(\OC_User::getUser(), false);
|
||||||
$expected = \OC_Avatar::getDefaultAvatar()->data();
|
$expected = \OC_Avatar::getDefaultAvatar()->data();
|
||||||
$this->assertEquals($expected, \OC_Avatar::get(\OC_User::getUser())->data());
|
$this->assertEquals($expected, \OC_Avatar::get(\OC_User::getUser())->data());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGravatar() {
|
/*public function testDefaultAvatar() {
|
||||||
\OC_Preferences::setValue(\OC_User::getUser(), 'settings', 'email', 'someone@example.com');
|
|
||||||
\OC_Config::setValue('avatar', 'gravatar');
|
|
||||||
$expected = "http://www.gravatar.com/avatar/".md5("someone@example.com")."?s=";
|
|
||||||
$this->assertEquals($expected."64", \OC_Avatar::get(\OC_User::getUser()));
|
|
||||||
$this->assertEquals($expected."32", \OC_Avatar::get(\OC_User::getUser(), 32));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testDefaultAvatar() {
|
|
||||||
$img = new \OC_Image(OC::$SERVERROOT.'/core/img/defaultavatar.png');
|
$img = new \OC_Image(OC::$SERVERROOT.'/core/img/defaultavatar.png');
|
||||||
$img->resize(128);
|
$img->resize(128);
|
||||||
$this->assertEquals($img->data(), \OC_Avatar::getDefaultAvatar(\OC_User::getUser(), 128)->data());
|
$this->assertEquals($img->data(), \OC_Avatar::getDefaultAvatar(\OC_User::getUser(), 128)->data());
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue