Remove use of each() as it is deprecated
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 16 Jan 2021 09:42:31 +0000 (09:42 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 16 Jan 2021 09:42:31 +0000 (09:42 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14881 7612ce4b-ef26-0410-bec9-ea0150e637f0

13 files changed:
functions/abook_database.php
functions/addressbook.php
functions/imap_general.php
functions/imap_mailbox.php
functions/mime.php
include/load_prefs.php
include/options/display.php
plugins/calendar/calendar.php
plugins/calendar/day.php
plugins/calendar/functions.php
plugins/squirrelspell/modules/check_me.mod
plugins/squirrelspell/modules/lang_setup.mod
templates/util_addressbook.php

index e0f12c5af2eeb0b23186b31dd82d64de1a685efc..45c2146d5f80259360a16316f78df0d77a1e3f28 100644 (file)
@@ -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';
index 64659b77e187abff2bc419259161928e9c842a8a..49e92158c292bfeefd512a6769cfeb409a775c33 100644 (file)
@@ -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;
         }
index fe6b7b88b9c5c6bab8c085ce7bd65f552689d4e8..0ea206a362fa7a94b5e9010b909a1c6f54788f51 100755 (executable)
@@ -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];
index 9b2f2b84a54d6ce7da38cbb7cad3fc5d195edf5e..2da924bb1527eee2886094879cd31991fa819e9c 100755 (executable)
@@ -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;
                 }
             }
         }
index 0e6d106a0def74a61c2860db0ad6f9534b69435a..6e0ee801f0b2e7b0f412c8efd9511b700c5e0a00 100644 (file)
@@ -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.
          */
index 633531349697b5b4663bcc2dc06295da8bdf0077..7db84c642c84a492fa2337b255475225b8ca85b3 100644 (file)
@@ -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;
+        }
     }
 }
 
index 33496d569ece8e6221097a3712f0c0b3036c5b24..3fc08c703469cc3257747c81bf9b1700bd20ae01 100644 (file)
@@ -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;
+            }
         }
     }
     
index 30736bc83ebff97e97adf2cdd0f3390f4d030b08..9967c3e009a1d3617dd4567852988e3217e418d7 100644 (file)
@@ -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 "<a href=\"#\" style=\"text-decoration:none; color: "
index b8c9c5107e3ba5fa0a838ce7d076d0cd0362dbc3..fd17e621e2db2e9fd8ab69c620fc17e4352f6963 100644 (file)
@@ -80,8 +80,8 @@ function initialize_events() {
     $cdate = $month . $day . $year;
 
     if (isset($calendardata[$cdate])){
-        while ( $calfoo = each($calendardata[$cdate])){
-            $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']];
+        foreach ($calendardata[$cdate] as $key => $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', '&nbsp;', 'left' ) .
                        html_tag( 'td',
                            "<font size=\"-1\"><a href=\"event_create.php?year=$year&amp;month=$month&amp;day=$day&amp;hour="
-                           .substr($calfoo['key'],0,2)."\">".
+                           .substr($key,0,2)."\">".
                            _("ADD") . "</a></font>" ,
                        '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',
                             "<font size=\"-1\"><nobr>\n" .
                             "<a href=\"event_edit.php?year=$year&amp;month=$month&amp;day=$day&amp;hour=".
-                            substr($calfoo['key'],0,2)."&amp;minute=".substr($calfoo['key'],2,2)."\">".
+                            substr($key,0,2)."&amp;minute=".substr($key,2,2)."\">".
                             _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
                             "<a href=\"event_delete.php?dyear=$year&amp;dmonth=$month&amp;dday=$day&amp;dhour=".
-                            substr($calfoo['key'],0,2)."&amp;dminute=".substr($calfoo['key'],2,2).
+                            substr($key,0,2)."&amp;dminute=".substr($key,2,2).
                             "&amp;year=$year&amp;month=$month&amp;day=$day\">" .
                             _("DEL") . '</a>' .
                             "</nobr></font>\n" ,
index a27630153e67ba5283cee2641d4594e4e5c7654d..ac0051867149e25f2f4776d8de0152d2a163567a 100644 (file)
@@ -71,11 +71,11 @@ function select_option_length($selected) {
         '360' => _("6 hr.")
     );
 
-    while( $bar = each($eventlength)) {
-        if($bar['key']==$selected){
-            echo '        <option value="'.$bar['key'].'" selected="selected">'.$bar['value']."</option>\n";
+    foreach($eventlength as $key => $value) {
+        if($key==$selected){
+            echo '        <option value="'.$key.'" selected="selected">'.$value."</option>\n";
         } else {
-            echo '        <option value="'.$bar['key'].'">'.$bar['value']."</option>\n";
+            echo '        <option value="'.$key.'">'.$value."</option>\n";
         }
     }
 }
@@ -103,11 +103,11 @@ function select_option_minute($selected) {
         '55'=>'55'
     );
 
-    while ( $bar = each($eventminute)) {
-        if ($bar['key']==$selected){
-            echo '        <option value="'.$bar['key'].'" selected="selected">'.$bar['value']."</option>\n";
+    foreach ($eventminute as $key => $value) {
+        if ($key==$selected){
+            echo '        <option value="'.$key.'" selected="selected">'.$value."</option>\n";
         } else {
-            echo '        <option value="'.$bar['key'].'">'.$bar['value']."</option>\n";
+            echo '        <option value="'.$key.'">'.$value."</option>\n";
         }
     }
 }
@@ -141,11 +141,11 @@ function select_option_priority($selected) {
         '1' => _("High"),
     );
 
-    while( $bar = each($eventpriority)) {
-        if($bar['key']==$selected){
-            echo '        <option value="'.$bar['key'].'" selected="selected">'.$bar['value']."</option>\n";
+    foreach($eventpriority as $key => $value) {
+        if($key==$selected){
+            echo '        <option value="'.$key.'" selected="selected">'.$value."</option>\n";
         } else {
-            echo '        <option value="'.$bar['key'].'">'.$bar['value']."</option>\n";
+            echo '        <option value="'.$key.'">'.$value."</option>\n";
         }
     }
 }
index 4753c1b558aceeac432d281943674e2a788b8956..7e87fb94c3cf5f7f1553fc7c82434cbab17514e0 100644 (file)
@@ -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++;
   }
index 81c34395f8a4773fa26416308c709b8925e9eebc..185018e24a47824a479b1378b6c14399716dae02 100644 (file)
@@ -32,7 +32,7 @@ $langs = sqspell_getSettings();
 $add = '<p><label for="lang_default">'
   . _("Make this dictionary my default selection:")
   . "</label> <select name=\"lang_default\" id=\"lang_default\">\n";
-while (list($avail_lang, $junk) = each($SQSPELL_APP)){
+foreach ($SQSPELL_APP as $avail_lang => $ignore){
   $msg .= "<input type=\"checkbox\" name=\"use_langs[]\" "
     . "value=\"$avail_lang\" id=\"use_langs_$avail_lang\"";
   if (in_array($avail_lang, $langs)) {
index 1dd2e3fd97405d15d576dda78cb6d7bffcb63f12..df00167e0e7616e5b28d152ab2dfc156031d7012 100644 (file)
@@ -39,7 +39,7 @@ function formatAddressList ($addresses) {
         return array();
         
     $contacts = array();
-    while(list($undef,$row) = each($addresses)) {
+    foreach($addresses as $row) {
         $contact = array (
                             'FirstName'      => 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;
         }