Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added ability to grant specific permissions when creating boards.

In addition to system default / world write toggle, now it is
possible to specify an arbitrary permission mask to be ORed
to default permissions once board creation is complete.
  • Loading branch information...
commit 3f54f30753117f8d1306aebd69b47cd50a5b9a18 1 parent 59b21e6
@p p authored
View
19 includes/functions_files.php
@@ -162,6 +162,11 @@ public static function append_slash(&$dir)
*/
public static function make_writable($dir, $root = true)
{
+ self::grant_permissions($dir, 0666, $root);
+ }
+
+ public static function grant_permissions($dir, $add_perms, $root = true)
+ {
global $phpEx;
$file_arr = scandir($dir);
@@ -181,15 +186,17 @@ public static function make_writable($dir, $root = true)
//}
$file = $dir . $file;
-
- if (is_file($file))
+
+ $old_perms = fileperms($file);
+ $new_perms = $old_perms | $add_perms;
+ if ($new_perms != $old_perms)
{
- chmod($file, 0666);
+ chmod($file, $new_perms);
}
- else
+
+ if (is_dir($file))
{
- chmod($file, 0777);
- self::make_writable($file, false);
+ self::grant_permissions($file, false);
}
}
View
4 language/en/qi.php
@@ -127,6 +127,8 @@
'FUNCTIONS_MODS_MISSING' => 'includes/automod/functions_mods.php not found.',
'GENERAL_ERROR' => 'General Error',
+ 'GRANT_PERMS' => 'Grant additional permissions',
+ 'GRANT_PERMS_EXPLAIN' => '(e.g. 0060 for group read/write)',
'IN_SETTINGS' => 'Manage your QuickInstall settings.',
'INCLUDE_MODS' => 'Include MODs',
@@ -141,6 +143,8 @@
'MAKE_WRITABLE' => 'Make files world writable',
'MAKE_WRITABLE_EXPLAIN' => 'Set files, config.php, and directories world writable by default. This can be changed when you create a forum.',
+ 'MAKE_WRITABLE_BOARD' => 'Make files world writable',
+ 'MAKE_WRITABLE_BOARD_EXPLAIN' => '(same as granting permissions of 0666)',
'MANAGE_BOARDS' => 'Manage boards',
'MAX' => 'Max',
'MIGHT_TAKE_LONG' => '<strong>Please note:</strong> Creation of the board can take a while, perhaps even a minute or longer, so <strong>don’t</strong> submit the form twice.',
View
7 modules/qi_create.php
@@ -51,6 +51,7 @@ public function __construct()
$delete_files = request_var('delete_files', false);
$automod = request_var('automod', false);
$make_writable = request_var('make_writable', false);
+ $grant_perms = octdec(request_var('grant_perms', 0));
$populate = request_var('populate', false);
$subsilver = request_var('subsilver', 0);
$alt_env = request_var('alt_env', '');
@@ -506,6 +507,12 @@ public function __construct()
file_functions::make_writable($board_dir);
}
+ // Grant additional permissions
+ if ($grant_perms)
+ {
+ file_functions::grant_permissions($board_dir, $grant_perms);
+ }
+
// if he wants to be redirected, redirect him
if ($redirect)
{
View
8 style/main_body.html
@@ -66,13 +66,19 @@
</dd>
</dl>
<dl>
- <dt><label for="make_writable">{L_MAKE_WRITABLE}:</label><br />{L_NO_IMPACT_WIN}</dt>
+ <dt><label for="make_writable">{L_MAKE_WRITABLE_BOARD}:</label<br />{L_MAKE_WRITABLE_BOARD_EXPLAIN}<br />{L_NO_IMPACT_WIN}</dt>
<dd>
<label><input type="radio" class="radio" name="make_writable" value="1"<!-- IF S_MAKE_WRITABLE == 1 --> checked="checked"<!-- ENDIF --> /> {L_YES}</label>
<label><input type="radio" class="radio" name="make_writable" value="0"<!-- IF S_MAKE_WRITABLE == 0 --> checked="checked"<!-- ENDIF --> /> {L_NO}</label>
</dd>
</dl>
<dl>
+ <dt><label for="make_writable">{L_GRANT_PERMS}:</label><br />{L_GRANT_PERMS_EXPLAIN}<br />{L_NO_IMPACT_WIN}</dt>
+ <dd>
+ <dd><input class="text medium" type="text" id="grant_perms" name="grant_perms" /></dd>
+ </dd>
+ </dl>
+ <dl>
<dt><label for="populate">{L_POPULATE}:</label><br />{L_POPULATE_MAIN_EXPLAIN}</dt>
<dd>
<label><input type="radio" class="radio" name="populate" value="1"<!-- IF S_POPULATE == 1 --> checked="checked"<!-- ENDIF --> /> {L_YES}</label>
Please sign in to comment.
Something went wrong with that request. Please try again.