From: Julien Moutinho Date: Wed, 31 Jul 2013 13:15:25 +0000 (+0200) Subject: initial commit, for roundcube v0.7.2-9 X-Git-Url: http://git.cyclocoop.org/?p=roundcube%2Fplugins%2Fjunk_keyword.git;a=commitdiff_plain;h=HEAD initial commit, for roundcube v0.7.2-9 --- 94f32d9ffe56f1c2d69982a49b9a6cbddcef848a diff --git a/junk_keyword.js b/junk_keyword.js new file mode 100644 index 0000000..01d0d15 --- /dev/null +++ b/junk_keyword.js @@ -0,0 +1,108 @@ +function junk_keyword_message_set(junk_uids, nonjunk_uids) { + var i; + for (i=0; i 0) + rcmail.http_post('mark', '_uid='+id+'&_flag=read&_quiet=1'); + } + for (i=0; i= 0) { + rcmail.set_env('junk_keyword_col', found); + } + if (rcmail.env.junk_keyword_col != null) { + var junk_icon = 'rcmjunk_keyword' + row.uid; + if (row.junk_icon = document.getElementById(junk_icon)) { + row.junk_icon._row = row.obj; + row.junk_icon.onmousedown = function(e) { + rcmail.command('plugin.junk_keyword.icon_toggle', this); + rcube_event.cancel(e); + }; + } + } + }); + }; +$(document).ready(function() { + junk_keyword_menu(); + var li = '
  • '; + $("#listmenu fieldset ul input#cols_threads").parent().after(li); + }); diff --git a/junk_keyword.php b/junk_keyword.php new file mode 100644 index 0000000..d896d8c --- /dev/null +++ b/junk_keyword.php @@ -0,0 +1,110 @@ +name, "init: task=" . print_r($rcmail->task, true) . " action=" . print_r($rcmail->action, true)); + $rcmail = rcmail::get_instance(); + $this->name = get_class($this); + if (($rcmail->task == 'mail') && ($rcmail->action == '')) { + $this->add_hook('render_page', array($this, 'render_page')); + $this->include_script('junk_keyword.js'); + } + $this->add_junk_flags = array + ( 'JUNK' => 'Junk' + , 'NONJUNK' => 'NonJunk' + ); + $this->register_action('plugin.junk_keyword.set_keywords', array($this, 'set_keywords')); + $this->add_hook('messages_list', array($this, 'message_list')); + $this->add_texts('localization'); + } + public function render_page($args) { + #write_log($this->name, "render_page: args=" . print_r($args, true)); + $rcmail = rcmail::get_instance(); + $icon = 'plugins/junk_keyword/' .$this->local_skin_path(). '/junk.png'; + $junk_keywordicon = html::img(array + ( 'alt' => $this->gettext('junk_keyword') + , 'id' => 'junk_keyword_menulink' + , 'src' => $icon + , 'title' => $this->gettext('junk_keyword'))); + $rcmail->output->add_label('junk_keyword.junk_keyword'); + $rcmail->output->set_env('junk_keywordicon', $junk_keywordicon); + $this->include_stylesheet($this->local_skin_path(). '/junk.css'); + + return $args; + } + public function message_list($args) { + #write_log($this->name, "message_list: args=" . print_r($args, true)); + if (!isset($args['messages']) or !is_array($args['messages'])) + return $args; + foreach($args['messages'] as $message) { + #write_log($this->name, "message_list: foreach: begin: message=" . print_r($message, true)); + $message->list_flags['extra_flags']['junk_keywords'] = array(); # always set extra_flags, needed for javascript later! + if (is_array($message->flags)) { + $uid = $message->uid; + $class = ''; + foreach ($message->flags as $flagname => $flagvalue) { + $flag = is_numeric("$flagvalue") ? $flagname : $flagvalue; // for compatibility with < 0.5.4 + $flag = strtolower($flag); + #write_log($this->name, "message_list: foreach: flag=" . print_r($flag, true)); + $message->list_flags['extra_flags']['junk'] = false; + if (preg_match('/^junk$/', $flag)) { + $class = "junk"; + $message->list_flags['extra_flags']['junk'] = true; + } + if (preg_match('/^nonjunk$/', $flag)) { + $class = "nonjunk"; + $message->list_flags['extra_flags']['junk'] = false; + } + } + if (!empty($uid)) + $message->list_cols['junk_keyword'] = '
     
    '; + } + } + return $args; + } + public function set_keywords() { + #write_log($this->name, "set_keywords: _GET=" . print_r($_GET, true)); + + $rcmail = rcmail::get_instance(); + $imap = $rcmail->imap; + //$cbox = get_input_value('_cur', RCUBE_INPUT_GET); + $mbox = get_input_value('_mbox', RCUBE_INPUT_GET); + $junk_uids = get_input_value('_junk_uids', RCUBE_INPUT_GET); + $junk_uids = array_filter(explode(',', $junk_uids)); + $nonjunk_uids = get_input_value('_nonjunk_uids', RCUBE_INPUT_GET); + $nonjunk_uids = array_filter(explode(',', $nonjunk_uids)); + + $imap->conn->flags = array_merge($imap->conn->flags, $this->add_junk_flags); + + if (!is_array($junk_uids) || !is_array($nonjunk_uids)) + return false; + //write_log($this->name, "set_keywords: junk_uids=" . print_r($junk_uids, true)); + //write_log($this->name, "set_keywords: nonjunk_uids=" . print_r($nonjunk_uids, true)); + + $error = ""; + $imap->conn->error = ""; + if (!empty($junk_uids)) { + if (!$imap->set_flag($junk_uids, 'SEEN', $mbox)) + $error = "set SEEN: " . $imap->conn->error; + if (!$imap->unset_flag($junk_uids, 'NONJUNK', $mbox)) + $error = "unset NONJUNK: " . $imap->conn->error; + if (!$imap->set_flag($junk_uids, 'JUNK', $mbox)) + $error = "set JUNK: " . $imap->conn->error; + } + if (!empty($nonjunk_uids)) { + if (!$imap->unset_flag($nonjunk_uids, 'JUNK', $mbox)) + $error = "unset JUNK: " . $imap->conn->error; + if (!$imap->set_flag($nonjunk_uids, 'NONJUNK', $mbox)) + $error = "set NONJUNK: " . $imap->conn->error; + } + if (empty($error)) + $rcmail->output->command('display_message', $this->gettext('classification_done'), 'confirmation'); + else + $rcmail->output->command('display_message', $this->gettext('classification_failed'). ': ' . $error, 'error'); + $this->api->output->send(); + return empty($error); + } + } +?> diff --git a/localization/en_US.inc b/localization/en_US.inc new file mode 100644 index 0000000..d3e1200 --- /dev/null +++ b/localization/en_US.inc @@ -0,0 +1,8 @@ + diff --git a/localization/fr_FR.inc b/localization/fr_FR.inc new file mode 100644 index 0000000..f98fe6b --- /dev/null +++ b/localization/fr_FR.inc @@ -0,0 +1,8 @@ + diff --git a/skins/default/junk.css b/skins/default/junk.css new file mode 100644 index 0000000..3a7edfb --- /dev/null +++ b/skins/default/junk.css @@ -0,0 +1,19 @@ +#messagelist tr td.junk_keyword { + background: transparent center no-repeat + display: inline-block; + width: 12px; + vertical-align: middle; + } +#messagelist tr td.junk_keyword div { + margin:0 auto; + height: 16px; + vertical-align: middle; + width: 12px; + } +#messagelist tr td.junk_keyword div.junk { + background: url(/plugins/junk_keyword/skins/default/junk.png); + } +#messagelist tr td.junk_keyword div:hover { + background: url(/plugins/junk_keyword/skins/default/junkify.png); + cursor: pointer !important; + } diff --git a/skins/default/junk.png b/skins/default/junk.png new file mode 100644 index 0000000..5861ba1 Binary files /dev/null and b/skins/default/junk.png differ diff --git a/skins/default/junkify.png b/skins/default/junkify.png new file mode 100644 index 0000000..3a07e09 Binary files /dev/null and b/skins/default/junkify.png differ