fix mail account dialog for non user-editable accounts was always readonly and SQL error on storing it, caused by moving tables from (no longer existing) emailadmin to api

This commit is contained in:
Ralf Becker 2016-04-06 08:48:52 +00:00
parent 5804b65787
commit 368a99167e
4 changed files with 26 additions and 8 deletions

View File

@ -96,7 +96,10 @@ use addressbook_merge; // should go to Contacts\Merge
*/ */
class Account implements \ArrayAccess class Account implements \ArrayAccess
{ {
const APP = 'emailadmin'; /**
* App tables belong to
*/
const APP = 'api';
/** /**
* Table with mail-accounts * Table with mail-accounts
*/ */
@ -903,8 +906,8 @@ class Account implements \ArrayAccess
} }
$access = false; $access = false;
// emailadmin has all rights // Admin app has all rights
if (isset($GLOBALS['egw_info']['user']['apps']['emailadmin'])) if (isset($GLOBALS['egw_info']['user']['apps']['admin']))
{ {
$access = true; $access = true;
$reason = 'user is EMailAdmin'; $reason = 'user is EMailAdmin';
@ -1150,7 +1153,7 @@ class Account implements \ArrayAccess
if (!($data['acc_id'] > 0)) if (!($data['acc_id'] > 0))
{ {
// set not set values which, are NOT NULL and therefore would give an SQL error // set not set values which, are NOT NULL and therefore would give an SQL error
$td = self::$db->get_table_definitions('emailadmin', self::TABLE); $td = self::$db->get_table_definitions('api', self::TABLE);
foreach($td['fd'] as $col => $def) foreach($td['fd'] as $col => $def)
{ {
if (!isset($data[$col]) && $def['nullable'] === false && !isset($def['default'])) if (!isset($data[$col]) && $def['nullable'] === false && !isset($def['default']))

View File

@ -25,8 +25,17 @@ use EGroupware\Api;
*/ */
class Credentials class Credentials
{ {
const APP = 'emailadmin'; /**
* App tables belong to
*/
const APP = 'api';
/**
* Name of credentials table
*/
const TABLE = 'egw_ea_credentials'; const TABLE = 'egw_ea_credentials';
/**
* Join to check account is user-editable
*/
const USER_EDITABLE_JOIN = 'JOIN egw_ea_accounts ON egw_ea_accounts.acc_id=egw_ea_credentials.acc_id AND acc_user_editable='; const USER_EDITABLE_JOIN = 'JOIN egw_ea_accounts ON egw_ea_accounts.acc_id=egw_ea_credentials.acc_id AND acc_user_editable=';
/** /**
@ -378,7 +387,7 @@ class Credentials
$old_mcrypt = null; $old_mcrypt = null;
foreach(self::$db->select(self::TABLE, self::TABLE.'.*', array( foreach(self::$db->select(self::TABLE, self::TABLE.'.*', array(
'account_id' => $data['account_id'] 'account_id' => $data['account_id']
),__LINE__, __FILE__, false, '', 'emailadmin', 0, self::USER_EDITABLE_JOIN.self::$db->quote(true, 'bool')) as $row) ),__LINE__, __FILE__, false, '', self::APP, 0, self::USER_EDITABLE_JOIN.self::$db->quote(true, 'bool')) as $row)
{ {
if (!isset($old_mcrypt)) if (!isset($old_mcrypt))
{ {

View File

@ -21,7 +21,13 @@ use EGroupware\Api;
*/ */
class Notifications class Notifications
{ {
const APP = 'emailadmin'; /**
* App tables belong to
*/
const APP = 'api';
/**
* Name of credentials table
*/
const TABLE = 'egw_ea_notifications'; const TABLE = 'egw_ea_notifications';
/** /**

View File

@ -45,7 +45,7 @@ class Sql extends Mail\Smtp
/** /**
* Name of app our table belongs to * Name of app our table belongs to
*/ */
const APP = 'emailadmin'; const APP = 'api';
/** /**
* Values for mail_type column * Values for mail_type column
* *