X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddrbook_search.php;h=d5e027d58860bedbee16cdf4cef431c826a22dfb;hb=010ce1b3cf60603c746f1538a8097a25e8fa7250;hp=ad41bfefa0b50e08634bd5cfd8aabd299b67c530;hpb=2a833d7253739cb67eb69aa760f7b37fe7aedd8c;p=squirrelmail.git diff --git a/src/addrbook_search.php b/src/addrbook_search.php index ad41bfef..d5e027d5 100644 --- a/src/addrbook_search.php +++ b/src/addrbook_search.php @@ -1,81 +1,40 @@ "; - } else { - echo "\n"; - } - - // Just make a blank page and exit - if(($show == "blank") || (empty($query) && empty($show))) { - printf("


%s

\n\n", - _("Search results will display here")); - exit; - } - - // Create search form - if($show == "form") { - printf("
\n", - $PHP_SELF); - printf(""); - printf("
\n"); - printf(" %s:\n\n", - _("Search for")); - printf(" \n", - htmlspecialchars($query)); - printf("\n"); - printf(" ", - _("Search")); - printf("\n"); - printf("\n", - _("Close window")); - printf("
\n"); - } +/*****************************************************************/ +/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/ +/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/ +/*** + Base level indent should begin at left margin, as ***/ +/*** the require_once below looks. ***/ +/*** + All identation should consist of four space blocks ***/ +/*** + Tab characters are evil. ***/ +/*** + all comments should use "slash-star ... star-slash" ***/ +/*** style -- no pound characters, no slash-slash style ***/ +/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/ +/*** ALWAYS USE { AND } CHARACTERS!!! ***/ +/*** + Please use ' instead of ", when possible. Note " ***/ +/*** should always be used in _( ) function calls. ***/ +/*** Thank you for your help making the SM code more readable. ***/ +/*****************************************************************/ + +require_once('../src/validate.php'); - // Include JavaScript code if this is search results - if(!empty($query)) { + // Function to include JavaScript code + function insert_javascript() { ?> -s_search($query); - - if(!is_array($res)) { - printf("


%s:
%s

\n\n", - _("Your search failed with the following error(s)"), - $abook->error); - exit; - } - - if(sizeof($res) == 0) { - printf("


%s.

\n\n", - _("No persons matching your search was found")); - exit; - } - - // List search results - $line = 0; - print ""; - printf("\n", - _("Name"), _("E-mail"), _("Info"), _("Source")); - - while(list($key, $row) = each($res)) { - printf("\n", - ($line % 2) ? " bgcolor=\"$color[0]\"" : "", $row["email"], - $row["email"], $row["name"], $row["email"], $row["email"], - $row["label"], $row["source"]); - $line++; - } - print "
 ". - " %s %s". - " %s". - " %s
". - "To | ". - "Cc". - " %s  ". - "%s ". - " %s  %s
"; - } -?> +'; + printf(" ". + " %s %s". + " %s", + _("Name"), _("E-mail"), _("Info")); + + if($includesource) + printf(" %s", _("Source")); + + echo "\n"; + + while(list($undef, $row) = each($res)) { + printf("". + "To | ". + "Cc | ". + "Bcc". + " %s ". + " %s ". + " %s ", + ($line % 2) ? " bgcolor=\"$color[0]\"" : "", + $row["email"], $row["email"], $row["email"], + $row["name"], $row["email"], $row["email"], + $row["label"]); + + if($includesource) + printf(" %s", $row["source"]); + + echo "\n"; + $line++; + } + echo ''; + } + + /* ================= End of functions ================= */ + + require_once('../functions/array.php'); + require_once('../functions/strings.php'); + require_once('../functions/addressbook.php'); + + displayHtmlHeader(); + + // Initialize vars + if(!isset($query)) $query = ""; + if(!isset($show)) $show = ""; + + // Choose correct colors for top and bottom frame + if($show == 'form') { + echo "'; + } else { + echo "\n"; + } + + // Empty search + if(empty($query) && empty($show) && empty($listall)) { + printf("


%s

\n\n", + _("No persons matching your search was found")); + exit; + } + + // Initialize addressbook + $abook = addressbook_init(); + + // Create search form + if($show == 'form') { + echo "
\n"; + echo ''; + echo "
\n"; + printf(" %s\n", _("Search for")); + printf(" \n", + htmlspecialchars($query)); + + // List all backends to allow the user to choose where to search + if($abook->numbackends > 1) { + printf("%s \n"; + } else { + print "\n"; + } + + printf("", + _("Search")); + printf(" | \n", + _("List all")); + print "\n"; + printf("\n", + _("Close window")); + print "
\n"; + } else + + // Show personal addressbook + if($show == 'blank' || !empty($listall)) { - + if($backend != -1 || $show == 'blank') { + if($show == 'blank') + $backend = $abook->localbackend; + + $res = $abook->list_addr($backend); + + if(is_array($res)) { + display_result($res, false); + } else { + printf("

"._("Unable to list addresses from %s"). + "

\n", $abook->backends[$backend]->sname); + } + + } else { + $res = $abook->list_addr(); + display_result($res, true); + } + + } else + + // Do the search + if(!empty($query) && empty($listall)) { + + if($backend == -1) { + $res = $abook->s_search($query); + } else { + $res = $abook->s_search($query, $backend); + } + + if(!is_array($res)) { + printf("


%s:
%s

\n\n", + _("Your search failed with the following error(s)"), + $abook->error); + exit; + } + + if(sizeof($res) == 0) { + printf("


%s.

\n\n", + _("No persons matching your search was found")); + exit; + } + + display_result($res); + } + + echo "\n"; + +?>