/**
  * Read available calendars for the current user and store them internally
  */
 private function _read_lists()
 {
     $hidden = array_filter(explode(',', $this->rc->config->get('hidden_tasklists', '')));
     if (!empty($this->rc->user->ID)) {
         $list_ids = array();
         $result = $this->rc->db->query("SELECT *, tasklist_id AS id FROM " . $this->db_lists . "\n           WHERE user_id=?\n           ORDER BY CASE WHEN name='INBOX' THEN 0 ELSE 1 END, name", $this->rc->user->ID);
         while ($result && ($arr = $this->rc->db->fetch_assoc($result))) {
             $arr['showalarms'] = intval($arr['showalarms']);
             $arr['active'] = !in_array($arr['id'], $hidden);
             $arr['name'] = html::quote($arr['name']);
             $arr['editable'] = true;
             $this->lists[$arr['id']] = $arr;
             $list_ids[] = $this->rc->db->quote($arr['id']);
         }
         $this->list_ids = join(',', $list_ids);
     }
 }
Exemplo n.º 2
0
 /**
  * Read available calendars for the current user and store them internally
  */
 private function _read_calendars()
 {
     $hidden = array_filter(explode(',', $this->rc->config->get('hidden_calendars', '')));
     if (!empty($this->rc->user->ID)) {
         $calendar_ids = array();
         $result = $this->rc->db->query("SELECT *, calendar_id AS id FROM " . $this->db_calendars . "\n         WHERE user_id=?\n         ORDER BY name", $this->rc->user->ID);
         while ($result && ($arr = $this->rc->db->fetch_assoc($result))) {
             $arr['showalarms'] = intval($arr['showalarms']);
             $arr['active'] = !in_array($arr['id'], $hidden);
             $arr['name'] = html::quote($arr['name']);
             $arr['listname'] = html::quote($arr['name']);
             $this->calendars[$arr['calendar_id']] = $arr;
             $calendar_ids[] = $this->rc->db->quote($arr['calendar_id']);
         }
         $this->calendar_ids = join(',', $calendar_ids);
     }
 }
Exemplo n.º 3
0
 /**
  * Return html for a flat list <select> for the mailbox tree
  */
 public function render_folder_tree_select(&$arrFolders, &$mbox_name, $maxlength, &$select, $realnames = false, $nestLevel = 0, $opts = array())
 {
     $out = '';
     foreach ($arrFolders as $folder) {
         // skip exceptions (and its subfolders)
         if (!empty($opts['exceptions']) && in_array($folder['id'], $opts['exceptions'])) {
             continue;
         }
         // skip folders in which it isn't possible to create subfolders
         if (!empty($opts['skip_noinferiors'])) {
             $attrs = $this->storage->folder_attributes($folder['id']);
             if ($attrs && in_array_nocase('\\Noinferiors', $attrs)) {
                 continue;
             }
         }
         if (!$realnames && ($folder_class = $this->folder_classname($folder['id']))) {
             $foldername = $this->gettext($folder_class);
         } else {
             $foldername = $folder['name'];
             // shorten the folder name to a given length
             if ($maxlength && $maxlength > 1) {
                 $foldername = abbreviate_string($foldername, $maxlength);
             }
         }
         $select->add(str_repeat('&nbsp;', $nestLevel * 4) . html::quote($foldername), $folder['id']);
         if (!empty($folder['folders'])) {
             $out .= $this->render_folder_tree_select($folder['folders'], $mbox_name, $maxlength, $select, $realnames, $nestLevel + 1, $opts);
         }
     }
     return $out;
 }
 /**
  * GUI object 'loginform'
  * Returns code for the webmail login form
  *
  * @param array Named parameters
  * @return string HTML code for the gui object
  */
 protected function login_form($attrib)
 {
     $default_host = $this->config->get('default_host');
     $autocomplete = (int) $this->config->get('login_autocomplete');
     $_SESSION['temp'] = true;
     // save original url
     $url = rcube_utils::get_input_value('_url', rcube_utils::INPUT_POST);
     if (empty($url) && !preg_match('/_(task|action)=logout/', $_SERVER['QUERY_STRING'])) {
         $url = $_SERVER['QUERY_STRING'];
     }
     // Disable autocapitalization on iPad/iPhone (#1488609)
     $attrib['autocapitalize'] = 'off';
     // set atocomplete attribute
     $user_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $host_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $pass_attrib = $autocomplete > 1 ? array() : array('autocomplete' => 'off');
     $input_task = new html_hiddenfield(array('name' => '_task', 'value' => 'login'));
     $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login'));
     $input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_'));
     $input_url = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url));
     $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser', 'required' => 'required') + $attrib + $user_attrib);
     $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd', 'required' => 'required') + $attrib + $pass_attrib);
     $input_host = null;
     if (is_array($default_host) && count($default_host) > 1) {
         $input_host = new html_select(array('name' => '_host', 'id' => 'rcmloginhost'));
         foreach ($default_host as $key => $value) {
             if (!is_array($value)) {
                 $input_host->add($value, is_numeric($key) ? $value : $key);
             } else {
                 $input_host = null;
                 break;
             }
         }
     } else {
         if (is_array($default_host) && ($host = key($default_host)) !== null) {
             $hide_host = true;
             $input_host = new html_hiddenfield(array('name' => '_host', 'id' => 'rcmloginhost', 'value' => is_numeric($host) ? $default_host[$host] : $host) + $attrib);
         } else {
             if (empty($default_host)) {
                 $input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost') + $attrib + $host_attrib);
             }
         }
     }
     $form_name = !empty($attrib['form']) ? $attrib['form'] : 'form';
     $this->add_gui_object('loginform', $form_name);
     // create HTML table with two cols
     $table = new html_table(array('cols' => 2));
     $table->add('title', html::label('rcmloginuser', html::quote($this->app->gettext('username'))));
     $table->add('input', $input_user->show('mail@box'));
     $table->add('title', html::label('rcmloginpwd', html::quote($this->app->gettext('password'))));
     $table->add('input', $input_pass->show());
     // add host selection row
     if (is_object($input_host) && !$hide_host) {
         $table->add('title', html::label('rcmloginhost', html::quote($this->app->gettext('server'))));
         $table->add('input', $input_host->show(rcube_utils::get_input_value('_host', rcube_utils::INPUT_GPC)));
     }
     $out = $input_task->show();
     $out .= $input_action->show();
     $out .= $input_tzone->show();
     $out .= $input_url->show();
     $out .= $table->show();
     if ($hide_host) {
         $out .= $input_host->show();
     }
     if (rcube_utils::get_boolean($attrib['submit'])) {
         $submit = new html_inputfield(array('type' => 'submit', 'id' => 'rcmloginsubmit', 'class' => 'button mainaction', 'value' => $this->app->gettext('login')));
         $out .= html::p('formbuttons', $submit->show());
     }
     // surround html output with a form tag
     if (empty($attrib['form'])) {
         $out = $this->form_tag(array('name' => $form_name, 'method' => 'post'), $out);
     }
     // include script for timezone detection
     $this->include_script('jstz.min.js');
     return $out;
 }
Exemplo n.º 5
0
 /**
  * GUI object 'loginform'
  * Returns code for the webmail login form
  *
  * @param array Named parameters
  * @return string HTML code for the gui object
  */
 protected function login_form($attrib)
 {
     $default_host = $this->config->get('default_host');
     $autocomplete = (int) $this->config->get('login_autocomplete');
     $_SESSION['temp'] = true;
     // save original url
     $url = rcube_utils::get_input_value('_url', rcube_utils::INPUT_POST);
     if (empty($url) && !preg_match('/_(task|action)=logout/', $_SERVER['QUERY_STRING'])) {
         $url = $_SERVER['QUERY_STRING'];
     }
     // set atocomplete attribute
     $user_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $host_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $pass_attrib = $autocomplete > 1 ? array() : array('autocomplete' => 'off');
     $input_task = new html_hiddenfield(array('name' => '_task', 'value' => 'login'));
     $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login'));
     $input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_'));
     $input_dst = new html_hiddenfield(array('name' => '_dstactive', 'id' => 'rcmlogindst', 'value' => '_default_'));
     $input_url = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url));
     $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser') + $attrib + $user_attrib);
     $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd') + $attrib + $pass_attrib);
     $input_host = null;
     if (is_array($default_host) && count($default_host) > 1) {
         $input_host = new html_select(array('name' => '_host', 'id' => 'rcmloginhost'));
         foreach ($default_host as $key => $value) {
             if (!is_array($value)) {
                 $input_host->add($value, is_numeric($key) ? $value : $key);
             } else {
                 $input_host = null;
                 break;
             }
         }
     } else {
         if (is_array($default_host) && ($host = array_pop($default_host))) {
             $hide_host = true;
             $input_host = new html_hiddenfield(array('name' => '_host', 'id' => 'rcmloginhost', 'value' => $host) + $attrib);
         } else {
             if (empty($default_host)) {
                 $input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost') + $attrib + $host_attrib);
             }
         }
     }
     $form_name = !empty($attrib['form']) ? $attrib['form'] : 'form';
     $this->add_gui_object('loginform', $form_name);
     // create HTML table with two cols
     $table = new html_table(array('cols' => 2));
     $table->add('title', html::label('rcmloginuser', html::quote($this->app->gettext('username'))));
     $table->add('input', $input_user->show(rcube_utils::get_input_value('_user', rcube_utils::INPUT_GPC)));
     $table->add('title', html::label('rcmloginpwd', html::quote($this->app->gettext('password'))));
     $table->add('input', $input_pass->show());
     // add host selection row
     if (is_object($input_host) && !$hide_host) {
         $table->add('title', html::label('rcmloginhost', html::quote($this->app->gettext('server'))));
         $table->add('input', $input_host->show(rcube_utils::get_input_value('_host', rcube_utils::INPUT_GPC)));
     }
     $out = $input_task->show();
     $out .= $input_action->show();
     $out .= $input_tzone->show();
     $out .= $input_dst->show();
     $out .= $input_url->show();
     $out .= $table->show();
     if ($hide_host) {
         $out .= $input_host->show();
     }
     // surround html output with a form tag
     if (empty($attrib['form'])) {
         $out = $this->form_tag(array('name' => $form_name, 'method' => 'post'), $out);
     }
     return $out;
 }
Exemplo n.º 6
0
 /**
  * Test for quote()
  * @dataProvider data_quote
  */
 function test_quote($str, $result)
 {
     $this->assertEquals(html::quote($str), $result);
 }
Exemplo n.º 7
0
// allow the current user to get to the next step
$_SESSION['allowinstaller'] = true;
if (!empty($_POST['submit'])) {
    $_SESSION['config'] = $RCI->create_config();
    if ($RCI->save_configfile($_SESSION['config'])) {
        echo '<p class="notice">The config file was saved successfully into <tt>' . RCMAIL_CONFIG_DIR . '</tt> directory of your Roundcube installation.';
        if ($RCI->legacy_config) {
            echo '<br/><br/>Afterwards, please <b>remove</b> the old configuration files <tt>main.inc.php</tt> and <tt>db.inc.php</tt> from the config directory.';
        }
        echo '</p>';
    } else {
        if (($dir = sys_get_temp_dir()) && @is_writable($dir)) {
            echo '<iframe name="getconfig" style="display:none"></iframe>';
            echo '<form id="getconfig_form" action="index.php" method="get" target="getconfig" style="display:none">';
            echo '<input name="_getconfig" value="2" /></form>';
            $button_txt = html::quote('Save in ' . $dir);
            $save_button = '&nbsp;<input type="button" onclick="document.getElementById(\'getconfig_form\').submit()" value="' . $button_txt . '" />';
        }
        echo '<p class="notice">Copy or download the following configuration and save it';
        echo ' as <tt><b>config.inc.php</b></tt> within the <tt>' . RCUBE_CONFIG_DIR . '</tt> directory of your Roundcube installation.<br/>';
        echo ' Make sure that there are no characters outside the <tt>&lt;?php ?&gt;</tt> brackets when saving the file.';
        echo '&nbsp;<input type="button" onclick="location.href=\'index.php?_getconfig=1\'" value="Download" />';
        echo $save_button;
        if ($RCI->legacy_config) {
            echo '<br/><br/>Afterwards, please <b>remove</b> the old configuration files <tt>main.inc.php</tt> and <tt>db.inc.php</tt> from the config directory.';
        }
        echo '</p>';
        $textbox = new html_textarea(array('rows' => 16, 'cols' => 60, 'class' => "configfile"));
        echo $textbox->show($_SESSION['config']);
    }
    echo '<p class="hint">Of course there are more options to configure.
Exemplo n.º 8
0
 /**
  * Read available calendars for the current user and store them internally
  */
 protected function _read_calendars()
 {
     if (!empty($this->rc->user->ID)) {
         $calendar_ids = array();
         $result = $this->rc->db->query("SELECT *, calendar_id AS id FROM " . $this->_get_table($this->db_calendars) . "\n         WHERE user_id=?\n         ORDER BY name", $this->rc->user->ID);
         while ($result && ($arr = $this->rc->db->fetch_assoc($result))) {
             $arr['showalarms'] = intval($arr['showalarms']);
             $arr['evts'] = intval($arr['events']);
             $arr['tasks'] = intval($arr['tasks']);
             $arr['active'] = $arr['subscribed'] ? true : false;
             $arr['name'] = html::quote($arr['name']);
             $arr['listname'] = html::quote($arr['name']);
             $arr['readonly'] = $arr['readonly'] ? true : false;
             $arr['isdefault'] = $arr['id'] == $this->rc->config->get('calendar_default_calendar') ? true : false;
             unset($arr['events']);
             $this->calendars[$arr['calendar_id']] = $arr;
             $calendar_ids[] = $this->rc->db->quote($arr['calendar_id']);
         }
         $this->calendar_ids = join(',', $calendar_ids);
     }
 }
Exemplo n.º 9
0
 /**
  * Test for quote()
  * @dataProvider data_quote
  */
 function test_quote($str, $expected)
 {
     $this->assertEquals($expected, html::quote($str));
 }