Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default avatar feature :) #152

Merged
merged 4 commits into from Feb 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions install/install_1-0_mysql.sql
Expand Up @@ -1751,6 +1751,7 @@ VALUES ('ourVersion', '{$current_version}'),
('banLastUpdated', '0'),
('smileys_dir', '{BOARDDIR}/smileys'),
('smileys_url', '{$boardurl}/smileys'),
('avatar_default', '0'),
('avatar_directory', '{BOARDDIR}/avatars'),
('avatar_url', '{$boardurl}/avatars'),
('avatar_max_height_external', '65'),
Expand Down
1 change: 1 addition & 0 deletions install/install_1-0_postgresql.sql
Expand Up @@ -2240,6 +2240,7 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('autoLinkUrls', '1');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('banLastUpdated', '0');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smileys_dir', '{BOARDDIR}/smileys');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smileys_url', '{$boardurl}/smileys');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_default', '1');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_directory', '{BOARDDIR}/avatars');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_url', '{$boardurl}/avatars');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_max_height_external', '65');
Expand Down
1 change: 1 addition & 0 deletions install/install_1-0_sqlite.sql
Expand Up @@ -1893,6 +1893,7 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('autoLinkUrls', '1');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('banLastUpdated', '0');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smileys_dir', '{BOARDDIR}/smileys');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('smileys_url', '{$boardurl}/smileys');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_default', '1');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_directory', '{BOARDDIR}/avatars');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_url', '{$boardurl}/avatars');
INSERT INTO {$db_prefix}settings (variable, value) VALUES ('avatar_max_height_external', '65');
Expand Down
7 changes: 7 additions & 0 deletions install/upgrade_dia_1-0_mysql.sql
Expand Up @@ -28,6 +28,13 @@ if (!isset($modSettings['package_make_full_backups']) && isset($modSettings['pac
---}
---#

---# Adding new settings ...
INSERT IGNORE INTO {$db_prefix}settings
(variable, value)
VALUES
('avatar_default', '0');
---#

/******************************************************************************/
--- Updating legacy attachments...
/******************************************************************************/
Expand Down
7 changes: 7 additions & 0 deletions install/upgrade_dia_1-0_postgresql.sql
Expand Up @@ -30,6 +30,13 @@ if (!isset($modSettings['package_make_full_backups']) && isset($modSettings['pac
---}
---#

---# Adding new settings ...
INSERT IGNORE INTO {$db_prefix}settings
(variable, value)
VALUES
('avatar_default', '0');
---#

/******************************************************************************/
--- Updating legacy attachments...
/******************************************************************************/
Expand Down
7 changes: 7 additions & 0 deletions install/upgrade_dia_1-0_sqlite.sql
Expand Up @@ -28,6 +28,13 @@ if (!isset($modSettings['package_make_full_backups']) && isset($modSettings['pac
---}
---#

---# Adding new settings ...
INSERT IGNORE INTO {$db_prefix}settings
(variable, value)
VALUES
('avatar_default', '0');
---#

/******************************************************************************/
--- Updating legacy attachments...
/******************************************************************************/
Expand Down
16 changes: 15 additions & 1 deletion sources/Load.php
Expand Up @@ -220,7 +220,7 @@ function reloadSettings()
*/
function loadUserSettings()
{
global $modSettings, $user_settings, $smcFunc;
global $modSettings, $user_settings, $smcFunc, $settings;
global $cookiename, $user_info, $language, $context;

// Check first the integration, then the cookie, and last the session.
Expand Down Expand Up @@ -278,6 +278,9 @@ function loadUserSettings()
$user_settings = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);

if(!empty($modSettings['avatar_default']) && empty($user_settings['avatar']) && empty($user_settings['filename']))
$user_settings['avatar'] = $settings['images_url'] . '/default_avatar.png';

if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
cache_put_data('user_settings-' . $id_member, $user_settings, 60);
}
Expand Down Expand Up @@ -1150,6 +1153,17 @@ function loadMemberContext($user, $display_custom_fields = false)
'local_time' => timeformat(time() + ($profile['time_offset'] - $user_info['time_offset']) * 3600, false),
);

if(!empty($modSettings['avatar_default']) && empty($profile['avatar']) && empty($profile['filename']))
{
// Change the avatar's URL
$memberContext[$user]['avatar'] = array(
'name' => '',
'image' => '<img src="' . $settings['images_url'] . '/default_avatar.png' . '" alt="" class="avatar" border="0" />',
'href' => $settings['images_url'] . '/default_avatar.png',
'url' => 'http://'
);
}

// Are we also loading the members custom fields into context?
if ($display_custom_fields && !empty($modSettings['displayFields']))
{
Expand Down
2 changes: 2 additions & 0 deletions sources/admin/ManageAttachments.php
Expand Up @@ -286,6 +286,8 @@ function action_avatars($return_config = false)
$context['valid_custom_avatar_dir'] = empty($modSettings['custom_avatar_enabled']) || (!empty($modSettings['custom_avatar_dir']) && is_dir($modSettings['custom_avatar_dir']) && is_writable($modSettings['custom_avatar_dir']));

$config_vars = array(
array('title', 'avatar_settings'),
array('check', 'avatar_default'),
// Server stored avatars!
array('title', 'avatar_server_stored'),
array('warning', empty($testImg) ? 'avatar_img_enc_warning' : ''),
Expand Down
Binary file added themes/default/images/default_avatar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions themes/default/languages/Admin.english.php
Expand Up @@ -458,6 +458,8 @@
$txt['attachment_transfer_same_dir'] = 'You cannot select the same directory as both the source and target.';
$txt['attachment_transfer_progress'] = 'Please wait. Transfer in progress.';

$txt['avatar_settings'] = 'General avatar settings';
$txt['avatar_default'] = 'Enable a default avatar for all users without their own avatar';
$txt['mods_cat_avatars'] = 'Avatars';
$txt['avatar_directory'] = 'Avatars directory';
$txt['avatar_url'] = 'Avatars URL';
Expand Down
1 change: 1 addition & 0 deletions themes/default/languages/Help.english.php
Expand Up @@ -515,6 +515,7 @@
$helptxt['maintenance_rot'] = 'This allows you to <strong>completely</strong> and <strong>irrevocably</strong> remove old topics. It is recommended that you try to make a backup first, just in case you remove something you didn\'t mean to.<br /><br />Use this option with care.';
$helptxt['maintenance_members'] = 'This allows you to <strong>completely</strong> and <strong>irrevocably</strong> remove member accounts from your forum. It is <strong>highly</strong> recommended that you try to make a backup first, just in case you remove something you didn\'t mean to.<br /><br />Use this option with care.';

$helptxt['avatar_default'] = 'With this option enabled, a default avatar is shown for all users without their own avatar. The file named \'default_avatar.png\' is located in the images folder inside the themes directory.';
$helptxt['avatar_server_stored'] = 'This allows your members to pick from avatars stored on your server itself. They are, generally, in the same place as the forum under the avatars directory.<br />As a tip, if you create directories in that folder, you can make &quot;categories&quot; of avatars.';
$helptxt['avatar_external'] = 'With this enabled, your members can type in a URL to their own avatar. The downside of this is that, in some cases, they may use avatars that are overly large or portray images you don\'t want on your forum.';
$helptxt['avatar_download_external'] = 'With this option enabled, the URL given by the user is accessed to download the avatar at that location. On success, the avatar will be treated as uploadable avatar.';
Expand Down