فهرست منبع

While/List/Each are now ForEach

Andy 7 سال پیش
والد
کامیت
53b9dbdc2d

+ 2 - 2
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 $undef=>$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 $undef=>$nickname) {
                 $query .= sprintf("%s nickname='%s' ", $sepstr,
                                   $this->dbh->quoteString($nickname));
                 $sepstr = 'OR';

+ 2 - 3
functions/addressbook.php

@@ -140,8 +140,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 $undef=>$param) {
             if (!is_array($param))
                 continue;
 
@@ -251,7 +250,7 @@ function getWritableBackends () {
     
     $write = array();
     $backends = $abook->get_backend_list();
-    while (list($undef,$v) = each($backends)) {
+    foreach ($backends as $undef=>$v) {
         if ($v->writeable) {
             $write[$v->bnum]=$v->sname;
         }

+ 1 - 1
functions/imap_general.php

@@ -1150,7 +1150,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 $k=>$v) {
                 $lst = explode('"', $v);
                 if (isset($lst[3])) {
                     $delnew[$lst[1]] = $lst[3];

+ 2 - 1
functions/imap_mailbox.php

@@ -858,9 +858,10 @@ function sqimap_mailbox_option_list($imap_stream, $show_selected = 0, $folder_sk
         $sel = false;
         if ($show_selected != 0) {
             reset($show_selected);
-            while (!$sel && (list($x, $val) = each($show_selected))) {
+            foreach($show_selected as $x=>$val) {
                 if (strtolower($value) == strtolower(sm_encode_html_special_chars($val))) {
                     $sel = true;
+                    break;
                 }
             }
         }

+ 2 - 2
functions/mime.php

@@ -1349,7 +1349,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);
@@ -1784,7 +1784,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.
          */

+ 25 - 2
include/load_prefs.php

@@ -510,18 +510,41 @@ $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))) {
+
+/*
+while (!$found_theme && (list($index, $data) = @each($user_themes))) {
     if ($data['PATH'] == $chosen_theme_path)
         $found_theme = true;
 }
+*/
+
+foreach ($user_themes as $index => $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))) {
+    while (!$found_theme && (list($path, $name) = @each($template_themes))) {
         if ($path == $chosen_theme_path)
             $found_theme = true;
     }
 }
+*/
+
+
+if (!$found_theme) {
+    $template_themes = $oTemplate->get_alternative_stylesheets(true);
+    foreach ($template_themes as $path => $name) {
+        if ($path == $chosen_theme_path) {
+            $found_theme = true;
+            break;
+        }
+    }
+}
 
 if (!$found_theme || $chosen_theme == 'none') {
     $chosen_theme_path = NULL;

+ 12 - 7
include/options/display.php

@@ -516,9 +516,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 $index=>$data) {
+        if ($data['PATH'] == $option->new_value) {
             $found = true;
+            break;
+        }
     }
     
     if (!$found)
@@ -533,17 +535,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 $index=>$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;
+            }
         }
     }