Set account object based on acc_id. Additionally, disable acc_id selectbox if not is_admin_vac

This commit is contained in:
Hadi Nategh 2014-05-21 17:44:10 +00:00
parent 5825c8df18
commit f820209a6a
3 changed files with 28 additions and 23 deletions

View File

@ -55,16 +55,13 @@ class mail_sieve
function __construct() function __construct()
{ {
$this->displayCharset = translation::charset(); $this->displayCharset = translation::charset();
$profileID = (int)$_GET['acc_id'];
$this->mail_admin = isset($GLOBALS['egw_info']['user']['apps']['emailadmin']); $this->mail_admin = isset($GLOBALS['egw_info']['user']['apps']['emailadmin']);
if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) $acc_id = isset($_GET['acc_id']) ? (int)$_GET['acc_id'] : egw_cache::getSession(__CLASS__, 'acc_id');
if ($acc_id > 0)
{ {
$profileID = (int) $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; $this->account = emailadmin_account::read($acc_id);
} }
$this->account = emailadmin_account::read($profileID);
$this->mailConfig = config::read('mail');
$this->restoreSessionData(); $this->restoreSessionData();
} }
@ -77,6 +74,10 @@ class mail_sieve
*/ */
function index(array $content=null,$msg=null) function index(array $content=null,$msg=null)
{ {
if (!is_array($content))
{
egw_cache::setSession(__CLASS__, 'acc_id', $this->account->acc_id);
}
//Instantiate an etemplate_new object //Instantiate an etemplate_new object
$tmpl = new etemplate_new('mail.sieve.index'); $tmpl = new etemplate_new('mail.sieve.index');
@ -483,9 +484,12 @@ class mail_sieve
} }
elseif(!is_array($content) && isset($_GET['acc_id'])) elseif(!is_array($content) && isset($_GET['acc_id']))
{ {
$this->account = emailadmin_account::read($_GET['acc_id']);
$preserv['acc_id'] = $this->account->acc_id; $preserv['acc_id'] = $this->account->acc_id;
} }
elseif ($content['acc_id'])
{
$this->account = emailadmin_account::read($content['acc_id']);
}
$icServer = $this->account->imapServer($this->is_admin_vac ? $account_id : false); $icServer = $this->account->imapServer($this->is_admin_vac ? $account_id : false);
@ -518,6 +522,7 @@ class mail_sieve
{ {
$content['days'] = '3'; $content['days'] = '3';
} }
$preserv['is_admin_vac'] = $content['is_admin_vac'] = $this->is_admin_vac;
} }
else else
{ {

View File

@ -2801,19 +2801,19 @@ app.classes.mail = AppJS.extend(
/** /**
* Open seive filter list * Open seive filter list
* *
* @param {egwAction} action - Action user did to get here * @param {action} _action
* @param {egwActionObject[]} selected - selected row(s) * @param {sender} _senders
* *
* @todo get the account id and open the relevant sieve, ATM alway open sieve rules which is set in preferences
*/ */
edit_sieve: function(action, selected) edit_sieve: function(_action, _senders)
{ {
var acc_id = parseInt(_senders[0].id);
this.egw.open_link(this.egw.link('/index.php', this.egw.open_link(this.egw.link('/index.php',
{ {
'menuaction': 'mail.mail_sieve.index', 'menuaction': 'mail.mail_sieve.index',
'acc_id': acc_id,
'ajax': 'true' 'ajax': 'true'
} }));
));
}, },
/** /**

View File

@ -12,9 +12,9 @@
<rows> <rows>
<row valign="top" class="dialogHeader"> <row valign="top" class="dialogHeader">
<description value="Edit vacation settings" class="et2_fullWidth"/> <description value="Edit vacation settings" class="et2_fullWidth"/>
<description align="right" disabled="!@acc_id" for="acc_id" value="Mail account"/> <description align="right" disabled="!@is_admin_vac" for="acc_id" value="Mail account"/>
<menulist> <menulist>
<menupopup id="acc_id" disabled="!@acc_id" onchange="app.mail.vacation_change_account" class="et2_fullWidth"/> <menupopup id="acc_id" disabled="!@is_admin_vac" onchange="app.mail.vacation_change_account" class="et2_fullWidth"/>
</menulist> </menulist>
<description/> <description/>
</row> </row>