@ -62,8 +62,9 @@ class rcube_sieve_engine
2 => 'notifyimportancenormal',
1 => 'notifyimportancehigh'
);
private $disabled_actions;
const VERSION = '8. 9';
const VERSION = '9.0 ';
const PROGNAME = 'Roundcube (Managesieve)';
const PORT = 4190;
@ -92,6 +93,8 @@ class rcube_sieve_engine
'filterseteditraw' => array($this, 'filterset_editraw'),
));
$this->disabled_actions = $this->rc->config->get('managesieve_disabled_actions', array());
// connect to managesieve server
$error = $this->connect($_SESSION['username'], $this->rc->decrypt($_SESSION['password']));
@ -147,6 +150,9 @@ class rcube_sieve_engine
}
$this->rc->output->set_env('raw_sieve_editor', $this->rc->config->get('managesieve_raw_editor', true));
$this->rc->output->set_env('managesieve_disabled_actions', $this->disabled_actions);
if (in_array('list_sets', $this->disabled_actions))
$this->rc->output->set_env('managesieve_no_set_list', true);
return $error;
}
@ -288,6 +294,7 @@ class rcube_sieve_engine
$fid = (int) rcube_utils::get_input_value('_fid', rcube_utils::INPUT_POST);
if ($action == 'delete' & & !$error) {
if (!in_array('delete_rule', $this->disabled_actions)) {
if (isset($this->script[$fid])) {
if ($this->sieve->script->delete_rule($fid))
$result = $this->save_script();
@ -301,6 +308,10 @@ class rcube_sieve_engine
}
}
}
else {
$this->rc->output->show_message('managesieve.disabledaction', 'error');
}
}
else if ($action == 'move' & & !$error) {
if (isset($this->script[$fid])) {
$to = (int) rcube_utils::get_input_value('_to', rcube_utils::INPUT_POST);
@ -366,6 +377,7 @@ class rcube_sieve_engine
}
}
else if ($action == 'setact' & & !$error) {
if (!in_array('enable_disable_set', $this->disabled_actions)) {
$script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_POST, true);
$result = $this->activate_script($script_name);
$kep14 = $this->rc->config->get('managesieve_kolab_master');
@ -380,7 +392,12 @@ class rcube_sieve_engine
$this->rc->output->show_message('managesieve.setactivateerror', 'error');
}
}
else {
$this->rc->output->show_message('managesieve.disabledaction', 'error');
}
}
else if ($action == 'deact' & & !$error) {
if (!in_array('enable_disable_set', $this->disabled_actions)) {
$script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_POST, true);
$result = $this->deactivate_script($script_name);
@ -394,7 +411,12 @@ class rcube_sieve_engine
$this->rc->output->show_message('managesieve.setdeactivateerror', 'error');
}
}
else {
$this->rc->output->show_message('managesieve.disabledaction', 'error');
}
}
else if ($action == 'setdel' & & !$error) {
if (!in_array('delete_set', $this->disabled_actions)) {
$script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_POST, true);
$result = $this->remove_script($script_name);
@ -408,7 +430,12 @@ class rcube_sieve_engine
$this->rc->output->show_message('managesieve.setdeleteerror', 'error');
}
}
else {
$this->rc->output->show_message('managesieve.disabledaction', 'error');
}
}
else if ($action == 'setget') {
if (!in_array('download_set', $this->disabled_actions)) {
$this->rc->request_security_check(rcube_utils::INPUT_GET);
$script_name = rcube_utils::get_input_value('_set', rcube_utils::INPUT_GPC, true);
@ -421,6 +448,7 @@ class rcube_sieve_engine
exit;
}
}
else if ($action == 'list') {
$result = $this->list_rules();
@ -547,7 +575,10 @@ class rcube_sieve_engine
$name_uc = mb_strtolower($name);
$list = $this->list_scripts();
if (!$name) {
if (in_array('new_set', $this->disabled_actions)) {
$error = 'managesieve.disabledaction';
}
else if (!$name) {
$this->errors['name'] = $this->plugin->gettext('cannotbeempty');
}
else if (mb_strlen($name) > 128) {
@ -1407,6 +1438,12 @@ class rcube_sieve_engine
$fid = rcube_utils::get_input_value('_fid', rcube_utils::INPUT_GPC);
$scr = isset($this->form) ? $this->form : $this->script[$fid];
// do not allow creation of new rules
if ($fid == null & & in_array('new_rule', $this->disabled_actions)) {
$this->rc->output->show_message('managesieve.disabledaction', 'error');
return;
}
$hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $this->rc->task));
$hiddenfields->add(array('name' => '_action', 'value' => 'plugin.managesieve-save'));
$hiddenfields->add(array('name' => '_framed', 'value' => ($_POST['_framed'] || $_GET['_framed'] ? 1 : 0)));
@ -2472,6 +2509,17 @@ class rcube_sieve_engine
}
}
// When no script listing allowed limit the list to the defined script
if (in_array('list_sets', $this->disabled_actions)) {
$script_name = $this->rc->config->get('managesieve_script_name', 'roundcube');
$this->list = array_intersect($this->list, array($script_name));
$this->active = null;
if (in_array($script_name, $this->list)) {
// Because its the only allowed script make sure its active
$this->activate_script($script_name);
}
}
// reindex
if (!empty($this->list)) {
$this->list = array_values($this->list);
@ -2514,7 +2562,7 @@ class rcube_sieve_engine
$user_script = $_SESSION['managesieve_user_script'];
// if the script is not active...
if ($user_script & & array_search($name, $this->active) === false) {
if ($user_script & & array_search($name, (array) $this->active) === false) {
// ...rewrite USER file adding appropriate include command
if ($this->sieve->load($user_script)) {
$script = $this->sieve->script->as_array();