Exemplo n.º 1
0
 /**
  * __construct
  *
  * Provide a uid, and parse message structure.
  *
  * @param string $uid    The message UID.
  * @param string $folder Folder name
  *
  * @see self::$app, self::$storage, self::$opt, self::$parts
  */
 function __construct($uid, $folder = null)
 {
     $this->uid = $uid;
     $this->app = rcube::get_instance();
     $this->storage = $this->app->get_storage();
     $this->folder = strlen($folder) ? $folder : $this->storage->get_folder();
     $this->storage->set_options(array('all_headers' => true));
     // Set current folder
     $this->storage->set_folder($this->folder);
     $this->headers = $this->storage->get_message($uid);
     if (!$this->headers) {
         return;
     }
     $this->mime = new rcube_mime($this->headers->charset);
     $this->subject = $this->mime->decode_mime_string($this->headers->subject);
     list(, $this->sender) = each($this->mime->decode_address_list($this->headers->from, 1));
     $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' => $this->app->url(array('action' => 'get', 'mbox' => $this->storage->get_folder(), 'uid' => $uid)));
     if (!empty($this->headers->structure)) {
         $this->get_mime_numbers($this->headers->structure);
         $this->parse_structure($this->headers->structure);
     } else {
         $this->body = $this->storage->get_body($uid);
     }
     // notify plugins and let them analyze this structured message object
     $this->app->plugins->exec_hook('message_load', array('object' => $this));
 }
Exemplo n.º 2
0
 private function _do_filterlearn($uids, $spam)
 {
     $rcmail = rcube::get_instance();
     $user = $rcmail->user;
     foreach ($uids as $uid) {
         $MESSAGE = new rcube_message($uid);
         $from = $MESSAGE->sender['mailto'];
         if ($from == "") {
             $rcmail->output->command('display_message', 'email address not found ' . $from, 'error');
         } else {
             $new_arr['whatfilter'] = 'from';
             $new_arr['searchstring'] = htmlspecialchars(addslashes($from));
             $new_arr['destfolder'] = addslashes("Junk");
             $new_arr['messages'] = 'all';
             $new_arr['filterpriority'] = '';
             $new_arr['markread'] = 'markread';
             $arr_prefs = $user->get_prefs();
             $arr_prefs['filters'][] = $new_arr;
             if ($user->save_prefs($arr_prefs)) {
                 $rcmail->output->command('display_message', 'I learned that messages from ' . $from . ' are SPAM', 'confirmation');
             } else {
                 $rcmail->output->command('display_message', 'I learned nothing', 'error');
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new database_attachments($rcube->api);
     $this->assertInstanceOf('database_attachments', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 4
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new help($rcube->api);
     $this->assertInstanceOf('help', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 5
0
 /**
  * This callback function adds a box below the message content
  * if there is a vcard attachment available
  */
 function html_output($p)
 {
     $attach_script = false;
     foreach ($this->vcard_parts as $part) {
         $vcards = rcube_vcard::import($this->message->get_part_content($part, null, true));
         // successfully parsed vcards?
         if (empty($vcards)) {
             continue;
         }
         // remove part's body
         if (in_array($part, $this->vcard_bodies)) {
             $p['content'] = '';
         }
         foreach ($vcards as $idx => $vcard) {
             // skip invalid vCards
             if (empty($vcard->email) || empty($vcard->email[0])) {
                 continue;
             }
             $display = $vcard->displayname . ' <' . $vcard->email[0] . '>';
             // add box below message body
             $p['content'] .= html::p(array('class' => 'vcardattachment'), html::a(array('href' => "#", 'onclick' => "return plugin_vcard_save_contact('" . rcube::JQ($part . ':' . $idx) . "')", 'title' => $this->gettext('addvcardmsg')), html::span(null, rcube::Q($display))));
         }
         $attach_script = true;
     }
     if ($attach_script) {
         $this->include_script('vcardattach.js');
         $this->include_stylesheet($this->local_skin_path() . '/style.css');
     }
     return $p;
 }
 /**
  * Callback function used to build mailto: links around e-mail strings
  *
  * This also adds an onclick-handler to open the Rouncube compose message screen on such links
  *
  * @param array Matches result from preg_replace_callback
  * @return int Index of saved string value
  * @see rcube_string_replacer::mailto_callback()
  */
 public function mailto_callback($matches)
 {
     $href = $matches[1];
     $suffix = $this->parse_url_brackets($href);
     $i = $this->add(html::a(array('href' => 'mailto:' . $href, 'onclick' => "return " . rcmail_output::JS_OBJECT_NAME . ".command('compose','" . rcube::JQ($href) . "',this)"), rcube::Q($href)) . $suffix);
     return $i >= 0 ? $this->get_replacement($i) : '';
 }
Exemplo n.º 7
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new new_user_dialog($rcube->api);
     $this->assertInstanceOf('new_user_dialog', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 8
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new additional_message_headers($rcube->api);
     $this->assertInstanceOf('additional_message_headers', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 9
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new example_addressbook($rcube->api);
     $this->assertInstanceOf('example_addressbook', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 10
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new debug_logger($rcube->api);
     $this->assertInstanceOf('debug_logger', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 11
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new newmail_notifier($rcube->api);
     $this->assertInstanceOf('newmail_notifier', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 12
0
 /**
  *
  */
 public function import($csv)
 {
     // convert to UTF-8
     $head = substr($csv, 0, 4096);
     $fallback = rcube::get_instance()->config->get('default_charset', 'ISO-8859-1');
     // fallback to Latin-1?
     $charset = rcube_charset::detect($head, RCUBE_CHARSET);
     $csv = rcube_charset::convert($csv, $charset);
     $head = '';
     $this->map = array();
     // Parse file
     foreach (preg_split("/[\r\n]+/", $csv) as $i => $line) {
         $elements = $this->parse_line($line);
         if (empty($elements)) {
             continue;
         }
         // Parse header
         if (empty($this->map)) {
             $this->parse_header($elements);
             if (empty($this->map)) {
                 break;
             }
         } else {
             $this->csv_to_vcard($elements);
         }
     }
 }
 function init()
 {
     $this->rc = rcube::get_instance();
     $this->add_hook('authenticate', array($this, 'authentication'));
     $this->add_hook('storage_connect', array($this, 'storage_connection'));
     $this->add_hook('smtp_connect', array($this, 'smtp_connection'));
 }
Exemplo n.º 14
0
 function init()
 {
     $this->rc = rcube::get_instance();
     // register actions
     $this->register_action('plugin.managesieve', array($this, 'managesieve_actions'));
     $this->register_action('plugin.managesieve-action', array($this, 'managesieve_actions'));
     $this->register_action('plugin.managesieve-vacation', array($this, 'managesieve_actions'));
     $this->register_action('plugin.managesieve-save', array($this, 'managesieve_save'));
     $this->register_action('plugin.managesieve-saveraw', array($this, 'managesieve_saveraw'));
     if ($this->rc->task == 'settings') {
         $this->add_hook('settings_actions', array($this, 'settings_actions'));
         $this->init_ui();
     } else {
         if ($this->rc->task == 'mail') {
             // register message hook
             if ($this->rc->action == 'show') {
                 $this->add_hook('message_headers_output', array($this, 'mail_headers'));
             }
             // inject Create Filter popup stuff
             if (empty($this->rc->action) || $this->rc->action == 'show' || strpos($this->rc->action, 'plugin.managesieve') === 0) {
                 $this->mail_task_handler();
             }
         }
     }
 }
Exemplo n.º 15
0
 function init()
 {
     $this->add_texts('localization/');
     $this->register_action('plugin.archive', array($this, 'request_action'));
     $rcmail = rcube::get_instance();
     if ($rcmail->task == 'mail' && ($rcmail->action == '' || $rcmail->action == 'show') && ($archive_folder = $rcmail->config->get('archive_mbox'))) {
         $this->add_hook('render_mailboxlist', array($this, 'render_mailboxlist'));
         if ($rcmail->config->get('archive_show_button', true)) {
             $this->add_button(array('type' => 'link', 'label' => 'buttontitle', 'command' => 'plugin.archive', 'class' => 'button buttonPas archive disabled', 'classact' => 'button archive', 'width' => 32, 'height' => 32, 'title' => 'buttontitle', 'domain' => $this->ID), 'toolbar');
         }
         $rcmail->output->set_env('archive_folder', $archive_folder);
         if ($rcmail->config->get('skin', 'larry') == 'classic') {
             $this->include_stylesheet('skins/classic/archivefolder.css');
         }
     } else {
         if ($rcmail->task == 'settings') {
             $dont_override = $rcmail->config->get('dont_override', array());
             if (!in_array('archive_mbox', $dont_override)) {
                 $this->add_hook('preferences_sections_list', array($this, 'archivefoldersection'));
                 $this->add_hook('preferences_list', array($this, 'prefs_table'));
                 $this->add_hook('preferences_save', array($this, 'save_prefs'));
             }
         }
     }
 }
Exemplo n.º 16
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new subscriptions_option($rcube->api);
     $this->assertInstanceOf('subscriptions_option', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 17
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new virtuser_file($rcube->api);
     $this->assertInstanceOf('virtuser_file', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 18
0
 public function ham(&$uids, $mbox)
 {
     $rcmail = rcube::get_instance();
     $storage = $rcmail->storage;
     $new_uids = array();
     foreach ($uids as $uid) {
         $saved = false;
         $message = new rcube_message($uid);
         if (sizeof($message->attachments) > 0) {
             foreach ($message->attachments as $part) {
                 if ($part->ctype_primary == 'message' && $part->ctype_secondary == 'rfc822' && $part->ctype_parameters['x-spam-type'] == 'original') {
                     $orig_message_raw = $message->get_part_body($part->mime_id);
                     $saved = $storage->save_message($mbox, $orig_message_raw);
                     if ($saved !== false) {
                         $rcmail->output->command('rcmail_markasjunk2_move', null, $uid);
                         array_push($new_uids, $saved);
                     }
                 }
             }
         }
     }
     if (sizeof($new_uids) > 0) {
         $uids = $new_uids;
     }
 }
Exemplo n.º 19
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new squirrelmail_usercopy($rcube->api);
     $this->assertInstanceOf('squirrelmail_usercopy', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 20
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new hide_blockquote($rcube->api);
     $this->assertInstanceOf('hide_blockquote', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 21
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new markasjunk($rcube->api);
     $this->assertInstanceOf('markasjunk', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
 /**
  * Replace emoticon icons <img> 'src' attribute, so it can
  * be replaced with real file by Mail_Mime.
  *
  * @param string &$html HTML content
  *
  * @return array List of image files
  */
 public static function replace(&$html)
 {
     // Replace this:
     // <img src="http[s]://.../tinymce/plugins/emoticons/img/smiley-cool.gif" ... />
     // with this:
     // <img src="/path/on/server/.../tinymce/plugins/emoticons/img/smiley-cool.gif" ... />
     $rcube = rcube::get_instance();
     $assets_dir = $rcube->config->get('assets_dir');
     $path = unslashify($assets_dir ?: INSTALL_PATH) . '/' . self::IMG_PATH;
     $offset = 0;
     $images = array();
     // remove any null-byte characters before parsing
     $html = preg_replace('/\\x00/', '', $html);
     if (preg_match_all('# src=[\'"]([^\'"]+)#', $html, $matches, PREG_OFFSET_CAPTURE)) {
         foreach ($matches[1] as $m) {
             // find emoticon image tags
             if (preg_match('#' . self::IMG_PATH . '(.*)$#', $m[0], $imatches)) {
                 $image_name = $imatches[1];
                 // sanitize image name so resulting attachment doesn't leave images dir
                 $image_name = preg_replace('/[^a-zA-Z0-9_\\.\\-]/i', '', $image_name);
                 $image_file = $path . $image_name;
                 // Add the same image only once
                 $images[$image_name] = $image_file;
                 $html = substr_replace($html, $image_file, $m[1] + $offset, strlen($m[0]));
                 $offset += strlen($image_file) - strlen($m[0]);
             }
         }
     }
     return $images;
 }
Exemplo n.º 23
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new identity_select($rcube->api);
     $this->assertInstanceOf('identity_select', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 24
0
 /**
  * Object constructor.
  *
  * @param string $type   Engine type ('db' or 'memcache' or 'apc')
  * @param int    $userid User identifier
  * @param string $prefix Key name prefix
  * @param string $ttl    Expiration time of memcache/apc items
  * @param bool   $packed Enables/disabled data serialization.
  *                       It's possible to disable data serialization if you're sure
  *                       stored data will be always a safe string
  */
 function __construct($type, $userid, $prefix = '', $ttl = 0, $packed = true)
 {
     $rcube = rcube::get_instance();
     $type = strtolower($type);
     if ($type == 'memcache') {
         $this->type = 'memcache';
         $this->db = $rcube->get_memcache();
     } else {
         if ($type == 'apc') {
             $this->type = 'apc';
             $this->db = function_exists('apc_exists');
             // APC 3.1.4 required
         } else {
             $this->type = 'db';
             $this->db = $rcube->get_dbh();
         }
     }
     // convert ttl string to seconds
     $ttl = get_offset_sec($ttl);
     if ($ttl > 2592000) {
         $ttl = 2592000;
     }
     $this->userid = (int) $userid;
     $this->ttl = $ttl;
     $this->packed = $packed;
     $this->prefix = $prefix;
 }
Exemplo n.º 25
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new zipdownload($rcube->api);
     $this->assertInstanceOf('zipdownload', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
 /**
  * Callback function when HTML page is rendered
  * We'll add an overlay box here.
  */
 function render_page($p)
 {
     if ($_SESSION['plugin.newuserdialog'] && $p['template'] == 'mail') {
         $this->add_texts('localization');
         $rcmail = rcmail::get_instance();
         $identity = $rcmail->user->get_identity();
         $identities_level = intval($rcmail->config->get('identities_level', 0));
         // compose user-identity dialog
         $table = new html_table(array('cols' => 2));
         $table->add('title', $this->gettext('name'));
         $table->add(null, html::tag('input', array('type' => 'text', 'name' => '_name', 'value' => $identity['name'], 'disabled' => $identities_level == 4)));
         $table->add('title', $this->gettext('email'));
         $table->add(null, html::tag('input', array('type' => 'text', 'name' => '_email', 'value' => rcube_utils::idn_to_utf8($identity['email']), 'disabled' => in_array($identities_level, array(1, 3, 4)))));
         $table->add('title', $this->gettext('organization'));
         $table->add(null, html::tag('input', array('type' => 'text', 'name' => '_organization', 'value' => $identity['organization'], 'disabled' => $identities_level == 4)));
         $table->add('title', $this->gettext('signature'));
         $table->add(null, html::tag('textarea', array('name' => '_signature', 'rows' => '3'), $identity['signature']));
         // add overlay input box to html page
         $rcmail->output->add_footer(html::tag('form', array('id' => 'newuserdialog', 'action' => $rcmail->url('plugin.newusersave'), 'method' => 'post'), html::p('hint', rcube::Q($this->gettext('identitydialoghint'))) . $table->show() . html::p(array('class' => 'formbuttons'), html::tag('input', array('type' => 'submit', 'class' => 'button mainaction', 'value' => $this->gettext('save'))))));
         $title = rcube::JQ($this->gettext('identitydialogtitle'));
         $script = "\n\$('#newuserdialog').show()\n  .dialog({modal:true, resizable:false, closeOnEscape:false, width:450, title:'{$title}'})\n  .submit(function() {\n    var i, request = {}, form = \$(this).serializeArray();\n    for (i in form)\n      request[form[i].name] = form[i].value;\n\n      rcmail.http_post('plugin.newusersave', request, true);\n      return false;\n  });\n\n\$('input[name=_name]').focus();\nrcube_webmail.prototype.new_user_dialog_close = function() { \$('#newuserdialog').dialog('close'); }\n";
         // disable keyboard events for messages list (#1486726)
         $rcmail->output->add_script($script, 'docready');
         $this->include_stylesheet('newuserdialog.css');
     }
 }
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new http_authentication($rcube->api);
     $this->assertInstanceOf('http_authentication', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
Exemplo n.º 28
0
 public function ham(&$uids)
 {
     $rcmail = rcube::get_instance();
     $storage = $rcmail->storage;
     $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
     $new_uids = array();
     foreach (explode(",", $uids) as $uid) {
         $saved = false;
         $message = new rcube_message($uid);
         if (sizeof($message->attachments) > 0) {
             foreach ($message->attachments as $part) {
                 if ($part->ctype_primary == 'message' && $part->ctype_secondary == 'rfc822') {
                     $orig_message_raw = $storage->get_message_part($message->uid, $part->mime_id, $part);
                     $saved = $storage->save_message($mbox, $orig_message_raw);
                     if ($saved !== false) {
                         $rcmail->output->command('rcmail_markasjunk2_move', null, $uid);
                         array_push($new_uids, $saved);
                     }
                 }
             }
         }
     }
     if (sizeof($new_uids) > 0) {
         $uids = implode(',', $new_uids);
     }
 }
Exemplo n.º 29
0
 /**
  * Plugin object construction test
  */
 function test_constructor()
 {
     $rcube = rcube::get_instance();
     $plugin = new legacy_browser($rcube->api);
     $this->assertInstanceOf('legacy_browser', $plugin);
     $this->assertInstanceOf('rcube_plugin', $plugin);
 }
 /**
  * Place a link in the messageAttachments (template object) 
  * to trigger the removal of all attachments
  */
 function attachment_removelink($p)
 {
     /* // place links to remove attachment for each attachment
             $links = preg_split('/(<li[^>]*>)/', $p['content'], null, PREG_SPLIT_DELIM_CAPTURE);		
     
             for ($i = 1; $i < count($links); $i+=2) {
                 if (preg_match('/ id="attach([0-9]+)"/', $links[$i], $matches)) {
                     $remove = $this->api->output->button(array('command' => 'plugin.removeattachments.removeone', 
                                                                'prop' => $matches[1], 
                                                                'image' => $this->url(null) . $this->local_skin_path() . '/del.png', 
                                                                'title' => 'removeattachments.removeattachment',
                                                                'style' => 'vertical-align:middle'));
                     $links[$i+1] = str_replace('</li>', '&nbsp;' . $remove . '</li>', $links[$i+1]);
     			}
     		}
     
             $p['content'] = join('', $links);
             */
     // when there are multiple attachments allow delete all
     if (substr_count($p['content'], ' id="attach') > 1) {
         $link = $this->api->output->button(array('type' => 'link', 'command' => 'plugin.removeattachments.removeall', 'content' => rcube::Q($this->gettext('removeattachments.removeall')), 'title' => 'removeattachments.removeall', 'class' => 'button removeattachments'));
         switch (rcmail::get_instance()->config->get('skin')) {
             case 'classic':
                 //$p['content'] = preg_replace('/(<ul[^>]*>)/', '$1' . $link, $p['content']);
                 $p['content'] = str_replace('</ul>', html::tag('li', null, $link) . '</ul>', $p['content']);
                 break;
             default:
                 $p['content'] .= $link;
                 break;
         }
         $this->include_stylesheet($this->local_skin_path() . '/removeattachments.css');
     }
     return $p;
 }