2011-07-01 12:37:47 +02:00
< ? php
/*************************************************************************** \
* eGroupWare - FeLaMiMail *
* http :// www . linux - at - work . de *
* http :// www . phpgw . de *
* http :// www . egroupware . org *
* Written by : Lars Kneschke [ lkneschke @ linux - at - work . de ] *
* ------------------------------------------------- *
* This program is free software ; you can redistribute it and / or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation ; either version 2 of the License , or ( at your *
* option ) any later version . *
\ ***************************************************************************/
/* $Id$ */
require_once ( EGW_INCLUDE_ROOT . '/felamimail/inc/class.sopreferences.inc.php' );
class bopreferences extends sopreferences
{
var $public_functions = array
(
'getPreferences' => True ,
);
// stores the users profile
var $profileData ;
var $sessionData ;
var $boemailadmin ;
function bopreferences ( $_restoreSession = true )
{
//error_log(__METHOD__." called ".print_r($_restoreSession,true).function_backtrace());
parent :: sopreferences ();
$this -> boemailadmin = new emailadmin_bo ( false , $_restoreSession ); // does read all profiles, no profile?
if ( $_restoreSession && ! ( is_array ( $this -> sessionData ) && ( count ( $this -> sessionData ) > 0 )) ) $this -> restoreSessionData ();
2012-10-04 15:50:26 +02:00
if ( $_restoreSession === false && ( is_array ( $this -> sessionData ) && ( count ( $this -> sessionData ) > 0 )) )
2011-07-01 12:37:47 +02:00
{
//error_log(__METHOD__." Unset Session ".function_backtrace());
//make sure session data will be reset
$this -> sessionData = array ();
$this -> profileData = array ();
self :: saveSessionData ();
}
//error_log(__METHOD__.print_r($this->sessionData,true));
2012-10-04 15:50:26 +02:00
if ( isset ( $this -> sessionData [ 'profileData' ]) && ( $this -> sessionData [ 'profileData' ] instanceof ea_preferences ))
2011-07-01 12:37:47 +02:00
{
//error_log(__METHOD__." Restore Session ".function_backtrace());
$this -> profileData = $this -> sessionData [ 'profileData' ];
}
}
function restoreSessionData ()
{
//error_log(__METHOD__." Session restore ".function_backtrace());
// set an own autoload function, search emailadmin for missing classes
$GLOBALS [ 'egw_info' ][ 'flags' ][ 'autoload' ] = array ( __CLASS__ , 'autoload' );
$this -> sessionData = ( array ) unserialize ( $GLOBALS [ 'egw' ] -> session -> appsession ( 'fm_preferences' , 'felamimail' ));
}
/**
* Autoload classes from emailadmin , ' til they get autoloading conform names
*
* @ param string $class
*/
static function autoload ( $class )
{
2011-11-03 16:25:41 +01:00
if ( strlen ( $class ) < 100 )
2011-07-01 12:37:47 +02:00
{
2011-11-03 16:25:41 +01:00
if ( file_exists ( $file = EGW_INCLUDE_ROOT . '/emailadmin/inc/class.' . $class . '.inc.php' ))
{
include_once ( $file );
//error_log(__METHOD__."($class) included $file");
}
elseif ( file_exists ( $file = EGW_INCLUDE_ROOT . '/felamimail/inc/class.' . $class . '.inc.php' ))
{
include_once ( $file );
}
else
{
#error_log(__METHOD__."($class) failed!");
}
2011-07-01 12:37:47 +02:00
}
}
function saveSessionData ()
{
$GLOBALS [ 'egw' ] -> session -> appsession ( 'fm_preferences' , 'felamimail' , serialize ( $this -> sessionData ));
}
// get the first active user defined account
function getAccountData ( & $_profileData , $_accountID = NULL )
{
#echo "<p>backtrace: ".function_backtrace()."</p>\n";
2011-09-12 16:06:30 +02:00
if ( ! ( $_profileData instanceof ea_preferences ))
2011-07-01 12:37:47 +02:00
die ( __FILE__ . ': ' . __LINE__ );
$accountData = parent :: getAccountData ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_id' ], $_accountID );
// currently we use only the first profile available
$accountData = array_shift ( $accountData );
2011-10-06 17:16:58 +02:00
//_debug_array($accountData);
2011-07-01 12:37:47 +02:00
$icServer = CreateObject ( 'emailadmin.defaultimap' );
$icServer -> ImapServerId = $accountData [ 'id' ];
$icServer -> encryption = isset ( $accountData [ 'ic_encryption' ]) ? $accountData [ 'ic_encryption' ] : 1 ;
$icServer -> host = $accountData [ 'ic_hostname' ];
$icServer -> port = isset ( $accountData [ 'ic_port' ]) ? $accountData [ 'ic_port' ] : 143 ;
$icServer -> validatecert = isset ( $accountData [ 'ic_validatecertificate' ]) ? ( bool ) $accountData [ 'ic_validatecertificate' ] : 1 ;
$icServer -> username = $accountData [ 'ic_username' ];
$icServer -> loginName = $accountData [ 'ic_username' ];
$icServer -> password = $accountData [ 'ic_password' ];
$icServer -> enableSieve = isset ( $accountData [ 'ic_enable_sieve' ]) ? ( bool ) $accountData [ 'ic_enable_sieve' ] : 1 ;
$icServer -> sieveHost = $accountData [ 'ic_sieve_server' ];
$icServer -> sievePort = isset ( $accountData [ 'ic_sieve_port' ]) ? $accountData [ 'ic_sieve_port' ] : 2000 ;
if ( $accountData [ 'ic_folderstoshowinhome' ]) $icServer -> folderstoshowinhome = $accountData [ 'ic_folderstoshowinhome' ];
if ( $accountData [ 'ic_trashfolder' ]) $icServer -> trashfolder = $accountData [ 'ic_trashfolder' ];
if ( $accountData [ 'ic_sentfolder' ]) $icServer -> sentfolder = $accountData [ 'ic_sentfolder' ];
if ( $accountData [ 'ic_draftfolder' ]) $icServer -> draftfolder = $accountData [ 'ic_draftfolder' ];
if ( $accountData [ 'ic_templatefolder' ]) $icServer -> templatefolder = $accountData [ 'ic_templatefolder' ];
2012-11-22 13:26:04 +01:00
$ogServer = new emailadmin_smtp ();
2011-07-01 12:37:47 +02:00
$ogServer -> SmtpServerId = $accountData [ 'id' ];
$ogServer -> host = $accountData [ 'og_hostname' ];
$ogServer -> port = isset ( $accountData [ 'og_port' ]) ? $accountData [ 'og_port' ] : 25 ;
$ogServer -> smtpAuth = ( bool ) $accountData [ 'og_smtpauth' ];
if ( $ogServer -> smtpAuth ) {
$ogServer -> username = $accountData [ 'og_username' ];
$ogServer -> password = $accountData [ 'og_password' ];
}
$identity = CreateObject ( 'emailadmin.ea_identity' );
$identity -> emailAddress = $accountData [ 'emailaddress' ];
$identity -> realName = $accountData [ 'realname' ];
//$identity->default = true;
$identity -> default = ( bool ) $accountData [ 'active' ];
$identity -> organization = $accountData [ 'organization' ];
$identity -> signature = $accountData [ 'signatureid' ];
$identity -> id = $accountData [ 'id' ];
$isActive = ( bool ) $accountData [ 'active' ];
return array ( 'icServer' => $icServer , 'ogServer' => $ogServer , 'identity' => $identity , 'active' => $isActive );
}
function getAllAccountData ( & $_profileData )
{
2011-09-12 16:06:30 +02:00
if ( ! ( $_profileData instanceof ea_preferences ))
2011-07-01 12:37:47 +02:00
die ( __FILE__ . ': ' . __LINE__ );
$AllAccountData = parent :: getAccountData ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_id' ], 'all' );
#_debug_array($accountData);
foreach ( $AllAccountData as $key => $accountData )
{
$icServer = CreateObject ( 'emailadmin.defaultimap' );
$icServer -> ImapServerId = $accountData [ 'id' ];
$icServer -> encryption = isset ( $accountData [ 'ic_encryption' ]) ? $accountData [ 'ic_encryption' ] : 1 ;
$icServer -> host = $accountData [ 'ic_hostname' ];
$icServer -> port = isset ( $accountData [ 'ic_port' ]) ? $accountData [ 'ic_port' ] : 143 ;
$icServer -> validatecert = isset ( $accountData [ 'ic_validatecertificate' ]) ? ( bool ) $accountData [ 'ic_validatecertificate' ] : 1 ;
$icServer -> username = $accountData [ 'ic_username' ];
$icServer -> loginName = $accountData [ 'ic_username' ];
$icServer -> password = $accountData [ 'ic_password' ];
$icServer -> enableSieve = isset ( $accountData [ 'ic_enable_sieve' ]) ? ( bool ) $accountData [ 'ic_enable_sieve' ] : 1 ;
$icServer -> sieveHost = $accountData [ 'ic_sieve_server' ];
$icServer -> sievePort = isset ( $accountData [ 'ic_sieve_port' ]) ? $accountData [ 'ic_sieve_port' ] : 2000 ;
if ( $accountData [ 'ic_folderstoshowinhome' ]) $icServer -> folderstoshowinhome = $accountData [ 'ic_folderstoshowinhome' ];
if ( $accountData [ 'ic_trashfolder' ]) $icServer -> trashfolder = $accountData [ 'ic_trashfolder' ];
if ( $accountData [ 'ic_sentfolder' ]) $icServer -> sentfolder = $accountData [ 'ic_sentfolder' ];
if ( $accountData [ 'ic_draftfolder' ]) $icServer -> draftfolder = $accountData [ 'ic_draftfolder' ];
if ( $accountData [ 'ic_templatefolder' ]) $icServer -> templatefolder = $accountData [ 'ic_templatefolder' ];
2012-11-22 13:26:04 +01:00
$ogServer = new emailadmin_smtp ();
2011-07-01 12:37:47 +02:00
$ogServer -> SmtpServerId = $accountData [ 'id' ];
$ogServer -> host = $accountData [ 'og_hostname' ];
$ogServer -> port = isset ( $accountData [ 'og_port' ]) ? $accountData [ 'og_port' ] : 25 ;
$ogServer -> smtpAuth = ( bool ) $accountData [ 'og_smtpauth' ];
if ( $ogServer -> smtpAuth ) {
$ogServer -> username = $accountData [ 'og_username' ];
$ogServer -> password = $accountData [ 'og_password' ];
}
$identity = CreateObject ( 'emailadmin.ea_identity' );
$identity -> emailAddress = $accountData [ 'emailaddress' ];
$identity -> realName = $accountData [ 'realname' ];
//$identity->default = true;
$identity -> default = ( bool ) $accountData [ 'active' ];
$identity -> organization = $accountData [ 'organization' ];
$identity -> signature = $accountData [ 'signatureid' ];
$identity -> id = $accountData [ 'id' ];
$isActive = ( bool ) $accountData [ 'active' ];
$out [ $accountData [ 'id' ]] = array ( 'icServer' => $icServer , 'ogServer' => $ogServer , 'identity' => $identity , 'active' => $isActive );
}
return $out ;
}
function getUserDefinedIdentities ()
{
2012-12-14 13:19:47 +01:00
$profileID = emailadmin_bo :: getUserDefaultProfileID ();
2011-07-01 12:37:47 +02:00
$profileData = $this -> boemailadmin -> getUserProfile ( 'felamimail' );
2012-12-14 13:19:47 +01:00
if ( ! ( $profileData instanceof ea_preferences ) || ! ( $profileData -> ic_server [ $profileID ] instanceof defaultimap )) {
2011-07-01 12:37:47 +02:00
return false ;
}
2012-10-04 15:50:26 +02:00
if ( $profileData -> userDefinedAccounts || $profileData -> userDefinedIdentities )
2011-07-01 12:37:47 +02:00
{
// get user defined accounts
$allAccountData = $this -> getAllAccountData ( $profileData );
2012-10-04 15:50:26 +02:00
if ( $allAccountData )
2011-07-01 12:37:47 +02:00
{
foreach ( $allAccountData as $tmpkey => $accountData )
{
$accountArray [] = $accountData [ 'identity' ];
}
return $accountArray ;
}
}
return array ();
}
/**
* getPreferences - fetches the active profile for a user
*
2012-10-04 15:50:26 +02:00
* @ param boolean $getUserDefinedProfiles
* @ param int $_profileID - use this profile to be set its prefs as active profile ( 0 )
2011-07-29 11:22:33 +02:00
* @ param string $_appName - the app the profile is fetched for
2012-11-19 14:24:00 +01:00
* @ param int $_singleProfileToFetch - single Profile to fetch no merging of profileData ; emailadminprofiles only ; for Administrative use only ( by now )
2012-10-04 15:50:26 +02:00
* @ return object ea_preferences object with the active emailprofile set to ID = 0
2011-07-01 12:37:47 +02:00
*/
2012-11-19 14:24:00 +01:00
function getPreferences ( $getUserDefinedProfiles = true , $_profileID = 0 , $_appName = 'felamimail' , $_singleProfileToFetch = 0 )
2011-07-01 12:37:47 +02:00
{
2012-10-04 15:50:26 +02:00
if ( isset ( $this -> sessionData [ 'profileData' ]) && ( $this -> sessionData [ 'profileData' ] instanceof ea_preferences ))
2011-07-01 12:37:47 +02:00
{
$this -> profileData = $this -> sessionData [ 'profileData' ];
}
2012-11-19 14:24:00 +01:00
if (( ! ( $this -> profileData instanceof ea_preferences ) && $_singleProfileToFetch == 0 ) || ( $_singleProfileToFetch != 0 && ! isset ( $this -> profileData -> icServer [ $_singleProfileToFetch ])))
2011-07-01 12:37:47 +02:00
{
$GLOBALS [ 'egw' ] -> preferences -> read_repository ();
$userPreferences = $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'felamimail' ];
$imapServerTypes = $this -> boemailadmin -> getIMAPServerTypes ();
2012-11-19 14:24:00 +01:00
$profileData = $this -> boemailadmin -> getUserProfile ( $_appName , '' ,( $_singleProfileToFetch < 0 ? - $_singleProfileToFetch : '' )); // by now we assume only one profile to be returned
2012-10-04 15:50:26 +02:00
$icServerKeys = array_keys (( array ) $profileData -> ic_server );
2011-07-01 12:37:47 +02:00
$icProfileID = array_shift ( $icServerKeys );
2012-10-04 15:50:26 +02:00
$ogServerKeys = array_keys (( array ) $profileData -> og_server );
2011-07-01 12:37:47 +02:00
$ogProfileID = array_shift ( $ogServerKeys );
2012-11-19 14:24:00 +01:00
//error_log(__METHOD__.__LINE__.' ServerProfile(s)Fetched->'.array2string(count($profileData->ic_server)));
2012-10-04 15:50:26 +02:00
//may be needed later on, as it may hold users Identities connected to MailAlternateAdresses
$IdIsDefault = 0 ;
$rememberIdentities = $profileData -> identities ;
foreach ( $rememberIdentities as $adkey => $ident )
{
if ( $ident -> default ) $IdIsDefault = $ident -> id ;
$profileData -> identities [ $adkey ] -> default = false ;
}
if ( ! ( $profileData instanceof ea_preferences ) || ! ( $profileData -> ic_server [ $icProfileID ] instanceof defaultimap ))
2011-07-01 12:37:47 +02:00
{
return false ;
}
// set the emailadminprofile as profile 0; it will be assumed the active one (if no other profiles are active)
$profileData -> setIncomingServer ( $profileData -> ic_server [ $icProfileID ], 0 );
$profileID = $icProfileID ;
$profileData -> setOutgoingServer ( $profileData -> og_server [ $ogProfileID ], 0 );
$profileData -> setIdentity ( $profileData -> identities [ $icProfileID ], 0 );
$userPrefs = $this -> mergeUserAndProfilePrefs ( $userPreferences , $profileData , $icProfileID );
2012-10-04 15:50:26 +02:00
$rememberID = array (); // there may be more ids to be rememered
$maxId = $icProfileID > 0 ? $icProfileID : 0 ;
$minId = $icProfileID < 0 ? $icProfileID : 0 ;
2011-07-01 12:37:47 +02:00
//$profileData->setPreferences($userPrefs,0);
2012-10-04 15:50:26 +02:00
if ( $profileData -> userDefinedAccounts && $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'felamimail' ] && $getUserDefinedProfiles )
2011-07-01 12:37:47 +02:00
{
// get user defined accounts (only fetch the active one(s), as we call it without second parameter)
// we assume only one account may be active at once
$allAccountData = $this -> getAllAccountData ( $profileData );
foreach (( array ) $allAccountData as $k => $accountData )
{
// set defined IMAP server
2011-09-12 16:06:30 +02:00
if (( $accountData [ 'icServer' ] instanceof defaultimap ))
2011-07-01 12:37:47 +02:00
{
$profileData -> setIncomingServer ( $accountData [ 'icServer' ], $k );
$userPrefs = $this -> mergeUserAndProfilePrefs ( $userPreferences , $profileData , $k );
//$profileData->setPreferences($userPrefs,$k);
}
// set defined SMTP Server
2012-11-22 13:26:04 +01:00
if (( $accountData [ 'ogServer' ] instanceof emailadmin_smtp ))
2011-07-01 12:37:47 +02:00
$profileData -> setOutgoingServer ( $accountData [ 'ogServer' ], $k );
2012-10-04 15:50:26 +02:00
if (( $accountData [ 'identity' ] instanceof ea_identity ))
{
$profileData -> setIdentity ( $accountData [ 'identity' ], $k );
$rememberID [] = $k ; // remember Identity as already added
if ( $k > 0 && $k > $maxId ) $maxId = $k ;
if ( $k < 0 && $k < $minId ) $minId = $k ;
}
2011-07-01 12:37:47 +02:00
if ( empty ( $_profileID ))
{
$setAsActive = $accountData [ 'active' ];
//if($setAsActive) error_log(__METHOD__.__LINE__." Setting Profile with ID=$k (using Active Info) for ActiveProfile");
}
else
{
$setAsActive = ( $_profileID == $k );
//if($setAsActive) error_log(__METHOD__.__LINE__." Setting Profile with ID=$_profileID for ActiveProfile");
}
2012-10-04 15:50:26 +02:00
if ( $setAsActive )
2011-07-01 12:37:47 +02:00
{
// replace the global defined IMAP Server
2011-09-12 16:06:30 +02:00
if (( $accountData [ 'icServer' ] instanceof defaultimap ))
2011-07-01 12:37:47 +02:00
{
$profileID = $k ;
$profileData -> setIncomingServer ( $accountData [ 'icServer' ], 0 );
$userPrefs = $this -> mergeUserAndProfilePrefs ( $userPreferences , $profileData , $k );
//$profileData->setPreferences($userPrefs,0);
}
// replace the global defined SMTP Server
2012-11-22 13:26:04 +01:00
if (( $accountData [ 'ogServer' ] instanceof emailadmin_smtp ))
2011-07-01 12:37:47 +02:00
$profileData -> setOutgoingServer ( $accountData [ 'ogServer' ], 0 );
// replace the global defined identity
2011-09-12 16:06:30 +02:00
if (( $accountData [ 'identity' ] instanceof ea_identity )) {
2011-07-01 12:37:47 +02:00
//_debug_array($profileData);
$profileData -> setIdentity ( $accountData [ 'identity' ], 0 );
2012-10-04 15:50:26 +02:00
$profileData -> identities [ 0 ] -> default = true ;
$rememberID [] = $IdIsDefault = $accountData [ 'identity' ] -> id ;
2011-07-01 12:37:47 +02:00
}
}
}
}
2012-10-04 15:50:26 +02:00
if ( $profileData -> userDefinedIdentities && $GLOBALS [ 'egw_info' ][ 'user' ][ 'apps' ][ 'felamimail' ])
2011-07-01 12:37:47 +02:00
{
$allUserIdentities = $this -> getUserDefinedIdentities ();
2012-10-04 15:50:26 +02:00
if ( is_array ( $allUserIdentities ))
2011-07-01 12:37:47 +02:00
{
2012-10-04 15:50:26 +02:00
$i = $maxId + 1 ;
$y = $minId - 1 ;
2011-07-01 12:37:47 +02:00
foreach ( $allUserIdentities as $tmpkey => $id )
{
2012-10-04 15:50:26 +02:00
if ( ! in_array ( $id -> id , $rememberID ))
2011-07-01 12:37:47 +02:00
{
$profileData -> setIdentity ( $id , $i );
$i ++ ;
}
}
}
}
2012-10-05 12:08:23 +02:00
// make sure there is one profile marked as default (either 0 or the one found)
$profileData -> identities [ $IdIsDefault ] -> default = true ;
2012-10-04 15:50:26 +02:00
2011-07-01 12:37:47 +02:00
$userPrefs = $this -> mergeUserAndProfilePrefs ( $userPreferences , $profileData , $profileID );
$profileData -> setPreferences ( $userPrefs );
//_debug_array($profileData);#exit;
$this -> sessionData [ 'profileData' ] = $this -> profileData = $profileData ;
$this -> saveSessionData ();
//_debug_array($this->profileData);
}
return $this -> profileData ;
}
function mergeUserAndProfilePrefs ( $userPrefs , & $profileData , $profileID )
{
// echo "<p>backtrace: ".function_backtrace()."</p>\n";
2012-10-04 15:50:26 +02:00
if ( is_array ( $profileData -> ic_server [ $profileID ] -> folderstoshowinhome ) && ! empty ( $profileData -> ic_server [ $profileID ] -> folderstoshowinhome [ 0 ]))
2011-07-01 12:37:47 +02:00
{
$userPrefs [ 'mainscreen_showfolders' ] = implode ( ',' , $profileData -> ic_server [ $profileID ] -> folderstoshowinhome );
}
if ( ! empty ( $profileData -> ic_server [ $profileID ] -> sentfolder )) $userPrefs [ 'sentFolder' ] = $profileData -> ic_server [ $profileID ] -> sentfolder ;
if ( ! empty ( $profileData -> ic_server [ $profileID ] -> trashfolder )) $userPrefs [ 'trashFolder' ] = $profileData -> ic_server [ $profileID ] -> trashfolder ;
if ( ! empty ( $profileData -> ic_server [ $profileID ] -> draftfolder )) $userPrefs [ 'draftFolder' ] = $profileData -> ic_server [ $profileID ] -> draftfolder ;
if ( ! empty ( $profileData -> ic_server [ $profileID ] -> templatefolder )) $userPrefs [ 'templateFolder' ] = $profileData -> ic_server [ $profileID ] -> templatefolder ;
if ( empty ( $userPrefs [ 'deleteOptions' ]))
$userPrefs [ 'deleteOptions' ] = 'mark_as_deleted' ;
if ( ! empty ( $userPrefs [ 'trash_folder' ]))
$userPrefs [ 'move_to_trash' ] = True ;
if ( ! empty ( $userPrefs [ 'sent_folder' ]))
{
if ( ! isset ( $userPrefs [ 'sendOptions' ]) || empty ( $userPrefs [ 'sendOptions' ])) $userPrefs [ 'sendOptions' ] = 'move_to_sent' ;
}
2013-04-08 14:25:57 +02:00
/* not used anymore
2011-07-29 14:41:08 +02:00
if ( ! empty ( $userPrefs [ 'email_sig' ])) $userPrefs [ 'signature' ] = $userPrefs [ 'email_sig' ];
2013-04-08 14:25:57 +02:00
*/
if ( isset ( $userPrefs [ 'email_sig' ])) unset ( $userPrefs [ 'email_sig' ]);
2011-07-01 12:37:47 +02:00
return $userPrefs ;
}
function saveAccountData ( $_icServer , $_ogServer , $_identity )
{
if ( is_object ( $_icServer ) && ! isset ( $_icServer -> validatecert )) {
$_icServer -> validatecert = true ;
}
if ( isset ( $_icServer -> host )) {
$_icServer -> sieveHost = $_icServer -> host ;
}
2011-09-28 13:30:59 +02:00
// unset the session data
2011-07-01 12:37:47 +02:00
$this -> sessionData = array ();
$this -> saveSessionData ();
2011-09-28 13:30:59 +02:00
//error_log(__METHOD__.__LINE__.array2string($_icServer));
emailadmin_bo :: unsetCachedObjects ( $_identity -> id );
2011-07-01 12:37:47 +02:00
return parent :: saveAccountData ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_id' ], $_icServer , $_ogServer , $_identity );
}
function deleteAccountData ( $_identity )
{
if ( is_array ( $_identity )) {
foreach ( $_identity as $tmpkey => $id )
{
if ( $id -> id ) {
$identity [] = $id -> id ;
} else {
$identity [] = $id ;
}
}
} else {
$identity = $_identity ;
}
$this -> sessionData = array ();
$this -> saveSessionData ();
parent :: deleteAccountData ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_id' ], $identity );
}
2013-04-23 09:38:55 +02:00
function setProfileActive ( $_status , $_identity = NULL , $_identityOnly = false )
2011-07-01 12:37:47 +02:00
{
$this -> sessionData = array ();
$this -> saveSessionData ();
2011-07-11 13:19:25 +02:00
if ( ! empty ( $_identity ) && $_status == true )
2011-07-01 12:37:47 +02:00
{
2011-07-11 13:19:25 +02:00
//error_log(__METHOD__.__LINE__.' change status of Profile '.$_identity.' to '.$_status);
2011-07-01 12:37:47 +02:00
// globals preferences add appname varname value
2013-04-23 09:38:55 +02:00
if ( ! $_identityOnly ) $GLOBALS [ 'egw' ] -> preferences -> add ( 'felamimail' , 'ActiveProfileID' , $_identity , 'user' );
2011-07-01 12:37:47 +02:00
// save prefs
2013-04-23 09:38:55 +02:00
if ( ! $_identityOnly ) $GLOBALS [ 'egw' ] -> preferences -> save_repository ( true );
if ( ! $_identityOnly ) egw_cache :: setSession ( 'felamimail' , 'activeProfileID' , $_identity );
2011-07-01 12:37:47 +02:00
}
2013-04-23 09:38:55 +02:00
// the parentCall only saves the database value
2011-07-01 12:37:47 +02:00
parent :: setProfileActive ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'account_id' ], $_status , $_identity );
}
}
?>