/** * __construct * * Provide a uid, and parse message structure. * * @param string $uid The message UID. * * @uses rcmail::get_instance() * @uses rcube_imap::decode_mime_string() * @uses self::set_safe() * * @see self::$app, self::$imap, self::$opt, self::$structure */ function __construct($uid) { $this->app = rcmail::get_instance(); $this->imap = $this->app->imap; $this->uid = $uid; $this->headers = $this->imap->get_headers($uid, NULL, true, true); $this->subject = rcube_imap::decode_mime_string($this->headers->subject, $this->headers->charset); list(, $this->sender) = each($this->imap->decode_address_list($this->headers->from)); $this->set_safe(intval($_GET['_safe']) || $_SESSION['safe_messages'][$uid]); $this->opt = array('safe' => $this->is_safe, 'prefer_html' => $this->app->config->get('prefer_html'), 'get_url' => rcmail_url('get', array('_mbox' => $this->imap->get_mailbox_name(), '_uid' => $uid))); if ($this->structure = $this->imap->get_structure($uid, $this->headers->body_structure)) { $this->get_mime_numbers($this->structure); $this->parse_structure($this->structure); } else { $this->body = $this->imap->get_body($uid); } }
/** * Place a link/button after attachments listing to trigger download */ public function attachment_ziplink($p) { $rcmail = rcmail::get_instance(); // only show the link if there is more than the configured number of attachments if (substr_count($p['content'], '<li') > $rcmail->config->get('zipdownload_attachments', 1)) { $link = html::a(array('href' => rcmail_url('plugin.zipdownload.zip_attachments', array('_mbox' => $rcmail->output->env['mailbox'], '_uid' => $rcmail->output->env['uid'])), 'class' => 'button zipdownload'), Q($this->gettext('downloadall'))); // append link to attachments list, slightly different in some skins switch (rcmail::get_instance()->config->get('skin')) { case 'classic': $p['content'] = str_replace('</ul>', html::tag('li', array('class' => 'zipdownload'), $link) . '</ul>', $p['content']); break; default: $p['content'] .= $link; break; } $this->include_stylesheet($this->local_skin_path() . '/zipdownload.css'); } return $p; }
/** * __construct * * Provide a uid, and parse message structure. * * @param string $uid The message UID. * * @uses rcmail::get_instance() * @uses rcube_imap::decode_mime_string() * @uses self::set_safe() * * @see self::$app, self::$imap, self::$opt, self::$structure */ function __construct($uid) { $this->app = rcmail::get_instance(); $this->imap = $this->app->imap; $this->imap->get_all_headers = true; $this->uid = $uid; $this->headers = $this->imap->get_message($uid); if (!$this->headers) { return; } $this->subject = rcube_imap::decode_mime_string($this->headers->subject, $this->headers->charset); list(, $this->sender) = each($this->imap->decode_address_list($this->headers->from)); $this->set_safe(intval($_GET['_safe']) || $_SESSION['safe_messages'][$uid]); $this->opt = array('safe' => $this->is_safe, 'prefer_html' => $this->app->config->get('prefer_html'), 'get_url' => rcmail_url('get', array('_mbox' => $this->imap->get_mailbox_name(), '_uid' => $uid))); if (!empty($this->headers->structure)) { $this->get_mime_numbers($this->headers->structure); $this->parse_structure($this->headers->structure); } else { $this->body = $this->imap->get_body($uid); } // notify plugins and let them analyze this structured message object $this->app->plugins->exec_hook('message_load', array('object' => $this)); }
/** * Create and register a button * * @param array Named button attributes * @return string HTML button * @todo Remove all inline JS calls and use jQuery instead. * @todo Remove all sprintf()'s - they are pretty, but also slow. */ public function button($attrib) { static $s_button_count = 100; // these commands can be called directly via url $a_static_commands = array('compose', 'list', 'preferences', 'folders', 'identities'); if (!($attrib['command'] || $attrib['name'])) { return ''; } // try to find out the button type if ($attrib['type']) { $attrib['type'] = strtolower($attrib['type']); } else { $attrib['type'] = $attrib['image'] || $attrib['imagepas'] || $attrib['imageact'] ? 'image' : 'link'; } $command = $attrib['command']; if ($attrib['task']) { $command = $attrib['task'] . '.' . $command; } if (!$attrib['image']) { $attrib['image'] = $attrib['imagepas'] ? $attrib['imagepas'] : $attrib['imageact']; } if (!$attrib['id']) { $attrib['id'] = sprintf('rcmbtn%d', $s_button_count++); } // get localized text for labels and titles if ($attrib['title']) { $attrib['title'] = Q(rcube_label($attrib['title'], $attrib['domain'])); } if ($attrib['label']) { $attrib['label'] = Q(rcube_label($attrib['label'], $attrib['domain'])); } if ($attrib['alt']) { $attrib['alt'] = Q(rcube_label($attrib['alt'], $attrib['domain'])); } // set title to alt attribute for IE browsers if ($this->browser->ie && !$attrib['title'] && $attrib['alt']) { $attrib['title'] = $attrib['alt']; } // add empty alt attribute for XHTML compatibility if (!isset($attrib['alt'])) { $attrib['alt'] = ''; } // register button in the system if ($attrib['command']) { $this->add_script(sprintf("%s.register_button('%s', '%s', '%s', '%s', '%s', '%s');", JS_OBJECT_NAME, $command, $attrib['id'], $attrib['type'], $attrib['imageact'] ? $this->abs_url($attrib['imageact']) : $attrib['classact'], $attrib['imagesel'] ? $this->abs_url($attrib['imagesel']) : $attrib['classsel'], $attrib['imageover'] ? $this->abs_url($attrib['imageover']) : '')); // make valid href to specific buttons if (in_array($attrib['command'], rcmail::$main_tasks)) { $attrib['href'] = rcmail_url(null, null, $attrib['command']); $attrib['onclick'] = sprintf("%s.command('switch-task','%s');return false", JS_OBJECT_NAME, $attrib['command']); } else { if ($attrib['task'] && in_array($attrib['task'], rcmail::$main_tasks)) { $attrib['href'] = rcmail_url($attrib['command'], null, $attrib['task']); } else { if (in_array($attrib['command'], $a_static_commands)) { $attrib['href'] = rcmail_url($attrib['command']); } else { if ($attrib['command'] == 'permaurl' && !empty($this->env['permaurl'])) { $attrib['href'] = $this->env['permaurl']; } } } } } // overwrite attributes if (!$attrib['href']) { $attrib['href'] = '#'; } if ($attrib['task']) { if ($attrib['classact']) { $attrib['class'] = $attrib['classact']; } } else { if ($command && !$attrib['onclick']) { $attrib['onclick'] = sprintf("return %s.command('%s','%s',this)", JS_OBJECT_NAME, $command, $attrib['prop']); } } $out = ''; // generate image tag if ($attrib['type'] == 'image') { $attrib_str = html::attrib_string($attrib, array('style', 'class', 'id', 'width', 'height', 'border', 'hspace', 'vspace', 'align', 'alt', 'tabindex', 'title')); $btn_content = sprintf('<img src="%s"%s />', $this->abs_url($attrib['image']), $attrib_str); if ($attrib['label']) { $btn_content .= ' ' . $attrib['label']; } $link_attrib = array('href', 'onclick', 'onmouseover', 'onmouseout', 'onmousedown', 'onmouseup', 'target'); } else { if ($attrib['type'] == 'link') { $btn_content = isset($attrib['content']) ? $attrib['content'] : ($attrib['label'] ? $attrib['label'] : $attrib['command']); $link_attrib = array('href', 'onclick', 'title', 'id', 'class', 'style', 'tabindex', 'target'); } else { if ($attrib['type'] == 'input') { $attrib['type'] = 'button'; if ($attrib['label']) { $attrib['value'] = $attrib['label']; } $attrib_str = html::attrib_string($attrib, array('type', 'value', 'onclick', 'id', 'class', 'style', 'tabindex')); $out = sprintf('<input%s disabled="disabled" />', $attrib_str); } } } // generate html code for button if ($btn_content) { $attrib_str = html::attrib_string($attrib, $link_attrib); $out = sprintf('<a%s>%s</a>', $attrib_str, $btn_content); } return $out; }