/* List addresses */ if (count($alist) > 0) { echo addForm($form_url, 'post', 'address_book_form'); if ($abook->add_extra_field) { $abook_fields = 6; } else { $abook_fields = 5; } $count = 0; while (list($undef, $row) = each($alist)) { /* New table header for each backend */ if ($prevbackend != $row['backend']) { if ($prevbackend < 0) { echo html_tag('table', html_tag('tr', html_tag('td', addSubmit(_("Edit selected"), 'editaddr') . addSubmit(_("Delete selected"), 'deladdr') . addSubmit(_("Compose to selected"), 'compose_to', $javascript_on && $compose_new_win ? $compose_to_in_new_window_javascript : ''), 'center', '', "colspan=\"{$abook_fields}\"")) . html_tag('tr', html_tag('td', ' <br />', 'center', '', 'colspan="5"')), 'center'); } echo html_tag('table', html_tag('tr', html_tag('td', "\n" . '<strong>' . $row['source'] . '</strong>' . "\n", 'center', $color[0], 'colspan="2"')) . concat_hook_function('address_book_header', $row), 'center', '', 'width="95%"') . "\n" . html_tag('table', '', 'center', '', 'border="0" cellpadding="1" cellspacing="0" width="90%"') . html_tag('tr', "\n" . html_tag('th', ' ', 'left', '', 'width="1%"') . html_tag('th', _("Nickname") . show_abook_sort_button($abook_sort_order, _("sort by nickname"), 0, 1), 'left', '', 'width="10%"') . html_tag('th', _("Name") . show_abook_sort_button($abook_sort_order, _("sort by name"), 2, 3), 'left', '', 'width="10%"') . html_tag('th', _("E-mail") . show_abook_sort_button($abook_sort_order, _("sort by email"), 4, 5), 'left', '', 'width="10%"') . html_tag('th', _("Info") . show_abook_sort_button($abook_sort_order, _("sort by info"), 6, 7), 'left', '', 'width="10%"') . ($abook->add_extra_field ? html_tag('th', ' ', 'left', '', 'width="1%0"') : ''), '', $color[9]) . "\n"; $line = 0; $headerprinted = true; } /* End of header */ $prevbackend = $row['backend']; /* Print one row, with alternating color */ if ($line % 2) { $tr_bgcolor = $color[12]; } else { $tr_bgcolor = $color[4]; } // Print special message if that's what we have // here instead of an actual address entry if (!empty($row['special_message'])) { echo html_tag('tr', '', '', $tr_bgcolor) . html_tag('td', $row['special_message'], 'center', '', 'colspan="5"') . "</tr>\n";
/** * Displays message header row in messages list * * @param array $aMsg contains all message related parameters * @return void */ function printMessageInfo($aMsg) { // FIX ME, remove these globals as well by adding an array as argument for the user settings // specificly meant for header display global $checkall, $color, $default_use_priority, $message_highlight_list, $index_order, $truncate_sender, $email_address, $show_recipient_instead, $use_icons, $icon_theme; /* icons theming */ $color_string = $color[4]; // initialisation: $mailbox = $aMsg['MAILBOX']; $msg = $aMsg['HEADER']; $t = $aMsg['INDX']; $start_msg = $aMsg['PAGEOFFSET']; $last = $aMsg['LAST']; if (isset($aMsg['SEARCH']) && count($aMsg['SEARCH']) > 1) { $where = $aMsg['SEARCH'][0]; $what = $aMsg['SEARCH'][1]; } else { $where = false; $what = false; } $iIndent = $aMsg['INDENT']; $sSubject = isset($msg['SUBJECT']) && $msg['SUBJECT'] != '' ? $msg['SUBJECT'] : _("(no subject)"); $sFrom = isset($msg['FROM']) ? $msg['FROM'] : _("Unknown sender"); $sTo = isset($msg['TO']) ? $msg['TO'] : _("Unknown recipient"); $sCc = isset($msg['CC']) ? $msg['CC'] : ''; $aFlags = isset($msg['FLAGS']) ? $msg['FLAGS'] : array(); $iPrio = isset($msg['PRIORITY']) ? $msg['PRIORITY'] : 3; $iSize = isset($msg['SIZE']) ? $msg['SIZE'] : 0; $sType0 = isset($msg['TYPE0']) ? $msg['TYPE0'] : 'text'; $sType1 = isset($msg['TYPE1']) ? $msg['TYPE1'] : 'plain'; if (isset($msg['INTERNALDATE'])) { $sDate = getDateString(getTimeStamp(explode(' ', $msg['INTERNALDATE']))); } else { $sDate = isset($msg['DATE']) ? getDateString(getTimeStamp(explode(' ', $msg['DATE']))) : ''; } $iId = isset($msg['UID']) ? $msg['UID'] : false; if (!$iId) { return; } if ($GLOBALS['alt_index_colors']) { if (!($t % 2)) { if (!isset($color[12])) { $color[12] = '#EAEAEA'; } $color_string = $color[12]; } } $urlMailbox = urlencode($mailbox); // FIXME, foldertype should be set in right_main.php // in other words, handle as sent is obsoleted from now. // We replace that by providing an array to aMailbox with the to shown headers // that way we are free to show the user different layouts for different folders $bSentFolder = handleAsSent($mailbox); if (!$bSentFolder && $show_recipient_instead) { // If the From address is the same as $email_address, then handle as Sent $from_array = parseAddress($sFrom, 1); if (!isset($email_address)) { global $datadir, $username; $email_address = getPref($datadir, $username, 'email_address'); } $bHandleAsSent = isset($from_array[0][0]) && $from_array[0][0] == $email_address; } else { $bHandleAsSent = $bSentFolder; } // If this is a Sent message, display To address instead of From if ($bHandleAsSent) { $sFrom = $sTo; } // Passing 1 below results in only 1 address being parsed, thus defeating the following code $sFrom = parseAddress($sFrom); /* * This is done in case you're looking into Sent folders, * because you can have multiple receivers. */ $senderNames = $sFrom; $senderName = ''; $senderAddress = ''; if (sizeof($senderNames)) { foreach ($senderNames as $senderNames_part) { if ($senderName != '') { $senderName .= ', '; $senderAddress .= ', '; } $sender_address_part = htmlspecialchars($senderNames_part[0]); $sender_name_part = str_replace(' ', ' ', decodeHeader($senderNames_part[1])); if ($sender_name_part) { $senderName .= $sender_name_part; $senderAddress .= $sender_name_part . ' <' . $sender_address_part . '>'; } else { $senderName .= $sender_address_part; $senderAddress .= $sender_address_part; } } } // If Sent, prefix with To: but only if not Sent folder if ($bHandleAsSent ^ $bSentFolder) { $senderName = _("To") . ': ' . $senderName; $senderAddress = _("To") . ': ' . $senderAddress; } // this is a column property which can apply to multiple columns. Do not use vars for one column // only. instead we should use something like this: // 1ed column $aMailbox['columns']['SUBJECT'] value: aray with properties ... // 2ed column $aMailbox['columns']['FROM'] value: aray with properties ... // NB in case of the sentfolder this could be the TO field // properties array example: // 'truncate' => length (0 is no truncate) // 'prefix => if (x in b then do that ) if ($truncate_sender > 0) { $senderName = truncateWithEntities($senderName, $truncate_sender); } $flag = $flag_end = $bold = $bold_end = $fontstr = $fontstr_end = $italic = $italic_end = ''; $bold = '<b>'; $bold_end = '</b>'; foreach ($aFlags as $sFlag => $value) { switch ($sFlag) { case '\\flagged': if ($value) { $flag = "<font color=\"{$color['2']}\">"; $flag_end = '</font>'; } break; case '\\seen': if ($value) { $bold = ''; $bold_end = ''; } break; case '\\deleted': if ($value) { $fontstr = "<font color=\"{$color['9']}\">"; $fontstr_end = '</font>'; } break; } } if ($bHandleAsSent) { $italic = '<i>'; $italic_end = '</i>'; } if ($where && $what) { $searchstr = '&where=' . $where . '&what=' . $what; } else { $searchstr = ''; } /* * Message highlight code */ $matches = array('TO' => 'sTo', 'CC' => 'sCc', 'FROM' => 'sFrom', 'SUBJECT' => 'sSubject'); if (is_array($message_highlight_list) && count($message_highlight_list)) { $sTo = parseAddress($sTo); $sCc = parseAddress($sCc); foreach ($message_highlight_list as $message_highlight_list_part) { if (trim($message_highlight_list_part['value']) != '') { $high_val = strtolower($message_highlight_list_part['value']); $match_type = strtoupper($message_highlight_list_part['match_type']); if ($match_type == 'TO_CC') { $match = array('TO', 'CC'); } else { $match = array($match_type); } foreach ($match as $match_type) { switch ($match_type) { case 'TO': case 'CC': case 'FROM': foreach (${$matches}[$match_type] as $address) { $address[0] = decodeHeader($address[0], true, false); $address[1] = decodeHeader($address[1], true, false); if (strstr('^^' . strtolower($address[0]), $high_val) || strstr('^^' . strtolower($address[1]), $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 4; } } break; default: $headertest = strtolower(decodeHeader(${$matches}[$match_type], true, false)); if (strstr('^^' . $headertest, $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 3; } break; } } } } } /* end Message highlight code */ if (!isset($hlt_color)) { $hlt_color = $color_string; } $col = 0; $sSubject = str_replace(' ', ' ', decodeHeader($sSubject)); $subject = processSubject($sSubject, $iIndent); echo html_tag('tr', '', '', '', 'valign="top"') . "\n"; if (sizeof($index_order)) { foreach ($index_order as $index_order_part) { switch ($index_order_part) { case 1: /* checkbox */ echo html_tag('td', addCheckBox("msg[{$t}]", $checkall, $iId), 'center', $hlt_color); break; case 2: /* from */ if ($senderAddress != $senderName) { $senderAddress = strtr($senderAddress, array_flip(get_html_translation_table(HTML_SPECIALCHARS))); $title = ' title="' . str_replace('"', "''", $senderAddress) . '"'; } else { $title = ''; } echo html_tag('td', $italic . $bold . $flag . $fontstr . $senderName . $fontstr_end . $flag_end . $bold_end . $italic_end, 'left', $hlt_color, $title); break; case 3: /* date */ if ($sDate == '') { $sDate = _("Unknown date"); } echo html_tag('td', $bold . $flag . $fontstr . $sDate . $fontstr_end . $flag_end . $bold_end, 'center', $hlt_color, 'nowrap'); break; case 4: /* subject */ $td_str = $bold; if ($iIndent) { $td_str .= str_repeat(" ", $iIndent); } $td_str .= '<a href="read_body.php?mailbox=' . $urlMailbox . '&passed_id=' . $iId . '&startMessage=' . $start_msg . $searchstr . '"'; $td_str .= ' ' . concat_hook_function('subject_link', array($start_msg, $searchstr)); if ($subject != $sSubject) { $title = get_html_translation_table(HTML_SPECIALCHARS); $title = array_flip($title); $title = strtr($sSubject, $title); $title = str_replace('"', "''", $title); $td_str .= " title=\"{$title}\""; } $td_str .= ">{$flag}{$subject}{$flag_end}</a>{$bold_end}"; echo html_tag('td', $td_str, 'left', $hlt_color); break; case 5: /* flags */ // icon message markers // if ($use_icons && $icon_theme != 'none') { $td_str = "<b><small>"; if (isset($aFlags['\\flagged']) && $aFlags['\\flagged'] == true) { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/flagged.png" border="0" height="10" width="10" /> '; } if ($default_use_priority) { if ($iPrio == 1 || $iPrio == 2) { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/prio_high.png" border="0" height="10" width="5" /> '; } else { if ($iPrio == 5) { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/prio_low.png" border="0" height="10" width="5" /> '; } else { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/transparent.png" border="0" width="5" /> '; } } } if ($sType1 == 'mixed') { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/attach.png" border="0" height="10" width="6" />'; } else { $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/transparent.png" border="0" width="6" />'; } $msg_icon = ''; if (!isset($aFlags['\\seen']) || $aFlags['\\seen'] == false) { $msg_alt = '(' . _("New") . ')'; $msg_title = '(' . _("New") . ')'; $msg_icon .= SM_PATH . 'images/themes/' . $icon_theme . '/msg_new'; } else { $msg_alt = '(' . _("Read") . ')'; $msg_title = '(' . _("Read") . ')'; $msg_icon .= SM_PATH . 'images/themes/' . $icon_theme . '/msg_read'; } if (isset($aFlags['\\deleted']) && $aFlags['\\deleted'] == true) { $msg_icon .= '_deleted'; } if (isset($aFlags['\\answered']) && $aFlags['\\answered'] == true) { $msg_alt = '(' . _("Answered") . ')'; $msg_title = '(' . _("Answered") . ')'; $msg_icon .= '_reply'; } $td_str .= '<img src="' . $msg_icon . '.png" border="0" alt="' . $msg_alt . '" title="' . $msg_title . '" height="12" width="18" />'; $td_str .= '</small></b>'; echo html_tag('td', $td_str, 'right', $hlt_color, 'nowrap'); } else { $stuff = false; $td_str = "<b><small>"; if (isset($aFlags['\\answered']) && $aFlags['\\answered'] == true) { $td_str .= _("A"); $stuff = true; } if ($sType1 == 'mixed') { $td_str .= '+'; $stuff = true; } if ($default_use_priority) { if ($iPrio == 1 || $iPrio == 2) { $td_str .= "<font color=\"{$color['1']}\">!</font>"; $stuff = true; } if ($iPrio == 5) { $td_str .= "<font color=\"{$color['8']}\">?</font>"; $stuff = true; } } if (isset($aFlags['\\deleted']) && $aFlags['\\deleted'] == true) { $td_str .= "<font color=\"{$color['1']}\">D</font>"; $stuff = true; } if (!$stuff) { $td_str .= ' '; } $td_str .= '</small></b>'; echo html_tag('td', $td_str, 'center', $hlt_color, 'nowrap'); } break; case 6: /* size */ echo html_tag('td', $bold . $fontstr . show_readable_size($iSize) . $fontstr_end . $bold_end, 'right', $hlt_color); break; } ++$col; } } /* html for separationlines between rows */ if ($last) { echo '</tr>' . "\n"; } else { echo '</tr>' . "\n" . '<tr><td colspan="' . $col . '" bgcolor="' . $color[0] . '" height="1"></td></tr>' . "\n"; } }
function formatMailboxName($imapConnection, $box_array) { global $folder_prefix, $trash_folder, $sent_folder, $color, $move_to_sent, $move_to_trash, $unseen_notify, $unseen_type, $collapse_folders, $draft_folder, $save_as_draft, $use_special_folder_color; $real_box = $box_array['unformatted']; $mailbox = str_replace(' ', '', $box_array['formatted']); $mailboxURL = urlencode($real_box); /* Strip down the mailbox name. */ if (ereg("^( *)([^ ]*)\$", $mailbox, $regs)) { $mailbox = $regs[2]; } $unseen = 0; $status = array('', ''); if ($unseen_notify == 2 && $real_box == 'INBOX' || $unseen_notify == 3) { $tmp_status = create_unseen_string($real_box, $box_array, $imapConnection, $unseen_type); if ($status !== false) { $status = $tmp_status; } } list($unseen_string, $unseen) = $status; $special_color = $use_special_folder_color && isSpecialMailbox($real_box); /* Start off with a blank line. */ $line = ''; /* If there are unseen message, bold the line. */ if ($unseen > 0) { $line .= '<b>'; } /* Create the link for this folder. */ if ($status !== false) { $line .= '<a href="right_main.php?PG_SHOWALL=0&sort=0&startMessage=1&mailbox=' . $mailboxURL . '" target="right" style="text-decoration:none">'; } if ($special_color) { $line .= "<font color=\"{$color['11']}\">"; } if ($mailbox == 'INBOX') { $line .= _("INBOX"); } else { $line .= str_replace(array(' ', '<', '>'), array(' ', '<', '>'), $mailbox); } if ($special_color == TRUE) { $line .= '</font>'; } if ($status !== false) { $line .= '</a>'; } /* If there are unseen message, close bolding. */ if ($unseen > 0) { $line .= "</b>"; } /* Print unseen information. */ if ($unseen_string != '') { $line .= " <small>{$unseen_string}</small>"; } /* If it's the trash folder, show a purge link when needed */ if ($move_to_trash && $real_box == $trash_folder) { if (!isset($numMessages)) { $numMessages = sqimap_get_num_messages($imapConnection, $real_box); } if ($numMessages > 0 or $box_array['parent'] == 1) { $urlMailbox = urlencode($real_box); $line .= "\n<small>\n" . ' (<a href="empty_trash.php" style="text-decoration:none">' . _("Purge") . '</a>)' . '</small>'; } } $line .= concat_hook_function('left_main_after_each_folder', array(isset($numMessages) ? $numMessages : '', $real_box, $imapConnection)); /* Return the final product. */ return $line; }
function printMessageInfo($imapConnection, $t, $not_last = true, $key, $mailbox, $start_msg, $where, $what) { global $checkall, $preselected, $color, $msgs, $msort, $td_str, $msg, $default_use_priority, $message_highlight_list, $index_order, $indent_array, $pos, $thread_sort_messages, $server_sort_order, $row_count, $allow_server_sort, $truncate_subject, $truncate_sender; $color_string = $color[4]; if ($GLOBALS['alt_index_colors']) { if (!isset($row_count)) { $row_count = 0; } $row_count++; if ($row_count % 2) { if (!isset($color[12])) { $color[12] = '#EAEAEA'; } $color_string = $color[12]; } } $msg = $msgs[$key]; if ($mailbox == 'None') { $boxes = sqimap_mailbox_list($imapConnection); $mailbox = $boxes[0]['unformatted']; unset($boxes); } $urlMailbox = urlencode($mailbox); if (handleAsSent($mailbox)) { $msg['FROM'] = $msg['TO']; } $msg['FROM'] = parseAddress($msg['FROM'], 1); /* * This is done in case you're looking into Sent folders, * because you can have multiple receivers. */ $senderNames = $msg['FROM']; $senderName = ''; $senderFrom = ''; if (sizeof($senderNames)) { foreach ($senderNames as $senderNames_part) { if ($senderName != '') { $senderName .= ', '; } if ($senderFrom != '') { $senderFrom .= ', '; } if ($senderNames_part[1]) { $senderName .= decodeHeader($senderNames_part[1]); } else { $senderName .= htmlspecialchars($senderNames_part[0]); } $senderFrom .= htmlspecialchars($senderNames_part[0]); } } $senderName = str_replace(' ', ' ', $senderName); echo html_tag('tr', '', '', '', 'valign="top"') . "\n"; if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true) { $flag = "<font color=\"{$color['2']}\">"; $flag_end = '</font>'; } else { $flag = ''; $flag_end = ''; } if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false) { $bold = '<b>'; $bold_end = '</b>'; } else { $bold = ''; $bold_end = ''; } if (handleAsSent($mailbox)) { $italic = '<i>'; $italic_end = '</i>'; } else { $italic = ''; $italic_end = ''; } if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) { $fontstr = "<font color=\"{$color['9']}\">"; $fontstr_end = '</font>'; } else { $fontstr = ''; $fontstr_end = ''; } if ($where && $what) { $searchstr = '&where=' . $where . '&what=' . $what; } else { $searchstr = ''; } if (is_array($message_highlight_list) && count($message_highlight_list)) { $msg['TO'] = parseAddress($msg['TO']); $msg['CC'] = parseAddress($msg['CC']); foreach ($message_highlight_list as $message_highlight_list_part) { if (trim($message_highlight_list_part['value']) != '') { $high_val = strtolower($message_highlight_list_part['value']); $match_type = strtoupper($message_highlight_list_part['match_type']); if ($match_type == 'TO_CC') { $match = array('TO', 'CC'); } else { $match = array($match_type); } foreach ($match as $match_type) { switch ($match_type) { case 'TO': case 'CC': case 'FROM': foreach ($msg[$match_type] as $address) { $address[0] = decodeHeader($address[0], true, false); $address[1] = decodeHeader($address[1], true, false); if (strstr('^^' . strtolower($address[0]), $high_val) || strstr('^^' . strtolower($address[1]), $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 4; } } break; default: $headertest = strtolower(decodeHeader($msg[$match_type], true, false)); if (strstr('^^' . $headertest, $high_val)) { $hlt_color = $message_highlight_list_part['color']; break 3; } break; } } } } } if (!isset($hlt_color)) { $hlt_color = $color_string; } if ($checkall == 1 || in_array($msg['ID'], $preselected)) { $checked = ' checked="checked"'; } else { $checked = ''; } $col = 0; $msg['SUBJECT'] = decodeHeader($msg['SUBJECT']); // $subject = processSubject($msg['SUBJECT'], $indent_array[$msg['ID']]); $subject = truncateWithEntities(str_replace(' ', ' ', $msg['SUBJECT']), $truncate_subject); if (sizeof($index_order)) { foreach ($index_order as $index_order_part) { switch ($index_order_part) { case 1: /* checkbox */ echo html_tag('td', "<input type=\"checkbox\" name=\"msg[{$t}]\" id=\"msg" . $msg['ID'] . "\" value=\"" . $msg['ID'] . "\"{$checked}>", 'center', $hlt_color); break; case 2: /* from */ $from_xtra = ''; $from_xtra = 'title="' . $senderFrom . '"'; echo html_tag('td', html_tag('label', $italic . $bold . $flag . $fontstr . truncateWithEntities($senderName, $truncate_sender) . $fontstr_end . $flag_end . $bold_end . $italic_end, '', '', 'for="msg' . $msg['ID'] . '"'), 'left', $hlt_color, $from_xtra); break; case 3: /* date */ $date_string = $msg['DATE_STRING'] . ''; if ($date_string == '') { $date_string = _("Unknown date"); } echo html_tag('td', $bold . $flag . $fontstr . $date_string . $fontstr_end . $flag_end . $bold_end, 'center', $hlt_color, 'nowrap'); break; case 4: /* subject */ $td_str = $bold; if ($thread_sort_messages == 1) { if (isset($indent_array[$msg['ID']])) { $td_str .= str_repeat(" ", $indent_array[$msg['ID']]); } } $td_str .= '<a href="read_body.php?mailbox=' . $urlMailbox . '&passed_id=' . $msg["ID"] . '&startMessage=' . $start_msg . $searchstr . '"'; $td_str .= ' ' . concat_hook_function('subject_link', array($start_msg, $searchstr)); if ($subject != $msg['SUBJECT']) { $title = get_html_translation_table(HTML_SPECIALCHARS); $title = array_flip($title); $title = strtr($msg['SUBJECT'], $title); $title = str_replace('"', "''", $title); $td_str .= " title=\"{$title}\""; } $td_str .= ">{$flag}{$subject}{$flag_end}</a>{$bold_end}"; echo html_tag('td', $td_str, 'left', $hlt_color); break; case 5: /* flags */ $stuff = false; $td_str = "<b><small>"; if (isset($msg['FLAG_ANSWERED']) && $msg['FLAG_ANSWERED'] == true) { $td_str .= _("A"); $stuff = true; } if ($msg['TYPE0'] == 'multipart' && $msg['TYPE1'] == 'mixed') { $td_str .= '+'; $stuff = true; } if ($default_use_priority) { if ($msg['PRIORITY'] == 1 || $msg['PRIORITY'] == 2) { $td_str .= "<font color=\"{$color['1']}\">!</font>"; $stuff = true; } if ($msg['PRIORITY'] == 5) { $td_str .= "<font color=\"{$color['8']}\">?</font>"; $stuff = true; } } if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'] == true) { $td_str .= "<font color=\"{$color['1']}\">D</font>"; $stuff = true; } if (!$stuff) { $td_str .= ' '; } do_hook("msg_envelope"); $td_str .= '</small></b>'; echo html_tag('td', $td_str, 'center', $hlt_color, 'nowrap'); break; case 6: /* size */ echo html_tag('td', $bold . $fontstr . show_readable_size($msg['SIZE']) . $fontstr_end . $bold_end, 'right', $hlt_color); break; } ++$col; } } if ($not_last) { echo '</tr>' . "\n" . '<tr><td colspan="' . $col . '" bgcolor="' . $color[0] . '" height="1"></td></tr>' . "\n"; } else { echo '</tr>' . "\n"; } }
/** * Applies the template and returns the resultant content string. * * @param string $file The template file to use * * @return string The template contents after applying the given template * */ function fetch($file) { // get right template file // $template = $this->get_template_file_path($file); // special case stylesheet.tpl falls back to SquirrelMail's // own default stylesheet // if (empty($template) && $file == 'css/stylesheet.tpl') { $template = SM_PATH . 'css/default.css'; } if (empty($template)) { trigger_error('The template "' . sm_encode_html_special_chars($file) . '" could not be fetched!', E_USER_ERROR); } else { $aPluginOutput = array(); $temp = array(&$aPluginOutput, &$this); $aPluginOutput = concat_hook_function('template_construct_' . $file, $temp, TRUE); $this->assign('plugin_output', $aPluginOutput); //$output = $this->apply_template($template); $rendering_engine = $this->get_rendering_template_engine_object($file); $output = $rendering_engine->apply_template($template); // CAUTION: USE OF THIS HOOK IS HIGHLY DISCOURAGED AND CAN // RESULT IN NOTICABLE PERFORMANCE DEGREDATION. Plugins // using this hook will probably be rejected by the // SquirrelMail team. // do_hook('template_output', $output); return $output; } }
function ShowTableInfo($full_name, $email_address, $reply_to, $signature, $post) { global $color; $OtherBG = $color[0]; if ($full_name == '' && $email_address == '' && $reply_to == '' && $signature == '') { $OtherBG = ''; } if ($full_name == '' && $email_address == '' && $reply_to == '' && $signature == '') { $isEmptySection = true; } else { $isEmptySection = false; } $return_val = ''; $return_val .= sti_input(_("Full Name"), 'full_name', $full_name, $post, $OtherBG); $return_val .= sti_input(_("E-Mail Address"), 'email_address', $email_address, $post, $OtherBG); $return_val .= sti_input(_("Reply To"), 'reply_to', $reply_to, $post, $OtherBG); $return_val .= sti_textarea(_("Signature"), 'signature', $signature, $post, $OtherBG); $return_val .= concat_hook_function('options_identities_table', array($OtherBG, $isEmptySection, $post)); $return_val .= html_tag('tr', '', '', $OtherBG); $return_val .= html_tag('td', ' ', 'left'); $return_val .= html_tag('td', '', 'left'); $return_val .= '<input type="hidden" name="form_for_' . $post . '" value="1" />'; $return_val .= '<input type="submit" name="update" value="' . _("Save / Update") . '" />'; if (!$isEmptySection && $post != '') { $return_val .= '<input type="submit" name="make_default_' . $post . '" value="' . _("Make Default") . '" />' . '<input type="submit" name="delete_' . $post . '" value="' . _("Delete") . '" />'; } if (!$isEmptySection && $post != '' && $post > 1) { $return_val .= '<input type="submit" name="promote_' . $post . '" value="' . _("Move Up") . '" />'; } $return_val .= concat_hook_function('options_identities_buttons', array($isEmptySection, $post)); $return_val .= '</td></tr>' . html_tag('tr', html_tag('td', ' ', 'left', '', 'colspan="2"')); return $return_val; }
function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) { global $base_uri, $draft_folder, $where, $what, $color, $sort, $startMessage, $PHP_SELF, $save_as_draft, $enable_forward_as_attachment; $topbar_delimiter = ' | '; $urlMailbox = urlencode($mailbox); $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"' . ' border="0" bgcolor="' . $color[9] . '"><tr>' . html_tag('td', '', 'left', '', 'width="33%"') . '<small>'; $msgs_url = $base_uri . 'src/'; if (isset($where) && isset($what)) { $msgs_url .= 'search.php?where=' . urlencode($where) . '&what=' . urlencode($what) . '&mailbox=' . $urlMailbox; $msgs_str = _("Search Results"); } else { $msgs_url .= 'right_main.php?sort=' . $sort . '&startMessage=' . $startMessage . '&mailbox=' . $urlMailbox; $msgs_str = _("Message List"); } $s .= '<a href="' . $msgs_url . '">' . $msgs_str . '</a>'; $delete_url = $base_uri . 'src/delete_message.php?mailbox=' . $urlMailbox . '&message=' . $passed_id . '&'; if (!(isset($passed_ent_id) && $passed_ent_id)) { if ($where && $what) { $delete_url .= 'where=' . urlencode($where) . '&what=' . urlencode($what); } else { $delete_url .= 'sort=' . $sort . '&startMessage=' . $startMessage; } $s .= $topbar_delimiter; $s .= '<a href="' . $delete_url . '">' . _("Delete") . '</a>'; } $comp_uri = 'src/compose.php' . '?passed_id=' . $passed_id . '&mailbox=' . $urlMailbox . '&startMessage=' . $startMessage . (isset($passed_ent_id) ? '&passed_ent_id=' . urlencode($passed_ent_id) : ''); if ($mailbox == $draft_folder && $save_as_draft) { $comp_alt_uri = $comp_uri . '&smaction=draft'; $comp_alt_string = _("Resume Draft"); } else { if (handleAsSent($mailbox)) { $comp_alt_uri = $comp_uri . '&smaction=edit_as_new'; $comp_alt_string = _("Edit Message as New"); } } if (isset($comp_alt_uri)) { $s .= $topbar_delimiter; $s .= makeComposeLink($comp_alt_uri, $comp_alt_string); } $s .= '</small></td><td align="center" width="33%"><small>'; if (!(isset($where) && isset($what)) && !$passed_ent_id) { $prev = findPreviousMessage($mbx_response['EXISTS'], $passed_id); $next = findNextMessage($passed_id); if ($prev != -1) { $uri = $base_uri . 'src/read_body.php?passed_id=' . $prev . '&mailbox=' . $urlMailbox . '&sort=' . $sort . '&startMessage=' . $startMessage . '&show_more=0'; $s .= '<a href="' . $uri . '">' . _("Previous") . '</a>'; } else { $s .= _("Previous"); } $s .= $topbar_delimiter; if ($next != -1) { $uri = $base_uri . 'src/read_body.php?passed_id=' . $next . '&mailbox=' . $urlMailbox . '&sort=' . $sort . '&startMessage=' . $startMessage . '&show_more=0'; $s .= '<a href="' . $uri . '">' . _("Next") . '</a>'; } else { $s .= _("Next"); } } else { if (isset($passed_ent_id) && $passed_ent_id) { /* code for navigating through attached message/rfc822 messages */ $url = set_url_var($PHP_SELF, 'passed_ent_id', 0); $s .= '<a href="' . $url . '">' . _("View Message") . '</a>'; $entities = array(); $entity_count = array(); $c = 0; foreach ($message->parent->entities as $ent) { if ($ent->type0 == 'message' && $ent->type1 == 'rfc822') { $c++; $entity_count[$c] = $ent->entity_id; $entities[$ent->entity_id] = $c; } } $prev_link = _("Previous"); if (!empty($entities[$passed_ent_id]) && $entities[$passed_ent_id] > 1) { $prev_ent_id = $entity_count[$entities[$passed_ent_id] - 1]; $prev_link = '<a href="' . set_url_var($PHP_SELF, 'passed_ent_id', $prev_ent_id) . '">' . $prev_link . '</a>'; } $next_link = _("Next"); if (!empty($entities[$passed_ent_id]) && $entities[$passed_ent_id] < $c) { $next_ent_id = $entity_count[$entities[$passed_ent_id] + 1]; $next_link = '<a href="' . set_url_var($PHP_SELF, 'passed_ent_id', $next_ent_id) . '">' . $next_link . '</a>'; } $s .= $topbar_delimiter . $prev_link; $par_ent_id = $message->parent->entity_id; if ($par_ent_id) { $par_ent_id = substr($par_ent_id, 0, -2); $s .= $topbar_delimiter; $url = set_url_var($PHP_SELF, 'passed_ent_id', $par_ent_id); $s .= '<a href="' . $url . '">' . _("Up") . '</a>'; } $s .= $topbar_delimiter . $next_link; } } $s .= '</small></td>' . "\n" . html_tag('td', '', 'right', '', 'width="33%" nowrap') . '<small>'; $comp_action_uri = $comp_uri . '&smaction=forward'; $s .= makeComposeLink($comp_action_uri, _("Forward")); if ($enable_forward_as_attachment) { $comp_action_uri = $comp_uri . '&smaction=forward_as_attachment'; $s .= $topbar_delimiter; $s .= makeComposeLink($comp_action_uri, _("Forward as Attachment")); } $comp_action_uri = $comp_uri . '&smaction=reply'; $s .= $topbar_delimiter; $s .= makeComposeLink($comp_action_uri, _("Reply")); $comp_action_uri = $comp_uri . '&smaction=reply_all'; $s .= $topbar_delimiter; $s .= makeComposeLink($comp_action_uri, _("Reply All")); $s .= '</small></td></tr></table>'; $ret = concat_hook_function('read_body_menu_top', $s); if ($ret != '') { $s = $ret; } echo $s; do_hook('read_body_menu_bottom'); }
function error_box($string, $color) { global $pageheader_sent; if (!isset($color)) { $color = array(); $color[0] = '#dcdcdc'; /* light gray TitleBar */ $color[1] = '#800000'; /* red */ $color[2] = '#cc0000'; /* light red Warning/Error Messages */ $color[4] = '#ffffff'; /* white Normal Background */ $color[7] = '#0000cc'; /* blue Links */ $color[8] = '#000000'; /* black Normal text */ $color[9] = '#ababab'; /* mid-gray Darker version of #0 */ } $err = _("ERROR"); $ret = concat_hook_function('error_box', $string); if ($ret != '') { $string = $ret; } /* check if the page header has been sent; if not, send it! */ if (!isset($pageheader_sent) && !$pageheader_sent) { /* include this just to be sure */ include_once SM_PATH . 'functions/page_header.php'; displayHtmlHeader('SquirrelMail: ' . $err); $pageheader_sent = TRUE; echo "<body text=\"{$color['8']}\" bgcolor=\"{$color['4']}\" link=\"{$color['7']}\" vlink=\"{$color['7']}\" alink=\"{$color['7']}\">\n\n"; } echo '<table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="' . $color[9] . '">' . '<tr><td>' . '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="' . $color[4] . '">' . '<tr><td align="center" bgcolor="' . $color[0] . '">' . '<font color="' . $color[2] . '"><b>' . $err . ':</b></font>' . '</td></tr><tr><td>' . '<table cellpadding="1" cellspacing="5" align="center" border="0">' . '<tr>' . html_tag('td', $string . "\n", 'left') . '</tr></table>' . '</td></tr></table></td></tr></table>'; }
break; case 'options.php': $right_frame_url = 'options.php'; break; case 'folders.php': $right_frame_url = 'folders.php'; break; case 'compose.php': $right_frame_url = 'compose.php?' . $mailtourl; break; case '': $right_frame_url = 'right_main.php'; break; default: $right_frame_url = urlencode($right_frame); break; } if ($location_of_bar == 'right') { $output .= "<frame src=\"{$right_frame_url}\" name=\"right\" frameborder=\"1\" />\n" . "<frame src=\"left_main.php\" name=\"left\" frameborder=\"1\" />\n"; } else { $output .= "<frame src=\"left_main.php\" name=\"left\" frameborder=\"1\" />\n" . "<frame src=\"{$right_frame_url}\" name=\"right\" frameborder=\"1\" />\n"; } $ret = concat_hook_function('webmail_bottom', $output); if ($ret != '') { $output = $ret; } echo $output; ?> </frameset> </html>
/** * Returns html formated identity form fields * * Contains options_identities_buttons and options_identities_table hooks. * Before 1.4.5/1.5.1 hooks were placed in ShowTableInfo() function. * In 1.1.3-1.4.1 they were called in do_hook function with two or * three arguments. Since 1.4.1 hooks are called in concat_hook_function. * Arguments are moved to array. * * options_identities_buttons hook uses array with two keys. First array key is * boolean variable used to indicate empty identity field. Second array key * is integer variable used to indicate identity number * * options_identities_table hook uses array with three keys. First array key is * a string containing background color style CSS (1.4.1-1.4.4/1.5.0 uses only * html color code). Second array key is boolean variable used to indicate empty * identity field. Third array key is integer variable used to indicate identity * number * @param string $title Name displayed in header row * @param array $identity Identity information * @param integer $id identity ID * @return string html formatted table rows with form fields for identity management * @since 1.5.1 and 1.4.5 (was called ShowTableInfo() in 1.1.3-1.4.4 and 1.5.0) */ function ShowIdentityInfo($title, $identity, $id) { global $color; if (empty($identity['full_name']) && empty($identity['email_address']) && empty($identity['reply_to']) && empty($identity['signature'])) { $bg = ''; $empty = true; } else { $bg = ' style="background-color:' . $color[0] . ';"'; $empty = false; } $name = 'newidentities[%d][%s]'; $return_str = ''; //FIXME: NO HTML IN THE CORE $return_str .= '<tr>' . "\n"; $return_str .= ' <th style="text-align:center;background-color:' . $color[9] . ';" colspan="2">' . $title . '</th> ' . "\n"; $return_str .= '</tr>' . "\n"; $return_str .= sti_input(_("Full Name"), sprintf($name, $id, 'full_name'), $identity['full_name'], $bg); $return_str .= sti_input(_("E-Mail Address"), sprintf($name, $id, 'email_address'), $identity['email_address'], $bg); $return_str .= sti_input(_("Reply To"), sprintf($name, $id, 'reply_to'), $identity['reply_to'], $bg); $return_str .= sti_textarea(_("Signature"), sprintf($name, $id, 'signature'), $identity['signature'], $bg); $temp = array(&$bg, &$empty, &$id); $return_str .= concat_hook_function('options_identities_table', $temp); $return_str .= '<tr' . $bg . '> ' . "\n"; $return_str .= ' <td> </td>' . "\n"; $return_str .= ' <td>' . "\n"; $return_str .= ' <input type="submit" name="smaction[save][' . $id . ']" value="' . _("Save / Update") . '" />' . "\n"; if (!$empty && $id > 0) { $return_str .= ' <input type="submit" name="smaction[makedefault][' . $id . ']" value="' . _("Make Default") . '" />' . "\n"; $return_str .= ' <input type="submit" name="smaction[delete][' . $id . ']" value="' . _("Delete") . '" />' . "\n"; if ($id > 1) { $return_str .= ' <input type="submit" name="smaction[move][' . $id . ']" value="' . _("Move Up") . '" />' . "\n"; } } $temp = array(&$empty, &$id); $return_str .= concat_hook_function('options_identities_buttons', $temp); $return_str .= ' </td>' . "\n"; $return_str .= '</tr>' . "\n"; $return_str .= '<tr>' . "\n"; $return_str .= ' <td colspan="2"> </td>' . "\n"; $return_str .= '</tr>'; return $return_str; }
?> <title><?php echo $org_title . ' - ' . _("Signout"); ?> </title> </head> <body text="<?php echo $color[8]; ?> " bgcolor="<?php echo $color[4]; ?> " link="<?php echo $color[7]; ?> " vlink="<?php echo $color[7]; ?> " alink="<?php echo $color[7]; ?> "> <br /><br /> <?php $plugin_message = concat_hook_function('logout_above_text'); echo html_tag('table', html_tag('tr', html_tag('th', _("Sign Out"), 'center'), '', $color[0], 'width="100%"') . $plugin_message . html_tag('tr', html_tag('td', _("You have been successfully signed out.") . '<br /><a href="login.php" target="' . $frame_top . '">' . _("Click here to log back in.") . '</a><br />', 'center'), '', $color[4], 'width="100%"') . html_tag('tr', html_tag('td', '<br />', 'center'), '', $color[0], 'width="100%"'), 'center', $color[4], 'width="50%" cols="1" cellpadding="2" cellspacing="0" border="0"'); ?> </body> </html>
function ListAdvancedBoxes($boxes, $mbx, $j = 'ID.0000') { global $data_dir, $username, $startmessage, $color, $unseen_notify, $unseen_type, $move_to_trash, $trash_folder, $collapse_folders, $use_special_folder_color; if (!isset($boxes) || empty($boxes)) { return; } /* use_folder_images only works if the images exist in ../images */ $use_folder_images = true; $pre = ''; $end = ''; $collapse = false; $unseen_found = false; $unseen = 0; $mailbox = $boxes->mailboxname_full; $mailboxURL = urlencode($mailbox); /* get unseen/total messages information */ /* Only need to display info when option is set */ if (isset($unseen_notify) && $unseen_notify > 1 && ($boxes->unseen !== false || $boxes->total !== false)) { if ($boxes->unseen !== false) { $unseen = $boxes->unseen; } /* Should only display unseen info if the folder is inbox or you set the option for all folders */ if (strtolower($mailbox) == 'inbox' || $unseen_notify == 3) { $unseen_string = $unseen; /* If users requests, display message count too */ if (isset($unseen_type) && $unseen_type == 2 && $boxes->total !== false) { $unseen_string .= '/' . $boxes->total; } $unseen_string = "<font color=\"{$color['11']}\">({$unseen_string})</font>"; /* Finally allow the script to display the values by setting a boolean. This can only occur if the unseen count is great than 0 (if you have unseen count only), or you have the message count too. */ if ($unseen > 0 || isset($unseen_type) && $unseen_type == 2) { $unseen_found = true; } } } /* If there are unseen message, bold the line. */ if ($unseen > 0) { $pre .= '<b>'; } /* color special boxes */ if ($use_special_folder_color && $boxes->is_special) { $pre .= "<font color=\"{$color['11']}\">"; $end .= '</font>'; } /* If there are unseen message, close bolding. */ if ($unseen > 0) { $end .= '</b>'; } /* Print unseen information. */ if ($unseen_found) { $end .= " {$unseen_string}"; } if ($move_to_trash && $mailbox == $trash_folder) { if (!isset($numMessages)) { $numMessages = $boxes->total; } $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox={$mailboxURL}\" target=\"right\">" . $pre; $end .= '</a>'; if ($numMessages > 0) { $urlMailbox = urlencode($mailbox); $end .= "\n<small>\n" . ' [<a class="mbx_link" href="empty_trash.php">' . _("Purge") . '</a>]' . '</small>'; } } else { if (!$boxes->is_noselect) { /* \Noselect boxes can't be selected */ $pre = "<a class=\"mbx_link\" href=\"right_main.php?PG_SHOWALL=0&startMessage=1&mailbox={$mailboxURL}\" target=\"right\">" . $pre; $end .= '</a>'; } } // let plugins fiddle with end of line global $imapConnection; $end .= concat_hook_function('left_main_after_each_folder', array(isset($numMessages) ? $numMessages : '', $boxes->mailboxname_full, $imapConnection)); if (!$boxes->is_root) { if ($use_folder_images) { if ($boxes->is_inbox) { $folder_img = '../images/inbox.png'; } else { if ($boxes->is_sent) { $folder_img = '../images/senti.png'; } else { if ($boxes->is_trash) { $folder_img = '../images/delitem.png'; } else { if ($boxes->is_draft) { $folder_img = '../images/draft.png'; } else { if ($boxes->is_noinferiors) { $folder_img = '../images/folder_noinf.png'; } else { $folder_img = '../images/folder.png'; } } } } } $folder_img = ' <img src="' . $folder_img . '" height="15" valign="center" /> '; } else { $folder_img = ''; } if (!isset($boxes->mbxs[0])) { echo ' ' . html_tag('div', '<tt>' . $pre . $folder_img . '</tt>' . str_replace(array(' ', '<', '>'), array(' ', '<', '>'), $boxes->mailboxname_sub) . $end, 'left', '', 'class="mbx_sub" id="' . $j . '"') . "\n"; } else { /* get collapse information */ if ($collapse_folders) { $form_entry = $j . 'F'; if (isset($mbx) && isset($mbx[$form_entry])) { $collapse = $mbx[$form_entry]; setPref($data_dir, $username, 'collapse_folder_' . $boxes->mailboxname_full, $collapse ? SM_BOX_COLLAPSED : SM_BOX_UNCOLLAPSED); } else { $collapse = getPref($data_dir, $username, 'collapse_folder_' . $mailbox); $collapse = $collapse == '' ? SM_BOX_UNCOLLAPSED : $collapse; } $img_src = $collapse ? '../images/plus.png' : '../images/minus.png'; $collapse_link = '<a href="javascript:void(0)">' . " <img src=\"{$img_src}\" border=\"1\" id={$j} onclick=\"hidechilds(this)\" style=\"cursor:hand\" /></a>"; } else { $collapse_link = ''; } echo ' ' . html_tag('div', $collapse_link . $pre . $folder_img . ' ' . $boxes->mailboxname_sub . $end, 'left', '', 'class="mbx_par" id="' . $j . 'P"') . "\n"; echo ' <input type="hidden" name="mbx[' . $j . 'F]" value="' . $collapse . '" id="mbx[' . $j . 'F]" />' . "\n"; } } $visible = $collapse ? ' style="display:none"' : ' style="display:block"'; if (isset($boxes->mbxs[0]) && !$boxes->is_root) { /* mailbox contains childs */ echo html_tag('div', '', 'left', '', 'class="par_area" id=' . $j . '.0000 ' . $visible) . "\n"; } if ($j != 'ID.0000') { $j = $j . '.0000'; } for ($i = 0; $i < count($boxes->mbxs); $i++) { $j++; ListAdvancedBoxes($boxes->mbxs[$i], $mbx, $j); } if (isset($boxes->mbxs[0]) && !$boxes->is_root) { echo '</div>' . "\n\n"; } }