From c71c845ce8a5f100f9b072a6143c8adfa3df7470 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Sat, 16 Jan 2021 09:42:31 +0000 Subject: [PATCH] Remove use of each() as it is deprecated git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14881 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/abook_database.php | 4 ++-- functions/addressbook.php | 4 ++-- functions/imap_general.php | 2 +- functions/imap_mailbox.php | 4 ++-- functions/mime.php | 4 ++-- include/load_prefs.php | 12 ++++++---- include/options/display.php | 19 ++++++++++------ plugins/calendar/calendar.php | 6 ++--- plugins/calendar/day.php | 20 ++++++++-------- plugins/calendar/functions.php | 24 ++++++++++---------- plugins/squirrelspell/modules/check_me.mod | 4 ++-- plugins/squirrelspell/modules/lang_setup.mod | 2 +- templates/util_addressbook.php | 4 ++-- 13 files changed, 59 insertions(+), 50 deletions(-) diff --git a/functions/abook_database.php b/functions/abook_database.php index e0f12c5a..45c2146d 100644 --- a/functions/abook_database.php +++ b/functions/abook_database.php @@ -681,7 +681,7 @@ class abook_database extends addressbook_backend { $sepstr = ''; $where_clause = ''; $where_clause_args = array(); - while (list($undef, $nickname) = each($alias)) { + foreach ($alias as $nickname) { $where_clause .= $sepstr . $this->identifier_quote_char . 'nickname' . $this->identifier_quote_char . ' = ?'; $where_clause_args[] = $nickname; $sepstr = ' OR '; @@ -705,7 +705,7 @@ class abook_database extends addressbook_backend { $this->table, $this->owner); $sepstr = ''; - while (list($undef, $nickname) = each($alias)) { + foreach ($alias as $nickname) { $query .= sprintf("%s nickname='%s' ", $sepstr, $this->dbh->quoteString($nickname)); $sepstr = 'OR'; diff --git a/functions/addressbook.php b/functions/addressbook.php index 64659b77..49e92158 100644 --- a/functions/addressbook.php +++ b/functions/addressbook.php @@ -141,7 +141,7 @@ function addressbook_init($showerr = true, $onlylocal = false) { /* Load configured LDAP servers (if PHP has LDAP support) */ if (isset($ldap_server) && is_array($ldap_server)) { reset($ldap_server); - while (list($undef,$param) = each($ldap_server)) { + foreach ($ldap_server as $param) { if (!is_array($param)) continue; @@ -251,7 +251,7 @@ function getWritableBackends () { $write = array(); $backends = $abook->get_backend_list(); - while (list($undef,$v) = each($backends)) { + foreach ($backends as $v) { if ($v->writeable) { $write[$v->bnum]=$v->sname; } diff --git a/functions/imap_general.php b/functions/imap_general.php index fe6b7b88..0ea206a3 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -1272,7 +1272,7 @@ function sqimap_get_delimiter ($imap_stream = false) { $pn = $data2[1]; $pna = explode(')(', $pn); $delnew = array(); - while (list($k, $v) = each($pna)) { + foreach ($pna as $v) { $lst = explode('"', $v); if (isset($lst[3])) { $delnew[$lst[1]] = $lst[3]; diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 9b2f2b84..2da924bb 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -857,10 +857,10 @@ function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_sk $lowerbox = strtolower(sm_encode_html_special_chars($value)); $sel = false; if ($show_selected != 0) { - reset($show_selected); - while (!$sel && (list($x, $val) = each($show_selected))) { + foreach ($show_selected as $val)) { if (strtolower($value) == strtolower(sm_encode_html_special_chars($val))) { $sel = true; + break; } } } diff --git a/functions/mime.php b/functions/mime.php index 0e6d106a..6e0ee801 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -1382,7 +1382,7 @@ function sq_tagprint($tagname, $attary, $tagtype){ $fulltag = '<' . $tagname; if (is_array($attary) && sizeof($attary)){ $atts = Array(); - while (list($attname, $attvalue) = each($attary)){ + foreach ($attary as $attname => $attvalue){ array_push($atts, "$attname=$attvalue"); } $fulltag .= ' ' . join(" ", $atts); @@ -1816,7 +1816,7 @@ function sq_fixatts($tagname, $mailbox ){ $me = 'sq_fixatts'; - while (list($attname, $attvalue) = each($attary)){ + foreach ($attary as $attname => $attvalue){ /** * See if this attribute should be removed. */ diff --git a/include/load_prefs.php b/include/load_prefs.php index 63353134..7db84c64 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -511,16 +511,20 @@ $oTemplate = Template::construct_template($sTemplateID); // need to adjust $chosen_theme path with SM_PATH $chosen_theme_path = preg_replace("/(\.\.\/){1,}/", SM_PATH, $chosen_theme_path); $found_theme = false; -while (!$found_theme && (list($index, $data) = each($user_themes))) { - if ($data['PATH'] == $chosen_theme_path) +foreach ($user_themes as $data) { + if ($data['PATH'] == $chosen_theme_path) { $found_theme = true; + break; + } } if (!$found_theme) { $template_themes = $oTemplate->get_alternative_stylesheets(true); - while (!$found_theme && (list($path, $name) = each($template_themes))) { - if ($path == $chosen_theme_path) + foreach ($template_themes as $path => $name) { + if ($path == $chosen_theme_path) { $found_theme = true; + break; + } } } diff --git a/include/options/display.php b/include/options/display.php index 33496d56..3fc08c70 100644 --- a/include/options/display.php +++ b/include/options/display.php @@ -523,9 +523,11 @@ function icon_theme_save($option) { // Don't assume the new value is there, double check // and only save if found $found = false; - while (!$found && (list($index, $data) = each($icon_themes))) { - if ($data['PATH'] == $option->new_value) + foreach ($icon_themes as $data) { + if ($data['PATH'] == $option->new_value) { $found = true; + break; + } } if (!$found) @@ -540,17 +542,20 @@ function css_theme_save ($option) { // Don't assume the new value is there, double check // and only save if found $found = false; - reset($user_themes); - while (!$found && (list($index, $data) = each($user_themes))) { - if ($data['PATH'] == $option->new_value) + foreach ($user_themes as $data) { + if ($data['PATH'] == $option->new_value) { $found = true; + break; + } } if (!$found) { $template_themes = $oTemplate->get_alternative_stylesheets(true); - while (!$found && (list($path, $name) = each($template_themes))) { - if ($path == $option->new_value) + foreach ($template_themes as $path => $name) { + if ($path == $option->new_value) { $found = true; + break; + } } } diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index 30736bc8..9967c3e0 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -110,10 +110,10 @@ function drawmonthview() { } if (isset($calendardata[$cdate])){ $i=0; - while ($calfoo = each($calendardata[$cdate])) { - $calbar = $calendardata[$cdate][$calfoo['key']]; + foreach ($calendardata[$cdate] as $key => $value) { + $calbar = $calendardata[$cdate][$key]; // FIXME: how to display multiline task - $title = '['. $calfoo['key']. '] ' . + $title = '['. $key. '] ' . str_replace(array("\r","\n"),array(' ',' '),sm_encode_html_special_chars($calbar['message'])); // FIXME: link to nowhere echo " $value){ + $daily_events[$key] = $calendardata[$cdate][$key]; } } } @@ -96,28 +96,28 @@ function display_events() { ksort($daily_events,SORT_STRING); $eo=0; - while ($calfoo = each($daily_events)){ + foreach ($daily_events as $key => $value) { if ($eo==0){ $eo=4; } else { $eo=0; } - $ehour = substr($calfoo['key'],0,2); - $eminute = substr($calfoo['key'],2,2); - if (!is_array($calfoo['value'])){ + $ehour = substr($key,0,2); + $eminute = substr($key,2,2); + if (!is_array($value)){ echo html_tag( 'tr', html_tag( 'td', $ehour . ':' . $eminute, 'left' ) . html_tag( 'td', ' ', 'left' ) . html_tag( 'td', "". + .substr($key,0,2)."\">". _("ADD") . "" , 'center' ) , '', $color[$eo]); } else { - $calbar=$calfoo['value']; + $calbar=$value; if ($calbar['length']!=0){ $elength = '-'.date_intl(_("H:i"),mktime($ehour,$eminute+$calbar['length'],0,1,1,0)); } else { @@ -133,10 +133,10 @@ function display_events() { html_tag( 'td', "\n" . "". + substr($key,0,2)."&minute=".substr($key,2,2)."\">". _("EDIT") . " | \n" . "" . _("DEL") . '' . "\n" , diff --git a/plugins/calendar/functions.php b/plugins/calendar/functions.php index a2763015..ac005186 100644 --- a/plugins/calendar/functions.php +++ b/plugins/calendar/functions.php @@ -71,11 +71,11 @@ function select_option_length($selected) { '360' => _("6 hr.") ); - while( $bar = each($eventlength)) { - if($bar['key']==$selected){ - echo ' \n"; + foreach($eventlength as $key => $value) { + if($key==$selected){ + echo ' \n"; } else { - echo ' \n"; + echo ' \n"; } } } @@ -103,11 +103,11 @@ function select_option_minute($selected) { '55'=>'55' ); - while ( $bar = each($eventminute)) { - if ($bar['key']==$selected){ - echo ' \n"; + foreach ($eventminute as $key => $value) { + if ($key==$selected){ + echo ' \n"; } else { - echo ' \n"; + echo ' \n"; } } } @@ -141,11 +141,11 @@ function select_option_priority($selected) { '1' => _("High"), ); - while( $bar = each($eventpriority)) { - if($bar['key']==$selected){ - echo ' \n"; + foreach($eventpriority as $key => $value) { + if($key==$selected){ + echo ' \n"; } else { - echo ' \n"; + echo ' \n"; } } } diff --git a/plugins/squirrelspell/modules/check_me.mod b/plugins/squirrelspell/modules/check_me.mod index 4753c1b5..7e87fb94 100644 --- a/plugins/squirrelspell/modules/check_me.mod +++ b/plugins/squirrelspell/modules/check_me.mod @@ -201,7 +201,7 @@ if ($errors){ */ $extrajs.= "var suggestions = new Array();\n"; $i=0; - while (list($word, $value) = each($misses)){ + foreach ($misses as $value){ if ($value=='_NONE') $value=''; $extrajs.= "suggestions[$i] = \"$value\";\n"; $i++; @@ -213,7 +213,7 @@ if ($errors){ */ $extrajs.= "var locations= new Array();\n"; $i=0; - while (list($word, $value) = each($locations)){ + foreach ($locations as $value){ $extrajs.= "locations[$i] = \"$value\";\n"; $i++; } diff --git a/plugins/squirrelspell/modules/lang_setup.mod b/plugins/squirrelspell/modules/lang_setup.mod index 81c34395..185018e2 100644 --- a/plugins/squirrelspell/modules/lang_setup.mod +++ b/plugins/squirrelspell/modules/lang_setup.mod @@ -32,7 +32,7 @@ $langs = sqspell_getSettings(); $add = '

sm_encode_html_special_chars($row['firstname']), 'LastName' => sm_encode_html_special_chars($row['lastname']), @@ -150,7 +150,7 @@ function getBackends () { $backends = array(); $backends['-1'] = _("All address books"); $ret = $abook->get_backend_list(); - while (list($undef,$v) = each($ret)) { + foreach ($ret as $v) { if ($v->btype == 'local' && !$v->listing) { continue; } -- 2.25.1