exists with in_array (which returns just that boolean), and fix the
left over call to array_search to also check for NULL return.
This should fix the problems that Fredrik, me and other PHP 4.1 users
had with Marc's recent changes.
From PHP docs:
"Note: Prior to PHP 4.2.0, array_search() returns NULL on failure instead of FALSE."
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7547
7612ce4b-ef26-0410-bec9-
ea0150e637f0
$message_id = (int) $message_id; // we use strickt array_search
if (is_array($aMailbox['UIDSET'])) {
$key = array_search($message_id,$aMailbox['UIDSET'],true);
- if ($key !== false) {
+ if ($key !== false && !is_null($key)) {
unset($aMailbox['UIDSET'][$key]);
$aMailbox['UIDSET'] = array_values($aMailbox['UIDSET']);
// adapt the exists count to avoid triggering of a new sort
$messages = array();
$read_list = array();
- if (array_search('UID',$aFetchItems,true) !== false) {
- $bUidFetch = false;
- } else {
- $bUidFetch = true;
- }
+ $bUidFetch = ! in_array('UID', $aFetchItems, true);
/* Get the small headers for each message in $msg_list */
if ($show_num != '999999' && $show_num != '*' ) {
// display flag buttons only if supported
if ($show_flag_buttons &&
- array_search('\\flagged',$aMailbox['PERMANENTFLAGS'], true) !== FALSE) {
+ in_array('\\flagged',$aMailbox['PERMANENTFLAGS'], true) ) {
echo getButton('SUBMIT', 'markUnflagged',_("Unflag"));
echo getButton('SUBMIT', 'markFlagged',_("Flag"));
echo ' ';
}
- if (array_search('\\seen',$aMailbox['PERMANENTFLAGS'], true) !== FALSE) {
+ if (in_array('\\seen',$aMailbox['PERMANENTFLAGS'], true)) {
echo getButton('SUBMIT', 'markUnread',_("Unread"));
echo getButton('SUBMIT', 'markRead',_("Read"));
echo ' ';
echo getButton('SUBMIT', 'attache',_("Forward"));
echo ' ';
- if (array_search('\\deleted',$aMailbox['PERMANENTFLAGS'], true) !== FALSE) {
+ if (in_array('\\deleted',$aMailbox['PERMANENTFLAGS'], true)) {
echo getButton('SUBMIT', 'delete',_("Delete"));
echo '<input type="checkbox" name="bypass_trash" />' . _("Bypass Trash");
echo ' ';
?></small>
</td>
<?php
- if (array_search('\\deleted',$aMailbox['PERMANENTFLAGS'], true) !== FALSE) {
+ if (in_array('\\deleted',$aMailbox['PERMANENTFLAGS'], true)) {
echo '<td align="right">
<small>';
//echo $thread_link_str; //previous behaviour
function ServerMDNSupport($aFlags) {
/* escaping $ doesn't work -> \x36 */
- return (array_search('$mdnsent',$aFlags,true) !== false ||
- array_search('\\*',$aFlags,true) !== false) ? true : false;
- //$ret = preg_match('/(\x36MDNSent|\\\\\*)/i', $read);
- //return $ret;
+ return ( in_array('$mdnsent',$aFlags,true) ||
+ in_array('\\*',$aFlags,true) ) ;
}
function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
// Only bother with Delete & Prev and Delete & Next IF
// top display is enabled.
if ( $delete_prev_next_display == 1 &&
- array_search('\\deleted', $mbx_response['PERMANENTFLAGS'],true) !== false) {
+ in_array('\\deleted', $mbx_response['PERMANENTFLAGS'],true) ) {
$del_prev_link = _("Delete & Prev");
if ($prev >= 0) {
$uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
$menu_row .= '</form> ';
- if (array_search('\\deleted', $mbx_response['PERMANENTFLAGS'],true) !== false) {
+ if ( in_array('\\deleted', $mbx_response['PERMANENTFLAGS'],true) ) {
// Form for deletion
$delete_url = $base_uri . 'src/delete_message.php?mailbox=' . $urlMailbox;
$menu_row .= '<form action="'.$delete_url.'" method="post" style="display: inline">';
// Add top move link
$menu_row .= '</small></td><td align="right">';
if ( !(isset($passed_ent_id) && $passed_ent_id) &&
- array_search('\\deleted', $mbx_response['PERMANENTFLAGS'],true) !== false) {
+ in_array('\\deleted', $mbx_response['PERMANENTFLAGS'],true) ) {
$current_box = 'mailbox='.$mailbox.'&sort='.$sort.'&startMessage='.$startMessage;