Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[ticket/10836] Enable avatars by default at install #771

Merged
merged 2 commits into from

5 participants

@galaxyAbstractor

Enables avatars and local avatar upload by default.

PHPBB3-10836

Ticket: http://tracker.phpbb.com/browse/PHPBB3-10836

@galaxyAbstractor galaxyAbstractor [ticket/10836] Enable avatars by default at install
Enables avatars and local avatar upload by default.

PHPBB3-10836
a21b367
@callumacrae

Looks good.

@naderman
Owner

This needs to take into account that I believe the avatar upload directory is only optionally writable in the installer. So uploading avatars needs to be disabled in the installer if the avatar upload directory is not writable.

@callumacrae

Why not make it non-optionally writable?

@naderman
Owner

So you don't have to make it writable if you don't want to allow avatar uploads anyway.

@galaxyAbstractor

Avatars is now disabled after installing if the directory is found not to be writable. Is this what you had in mind? If I missed anything, I'll fix that too.

@callumacrae

Looks good to me.

phpBB/install/install_install.php
@@ -1942,6 +1943,24 @@ function email_admin($mode, $sub)
}
/**
+ * Check if the avatar directory is writeable and disable avatars
+ * if it isn't writeable.
+ */
+ function check_avatar_dir_writable($mode, $sub)
+ {
+ global $db, $phpbb_root_path;
+
+ if (!phpbb_is_writable($phpbb_root_path . 'images/avatars/upload/'))
+ {
+ $sql = 'UPDATE ' . CONFIG_TABLE . "
@naderman Owner

This should use the $config->set() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
phpBB/install/install_install.php
@@ -1942,6 +1943,24 @@ function email_admin($mode, $sub)
}
/**
+ * Check if the avatar directory is writeable and disable avatars
+ * if it isn't writeable.
+ */
+ function check_avatar_dir_writable($mode, $sub)
+ {
+ global $db, $phpbb_root_path;
@naderman Owner

Please avoid global variables in new methods. Instead, pass them as parameters or store them in class members.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@naderman
Owner

Oh I'm sorry I thought this was for 3.1, please ignore my comment regarding globals.

On 3.0, the comment regarding config, should be to use the set_config() function.

@galaxyAbstractor

Righty, fixed :>

phpBB/install/install_install.php
@@ -1942,6 +1943,21 @@ function email_admin($mode, $sub)
}
/**
+ * Check if the avatar directory is writeable and disable avatars
+ * if it isn't writeable.
@p
p added a note

Please add parameter documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
phpBB/install/install_install.php
@@ -1942,6 +1943,21 @@ function email_admin($mode, $sub)
}
/**
+ * Check if the avatar directory is writeable and disable avatars
+ * if it isn't writeable.
+ */
+ function check_avatar_dir_writable($mode, $sub)
@p
p added a note

Might be more appropriately called "enable avatars if upload dir writable" or similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
phpBB/install/install_install.php
@@ -1942,6 +1943,21 @@ function email_admin($mode, $sub)
}
/**
+ * Check if the avatar directory is writeable and disable avatars
+ * if it isn't writeable.
+ */
+ function check_avatar_dir_writable($mode, $sub)
+ {
+ global $db, $phpbb_root_path, $config;
@p
p added a note

db and config should be taken out as they are unused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@galaxyAbstractor galaxyAbstractor [ticket/10836] Check if avatar directory is writable after install
Check if the avatar directory is writeable after the installation is complete.
If it isn't, disable avatars and avatar uploading by default.

PHPBB3-10836
1a8db76
@p-scratch

The diff looks ok to me now I think.

@p-scratch

Installer will not create the avatar upload directory even if filesystem permissions allow that.

Otherwise both cases appear to work correctly.

@p p referenced this pull request from a commit in p/phpbb3
@p p Merge PR #771 branch 'develop-olympus' into develop
* develop-olympus:
  [ticket/10836] Check if avatar directory is writable after install
  [ticket/10836] Enable avatars by default at install
cd6f6d2
@p p referenced this pull request from a commit
@p p Merge PR #771 branch 'galaxyAbstractor/ticket/10836' into develop-oly…
…mpus

* galaxyAbstractor/ticket/10836:
  [ticket/10836] Check if avatar directory is writable after install
  [ticket/10836] Enable avatars by default at install
3a67604
@p p merged commit 1a8db76 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 21, 2012
  1. @galaxyAbstractor

    [ticket/10836] Enable avatars by default at install

    galaxyAbstractor authored
    Enables avatars and local avatar upload by default.
    
    PHPBB3-10836
Commits on Apr 25, 2012
  1. @galaxyAbstractor

    [ticket/10836] Check if avatar directory is writable after install

    galaxyAbstractor authored
    Check if the avatar directory is writeable after the installation is complete.
    If it isn't, disable avatars and avatar uploading by default.
    
    PHPBB3-10836
This page is out of date. Refresh to see the latest.
View
16 phpBB/install/install_install.php
@@ -105,6 +105,7 @@ function main($mode, $sub)
$this->add_language($mode, $sub);
$this->add_bots($mode, $sub);
$this->email_admin($mode, $sub);
+ $this->disable_avatars_if_unwritable();
// Remove the lock file
@unlink($phpbb_root_path . 'cache/install_lock');
@@ -1942,6 +1943,21 @@ function email_admin($mode, $sub)
}
/**
+ * Check if the avatar directory is writable and disable avatars
+ * if it isn't writable.
+ */
+ function disable_avatars_if_unwritable()
+ {
+ global $phpbb_root_path;
+
+ if (!phpbb_is_writable($phpbb_root_path . 'images/avatars/upload/'))
+ {
+ set_config('allow_avatar', 0);
+ set_config('allow_avatar_upload', 0);
+ }
+ }
+
+ /**
* Generate a list of available mail server authentication methods
*/
function mail_auth_select($selected_method)
View
4 phpBB/install/schemas/schema_data.sql
@@ -8,10 +8,10 @@
INSERT INTO phpbb_config (config_name, config_value) VALUES ('active_sessions', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_attachments', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_autologin', '1');
-INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar', '0');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_local', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_remote', '0');
-INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_upload', '0');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_upload', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_remote_upload', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bbcode', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_birthdays', '1');
Something went wrong with that request. Please try again.