summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/html.php4
-rw-r--r--program/include/rcube_image.php23
-rw-r--r--program/include/rcube_imap.php2
-rw-r--r--program/include/rcube_imap_generic.php3
-rw-r--r--program/include/rcube_ldap.php30
-rw-r--r--program/include/rcube_message.php9
-rw-r--r--program/include/rcube_output_html.php10
-rw-r--r--program/include/rcube_user.php25
8 files changed, 82 insertions, 24 deletions
diff --git a/program/include/html.php b/program/include/html.php
index 880873ddc..0f93e969d 100644
--- a/program/include/html.php
+++ b/program/include/html.php
@@ -252,9 +252,9 @@ class html
* @return string HTML code
* @see html::tag()
*/
- public static function br()
+ public static function br($attrib = array())
{
- return self::tag('br');
+ return self::tag('br', $attrib);
}
/**
diff --git a/program/include/rcube_image.php b/program/include/rcube_image.php
index 80e8bd4f3..c0d4e878d 100644
--- a/program/include/rcube_image.php
+++ b/program/include/rcube_image.php
@@ -78,10 +78,11 @@ class rcube_image
*
* @param int $size Max width/height size
* @param string $filename Output filename
+ * @param boolean $browser_compat Convert to image type displayable by any browser
*
- * @return bool True on success, False on failure
+ * @return mixed Output type on success, False on failure
*/
- public function resize($size, $filename = null)
+ public function resize($size, $filename = null, $browser_compat = false)
{
$result = false;
$rcube = rcube::get_instance();
@@ -104,15 +105,22 @@ class rcube_image
}
$type = strtr($type, array("jpeg" => "jpg", "tiff" => "tif", "ps" => "eps", "ept" => "eps"));
+ $p['intype'] = $type;
+
+ // convert to an image format every browser can display
+ if ($browser_compat && !in_array($type, array('jpg','gif','png'))) {
+ $type = 'jpg';
+ }
+
$p += array('type' => $type, 'types' => "bmp,eps,gif,jp2,jpg,png,svg,tif", 'quality' => 75);
- $p['-opts'] = array('-resize' => $size.'>');
+ $p['-opts'] = array('-resize' => $p['size'].'>');
if (in_array($type, explode(',', $p['types']))) { // Valid type?
- $result = rcube::exec($convert . ' 2>&1 -flatten -auto-orient -colorspace RGB -quality {quality} {-opts} {in} {type}:{out}', $p);
+ $result = rcube::exec($convert . ' 2>&1 -flatten -auto-orient -colorspace RGB -quality {quality} {-opts} {intype}:{in} {type}:{out}', $p);
}
if ($result === '') {
- return true;
+ return $type;
}
}
@@ -148,16 +156,19 @@ class rcube_image
if ($props['gd_type'] == IMAGETYPE_JPEG) {
$result = imagejpeg($image, $filename, 75);
+ $type = 'jpg';
}
elseif($props['gd_type'] == IMAGETYPE_GIF) {
$result = imagegif($image, $filename);
+ $type = 'gid';
}
elseif($props['gd_type'] == IMAGETYPE_PNG) {
$result = imagepng($image, $filename, 6, PNG_ALL_FILTERS);
+ $type = 'png';
}
if ($result) {
- return true;
+ return $type;
}
}
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index a89fd164d..f2645f60f 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -2074,7 +2074,7 @@ class rcube_imap extends rcube_storage
if ($o_part && $o_part->size) {
$body = $this->conn->handlePartBody($this->folder, $uid, true,
- $part ? $part : 'TEXT', $o_part->encoding, $print, $fp);
+ $part ? $part : 'TEXT', $o_part->encoding, $print, $fp, $o_part->ctype_primary == 'text');
}
if ($fp || $print) {
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index 651de9d97..bc7ecfc37 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -2379,7 +2379,7 @@ class rcube_imap_generic
return $this->handlePartBody($mailbox, $id, $is_uid, $part);
}
- function handlePartBody($mailbox, $id, $is_uid=false, $part='', $encoding=NULL, $print=NULL, $file=NULL, $formatted=true)
+ function handlePartBody($mailbox, $id, $is_uid=false, $part='', $encoding=NULL, $print=NULL, $file=NULL, $formatted=false)
{
if (!$this->select($mailbox)) {
return false;
@@ -2417,6 +2417,7 @@ class rcube_imap_generic
}
if ($binary) {
+ // WARNING: Use $formatting argument with care, this may break binary data stream
$mode = -1;
}
diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php
index 61a073fa3..7cef25556 100644
--- a/program/include/rcube_ldap.php
+++ b/program/include/rcube_ldap.php
@@ -160,7 +160,8 @@ class rcube_ldap extends rcube_addressbook
}
// make sure LDAP_rdn field is required
- if (!empty($this->prop['LDAP_rdn']) && !in_array($this->prop['LDAP_rdn'], $this->prop['required_fields'])) {
+ if (!empty($this->prop['LDAP_rdn']) && !in_array($this->prop['LDAP_rdn'], $this->prop['required_fields'])
+ && !in_array($this->prop['LDAP_rdn'], array_keys((array)$this->prop['autovalues']))) {
$this->prop['required_fields'][] = $this->prop['LDAP_rdn'];
}
@@ -1086,6 +1087,9 @@ class rcube_ldap extends rcube_addressbook
$newentry = $this->_map_data($save_cols);
$newentry['objectClass'] = $this->prop['LDAP_Object_Classes'];
+ // add automatically generated attributes
+ $this->add_autovalues($newentry);
+
// Verify that the required fields are set.
$missing = null;
foreach ($this->prop['required_fields'] as $fld) {
@@ -1389,6 +1393,30 @@ class rcube_ldap extends rcube_addressbook
}
}
+ /**
+ * Generate missing attributes as configured
+ *
+ * @param array LDAP record attributes
+ */
+ protected function add_autovalues(&$attrs)
+ {
+ $attrvals = array();
+ foreach ($attrs as $k => $v) {
+ $attrvals['{'.$k.'}'] = is_array($v) ? $v[0] : $v;
+ }
+
+ foreach ((array)$this->prop['autovalues'] as $lf => $templ) {
+ if (empty($attrs[$lf])) {
+ // replace {attr} placeholders with concrete attribute values
+ $templ = preg_replace('/\{\w+\}/', '', strtr($templ, $attrvals));
+
+ if (strpos($templ, '(') !== false)
+ $attrs[$lf] = eval("return ($templ);");
+ else
+ $attrs[$lf] = $templ;
+ }
+ }
+ }
/**
* Execute the LDAP search based on the stored credentials
diff --git a/program/include/rcube_message.php b/program/include/rcube_message.php
index 47aa4493e..74bf4574f 100644
--- a/program/include/rcube_message.php
+++ b/program/include/rcube_message.php
@@ -198,14 +198,15 @@ class rcube_message
* Determine if the message contains a HTML part
*
* @param bool $recursive Enables checking in all levels of the structure
+ * @param bool $enriched Enables checking for text/enriched parts too
*
* @return bool True if a HTML is available, False if not
*/
- function has_html_part($recursive = true)
+ function has_html_part($recursive = true, $enriched = false)
{
// check all message parts
foreach ($this->parts as $part) {
- if ($part->mimetype == 'text/html') {
+ if ($part->mimetype == 'text/html' || ($enriched && $part->mimetype == 'text/enriched')) {
// Level check, we'll skip e.g. HTML attachments
if (!$recursive) {
$level = explode('.', $part->mime_id);
@@ -270,10 +271,6 @@ class rcube_message
else if ($part->mimetype == 'text/html') {
$out = $this->get_part_content($mime_id);
- // remove special chars encoding
- $trans = array_flip(get_html_translation_table(HTML_ENTITIES));
- $out = strtr($out, $trans);
-
// create instance of html2text class
$txt = new html2text($out);
return $txt->get_text();
diff --git a/program/include/rcube_output_html.php b/program/include/rcube_output_html.php
index d80d28a9b..ac07d58e9 100644
--- a/program/include/rcube_output_html.php
+++ b/program/include/rcube_output_html.php
@@ -457,7 +457,7 @@ class rcube_output_html extends rcube_output
if (is_readable($path)) {
$this->config->set('skin_path', $skin_path);
- $this->base_path = $skin_path;
+ $this->base_path = preg_replace('!plugins/\w+/!', '', $skin_path); // set base_path to core skin directory (not plugin's skin)
break;
}
else {
@@ -494,8 +494,6 @@ class rcube_output_html extends rcube_output
$output = $hook['content'];
unset($hook['content']);
- $output = $this->parse_with_globals($this->fix_paths($output));
-
// make sure all <form> tags have a valid request token
$output = preg_replace_callback('/<form\s+([^>]+)>/Ui', array($this, 'alter_form_tag'), $output);
$this->footer = preg_replace_callback('/<form\s+([^>]+)>/Ui', array($this, 'alter_form_tag'), $this->footer);
@@ -856,7 +854,7 @@ class rcube_output_html extends rcube_output
case 'include':
$old_base_path = $this->base_path;
if ($path = $this->get_skin_file($attrib['file'], $skin_path, $attrib['skinpath'])) {
- $this->base_path = $skin_path;
+ $this->base_path = preg_replace('!plugins/\w+/!', '', $skin_path); // set base_path to core skin directory (not plugin's skin)
$path = realpath($path);
}
@@ -1089,7 +1087,7 @@ class rcube_output_html extends rcube_output
// make valid href to specific buttons
if (in_array($attrib['command'], rcmail::$main_tasks)) {
$attrib['href'] = $this->app->url(array('task' => $attrib['command']));
- $attrib['onclick'] = sprintf("%s.command('switch-task','%s',null,event); return false", rcmail::JS_OBJECT_NAME, $attrib['command']);
+ $attrib['onclick'] = sprintf("return %s.command('switch-task','%s',this,event)", rcmail::JS_OBJECT_NAME, $attrib['command']);
}
else if ($attrib['task'] && in_array($attrib['task'], rcmail::$main_tasks)) {
$attrib['href'] = $this->app->url(array('action' => $attrib['command'], 'task' => $attrib['task']));
@@ -1357,6 +1355,8 @@ class rcube_output_html extends rcube_output
$output = substr_replace($output, $css, $pos, 0);
}
+ $output = $this->parse_with_globals($this->fix_paths($output));
+
// trigger hook with final HTML content to be sent
$hook = $this->app->plugins->exec_hook("send_page", array('content' => $output));
if (!$hook['abort']) {
diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php
index b92187ad4..72b03cd15 100644
--- a/program/include/rcube_user.php
+++ b/program/include/rcube_user.php
@@ -47,6 +47,13 @@ class rcube_user
*/
private $rc;
+ /**
+ * Internal identities cache
+ *
+ * @var array
+ */
+ private $identities = array();
+
const SEARCH_ADDRESSBOOK = 1;
const SEARCH_MAIL = 2;
@@ -213,8 +220,14 @@ class rcube_user
*/
function get_identity($id = null)
{
- $result = $this->list_identities($id ? sprintf('AND identity_id = %d', $id) : '');
- return $result[0];
+ $id = (int)$id;
+ // cache identities for better performance
+ if (!array_key_exists($id, $this->identities)) {
+ $result = $this->list_identities($id ? 'AND identity_id = ' . $id : '');
+ $this->identities[$id] = $result[0];
+ }
+
+ return $this->identities[$id];
}
@@ -273,6 +286,8 @@ class rcube_user
call_user_func_array(array($this->db, 'query'),
array_merge(array($sql), $query_params));
+ $this->identities = array();
+
return $this->db->affected_rows();
}
@@ -305,6 +320,8 @@ class rcube_user
call_user_func_array(array($this->db, 'query'),
array_merge(array($sql), $insert_values));
+ $this->identities = array();
+
return $this->db->insert_id('identities');
}
@@ -339,6 +356,8 @@ class rcube_user
$this->ID,
$iid);
+ $this->identities = array();
+
return $this->db->affected_rows();
}
@@ -359,6 +378,8 @@ class rcube_user
" AND del <> 1",
$this->ID,
$iid);
+
+ unset($this->identities[0]);
}
}