Hi
I write plugin with settings roles for mails and I need create select input with folders list, I try use rcmail_mailbox_select but I get empty page.
I need some examples how use rcmail_mailbox_select.
function init()
{
$rcmail = rcmail::get_instance();
// add Tab label
$this->add_texts('localization/', array('filtermails'));
$this->register_action('plugin.filter_mails', array($this, 'filter_init'));
$this->register_action('plugin.filter_mails_new', array($this, 'filter_add'));
// $this->add_hook('render_mailboxlist', array($this, 'filter_add2'));
$rcmail->output->add_label($this->gettext('Filters'));
$this->include_script('filter_mails.js');
$this->include_stylesheet('filter_mails.css');
}
// function FilterList_init()
function filter_init()
{
$this->register_handler('plugin.body', array($this, 'infohtml1'));
$rcmail = rcmail::get_instance();
$rcmail->output->set_pagetitle($this->gettext('filters'));
$rcmail->output->send('plugin');
}
function filter_add($args)
{
$this->register_handler('plugin.body', array($this, 'filter_form'));
$rcmail = rcmail::get_instance();
$rcmail->output->set_pagetitle($this->gettext('filter_add'));
$rcmail->output->send('plugin');
}
function infohtml1()
{
global $table;
// $this->_load_config();
$rcmail = rcmail::get_instance();
$user = $rcmail->user;
// Set commalist variables from config and language file
// if ($this->config['pn_newline']) {
// $pn_newline = true;
// $pn_parentheses = false;
// } else {
// $pn_newline = false;
// $pn_parentheses = true;
// }
$table = new html_table(array('cols' => 4, 'cellpadding' => 0, 'cellspacing' => 0, 'class' => 'filters'));
// ----- Account start -----
$table->add(array('colspan' => 4),
'<DIV class="button_filter" '.
'onmouseout="fiilter_Change_Class(this, \'button_filter\')" onmouseover="fiilter_Change_Class(this, \'button_filter_over\')" ><a class="button_link" href="'.
rcmail_url('plugin.filter_mails_new', array()).'">'.$this->gettext('filter_add').'</a></div>'.
'<DIV class="button_filter" '.
'onmouseout="fiilter_Change_Class(this, \'button_filter\')" onmouseover="fiilter_Change_Class(this, \'button_filter_over\')"><a class="button_link" href="'.
rcmail_url('plugin.filter_mails', array()).'">'.
$this->gettext('filter_list').'</a></div>');
$table->add_row();
$table->add(array('colspan' => 4), '<hr>');
$table->add_row();
$table->add(array('width' => '80px'), $this->gettext('filterpriority'));
$table->add('value', $this->gettext('filtername'));
$table->add('value', $this->gettext('option'));
$table->add('value', $this->gettext('description'));
$out = html::div(array('class' => 'settingsbox settingsbox-filters'),
html::div(array('class' => 'boxtitle'), $this->gettext('filters')) .
html::div(array('class' => 'boxcontent'), $table->show()));
// print_r($out);
return $out;
}
function filter_form($args)
{
$rcmail = rcmail::get_instance();
$this->load_config();
$rcmail->config->get('product_name'));
$table = new html_table(array('cols' => 6, 'cellpadding' => 0, 'cellspacing' => 0, 'class' => 'filters'));
$table->add(array('colspan' => 6),
'<DIV class="button_filter" '.
'onmouseout="fiilter_Change_Class(this, \'button_filter\')" onmouseover="fiilter_Change_Class(this, \'button_filter_over\')" ><a class="button_link" href="'.
rcmail_url('plugin.filter_mails_new', array()).'">'.$this->gettext('filter_add').'</a></div>'.
'<DIV class="button_filter" '.
'onmouseout="fiilter_Change_Class(this, \'button_filter\')" onmouseover="fiilter_Change_Class(this, \'button_filter_over\')"><a class="button_link" href="'.
rcmail_url('plugin.filter_mails', array()).'">'.
$this->gettext('filter_list').'</a></div>');
$table->add_row();
$table->add(array('colspan' => 6), '<hr>');
$table->add_row();
$field_id = 'feldfilter';
$select_feldfilter = new html_select(array('name' => '_feldfilter', 'id' => $field_id));
$select_feldfilter->add(array($this->gettext('filter_by_subject'),
$this->gettext('filter_by_sender'),
$this->gettext('filter_by_receiver')),
array('subject','sender','receiver'));
$table->add(null, html::label($field_id, Q($this->gettext('filter_by'))));
$table->add(null, $select_feldfilter->show('DE'));
$field_id = 'feldoption';
$select_feldoption = new html_select(array('name' => '_feldoption', 'id' => $field_id));
$select_feldoption->add(array($this->gettext('filter_equal'),
$this->gettext('filter_contain'),
$this->gettext('filter_begining'),
$this->gettext('filter_ending')),
array('equal','contain','begining','ending'));
$table->add(null, $select_feldoption->show());
$field_id = 'feldvalue';
$input_feldvalue = new html_inputfield(array('name' => '_feldvalue', 'id' => $field_id,
'size' => 20, 'autocomplete' => 'on'));
$table->add(null, $input_feldvalue->show());
$field_id = 'feldaction';
$select_feldaction = new html_select(array('name' => '_feldaction', 'id' => $field_id));
$select_feldaction->add(array($this->gettext('filter_move'),
$this->gettext('filter_copy')),
array('move','copy'));
$table->add(null, $select_feldaction->show());
$select_folders= new html_select();
// $sselect_folders=rcmail_mailbox_select();
//array('noselection' => '---', 'realnames' => true,
// 'maxlength' => 30, 'exceptions' => array('INBOX')));
$table->add(null, $select_folders->show());
$table->add_row();
$table->add(array('colspan' => 6), '<hr>');
$table->add_row();
$table->add(array('colspan' => 6), $this->_gen_folder_list($args['list'], '#copyto'));
$out = html::div(array('class' => 'settingsbox', 'style' => 'margin:0'),
html::div(array('id' => 'prefs-title', 'class' => 'boxtitle'), $this->gettext('filter_add')) .
html::div(array('class' => 'boxcontent'), $table->show() .
html::p(null,
$rcmail->output->button(array(
'command' => 'plugin.filter_add-save',
'type' => 'input',
'class' => 'button mainaction',
'label' => 'save'
)))
)
);
$rcmail->output->add_gui_object('filter0form', 'filter_add-form');
return $rcmail->output->form_tag(array(
'id' => 'filter_add-form',
'name' => 'filter_add-form',
'method' => 'post',
'action' => './?_task=settings&_action=plugin.filter_add-save',
), $out);
}
Thanks
I try to use $rcmail->imap->list_mailboxes();
by always get blank page, what I doing wrong?
Thanks
Dariusz
its been a while since i did this but from what i remember you need to do it differently depending on where in the system you are when you try and call the list. in the settings section you can use soemthing like this:
// get mailbox list
$mbox_name = $rcmail->imap->get_mailbox_name();
// build the folders tree
if (empty($a_mailboxes)) {
// get mailbox list
$a_folders = $rcmail->imap->list_mailboxes();
$delimiter = $rcmail->imap->get_hierarchy_delimiter();
$a_mailboxes = array();
foreach ($a_folders as $ifolder)
rcmail_build_folder_tree($a_mailboxes, $ifolder, $delimiter);
}
$input_folderlist = new html_select($attrib);
rcmail_render_folder_tree_select($a_mailboxes, $mbox_name, 100, $input_folderlist, false);
$input_folderlist->show();