|
@@ -963,7 +963,7 @@ function saveProfileFields()
|
|
|
*/
|
|
|
function saveProfileChanges(&$profile_vars, &$post_errors, $memID)
|
|
|
{
|
|
|
- global $user_info, $txt, $user_profile;
|
|
|
+ global $txt, $user_profile;
|
|
|
global $context, $sourcedir;
|
|
|
global $smcFunc;
|
|
|
|
|
@@ -1779,7 +1779,7 @@ function getAvatars($directory, $level)
|
|
|
*/
|
|
|
function theme($memID)
|
|
|
{
|
|
|
- global $txt, $context, $user_profile, $user_info, $smcFunc;
|
|
|
+ global $txt, $context, $user_profile, $smcFunc;
|
|
|
|
|
|
loadThemeOptions($memID);
|
|
|
if (allowedTo(array('profile_extra_own', 'profile_extra_any')))
|
|
@@ -1889,7 +1889,7 @@ function authentication($memID, $saving = false)
|
|
|
*/
|
|
|
function notification($memID)
|
|
|
{
|
|
|
- global $txt, $scripturl, $user_profile, $user_info, $context, $smcFunc, $sourcedir;
|
|
|
+ global $txt, $scripturl, $user_profile, $context, $smcFunc, $sourcedir;
|
|
|
|
|
|
// Going to want this for consistency.
|
|
|
loadCSSFile('admin.css', array(), 'admin');
|
|
@@ -1897,6 +1897,7 @@ function notification($memID)
|
|
|
// This is just a bootstrap for everything else.
|
|
|
$sa = array(
|
|
|
'alerts' => 'alert_configuration',
|
|
|
+ 'markread' => 'alert_markread',
|
|
|
'topics' => 'alert_notifications_topics',
|
|
|
'boards' => 'alert_notifications_boards',
|
|
|
);
|
|
@@ -1914,7 +1915,7 @@ function notification($memID)
|
|
|
|
|
|
function alert_configuration($memID)
|
|
|
{
|
|
|
- global $txt, $scripturl, $user_profile, $user_info, $context, $modSettings, $smcFunc, $sourcedir;
|
|
|
+ global $txt, $scripturl, $user_profile, $context, $modSettings, $smcFunc, $sourcedir;
|
|
|
|
|
|
$context['token_check'] = 'profile-nt' . $memID;
|
|
|
is_not_guest();
|
|
@@ -2112,9 +2113,45 @@ function alert_configuration($memID)
|
|
|
createToken($context['token_check'], 'post');
|
|
|
}
|
|
|
|
|
|
+function alert_markread($memID)
|
|
|
+{
|
|
|
+ global $context, $db_show_debug, $smcFunc;
|
|
|
+
|
|
|
+ // We do not want to output debug information here.
|
|
|
+ $db_show_debug = false;
|
|
|
+
|
|
|
+ // We only want to output our little layer here.
|
|
|
+ $context['template_layers'] = array();
|
|
|
+ $context['sub_template'] = 'alerts_all_read';
|
|
|
+
|
|
|
+ loadLanguage('Alerts');
|
|
|
+
|
|
|
+ // Now we're all set up.
|
|
|
+ is_not_guest();
|
|
|
+ if (!$context['user']['is_owner'])
|
|
|
+ fatal_error('no_access');
|
|
|
+
|
|
|
+ checkSession('get');
|
|
|
+
|
|
|
+ // Assuming we're here, mark everything as read and head back.
|
|
|
+ // We only spit back the little layer because this should be called AJAXively.
|
|
|
+ $smcFunc['db_query']('', '
|
|
|
+ UPDATE {db_prefix}user_alerts
|
|
|
+ SET is_read = {int:now}
|
|
|
+ WHERE id_member = {int:current_member}
|
|
|
+ AND is_read = 0',
|
|
|
+ array(
|
|
|
+ 'now' => time(),
|
|
|
+ 'current_member' => $memID,
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ updateMemberData($memID, array('alerts' => 0));
|
|
|
+}
|
|
|
+
|
|
|
function alert_notifications_topics($memID)
|
|
|
{
|
|
|
- global $txt, $scripturl, $user_profile, $user_info, $context, $modSettings, $smcFunc, $sourcedir;
|
|
|
+ global $txt, $scripturl, $user_profile, $context, $modSettings, $smcFunc, $sourcedir;
|
|
|
|
|
|
// Because of the way this stuff works, we want to do this ourselves.
|
|
|
if (isset($_POST['edit_notify_topics']))
|
|
@@ -2254,7 +2291,7 @@ function alert_notifications_topics($memID)
|
|
|
|
|
|
function alert_notifications_boards($memID)
|
|
|
{
|
|
|
- global $txt, $scripturl, $user_profile, $user_info, $context, $smcFunc, $sourcedir;
|
|
|
+ global $txt, $scripturl, $user_profile, $context, $smcFunc, $sourcedir;
|
|
|
|
|
|
// Because of the way this stuff works, we want to do this ourselves.
|
|
|
if (isset($_POST['edit_notify_boards']))
|
|
@@ -2549,7 +2586,7 @@ function loadThemeOptions($memID)
|
|
|
*/
|
|
|
function ignoreboards($memID)
|
|
|
{
|
|
|
- global $txt, $user_info, $context, $modSettings, $smcFunc, $cur_profile;
|
|
|
+ global $txt, $context, $modSettings, $smcFunc, $cur_profile;
|
|
|
|
|
|
// Have the admins enabled this option?
|
|
|
if (empty($modSettings['allow_ignore_boards']))
|
|
@@ -2945,26 +2982,9 @@ function profileSaveAvatarData(&$value)
|
|
|
|
|
|
require_once($sourcedir . '/ManageAttachments.php');
|
|
|
|
|
|
- // We need to know where we're going to be putting it..
|
|
|
- if (!empty($modSettings['custom_avatar_enabled']))
|
|
|
- {
|
|
|
- $uploadDir = $modSettings['custom_avatar_dir'];
|
|
|
- $id_folder = 1;
|
|
|
- }
|
|
|
- elseif (!empty($modSettings['currentAttachmentUploadDir']))
|
|
|
- {
|
|
|
- if (!is_array($modSettings['attachmentUploadDir']))
|
|
|
- $modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
|
|
|
-
|
|
|
- // Just use the current path for temp files.
|
|
|
- $uploadDir = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
|
|
|
- $id_folder = $modSettings['currentAttachmentUploadDir'];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $uploadDir = $modSettings['attachmentUploadDir'];
|
|
|
- $id_folder = 1;
|
|
|
- }
|
|
|
+ // We're going to put this on a nice custom dir.
|
|
|
+ $uploadDir = $modSettings['custom_avatar_dir'];
|
|
|
+ $id_folder = 1;
|
|
|
|
|
|
$downloadedExternalAvatar = false;
|
|
|
if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external']))
|
|
@@ -2988,6 +3008,7 @@ function profileSaveAvatarData(&$value)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Removes whatever attachment there was before updating
|
|
|
if ($value == 'none')
|
|
|
{
|
|
|
$profile_vars['avatar'] = '';
|
|
@@ -2999,6 +3020,8 @@ function profileSaveAvatarData(&$value)
|
|
|
|
|
|
removeAttachments(array('id_member' => $memID));
|
|
|
}
|
|
|
+
|
|
|
+ // An avatar from the server-stored galleries.
|
|
|
elseif ($value == 'server_stored' && allowedTo('profile_server_avatar'))
|
|
|
{
|
|
|
$profile_vars['avatar'] = strtr(empty($_POST['file']) ? (empty($_POST['cat']) ? '' : $_POST['cat']) : $_POST['file'], array('&' => '&'));
|
|
@@ -3022,14 +3045,13 @@ function profileSaveAvatarData(&$value)
|
|
|
// Remove any attached avatar...
|
|
|
removeAttachments(array('id_member' => $memID));
|
|
|
|
|
|
- // @todo http://www.simplemachines.org/community/index.php?topic=462089.msg3226650#msg3226650
|
|
|
$profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal']));
|
|
|
|
|
|
if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///')
|
|
|
$profile_vars['avatar'] = '';
|
|
|
// Trying to make us do something we'll regret?
|
|
|
elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://')
|
|
|
- return 'bad_avatar';
|
|
|
+ return 'bad_avatar_invalid_url';
|
|
|
// Should we check dimensions?
|
|
|
elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external']))
|
|
|
{
|
|
@@ -3040,7 +3062,7 @@ function profileSaveAvatarData(&$value)
|
|
|
{
|
|
|
// Houston, we have a problem. The avatar is too large!!
|
|
|
if ($modSettings['avatar_action_too_large'] == 'option_refuse')
|
|
|
- return 'bad_avatar';
|
|
|
+ return 'bad_avatar_too_large';
|
|
|
elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
|
|
|
{
|
|
|
// @todo remove this if appropriate
|
|
@@ -3104,12 +3126,16 @@ function profileSaveAvatarData(&$value)
|
|
|
$cur_profile['filename'] = $modSettings['new_avatar_data']['filename'];
|
|
|
$cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type'];
|
|
|
}
|
|
|
+
|
|
|
+ // Admin doesn't want to resize large avatars, can't do much about it but to tell you to use a different one :(
|
|
|
else
|
|
|
{
|
|
|
@unlink($_FILES['attachment']['tmp_name']);
|
|
|
- return 'bad_avatar';
|
|
|
+ return 'bad_avatar_too_large';
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // So far, so good, checks lies ahead!
|
|
|
elseif (is_array($sizes))
|
|
|
{
|
|
|
// Now try to find an infection.
|
|
@@ -3120,7 +3146,7 @@ function profileSaveAvatarData(&$value)
|
|
|
if (empty($modSettings['avatar_reencode']) || (!reencodeImage($_FILES['attachment']['tmp_name'], $sizes[2])))
|
|
|
{
|
|
|
@unlink($_FILES['attachment']['tmp_name']);
|
|
|
- return 'bad_avatar';
|
|
|
+ return 'bad_avatar_fail_reencode';
|
|
|
}
|
|
|
// We were successful. However, at what price?
|
|
|
$sizes = @getimagesize($_FILES['attachment']['tmp_name']);
|
|
@@ -3143,7 +3169,7 @@ function profileSaveAvatarData(&$value)
|
|
|
$mime_type = 'image/' . ($extension === 'jpg' ? 'jpeg' : ($extension === 'bmp' ? 'x-ms-bmp' : $extension));
|
|
|
$destName = 'avatar_' . $memID . '_' . time() . '.' . $extension;
|
|
|
list ($width, $height) = getimagesize($_FILES['attachment']['tmp_name']);
|
|
|
- $file_hash = empty($modSettings['custom_avatar_enabled']) ? getAttachmentFilename($destName, false, null, true) : '';
|
|
|
+ $file_hash = '';
|
|
|
|
|
|
// Remove previous attachments this member might have had.
|
|
|
removeAttachments(array('id_member' => $memID));
|
|
@@ -3155,7 +3181,7 @@ function profileSaveAvatarData(&$value)
|
|
|
'width' => 'int', 'height' => 'int', 'mime_type' => 'string', 'id_folder' => 'int',
|
|
|
),
|
|
|
array(
|
|
|
- $memID, (empty($modSettings['custom_avatar_enabled']) ? 0 : 1), $destName, $file_hash, $extension, filesize($_FILES['attachment']['tmp_name']),
|
|
|
+ $memID, 1, $destName, $file_hash, $extension, filesize($_FILES['attachment']['tmp_name']),
|
|
|
(int) $width, (int) $height, $mime_type, $id_folder,
|
|
|
),
|
|
|
array('id_attach')
|
|
@@ -3163,7 +3189,7 @@ function profileSaveAvatarData(&$value)
|
|
|
|
|
|
$cur_profile['id_attach'] = $smcFunc['db_insert_id']('{db_prefix}attachments', 'id_attach');
|
|
|
$cur_profile['filename'] = $destName;
|
|
|
- $cur_profile['attachment_type'] = empty($modSettings['custom_avatar_enabled']) ? 0 : 1;
|
|
|
+ $cur_profile['attachment_type'] = 1;
|
|
|
|
|
|
$destinationPath = $uploadDir . '/' . (empty($file_hash) ? $destName : $cur_profile['id_attach'] . '_' . $file_hash . '.dat');
|
|
|
if (!rename($_FILES['attachment']['tmp_name'], $destinationPath))
|
|
@@ -3487,7 +3513,7 @@ function profileSendActivation()
|
|
|
*/
|
|
|
function groupMembership($memID)
|
|
|
{
|
|
|
- global $txt, $scripturl, $user_profile, $user_info, $context, $smcFunc;
|
|
|
+ global $txt, $scripturl, $user_profile, $context, $smcFunc;
|
|
|
|
|
|
$curMember = $user_profile[$memID];
|
|
|
$context['primary_group'] = $curMember['id_group'];
|