Urlencode mail recipients for storing in session + little code cleanup
| | |
| | | function rcmail_url($action, $p=array(), $task=null) |
| | | { |
| | | $app = rcmail::get_instance(); |
| | | |
| | | $qstring = ''; |
| | | $base = $app->comm_path; |
| | | |
| | | if ($task && in_array($task, rcmail::$main_tasks)) |
| | | $base = ereg_replace('_task=[a-z]+', '_task='.$task, $app->comm_path); |
| | | |
| | | if (is_array($p)) |
| | | foreach ($p as $key => $val) |
| | | $qstring .= '&'.urlencode($key).'='.urlencode($val); |
| | | |
| | | return $base . ($action ? '&_action='.$action : '') . $qstring; |
| | | return $app->url((array)$p + array('_action' => $action, 'task' => $task)); |
| | | } |
| | | |
| | | |
| | |
| | | public function url($p) |
| | | { |
| | | if (!is_array($p)) |
| | | $p = array('action' => @func_get_arg(0)); |
| | | |
| | | $url = $p['task'] ? './?_task=' . $p['task'] : $this->comm_path; |
| | | unset($p['task']); |
| | | $p = array('_action' => @func_get_arg(0)); |
| | | |
| | | if ($p['task'] && in_array($p['task'], rcmail::$main_tasks)) |
| | | $url = './?_task='.$p['task']; |
| | | else |
| | | $url = $this->comm_path; |
| | | |
| | | unset($p['task']); |
| | | foreach ($p as $par => $val) |
| | | $url .= sprintf('&%s=%s', urlencode($par), urlencode($val)); |
| | | $url .= '&'.urlencode($par).'='.urlencode($val); |
| | | |
| | | return $url; |
| | | } |
| | |
| | | * @param mixed Either a string with the action or url parameters as key-value pairs |
| | | * @see rcmail::url() |
| | | */ |
| | | public function redirect($p = array(), $delay = 0) |
| | | public function redirect($p = array(), $delay = 1) |
| | | { |
| | | $location = rcmail::get_instance()->url($p); |
| | | $this->remote_response("window.setTimeout(\"location.href='{$location}'\", $delay);"); |
| | |
| | | { |
| | | $mailto_str = join(', ', $mailto); |
| | | $mailto_id = substr(md5($mailto_str), 0, 16); |
| | | $_SESSION['mailto'][$mailto_id] = $mailto_str; |
| | | $OUTPUT->command('redirect', rcmail_url('compose', array('_mailto' => $mailto_id), 'mail')); |
| | | $_SESSION['mailto'][$mailto_id] = urlencode($mailto_str); |
| | | $OUTPUT->redirect(array('task' => 'mail', '_action' => 'compose', '_mailto' => $mailto_id)); |
| | | } |
| | | else |
| | | $OUTPUT->show_message('nocontactsfound', 'warning'); |
| | |
| | | |
| | | // we have a set of recipients stored is session |
| | | if (($mailto_id = $_SESSION['compose']['param']['_mailto']) && $_SESSION['mailto'][$mailto_id]) |
| | | $fvalue = $_SESSION['mailto'][$mailto_id]; |
| | | $fvalue = urldecode($_SESSION['mailto'][$mailto_id]); |
| | | else if (!empty($_SESSION['compose']['param']['_to'])) |
| | | $fvalue = $_SESSION['compose']['param']['_to']; |
| | | |