Skip to content

Commit

Permalink
Merge pull request #54 from bpcurse/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bpcurse authored May 4, 2021
2 parents a4a183b + 51912e2 commit ac4c4fe
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 23 deletions.
38 changes: 34 additions & 4 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@
* Security settings
*/

// Security token that must be provided to access the login page (either as GET parameter or manually)
/**
* Security token that must be provided to access the login page (either as GET parameter or manually)
*/
// $access_token = 'some_long_random_string';

// Disallow insecure http:// connections even if !http:// override option has been specified. DEFAULT 'false'
/**
* Disallow insecure http:// connections even if !http:// override option has been specified. DEFAULT 'false'
*/
$https_strict = false;

// Allowed frame ancestors e.g. your cloud URL incl. https:// (if you want to open the script from external sites app)
// Multiple URLs can be set by separating them with a space
/**
* Allowed frame ancestors e.g. your cloud URL incl. https:// (if you want to open the script from external sites app)
* Multiple URLs can be set by separating them with a space
*/
// $frame_ancestors = 'https://cloud.example.com';

/**
Expand All @@ -36,6 +42,30 @@
*/
$language = 'en';

/**
* Set default columns to show/export
*
* Available columns are:
* id, displayname, email, lastLogin, backend, enabled, quota, used,
* percentage_used, free, groups, subadmin, language and locale
*
* DEFAULT ['id', 'displayname', 'email', 'lastLogin']
*
* Has to be set as an array ['choice1', 'choice2', 'choice3', ...]
*
*/
$data_choices = ['id', 'displayname', 'email', 'lastLogin'];

/**
* Set default group to preselect
*
* DEFAULT unset
*
* filter_group has to be an exact match with an existing groupname
*
*/
// $filter_group = 'groupname';

/**
* Define +/- tolerance for disk space "almost equal to" filters in a
* decimal number representing percent (e.g. 0.15 for 15 %)
Expand Down
28 changes: 21 additions & 7 deletions email.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,34 @@
<input type='radio' name='filter_group_choice' value='set_filter'"
.check_and_set_filter('group').">
<label for='filter_group_choice'>".L10N_GROUP."</label>
<select name='filter_group'>
<option value='' selected>-- ".L10N_SELECT_GROUP." --</option>";
foreach($_SESSION['grouplist'] as $item)
echo "<option value='$item'>$item</option>";
<select name='filter_group'>";
foreach($_SESSION['grouplist'] as $item) {
$selected = $item == $_SESSION['filter_group']
? ' selected'
: '';
echo "<option value='$item'$selected>$item</option>";
}
echo "</select></td></tr>
<tr>
<td><u>".L10N_FILTER_BY."<u></td>
<td style='padding: 0.3em;'>
<input type='checkbox' name='filter_lastLogin_choice' value='set_filter'"
.check_and_set_filter('lastLogin').">
<label for='filter_lastLogin_choice'>".L10N_LAST_LOGIN_BETWEEN." </label>
<input type=date name='filter_ll_since'>
".L10N_AND."
<input type=date name='filter_ll_before' value='".date('Y-m-d')."'>
<input type=date name='filter_ll_since'";

if($_SESSION['filter_ll_since'])
echo " value='{$_SESSION['filter_ll_since']}'";

echo ">".L10N_AND."
<input type=date name='filter_ll_before' value='";

if($_SESSION['filter_ll_before'])
echo $_SESSION['filter_ll_before'];
else
echo date('Y-m-d');

echo "'>
</td>
</tr>
<tr>
Expand Down
20 changes: 16 additions & 4 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ function select_group_members($group, $format = null) {
*/
function calculate_quota() {

// Reset values
$_SESSION['quota_total_assigned'] = 0;
$_SESSION['quota_total_free'] = 0;
$_SESSION['quota_total_used'] = 0;
Expand All @@ -693,6 +694,11 @@ function calculate_quota() {
}

if($_SESSION['groupfolders_active'])

// Reset values
$_SESSION['quota_groupfolders_used'] = 0;
$_SESSION['quota_groupfolders_assigned'] = 0;

foreach($_SESSION['raw_groupfolders_data']['ocs']['data'] as $groupfolder) {
$_SESSION['quota_groupfolders_used'] += $groupfolder['size'];
$_SESSION['quota_groupfolders_assigned'] += $groupfolder['quota'];
Expand Down Expand Up @@ -950,9 +956,9 @@ function delete_temp_folder() {
*
*/
function build_table_user_data($user_data) {
$data_choices = $_SESSION['data_choices'];

require 'config.php';
$data_choices = $_SESSION['data_choices'];

if($_SESSION['filters_set']) {
echo count($user_data)." ".L10N_USERS." ".L10N_FILTERED_BY.
Expand Down Expand Up @@ -1203,7 +1209,7 @@ function build_table_groupfolder_data() {

if($perc_used < $negligible_limit_percent)
$perc_used = "< ".$negligible_limit_percent." %";
else
elseif ($perc_used !== "N/A")
$perc_used .= " %";

$color_text_perc = ($perc_used === "N/A"
Expand Down Expand Up @@ -1557,11 +1563,14 @@ function logout() {

function check_and_set_filter($filter) {

if(!$_SESSION['filters_set'])
return;
include 'config.php';

switch($filter) {
case 'group':
if($filter_group && !$_SESSION['group_filter_checked_by_config']) {
$_SESSION['group_filter_checked_by_config'] = true;
return " checked";
}
$chosen_filter = 'filter_group_choice';
break;
case 'lastLogin':
Expand All @@ -1572,6 +1581,9 @@ function check_and_set_filter($filter) {
break;
}

if(!$_SESSION['filters_set'])
return;

if(in_array($chosen_filter, $_SESSION['filters_set']))
return " checked";

Expand Down
8 changes: 6 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
// Include language file
require_once 'l10n/'.$_SESSION['language'].'.php';

// Check access_token if set and supplied
/**
* Check access_token if set and supplied
*/
if($access_token) {

if(!$_SESSION['access_token_provided'])
Expand All @@ -48,11 +50,13 @@
*/
$_SESSION['data_choices'] = isset($_GET["select"])
? explode(",", $_GET["select"])
: ['id', 'displayname', 'email', 'lastLogin'];
: $data_choices;
// Check if export type has been set (GET parameter 'type'), else default to 'table'
$_SESSION['export_type'] = $_GET['type'] ?? 'table';
// Check if message mode has been set (GET parameter 'msg_mode'), else default to 'bcc'
$_SESSION['message_mode'] = $_GET['msg_mode'] ?? 'bcc';
// Check if group has been selected for filtering
$_SESSION['filter_group'] = $_GET['filter_group'] ?? $filter_group;

// Populate session array 'data_options' with all data options that can be selected
set_data_options();
Expand Down
27 changes: 21 additions & 6 deletions users.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,35 @@ function toggle(source) {
<input type='checkbox' name='filter_group_choice' value='set_filter'"
.check_and_set_filter('group').">
<label for='filter_group_choice'>".L10N_GROUP."</label>
<select name='filter_group'>
<option value='' selected>-- ".L10N_SELECT_GROUP." --</option>";
foreach($_SESSION['grouplist'] as $item)
echo "<option value='$item'>$item</option>";
<select name='filter_group'>";
foreach($_SESSION['grouplist'] as $item) {
$selected = $item == $_SESSION['filter_group']
? ' selected'
: '';
echo "<option value='$item'$selected>$item</option>";
}
echo "</select>
</td>
</tr><tr>
<td>
<input type='checkbox' name='filter_lastLogin_choice' value='set_filter'"
.check_and_set_filter('lastLogin').">
<label for='filter_lastLogin_choice'>".L10N_LAST_LOGIN_BETWEEN." </label>
<input type=date name='filter_ll_since'>
<input type=date name='filter_ll_since'";

if($_SESSION['filter_ll_since'])
echo " value='{$_SESSION['filter_ll_since']}'";

echo ">
".L10N_AND."
<input type=date name='filter_ll_before' value='".date('Y-m-d')."'>
<input type=date name='filter_ll_before' value='";

if($_SESSION['filter_ll_before'])
echo $_SESSION['filter_ll_before'];
else
echo date('Y-m-d');

echo "'>
</td>
</tr>
<tr>
Expand Down

0 comments on commit ac4c4fe

Please sign in to comment.