Skip to content

Commit

Permalink
Merge pull request #345 from bbannon/Global
Browse files Browse the repository at this point in the history
php function global
  • Loading branch information
craigk5n authored Aug 5, 2023
2 parents e2e231b + f103a5d commit 54e779c
Show file tree
Hide file tree
Showing 20 changed files with 185 additions and 176 deletions.
2 changes: 1 addition & 1 deletion events_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ function setCategories ( $eventList )
// Get all categories for each event.
function load_category_ids ( $ids )
{
global $eventCats, $user, $debug;
global $debug, $eventCats, $user;
//$ids = array_unique ( sort ( $ids, SORT_NUMERIC ) );
$idList = implode ( ",", $ids );
if ( $debug )
Expand Down
4 changes: 2 additions & 2 deletions import.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* - non-admin users this functionality
*/
function print_user_list() {
global $is_admin, $is_assistant, $is_nonuser_admin, $login,
$NONUSER_AT_TOP, $NONUSER_ENABLED, $single_user;
global $is_admin, $is_assistant, $is_nonuser_admin,
$login, $NONUSER_AT_TOP, $NONUSER_ENABLED, $single_user;

if ( $single_user == 'N' && $is_admin ) {
$userlist = user_get_users();
Expand Down
9 changes: 5 additions & 4 deletions includes/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,9 @@ function get_default_function_access( $page_id, $user ) {

function access_user_calendar( $cal_can_xxx, $other_user, $cur_user = '',
$type = '', $access = '' ) {
global $access_other_cals, $access_users, $ADMIN_OVERRIDE_UAC,
$ALLOW_VIEW_OTHER, $is_admin, $login;

global $access_other_cals, $access_users,
$ADMIN_OVERRIDE_UAC, $ALLOW_VIEW_OTHER, $is_admin, $login;

$admin_override = ( $is_admin && ! empty( $ADMIN_OVERRIDE_UAC )
&& $ADMIN_OVERRIDE_UAC == 'Y' );
Expand Down Expand Up @@ -556,10 +557,10 @@ function access_user_calendar( $cal_can_xxx, $other_user, $cur_user = '',
$type_wt = TASK_WT;

$total_wt = $type_wt & $access_wt;

if( !is_numeric($ret) )
$ret = 0;

$ret = ( $ret &$total_wt ? $ret : 0 );
}

Expand Down
4 changes: 2 additions & 2 deletions includes/classes/WebCalMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class WebCalMailer {
* Constructor
*/
function __construct() {
global $EMAIL_MAILER, $mailerError,
$SMTP_AUTH, $SMTP_HOST, $SMTP_PORT, $SMTP_PASSWORD, $SMTP_USERNAME;
global $EMAIL_MAILER, $mailerError, $SMTP_AUTH,
$SMTP_HOST, $SMTP_PORT, $SMTP_PASSWORD, $SMTP_USERNAME;

$this->mail = new PHPMailer\PHPMailer(false);
$mailerError = '';
Expand Down
31 changes: 15 additions & 16 deletions includes/classes/WebCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ function addExternalPage ( $pattern, $initArray ) {
* @access private
*/
function _initInitFirstPhase() {
global $DMW, $HTTP_GET_VARS, $HTTP_POST_VARS, $PHP_SELF, $SCRIPT, $self,
$special, $user_inc;
global $DMW, $HTTP_GET_VARS, $HTTP_POST_VARS,
$PHP_SELF, $SCRIPT, $self, $special, $user_inc;

// Make sure another app in the same domain doesn't have a 'user' cookie.
if ( empty ( $HTTP_GET_VARS ) )
Expand Down Expand Up @@ -156,13 +156,12 @@ function _initInitFirstPhase() {
*/
function _initInitSecondPhase() {
global $ALLOW_VIEW_OTHER, $can_add, $cat_id, $CATEGORIES_ENABLED,
$CATEGORY_VIEW, $caturl, $date, $DMW, $friendly, $ignore_user_case,
$override, $fullname, $GROUPS_ENABLED,
$hour, $id, $is_admin, $is_assistant, $is_nonuser, $is_nonuser_admin,
$login, $minute, $month,
$NONUSER_ENABLED, $nonusers, $ovrd, $PUBLIC_ACCESS, $PUBLIC_ACCESS_CAN_ADD,
$PUBLIC_ACCESS_FULLNAME, $PUBLIC_ACCESS_OTHERS, $readonly, $u_url, $user,
$user_fullname, $USER_SEES_ONLY_HIS_GROUPS, $userlist, $valid_user, $year;
$CATEGORY_VIEW, $caturl, $date, $DMW, $friendly, $fullname, $GROUPS_ENABLED,
$hour, $id, $ignore_user_case, $is_admin, $is_assistant, $is_nonuser_admin,
$is_nonuser, $login, $minute, $month, $NONUSER_ENABLED, $nonusers,
$override, $ovrd, $PUBLIC_ACCESS_CAN_ADD, $PUBLIC_ACCESS_FULLNAME,
$PUBLIC_ACCESS_OTHERS, $PUBLIC_ACCESS, $readonly, $u_url, $user_fullname,
$USER_SEES_ONLY_HIS_GROUPS, $user, $userlist, $valid_user, $year;

load_global_settings();

Expand Down Expand Up @@ -311,8 +310,8 @@ function _initPHPDBI() {
* @access private
*/
function _initFunctions() {
global $byday_names, $byday_values, $days_per_month, $db_login, $db_password,
$ldays_per_month,
global $byday_names, $byday_values, $days_per_month,
$db_login, $db_password, $ldays_per_month,
$offsets, $PHP_SELF, $settings, $weekday_names;

/**#@+
Expand Down Expand Up @@ -623,8 +622,8 @@ function _initConnect() {
$login_email, $login_firstname, $login_fullname, $login_is_admin,
$login_lastname, $login_login, $login_url, $not_auth, $PHP_AUTH_USER,
$PHP_SELF, $PROGRAM_VERSION, $pub_acc_enabled, $PUBLIC_ACCESS_CAN_ADD,
$readonly, $SCRIPT, $session_not_found, $single_user, $single_user_login,
$use_http_auth, $user_email, $user_inc;
$readonly, $SCRIPT, $session_not_found, $single_user,
$single_user_login, $use_http_auth, $user_email, $user_inc;

// db settings are in config.php.

Expand Down Expand Up @@ -899,8 +898,8 @@ function _initAccess() {
* @access private
*/
function _initTranslate() {
global $lang, $lang_file, $LANGUAGE, $PUBLIC_ACCESS_FULLNAME,
$translation_loaded, $enable_mbstring;
global $enable_mbstring, $lang_file, $lang,
$LANGUAGE, $PUBLIC_ACCESS_FULLNAME, $translation_loaded;

if ( empty ( $LANGUAGE ) )
$LANGUAGE = 'English-US'; // Default
Expand Down Expand Up @@ -1023,4 +1022,4 @@ function absolutePath ( $path ) {
}
}

?>
?>
84 changes: 43 additions & 41 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ function calc_time_slot ( $time, $round_down = false ) {
*/
function check_for_conflicts ( $dates, $duration, $eventstart,
$participants, $login, $id ) {
global $LIMIT_APPTS, $LIMIT_APPTS_NUMBER, $repeated_events,
$single_user, $single_user_login, $jumpdate;
global $jumpdate, $LIMIT_APPTS_NUMBER, $LIMIT_APPTS,
$repeated_events, $single_user_login, $single_user;

$datecnt = count ( $dates );
if ( ! $datecnt )
Expand Down Expand Up @@ -531,9 +531,9 @@ function combine_and_sort_events ( $ev, $rep ) {
* @return string HTML to display matrix.
*/
function daily_matrix ( $date, $participants, $popup = '' ) {
global $CELLBG, $ENTRY_SLOTS, $events, $repeated_events, $TABLEBG, $THBG,
$THFG, $thismonth, $thisyear, $TIME_FORMAT, $TODAYCELLBG, $user_fullname,
$WORK_DAY_END_HOUR, $WORK_DAY_START_HOUR;
global $CELLBG, $ENTRY_SLOTS, $events, $repeated_events, $TABLEBG,
$THBG, $THFG, $thismonth, $thisyear, $TIME_FORMAT, $TODAYCELLBG,
$user_fullname, $WORK_DAY_END_HOUR, $WORK_DAY_START_HOUR;

$allAttendeesStr = translate ( 'All Attendees' );
$busy = translate ( 'Busy' );
Expand Down Expand Up @@ -1013,9 +1013,9 @@ function display_admin_link($break = true) {
*/
function display_month( $thismonth, $thisyear, $demo = false,
$enableDblClick = false ) {
global $DISPLAY_ALL_DAYS_IN_MONTH, $DISPLAY_LONG_DAYS, $DISPLAY_WEEKNUMBER,
$is_admin, $is_nonuser, $login, $PUBLIC_ACCESS, $PUBLIC_ACCESS_CAN_ADD,
$readonly, $today, $user, $WEEKENDBG, $WEEK_START;
global $DISPLAY_ALL_DAYS_IN_MONTH, $DISPLAY_LONG_DAYS,
$DISPLAY_WEEKNUMBER, $is_admin, $is_nonuser, $login, $PUBLIC_ACCESS,
$PUBLIC_ACCESS_CAN_ADD, $readonly, $today, $user, $WEEKENDBG, $WEEK_START;

$ret = '';

Expand Down Expand Up @@ -1155,10 +1155,10 @@ function display_month( $thismonth, $thisyear, $demo = false,
*/
function display_navigation ( $name, $show_arrows = true, $show_cats = true ) {
global $cat_id, $CATEGORIES_ENABLED, $caturl, $DATE_FORMAT_MY,
$DISPLAY_SM_MONTH, $DISPLAY_TASKS, $DISPLAY_WEEKNUMBER, $is_admin,
$is_assistant, $is_nonuser_admin, $login, $nextYmd, $nowYmd, $prevYmd,
$single_user, $spacer, $thisday, $thismonth, $thisyear, $user, $user_fullname,
$wkend, $wkstart;
$DISPLAY_SM_MONTH, $DISPLAY_TASKS, $DISPLAY_WEEKNUMBER,
$is_admin, $is_assistant, $is_nonuser_admin, $login, $nextYmd,
$nowYmd, $prevYmd, $single_user, $spacer, $thisday, $thismonth,
$thisyear, $user, $user_fullname, $wkend, $wkstart;

if ( empty ( $name ) )
return;
Expand Down Expand Up @@ -1233,7 +1233,7 @@ function display_small_month ( $thismonth, $thisyear, $showyear,
global $boldDays, $caturl, $DATE_FORMAT_MY, $DISPLAY_ALL_DAYS_IN_MONTH,
$DISPLAY_TASKS, $DISPLAY_WEEKNUMBER, $get_unapproved, $login,
$MINI_TARGET, // Used by minical.php
$SCRIPT, $SHOW_EMPTY_WEEKENDS,//Used by year.php
$SCRIPT, $SHOW_EMPTY_WEEKENDS, // Used by year.php
$thisday, // Needed for day.php
$today, $use_http_auth, $user, $WEEK_START;

Expand Down Expand Up @@ -1594,8 +1594,8 @@ function display_time ( $time = '', $control = 0, $timestamp = '',
* @param string $user Current user login
*/
function display_unapproved_events ( $user ) {
global $is_admin, $is_nonuser, $login, $MENU_ENABLED,
$NONUSER_ENABLED, $PUBLIC_ACCESS;
global $is_admin, $is_nonuser, $login,
$MENU_ENABLED, $NONUSER_ENABLED, $PUBLIC_ACCESS;
static $retval;

// Don't do this for public access login,
Expand Down Expand Up @@ -2540,8 +2540,8 @@ function get_entries ( $date, $get_unapproved = true ) {
*/
function get_groups($user, $includeUserlist=false)
{
global $GROUPS_ENABLED, $USER_SEES_ONLY_HIS_GROUPS, $PUBLIC_ACCESS_FULLNAME, $NONUSER_PREFIX,
$is_nonuser_admin, $is_assistant, $login, $is_admin;
global $GROUPS_ENABLED, $is_admin, $is_assistant, $is_nonuser_admin,
$login, $NONUSER_PREFIX, $PUBLIC_ACCESS_FULLNAME, $USER_SEES_ONLY_HIS_GROUPS;

if (empty($GROUPS_ENABLED) || $GROUPS_ENABLED != 'Y')
return false;
Expand Down Expand Up @@ -2643,9 +2643,9 @@ function get_last_view ( $clear=true ) {
* - cal_is_public
*/
function get_my_nonusers ( $user = '', $add_public = false, $reason = 'invite' ) {
global $GROUPS_ENABLED, $is_admin, $is_nonuser, $is_nonuser_admin, $login,
$my_nonuser_array, $my_user_array, $PUBLIC_ACCESS, $PUBLIC_ACCESS_FULLNAME,
$USER_SEES_ONLY_HIS_GROUPS, $USER_SORT_ORDER;
global $GROUPS_ENABLED, $is_admin, $is_nonuser, $is_nonuser_admin,
$login, $my_nonuser_array, $my_user_array, $PUBLIC_ACCESS,
$PUBLIC_ACCESS_FULLNAME, $USER_SEES_ONLY_HIS_GROUPS, $USER_SORT_ORDER;

$this_user = ( empty ( $user ) ? $login : $user );
// Return the global variable (cached).
Expand Down Expand Up @@ -2751,8 +2751,8 @@ function get_my_nonusers ( $user = '', $add_public = false, $reason = 'invite' )
* - cal_fullname
*/
function get_my_users ( $user = '', $reason = 'invite' ) {
global $GROUPS_ENABLED, $is_admin, $is_nonuser, $is_nonuser_admin, $login,
$my_user_array, $USER_SEES_ONLY_HIS_GROUPS, $USER_SORT_ORDER;
global $GROUPS_ENABLED, $is_admin, $is_nonuser, $is_nonuser_admin,
$login, $my_user_array, $USER_SEES_ONLY_HIS_GROUPS, $USER_SORT_ORDER;

$this_user = ( empty ( $user ) ? $login : $user );
// Return the global variable (cached).
Expand Down Expand Up @@ -2845,6 +2845,7 @@ function get_my_users ( $user = '', $reason = 'invite' ) {
*/
function get_nonuser_cals ( $user = '', $remote = false ) {
global $is_admin, $USER_SORT_ORDER;

$count = 0;
$query_params = $ret = [];
$sql = 'SELECT cal_login, cal_lastname, cal_firstname, cal_admin,
Expand Down Expand Up @@ -2962,7 +2963,8 @@ function update_import_check_date($username)
*/
function load_remote_calendar($username, $url)
{
global $login, $errormsg, $error_num, $count_suc, $numDeleted, $calUser, $importMd5;
global $calUser, $count_suc, $error_num,
$errormsg, $importMd5, $login, $numDeleted;

// Set global vars used in xcal.php (blech)
$data = [];
Expand Down Expand Up @@ -3595,8 +3597,8 @@ function hextoint ( $val ) {
*/
function html_for_event_day_at_a_glance ( $event, $date ) {
global $ALLOW_HTML_DESCRIPTION, $categories, $DISPLAY_DESC_PRINT_DAY,
$DISPLAY_END_TIMES, $first_slot, $hour_arr, $last_slot, $layers, $login,
$PHP_SELF, $rowspan, $rowspan_arr;
$DISPLAY_END_TIMES, $first_slot, $hour_arr, $last_slot,
$layers, $login, $PHP_SELF, $rowspan, $rowspan_arr;
static $key = 0;

$can_access = CAN_DOALL;
Expand Down Expand Up @@ -3751,8 +3753,8 @@ function html_for_event_day_at_a_glance ( $event, $date ) {
function html_for_event_week_at_a_glance ( $event, $date,
$override_class = '', $show_time = true ) {
global $categories, $DISPLAY_ICONS, $DISPLAY_TZ, $eventinfo, $first_slot,
$hour_arr, $is_assistant, $is_nonuser_admin, $last_slot, $layers, $login,
$PHP_SELF, $rowspan, $rowspan_arr, $TIME_SPACER, $user;
$hour_arr, $is_assistant, $is_nonuser_admin, $last_slot, $layers,
$login, $PHP_SELF, $rowspan, $rowspan_arr, $TIME_SPACER, $user;
static $key = 0;

$can_access = CAN_DOALL;
Expand Down Expand Up @@ -4487,7 +4489,7 @@ function nonuser_load_variables ( $login, $prefix ) {
* @param int $cat_id Category id that should be pre-selected
*/
function print_category_menu ( $form, $date = '', $cat_id = '' ) {
global $categories, $login, $user, $CATEGORIES_ENABLED;
global $CATEGORIES_ENABLED, $categories, $login, $user;

if ( empty( $CATEGORIES_ENABLED ) || $CATEGORIES_ENABLED == 'N' )
return false;
Expand Down Expand Up @@ -4547,12 +4549,12 @@ function print_checkbox( $vals, $id = '', $onchange = '' ) {
$setting = $s[$vals[0]];
$variable = 'admin_' . $vals[0];
}

if( $SCRIPT == 'pref.php' ) {
$setting = $prefarray[$vals[0]];
$variable = 'pref_' . $vals[0];
}

$hidden = ( strpos( 'admin.phpref.php', $SCRIPT ) === false ? '' : '
<input type="hidden" name="' . $variable . '" value="N" />' );

Expand Down Expand Up @@ -4585,7 +4587,8 @@ function print_checkbox( $vals, $id = '', $onchange = '' ) {
* @return string HTML for the color selector.
*/
function print_color_input_html ($varname, $title, $varval = '', $id='', $tag='div', $class='form-inline', $onchange = '') {
global $SCRIPT, $s, $prefarray;
global $prefarray, $s, $SCRIPT;

$id = empty($id) ? $varname : $id;
// TODO: Get the text input box working so users can input RGB values.
//$textId = $id . 'RGB';
Expand Down Expand Up @@ -4626,9 +4629,9 @@ function print_color_input_html ($varname, $title, $varval = '', $id='', $tag='d
*/
function print_date_entries ( $date, $user, $ssi = false,
$disallowAddIcon = false ) {
global $cat_id, $DISPLAY_TASKS_IN_GRID, $DISPLAY_UNAPPROVED, $events,
$is_admin, $is_nonuser, $login, $PUBLIC_ACCESS, $PUBLIC_ACCESS_CAN_ADD,
$readonly, $tasks, $WEEK_START;
global $cat_id, $DISPLAY_TASKS_IN_GRID, $DISPLAY_UNAPPROVED,
$events, $is_admin, $is_nonuser, $login, $PUBLIC_ACCESS,
$PUBLIC_ACCESS_CAN_ADD, $readonly, $tasks, $WEEK_START;
static $newEntryStr;

if ( empty ( $newEntryStr ) )
Expand Down Expand Up @@ -4837,8 +4840,8 @@ function print_day_at_a_glance ( $date, $user, $can_add = 0 ) {
*/
function print_entry ( $event, $date ) {
global $categories, $DISPLAY_END_TIMES, $DISPLAY_LOCATION,
$DISPLAY_TASKS_IN_GRID, $eventinfo, $is_assistant, $is_nonuser_admin,
$layers, $login, $PHP_SELF, $TIME_SPACER, $user;
$DISPLAY_TASKS_IN_GRID, $eventinfo, $is_assistant,
$is_nonuser_admin, $layers, $login, $PHP_SELF, $TIME_SPACER, $user;

static $key = 0;
static $viewEventStr, $viewTaskStr;
Expand Down Expand Up @@ -5167,9 +5170,9 @@ function print_timezone_select_html ( $prefix, $tz ) {
*/
function query_events ( $user, $want_repeated, $date_filter, $cat_id = '',
$is_task = false ) {
global $db_connection_info, $jumpdate, $layers, $login, $max_until,
global $db_connection_info, $jumpdate, $layers, $login,
$max_until, $OVERRIDE_PUBLIC_TEXT, $OVERRIDE_PUBLIC,
$PUBLIC_ACCESS_DEFAULT_VISIBLE, $result, $thismonth, $thisyear;
global $OVERRIDE_PUBLIC, $OVERRIDE_PUBLIC_TEXT;

// New multiple categories requires some checking to see if this cat_id is
// valid for this cal_id. It could be done with nested SQL,
Expand Down Expand Up @@ -5650,8 +5653,7 @@ function send_to_preferred_view ( $indate = '', $args = '' ) {
* @return bool true = success false = not allowed.
*/
function set_env ( $val, $setting ) {
global $tzOffset;
global $tzInitSet;
global $tzInitSet, $tzOffset;

// Set SERVER TIMEZONE.
if ( ! $tzInitSet ) {
Expand Down Expand Up @@ -6457,4 +6459,4 @@ function sendCookie($name, $value, $expiration=0, $path='', $sensitive=true) {
SetCookie ( $name, $value, $expiration, $path, $domain, $secure, $httpOnly);
}

?>
?>
Loading

0 comments on commit 54e779c

Please sign in to comment.