From 906889e6d9e233160b6f4276fb39fb61b9acf3d3 Mon Sep 17 00:00:00 2001 From: Lars Kneschke Date: Wed, 16 May 2007 08:54:12 +0000 Subject: [PATCH] merge from trunk(revision 23866:23873) to 1.4 branch --- addressbook/inc/class.socontacts_sql.inc.php | 22 ++++++++++++++++++++ addressbook/inc/class.uicontacts.inc.php | 11 ++++++++++ calendar/inc/class.uiforms.inc.php | 2 +- etemplate/inc/class.uietemplate.inc.php | 20 +++++++++++------- felamimail/inc/class.uicompose.inc.php | 11 ++++++++-- phpgwapi/inc/class.egw_db.inc.php | 14 +++++++------ setup/index.php | 2 +- 7 files changed, 64 insertions(+), 18 deletions(-) diff --git a/addressbook/inc/class.socontacts_sql.inc.php b/addressbook/inc/class.socontacts_sql.inc.php index cda7f2d30c..bd44cf8c20 100644 --- a/addressbook/inc/class.socontacts_sql.inc.php +++ b/addressbook/inc/class.socontacts_sql.inc.php @@ -276,6 +276,11 @@ class socontacts_sql extends so_sql $criteria[] = $this->db->expression($this->extra_table,'(',array('contact_name'=>substr($col,1),'contact_value'=>$val),')'); $search_customfields = true; } + elseif($col == 'cat_id') // search in comma-sep. cat-column + { + $criteria = array_merge($criteria,$this->_cat_search($val)); + unset($criteria[$col]); + } } } if ($search_customfields) // search the custom-fields @@ -345,6 +350,23 @@ class socontacts_sql extends so_sql return '('.implode(' OR ',$cat_filter).')'; } + /** + * fix cat_id criteria to search in comma-separated multiple cats + * + * @internal + * @param int/array $cats + * @return array of sql-strings to be OR'ed or AND'ed together + */ + function _cat_search($cats) + { + $cat_filter = array(); + foreach(is_array($cats) ? $cats : array($cats) as $cat) + { + if (is_numeric($cat)) $cat_filter[] = $this->db->concat("','",cat_id,"','")." LIKE '%,$cat,%'"; + } + return $cat_filter; + } + /** * Change the ownership of contacts owned by a given account * diff --git a/addressbook/inc/class.uicontacts.inc.php b/addressbook/inc/class.uicontacts.inc.php index 79eec797ad..d1d5e07b59 100644 --- a/addressbook/inc/class.uicontacts.inc.php +++ b/addressbook/inc/class.uicontacts.inc.php @@ -1527,6 +1527,17 @@ $readonlys['button[vcard]'] = true; '%' => lang('contains'), false => lang('exact'), ); + if ($this->customfields) + { + foreach($this->customfields as $name => $data) + { + if ($data['type'] == 'select') + { + if (!isset($content['#'.$name])) $content['#'.$name] = ''; + if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one'); + } + } + } // configure edit template as search dialog $readonlys['change_photo'] = true; $readonlys['fileas_type'] = true; diff --git a/calendar/inc/class.uiforms.inc.php b/calendar/inc/class.uiforms.inc.php index d437fe73ae..72742c97bd 100644 --- a/calendar/inc/class.uiforms.inc.php +++ b/calendar/inc/class.uiforms.inc.php @@ -567,7 +567,7 @@ class uiforms extends uical } $vars = array( 'menuaction' => 'felamimail.uicompose.compose', - 'preset[to]' => implode(', ',$to), + 'preset[to]' => $to, 'preset[subject]' => $subject, 'preset[body]' => $body, 'preset[name]' => 'event.ics', diff --git a/etemplate/inc/class.uietemplate.inc.php b/etemplate/inc/class.uietemplate.inc.php index d04b49b5c3..198b8fee73 100644 --- a/etemplate/inc/class.uietemplate.inc.php +++ b/etemplate/inc/class.uietemplate.inc.php @@ -1655,26 +1655,30 @@ $url = $GLOBALS['egw']->link($matches[1],$matches[2]); $on = str_replace($matches[0],'\''.$url.'\'',$on); } - if (preg_match_all("/form::name\\('([^']+)'\\)/",$on,$matches)) - { - foreach($matches[1] as $n => $matche_name) - { + + if (preg_match_all("/form::name\\('([^']+)'\\)/",$on,$matches)) { + foreach($matches[1] as $n => $matche_name) { $matches[1][$n] = '\''.$this->form_name($cname,$matche_name).'\''; } $on = str_replace($matches[0],$matches[1],$on); } - if (preg_match('/confirm\(["\']{1}(.*)["\']{1}\)/',$on,$matches)) - { + + if (preg_match('/confirm\(["\']{1}(.*)["\']{1}\)/',$on,$matches)) { $question = lang($matches[1]).(substr($matches[1],-1) != '?' ? '?' : ''); // add ? if not there, saves extra phrase $on = str_replace($matches[0],'confirm(\''.addslashes($question).'\')',$on); //$on = preg_replace('/confirm\(["\']{1}(.*)["\']{1}\)/','confirm(\''.addslashes($question).'\')',$on); } + + if (preg_match("/window.open\('(.*)','(.*)','dependent=yes,width=(.*),height=(.*),scrollbars=yes,status=(.*)'\)/",$on,$matches)) { + $on = str_replace($matches[0], "egw_openWindowCentered2('{$matches[1]}', '{$matches[2]}', '{$matches[3]}', '{$matches[4]}', '{$matches[5]}')", $on); + } + // replace xajax calls to code in widgets, with the "etemplate" handler, // this allows to call widgets with the current app, otherwise everyone would need etemplate run rights - if (strpos($on,"xajax_doXMLHTTP('etemplate.")!==false) - { + if (strpos($on,"xajax_doXMLHTTP('etemplate.")!==false) { $on = preg_replace("/^xajax_doXMLHTTP\('etemplate\.([a-z]+_widget\.[a-zA-Z0-9_]+)\'/",'xajax_doXMLHTTP(\''.$GLOBALS['egw_info']['flags']['currentapp'].'.\\1.etemplate\'',$on); } + return $on; } diff --git a/felamimail/inc/class.uicompose.inc.php b/felamimail/inc/class.uicompose.inc.php index af866a3252..3222cf0662 100644 --- a/felamimail/inc/class.uicompose.inc.php +++ b/felamimail/inc/class.uicompose.inc.php @@ -118,8 +118,15 @@ $sessionData = $this->bocompose->getSessionData(); if (is_array($_GET['preset'])) { - $this->bocompose->addAttachment(array_merge($sessionData,$_GET['preset'])); - $sessionData = $this->bocompose->getSessionData(); + if ($_GET['preset']['file'] && is_readable($_GET['preset']['file'])) + { + $this->bocompose->addAttachment(array_merge($sessionData,$_GET['preset'])); + $sessionData = $this->bocompose->getSessionData(); + } + foreach(array('to','cc','bcc','subject','body') as $name) + { + if ($_GET['preset'][$name]) $sessionData[$name] = $_GET['preset'][$name]; + } } $preferences = ExecMethod('felamimail.bopreferences.getPreferences'); #_debug_array($preferences); diff --git a/phpgwapi/inc/class.egw_db.inc.php b/phpgwapi/inc/class.egw_db.inc.php index c55ac474cb..1fa2c596f9 100644 --- a/phpgwapi/inc/class.egw_db.inc.php +++ b/phpgwapi/inc/class.egw_db.inc.php @@ -980,20 +980,23 @@ $currentPassword = $this->Password; $currentDatabase = $this->Database; - $extra = array(); + $sqls = array(); $set_charset = ''; switch ($this->Type) { case 'pgsql': $meta_db = 'template1'; + $sqls[] = "CREATE DATABASE $currentDatabase"; break; case 'mysql': + $create = "CREATE DATABASE `$currentDatabase`"; if ($charset && isset($this->Link_ID->charset2mysql[$charset]) && (float) $this->ServerInfo['version'] >= 4.1) { - $set_charset = ' DEFAULT CHARACTER SET '.$this->Link_ID->charset2mysql[$charset].';'; + $create .= ' DEFAULT CHARACTER SET '.$this->Link_ID->charset2mysql[$charset].';'; } + $sqls[] = $create; + $sqls[] = "GRANT ALL ON `$currentDatabase`.* TO $currentUser@localhost IDENTIFIED BY ".$this->quote($currentPassword); $meta_db = 'mysql'; - $extra[] = "GRANT ALL ON $currentDatabase.* TO $currentUser@localhost IDENTIFIED BY '$currentPassword'"; break; default: echo "

db::create_database(user='$adminname',\$pw) not yet implemented for DB-type '$this->Type'

\n"; @@ -1006,10 +1009,9 @@ $this->Database = $meta_db; } $this->disconnect(); - $this->query('CREATE DATABASE '.$currentDatabase.$set_charset); - foreach($extra as $sql) + foreach($sqls as $sql) { - $this->query($sql); + $this->query($sql,__LINE__,__FILE__); } $this->disconnect(); diff --git a/setup/index.php b/setup/index.php index b71e3b6fa9..745bebe751 100644 --- a/setup/index.php +++ b/setup/index.php @@ -298,7 +298,7 @@ switch ($GLOBALS['egw_info']['setup']['currentver']['phpgwapi']) { case 'dbcreate': - $GLOBALS['egw_setup']->db->create_database($_POST['db_root'], $_POST['db_pass'], $_POST['system_charset']); + $GLOBALS['egw_setup']->db->create_database($_POST['db_root'], $_POST['db_pass'],'utf8'); // create all new db's with utf8 break; case 'drop': $setup_info = $GLOBALS['egw_setup']->detection->get_versions($setup_info);