31 $op = Request::getCmd(
'op',
'list');
40 $xoops->header(
'module:avatars/avatars_editavatar.tpl');
46 $mimetypes = array(
'image/gif',
'image/jpeg',
'image/pjpeg',
'image/x-png',
'image/png');
50 if (
$helper->getConfig(
'avatars_allowupload') == 1
51 &&
$xoops->user->getVar(
'posts') >=
$helper->getConfig(
'avatars_postsrequired')
66 $xoops->tpl()->assign(
'uid',
$xoops->user->getVar(
"uid"));
68 $oldavatar =
$xoops->user->getVar(
'user_avatar');
69 if (!empty($oldavatar) && $oldavatar !=
'blank.gif') {
72 $warning_msg .=
"<img src='" .
$xoops_upload_url .
'/' . $oldavatar .
"' alt=' ' />";
85 if (!
$xoops->security()->check()) {
86 $xoops->redirect(
'/index.php', 3, implode(
'<br />',
$xoops->security()->getErrors()));
88 $uid = Request::getInt(
'uid', 0);
93 $uploader_avatars_img =
98 if ($uploader_avatars_img->fetchMedia(
'user_avatar')) {
99 $uploader_avatars_img->setPrefix(
'savt');
100 $uploader_avatars_img->fetchMedia(
'user_avatar');
101 if (!$uploader_avatars_img->upload()) {
102 $error_msg .= $uploader_avatars_img->getErrors();
103 $obj->setVar(
'avatar_file',
'avatars/blank.gif');
105 $obj->setVar(
'avatar_name',
$xoops->user->getVar(
'uname'));
106 $obj->setVar(
'avatar_mimetype', $uploader_avatars_img->getMediaType());
107 $obj->setVar(
'avatar_file',
'avatars/' . $uploader_avatars_img->getSavedFileName());
108 $obj->setVar(
'avatar_display', 1);
109 $obj->setVar(
'avatar_type',
'C');
111 if ($error_msg ==
'') {
113 $oldavatar =
$xoops->user->getVar(
'user_avatar');
118 if (! empty($avatars) && count($avatars) == 1 && is_object($avatars[0])) {
123 && is_file($oldavatar_path)
125 unlink($oldavatar_path);
128 $sql =
$xoops->db()->createXoopsQueryBuilder()
129 ->updatePrefix(
'users')
130 ->set(
'user_avatar',
':avatar')
131 ->where(
'uid = :uid')
132 ->setParameter(
':uid',
$xoops->user->getVar(
'uid'), \PDO::PARAM_INT)
135 'avatars/' . $uploader_avatars_img->getSavedFileName(),
142 $error_msg .= $obj->getHtmlErrors();
146 $user_avatar = Request::getString(
'user_avatar',
'blank.gif');
147 $oldavatar =
$xoops->user->getVar(
'user_avatar');
148 $xoops->user->setVar(
'user_avatar', $user_avatar);
151 echo
$xoops->user->getHtmlErrors();
157 if (!empty($avatars) && count($avatars) == 1 && is_object($avatars[0])) {
161 if (0 === strpos($oldavatar_path, realpath(
$xoops_upload_path)) && is_file($oldavatar_path)) {
162 unlink($oldavatar_path);
165 if ($user_avatar !=
'blank.gif') {
167 if (is_object($avatars[0])) {
173 $xoops->tpl()->assign(
'uid',
$xoops->user->getVar(
"uid"));
176 $form =
$xoops->getModuleForm($obj,
'avatar_user');
if($uname== ''||$pass== '') $member_handler
const INFORMATION_FOR_UPLOADS
defined('DS') or define('DS' DIRECTORY_SEPARATOR
const ALERT_INFO_MIMETYPES
if(!$xoops->isUser()) $uid
const E_NO_ACCESS_PERMISSION